| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | Copyright CiviCRM LLC. All rights reserved. | |
| 5 | | | |
| 6 | | This work is published under the GNU AGPLv3 license with some | |
| 7 | | permitted exceptions and without any warranty. For full license | |
| 8 | | and copyright information, see https://civicrm.org/licensing | |
| 9 | +--------------------------------------------------------------------+ |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * This class introduces component to the system and provides all the |
| 14 | * information about it. It needs to extend CRM_Core_Component_Info |
| 15 | * abstract class. |
| 16 | * |
| 17 | * @package CRM |
| 18 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
| 19 | */ |
| 20 | class CRM_Campaign_Info extends CRM_Core_Component_Info { |
| 21 | |
| 22 | /** |
| 23 | * @var string |
| 24 | * @inheritDoc |
| 25 | */ |
| 26 | protected $keyword = 'campaign'; |
| 27 | |
| 28 | /** |
| 29 | * @inheritDoc |
| 30 | * @return array |
| 31 | */ |
| 32 | public function getInfo() { |
| 33 | return [ |
| 34 | 'name' => 'CiviCampaign', |
| 35 | 'translatedName' => ts('CiviCampaign'), |
| 36 | 'title' => ts('CiviCRM Campaign Engine'), |
| 37 | 'search' => 1, |
| 38 | 'showActivitiesInCore' => 1, |
| 39 | ]; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @inheritDoc |
| 44 | * @param bool $getAllUnconditionally |
| 45 | * @param bool $descriptions |
| 46 | * Whether to return permission descriptions |
| 47 | * |
| 48 | * @return array |
| 49 | */ |
| 50 | public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { |
| 51 | $permissions = [ |
| 52 | 'administer CiviCampaign' => [ |
| 53 | ts('administer CiviCampaign'), |
| 54 | ts('Create new campaign, survey and petition types and their status'), |
| 55 | ], |
| 56 | 'manage campaign' => [ |
| 57 | ts('manage campaign'), |
| 58 | ts('Create new campaigns, surveys and petitions, reserve respondents'), |
| 59 | ], |
| 60 | 'reserve campaign contacts' => [ |
| 61 | ts('reserve campaign contacts'), |
| 62 | ts('Reserve campaign contacts for surveys and petitions'), |
| 63 | ], |
| 64 | 'release campaign contacts' => [ |
| 65 | ts('release campaign contacts'), |
| 66 | ts('Release reserved campaign contacts for surveys and petitions'), |
| 67 | ], |
| 68 | 'interview campaign contacts' => [ |
| 69 | ts('interview campaign contacts'), |
| 70 | ts('Record survey and petition responses from their reserved contacts'), |
| 71 | ], |
| 72 | 'gotv campaign contacts' => [ |
| 73 | ts('GOTV campaign contacts'), |
| 74 | ts('Record that contacts voted'), |
| 75 | ], |
| 76 | 'sign CiviCRM Petition' => [ |
| 77 | ts('sign CiviCRM Petition'), |
| 78 | ], |
| 79 | ]; |
| 80 | |
| 81 | if (!$descriptions) { |
| 82 | foreach ($permissions as $name => $attr) { |
| 83 | $permissions[$name] = array_shift($attr); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | return $permissions; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * @inheritDoc |
| 92 | * @return null |
| 93 | */ |
| 94 | public function getUserDashboardElement() { |
| 95 | // no dashboard element for this component |
| 96 | return NULL; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * @return null |
| 101 | */ |
| 102 | public function getUserDashboardObject() { |
| 103 | // no dashboard element for this component |
| 104 | return NULL; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * @inheritDoc |
| 109 | * @return null |
| 110 | */ |
| 111 | public function registerTab() { |
| 112 | // this component doesn't use contact record tabs |
| 113 | return NULL; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * @inheritDoc |
| 118 | * @return string |
| 119 | */ |
| 120 | public function getIcon() { |
| 121 | return 'crm-i fa-star-o'; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * @inheritDoc |
| 126 | * @return null |
| 127 | */ |
| 128 | public function registerAdvancedSearchPane() { |
| 129 | // this component doesn't use advanced search |
| 130 | return NULL; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * @inheritDoc |
| 135 | */ |
| 136 | public function getActivityTypes() { |
| 137 | return NULL; |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * add shortcut to Create New. |
| 142 | * @param $shortCuts |
| 143 | */ |
| 144 | public function creatNewShortcut(&$shortCuts) { |
| 145 | if (CRM_Core_Permission::check('manage campaign') || |
| 146 | CRM_Core_Permission::check('administer CiviCampaign') |
| 147 | ) { |
| 148 | $shortCuts = array_merge($shortCuts, [ |
| 149 | [ |
| 150 | 'path' => 'civicrm/campaign/add', |
| 151 | 'query' => "reset=1&action=add", |
| 152 | 'ref' => 'new-campaign', |
| 153 | 'title' => ts('Campaign'), |
| 154 | ], |
| 155 | [ |
| 156 | 'path' => 'civicrm/survey/add', |
| 157 | 'query' => "reset=1&action=add", |
| 158 | 'ref' => 'new-survey', |
| 159 | 'title' => ts('Survey'), |
| 160 | ], |
| 161 | ]); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | } |