classes/manager/form/scheduler/SpecialEventForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('form.Form');
00018 
00019 class SpecialEventForm extends Form {
00021    var $specialEventId;
00022 
00027    function SpecialEventForm($specialEventId = null) {
00028       $this->specialEventId = isset($specialEventId) ? (int) $specialEventId : null;
00029 
00030       parent::Form('manager/scheduler/specialEventForm.tpl');
00031 
00032       // Type name is provided
00033       $this->addCheck(new FormValidatorLocale($this, 'name', 'required', 'manager.scheduler.specialEvent.form.nameRequired'));
00034 
00035       // Special event must start before it ends
00036       $this->addCheck(new FormValidatorCustom($this, 'endTime', 'required', 'manager.scheduler.specialEvent.form.checkTimes',
00037          create_function('$endTime,$form',
00038          'return ($endTime >= $form->getData(\'startTime\'));'),
00039          array(&$this)));
00040 
00041       $this->addCheck(new FormValidatorPost($this));
00042    }
00043 
00048    function getLocaleFieldNames() {
00049       $specialEventDao =& DAORegistry::getDAO('SpecialEventDAO');
00050       return $specialEventDao->getLocaleFieldNames();
00051    }
00052 
00056    function display() {
00057       $templateMgr =& TemplateManager::getManager();
00058       $schedConf =& Request::getSchedConf();
00059 
00060       $templateMgr->assign('specialEventId', $this->specialEventId);
00061       $templateMgr->assign('helpTopicId', 'conference.currentConferences.specialEvents');
00062 
00063       import('manager.form.TimelineForm');
00064       list($earliestDate, $latestDate) = TimelineForm::getOutsideDates($schedConf);
00065       $templateMgr->assign('firstYear', strftime('%Y', $earliestDate));
00066       $templateMgr->assign('lastYear', strftime('%Y', $latestDate));
00067 
00068       // Get a good default start time
00069       import('manager.form.scheduler.ScheduleForm');
00070       $defaultStartTime = ScheduleForm::getDefaultStartTime();
00071       $templateMgr->assign('defaultStartTime', $defaultStartTime);
00072 
00073       parent::display();
00074    }
00075 
00079    function initData() {
00080       if (isset($this->specialEventId)) {
00081          $specialEventDao =& DAORegistry::getDAO('SpecialEventDAO');
00082          $specialEvent =& $specialEventDao->getSpecialEvent($this->specialEventId);
00083 
00084          if ($specialEvent != null) {
00085             $this->_data = array(
00086                'name' => $specialEvent->getName(null), // Localized
00087                'description' => $specialEvent->getDescription(null), // Localized
00088                'startTime' => $specialEvent->getStartTime(),
00089                'endTime' => $specialEvent->getEndTime()
00090             );
00091 
00092          } else {
00093             $this->specialEventId = null;
00094          }
00095       }
00096    }
00097 
00101    function readInputData() {
00102       $this->readUserVars(array('name', 'description', 'isMultiple'));
00103       $this->readUserDateVars(array('startTime', 'endTime'));
00104       $startTime = $this->getData('startTime');
00105       $endTime = $this->getData('endTime');
00106       list($year, $month, $day) = explode('-', date('Y-m-d', $startTime));
00107       $this->setData('endTime', mktime(
00108          (int) date('H', $endTime),
00109          (int) date('i', $endTime),
00110          (int) date('s', $endTime),
00111          $month, $day, $year
00112       ));
00113    }
00114 
00118    function execute() {
00119       $specialEventDao =& DAORegistry::getDAO('SpecialEventDAO');
00120       $schedConf =& Request::getSchedConf();
00121 
00122       if (isset($this->specialEventId)) {
00123          $specialEvent =& $specialEventDao->getSpecialEvent($this->specialEventId);
00124       }
00125 
00126       if (!isset($specialEvent)) {
00127          $specialEvent = new SpecialEvent();
00128       }
00129 
00130       $specialEvent->setSchedConfId($schedConf->getId());
00131       $specialEvent->setName($this->getData('name'), null); // Localized
00132       $specialEvent->setDescription($this->getData('description'), null); // Localized
00133       $specialEvent->setStartTime(date('Y-m-d H:i:s', $this->getData('startTime')));
00134       $specialEvent->setEndTime(date('Y-m-d H:i:s', $this->getData('endTime')));
00135 
00136       // Update or insert specialEvent
00137       if ($specialEvent->getId() != null) {
00138          $specialEventDao->updateSpecialEvent($specialEvent);
00139       } else {
00140          $specialEventDao->insertSpecialEvent($specialEvent);
00141       }
00142    }
00143 }
00144 
00145 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7