classes/submission/form/ReviewFormResponseForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00017 import('form.Form');
00018 
00019 class ReviewFormResponseForm extends Form {
00020 
00022    var $reviewId;
00023 
00025    var $reviewFormId;
00026 
00033    function ReviewFormResponseForm($reviewId, $reviewFormId) {
00034       parent::Form('submission/reviewForm/reviewFormResponse.tpl');
00035 
00036       $this->reviewId = $reviewId;
00037       $this->reviewFormId = $reviewFormId;
00038 
00039       $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
00040       $requiredReviewFormElementIds = $reviewFormElementDao->getRequiredReviewFormElementIds($this->reviewFormId);
00041 
00042       $this->addCheck(new FormValidatorCustom($this, 'reviewFormResponses', 'required', 'reviewer.paper.reviewFormResponse.form.responseRequired', create_function('$reviewFormResponses, $requiredReviewFormElementIds', 'foreach ($requiredReviewFormElementIds as $requiredReviewFormElementId) { if (!isset($reviewFormResponses[$requiredReviewFormElementId]) || $reviewFormResponses[$requiredReviewFormElementId] == \'\') return false; } return true;'), array($requiredReviewFormElementIds)));
00043       $this->addCheck(new FormValidatorPost($this));
00044    }
00045 
00049    function display() {
00050       $conference =& Request::getConference();
00051       $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO');
00052       $reviewForm =& $reviewFormDao->getReviewForm($this->reviewFormId, ASSOC_TYPE_CONFERENCE, $conference->getId());
00053       $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
00054       $reviewFormElements =& $reviewFormElementDao->getReviewFormElements($this->reviewFormId);
00055       $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
00056       $reviewFormResponses =& $reviewFormResponseDao->getReviewReviewFormResponseValues($this->reviewId);
00057       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00058       $reviewAssignment = $reviewAssignmentDao->getReviewAssignmentById($this->reviewId);
00059 
00060       $editorPreview = Request::getRequestedPage() != 'reviewer';
00061 
00062       if (!$editorPreview) {
00063          ReviewerHandler::setupTemplate(true, $reviewAssignment->getPaperId(), $this->reviewId);
00064       }
00065 
00066       $templateMgr =& TemplateManager::getManager();
00067       $templateMgr->assign('pageTitle', 'submission.reviewFormResponse');
00068       $templateMgr->assign_by_ref('reviewForm', $reviewForm);
00069       $templateMgr->assign('reviewFormElements', $reviewFormElements);
00070       $templateMgr->assign('reviewFormResponses', $reviewFormResponses);
00071       $templateMgr->assign('reviewId', $this->reviewId);
00072       $templateMgr->assign('paperId', $reviewAssignment->getPaperId());
00073       $templateMgr->assign('isLocked', isset($reviewAssignment) && $reviewAssignment->getDateCompleted() != null);
00074       $templateMgr->assign('editorPreview', $editorPreview);
00075 
00076       parent::display();
00077    }
00078 
00082    function readInputData() {
00083       $this->readUserVars(
00084          array(
00085             'reviewFormResponses'
00086          )
00087       );
00088    }
00089 
00093    function execute() {
00094       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00095       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($this->reviewId);
00096       $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
00097 
00098       $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
00099 
00100       $reviewFormResponses = $this->getData('reviewFormResponses');
00101       if (is_array($reviewFormResponses)) foreach ($reviewFormResponses as $reviewFormElementId => $reviewFormResponseValue) {
00102          $reviewFormResponse =& $reviewFormResponseDao->getReviewFormResponse($this->reviewId, $reviewFormElementId);
00103          if (!isset($reviewFormResponse)) {
00104             $reviewFormResponse = new ReviewFormResponse();
00105          }
00106          $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
00107          $reviewFormElement = $reviewFormElementDao->getReviewFormElement($reviewFormElementId);
00108          $elementType = $reviewFormElement->getElementType();
00109          switch ($elementType) {
00110             case REVIEW_FORM_ELEMENT_TYPE_SMALL_TEXT_FIELD:
00111             case REVIEW_FORM_ELEMENT_TYPE_TEXT_FIELD:
00112             case REVIEW_FORM_ELEMENT_TYPE_TEXTAREA:
00113                $reviewFormResponse->setResponseType('string');
00114                $reviewFormResponse->setValue($reviewFormResponseValue);
00115                break;
00116             case REVIEW_FORM_ELEMENT_TYPE_RADIO_BUTTONS:
00117             case REVIEW_FORM_ELEMENT_TYPE_DROP_DOWN_BOX:
00118                $reviewFormResponse->setResponseType('int');
00119                $reviewFormResponse->setValue($reviewFormResponseValue);
00120                break;
00121             case REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES:
00122                $reviewFormResponse->setResponseType('object');
00123                $reviewFormResponse->setValue($reviewFormResponseValue);
00124                break;
00125          }
00126          if ($reviewFormResponse->getReviewFormElementId() != null && $reviewFormResponse->getReviewId() != null) {
00127             $reviewFormResponseDao->updateObject($reviewFormResponse);
00128          } else {
00129             $reviewFormResponse->setReviewFormElementId($reviewFormElementId);
00130             $reviewFormResponse->setReviewId($this->reviewId);
00131             $reviewFormResponseDao->insertObject($reviewFormResponse);
00132          }
00133       }
00134    }
00135 }
00136 
00137 ?>

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