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