/** * Function to set variables up before form is built * * @return void * @access public */ function preProcess() { $this->_isTemplate = (bool) CRM_Utils_Request::retrieve('template', 'Integer', $this); $this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this); if ($this->_isTemplate) { CRM_Utils_System::setTitle(ts('New Vacancy Template')); } if ($this->_id) { if ($this->_isTemplate = CRM_Core_DAO::getFieldValue('CRM_HRRecruitment_DAO_HRVacancy', $this->_id, 'is_template')) { CRM_Utils_System::setTitle(ts('Edit Vacancy Template')); } else { CRM_Utils_System::setTitle(ts('Edit Vacancy')); } } $this->assign('isTemplate', $this->_isTemplate); $session = CRM_Core_Session::singleton(); if ($this->_id) { $permission = CRM_HRRecruitment_BAO_HRVacancyPermission::checkVacancyPermission($this->_id, array("administer Vacancy", "administer CiviCRM")); } else { $permission = CRM_Core_Permission::checkAnyPerm(array("administer Vacancy", "administer CiviCRM")); } if (!$permission) { $session->pushUserContext(CRM_Utils_System::url('civicrm')); CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to perform this action.')); } CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrrecruitment', 'templates/CRM/HRRecruitment/Form/HRVacancy.js'); }
/** * @inheritDoc */ public function getUserRecordUrl($contactID) { $uid = CRM_Core_BAO_UFMatch::getUFId($contactID); if (CRM_Core_Session::singleton()->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm(array('cms:administer users'))) { return CRM_Core_Config::singleton()->userFrameworkBaseURL . "wp-admin/user-edit.php?user_id=" . $uid; } }
/** * Pick a message to display. * * @return NULL|array */ public function pick() { $document = $this->getDocument(); $messages = array(); foreach ($document['messages'] as $message) { if (!isset($message['perms'])) { $message['perms'] = array(self::DEFAULT_PERMISSION); } if (!CRM_Core_Permission::checkAnyPerm($message['perms'])) { continue; } if (isset($message['components'])) { $enabled = array_keys(CRM_Core_Component::getEnabledComponents()); if (count(array_intersect($enabled, $message['components'])) == 0) { continue; } } $messages[] = $message; } if (empty($messages)) { return NULL; } $idx = rand(0, count($messages) - 1); return $messages[$idx]; }
/** * @inheritDoc */ public function getUserRecordUrl($contactID) { $uid = CRM_Core_BAO_UFMatch::getUFId($contactID); if (CRM_Core_Session::singleton()->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm(array('cms:administer users', 'cms:view user account'))) { return CRM_Utils_System::url('user/' . $uid); } }
/** * Add urls for display in the actions menu */ static function addUrls(&$obj, $cid) { // TODO rewrite without so many hard-coded CMS bits; use abstractions like CRM_Core_Permission::check('cms:...') and CRM_Utils_System $config = CRM_Core_Config::singleton(); $session = CRM_Core_Session::singleton(); $uid = CRM_Core_BAO_UFMatch::getUFId($cid); $userRecordUrl = NULL; if ($uid) { if ($config->userSystem->is_drupal == '1' && ($session->get('userID') == $cid || CRM_Core_Permission::checkAnyPerm(array('cms:administer users', 'cms:view user account')))) { $userRecordUrl = CRM_Utils_System::url('user/' . $uid); } elseif ($config->userFramework == 'Joomla') { $userRecordUrl = NULL; // if logged in user is super user, then he can view other users joomla profile if (JFactory::getUser()->authorise('core.admin')) { $userRecordUrl = $config->userFrameworkBaseURL . "index.php?option=com_users&view=user&task=user.edit&id=" . $uid; } elseif ($session->get('userID') == $cid) { $userRecordUrl = $config->userFrameworkBaseURL . "index.php?option=com_admin&view=profile&layout=edit&id=" . $uid; } } elseif ($config->userFramework == 'WordPress' && ($session->get('userID') == $cid || CRM_Core_Permission::checkAnyPerm(array('cms:administer users')))) { $userRecordUrl = $config->userFrameworkBaseURL . "wp-admin/user-edit.php?user_id=" . $uid; } $obj->assign('userRecordUrl', $userRecordUrl); $obj->assign('userRecordId', $uid); } elseif ($config->userSystem->is_drupal == '1' && CRM_Core_Permission::check('administer users') || $config->userFramework == 'Joomla' && JFactory::getUser()->authorise('core.create', 'com_users')) { $userAddUrl = CRM_Utils_System::url('civicrm/contact/view/useradd', 'reset=1&action=add&cid=' . $cid); $obj->assign('userAddUrl', $userAddUrl); } if (CRM_Core_Permission::check('access Contact Dashboard')) { $dashboardURL = CRM_Utils_System::url('civicrm/user', "reset=1&id={$cid}"); $obj->assign('dashboardURL', $dashboardURL); } // See if other modules want to add links to the activtity bar $hookLinks = array(); CRM_Utils_Hook::links('view.contact.activity', 'Contact', $cid, $hookLinks, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject); if (is_array($hookLinks)) { $obj->assign('hookLinks', $hookLinks); } }