本文整理汇总了PHP中CRM_Utils_Hook::shortcuts方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Hook::shortcuts方法的具体用法?PHP CRM_Utils_Hook::shortcuts怎么用?PHP CRM_Utils_Hook::shortcuts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Hook
的用法示例。
在下文中一共展示了CRM_Utils_Hook::shortcuts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setTemplateShortcutValues
/**
* create the list of options to create New objects for the application and format is as a block
*
* @return void
* @access private
*/
private function setTemplateShortcutValues()
{
$config =& CRM_Core_Config::singleton();
static $shortCuts = array();
if (!$shortCuts) {
if (CRM_Core_Permission::check('add contacts')) {
require_once 'CRM/Contact/BAO/ContactType.php';
$shortCuts = CRM_Contact_BAO_ContactType::getCreateNewList();
if (CRM_Core_Permission::access('Quest')) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/quest/search', 'query' => 'reset=1', 'ref' => 'quest-search', 'title' => ts('Quest Search'))));
}
}
// new activity (select target contact)
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/activity', 'query' => 'action=add&reset=1&context=standalone', 'ref' => 'new-activity', 'title' => ts('Activity'))));
if (CRM_Core_Permission::check('access CiviCase') && CRM_Core_Permission::check('add contacts') && in_array('CiviCase', $config->enableComponents)) {
require_once 'CRM/Core/OptionGroup.php';
$atype = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
if ($atype) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/case/add', 'query' => "reset=1&action=add&atype={$atype}&context=standalone", 'ref' => 'new-case', 'title' => ts('Case'))));
}
}
if (CRM_Core_Permission::check('access CiviContribute') && CRM_Core_Permission::check('edit contributions') && in_array('CiviContribute', $config->enableComponents)) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/contribute/add', 'query' => "reset=1&action=add&context=standalone", 'ref' => 'new-contribution', 'title' => ts('Contribution'))));
}
// new email (select recipients)
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/activity/add', 'query' => 'atype=3&action=add&reset=1&context=standalone', 'ref' => 'new-email', 'title' => ts('Email'))));
if (CRM_Core_Permission::check('access CiviEvent') && CRM_Core_Permission::check('edit event participants') && in_array('CiviEvent', $config->enableComponents)) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/participant/add', 'query' => "reset=1&action=add&context=standalone", 'ref' => 'new-participant', 'title' => ts('Event Registration'))));
}
if (CRM_Core_Permission::check('access CiviGrant') && CRM_Core_Permission::check('edit grants') && in_array('CiviGrant', $config->enableComponents)) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/grant/add', 'query' => "reset=1&action=add&context=standalone", 'ref' => 'new-grant', 'title' => ts('Grant'))));
}
if (CRM_Core_Permission::check('access CiviMember') && CRM_Core_Permission::check('edit memberships') && in_array('CiviMember', $config->enableComponents)) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/member/add', 'query' => "reset=1&action=add&context=standalone", 'ref' => 'new-membership', 'title' => ts('Membership'))));
}
if (CRM_Core_Permission::check('access CiviPledge') && CRM_Core_Permission::check('edit pledges') && in_array('CiviPledge', $config->enableComponents)) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/pledge/add', 'query' => "reset=1&action=add&context=standalone", 'ref' => 'new-pledge', 'title' => ts('Pledge'))));
}
if (CRM_Core_Permission::check('edit groups')) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/group/add', 'query' => 'reset=1', 'ref' => 'new-group', 'title' => ts('Group'))));
}
if (CRM_Core_Permission::check('administer CiviCRM')) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/admin/tag', 'query' => 'reset=1&action=add', 'ref' => 'new-tag', 'title' => ts('Tag'))));
}
if (empty($shortCuts)) {
return null;
}
}
$values = array();
foreach ($shortCuts as $short) {
$value = array();
if (isset($short['url'])) {
$value['url'] = $short['url'];
} else {
$value['url'] = CRM_Utils_System::url($short['path'], $short['query'], false);
}
$value['title'] = $short['title'];
$value['ref'] = $short['ref'];
$values[] = $value;
}
// call shortcut hook
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::shortcuts($values);
self::setProperty(self::CREATE_NEW, 'templateValues', array('shortCuts' => $values));
}