3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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-2017
37 * Helper class to build navigation links
39 class CRM_Event_Form_ManageEvent_TabHeader
{
42 * @param CRM_Event_Form_ManageEvent $form
46 public 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', 1, 'html-header')
56 'tabSettings' => array(
57 'active' => self
::getCurrentTab($tabs),
60 CRM_Event_Form_ManageEvent
::addProfileEditScripts();
65 * @param CRM_Event_Form_ManageEvent $form
70 public static function process(&$form) {
71 if ($form->getVar('_id') <= 0) {
80 'class' => 'ajaxForm',
84 $tabs['settings'] = array('title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage') +
$default;
85 $tabs['location'] = array('title' => ts('Event Location')) +
$default;
86 $tabs['fee'] = array('title' => ts('Fees')) +
$default;
87 $tabs['registration'] = array('title' => ts('Online Registration')) +
$default;
88 if (CRM_Core_Permission
::check('administer CiviCRM') || CRM_Event_BAO_Event
::checkPermission(NULL, CRM_Core_Permission
::EDIT
)) {
89 $tabs['reminder'] = array('title' => ts('Schedule Reminders'), 'class' => 'livePage') +
$default;
91 $tabs['conference'] = array('title' => ts('Conference Slots')) +
$default;
92 $tabs['friend'] = array('title' => ts('Tell a Friend')) +
$default;
93 $tabs['pcp'] = array('title' => ts('Personal Campaigns')) +
$default;
94 $tabs['repeat'] = array('title' => ts('Repeat')) +
$default;
96 // Repeat tab must refresh page when switching repeat mode so js & vars will get set-up
97 if (!$form->_isRepeatingEvent
) {
98 unset($tabs['repeat']['class']);
101 // check if we're in shopping cart mode for events
102 $enableCart = Civi
::settings()->get('enable_cart');
104 unset($tabs['conference']);
107 $eventID = $form->getVar('_id');
109 // disable tabs based on their configuration status
110 $eventNameMapping = CRM_Utils_Array
::first(CRM_Core_BAO_ActionSchedule
::getMappings(array(
111 'id' => CRM_Event_ActionMapping
::EVENT_NAME_MAPPING_ID
,
114 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, re.id as is_repeating_event
116 LEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )
117 LEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id )
118 LEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = %2 AND sch.entity_value = %1 )
119 LEFT JOIN civicrm_recurring_entity re ON ( e.id = re.entity_id AND re.entity_table = 'civicrm_event' )
122 //Check if repeat is configured
123 $eventHasParent = CRM_Core_BAO_RecurringEntity
::getParentFor($eventID, 'civicrm_event');
125 1 => array($eventID, 'Integer'),
126 2 => array($eventNameMapping->getId(), 'Integer'),
128 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
129 if (!$dao->fetch()) {
130 CRM_Core_Error
::fatal();
132 if (!$dao->is_location
) {
133 $tabs['location']['valid'] = FALSE;
135 if (!$dao->is_online_registration
) {
136 $tabs['registration']['valid'] = FALSE;
138 if (!$dao->is_monetary
) {
139 $tabs['fee']['valid'] = FALSE;
141 if (!$dao->is_active
) {
142 $tabs['friend']['valid'] = FALSE;
145 $tabs['pcp']['valid'] = FALSE;
147 if (!$dao->is_reminder
) {
148 $tabs['reminder']['valid'] = FALSE;
150 if (!$dao->is_repeating_event
) {
151 $tabs['repeat']['valid'] = FALSE;
155 // see if any other modules want to add any tabs
156 // note: status of 'valid' flag of any injected tab, needs to be taken care in the hook implementation.
157 CRM_Utils_Hook
::tabset('civicrm/event/manage', $tabs,
158 array('event_id' => $eventID));
160 $fullName = $form->getVar('_name');
161 $className = CRM_Utils_String
::getClassName($fullName);
164 // hack for special cases.
165 switch ($className) {
167 $attributes = $form->getVar('_attributes');
168 $class = strtolower(basename(CRM_Utils_Array
::value('action', $attributes)));
175 case 'ScheduleReminders':
180 $class = strtolower($className);
184 if (array_key_exists($class, $tabs)) {
185 $tabs[$class]['current'] = TRUE;
186 $qfKey = $form->get('qfKey');
188 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
193 $reset = !empty($_GET['reset']) ?
'reset=1&' : '';
195 foreach ($tabs as $key => $value) {
196 if (!isset($tabs[$key]['qfKey'])) {
197 $tabs[$key]['qfKey'] = NULL;
201 if ($key == 'reminder') {
205 $link = "civicrm/event/manage/{$key}";
206 $query = "{$reset}action={$action}&id={$eventID}&component=event{$tabs[$key]['qfKey']}";
208 $tabs[$key]['link'] = (isset($value['link']) ?
$value['link'] :
209 CRM_Utils_System
::url($link, $query));
217 * @param CRM_Event_Form_ManageEvent $form
219 public static function reset(&$form) {
220 $tabs = self
::process($form);
221 $form->set('tabHeader', $tabs);
229 public static function getCurrentTab($tabs) {
230 static $current = FALSE;
236 if (is_array($tabs)) {
237 foreach ($tabs as $subPage => $pageVal) {
238 if ($pageVal['current'] === TRUE) {
245 $current = $current ?
$current : 'settings';