Exemplo n.º 1
0
    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;">&nbsp;</span>';
        return $html;
    }
Exemplo n.º 2
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;
    }
Exemplo n.º 3
0
 function performACLCheck($ajax = false, $callArray, $args)
 {
     //Return if admin
     $userId = JFactory::getUser()->id;
     if (XiptHelperUtils::isAdmin($userId)) {
         return false;
     }
     $option = JRequest::getVar('option');
     $feature = JRequest::getCmd('view');
     $task = JRequest::getCmd('task');
     // depending upon call get feature and task, might be objectID
     if ($ajax) {
         $option = 'com_community';
         $feature = JString::strtolower($callArray[0]);
         $task = JString::strtolower($callArray[1]);
     }
     // if user is uploading avatar at the time of registration then
     // the user id will be availabale from tmpuser
     if ($option == 'com_community' && $feature == 'register' && ($task == 'registerAvatar' || $task == 'registerSucess')) {
         $userId = JFactory::getSession()->get('tmpUser', '')->id;
     }
     $viewuserid = JRequest::getVar('userid', 0);
     // assign into one array
     $info['option'] = $option;
     $info['view'] = $feature;
     $info['task'] = strtolower($task);
     $info['userid'] = $userId;
     $info['viewuserid'] = $viewuserid;
     $info['ajax'] = $ajax;
     $info['args'] = $args;
     //get all published rules
     $rules = XiptAclFactory::getAclRulesInfo(array('published' => 1));
     if (empty($rules)) {
         return false;
     }
     foreach ($rules as $rule) {
         $aclObject = XiptAclFactory::getAclObject($rule->aclname);
         $aclObject->bind($rule);
         if (false == $aclObject->isApplicable($info)) {
             continue;
         }
         if (false == $aclObject->checkViolation($info)) {
             //rule might update viewuserid, pass corerct id to next rule
             $info['viewuserid'] = $viewuserid;
             continue;
         }
         $aclObject->handleViolation($info);
         break;
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * Save user's joomla-user-type
  * @param $userid
  * @param $newUsertype
  * @return true/false
  */
 function updateJoomlaUserType($userid, $newUsertype = JOOMLA_USER_TYPE_NONE)
 {
     //do not change usertypes for admins
     if (XiptHelperUtils::isAdmin($userid) == true || 0 == $userid || $newUsertype === JOOMLA_USER_TYPE_NONE) {
         return false;
     }
     //self::reloadCUser($userid);
     $user = CFactory::getUser($userid);
     $authorize = JFactory::getACL();
     $user->set('usertype', $newUsertype);
     if (XIPT_JOOMLA_15) {
         $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
     } else {
         $group = CACL::getInstance();
         $groups[] = $group->getGroupID($newUsertype);
         JUserHelper::setUserGroups($userid, $groups);
     }
     $user->save();
     self::reloadCUser($userid);
     return true;
 }
Exemplo n.º 5
0
 function resetUserAvatar($pid, $newavatar, $oldavatar, $newavatarthumb)
 {
     //get all users for profiletype
     $users = XiptLibProfiletypes::getAllUsers($pid);
     //Change all avatar and thumb path in url formate
     $newavatar = XiptHelperUtils::getUrlpathFromFilePath($newavatar);
     $newavatarthumb = XiptHelperUtils::getUrlpathFromFilePath($newavatarthumb);
     $cnt = count($users);
     for ($i = 0; $i < $cnt; $i++) {
         //if user is admin unset value
         if (XiptHelperUtils::isAdmin($users[$i])) {
             unset($users[$i]);
         }
     }
     $users = array_values($users);
     $cnt = count($users);
     if ($cnt > 0) {
         // XITODO : Change IN query to sub query
         //update user avatar and thumb of all users who doesn't have custom avatar
         $query = new XiptQuery();
         $result = $query->update('#__community_users')->set(" avatar = '{$newavatar}' ")->set(" thumb = '{$newavatarthumb}' ")->where(" avatar = '{$oldavatar}' ")->where(" userid  IN (" . implode(",", $users) . ") ")->dbLoadQuery()->query();
         if (!$result) {
             return XiptError::raiseWarning(500, XiptText::_("ERROR_IN_DATABASE_WHEN_SAVING_AVATAR_IN_COMMUNITY_USER_TABLE"));
         }
         return true;
     }
 }
Exemplo n.º 6
0
 /**
  * This function will ensure that who is not allowed to change template
  * or profiletype the data should not be saved.
  *
  * @param $userId
  * @param $fieldValueCodes
  * @return true
  */
 function onBeforeProfileUpdate($userid, $fieldValueCodes)
 {
     // We NEVER send false from here. If profiletype should not be changed then
     // we simply store previous values. so correct values are always there during the
     // after event
     // TODO : array_key_exists Check for both fields exist in array or not
     $profileTypeValue =& $fieldValueCodes[PROFILETYPE_CUSTOM_FIELD_CODE];
     $templateValue =& $fieldValueCodes[TEMPLATE_CUSTOM_FIELD_CODE];
     // skip these calls from backend
     if (JFactory::getApplication()->isAdmin()) {
         return true;
     }
     // the use is admin, might be editing from frontend return true
     if (XiptHelperUtils::isAdmin($userid)) {
         return true;
     }
     // user is allowed or not.
     $allowToChangePType = XiptFactory::getSettings('allow_user_to_change_ptype_after_reg', 0);
     $oldPtype = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE');
     $allowToChangeTemplate = XiptHelperProfiletypes::getProfileTypeData($oldPtype, 'allowt');
     // not changing anything get data from table and set it
     if (!$allowToChangeTemplate || empty($templateValue)) {
         //reset to old users value
         $templateValue = XiptLibProfiletypes::getUserData($userid, 'TEMPLATE');
         //if user is changing profiletype then we should pick the template as per profiletype
         if ($allowToChangePType && $oldPtype != $profileTypeValue) {
             $templateValue = XiptLibProfiletypes::getProfiletypeData($profileTypeValue, 'template');
         }
     }
     // not allowed to change profiletype, get data from table and set it
     if (!$allowToChangePType || !$profileTypeValue) {
         $profileTypeValue = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE');
     }
     return true;
 }
Exemplo n.º 7
0
 function hideJSToolbar($userid)
 {
     // the user is admin, return true
     if (XiptHelperUtils::isAdmin($userid)) {
         return true;
     }
     XiptHelperJSToolbar::getMenusToHide($userid);
 }