3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
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
,
115 unset($tabs['conference']);
118 $eventID = $form->getVar('_id');
120 $fullName = $form->getVar('_name');
121 $className = CRM_Utils_String
::getClassName($fullName);
123 // hack for special cases.
124 switch ($className) {
126 $attributes = $form->getVar('_attributes');
127 $class = strtolower(basename(CRM_Utils_Array
::value('action', $attributes)));
130 case 'ScheduleReminders':
132 $new = CRM_Utils_Array
::value('new', $_GET) ?
'&new=1' : '';
136 $class = strtolower($className);
140 if (array_key_exists($class, $tabs)) {
141 $tabs[$class]['current'] = TRUE;
142 $qfKey = $form->get('qfKey');
144 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
149 $reset = CRM_Utils_Array
::value('reset', $_GET) ?
'reset=1&' : '';
151 foreach ($tabs as $key => $value) {
152 if (!isset($tabs[$key]['qfKey'])) {
153 $tabs[$key]['qfKey'] = NULL;
156 $tabs[$key]['link'] = CRM_Utils_System
::url("civicrm/event/manage/{$key}",
157 "{$reset}action=update&snippet=5&id={$eventID}&component=event{$new}{$tabs[$key]['qfKey']}"
159 $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
162 // retrieve info about paid event, tell a friend and online reg
164 SELECT e.is_online_registration, e.is_monetary, taf.is_active
166 LEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )
169 $params = array(1 => array($eventID, 'Integer'));
170 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
171 if (!$dao->fetch()) {
172 CRM_Core_Error
::fatal();
175 if (!$dao->is_online_registration
) {
176 $tabs['registration']['valid'] = FALSE;
179 if (!$dao->is_monetary
) {
180 $tabs['fee']['valid'] = FALSE;
183 if (!$dao->is_active
) {
184 $tabs['friend']['valid'] = FALSE;
187 //calculate if the reminder has been configured for this event
192 static function reset(&$form) {
193 $tabs = self
::process($form);
194 $form->set('tabHeader', $tabs);
197 static function getCurrentTab($tabs) {
198 static $current = FALSE;
204 if (is_array($tabs)) {
205 foreach ($tabs as $subPage => $pageVal) {
206 if ($pageVal['current'] === TRUE) {
213 $current = $current ?
$current : 'settings';