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