3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
37 * Page for displaying list of membership types
39 class CRM_Member_Page_MembershipType
extends CRM_Core_Page
{
42 * The action links that we need to display for the browse screen
47 static $_links = NULL;
52 * @return array (reference) of action links
55 if (!(self
::$_links)) {
56 self
::$_links = array(
57 CRM_Core_Action
::UPDATE
=> array(
59 'url' => 'civicrm/admin/member/membershipType/add',
60 'qs' => 'action=update&id=%%id%%&reset=1',
61 'title' => ts('Edit Membership Type'),
63 CRM_Core_Action
::DISABLE
=> array(
64 'name' => ts('Disable'),
65 'ref' => 'crm-enable-disable',
66 'title' => ts('Disable Membership Type'),
68 CRM_Core_Action
::ENABLE
=> array(
69 'name' => ts('Enable'),
70 'ref' => 'crm-enable-disable',
71 'title' => ts('Enable Membership Type'),
73 CRM_Core_Action
::DELETE
=> array(
74 'name' => ts('Delete'),
75 'url' => 'civicrm/admin/member/membershipType/add',
76 'qs' => 'action=delete&id=%%id%%',
77 'title' => ts('Delete Membership Type'),
87 * This method is called after the page is created. It checks for the
88 * type of action and executes that action.
89 * Finally it calls the parent's run method.
103 * Browse all membership types.
111 CRM_Core_Resources
::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
112 // get all membership types sorted by weight
113 $membershipType = array();
114 $dao = new CRM_Member_DAO_MembershipType();
116 $dao->orderBy('weight');
120 while ($dao->fetch()) {
121 $membershipType[$dao->id
] = array();
122 CRM_Core_DAO
::storeValues($dao, $membershipType[$dao->id
]);
124 //adding column for relationship type label. CRM-4178.
125 if ($dao->relationship_type_id
) {
126 //If membership associated with 2 or more relationship then display all relationship with comma separated
127 $relTypeIds = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $dao->relationship_type_id
);
128 $relTypeNames = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $dao->relationship_direction
);
129 $membershipType[$dao->id
]['relationshipTypeName'] = NULL;
130 foreach ($relTypeIds as $key => $value) {
131 $relationshipName = 'label_' . $relTypeNames[$key];
132 if ($membershipType[$dao->id
]['relationshipTypeName']) {
133 $membershipType[$dao->id
]['relationshipTypeName'] .= ", ";
135 $membershipType[$dao->id
]['relationshipTypeName'] .= CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_RelationshipType',
136 $value, $relationshipName
139 $membershipType[$dao->id
]['maxRelated'] = CRM_Utils_Array
::value('max_related', $membershipType[$dao->id
]);
141 // form all action links
142 $action = array_sum(array_keys($this->links()));
144 // update enable/disable links depending on if it is is_reserved or is_active
145 if (!isset($dao->is_reserved
)) {
146 if ($dao->is_active
) {
147 $action -= CRM_Core_Action
::ENABLE
;
150 $action -= CRM_Core_Action
::DISABLE
;
152 $membershipType[$dao->id
]['order'] = $membershipType[$dao->id
]['weight'];
153 $membershipType[$dao->id
]['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
154 array('id' => $dao->id
),
157 'membershipType.manage.action',
164 $returnURL = CRM_Utils_System
::url('civicrm/admin/member/membershipType', "reset=1&action=browse");
165 CRM_Utils_Weight
::addOrder($membershipType, 'CRM_Member_DAO_MembershipType',
169 CRM_Member_BAO_MembershipType
::convertDayFormat($membershipType);
170 $this->assign('rows', $membershipType);