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(); }
function isRequired() { $defaultProfiletypeID = XiptFactory::getSettings('defaultProfiletypeID', 0); if ($defaultProfiletypeID && XiptLibProfiletypes::validateProfiletype($defaultProfiletypeID)) { return false; } return true; }
function ajaxShowNewUserForm(&$args, &$response) { $mySess = JFactory::getSession(); //Set facebook variable in session so we can redirect user //to plan selection page after login //XITODO : we will remove this when aec support fbc $aecExists = XiptLibAec::isAecExists(); if ($aecExists) { $mySess->set('FROM_FACEBOOK', true, 'XIPT'); } /*if ptype is not required during registration then return */ if (!XiptFactory::getSettings('show_ptype_during_reg', 0)) { return true; } //if aec is integrate with ptype then we don't want to display //ptype selection page during facebook integration so return // pType already selected if ($aecExists && XiptFactory::getSettings('subscription_integrate', 0)) { return true; } /*check if ptype exist in session , * if true means we have already gone through ptype selection process * no need to process again , return */ if ($mySess->get('SELECTED_PROFILETYPE_ID', 0, 'XIPT')) { return true; } /*if not any above process fullfill the requirement then * we need to display ptype selection page */ $html = ''; if ($args && count($args)) { $selectedProfiletypeID = $args[0]; // validate values if (XiptLibProfiletypes::validateProfiletype($selectedProfiletypeID)) { $mySess->set('SELECTED_PROFILETYPE_ID', $selectedProfiletypeID, 'XIPT'); return true; } else { $html .= XiptText::_('PLEASE_ENTER_VALID_PROFILETYPE'); } } return self::getPtypeDisplayPageForFacebook($response, $html); }
function onBeforeProfileTypeSelection() { // if user comes from genaral registration link then return $ptypeid = JRequest::getVar('ptypeid', 0); // if user comes from a direct link (with profile type selected) // the reset will be false or does not exist // if user comes for selecting profile type again then reset is true $reset = JRequest::getVar('reset', false); if ($ptypeid == 0 || $reset == "true") { return true; } if (!XiptLibProfiletypes::validateProfiletype($ptypeid)) { return true; } XiptHelperProfiletypes::setProfileTypeInSession($ptypeid); return true; }
/** * This function is used to update user's profiletype * and its associated data. * @param $userid * @param $ptype * @param $template * @param $what * @return unknown_type */ function updateUserProfiletypeData($userid, $ptype, $template, $what = 'ALL') { XiptError::assert($userid, XiptText::_("USERID {$userid} IS_NOT_VALID"), XiptError::ERROR); $uModel = XiptFactory::getInstance('Users', 'model'); //store prev profiletype //IMP : must be first line, as we want to store prev profiletype $prevProfiletype = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE'); if ($what == 'profiletype' || $what == 'ALL') { // trigger an API for before profile type updation $dispatcher = JDispatcher::getInstance(); $userInfo['userid'] = $userid; $userInfo['oldPtype'] = $prevProfiletype; $userInfo['newPtype'] =& $ptype; /* we are sending refrence of new ptype * this should be validate before save */ $dispatcher->trigger('onBeforeProfileTypeChange', array($userInfo)); // validate profile type, may be changed in event triggered if (XiptLibProfiletypes::validateProfiletype($ptype) == false) { $ptype = XiptLibProfiletypes::getDefaultProfiletype(); } if (!$template) { $template = XiptLibProfiletypes::getProfileTypeData($ptype, 'template'); } //set profiletype and template for user in #__xipt_users table $result = $uModel->save(array('userid' => $userid, 'profiletype' => $ptype, 'template' => $template), $userid); //set profiletype and template field in #__community_fields_values table // also change the user's type in profiletype field. XiptLibJomsocial::updateCommunityCustomField($userid, $template, TEMPLATE_CUSTOM_FIELD_CODE); XiptLibJomsocial::updateCommunityCustomField($userid, $ptype, PROFILETYPE_CUSTOM_FIELD_CODE); // trigger an API for after profile type updation /* send success result */ //send the result as true $dispatcher->trigger('onAfterProfileTypeChange', array($ptype, $result)); } $feature = array(); $oldData = array(); $newData = array(); //set usertype acc to profiletype in #__user table if ($what == 'ALL' || $what == 'jusertype') { $feature[] = 'jusertype'; $oldData['jusertype'] = self::getProfiletypeData($prevProfiletype, 'jusertype'); $newData['jusertype'] = self::getProfiletypeData($ptype, 'jusertype'); } //set user avatar in #__community_users table if ($what == 'ALL' || $what == 'avatar') { $feature[] = 'avatar'; $oldData['avatar'] = self::getProfiletypeData($prevProfiletype, 'avatar'); $newAvatar = self::getProfiletypeData($ptype, 'avatar'); if (JString::stristr($newAvatar, 'components/com_community/assets/user.png')) { $newAvatar = ''; } $newData['avatar'] = $newAvatar; } //set user watermark if ($what == 'ALL' || $what == 'watermark') { $feature[] = 'watermark'; $oldData['watermark'] = self::getProfiletypeData($prevProfiletype, 'watermark'); $newData['watermark'] = self::getProfiletypeData($ptype, 'watermark'); } //assign the default group if ($what == 'ALL' || $what == 'group') { $feature[] = 'group'; $oldData['group'] = self::getProfiletypeData($prevProfiletype, 'group'); $newData['group'] = self::getProfiletypeData($ptype, 'group'); } //set privacy data if ($what == 'ALL' || $what == 'privacy') { $feature[] = 'privacy'; $pModel = XiptFactory::getInstance('profiletypes', 'model'); $oldPrivacy = $pModel->loadParams($prevProfiletype, 'privacy'); $newPrivacy = $pModel->loadParams($ptype, 'privacy'); $oldData['privacy'] = $oldPrivacy; $newData['privacy'] = $newPrivacy; } self::updateUserProfiletypeFilteredData($userid, $feature, $oldData, $newData); return true; }
function isValid($value, $required) { if (!$value) { return false; } if (!XiptLibProfiletypes::validateProfiletype($value)) { return false; } return true; }
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); }