PDA

Zobacz pełną wersję : Plugin User Extended Fields for K2



KoPyT1
23-10-2011, 18:32
Witam,

mam problem z w/w pluginem, dałem radę usunąć pola, które mnie nie interesowały, jednak nie potrafię zrobić, aby pola z pluginu były wymagane przy rejestracji.
Czy ktoś mógłby mi pomóc?

register.php

<?php/**
* @version $Id: register.php 478 2010-06-16 16:11:42Z joomlaworks $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.gr
* @copyright Copyright (c) 2006 - 2010 JoomlaWorks, a business unit of Nuevvo Webware Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/


// no direct access
defined('_JEXEC') or die('Restricted access');


?>


<script type="text/javascript">
//<![CDATA[
window.onDomReady(function(){
document.formvalidator.setHandler('passverify', function (value){
return ($('password').value == value);
});
});
//]]>
</script>


<!-- K2 user register form -->


<?php if(isset($this->message)) $this->display('message'); ?>


<form action="<?php echo JRoute::_( 'index.php?option=com_user' ); ?>" enctype="multipart/form-data" method="post" id="josForm" name="josForm" class="form-validate">


<?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?>
<div class="componentheading<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>">
<?php echo $this->escape($this->params->get('page_title')); ?>
</div>
<?php endif; ?>


<div id="k2Container" class="k2AccountPage">


<table cellpadding="0" cellspacing="0">
<tr>
<th colspan="2"><?php echo JText::_( 'Account details' ); ?></th>
</tr>
<tr>
<td><label id="namemsg" for="name"><?php echo JText::_( 'Name' ); ?></label></td>
<td><input type="text" name="name" id="name" size="40" value="<?php echo $this->escape($this->user->get( 'name' )); ?>" class="inputbox required" maxlength="50" />
* </td>
</tr>
<tr>
<td><label id="usernamemsg" for="username"><?php echo JText::_( 'User name' ); ?></label></td>
<td><input type="text" id="username" name="username" size="40" value="<?php echo $this->escape($this->user->get( 'username' )); ?>" class="inputbox required validate-username" maxlength="25" />
* </td>
</tr>
<tr>
<td><label id="emailmsg" for="email"><?php echo JText::_( 'Email' ); ?></label></td>
<td><input type="text" id="email" name="email" size="40" value="<?php echo $this->escape($this->user->get( 'email' )); ?>" class="inputbox required validate-email" maxlength="100" />
* </td>
</tr>
<tr>
<td><label id="pwmsg" for="password"><?php echo JText::_( 'Password' ); ?></label></td>
<td><input class="inputbox required validate-password" type="password" id="password" name="password" size="40" value="" />
* </td>
</tr>
<tr>
<td><label id="pw2msg" for="password2"><?php echo JText::_( 'Verify Password' ); ?></label></td>
<td><input class="inputbox required validate-passverify" type="password" id="password2" name="password2" size="40" value="" />
* </td>
</tr>
<?php if(count(array_filter($this->K2Plugins))): ?>
<!-- K2 Plugin attached fields -->
<tr>
<th colspan="2"><?php echo JText::_( 'Informacje dodatkowe' ); ?></th>
</tr>
<?php foreach ($this->K2Plugins as $K2Plugin):?>
<?php if(!is_null($K2Plugin)): ?>
<tr>
<td colspan="2"><?php echo $K2Plugin->fields; ?></td>
</tr>
<tr>
<th colspan="2">Avatar</th>
</tr>
<!-- K2 attached fields -->

<tr>
<td><label id="imagemsg" for="image"><?php echo JText::_( 'User image (avatar)' ); ?></label></td>
<td><input type="file" id="image" name="image"/>
<?php if ($this->K2User->image): ?>
<img class="k2AdminImage" src="<?php echo JURI::root().'media/k2/users/'.$this->K2User->image; ?>" alt="<?php echo $this->user->name; ?>" />
<input type="checkbox" name="del_image" id="del_image" />
<label for="del_image"><?php echo JText::_('Check this box to delete current image or just upload a new image to replace the existing one'); ?></label>
<?php endif; ?></td>
</tr>

<?php endif;?>
<?php endforeach; ?>
<?php endif; ?>
</table>


<div class="k2AccountPageNotice"><?php echo JText::_( 'REGISTER_REQUIRED' ); ?></div>


<div class="k2AccountPageUpdate">
<button class="button validate" type="submit">
<?php echo JText::_('Register'); ?>
</button>
</div>


</div>


<input type="hidden" name="task" value="register_save" />
<input type="hidden" name="id" value="0" />
<input type="hidden" name="gid" value="0" />
<input type="hidden" name="K2UserForm" value="1" />
<?php echo JHTML::_( 'form.token' ); ?>


</form>




userextendedfields.php

<?php/*
// JoomlaWorks "User Extended Fields for K2" Plugin for Joomla! 1.5.x - Version 1.0
// Copyright (c) 2006 - 2010 JoomlaWorks, a business unit of Nuevvo Webware Ltd. All rights reserved.
// Released under the GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
// More info at http://www.joomlaworks.gr
// Designed and developed by the JoomlaWorks team
// *** Last update: May 13th, 2010 ***
*/


