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