Example #1
0
    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;">&nbsp;</span>';
        return $html;
    }
Example #2
0
 function getFieldData($value = 0)
 {
     $pID = $value;
     if (!$pID) {
         //get value from profiletype field from xipt_users table
         //not required to get data from getUser() fn b'coz we call this fn in
         //getViewableprofile only.
         $userid = JRequest::getVar('userid', 0);
         XiptError::assert($userid, XiptText::_("USERID {$userid} DOES_NOT_EXIST"), XiptError::ERROR);
         $pID = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE');
     }
     $pName = XiptLibProfiletypes::getProfiletypeName($pID);
     return $pName;
 }
Example #3
0
 public static function getPayplansMessage()
 {
     $data = self::getProfiletypeInfoFromPayplans();
     $msgOption = XiptFactory::getSettings('subscription_message', 'b');
     $pTypeName = XiptLibProfiletypes::getProfiletypeName($data['profiletype']);
     if ($msgOption === 'pl') {
         return XiptText::sprintf('COM_XIPT_ALREADY_SELECTED_PLAN_AS_ONLYPLAN', $data['plan']);
     }
     if ($msgOption === 'pt') {
         return XiptText::sprintf('COM_XIPT_ALREADY_SELECTED_PLAN_AS_ONLY_PTYPE', $pTypeName);
     }
     if ($msgOption === 'no') {
         return false;
     }
     return XiptText::sprintf('COM_XIPT_ALREADY_SELECTED_PLAN_AS_BOTH', $data['plan'], $pTypeName);
 }
Example #4
0
 function getProfileTypeName($profileTypeId)
 {
     return XiptLibProfiletypes::getProfiletypeName($profileTypeId);
 }
Example #5
0
 function integrateRegistrationWithPType()
 {
     $aecExists = XiptLibAec::isAecExists();
     $payplansExists = XiptLibPayplans::isPayplansExists();
     $subs_integrate = XiptFactory::getSettings('subscription_integrate', 0);
     $integrate_with = XiptFactory::getSettings('integrate_with', 0);
     $show_ptype_during_reg = XiptFactory::getSettings('show_ptype_during_reg', 0);
     $selectedProfiletypeID = $this->isPTypeExistInSession();
     if ($show_ptype_during_reg) {
         $link = "index.php?option=com_xipt&view=registration";
         // pType not selected : send to select profiletype
         if (!$selectedProfiletypeID) {
             $this->app->redirect(XiptRoute::_("index.php?option=com_xipt&view=registration", false));
             return;
         }
         // pType already selected
         if ($aecExists && $subs_integrate && $integrate_with == 'aec') {
             $url = XiptRoute::_('index.php?option=com_acctexp&task=subscribe', false);
             $msg = XiptLibAec::getAecMessage();
             if ($msg != false) {
                 $link = '<a id="xipt_back_link" href=' . $url . '>' . XiptText::_("CLICK_HERE") . '</a>';
                 $this->app->enqueueMessage($msg . ' ' . $link);
             }
             return;
         } else {
             $url = XiptRoute::_('index.php?option=com_xipt&view=registration&ptypeid=' . $selectedProfiletypeID . '&reset=true', false);
             $selectedpTypeName = XiptLibProfiletypes::getProfiletypeName($selectedProfiletypeID);
             $msg = sprintf(XiptText::_('CURRENT_PTYPE_AND_CHANGE_PTYPE_OPTION'), $selectedpTypeName);
             $link = '<a id="xipt_back_link" href=' . $url . '>' . XiptText::_("CLICK_HERE") . '</a>';
             $this->app->enqueueMessage($msg . ' ' . $link);
             return;
         }
     } else {
         if ($subs_integrate) {
             if ($payplansExists && $integrate_with == 'payplans') {
                 $url = XiptRoute::_('index.php?option=com_payplans&view=plan', false);
                 $msg = XiptLibPayplans::getPayplansMessage();
                 if ($msg != false) {
                     $link = '<a id="xipt_back_link" href=' . $url . '>' . XiptText::_("CLICK_HERE") . '</a>';
                     $this->app->enqueueMessage($msg . ' ' . $link);
                 }
                 return;
             }
         }
     }
     // if pType is not set, collect default pType
     // set it in session
     if (!$selectedProfiletypeID) {
         $pType = $this->getRegistrationPType();
         $this->setDataInSession('SELECTED_PROFILETYPE_ID', $pType);
         return;
     }
     return;
 }