classes/manager/form/ReviewFormElementForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 import('form.Form');
00017 
00018 class ReviewFormElementForm extends Form {
00019 
00021    var $reviewFormId;
00022 
00024    var $reviewFormElementId;
00025 
00031    function ReviewFormElementForm($reviewFormId, $reviewFormElementId = null) {
00032       parent::Form('manager/reviewForms/reviewFormElementForm.tpl');
00033 
00034       $this->reviewFormId = $reviewFormId;
00035       $this->reviewFormElementId = $reviewFormElementId;
00036 
00037       // Validation checks for this form
00038       $this->addCheck(new FormValidatorLocale($this, 'question', 'required', 'manager.reviewFormElements.form.questionRequired'));
00039       $this->addCheck(new FormValidator($this, 'elementType', 'required', 'manager.reviewFormElements.form.elementTypeRequired'));
00040       $this->addCheck(new FormValidatorPost($this));
00041    }
00042 
00047    function getLocaleFieldNames() {
00048       $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
00049       return $reviewFormElementDao->getLocaleFieldNames();
00050    }
00051 
00055    function display() {
00056       $templateMgr =& TemplateManager::getManager();
00057       $templateMgr->assign('reviewFormId', $this->reviewFormId);
00058       $templateMgr->assign('reviewFormElementId', $this->reviewFormElementId);
00059       $templateMgr->assign_by_ref('multipleResponsesElementTypes', ReviewFormElement::getMultipleResponsesElementTypes());
00060       // in order to be able to search for an element in the array in the javascript function 'togglePossibleResponses':
00061       $templateMgr->assign('multipleResponsesElementTypesString', ';'.implode(';', ReviewFormElement::getMultipleResponsesElementTypes()).';');
00062       import('reviewForm.ReviewFormElement');
00063       $templateMgr->assign_by_ref('reviewFormElementTypeOptions', ReviewFormElement::getReviewFormElementTypeOptions());
00064       $templateMgr->assign('helpTopicId','conference.managementPages.reviewForms');
00065       parent::display();
00066    }
00067 
00071    function initData() {
00072       if ($this->reviewFormElementId != null) {
00073          $conference =& Request::getConference();
00074          $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
00075          $reviewFormElement =& $reviewFormElementDao->getReviewFormElement($this->reviewFormElementId);
00076 
00077          if ($reviewFormElement == null) {
00078             $this->reviewFormElementId = null;
00079             $this->_data = array(
00080                'included' => 1
00081             );
00082          } else {
00083             $this->_data = array(
00084                'question' => $reviewFormElement->getQuestion(null), // Localized
00085                'required' => $reviewFormElement->getRequired(),
00086                'included' => $reviewFormElement->getIncluded(),
00087                'elementType' => $reviewFormElement->getElementType(),
00088                'possibleResponses' => $reviewFormElement->getPossibleResponses(null) //Localized
00089             );
00090          }
00091       }
00092    }
00093 
00097    function readInputData() {
00098       $this->readUserVars(array('question', 'required', 'included', 'elementType', 'possibleResponses'));
00099    }
00100 
00104    function execute() {
00105       $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
00106 
00107       if ($this->reviewFormElementId != null) {
00108          $reviewFormElement =& $reviewFormElementDao->getReviewFormElement($this->reviewFormElementId);
00109       }
00110 
00111       if (!isset($reviewFormElement)) {
00112          $reviewFormElement = new ReviewFormElement();
00113          $reviewFormElement->setReviewFormId($this->reviewFormId);
00114          $reviewFormElement->setSequence(REALLY_BIG_NUMBER);
00115       }
00116 
00117       $reviewFormElement->setQuestion($this->getData('question'), null); // Localized
00118       $reviewFormElement->setRequired($this->getData('required') ? 1 : 0);
00119       $reviewFormElement->setIncluded($this->getData('included') ? 1 : 0);
00120       $reviewFormElement->setElementType($this->getData('elementType'));
00121 
00122       if (in_array($this->getData('elementType'), ReviewFormElement::getMultipleResponsesElementTypes())) {
00123          $reviewFormElement->setPossibleResponses($this->getData('possibleResponses'), null); // Localized
00124       } else {
00125          $reviewFormElement->setPossibleResponses(null, null);
00126       }
00127 
00128       if ($reviewFormElement->getId() != null) {
00129          $reviewFormElementDao->deleteSetting($reviewFormElement->getId(), 'possibleResponses');
00130          $reviewFormElementDao->updateObject($reviewFormElement);
00131          $this->reviewFormElementId = $reviewFormElement->getId();
00132       } else {
00133          $this->reviewFormElementId = $reviewFormElementDao->insertObject($reviewFormElement);
00134          $reviewFormElementDao->resequenceReviewFormElements($this->reviewFormId);
00135       }
00136 
00137    }
00138 }
00139 
00140 ?>

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