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 'settings' => array('title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage') +
$default,
80 'location' => array('title' => ts('Event Location')) +
$default,
81 'fee' => array('title' => ts('Fees')) +
$default,
82 'registration' => array('title' => ts('Online Registration')) +
$default,
83 'reminder' => array('title' => ts('Schedule Reminders'), 'class' => 'livePage') +
$default,
84 'conference' => array('title' => ts('Conference Slots')) +
$default,
85 'friend' => array('title' => ts('Tell a Friend')) +
$default,
86 'pcp' => array('title' => ts('Personal Campaigns')) +
$default,
89 // check if we're in shopping cart mode for events
90 $enableCart = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::EVENT_PREFERENCES_NAME
,
94 unset($tabs['conference']);
97 $eventID = $form->getVar('_id');
99 // disable tabs based on their configuration status
101 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
103 LEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )
104 LEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id )
105 LEFT JOIN civicrm_action_mapping map ON ( map.entity_value = 'civicrm_event' )
106 LEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = map.id AND sch.entity_value = %1 )
109 $params = array(1 => array($eventID, 'Integer'));
110 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
111 if (!$dao->fetch()) {
112 CRM_Core_Error
::fatal();
114 if (!$dao->is_location
) {
115 $tabs['location']['valid'] = FALSE;
117 if (!$dao->is_online_registration
) {
118 $tabs['registration']['valid'] = FALSE;
120 if (!$dao->is_monetary
) {
121 $tabs['fee']['valid'] = FALSE;
123 if (!$dao->is_active
) {
124 $tabs['friend']['valid'] = FALSE;
127 $tabs['pcp']['valid'] = FALSE;
129 if (!$dao->is_reminder
) {
130 $tabs['reminder']['valid'] = FALSE;
134 // see if any other modules want to add any tabs
135 // note: status of 'valid' flag of any injected tab, needs to be taken care in the hook implementation.
136 CRM_Utils_Hook
::tabset('civicrm/event/manage', $tabs,
137 array('event_id' => $eventID));
139 $fullName = $form->getVar('_name');
140 $className = CRM_Utils_String
::getClassName($fullName);
142 // hack for special cases.
143 switch ($className) {
145 $attributes = $form->getVar('_attributes');
146 $class = strtolower(basename(CRM_Utils_Array
::value('action', $attributes)));
153 case 'ScheduleReminders':
155 $new = !empty($_GET['new']) ?
'&new=1' : '';
159 $class = strtolower($className);
163 if (array_key_exists($class, $tabs)) {
164 $tabs[$class]['current'] = TRUE;
165 $qfKey = $form->get('qfKey');
167 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
172 $reset = !empty($_GET['reset']) ?
'reset=1&' : '';
174 foreach ($tabs as $key => $value) {
175 if (!isset($tabs[$key]['qfKey'])) {
176 $tabs[$key]['qfKey'] = NULL;
179 $tabs[$key]['link'] = CRM_Utils_System
::url("civicrm/event/manage/{$key}",
180 "{$reset}action=update&id={$eventID}&component=event{$new}{$tabs[$key]['qfKey']}"
188 static function reset(&$form) {
189 $tabs = self
::process($form);
190 $form->set('tabHeader', $tabs);
193 static function getCurrentTab($tabs) {
194 static $current = FALSE;
200 if (is_array($tabs)) {
201 foreach ($tabs as $subPage => $pageVal) {
202 if ($pageVal['current'] === TRUE) {
209 $current = $current ?
$current : 'settings';