function handleViolation($data) { $fieldCount = count($data['args']['field']); $otherptype_arr = unserialize($this->aclparams->get('Xiprofiletypes')); //if any value is not saved for any field, then // by default add None profiletype //XITODO try to set return if (!isset($otherptype_arr) || empty($otherptype_arr)) { $otherptype_arr = array(XIPT_PROFILETYPE_NONE); } $userid = $data['viewuserid']; $otherpid = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE'); $selfprofiletype = $this->coreparams->get('core_profiletype', 0); $arr_field =& $data['args']['field']; for ($i = 0; $i < $fieldCount; $i++) { $field = $arr_field[$i]; if (is_object($field)) { $fieldId = $field->id; } else { $fieldId = $field['id']; } if (array_key_exists($fieldId, $otherptype_arr) && (in_array($otherpid, $otherptype_arr[$fieldId]) || in_array(0, $otherptype_arr[$fieldId]))) { unset($arr_field[$i]); continue; } } $fields = array_values($arr_field); }
function getMenusToHide($userid) { $jsmodel = XiptFactory::getInstance('jstoolbar', 'model'); $pID = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE'); $query = new XiptQuery(); $menuids = $query->select('menuid')->from('#__xipt_jstoolbar')->where(" `profiletype` = {$pID} ")->dbLoadQuery("", "")->loadResultArray(); if (empty($menuids)) { return false; } foreach ($menuids as $menuid) { $result = $jsmodel->getMenu($menuid); $hideMenu = XiptRoute::_("{$result->link}"); ob_start(); ?> joms.jQuery(document).ready(function(){ var menuUrl = "<?php echo $hideMenu; ?> ".replace(/\&\;/gi, "&"); joms.jQuery("a[href='" + menuUrl + "']").hide(); }); <?php $content = ob_get_contents(); ob_clean(); JFactory::getDocument()->addScriptDeclaration($content); } }
function formatData($value = 0) { $pID = $value; if (!$pID) { //get value from profiletype field from xipt_users table $userid = JRequest::getVar('userid', 0); $pID = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE'); } return $pID; }
/** * When user remove Avatar then set to default avatar as profile pix */ static function removeProfilePicture() { //when admin remove any avatar of user by admin panel then get userid // at default value,if user remove self avatar.(when fron end user login) $userId = JRequest::getVar('userid', JFactory::getUser()->id, 'POST'); $pType = XiptLibProfiletypes::getUserData($userId, 'PROFILETYPE'); $newPath = XiptLibProfiletypes::getProfiletypeData($pType, 'avatar'); self::_removeProfilePicture($userId, $pType, $newPath); $view = JRequest::getVar('view', 'profile', 'GET'); //$task = JRequest::getVar('task','profile','GET'); JFactory::getApplication()->redirect(CRoute::_("index.php?option=com_community&view={$view}&userid={$userId}", false), JText::_('CC_PROFILE_PICTURE_REMOVED')); }
function isApplicableOnSelfProfiletype($resourceAccesser) { $aclSelfPtype = $this->getACLAccesserProfileType(); $sessionPid = JFactory::getSession()->get('sessionpt', false, 'XIPT'); if ($sessionPid) { $selfPid = $sessionPid; } else { $selfPid = XiptLibProfiletypes::getUserData($resourceAccesser, 'PROFILETYPE'); } if (in_array($aclSelfPtype, array(XIPT_PROFILETYPE_ALL, $selfPid))) { return true; } return false; }
function getTemplateValue($value, $userid) { // during registration if ($this->_view == 'register') { $pID = XiptFactory::getPluginHandler()->getRegistrationPType(); $tName = XiptLibProfiletypes::getProfileTypeData($pID, 'template'); return $tName; } if ($value) { $tName = $value; } else { //a valid or default value $tName = XiptLibProfiletypes::getUserData($userid, 'TEMPLATE'); } return $tName; }
function getFieldData($field = array()) { $pID = 0; if (!empty($field) && isset($field['value'])) { $pID = $field['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; }
/** * The user data have been saved. * We will save user's data (profiletype and template) into Xipt tables * @param $userId * @param $saveSuccess * @return unknown_type */ function onAfterProfileUpdate($userId, $saveSuccess) { // data was not saved, do nothing if (false == $saveSuccess) { return true; } // the JomSocial already store values in field tables // now we need to apply that information to our tables // $cuser = CFactory::getUser($userId); // $profiletype = $cuser->getInfo(PROFILETYPE_CUSTOM_FIELD_CODE); // $template = $cuser->getInfo(TEMPLATE_CUSTOM_FIELD_CODE); $profiletype = XiptHelperUtils::getInfo($userId, PROFILETYPE_CUSTOM_FIELD_CODE); $template = XiptHelperUtils::getInfo($userId, TEMPLATE_CUSTOM_FIELD_CODE); // Changing Profile From Front End If The Template allow is None then Set Profiletype template. // If Template is Allowed on Profile Type Then Take User Define Template From Front End. $oldPtype = XiptLibProfiletypes::getUserData($userId, 'PROFILETYPE'); $OldallowToChangeTemplate = XiptHelperProfiletypes::getProfileTypeData($oldPtype, 'allowt'); $NewallowToChangeTemplate = XiptHelperProfiletypes::getProfileTypeData($profiletype, 'allowt'); //update profiletype only XiptLibProfiletypes::updateUserProfiletypeData($userId, $profiletype, $template, 'ALL'); //update template seperately $filter[] = 'template'; $allowToChangeTemplate = XiptFactory::getSettings('allow_templatechange', 0); if (($NewallowToChangeTemplate == 0 || $OldallowToChangeTemplate == 0) && $allowToChangeTemplate == 0) { $newData['template'] = XiptLibProfiletypes::getProfiletypeData($profiletype, 'template'); } else { $newData['template'] = $template; } XiptLibProfiletypes::updateUserProfiletypeFilteredData($userId, $filter, null, $newData); $this->showActivity($userId, $profiletype, $oldPtype); return true; }
function isApplicableOnOtherProfiletype($resourceOwner) { $otherptype = $this->getACLOwnerProfileType(); $otherpid = XiptLibProfiletypes::getUserData($resourceOwner, 'PROFILETYPE'); // REMOVING ,XIPT_PROFILETYPE_NONE, as it should not be here if (in_array($otherptype, array(XIPT_PROFILETYPE_ALL, $otherpid))) { return true; } return false; }
function getWatermark($userid) { $ptype = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE'); $watermarkInfo = XiptLibProfiletypes::getProfiletypeData($ptype, 'watermark'); if (!$watermarkInfo) { return false; } return $watermarkInfo; }
function filterCommunityFields($userid, &$fields, $from) { //durin loadAllfields no user id avaialble // so we pick the pType from registration if ($userid == 0) { $pTypeID = XiptFactory::getPluginHandler()->getRegistrationPType(); } else { $pTypeID = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE'); } //(fields) Privacy should not be applicable on Admin // if(XiptHelperUtils::isAdmin($userid) == true){ // return true; // } // filter the fields as per profiletype $model = XiptFactory::getInstance('Profilefields', 'model'); $model->getFieldsForProfiletype($fields, $pTypeID, $from); }
/** * returns user information * @param $userid : * @param $what : can be 'PROFILETYPE' or 'TEMPLATE' * @return unknown_type */ function getUserInfo($userid, $what = 'PROFILETYPE') { return XiptLibProfiletypes::getUserData($userid, $what); }
function isPrivacyAllow($myProfileID = null) { static $result = null; if ($result != null) { return $result; } $modelObj = XiptFactory::getInstance('profiletypes', 'model'); if (empty($myProfileID)) { $myProfileID = XiptLibProfiletypes::getUserData(JFactory::getUser()->id, 'PROFILETYPE'); } $privacyParams = $modelObj->loadParams($myProfileID, 'privacy'); // jsPrivacyController == 1 means privacy handle by admin $result = 1 == $privacyParams->get('jsPrivacyController') ? true : false; return $result; }
function updateCommunityUserWatermark($userid, $watermark = '') { // Get water is enable or disable $isWaterMarkEnable = XiptLibProfiletypes::getParams(XiptLibProfiletypes::getUserData($userid), 'watermarkparams')->get('enableWaterMark', 0); //update watermark on user's avatar $pTypeAvatar = XiptLibJomsocial::getUserDataFromCommunity($userid, 'avatar'); $pTypeThumbAvatar = XiptLibJomsocial::getUserDataFromCommunity($userid, 'thumb'); // no watermark on default avatars if (XiptLibProfiletypes::isDefaultAvatarOfProfileType($pTypeAvatar, true)) { return false; } //no watermark then resotre backup avatar and return //if water-mark disable then restore avatar(hit both by resete & by update any user profile ) if (false == $isWaterMarkEnable || $watermark == '') { self::restoreBackUpAvatar($pTypeAvatar); self::restoreBackUpAvatar($pTypeThumbAvatar); return true; } //add watermark on user avatar image if ($pTypeAvatar) { XiptHelperImage::addWatermarkOnAvatar($userid, $pTypeAvatar, $watermark, 'avatar'); } //add watermark on thumb image if ($pTypeThumbAvatar) { XiptHelperImage::addWatermarkOnAvatar($userid, $pTypeThumbAvatar, $watermark, 'thumb'); } return true; }