Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
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 | |
6b83d5bd | 34 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
35 | * $Id$ |
36 | * | |
37 | */ | |
38 | class CRM_Member_Info extends CRM_Core_Component_Info { | |
39 | ||
e7c15cb6 | 40 | /** |
971e129b | 41 | * @var string |
e7c15cb6 CW |
42 | * @inheritDoc |
43 | */ | |
6a488035 TO |
44 | protected $keyword = 'member'; |
45 | ||
bb3a214a | 46 | /** |
e7c15cb6 | 47 | * @inheritDoc |
bb3a214a EM |
48 | * Provides base information about the component. |
49 | * Needs to be implemented in component's information | |
50 | * class. | |
51 | * | |
a6c01b45 CW |
52 | * @return array |
53 | * collection of required component settings | |
bb3a214a | 54 | */ |
971e129b | 55 | |
bb3a214a EM |
56 | /** |
57 | * @return array | |
58 | */ | |
6a488035 | 59 | public function getInfo() { |
be2fb01f | 60 | return [ |
6a488035 TO |
61 | 'name' => 'CiviMember', |
62 | 'translatedName' => ts('CiviMember'), | |
e300cf31 | 63 | 'title' => ts('CiviCRM Membership Engine'), |
6a488035 TO |
64 | 'search' => 1, |
65 | 'showActivitiesInCore' => 1, | |
be2fb01f | 66 | ]; |
6a488035 TO |
67 | } |
68 | ||
bb3a214a | 69 | /** |
e7c15cb6 | 70 | * @inheritDoc |
bb3a214a EM |
71 | * Provides permissions that are used by component. |
72 | * Needs to be implemented in component's information | |
73 | * class. | |
74 | * | |
75 | * NOTE: if using conditionally permission return, | |
76 | * implementation of $getAllUnconditionally is required. | |
77 | * | |
78 | * @param bool $getAllUnconditionally | |
221b21b4 AH |
79 | * @param bool $descriptions |
80 | * Whether to return permission descriptions | |
bb3a214a | 81 | * |
72b3a70c CW |
82 | * @return array|null |
83 | * collection of permissions, null if none | |
bb3a214a | 84 | */ |
221b21b4 | 85 | public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { |
be2fb01f CW |
86 | $permissions = [ |
87 | 'access CiviMember' => [ | |
221b21b4 AH |
88 | ts('access CiviMember'), |
89 | ts('View memberships'), | |
be2fb01f CW |
90 | ], |
91 | 'edit memberships' => [ | |
221b21b4 AH |
92 | ts('edit memberships'), |
93 | ts('Create and update memberships'), | |
be2fb01f CW |
94 | ], |
95 | 'delete in CiviMember' => [ | |
221b21b4 AH |
96 | ts('delete in CiviMember'), |
97 | ts('Delete memberships'), | |
be2fb01f CW |
98 | ], |
99 | ]; | |
221b21b4 AH |
100 | |
101 | if (!$descriptions) { | |
102 | foreach ($permissions as $name => $attr) { | |
103 | $permissions[$name] = array_shift($attr); | |
104 | } | |
105 | } | |
106 | ||
107 | return $permissions; | |
6a488035 TO |
108 | } |
109 | ||
bb3a214a | 110 | /** |
e7c15cb6 | 111 | * @inheritDoc |
bb3a214a EM |
112 | * Provides information about user dashboard element |
113 | * offered by this component. | |
114 | * | |
72b3a70c CW |
115 | * @return array|null |
116 | * collection of required dashboard settings, | |
bb3a214a | 117 | * null if no element offered |
bb3a214a | 118 | */ |
971e129b | 119 | |
bb3a214a EM |
120 | /** |
121 | * @return array|null | |
122 | */ | |
6a488035 | 123 | public function getUserDashboardElement() { |
be2fb01f | 124 | return [ |
353ffa53 | 125 | 'name' => ts('Memberships'), |
6a488035 TO |
126 | 'title' => ts('Your Membership(s)'), |
127 | // this is CiviContribute specific permission, since | |
128 | // there is no permission that could be checked for | |
129 | // CiviMember | |
be2fb01f | 130 | 'perm' => ['make online contributions'], |
6a488035 | 131 | 'weight' => 30, |
be2fb01f | 132 | ]; |
6a488035 TO |
133 | } |
134 | ||
bb3a214a | 135 | /** |
e7c15cb6 | 136 | * @inheritDoc |
bb3a214a EM |
137 | * Provides information about user dashboard element |
138 | * offered by this component. | |
139 | * | |
72b3a70c CW |
140 | * @return array|null |
141 | * collection of required dashboard settings, | |
bb3a214a | 142 | * null if no element offered |
bb3a214a | 143 | */ |
971e129b | 144 | |
bb3a214a EM |
145 | /** |
146 | * @return array|null | |
147 | */ | |
6a488035 | 148 | public function registerTab() { |
be2fb01f | 149 | return [ |
353ffa53 | 150 | 'title' => ts('Memberships'), |
6a488035 TO |
151 | 'url' => 'membership', |
152 | 'weight' => 30, | |
be2fb01f | 153 | ]; |
6a488035 TO |
154 | } |
155 | ||
b04115b4 CW |
156 | /** |
157 | * @inheritDoc | |
158 | * @return string | |
159 | */ | |
160 | public function getIcon() { | |
161 | return 'crm-i fa-id-badge'; | |
162 | } | |
163 | ||
bb3a214a | 164 | /** |
e7c15cb6 | 165 | * @inheritDoc |
bb3a214a EM |
166 | * Provides information about advanced search pane |
167 | * offered by this component. | |
168 | * | |
72b3a70c CW |
169 | * @return array|null |
170 | * collection of required pane settings, | |
bb3a214a | 171 | * null if no element offered |
bb3a214a | 172 | */ |
971e129b | 173 | |
bb3a214a EM |
174 | /** |
175 | * @return array|null | |
176 | */ | |
6a488035 | 177 | public function registerAdvancedSearchPane() { |
be2fb01f | 178 | return [ |
353ffa53 | 179 | 'title' => ts('Memberships'), |
6a488035 | 180 | 'weight' => 30, |
be2fb01f | 181 | ]; |
6a488035 TO |
182 | } |
183 | ||
bb3a214a | 184 | /** |
e7c15cb6 | 185 | * @inheritDoc |
bb3a214a EM |
186 | * Provides potential activity types that this |
187 | * component might want to register in activity history. | |
188 | * Needs to be implemented in component's information | |
189 | * class. | |
190 | * | |
72b3a70c CW |
191 | * @return array|null |
192 | * collection of activity types | |
bb3a214a | 193 | */ |
971e129b | 194 | |
bb3a214a EM |
195 | /** |
196 | * @return array|null | |
197 | */ | |
6a488035 TO |
198 | public function getActivityTypes() { |
199 | return NULL; | |
200 | } | |
201 | ||
bb3a214a | 202 | /** |
fe482240 | 203 | * add shortcut to Create New. |
bb3a214a EM |
204 | * @param $shortCuts |
205 | * @param $newCredit | |
206 | */ | |
6a488035 TO |
207 | public function creatNewShortcut(&$shortCuts, $newCredit) { |
208 | if (CRM_Core_Permission::check('access CiviMember') && | |
209 | CRM_Core_Permission::check('edit memberships') | |
210 | ) { | |
be2fb01f | 211 | $shortCut[] = [ |
6b5ca1ea | 212 | 'path' => 'civicrm/member/add', |
213 | 'query' => "reset=1&action=add&context=standalone", | |
214 | 'ref' => 'new-membership', | |
215 | 'title' => ts('Membership'), | |
be2fb01f | 216 | ]; |
6a488035 TO |
217 | if ($newCredit) { |
218 | $title = ts('Membership') . '<br /> (' . ts('credit card') . ')'; | |
be2fb01f | 219 | $shortCut[0]['shortCuts'][] = [ |
6b5ca1ea | 220 | 'path' => 'civicrm/member/add', |
221 | 'query' => "reset=1&action=add&context=standalone&mode=live", | |
222 | 'ref' => 'new-membership-cc', | |
223 | 'title' => $title, | |
be2fb01f | 224 | ]; |
6a488035 | 225 | } |
6b5ca1ea | 226 | $shortCuts = array_merge($shortCuts, $shortCut); |
6a488035 TO |
227 | } |
228 | } | |
96025800 | 229 | |
6a488035 | 230 | } |