本文整理汇总了PHP中CRM_Core_Permission::check方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Permission::check方法的具体用法?PHP CRM_Core_Permission::check怎么用?PHP CRM_Core_Permission::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Permission
的用法示例。
在下文中一共展示了CRM_Core_Permission::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initTasks
static function initTasks()
{
if (!self::$_tasks) {
self::$_tasks = array(1 => array('title' => ts('Add Contacts to Group'), 'class' => 'CRM_Contact_Form_Task_AddToGroup', 'result' => true), 2 => array('title' => ts('Remove Contacts from Group'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup', 'result' => true), 3 => array('title' => ts('Tag Contacts (assign tags)'), 'class' => 'CRM_Contact_Form_Task_AddToTag', 'result' => true), 4 => array('title' => ts('Untag Contacts (remove tags)'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag', 'result' => true), 5 => array('title' => ts('Export Contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => false), 6 => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => true), 7 => array('title' => ts('Send SMS to Contacts'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => true), 8 => array('title' => ts('Delete Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => false), 11 => array('title' => ts('Record Activity for Contacts'), 'class' => 'CRM_Activity_Form_Activity', 'result' => true), 13 => array('title' => ts('New Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => true), 14 => array('title' => ts('Update Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => true), 15 => array('title' => ts('Print Contacts'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => false), 16 => array('title' => ts('Mailing Labels'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => true), 17 => array('title' => ts('Batch Update via Profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => true), 19 => array('title' => ts('Print PDF Letter for Contacts'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => true), 21 => array('title' => ts('Merge Contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => true));
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
$label = CRM_Contact_BAO_ContactType::getLabel('Household');
self::$_tasks[9] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold', 'result' => true);
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
$label = CRM_Contact_BAO_ContactType::getLabel('Organization');
self::$_tasks[10] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization', 'result' => true);
}
//CRM-4418, check for delete
if (!CRM_Core_Permission::check('delete contacts')) {
unset(self::$_tasks[8]);
}
//show map action only if map provider and key is set
$config =& CRM_Core_Config::singleton();
if ($config->mapProvider && $config->mapAPIKey) {
self::$_tasks[12] = array('title' => ts('Map Contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => false);
}
if (CRM_Core_Permission::access('CiviEvent')) {
self::$_tasks[18] = array('title' => ts('Add Contacts to Event'), 'class' => 'CRM_Event_Form_Participant', 'result' => true);
}
if (CRM_Core_Permission::access('CiviMail')) {
self::$_tasks[20] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test', 'CRM_Mailing_Form_Schedule'), 'result' => false);
}
self::$_tasks += CRM_Core_Component::taskList();
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
asort(self::$_tasks);
}
}
示例2: whereClause
/**
* Get the permissioned where clause for the user
*
* @param int $type the type of permission needed
* @param array $tables (reference ) add the tables that are needed for the select clause
* @param array $whereTables (reference ) add the tables that are needed for the where clause
* @param int $contactID the contactID for whom the check is made
* @param bool $onlyDeleted whether to include only deleted contacts
* @param bool $skipDeleteClause don't add delete clause if this is true,
* this means it is handled by generating query
*
* @return string the group where clause for this user
* @access public
*/
public static function whereClause($type, &$tables, &$whereTables, $contactID = null, $onlyDeleted = false, $skipDeleteClause = false)
{
// first see if the contact has edit / view all contacts
if (CRM_Core_Permission::check('edit all contacts') || $type == self::VIEW && CRM_Core_Permission::check('view all contacts')) {
$deleteClause = ' ( 1 ) ';
if (!$skipDeleteClause) {
if (CRM_Core_Permission::check('access deleted contacts') and $onlyDeleted) {
$deleteClause = '(contact_a.is_deleted)';
} else {
// CRM-6181
$deleteClause = '(contact_a.is_deleted = 0)';
}
}
return $deleteClause;
}
if ($contactID == null) {
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
}
if (!$contactID) {
$contactID = 0;
// anonymous user
}
require_once 'CRM/ACL/BAO/ACL.php';
return CRM_ACL_BAO_ACL::whereClause($type, $tables, $whereTables, $contactID);
}
示例3: preProcess
public function preProcess()
{
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
$this->_system = CRM_Utils_Request::retrieve('system', 'Boolean', $this, FALSE, TRUE);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update');
if (isset($action)) {
$this->assign('action', $action);
}
$session = CRM_Core_Session::singleton();
$this->_config = new CRM_Core_DAO();
if ($this->_system) {
if (CRM_Core_Permission::check('administer CiviCRM')) {
$this->_contactID = NULL;
} else {
CRM_Utils_System::fatal('You do not have permission to edit preferences');
}
$this->_config->contact_id = NULL;
} else {
if (!$this->_contactID) {
$this->_contactID = $session->get('userID');
if (!$this->_contactID) {
CRM_Utils_System::fatal('Could not retrieve contact id');
}
$this->set('cid', $this->_contactID);
}
$this->_config->contact_id = $this->_contactID;
}
$settings = Civi::settings();
foreach ($this->_varNames as $groupName => $settingNames) {
foreach ($settingNames as $settingName => $options) {
$this->_config->{$settingName} = $settings->get($settingName);
}
}
$session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
}
示例4: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
if (CRM_Mailing_Info::workflowEnabled()) {
if (!CRM_Core_Permission::check('approve mailings') && !CRM_Core_Permission::check('access CiviMail')) {
$this->redirectToListing();
}
} else {
$this->redirectToListing();
}
// when user come from search context.
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
//retrieve mid from different wizard and url contexts
$this->_mailingID = $this->get('mailing_id');
$this->_approveFormOnly = FALSE;
if (!$this->_mailingID) {
$this->_mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, TRUE);
$this->_approveFormOnly = TRUE;
}
$session = CRM_Core_Session::singleton();
$this->_contactID = $session->get('userID');
$this->_mailing = new CRM_Mailing_BAO_Mailing();
$this->_mailing->id = $this->_mailingID;
if (!$this->_mailing->find(TRUE)) {
$this->redirectToListing();
}
}
示例5: preProcess
function preProcess()
{
$this->_mailingID = $this->get('mailing_id');
if (CRM_Core_Permission::check('administer CiviCRM')) {
$this->assign('isAdmin', 1);
}
}
示例6: getAngularModules
/**
* Get AngularJS modules and their dependencies
*
* @return array
* list of modules; same format as CRM_Utils_Hook::angularModules(&$angularModules)
* @see CRM_Utils_Hook::angularModules
*/
public function getAngularModules()
{
// load angular files only if valid permissions are granted to the user
if (!CRM_Core_Permission::check('access CiviMail') && !CRM_Core_Permission::check('create mailings') && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings')) {
return array();
}
$result = array();
$result['crmMailing'] = array('ext' => 'civicrm', 'js' => array('ang/crmMailing.js', 'ang/crmMailing/*.js'), 'css' => array('ang/crmMailing.css'), 'partials' => array('ang/crmMailing'));
$result['crmMailingAB'] = array('ext' => 'civicrm', 'js' => array('ang/crmMailingAB.js', 'ang/crmMailingAB/*.js', 'ang/crmMailingAB/*/*.js'), 'css' => array('ang/crmMailingAB.css'), 'partials' => array('ang/crmMailingAB'));
$result['crmD3'] = array('ext' => 'civicrm', 'js' => array('ang/crmD3.js', 'bower_components/d3/d3.min.js'));
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
// Get past mailings
// CRM-16155 - Limit to a reasonable number
$civiMails = civicrm_api3('Mailing', 'get', array('is_completed' => 1, 'mailing_type' => array('IN' => array('standalone', 'winner')), 'return' => array('id', 'name', 'scheduled_date'), 'sequential' => 1, 'options' => array('limit' => 500, 'sort' => 'is_archived asc, scheduled_date desc')));
// Generic params
$params = array('options' => array('limit' => 0), 'sequential' => 1);
$groupNames = civicrm_api3('Group', 'get', $params + array('is_active' => 1, 'check_permissions' => TRUE, 'return' => array('title', 'visibility', 'group_type', 'is_hidden')));
$headerfooterList = civicrm_api3('MailingComponent', 'get', $params + array('is_active' => 1, 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text')));
$emailAdd = civicrm_api3('Email', 'get', array('sequential' => 1, 'return' => "email", 'contact_id' => $contactID));
$mesTemplate = civicrm_api3('MessageTemplate', 'get', $params + array('sequential' => 1, 'is_active' => 1, 'return' => array("id", "msg_title"), 'workflow_id' => array('IS NULL' => "")));
$mailTokens = civicrm_api3('Mailing', 'gettokens', array('entity' => array('contact', 'mailing'), 'sequential' => 1));
$fromAddress = civicrm_api3('OptionValue', 'get', $params + array('option_group_id' => "from_email_address", 'domain_id' => CRM_Core_Config::domainID()));
CRM_Core_Resources::singleton()->addSetting(array('crmMailing' => array('civiMails' => $civiMails['values'], 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents), 'groupNames' => $groupNames['values'], 'headerfooterList' => $headerfooterList['values'], 'mesTemplate' => $mesTemplate['values'], 'emailAdd' => $emailAdd['values'], 'mailTokens' => $mailTokens['values'], 'contactid' => $contactID, 'requiredTokens' => CRM_Utils_Token::getRequiredTokens(), 'enableReplyTo' => (int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'replyTo'), 'disableMandatoryTokensCheck' => (int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'disable_mandatory_tokens_check'), 'fromAddress' => $fromAddress['values'], 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array('id' => 'user_contact_id', 'return' => 'email')), 'visibility' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::groupVisibility()), 'workflowEnabled' => CRM_Mailing_Info::workflowEnabled())))->addPermissions(array('view all contacts', 'access CiviMail', 'create mailings', 'schedule mailings', 'approve mailings', 'delete in CiviMail', 'edit message templates'));
return $result;
}
示例7: array
/**
* Get tab Links for events.
*
* @param $enableCart
*
* @return array
* (reference) of tab links
*/
public static function &tabs($enableCart)
{
$cacheKey = $enableCart ? 1 : 0;
if (!self::$_tabLinks) {
self::$_tabLinks = array();
}
if (!isset(self::$_tabLinks[$cacheKey])) {
self::$_tabLinks[$cacheKey]['settings'] = array('title' => ts('Info and Settings'), 'url' => 'civicrm/event/manage/settings', 'field' => 'id');
self::$_tabLinks[$cacheKey]['location'] = array('title' => ts('Location'), 'url' => 'civicrm/event/manage/location', 'field' => 'loc_block_id');
self::$_tabLinks[$cacheKey]['fee'] = array('title' => ts('Fees'), 'url' => 'civicrm/event/manage/fee', 'field' => 'is_monetary');
self::$_tabLinks[$cacheKey]['registration'] = array('title' => ts('Online Registration'), 'url' => 'civicrm/event/manage/registration', 'field' => 'is_online_registration');
if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Event_BAO_Event::checkPermission(NULL, CRM_Core_Permission::EDIT)) {
self::$_tabLinks[$cacheKey]['reminder'] = array('title' => ts('Schedule Reminders'), 'url' => 'civicrm/event/manage/reminder', 'field' => 'reminder');
}
self::$_tabLinks[$cacheKey]['conference'] = array('title' => ts('Conference Slots'), 'url' => 'civicrm/event/manage/conference', 'field' => 'slot_label_id');
self::$_tabLinks[$cacheKey]['friend'] = array('title' => ts('Tell a Friend'), 'url' => 'civicrm/event/manage/friend', 'field' => 'friend');
self::$_tabLinks[$cacheKey]['pcp'] = array('title' => ts('Personal Campaign Pages'), 'url' => 'civicrm/event/manage/pcp', 'field' => 'is_pcp_enabled');
self::$_tabLinks[$cacheKey]['repeat'] = array('title' => ts('Repeat'), 'url' => 'civicrm/event/manage/repeat', 'field' => 'is_repeating_event');
}
if (!$enableCart) {
unset(self::$_tabLinks[$cacheKey]['conference']);
}
CRM_Utils_Hook::tabset('civicrm/event/manage', self::$_tabLinks[$cacheKey], array());
return self::$_tabLinks[$cacheKey];
}
示例8: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$this->_addProfileBottom = CRM_Utils_Array::value('addProfileBottom', $_GET, FALSE);
$this->_profileBottomNum = CRM_Utils_Array::value('addProfileNum', $_GET, 0);
$this->_addProfileBottomAdd = CRM_Utils_Array::value('addProfileBottomAdd', $_GET, FALSE);
$this->_profileBottomNumAdd = CRM_Utils_Array::value('addProfileNumAdd', $_GET, 0);
parent::preProcess();
$this->assign('addProfileBottom', $this->_addProfileBottom);
$this->assign('profileBottomNum', $this->_profileBottomNum);
$urlParams = "id={$this->_id}&addProfileBottom=1&qfKey={$this->controller->_key}";
$this->assign('addProfileParams', $urlParams);
if ($addProfileBottom = CRM_Utils_Array::value('custom_post_id_multiple', $_POST)) {
foreach (array_keys($addProfileBottom) as $profileNum) {
self::buildMultipleProfileBottom($this, $profileNum);
}
}
$this->assign('perm', 0);
$ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
$ufCreate = CRM_ACL_API::group(CRM_Core_Permission::CREATE, NULL, 'civicrm_uf_group', $ufGroups);
$ufEdit = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_uf_group', $ufGroups);
$checkPermission = array(array('administer CiviCRM', 'manage event profiles'));
if (CRM_Core_Permission::check($checkPermission) || !empty($ufCreate) || !empty($ufEdit)) {
$this->assign('perm', 1);
}
$this->assign('addProfileBottomAdd', $this->_addProfileBottomAdd);
$this->assign('profileBottomNumAdd', $this->_profileBottomNumAdd);
$urlParamsAdd = "id={$this->_id}&addProfileBottomAdd=1&qfKey={$this->controller->_key}";
$this->assign('addProfileParamsAdd', $urlParamsAdd);
if ($addProfileBottomAdd = CRM_Utils_Array::value('additional_custom_post_id_multiple', $_POST)) {
foreach (array_keys($addProfileBottomAdd) as $profileNum) {
self::buildMultipleProfileBottom($this, $profileNum, 'additional_', ts('Profile for Additional Participants'));
}
}
}
示例9: checkPermission
/**
* Lets do permission checking here
* First check for valid mailing, if false return fatal
* Second check for visibility
* Call a hook to see if hook wants to override visibility setting
*/
function checkPermission()
{
if (!$this->_mailing) {
return false;
}
// check for visibility, if visibility is user pages
// return true
if ($this->_mailing->visibility == 'Public Pages') {
return true;
}
// if user is an admin, return true
require_once 'CRM/Core/Permission.php';
if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Core_Permission::check('access CiviMail')) {
return true;
}
// if anon user return false
if (empty($this->_contactID)) {
return false;
}
// if user has recd this mailing return true, else return false
// check in mailing event table for this contact
$sql = "\nSELECT id\nFROM civicrm_mailing_event_queue q\nINNER JOIN civicrm_mailing_job j ON q.job_id = j.id\nWHERE j.mailing_id = %1\nAND q.contact_id = %2\n";
$params = array(1 => array($this->_mailingID, 'Integer'), 2 => array($this->_contactID, 'Integer'));
return CRM_Core_DAO::singleValueQuery($sql, $params) ? true : false;
}
示例10: preProcess
function preProcess()
{
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
$this->_system = CRM_Utils_Request::retrieve('system', 'Boolean', $this, false, true);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'update');
if (isset($action)) {
$this->assign('action', $action);
}
$session = CRM_Core_Session::singleton();
require_once 'CRM/Core/DAO/Preferences.php';
$this->_config = new CRM_Core_DAO_Preferences();
$this->_config->domain_id = CRM_Core_Config::domainID();
if ($this->_system) {
if (CRM_Core_Permission::check('administer CiviCRM')) {
$this->_contactID = null;
} else {
CRM_Utils_System::fatal('You do not have permission to edit preferences');
}
$this->_config->is_domain = 1;
$this->_config->contact_id = null;
} else {
if (!$this->_contactID) {
$this->_contactID = $session->get('userID');
if (!$this->_contactID) {
CRM_Utils_System::fatal('Could not retrieve contact id');
}
$this->set('cid', $this->_contactID);
}
$this->_config->is_domain = 0;
$this->_config->contact_id = $this->_contactID;
}
$this->_config->find(true);
$session->pushUserContext(CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'));
}
示例11: creatNewShortcut
public function creatNewShortcut(&$shortCuts)
{
require_once 'CRM/Core/Permission.php';
if (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign')) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/campaign/add', 'query' => "reset=1&action=add", 'ref' => 'new-campaign', 'title' => ts('Campaign')), array('path' => 'civicrm/survey/add', 'query' => "reset=1&action=add", 'ref' => 'new-survey', 'title' => ts('Survey'))));
}
}
示例12: preProcess
/**
* Pre processing work done here.
*
* gets session variables for group or field id
*
* @param
*
* @return void
*/
public function preProcess()
{
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
// CRM_Core_Controller validates qfKey for POST requests, but not necessarily
// for GET requests. Allowing GET would therefore be CSRF vulnerability.
CRM_Core_Error::fatal(ts('Preview only supports HTTP POST'));
}
// Inline forms don't get menu-level permission checks
$checkPermission = array(array('administer CiviCRM', 'manage event profiles'));
if (!CRM_Core_Permission::check($checkPermission)) {
CRM_Core_Error::fatal(ts('Permission Denied'));
}
$content = json_decode($_REQUEST['ufData'], TRUE);
foreach (array('ufGroup', 'ufFieldCollection') as $key) {
if (!is_array($content[$key])) {
CRM_Core_Error::fatal("Missing JSON parameter, {$key}");
}
}
//echo '<pre>'.htmlentities(var_export($content, TRUE)) .'</pre>';
//CRM_Utils_System::civiExit();
$fields = CRM_Core_BAO_UFGroup::formatUFFields($content['ufGroup'], $content['ufFieldCollection']);
//$fields = CRM_Core_BAO_UFGroup::getFields(1);
$this->setProfile($fields);
//echo '<pre>'.htmlentities(var_export($fields, TRUE)) .'</pre>';CRM_Utils_System::civiExit();
}
示例13: checkPerms
/**
* See if the current user can edit an event.
*
* @param int $eventId
* The event ID.
*
* @return bool
* Whether permission is granted.
*/
public static function checkPerms($eventId)
{
// Admins or users with "edit all events" can edit all events.
if (CRM_Core_Permission::check('edit all events') || CRM_Core_Permission::check('administer CiviCRM')) {
return TRUE;
}
if (!$eventId) {
return NULL;
}
$contactId = CRM_Core_Session::singleton()->get('userID');
// Creators of events can edit their events.
try {
$result = civicrm_api3('Event', 'getcount', array('id' => $eventId, 'created_id' => $contactId));
if (!empty($result)) {
return TRUE;
}
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
CRM_Core_Error::debug_log_message(ts('API Error finding event owner: %1', array('domain' => 'com.aghstrategies.eventpermissions', 1 => $error)));
}
// Hosts of events can edit their events.
try {
// TODO: fix role_id depending upon site-specific naming.
$result = civicrm_api3('Participant', 'getcount', array('contact_id' => $contactId, 'event_id' => $eventId, 'role_id' => "Host"));
if (!empty($result)) {
return TRUE;
}
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
CRM_Core_Error::debug_log_message(ts('API Error finding event owner: %1', array('domain' => 'com.aghstrategies.eventpermissions', 1 => $error)));
}
return FALSE;
}
示例14: smarty_function_crmNavigationMenu
/**
* Output navigation script tag
*
* @param array $params
* - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU)
* @param object $smarty the Smarty object
*
* @return string HTML
*/
function smarty_function_crmNavigationMenu($params, &$smarty)
{
$config = CRM_Core_Config::singleton();
//check if logged in user has access CiviCRM permission and build menu
$buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM');
if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) {
$buildNavigation = FALSE;
}
if ($config->userFrameworkFrontend) {
$buildNavigation = FALSE;
}
if ($buildNavigation) {
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
if ($contactID) {
// These params force the browser to refresh the js file when switching user, domain, or language
// We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url
// We end the string with .js to trick apache mods into sending pro-caching headers
// @see CRM_Admin_Page_AJAX::getNavigationMenu
$lang = $config->lcMessages;
$domain = CRM_Core_Config::domainID();
$key = CRM_Core_BAO_Navigation::getCacheKey($contactID);
$src = CRM_Utils_System::url("civicrm/ajax/menujs/{$contactID}/{$lang}/{$domain}/{$key}.js");
return '<script type="text/javascript" src="' . $src . '"></script>';
}
}
return '';
}
示例15: build_price_options
/**
* Build price options.
*
* @param CRM_Event_BAO_Event $event
*
* @return array
*/
public function build_price_options($event)
{
$price_fields_for_event = array();
$base_field_name = "event_{$event->id}_amount";
$price_set_id = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $event->id);
//CRM-14492 display admin fields only if user is admin
$adminFieldVisible = FALSE;
if (CRM_Core_Permission::check('administer CiviCRM')) {
$adminFieldVisible = TRUE;
}
if ($price_set_id) {
$price_sets = CRM_Price_BAO_PriceSet::getSetDetail($price_set_id, TRUE, TRUE);
$price_set = $price_sets[$price_set_id];
$index = -1;
foreach ($price_set['fields'] as $field) {
$index++;
if (CRM_Utils_Array::value('visibility', $field) == 'public' || CRM_Utils_Array::value('visibility', $field) == 'admin' && $adminFieldVisible == TRUE) {
$field_name = "event_{$event->id}_price_{$field['id']}";
CRM_Price_BAO_PriceField::addQuickFormElement($this, $field_name, $field['id'], FALSE);
$price_fields_for_event[] = $field_name;
}
}
}
return $price_fields_for_event;
}