// no direct access
defined('_JEXEC') or die('Restricted access');


// Load the K2 plugin API
JLoader::register('K2Plugin', JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS .'lib'.DS.'k2plugin.php');


class plgK2Userextendedfields extends K2Plugin {


// Required global reference parameters
var $pluginName = 'userExtendedFields';
var $pluginNameHumanReadable = 'User Extended Fields for K2';
var $plgCopyrightsStart = "\n\n<!-- JoomlaWorks \"User Extended Fields for K2\" Plugin (v1.0) starts here -->\n";
var $plgCopyrightsEnd = "\n<!-- JoomlaWorks \"User Extended Fields for K2\" Plugin (v1.0) ends here -->\n\n";


function plgK2Userextendedfields(&$subject, $params) {
parent::__construct($subject, $params);
}

function onK2UserDisplay(&$user, &$params, $limitstart){

// API
$mainframe= &JFactory::getApplication();
$document = &JFactory::getDocument();

// Assign paths
$sitePath = JPATH_SITE;
$siteUrl = substr(JURI::root(), 0, -1);

// Check if plugin is enabled
if(JPluginHelper::isEnabled('k2',$this->pluginName)==false) return;

// Load the plugin language file the proper way
if($mainframe->isAdmin()){
JPlugin::loadLanguage( 'plg_k2_'.$this->pluginName );
} else {
JPlugin::loadLanguage( 'plg_k2_'.$this->pluginName, 'administrator' );
}

// ----------------------------------- Get plugin parameters -----------------------------------

// Global plugin params
$plugin =& JPluginHelper::getPlugin('k2',$this->pluginName);
$pluginGlobalParams = new JParameter($plugin->params);
$contactDetails = $pluginGlobalParams->get('contactDetails',0);
$socialProfiles = $pluginGlobalParams->get('socialProfiles',1);

// K2 User plugin specific params
$pluginParams = new K2Parameter($user->plugins,'',$this->pluginName);
if($contactDetails){
$address = $pluginParams->get('address');
$city = $pluginParams->get('city');
$stateOrProvince = $pluginParams->get('stateOrProvince');
$zipCode = $pluginParams->get('zipCode');
$country = $pluginParams->get('country');
$telephone = $pluginParams->get('telephone');
$mobile = $pluginParams->get('mobile');
}
if($socialProfiles){
$facebook = $pluginParams->get('facebook');
$twitter = $pluginParams->get('twitter');
$google = $pluginParams->get('google');
$linkedin = $pluginParams->get('linkedin');
$youtube = $pluginParams->get('youtube');
$vimeo = $pluginParams->get('vimeo');
$blip = $pluginParams->get('blip');
$flickr = $pluginParams->get('flickr');
$picasa = $pluginParams->get('picasa');
}

// ----------------------------------- Requirements -----------------------------------
require_once(dirname(__FILE__).DS.$this->pluginName.DS.'includes'.DS.'helper.php');


// ----------------------------------- Head tag includes -----------------------------------
$pluginCSS = userExtendedFieldsHelper::getTemplatePath($this->pluginName,'css/template.css');
$pluginCSS = $pluginCSS->http;
$pluginCSS = '
'.JHTML::_('behavior.mootools').'
<style type="text/css" media="all">
@import "'.$pluginCSS.'";
</style>
';


// Append head includes, but not when we're outputing raw content in K2
if(JRequest::getCmd('format')!='raw'){
userExtendedFieldsHelper::loadHeadIncludes($this->plgCopyrightsStart.$pluginCSS.$this->plgCopyrightsEnd);
}

// ----------------------------------- Fetch the template -----------------------------------
ob_start();
$getTemplatePath = userExtendedFieldsHelper::getTemplatePath($this->pluginName,'default.php');
$getTemplatePath = $getTemplatePath->file;
include($getTemplatePath);
$getTemplate = $this->plgCopyrightsStart.ob_get_contents().$this->plgCopyrightsEnd;
ob_end_clean();

// ----------------------------------- Output -----------------------------------
return $getTemplate;

}


} // End class