function onAfterRoute() { $app = JFactory::getApplication(); // get option, view and task $option = JRequest::getVar('option', 'BLANK'); $view = JRequest::getVar('view', 'BLANK'); $task = JRequest::getVar('task', 'BLANK'); $component = JRequest::getVar('component', 'BLANK'); $jsconfig = JRequest::getVar('jsconfiguration', 'BLANK'); if ($app->isAdmin() && $option == 'com_community' && $view == 'configuration' && $jsconfig == 'privacy') { $this->_addResetPrivacyScript(); return true; } if ($app->isAdmin()) { return false; } if ($option === 'com_community') { $userid = JFactory::getUser()->id; $this->_pluginHandler->hideJSToolbar($userid); } /* When XiPT is integrated with subscription method and user does not pay or subscribe any plan, * till then XiPT apply default profile-type. */ if ($option == 'com_community' && $task == 'registerUpdateProfile' && ($view == 'register' || $view == 'registration')) { $subscription = XiptFactory::getSettings('subscription_integrate', 0); if ($subscription) { // Change post data (only profile-type and template field). $profiletypeId = XiptHelperJomsocial::getFieldId(PROFILETYPE_CUSTOM_FIELD_CODE); $templateId = XiptHelperJomsocial::getFieldId(TEMPLATE_CUSTOM_FIELD_CODE); //set current PT in other variable for further use $defaultPT = XiptLibProfiletypes::getDefaultProfiletype(); $this->_pluginHandler->setDataInSession('sessionpt', JRequest::getVar("field{$profiletypeId}", $defaultPT)); JRequest::setVar("field{$profiletypeId}", $defaultPT); JRequest::setVar("field{$templateId}", XiptLibProfiletypes::getProfiletypeData($defaultPT, 'template')); } } // perform all acl check from here XiptAclHelper::performACLCheck(false, false, false); //do routine works $eventName = $this->_eventPreText . strtolower($option) . '_' . strtolower($view) . '_' . strtolower($task); //call defined event to handle work $exist = method_exists($this, $eventName); if ($exist) { $this->{$eventName}(); } return false; }
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 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; }