classes/manager/form/TrackForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 // $Id$
00017 
00018 
00019 import('form.Form');
00020 
00021 class TrackForm extends Form {
00022 
00024    var $trackId;
00025 
00030    function TrackForm($trackId = null) {
00031       parent::Form('manager/tracks/trackForm.tpl');
00032 
00033       $conference =& Request::getConference();
00034       $this->trackId = $trackId;
00035 
00036       // Validation checks for this form
00037       $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'manager.tracks.form.titleRequired'));
00038       $this->addCheck(new FormValidatorLocale($this, 'abbrev', 'required', 'manager.tracks.form.abbrevRequired'));
00039       $this->addCheck(new FormValidatorPost($this));
00040 
00041       $this->addCheck(new FormValidatorCustom($this, 'reviewFormId', 'optional', 'manager.sections.form.reviewFormId', array(DAORegistry::getDAO('ReviewFormDAO'), 'reviewFormExists'), array(ASSOC_TYPE_CONFERENCE, $conference->getId())));
00042    }
00043 
00048    function getLocaleFieldNames() {
00049       $trackDao =& DAORegistry::getDAO('TrackDAO');
00050       return $trackDao->getLocaleFieldNames();
00051    }
00052 
00056    function display() {
00057       $conference =& Request::getConference();
00058       $schedConf =& Request::getSchedConf();
00059       $templateMgr =& TemplateManager::getManager();
00060       $templateMgr->assign('trackId', $this->trackId);
00061 
00062       if (Request::getUserVar('assignedDirectors') != null) {
00063          // Reloading edit form -- get directors from form data
00064          $unassignedDirectorIds = explode(':', Request::getUserVar('unassignedDirectors'));
00065          $assignedDirectorIds = explode(':', Request::getUserVar('assignedDirectors'));
00066 
00067          $userDao =& DAORegistry::getDAO('UserDAO');
00068 
00069          // Get track directors not assigned to this track
00070          $unassignedDirectors = array();
00071          foreach ($unassignedDirectorIds as $edUserId) {
00072             if (!empty($edUserId)) {
00073                $unassignedDirectors[] =& $userDao->getUser($edUserId);
00074             }
00075          }
00076 
00077          // Get track directors assigned to this track
00078          $assignedDirectors = array();
00079          foreach ($assignedDirectorIds as $edUserId) {
00080             if (!empty($edUserId)) {
00081                $assignedDirectors[] =& $userDao->getUser($edUserId);
00082             }
00083          }
00084 
00085       } else {
00086          $trackDirectorsDao =& DAORegistry::getDAO('TrackDirectorsDAO');
00087 
00088          // Get track directors not assigned to this track
00089          $unassignedDirectors =& $trackDirectorsDao->getDirectorsNotInTrack($schedConf->getId(), $this->trackId);
00090 
00091          // Get track directors assigned to this track
00092          $assignedDirectors =& $trackDirectorsDao->getDirectorsByTrackId($schedConf->getId(), $this->trackId);
00093       }
00094 
00095       $templateMgr->assign('unassignedDirectors', $unassignedDirectors);
00096       $templateMgr->assign('assignedDirectors', $assignedDirectors);
00097       $templateMgr->assign('commentsEnabled', $conference->getSetting('enableComments'));
00098       $templateMgr->assign('helpTopicId','conference.currentConferences.tracks');
00099 
00100       $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO');
00101       $reviewForms =& $reviewFormDao->getActiveByAssocId(ASSOC_TYPE_CONFERENCE, $conference->getId());
00102       $reviewFormOptions = array();
00103       while ($reviewForm =& $reviewForms->next()) {
00104          $reviewFormOptions[$reviewForm->getId()] = $reviewForm->getLocalizedTitle();
00105       }
00106       $templateMgr->assign_by_ref('reviewFormOptions', $reviewFormOptions);
00107 
00108       parent::display();
00109    }
00110 
00114    function initData() {
00115       $conference =& Request::getConference();
00116       $trackDirectorsDao =& DAORegistry::getDAO('TrackDirectorsDAO');
00117       
00118       if (isset($this->trackId)) {
00119          $trackDao =& DAORegistry::getDAO('TrackDAO');
00120          $track =& $trackDao->getTrack($this->trackId);
00121 
00122          if ($track == null) {
00123             unset($this->trackId);
00124          } else {
00125             $this->_data = array(
00126                'title' => $track->getTitle(null), // Localized
00127                'abbrev' => $track->getAbbrev(null), // Localized
00128                'reviewFormId' => $track->getReviewFormId(),
00129                'metaNotReviewed' => $track->getMetaReviewed()?0:1,
00130                'identifyType' => $track->getIdentifyType(null), // Localized
00131                'directorRestriction' => $track->getDirectorRestricted(),
00132                'policy' => $track->getPolicy(null), // Localized
00133                'hideAbout' => $track->getHideAbout(),
00134                'disableComments' => $track->getDisableComments(),
00135                'wordCount' => $track->getAbstractWordCount()
00136             );
00137          }
00138       } else {
00139          $this->_data = array(
00140             'unassignedDirectors' => $trackDirectorsDao->getDirectorsNotInTrack($conference->getId(), null)
00141          );
00142 
00143       }
00144    }
00145 
00149    function readInputData() {
00150       $this->readUserVars(array('title', 'abbrev', 'policy', 'reviewFormId', 'metaNotReviewed', 'identifyType', 'directorRestriction', 'hideAbout', 'disableComments', 'wordCount'));
00151    }
00152 
00156    function execute() {
00157       $schedConf =& Request::getSchedConf();
00158 
00159       $trackDao =& DAORegistry::getDAO('TrackDAO');
00160 
00161       if (isset($this->trackId)) {
00162          $track =& $trackDao->getTrack($this->trackId);
00163       }
00164 
00165       if (!isset($track)) {
00166          $track = new Track();
00167          $track->setSchedConfId($schedConf->getId());
00168          $track->setSequence(REALLY_BIG_NUMBER);
00169       }
00170 
00171       $track->setTitle($this->getData('title'), null); // Localized
00172       $track->setAbbrev($this->getData('abbrev'), null); // Localized
00173       $reviewFormId = $this->getData('reviewFormId');
00174       if ($reviewFormId === '') $reviewFormId = null;
00175       $track->setReviewFormId($reviewFormId);
00176       $track->setMetaReviewed($this->getData('metaNotReviewed') ? 0 : 1);
00177       $track->setIdentifyType($this->getData('identifyType'), null); // Localized
00178       $track->setDirectorRestricted($this->getData('directorRestriction') ? 1 : 0);
00179       $track->setPolicy($this->getData('policy'), null); // Localized
00180       $track->setHideAbout($this->getData('hideAbout'));
00181       $track->setDisableComments($this->getData('disableComments') ? 1 : 0);
00182       $track->setAbstractWordCount($this->getData('wordCount'));
00183 
00184       if ($track->getId() != null) {
00185          $trackDao->updateTrack($track);
00186          $trackId = $track->getId();
00187       } else {
00188          $trackId = $trackDao->insertTrack($track);
00189          $trackDao->resequenceTracks($schedConf->getId());
00190       }
00191 
00192       // Save assigned directors
00193       $trackDirectorsDao =& DAORegistry::getDAO('TrackDirectorsDAO');
00194       $trackDirectorsDao->deleteDirectorsByTrackId($trackId, $schedConf->getId());
00195       $directors = explode(':', Request::getUserVar('assignedDirectors'));
00196       foreach ($directors as $edUserId) {
00197          if (!empty($edUserId)) {
00198             $trackDirectorsDao->insertDirector($schedConf->getId(), $trackId, $edUserId);
00199          }
00200       }
00201    }
00202 }
00203 
00204 ?>

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