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 * Helper class to build navigation links
39 class CRM_Event_Form_ManageEvent_TabHeader
{
41 static function build(&$form) {
42 $tabs = $form->get('tabHeader');
43 if (!$tabs ||
!CRM_Utils_Array
::value('reset', $_GET)) {
44 $tabs = self
::process($form);
45 $form->set('tabHeader', $tabs);
47 $form->assign_by_ref('tabHeader', $tabs);
48 $selectedTab = self
::getCurrentTab($tabs);
49 $form->assign_by_ref('selectedTab', $selectedTab);
53 static function process(&$form) {
54 if ($form->getVar('_id') <= 0) {
59 'settings' => array('title' => ts('Info and Settings'),
65 'location' => array('title' => ts('Event Location'),
71 'fee' => array('title' => ts('Fees'),
77 'registration' => array('title' => ts('Online Registration'),
83 'reminder' => array('title' => ts('Schedule Reminders'),
89 'conference' => array('title' => ts('Conference Slots'),
95 'friend' => array('title' => ts('Tell a Friend'),
101 'pcp' => array('title' => ts('Personal Campaigns'),
109 // check if we're in shopping cart mode for events
110 $enableCart = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::EVENT_PREFERENCES_NAME
,
114 unset($tabs['conference']);
117 $eventID = $form->getVar('_id');
119 // disable tabs based on their configuration status
121 SELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.id as is_pcp, sch.id as is_reminder
123 LEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )
124 LEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id )
125 LEFT JOIN civicrm_action_mapping map ON ( map.entity_value = 'civicrm_event' )
126 LEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = map.id AND sch.entity_value = %1 )
129 $params = array(1 => array($eventID, 'Integer'));
130 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
131 if (!$dao->fetch()) {
132 CRM_Core_Error
::fatal();
134 if (!$dao->is_location
) {
135 $tabs['location']['valid'] = FALSE;
137 if (!$dao->is_online_registration
) {
138 $tabs['registration']['valid'] = FALSE;
140 if (!$dao->is_monetary
) {
141 $tabs['fee']['valid'] = FALSE;
143 if (!$dao->is_active
) {
144 $tabs['friend']['valid'] = FALSE;
147 $tabs['pcp']['valid'] = FALSE;
149 if (!$dao->is_reminder
) {
150 $tabs['reminder']['valid'] = FALSE;
154 // see if any other modules want to add any tabs
155 // note: status of 'valid' flag of any injected tab, needs to be taken care in the hook implementation.
156 CRM_Utils_Hook
::tabset('civicrm/event/manage', $tabs,
157 array('event_id' => $eventID));
159 $fullName = $form->getVar('_name');
160 $className = CRM_Utils_String
::getClassName($fullName);
162 // hack for special cases.
163 switch ($className) {
165 $attributes = $form->getVar('_attributes');
166 $class = strtolower(basename(CRM_Utils_Array
::value('action', $attributes)));
169 case 'ScheduleReminders':
171 $new = CRM_Utils_Array
::value('new', $_GET) ?
'&new=1' : '';
175 $class = strtolower($className);
179 if (array_key_exists($class, $tabs)) {
180 $tabs[$class]['current'] = TRUE;
181 $qfKey = $form->get('qfKey');
183 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
188 $reset = CRM_Utils_Array
::value('reset', $_GET) ?
'reset=1&' : '';
190 foreach ($tabs as $key => $value) {
191 if (!isset($tabs[$key]['qfKey'])) {
192 $tabs[$key]['qfKey'] = NULL;
195 $tabs[$key]['link'] = CRM_Utils_System
::url("civicrm/event/manage/{$key}",
196 "{$reset}action=update&snippet=5&id={$eventID}&component=event{$new}{$tabs[$key]['qfKey']}"
204 static function reset(&$form) {
205 $tabs = self
::process($form);
206 $form->set('tabHeader', $tabs);
209 static function getCurrentTab($tabs) {
210 static $current = FALSE;
216 if (is_array($tabs)) {
217 foreach ($tabs as $subPage => $pageVal) {
218 if ($pageVal['current'] === TRUE) {
225 $current = $current ?
$current : 'settings';