function display($save = '', $pt = 0) { //trigger event $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeProfileTypeSelection'); // check for session // if does not exist redirect user to community page XiptHelperProfiletypes::checkSessionForProfileType(); //If not allowed to select PT for user then return if (XiptFactory::getSettings('show_ptype_during_reg') == 0) { $selectedProfiletypeID = XiptLibProfiletypes::getDefaultProfiletype(); XiptHelperProfiletypes::setProfileTypeInSession($selectedProfiletypeID); } // do some validation for visibility and publish of ptype if (JRequest::getVar('save', $save, 'POST') != '') { $selectedProfiletypeID = JRequest::getVar('profiletypes', $pt, 'POST'); if (XiptLibProfiletypes::validateProfiletype($selectedProfiletypeID, array('published' => 1, 'visible' => 1)) == false) { $msg = XiptText::_('INVALID_PROFILE_TYPE_SELECTED'); $link = XiptRoute::_('index.php?option=com_xipt&view=registration', false); $this->setRedirect($link, $msg); } $dispatcher->trigger('onAfterProfileTypeSelection', array(&$selectedProfiletypeID)); return true; } // Get the view $this->getView()->display(); }
public static function getProfiletype() { $defaultPtype = XiptLibProfiletypes::getDefaultProfiletype(); $session = JFactory::getSession(); $pid = $session->get('SELECTED_PROFILETYPE_ID', 0, 'XIPT'); if (!$pid) { return $defaultPtype; } return $pid; }
/** * Collect profileType from session, * is session does not have profiletype, return default one * * @return int */ function getRegistrationPType() { //get ptype from session $selectedProfiletypeID = $this->isPTypeExistInSession(); // pType exist in session if ($selectedProfiletypeID) { return $selectedProfiletypeID; } //no pType in session, return default value $defaultProfiletypeID = XiptLibProfiletypes::getDefaultProfiletype(); return $defaultProfiletypeID; }
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; }
public static function getProfiletype($planid) { $defaultPtype = XiptLibProfiletypes::getDefaultProfiletype(); //get MI of given planid; $planMIs = self::getMIntegration($planid); //check existance of plan and its microintegration if (!self::isPlanExists($planid) || count($planMIs) <= 0) { return $defaultPtype; } $validMIs = self::getExistingMI($planMIs); $query = new XiptQuery(); $result = $query->select('profiletype')->from('#__xipt_aec')->where(" planid IN (" . implode(',', $validMIs) . ") ")->dbLoadQuery()->loadResult(); if (!$result) { return $defaultPtype; } return $result; }
function remove($ids = array()) { $ids = JRequest::getVar('cid', $ids, 'post', 'array'); $link = XiptRoute::_('index.php?option=com_xipt&view=profiletypes', false); $i = 1; //XITODO : Clean and commonize it $defaultPtype = XiptLibProfiletypes::getDefaultProfiletype(); foreach ($ids as $id) { // can not delete default profiletype if ($id == $defaultPtype) { $message = XiptText::_('CAN_NOT_DELETE_DEFAULT_PROFILE_TYPE'); JFactory::getApplication()->enqueueMessage($message); continue; } if (!$this->getModel()->delete($id)) { // If there are any error when deleting, we just stop and redirect user with error. $message = XiptText::_('ERROR_IN_REMOVING_PROFILETYPE'); $this->setRedirect($link, $message); return false; } $i++; } $message = $i - 1 . ' ' . XiptText::_('PROFILETYPE_REMOVED'); $this->setRedirect($link, $message); }
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 getDefaultProfiletype() { return XiptLibProfiletypes::getDefaultProfiletype(); }
function ajaxCheckUsernameDuringFacebook(&$args, &$response) { $pluginHandler = new XiptLibPluginhandler(); $ptype = $pluginHandler->isPTypeExistInSession(); if (!$ptype) { //when no profiletype selected select default $ptype = XiptLibProfiletypes::getDefaultProfiletype(); //XiptError::assert($ptype, XiptText::_('PROFILE TYPE IS NOT SELECTED'), XiptError::WARNING); //return false; } // as per JomSocial code $email = $args[0]; if (XiptHelperRegistration::checkIfUsernameAllowed($email, $ptype)) { return true; } // invalid emails $msg = XiptText::_('XIPT_USERNAME_NOT_ALLOWED'); $response->addScriptCall('jQuery("#newusername").addClass("invalid");'); $response->addScriptCall('jQuery("#error-newusername").show();'); $response->addScriptCall('jQuery("#error-newusername").html("' . $msg . '");'); //$response->addScriptCall('false;'); return false; }