| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 5 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
| 7 | +--------------------------------------------------------------------+ |
| 8 | | This file is a part of CiviCRM. | |
| 9 | | | |
| 10 | | CiviCRM is free software; you can copy, modify, and distribute it | |
| 11 | | under the terms of the GNU Affero General Public License | |
| 12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | |
| 13 | | | |
| 14 | | CiviCRM is distributed in the hope that it will be useful, but | |
| 15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 17 | | See the GNU Affero General Public License for more details. | |
| 18 | | | |
| 19 | | You should have received a copy of the GNU Affero General Public | |
| 20 | | License and the CiviCRM Licensing Exception along | |
| 21 | | with this program; if not, contact CiviCRM LLC | |
| 22 | | at info[AT]civicrm[DOT]org. If you have questions about the | |
| 23 | | GNU Affero General Public License or the licensing of CiviCRM, | |
| 24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | |
| 25 | +--------------------------------------------------------------------+ |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * This class introduces component to the system and provides all the |
| 30 | * information about it. It needs to extend CRM_Core_Component_Info |
| 31 | * abstract class. |
| 32 | * |
| 33 | * @package CRM |
| 34 | * @copyright CiviCRM LLC (c) 2004-2018 |
| 35 | * $Id$ |
| 36 | * |
| 37 | */ |
| 38 | class CRM_Grant_Info extends CRM_Core_Component_Info { |
| 39 | |
| 40 | /** |
| 41 | * @inheritDoc |
| 42 | */ |
| 43 | protected $keyword = 'grant'; |
| 44 | |
| 45 | /** |
| 46 | * @inheritDoc |
| 47 | * @return array |
| 48 | */ |
| 49 | public function getInfo() { |
| 50 | return array( |
| 51 | 'name' => 'CiviGrant', |
| 52 | 'translatedName' => ts('CiviGrant'), |
| 53 | 'title' => 'CiviCRM Grant Management Engine', |
| 54 | 'path' => 'CRM_Grant_', |
| 55 | 'search' => 1, |
| 56 | 'showActivitiesInCore' => 1, |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | /** |
| 62 | * @inheritDoc |
| 63 | * @param bool $getAllUnconditionally |
| 64 | * @param bool $descriptions |
| 65 | * Whether to return permission descriptions |
| 66 | * |
| 67 | * @return array |
| 68 | */ |
| 69 | public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { |
| 70 | $permissions = array( |
| 71 | 'access CiviGrant' => array( |
| 72 | ts('access CiviGrant'), |
| 73 | ts('View all grants'), |
| 74 | ), |
| 75 | 'edit grants' => array( |
| 76 | ts('edit grants'), |
| 77 | ts('Create and update grants'), |
| 78 | ), |
| 79 | 'delete in CiviGrant' => array( |
| 80 | ts('delete in CiviGrant'), |
| 81 | ts('Delete grants'), |
| 82 | ), |
| 83 | ); |
| 84 | |
| 85 | if (!$descriptions) { |
| 86 | foreach ($permissions as $name => $attr) { |
| 87 | $permissions[$name] = array_shift($attr); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | return $permissions; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @inheritDoc |
| 96 | * @return null |
| 97 | */ |
| 98 | public function getUserDashboardElement() { |
| 99 | // no dashboard element for this component |
| 100 | return NULL; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * @inheritDoc |
| 105 | * @return null |
| 106 | */ |
| 107 | public function getUserDashboardObject() { |
| 108 | // no dashboard element for this component |
| 109 | return NULL; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * @inheritDoc |
| 114 | * @return array |
| 115 | */ |
| 116 | public function registerTab() { |
| 117 | return array( |
| 118 | 'title' => ts('Grants'), |
| 119 | 'url' => 'grant', |
| 120 | 'weight' => 50, |
| 121 | ); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * @inheritDoc |
| 126 | * @return array |
| 127 | */ |
| 128 | public function registerAdvancedSearchPane() { |
| 129 | return array( |
| 130 | 'title' => ts('Grants'), |
| 131 | 'weight' => 50, |
| 132 | ); |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * @inheritDoc |
| 137 | * @return null |
| 138 | */ |
| 139 | public function getActivityTypes() { |
| 140 | return NULL; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * add shortcut to Create New. |
| 145 | * @param $shortCuts |
| 146 | */ |
| 147 | public function creatNewShortcut(&$shortCuts) { |
| 148 | if (CRM_Core_Permission::check('access CiviGrant') && |
| 149 | CRM_Core_Permission::check('edit grants') |
| 150 | ) { |
| 151 | $shortCuts = array_merge($shortCuts, array( |
| 152 | array( |
| 153 | 'path' => 'civicrm/grant/add', |
| 154 | 'query' => "reset=1&action=add&context=standalone", |
| 155 | 'ref' => 'new-grant', |
| 156 | 'title' => ts('Grant'), |
| 157 | ), |
| 158 | )); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | } |