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
{
46 static function build(&$form) {
47 $tabs = $form->get('tabHeader');
48 if (!$tabs ||
empty($_GET['reset'])) {
49 $tabs = self
::process($form);
50 $form->set('tabHeader', $tabs);
52 $form->assign_by_ref('tabHeader', $tabs);
53 CRM_Core_Resources
::singleton()
54 ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js')
55 ->addSetting(array('tabSettings' => array(
56 'active' => self
::getCurrentTab($tabs),
58 CRM_Event_Form_ManageEvent
::addProfileEditScripts();
68 static function process(&$form) {
69 if ($form->getVar('_id') <= 0) {
78 'class' => 'ajaxForm',
82 $tabs['settings'] = array('title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage') +
$default;
83 $tabs['location'] = array('title' => ts('Event Location')) +
$default;
84 $tabs['fee'] = array('title' => ts('Fees')) +
$default;
85 $tabs['registration'] = array('title' => ts('Online Registration')) +
$default;
86 if (CRM_Core_Permission
::check('administer CiviCRM')) {
87 $tabs['reminder'] = array('title' => ts('Schedule Reminders'), 'class' => 'livePage') +
$default;
89 $tabs['conference'] = array('title' => ts('Conference Slots')) +
$default;
90 $tabs['friend'] = array('title' => ts('Tell a Friend')) +
$default;
91 $tabs['pcp'] = array('title' => ts('Personal Campaigns')) +
$default;
94 // check if we're in shopping cart mode for events
95 $enableCart = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::EVENT_PREFERENCES_NAME
,
99 unset($tabs['conference']);
102 $eventID = $form->getVar('_id');
104 // disable tabs based on their configuration status
106 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
108 LEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )
109 LEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id )
110 LEFT JOIN civicrm_action_mapping map ON ( map.entity_value = 'civicrm_event' )
111 LEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = map.id AND sch.entity_value = %1 )
114 $params = array(1 => array($eventID, 'Integer'));
115 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
116 if (!$dao->fetch()) {
117 CRM_Core_Error
::fatal();
119 if (!$dao->is_location
) {
120 $tabs['location']['valid'] = FALSE;
122 if (!$dao->is_online_registration
) {
123 $tabs['registration']['valid'] = FALSE;
125 if (!$dao->is_monetary
) {
126 $tabs['fee']['valid'] = FALSE;
128 if (!$dao->is_active
) {
129 $tabs['friend']['valid'] = FALSE;
132 $tabs['pcp']['valid'] = FALSE;
134 if (!$dao->is_reminder
) {
135 $tabs['reminder']['valid'] = FALSE;
139 // see if any other modules want to add any tabs
140 // note: status of 'valid' flag of any injected tab, needs to be taken care in the hook implementation.
141 CRM_Utils_Hook
::tabset('civicrm/event/manage', $tabs,
142 array('event_id' => $eventID));
144 $fullName = $form->getVar('_name');
145 $className = CRM_Utils_String
::getClassName($fullName);
147 // hack for special cases.
148 switch ($className) {
150 $attributes = $form->getVar('_attributes');
151 $class = strtolower(basename(CRM_Utils_Array
::value('action', $attributes)));
158 case 'ScheduleReminders':
160 $new = !empty($_GET['new']) ?
'&new=1' : '';
164 $class = strtolower($className);
168 if (array_key_exists($class, $tabs)) {
169 $tabs[$class]['current'] = TRUE;
170 $qfKey = $form->get('qfKey');
172 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
177 $reset = !empty($_GET['reset']) ?
'reset=1&' : '';
179 foreach ($tabs as $key => $value) {
180 if (!isset($tabs[$key]['qfKey'])) {
181 $tabs[$key]['qfKey'] = NULL;
184 $tabs[$key]['link'] = CRM_Utils_System
::url("civicrm/event/manage/{$key}",
185 "{$reset}action=update&id={$eventID}&component=event{$new}{$tabs[$key]['qfKey']}"
196 static function reset(&$form) {
197 $tabs = self
::process($form);
198 $form->set('tabHeader', $tabs);
206 static function getCurrentTab($tabs) {
207 static $current = FALSE;
213 if (is_array($tabs)) {
214 foreach ($tabs as $subPage => $pageVal) {
215 if ($pageVal['current'] === TRUE) {
222 $current = $current ?
$current : 'settings';