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