00001 <?php
00002
00019
00020
00021 import('form.Form');
00022
00023 class CommentForm extends Form {
00024
00026 var $commentType;
00027
00029 var $roleId;
00030
00032 var $paper;
00033
00035 var $user;
00036
00038 var $commentId;
00039
00044 function CommentForm($paper, $commentType, $roleId, $assocId = null) {
00045 if ($commentType == COMMENT_TYPE_PEER_REVIEW) {
00046 parent::Form('submission/comment/peerReviewComment.tpl');
00047 } else if ($commentType == COMMENT_TYPE_DIRECTOR_DECISION) {
00048 parent::Form('submission/comment/directorDecisionComment.tpl');
00049 } else {
00050 parent::Form('submission/comment/comment.tpl');
00051 }
00052
00053 $this->paper = $paper;
00054 $this->commentType = $commentType;
00055 $this->roleId = $roleId;
00056 $this->assocId = $assocId == null ? $paper->getId() : $assocId;
00057
00058 $this->user =& Request::getUser();
00059
00060 if ($commentType != COMMENT_TYPE_PEER_REVIEW) $this->addCheck(new FormValidator($this, 'comments', 'required', 'director.paper.commentsRequired'));
00061
00062 $this->addCheck(new FormValidatorPost($this));
00063 }
00064
00069 function setUser(&$user) {
00070 $this->user =& $user;
00071 }
00072
00076 function display() {
00077 $paper = $this->paper;
00078
00079 $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
00080 $paperComments =& $paperCommentDao->getPaperComments($paper->getId(), $this->commentType, $this->assocId);
00081
00082 $templateMgr =& TemplateManager::getManager();
00083 $templateMgr->assign('paperId', $paper->getId());
00084 $templateMgr->assign('commentTitle', strip_tags($paper->getLocalizedTitle()));
00085 $templateMgr->assign('userId', $this->user->getId());
00086 $templateMgr->assign('paperComments', $paperComments);
00087
00088 parent::display();
00089 }
00090
00094 function readInputData() {
00095 $this->readUserVars(
00096 array(
00097 'commentTitle',
00098 'comments',
00099 'viewable'
00100 )
00101 );
00102 }
00103
00107 function execute() {
00108 $commentDao =& DAORegistry::getDAO('PaperCommentDAO');
00109 $paper = $this->paper;
00110
00111
00112 $comment = new PaperComment();
00113 $comment->setCommentType($this->commentType);
00114 $comment->setRoleId($this->roleId);
00115 $comment->setPaperId($paper->getId());
00116 $comment->setAssocId($this->assocId);
00117 $comment->setAuthorId($this->user->getId());
00118 $comment->setCommentTitle($this->getData('commentTitle'));
00119 $comment->setComments($this->getData('comments'));
00120 $comment->setDatePosted(Core::getCurrentDate());
00121 $comment->setViewable($this->getData('viewable'));
00122
00123 $this->commentId = $commentDao->insertPaperComment($comment);
00124 }
00125
00130 function email($recipients) {
00131 $paper = $this->paper;
00132 $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
00133 $schedConf =& Request::getSchedConf();
00134
00135 import('mail.PaperMailTemplate');
00136 $email = new PaperMailTemplate($paper, 'SUBMISSION_COMMENT');
00137 $email->setFrom($this->user->getEmail(), $this->user->getFullName());
00138
00139 $commentText = $this->getData('comments');
00140
00141
00142 foreach ($recipients as $emailAddress => $name) {
00143 $email->addRecipient($emailAddress, $name);
00144
00145 $paramArray = array(
00146 'name' => $name,
00147 'commentName' => $this->user->getFullName(),
00148 'comments' => String::html2text($commentText)
00149 );
00150
00151 $email->sendWithParams($paramArray);
00152 $email->clearRecipients();
00153 }
00154 }
00155 }
00156
00157 ?>