function getFieldHTML($field, $required) { $html = ''; $pID = $field->value; $class = $required == 1 ? ' required' : ''; $disabled = ''; if ($this->_view === 'register') { // get pType from registration session OR defaultPType $pID = XiptFactory::getPluginHandler()->getRegistrationPType(); $html = '<input type="hidden" id="field' . $field->id . '" name="field' . $field->id . '" value="' . $pID . '" />'; $pName = XiptLibProfiletypes::getProfiletypeName($pID); $html .= $pName; return $html; } // it might be some other user (in case of admin is editing profile) $user = JFactory::getUser(); $userid = $user->id; if (!(int) $pID) { $pID = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE'); XiptError::assert($pID, XiptText::_("USERID {$pID} DOES_NOT_EXIST"), XiptError::ERROR); } $visiblePT = XiptLibProfiletypes::getProfiletypeArray(array('visible' => 1)); $allowToChangePType = $this->_params->get('allow_user_to_change_ptype_after_reg', 0); $allowToChangePType = $allowToChangePType && array_key_exists($pID, $visiblePT) || XiptHelperUtils::isAdmin($user->id); //if not allowed then show disabled view of ptype if ($allowToChangePType == false) { $pName = XiptLibProfiletypes::getProfileTypeName($pID); $pName = $pName; $html = '<input type="hidden" id="field' . $field->id . '" name="field' . $field->id . '" value="' . $pID . '" />'; return $html . $pName; } $mainframe = JFactory::getApplication(); if ($mainframe->isAdmin() == true || XiptHelperUtils::isAdmin($user->id)) { $filter = array('published' => 1); } else { $filter = array('published' => 1, 'visible' => 1); } // user can change profiletype, add information $pTypes = XiptLibProfiletypes::getProfiletypeArray($filter); $html = '<select id="field' . $field->id . '" name="field' . $field->id . '" ' . $disabled . ' class="hasTip select' . $class . ' inputbox" title="' . $field->name . '::' . htmlentities($field->tips) . '">'; $selectedElement = 0; if (!empty($pTypes)) { foreach ($pTypes as $pType) { $selected = $pType->id == $pID ? ' selected="selected"' : ''; if (!empty($selected)) { $selectedElement++; } $html .= '<option value="' . $pType->id . '"' . $selected . '>' . $pType->name . '</option>'; } } $html .= '</select>'; $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;"> </span>'; return $html; }
function getTemplateValue($value, $userid) { // during registration if ($this->_view == 'register') { $pID = XiptFactory::getPluginHandler()->getRegistrationPType(); $tName = XiptLibProfiletypes::getProfileTypeData($pID, 'template'); return $tName; } if ($value) { $tName = $value; } else { //a valid or default value $tName = XiptLibProfiletypes::getUserData($userid, 'TEMPLATE'); } return $tName; }
/** * @param $instance * @return CConfig */ function updateCommunityConfig(&$instance, $userId = null) { // skip these calls from backend if (JFactory::getApplication()->isAdmin()) { return true; } $loggedInUser = JFactory::getUser($userId); $pID = XiptLibProfiletypes::getUserData($loggedInUser->id, 'PROFILETYPE'); if (JRequest::getVar('view') === 'register') { $pluginHandler = XiptFactory::getPluginHandler(); $pID = $pluginHandler->getRegistrationPType(); } XiptError::assert($pID, sprintf(XiptText::_("PID_IS_NOT_VALID"), $pID), XiptError::ERROR); $params = XiptLibProfiletypes::getParams($pID); if ($params) { $allParams = $params->toArray(); if (!empty($allParams)) { foreach ($allParams as $key => $value) { $instance->set($key, $value); } } } //means guest is looking user profile , // so we will show them default template $visitingUser = JRequest::getInt('userid', $loggedInUser->id); //$visitingUser = 0 means loggen-in-user is looking their own profile //so we set $visitingUser as logged-in-user //if in case user is already logged in //then honour his template else return and honour global settings if ($visitingUser <= 0) { return true; } //$visitingUser > 0 means a valid-user to visit profile //so we will show them profile in user template //so update the template in configuration $template = XiptLibProfiletypes::getUserData($visitingUser, 'TEMPLATE'); //now update template @template if ($template) { $instance->set('template', $template); } return true; }
function plgCommunityxipt_community($subject, $params) { parent::__construct($subject, $params); $this->_pluginHandler = XiptFactory::getPluginHandler(); }
function filterCommunityFields($userid, &$fields, $from) { //durin loadAllfields no user id avaialble // so we pick the pType from registration if ($userid == 0) { $pTypeID = XiptFactory::getPluginHandler()->getRegistrationPType(); } else { $pTypeID = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE'); } //(fields) Privacy should not be applicable on Admin // if(XiptHelperUtils::isAdmin($userid) == true){ // return true; // } // filter the fields as per profiletype $model = XiptFactory::getInstance('Profilefields', 'model'); $model->getFieldsForProfiletype($fields, $pTypeID, $from); }