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