classes/submission/form/comment/EditCommentForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('form.Form');
00018 
00019 class EditCommentForm extends Form {
00020 
00022    var $paper;
00023 
00025    var $comment;
00026 
00028    var $roleId;
00029 
00031    var $user;
00032 
00038    function EditCommentForm(&$paper, &$comment) {
00039       parent::Form('submission/comment/editComment.tpl');
00040 
00041       $this->comment = $comment;
00042       $this->roleId = $comment->getRoleId();
00043 
00044       $this->paper = $paper;
00045       $this->user =& Request::getUser();
00046 
00047       $this->addCheck(new FormValidatorPost($this));
00048    }
00049 
00053    function initData() {
00054       $comment =& $this->comment;
00055       $this->_data = array(
00056          'commentId' => $comment->getId(),
00057          'commentTitle' => $comment->getCommentTitle(),
00058          'comments' => $comment->getComments(),
00059          'viewable' => $comment->getViewable(),
00060       );
00061    }  
00062 
00066    function display($additionalHiddenParams = null) {
00067       $hiddenFormParams = array(
00068          'paperId' => $this->paper->getPaperId(),
00069          'commentId' => $this->comment->getCommentId()
00070       );
00071       if (isset($additionalHiddenParams)) {
00072          $hiddenFormParams = array_merge ($hiddenFormParams, $additionalHiddenParams);
00073       }
00074 
00075       $templateMgr =& TemplateManager::getManager();
00076 
00077       $isPeerReviewComment = $this->comment->getCommentType() == COMMENT_TYPE_PEER_REVIEW;
00078       $templateMgr->assign('isPeerReviewComment', $isPeerReviewComment); // FIXME
00079 
00080       $templateMgr->assign_by_ref('comment', $this->comment);
00081       $templateMgr->assign_by_ref('hiddenFormParams', $hiddenFormParams);
00082 
00083       parent::display();
00084    }
00085 
00089    function readInputData() {
00090       $this->readUserVars(
00091          array(
00092             'commentTitle',
00093             'comments',
00094             'viewable'
00095          )
00096       );
00097    }
00098 
00102    function execute() {
00103       $commentDao =& DAORegistry::getDAO('PaperCommentDAO');
00104 
00105       // Update comment    
00106       $comment = $this->comment;
00107       $comment->setCommentTitle($this->getData('commentTitle'));
00108       $comment->setComments($this->getData('comments'));
00109       $comment->setViewable($this->getData('viewable') ? 1 : 0);
00110       $comment->setDateModified(Core::getCurrentDate());
00111 
00112       $commentDao->updatePaperComment($comment);
00113    }
00114 
00119    function emailHelper() {
00120       $roleDao =& DAORegistry::getDAO('RoleDAO');
00121       $userDao =& DAORegistry::getDAO('UserDAO');
00122       $conference =& Request::getConference();
00123 
00124       $recipients = array();
00125 
00126       // Get directors for paper
00127       $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
00128       $editAssignments =& $editAssignmentDao->getEditAssignmentsByPaperId($this->paper->getPaperId());
00129       $editAssignments =& $editAssignments->toArray();
00130       $directorAddresses = array();
00131       foreach ($editAssignments as $editAssignment) {
00132          $directorAddresses[$editAssignment->getDirectorEmail()] = $editAssignment->getDirectorFullName();
00133       }
00134 
00135       // If no directors are currently assigned, send this message to
00136       // all of the conference's directors.
00137       if (empty($directorAddresses)) {
00138          $directors =& $roleDao->getUsersByRoleId(ROLE_ID_DIRECTOR, $conference->getId());
00139          while (!$directors->eof()) {
00140             $director =& $directors->next();
00141             $directorAddresses[$director->getEmail()] = $director->getFullName();
00142          }
00143       }
00144 
00145       // Get reviewer
00146       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00147       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($this->comment->getAssocId());
00148       if ($reviewAssignment != null && $reviewAssignment->getReviewerId() != null) {
00149          $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId());
00150       } else {
00151          $reviewer = null;
00152       }
00153 
00154       // Get author
00155       $author =& $userDao->getUser($this->paper->getUserId());
00156 
00157       switch ($this->comment->getCommentType()) {
00158       case COMMENT_TYPE_PEER_REVIEW:
00159          if ($this->roleId == ROLE_ID_DIRECTOR || $this->roleId == ROLE_ID_TRACK_DIRECTOR) {
00160             // Then add reviewer
00161             if ($reviewer != null) {
00162                $recipients = array_merge($recipients, array($reviewer->getEmail() => $reviewer->getFullName()));
00163             }
00164          }
00165          break;
00166 
00167       case COMMENT_TYPE_DIRECTOR_DECISION:
00168          if ($this->roleId == ROLE_ID_DIRECTOR || $this->roleId == ROLE_ID_TRACK_DIRECTOR) {
00169             // Then add author
00170             if (isset($author)) $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
00171          } else {
00172             // Then add directors
00173             $recipients = array_merge($recipients, $directorAddresses);
00174          }
00175          break;
00176       }
00177 
00178       return $recipients;
00179    }
00180 
00185    function email($recipients) {
00186       import('mail.PaperMailTemplate');
00187       $email = new PaperMailTemplate($this->paper, 'SUBMISSION_COMMENT');
00188 
00189       foreach ($recipients as $emailAddress => $name) {
00190          $email->addRecipient($emailAddress, $name);
00191          $email->setSubject(strip_tags($this->paper->getLocalizedTitle()));
00192 
00193          $paramArray = array(
00194             'name' => $name,
00195             'commentName' => $this->user->getFullName(),
00196             'comments' => String::html2text($this->getData('comments'))
00197          );
00198          $email->assignParams($paramArray);
00199 
00200          $email->send();
00201          $email->clearRecipients();
00202       }
00203    }
00204 }
00205 
00206 ?>

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