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