Commit | Line | Data |
---|---|---|
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 | */ |
20 | class CRM_Pledge_Info extends CRM_Core_Component_Info { | |
21 | ||
e7c15cb6 | 22 | /** |
c86d4e7c | 23 | * @var string |
d7923f9a | 24 | * @inheritDoc |
e7c15cb6 | 25 | */ |
6a488035 TO |
26 | protected $keyword = 'pledge'; |
27 | ||
ffd93213 EM |
28 | /** |
29 | * Provides base information about the component. | |
30 | * Needs to be implemented in component's information | |
31 | * class. | |
32 | * | |
a6c01b45 CW |
33 | * @return array |
34 | * collection of required component settings | |
ffd93213 | 35 | */ |
6a488035 | 36 | public function getInfo() { |
be2fb01f | 37 | return [ |
6a488035 TO |
38 | 'name' => 'CiviPledge', |
39 | 'translatedName' => ts('CiviPledge'), | |
40 | 'title' => ts('CiviCRM Pledge Engine'), | |
41 | 'search' => 1, | |
42 | 'showActivitiesInCore' => 1, | |
be2fb01f | 43 | ]; |
6a488035 TO |
44 | } |
45 | ||
ffd93213 | 46 | /** |
d7923f9a | 47 | * @inheritDoc |
ffd93213 EM |
48 | * Provides permissions that are used by component. |
49 | * Needs to be implemented in component's information | |
50 | * class. | |
51 | * | |
52 | * NOTE: if using conditionally permission return, | |
53 | * implementation of $getAllUnconditionally is required. | |
54 | * | |
55 | * @param bool $getAllUnconditionally | |
221b21b4 AH |
56 | * @param bool $descriptions |
57 | * Whether to return permission descriptions | |
ffd93213 | 58 | * |
72b3a70c CW |
59 | * @return array|null |
60 | * collection of permissions, null if none | |
ffd93213 | 61 | */ |
221b21b4 | 62 | public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { |
be2fb01f CW |
63 | $permissions = [ |
64 | 'access CiviPledge' => [ | |
221b21b4 AH |
65 | ts('access CiviPledge'), |
66 | ts('View pledges'), | |
be2fb01f CW |
67 | ], |
68 | 'edit pledges' => [ | |
221b21b4 AH |
69 | ts('edit pledges'), |
70 | ts('Create and update pledges'), | |
be2fb01f CW |
71 | ], |
72 | 'delete in CiviPledge' => [ | |
221b21b4 AH |
73 | ts('delete in CiviPledge'), |
74 | ts('Delete pledges'), | |
be2fb01f CW |
75 | ], |
76 | ]; | |
221b21b4 AH |
77 | |
78 | if (!$descriptions) { | |
79 | foreach ($permissions as $name => $attr) { | |
80 | $permissions[$name] = array_shift($attr); | |
81 | } | |
82 | } | |
83 | ||
84 | return $permissions; | |
6a488035 TO |
85 | } |
86 | ||
ffd93213 | 87 | /** |
d7923f9a | 88 | * @inheritDoc |
ffd93213 EM |
89 | * Provides information about user dashboard element |
90 | * offered by this component. | |
91 | * | |
72b3a70c CW |
92 | * @return array|null |
93 | * collection of required dashboard settings, | |
ffd93213 | 94 | * null if no element offered |
ffd93213 | 95 | */ |
6a488035 | 96 | public function getUserDashboardElement() { |
be2fb01f | 97 | return [ |
353ffa53 | 98 | 'name' => ts('Pledges'), |
6a488035 TO |
99 | 'title' => ts('Your Pledge(s)'), |
100 | // we need to check this permission since you can click on contribution page link for making payment | |
be2fb01f | 101 | 'perm' => ['make online contributions'], |
6a488035 | 102 | 'weight' => 15, |
be2fb01f | 103 | ]; |
6a488035 TO |
104 | } |
105 | ||
ffd93213 | 106 | /** |
d7923f9a | 107 | * @inheritDoc |
ffd93213 EM |
108 | * Provides information about user dashboard element |
109 | * offered by this component. | |
110 | * | |
72b3a70c CW |
111 | * @return array|null |
112 | * collection of required dashboard settings, | |
ffd93213 | 113 | * null if no element offered |
ffd93213 | 114 | */ |
6a488035 | 115 | public function registerTab() { |
be2fb01f | 116 | return [ |
353ffa53 | 117 | 'title' => ts('Pledges'), |
6a488035 TO |
118 | 'url' => 'pledge', |
119 | 'weight' => 25, | |
be2fb01f | 120 | ]; |
6a488035 TO |
121 | } |
122 | ||
b04115b4 CW |
123 | /** |
124 | * @inheritDoc | |
125 | * @return string | |
126 | */ | |
127 | public function getIcon() { | |
128 | return 'crm-i fa-paper-plane'; | |
129 | } | |
130 | ||
ffd93213 | 131 | /** |
d7923f9a | 132 | * @inheritDoc |
ffd93213 EM |
133 | * Provides information about advanced search pane |
134 | * offered by this component. | |
135 | * | |
72b3a70c CW |
136 | * @return array|null |
137 | * collection of required pane settings, | |
ffd93213 | 138 | * null if no element offered |
ffd93213 | 139 | */ |
6a488035 | 140 | public function registerAdvancedSearchPane() { |
be2fb01f | 141 | return [ |
353ffa53 | 142 | 'title' => ts('Pledges'), |
6a488035 | 143 | 'weight' => 25, |
be2fb01f | 144 | ]; |
6a488035 TO |
145 | } |
146 | ||
ffd93213 | 147 | /** |
d7923f9a | 148 | * @inheritDoc |
ffd93213 EM |
149 | * Provides potential activity types that this |
150 | * component might want to register in activity history. | |
151 | * Needs to be implemented in component's information | |
152 | * class. | |
153 | * | |
72b3a70c CW |
154 | * @return array|null |
155 | * collection of activity types | |
ffd93213 | 156 | */ |
6a488035 TO |
157 | public function getActivityTypes() { |
158 | return NULL; | |
159 | } | |
160 | ||
ffd93213 | 161 | /** |
fe482240 | 162 | * add shortcut to Create New. |
ffd93213 EM |
163 | * @param $shortCuts |
164 | */ | |
6a488035 TO |
165 | public function creatNewShortcut(&$shortCuts) { |
166 | if (CRM_Core_Permission::check('access CiviPledge') && | |
167 | CRM_Core_Permission::check('edit pledges') | |
168 | ) { | |
be2fb01f CW |
169 | $shortCuts = array_merge($shortCuts, [ |
170 | [ | |
353ffa53 TO |
171 | 'path' => 'civicrm/pledge/add', |
172 | 'query' => 'reset=1&action=add&context=standalone', | |
173 | 'ref' => 'new-pledge', | |
174 | 'title' => ts('Pledge'), | |
be2fb01f CW |
175 | ], |
176 | ]); | |
6a488035 TO |
177 | } |
178 | } | |
96025800 | 179 | |
6a488035 | 180 | } |