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;"> </span>'; return $html; }
function createCustomField($what) { // Load the JTable Object. JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_community' . DS . 'tables'); $row = JTable::getInstance('profiles', 'CommunityTable'); $row->load(0); switch ($what) { case PROFILETYPE_CUSTOM_FIELD_CODE: $data['type'] = PROFILETYPE_FIELD_TYPE_NAME; $data['name'] = 'Profiletype'; $data['tips'] = 'Profiletype Of User'; break; case TEMPLATE_CUSTOM_FIELD_CODE: $data['type'] = TEMPLATE_FIELD_TYPE_NAME; $data['name'] = 'Template'; $data['tips'] = 'Template Of User'; break; default: XiptError::assert(0); break; } $data['published'] = 1; $data['fieldcode'] = $what; return $row->bind($data) && $row->store(); }
function save($post = null) { if ($post === null) { $post = JRequest::get('post', JREQUEST_ALLOWRAW); } $save = $this->getModel()->saveParams($post['settings'], 'settings', 'params'); XiptError::assert($save, XiptText::_('ERROR_IN_SAVING_SETTINGS'), XiptError::WARNING); $msg = XiptText::_('SETTINGS_SAVED'); $this->setRedirect("index.php?option=com_xipt&view=settings", $msg); return true; }
function getProfileTypeArray($menuid) { XiptError::assert($menuid, XiptText::_("MENU_ID_CANNOT_BE_NULL"), XiptError::ERROR); $results = XiptFactory::getInstance('jstoolbar', 'model')->getProfileTypes($menuid); if (empty($results)) { return array(XIPT_PROFILETYPE_ALL); } $allTypes = XiptHelperProfiletypes::getProfileTypeArray(); // array_values is user to arrange the array from index 0, //array_diff uses index starting from 1 return array_values(array_diff($allTypes, $results)); }
function getProfileTypeArray($fid, $for) { XiptError::assert($fid, XiptText::_("PROFILEFIELD_ID_CAN_NOT_BE_NULL"), XiptError::ERROR); //Load all profiletypes for the field $results = XiptFactory::getInstance('profilefields', 'model')->getProfileTypes($fid, $for); if (empty($results)) { return array(XIPT_PROFILETYPE_ALL); } $allTypes = XiptHelperProfiletypes::getProfileTypeArray(); // array_values is user to arrange the array from index 0, //array_diff uses index starting from 1 return array_values(array_diff($allTypes, $results)); }
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; }
function getFieldsForProfiletype(&$fields, $selectedProfiletypeID, $from, $notSelectedFields = null) { XiptError::assert($selectedProfiletypeID, XiptText::_("SELECTED_PROFILETYPE_DOES_NOT_EXIST"), XiptError::ERROR); $task = JRequest::getVar('task', ''); if ($notSelectedFields === null) { $categories = XiptHelperProfilefields::getProfileFieldCategories(); foreach ($categories as $catIndex => $catInfo) { $catName = $catInfo['name']; $notSelectedFields[$catName] = $this->getNotSelectedFieldForProfiletype($selectedProfiletypeID, $catIndex); } } $count = count($fields); for ($i = 0; $i < $count; $i++) { $field =& $fields[$i]; if (is_object($field)) { $fieldId = $field->id; } else { $fieldId = $field['id']; } if (in_array($fieldId, $notSelectedFields['ALLOWED'])) { unset($fields[$i]); continue; } if (in_array($fieldId, $notSelectedFields['REQUIRED'])) { if (is_object($field)) { $field->required = 0; } else { $field['required'] = 0; } } if (in_array($fieldId, $notSelectedFields['VISIBLE']) && $from === 'getViewableProfile') { unset($fields[$i]); continue; } if (in_array($fieldId, $notSelectedFields['EDITABLE_AFTER_REG']) && $from === 'getEditableProfile' && JFactory::getApplication()->isAdmin() == false) { unset($fields[$i]); continue; } if (in_array($fieldId, $notSelectedFields['EDITABLE_DURING_REG']) && $from != 'getViewableProfile' && $from != 'getEditableProfile' && $task != 'advancesearch') { unset($fields[$i]); continue; } if (in_array($fieldId, $notSelectedFields['ADVANCE_SEARCHABLE']) && $from === '_loadAllFields' && $task === 'advancesearch') { unset($fields[$i]); } } $fields = array_values($fields); return true; }
function reset($id = 0) { //XITODO : what to do if invalid id comes $id = JRequest::getVar('profileId', $id); $pModel = $this->getModel(); // Try to save configurations $save = $pModel->save(array('params' => ''), $id); if (XiptError::assert($save, XiptText::_('UNABLE_TO_RESET_PROFILETYPE_INTO_DATABASE_PLEASE_ENSURE_THAT_THE_TABLE_JOS_XIPT_PROFILETYPES_EXISTS'), XiptError::WARNING) == false) { return false; } $link = XiptRoute::_('index.php?option=com_xipt&view=configuration', false); $msg = XiptText::_('PROFILETYPE_HAS_BEEN_RESET'); $this->setRedirect($link, $msg); return true; }
function edit($id = 0, $acl = 0) { $id = JRequest::getVar('id', $id); $acl = JRequest::getVar('acl', $acl); $view = $this->getView(); XiptError::assert($acl || $id, XiptText::_("NOT_DEFINED {$id} or {$acl}"), XiptError::ERROR); if ($acl) { $aclObject = XiptAclFactory::getAclObject($acl); } else { $aclObject = XiptAclFactory::getAclObjectFromId($id); } XiptError::assert(isset($aclObject), XiptText::_("NOT_ABLE_TO_CREATE_ACL_OBJECT"), XiptError::ERROR); $aclObject->load($id); $data = $aclObject->getObjectInfoArray(); $data['id'] = $id; return $view->edit($data); }
/** * Save the configuration to the config file * * @return boolean True on success false on failure. **/ function saveParams($data, $id, $what = 'params') { XiptError::assert($id, XiptText::_("ID {$id} IS_NOT_VALID"), XiptError::ERROR); if (empty($data) || !is_array($data)) { return false; } //We want to handle only JS Configuration from this function //Everything else should be handled by generic parent function if ($what != 'params') { parent::saveParams($data, $id, $what); return; } // XITODO : move this to controller unset($data[JUtility::getToken()]); unset($data['option']); unset($data['task']); unset($data['view']); unset($data['id']); //XITODO : bind params $param = new XiptParameter(); $param->loadArray($data); $params = $param->toString('XiptINI'); return $this->save(array($what => $params), $id); }
function loadParams($id, $what = '') { $record = $this->loadRecords(0); $xmlPath = XIPT_FRONT_PATH_ASSETS . DS . 'xml' . DS . JString::strtolower($this->getName() . ".{$what}.xml"); $iniPath = XIPT_FRONT_PATH_ASSETS . DS . 'ini' . DS . JString::strtolower($this->getName() . ".{$what}.ini"); $iniData = JFile::read($iniPath); XiptError::assert(JFile::exists($xmlPath), sprintf(XiptText::_("FILE_DOES_NOT_EXIST"), $xmlPath), XiptError::ERROR); $config = new XiptParameter($iniData, $xmlPath); if (isset($record[$id])) { $config->bind($record[$id]->{$what}); } return $config; }
function bind($data) { if (is_object($data)) { $this->aclparams->bind($data->aclparams); $this->coreparams->bind($data->coreparams); $this->rulename = $data->rulename; $this->published = $data->published; $this->id = $data->id; return $this; } if (is_array($data)) { //XiTODO:: need to test for Joomla 1.5 $aclParam = $data['aclparams']->toArray(); $coreParams = $data['coreparams']->toArray(); $this->aclparams->bind($aclParam); $this->coreparams->bind($coreParams); //$this->aclparams->bind($data['aclparams']); //$this->coreparams->bind($data['coreparams']); $this->rulename = $data['rulename']; $this->published = $data['published']; $this->id = $data['id']; return $this; } //Any issue XiptError::assert(0); }
function getProfileTypeData($id, $what = 'name') { //XITODO : Caching can be added $searchFor = 'name'; $defaultValue = 'NONE'; $data = array('name' => array('name' => 'name', 'value' => 'All'), 'template' => array('name' => 'template', 'value' => 'default'), 'jusertype' => array('name' => 'jusertype', 'value' => 'Registered'), 'avatar' => array('name' => 'avatar', 'value' => DEFAULT_AVATAR), 'watermark' => array('name' => 'watermark', 'value' => ''), 'approve' => array('name' => 'approve', 'value' => true), 'allowt' => array('name' => 'allowt', 'value' => false), 'group' => array('name' => 'group', 'value' => 0)); //XITODO : clean this fn XiptError::assert(array_key_exists($what, $data), XiptText::_("ARRAY_KEY_DOES_NOT_EXIST")); if ($id == 0) { return $data[$what]['value']; } $val = XiptFactory::getInstance('profiletypes', 'model')->loadRecords(0); if (!$val) { return $data[$what]['value']; } if (isset($val[$id])) { return $val[$id]->{$what}; } return false; }
function _addUserToGroup($userId, $groupIds) { if (empty($groupIds)) { return false; } $groupIds = explode(',', $groupIds); $groupModel = CFactory::getModel('groups'); //if user has selected "none" just exit if (is_array($groupIds) == false || in_array(NONE, $groupIds)) { return false; } foreach ($groupIds as $k => $gid) { if ($groupModel->isMember($userId, $gid)) { continue; } $group = JTable::getInstance('Group', 'CTable'); $member = JTable::getInstance('GroupMembers', 'CTable'); $group->load($gid); // Set the properties for the members table $member->groupid = $group->id; $member->memberid = $userId; // @rule: If approvals is required, set the approved status accordingly. $member->approved = 1; // SHOULD BE always 1 by SHYAM//( $group->approvals ) ? '0' : 1; //@todo: need to set the privileges $member->permissions = '0'; $store = $member->store(); // Assert if storing fails XiptError::assert($store, XiptText::_("DATA_IS_NOT_STORED"), XiptError::ERROR); if ($member->approved) { self::addWallCount($gid); } } return true; }
function createImageWatermark($path, $filename) { XiptError::assert(!empty($path), XiptText::_("PATH_IS_EMPTY"), XiptError::ERROR); XiptError::assert(!empty($filename), XiptText::_("FILE_IS_EMPTY"), XiptError::ERROR); //here check if folder exist or not. if not then create it. if (JFolder::exists($path) == false && JFolder::create($path) === false) { XiptError::raiseError(__CLASS__ . '.' . __LINE__, sprintf(XiptText::_("FOLDER_DOES_NOT_EXIST"), $path)); return false; } $filename = $filename . ".png"; $filepath = $path . "/" . $filename; //create an image identifier from path $img = $this->load($this->imgname); if ($img == false) { return false; } $img_width = imagesx($img); $img_height = imagesy($img); //create a blank transparent image with the // height and width of the watermark $new_image = $this->imageCreateTransparent($this->width, $this->height); // resize $img to watermark height and width //copy it to $new_image imagecopyresampled($new_image, $img, 0, 0, 0, 0, $this->width, $this->height, $img_width, $img_height); // create an png image $result = imagepng($new_image, $filepath); chmod($filepath, 0744); imagedestroy($new_image); // if file creation is successfull return filename , else false return $result ? $filename : false; }
/** * 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 multidobool($task = 'enable', $cids = array(0)) { $task = JRequest::getVar('task', $task); $offpattern = '/^switchOff/'; $onpattern = '/^switchOn/'; if (preg_match($onpattern, $task)) { $switch = false; //$columninfo = str_split($task,strlen('switchOn')); $columninfo = explode('switchOn', $task); $column = array_key_exists(1, $columninfo) ? $columninfo[1] : ''; $value = 1; } else { if (preg_match($offpattern, $task)) { $switch = false; //$columninfo = str_split($task,strlen('switchOff')); $columninfo = explode('switchOff', $task); $column = array_key_exists(1, $columninfo) ? $columninfo[1] : ''; $value = 0; } else { XiptError::assert(0); } } $cids = JRequest::getVar('cid', $cids, 'post', 'array'); foreach ($cids as $cid) { if (!$this->_doBool($column, $value, $cid)) { XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("ERROR_IN_REORDERING_ITEMS")); } } //redirect now $this->setRedirect(XiptRoute::_("index.php?option=com_" . JString::strtolower($this->getPrefix()) . "&view={$this->getName()}"), sprintf(XiptText::_($task . '.MSG'), $cids)); return false; }
function showWatermarkOverImage($imagePath, $watermarkPath, $newImageName = "tmp", $position = 'bl') { XiptError::assert(JFile::exists($imagePath) && JFile::exists($watermarkPath), XiptText::_("FILE {$imagePath} AND {$watermarkPath} DOES NOT EXIST"), XiptError::ERROR); //original image $destinationType = self::getImageType($imagePath); $watermarkType = self::getImageType($watermarkPath); // Load image helper library as it is needed. require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'helpers' . DS . 'image.php'; $watermarkImage = cImageOpen($watermarkPath, $watermarkType); /*if(JFolder::exists(PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH)==false) JFolder::create(PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH); JFile::copy($imagePath,$newImagePath);*/ $imageImage = cImageOpen($imagePath, $destinationType); /*calculate watermark height and width from watermark image */ $watermarkWidth = imagesx($watermarkImage); $watermarkHeight = imagesy($watermarkImage); /*get original image size */ $size = getimagesize($imagePath); $dest_x = 0; //$size[0] - $watermarkWidth - 5; $dest_y = 0; //$size[1] - $watermarkHeight - 5; $xy = array(); $xy[0] =& $dest_x; $xy[1] =& $dest_y; $watermarkSize = array(); $watermarkSize[0] = $watermarkWidth; $watermarkSize[1] = $watermarkHeight; self::setPosotion($size, $watermarkSize, $watermarkImage, $position, $xy); imagecopymerge($imageImage, $watermarkImage, $dest_x, $dest_y, 0, 0, $watermarkSize[0], $watermarkSize[1], 100); /*first copy the image to tmp location , b'coz we don't want to destroy original image */ $newImagePath = PROFILETYPE_AVATAR_STORAGE_PATH . DS . $newImageName . '.' . JFile::getExt($imagePath); $newImageRefPath = PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH . DS . $newImageName . '.' . JFile::getExt($imagePath); imagesavealpha($imageImage, true); ob_start(); // Test if type is png if ($destinationType == 'image/png' || $destinationType == 'image/x-png') { imagepng($imageImage); } elseif ($destinationType == 'image/gif') { imagegif($imageImage); } else { // We default to use jpeg imagejpeg($imageImage, null, 100); } $output = ob_get_contents(); ob_end_clean(); JFile::write($newImagePath, $output); // Free any memory from the existing image resources imagedestroy($imageImage); imagedestroy($watermarkImage); return $output ? $newImageRefPath : false; }
function _processSave($post = null, $id = 0) { if ($post === null) { $post = JRequest::get('post'); } $id = JRequest::getVar('id', $id, 'post'); //We only need few data as special case $data = $post; $data['tip'] = JRequest::getVar('tip', $post['tip'], 'post', 'string', JREQUEST_ALLOWRAW); $data['group'] = implode(',', $post['group']); // These data will be seperately stored, we dont want to update these unset($data['watermarkparams']); unset($data['config']); unset($data['privacy']); $model = $this->getModel(); //for Reset we will save old Data // give 0 in loadRecords so that all records will be loaded $allData = $model->loadRecords(0); if (isset($allData[$id])) { $oldData = $allData[$id]; } // set ordering if (end($allData)) { if ($allData[$id]->id == 0) { $data['ordering'] = end($allData)->ordering + 1; } } else { $data['ordering'] = 1; } // now save model $id = $model->save($data, $id); XiptError::assert($id, XiptText::_("{$id} NOT_EXISTS"), XiptError::ERROR); // Now store other data // Handle Avatar : call uploadImage function if post(image) data is set $fileAvatar = JRequest::getVar('FileAvatar', '', 'FILES', 'array'); if (isset($fileAvatar['tmp_name']) && !empty($fileAvatar['tmp_name'])) { XiptHelperProfiletypes::uploadAndSetImage($fileAvatar, $id, 'avatar'); } //display demo on watermark profile according ProfileType if ($post['watermarkparams']['enableWaterMark']) { $post['watermarkparams']['demo'] = $id; } // if jsPrivacyController = 0 then Old privacy set in profile-type table if (is_array($post['privacy']) && $post['privacy']['jsPrivacyController'] == 0) { $oldPrivacy = $model->loadParams($id, 'privacy')->toArray(); $oldPrivacy['jsPrivacyController'] = $post['privacy']['jsPrivacyController']; $post['privacy'] = $oldPrivacy; } // Handle Params : watermarkparams, privacy, config $model->saveParams($post['watermarkparams'], $id, 'watermarkparams'); $model->saveParams($post['config'], $id, 'config'); $model->saveParams($post['privacy'], $id, 'privacy'); // now generate watermark, and update watermark field $image = $this->_saveWatermark($id); //XITODO : Ensure data is reloaded, not cached $newData = $model->loadRecords(0); $newData = $newData[$id]; //to reset privacy of users need to load from loadParams $newData->privacy = $model->loadParams($id, 'privacy'); // Reset existing user's if ($post['resetAll'] && isset($oldData)) { $newData = serialize($newData); //new method $preTask = JRequest::getVar('task', 'save'); $session = JFactory::getSession(); $session->set('oldPtData', $oldData, 'jspt'); $session->set('newPtData', $newData, 'jspt'); $session->set('preTask', $preTask, 'jspt'); if (!XIPT_TEST_MODE) { JFactory::getApplication()->redirect(XiPTRoute::_("index.php?option=com_xipt&view=profiletypes&task=resetall&id={$id}", false)); } $this->resetall($id, 25000); //old method //XiptHelperProfiletypes::resetAllUsers($id, $oldData, $newData); } $info['id'] = $id; $info['msg'] = XiptText::_('PROFILETYPE_SAVED'); return $info; }
function getPTPrivacyValue($privacy) { $value = PRIVACY_PUBLIC; switch ($privacy) { case "friends": $value = PRIVACY_FRIENDS; break; case "members": $value = PRIVACY_MEMBERS; break; case "public": $value = PRIVACY_PUBLIC; break; default: XiptError::assert(0); } return $value; }