/** * 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)); }
/** * Create the list of options to create New objects for the application and format is as a block. * * @return void */ private static function setTemplateShortcutValues() { $config = CRM_Core_Config::singleton(); static $shortCuts = array(); if (!$shortCuts) { if (CRM_Core_Permission::check('add contacts')) { if (CRM_Core_Permission::giveMeAllACLs()) { $shortCuts = CRM_Contact_BAO_ContactType::getCreateNewList(); } } // 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')))); $components = CRM_Core_Component::getEnabledComponents(); if (!empty($config->enableComponents)) { // check if we can process credit card contribs $newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments(); foreach ($components as $componentName => $obj) { if (in_array($componentName, $config->enableComponents)) { $obj->creatNewShortcut($shortCuts, $newCredit); } } } // new email (select recipients) $shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/activity/email/add', 'query' => 'atype=3&action=add&reset=1&context=standalone', 'ref' => 'new-email', 'title' => ts('Email')))); 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 $key => $short) { $values[$key] = self::setShortCutValues($short); } // call links hook to add user defined links CRM_Utils_Hook::links('create.new.shorcuts', NULL, CRM_Core_DAO::$_nullObject, $values, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject); foreach ($values as $key => $val) { if (!empty($val['title'])) { $values[$key]['name'] = CRM_Utils_Array::value('name', $val, $val['title']); } } self::setProperty(self::CREATE_NEW, 'templateValues', array('shortCuts' => $values)); }
/** * 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')) { if (CRM_Core_Permission::giveMeAllACLs()) { $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')))); $components = CRM_Core_Component::getEnabledComponents(); if (!empty($config->enableComponents)) { foreach ($components as $componentName => $obj) { if (in_array($componentName, $config->enableComponents)) { eval('$obj->creatNewShortcut( $shortCuts );'); } } } // new email (select recipients) $shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/activity/email/add', 'query' => 'atype=3&action=add&reset=1&context=standalone', 'ref' => 'new-email', 'title' => ts('Email')))); 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 links hook to add user defined links CRM_Utils_Hook::links('create.new.shorcuts', NULL, CRM_Core_DAO::$_nullObject, $values, CRM_Core_DAO::$_nullObject); self::setProperty(self::CREATE_NEW, 'templateValues', array('shortCuts' => $values)); }