3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
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 ||
empty($_GET['reset'])) {
44 $tabs = self
::process($form);
45 $form->set('tabHeader', $tabs);
47 $form->assign_by_ref('tabHeader', $tabs);
48 CRM_Core_Resources
::singleton()
49 ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js')
50 ->addSetting(array('tabSettings' => array(
51 'active' => self
::getCurrentTab($tabs),
54 // Preload libraries required by Online Registration Include Profiles
55 $schemas = array('IndividualModel', 'ParticipantModel');
56 if (in_array('CiviMember', CRM_Core_Config
::singleton()->enableComponents
)) {
57 $schemas[] = 'MembershipModel';
59 CRM_UF_Page_ProfileEditor
::registerProfileScripts();
60 CRM_UF_Page_ProfileEditor
::registerSchemas($schemas);
65 static function process(&$form) {
66 if ($form->getVar('_id') <= 0) {
75 'class' => 'ajaxForm',
79 $tabs['settings'] = array('title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage') +
$default;
80 $tabs['location'] = array('title' => ts('Event Location')) +
$default;
81 $tabs['fee'] = array('title' => ts('Fees')) +
$default;
82 $tabs['registration'] = array('title' => ts('Online Registration')) +
$default;
83 if (CRM_Core_Permission
::check('administer CiviCRM')) {
84 $tabs['reminder'] = array('title' => ts('Schedule Reminders'), 'class' => 'livePage') +
$default;
86 $tabs['conference'] = array('title' => ts('Conference Slots')) +
$default;
87 $tabs['friend'] = array('title' => ts('Tell a Friend')) +
$default;
88 $tabs['pcp'] = array('title' => ts('Personal Campaigns')) +
$default;
91 // check if we're in shopping cart mode for events
92 $enableCart = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::EVENT_PREFERENCES_NAME
,
96 unset($tabs['conference']);
99 $eventID = $form->getVar('_id');
101 // disable tabs based on their configuration status
103 SELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.is_active as is_pcp, sch.id as is_reminder
105 LEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )
106 LEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id )
107 LEFT JOIN civicrm_action_mapping map ON ( map.entity_value = 'civicrm_event' )
108 LEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = map.id AND sch.entity_value = %1 )
111 $params = array(1 => array($eventID, 'Integer'));
112 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
113 if (!$dao->fetch()) {
114 CRM_Core_Error
::fatal();
116 if (!$dao->is_location
) {
117 $tabs['location']['valid'] = FALSE;
119 if (!$dao->is_online_registration
) {
120 $tabs['registration']['valid'] = FALSE;
122 if (!$dao->is_monetary
) {
123 $tabs['fee']['valid'] = FALSE;
125 if (!$dao->is_active
) {
126 $tabs['friend']['valid'] = FALSE;
129 $tabs['pcp']['valid'] = FALSE;
131 if (!$dao->is_reminder
) {
132 $tabs['reminder']['valid'] = FALSE;
136 // see if any other modules want to add any tabs
137 // note: status of 'valid' flag of any injected tab, needs to be taken care in the hook implementation.
138 CRM_Utils_Hook
::tabset('civicrm/event/manage', $tabs,
139 array('event_id' => $eventID));
141 $fullName = $form->getVar('_name');
142 $className = CRM_Utils_String
::getClassName($fullName);
144 // hack for special cases.
145 switch ($className) {
147 $attributes = $form->getVar('_attributes');
148 $class = strtolower(basename(CRM_Utils_Array
::value('action', $attributes)));
155 case 'ScheduleReminders':
157 $new = !empty($_GET['new']) ?
'&new=1' : '';
161 $class = strtolower($className);
165 if (array_key_exists($class, $tabs)) {
166 $tabs[$class]['current'] = TRUE;
167 $qfKey = $form->get('qfKey');
169 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
174 $reset = !empty($_GET['reset']) ?
'reset=1&' : '';
176 foreach ($tabs as $key => $value) {
177 if (!isset($tabs[$key]['qfKey'])) {
178 $tabs[$key]['qfKey'] = NULL;
181 $tabs[$key]['link'] = CRM_Utils_System
::url("civicrm/event/manage/{$key}",
182 "{$reset}action=update&id={$eventID}&component=event{$new}{$tabs[$key]['qfKey']}"
190 static function reset(&$form) {
191 $tabs = self
::process($form);
192 $form->set('tabHeader', $tabs);
195 static function getCurrentTab($tabs) {
196 static $current = FALSE;
202 if (is_array($tabs)) {
203 foreach ($tabs as $subPage => $pageVal) {
204 if ($pageVal['current'] === TRUE) {
211 $current = $current ?
$current : 'settings';