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