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