function getFieldHTML($field, $required) { // it might be some other user (in case of admin is editing profile) $user =& JFactory::getUser(); $tName = $field->value; $templates = XiptHelperJomsocial::getTemplatesList(); $class = $required == 1 ? ' required' : ''; $selectedValue = $this->getTemplateValue($tName, $user->id); // XITODO : format it in proper way $allowToChangeTemplate = XiptHelperProfiletypes::getProfileTypeData(XiptLibProfiletypes::getUserData($user->id), 'allowt'); $allowToChangeTemplate = $allowToChangeTemplate || XiptHelperUtils::isAdmin($user->id); if (!$allowToChangeTemplate) { $html = '<input type="hidden" id="field' . $field->id . '" name="field' . $field->id . '" value="' . $selectedValue . '" />'; $html .= $selectedValue; return $html; } $html = '<select id="field' . $field->id . '" name="field' . $field->id . '" class="hasTip select' . $class . ' inputbox" title="' . $field->name . '::' . htmlentities($field->tips) . '">'; $selectedElement = 0; if (!empty($templates)) { foreach ($templates as $tmpl) { $selected = $tmpl == $selectedValue ? ' selected="selected"' : ''; if (!empty($selected)) { $selectedElement++; } $html .= '<option value="' . $tmpl . '"' . $selected . '>' . $tmpl . '</option>'; } } $html .= '</select>'; $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;"> </span>'; return $html; }
function isApplicable() { if (XiptHelperJomsocial::isSupportedJS()) { return false; } return true; }
public static function getInstance() { $suffix = JString::stristr(XiptHelperJomsocial::get_js_version(), 2.0) ? "Js20" : "Js18"; $classname = "XiptFieldsProfiletypes" . JString::ucfirst($suffix); if (class_exists($classname, true) === false) { XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("{$className} : CLASS_NOT_FOUND")); return false; } $instance = new $classname(); return $instance; }
function syncUpUserPT($start, $limit, $test = false) { $PTFieldId = XiptHelperJomsocial::getFieldId(PROFILETYPE_CUSTOM_FIELD_CODE); $TMFieldId = XiptHelperJomsocial::getFieldId(TEMPLATE_CUSTOM_FIELD_CODE); // we need first these fields to be exist if (!($PTFieldId && $TMFieldId)) { return false; } // get userids for syn-cp $result = $this->getUsertoSyncUp($start, $limit); $profiletype = XiPTLibProfiletypes::getDefaultProfiletype(); $template = XiPTLibProfiletypes::getProfileTypeData($profiletype, 'template'); $total = $this->totalUsers; $flag = false; if ($total > $limit) { //echo msg when users are syn-cp echo $this->getHTML($start, $total, $limit); if (JRequest::getVar('step', false) == false) { $this->_SynCpUser($result, $profiletype, $template); return -1; } //$start+=$limit; $flag = true; } $this->_SynCpUser($result, $profiletype, $template); // Continue user are continuesyn-cp if ($flag === true) { return -1; } if ($test) { return true; } $step = JRequest::getVar('step'); $msg = 'Total ' . ($limit * $step + count($result)) . ' users ' . XiptText::_('SYNCHORNIZED'); JFactory::getApplication()->enqueueMessage($msg); return true; }
function isAdminUserModelPatchRequired() { // no need to pacth the admin user model in jspt 2.0 if (JString::stristr(XiptHelperJomsocial::get_js_version(), "2.")) { return false; } // we need to patch User Model $filename = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'users.php'; if (JFile::exists($filename)) { if (!is_readable($filename)) { XiptError::raiseWarning(sprintf(XiptText::_('FILE_IS_NOT_READABLE_PLEASE_CHECK_PERMISSION'), $filename)); } $file = JFile::read($filename); $searchString = '$pluginHandler->onProfileLoad($userId, $result, __FUNCTION__);'; $count = substr_count($file, $searchString); if ($count >= 1) { return false; } return true; } return false; }
function event_com_xipt_registration_blank() { $app = JFactory::getApplication(); $subs_integrate = XiptFactory::getSettings('subscription_integrate', 0); $integrate_with = XiptFactory::getSettings('integrate_with', 0); if (!$subs_integrate) { return false; } //when integrated with AEC, set PT in session as per plan. if ($integrate_with == 'aec') { if (!XiptLibAec::isAecExists()) { return false; } // find selected profiletype from AEC $aecData = XiptLibAec::getProfiletypeInfoFromAEC(); // as user want to integrate the AEC so a plan must be selected // send user to profiletype selection page if ($aecData['planSelected'] == false) { $app->redirect(XiptRoute::_('index.php?option=com_acctexp&task=subscribe', false), XiptText::_('PLEASE_SELECT_AEC_PLAN_IT_IS_RQUIRED')); } // set selected profiletype in session $this->_pluginHandler->mySess->set('SELECTED_PROFILETYPE_ID', $aecData['profiletype'], 'XIPT'); } //when integrated with Payplans, no need to set PT in session //payplans itself set PT in session if ($integrate_with == 'payplans') { if (!XiptLibPayplans::isPayplansExists()) { return false; } // find selected profiletype from Payplans $payplansData = XiptLibPayplans::getProfiletypeInfoFromPayplans(); // as user want to integrate the Payplans so a plan must be selected // send user to profiletype selection page if ($payplansData['planSelected'] == false) { $app->redirect(XiptRoute::_('index.php?option=com_payplans&view=plan', false), XiptText::_('PLEASE_SELECT_AEC_PLAN_IT_IS_RQUIRED')); } } $app->redirect(XiptHelperJomsocial::getReturnURL()); return true; }
<?php /** * @Copyright Ready Bytes Software Labs Pvt. Ltd. (C) 2010- author-Team Joomlaxi * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html *@TODO : Include all helper files or other files in one common file and include that file **/ // no direct access if (!defined('_JEXEC')) { die('Restricted access'); } // add include files require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_xipt' . DS . 'includes.php'; // check for jom social supported version and show message if (!XiptHelperJomsocial::isSupportedJS()) { $msg = "ERROR : The JomSocial Current Version used by you is not supported for ProfileTypes."; JFactory::getApplication()->enqueueMessage($msg); } $controller = JRequest::getCmd('view', 'cpanel'); $controller = JString::strtolower($controller); $class = 'XiptController' . JString::ucfirst($controller); // Test if the object really exists in the current context if (!class_exists($class, true)) { XiptError::raiseError(__CLASS__ . '.' . __LINE__, sprintf(XiptText_("INVALID_CONTROLLER_OBJECT_CLASS_DEFINITION_DOES_NOT_EXISTS_IN_THIS_CONTEXT"), $class)); } $controller = new $class(); // Perform the Request task $task = JRequest::getCmd('task', 'display'); // Task's are methods of the controller. Perform the Request task $controller->execute($task); // Redirect if set by the controller
function getUserData($userid, $what = 'PROFILETYPE') { $results = array(); switch ($what) { case 'PROFILETYPE': if ($userid == 0) { return XiptFactory::getSettings('guestProfiletypeID', XiptFactory::getSettings('defaultProfiletypeID', 0)); } $getMe = PROFILETYPE_FIELD_IN_USER_TABLE; $defaultValue = XiptLibProfiletypes::getDefaultProfiletype(); break; case 'TEMPLATE': $getMe = TEMPLATE_FIELD_IN_USER_TABLE; $allTemplates = XiptHelperJomsocial::getTemplatesList(); $pID = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE'); $defaultValue = XiptLibProfiletypes::getProfileTypeData($pID, 'template'); //else get system template if (in_array($defaultValue, $allTemplates) === false) { $defaultValue = XiptLibProfiletypes::getDefaultTemplate(); } break; default: XiptError::raiseError('XIPT-SYSTEM-ERROR', 'XIPT System Error'); } $results = XiptFactory::getInstance('users', 'model')->loadRecords(0); // not a valid result OR value not set if (!$results || isset($results[$userid]) == false) { return $defaultValue; } $what = strtolower($what); return $results[$userid]->{$what}; }
function setProfileTypeInSession($selectedProfiletypeID) { // XITODO : move redirection to controller $mySess =& JFactory::getSession(); $redirectUrl = XiptHelperJomsocial::getReturnURL(); // validate values if (!XiptLibProfiletypes::validateProfiletype($selectedProfiletypeID)) { $msg = XiptText::_('PLEASE_ENTER_VALID_PROFILETYPE'); JFactory::getApplication()->redirect(XiptRoute::_('index.php?option=com_xipt&view=registration'), $msg); return; } //set value in session and redirect to destination url $mySess->set('SELECTED_PROFILETYPE_ID', $selectedProfiletypeID, 'XIPT'); JFactory::getApplication()->redirect($redirectUrl); }
function updateCommunityCustomField($userId, $value, $what = '') { //ensure we are calling it for correct field XiptError::assert($what == PROFILETYPE_CUSTOM_FIELD_CODE || $what == TEMPLATE_CUSTOM_FIELD_CODE, XiptText::_("CUSTOM_FIELD_DOES_NOT_EXIST"), XiptError::ERROR); // find the profiletype or template field // dont patch up the database. $res = XiptHelperJomsocial::getFieldId($what); // skip these calls from backend XiptError::assert($res); $field_id = $res; //if row does not exist $query = new XiptQuery(); $res = $query->select('*')->from('#__community_fields_values')->where(" user_id = {$userId} ", 'AND')->where(" field_id = {$field_id} ")->dbLoadQuery()->loadObject(); $db = JFactory::getDBO(); //record does not exist, insert it if (!$res) { $res = new stdClass(); $res->user_id = $userId; $res->field_id = $field_id; $res->value = $value; $db->insertObject('#__community_fields_values', $res, 'id'); if ($db->getErrorNum()) { XiptError::raiseError(__CLASS__ . '.' . __LINE__, $db->stderr()); } return true; } // change the type $res->user_id = $userId; $res->field_id = $field_id; $res->value = $value; $db->updateObject('#__community_fields_values', $res, 'id'); if ($db->getErrorNum()) { XiptError::raiseError(__CLASS__ . '.' . __LINE__, $db->stderr()); } return true; }