paper = $paper; $this->commentType = $commentType; $this->roleId = $roleId; $this->assocId = $assocId == null ? $paper->getPaperId() : $assocId; $this->user = &Request::getUser(); if ($commentType != COMMENT_TYPE_PEER_REVIEW) $this->addCheck(new FormValidator($this, 'comments', 'required', 'director.paper.commentsRequired')); $this->addCheck(new FormValidatorPost($this)); } /** * Set the user this comment form is associated with. * @param $user object */ function setUser(&$user) { $this->user =& $user; } /** * Display the form. */ function display() { $paper = $this->paper; $paperCommentDao = &DAORegistry::getDAO('PaperCommentDAO'); $paperComments = &$paperCommentDao->getPaperComments($paper->getPaperId(), $this->commentType, $this->assocId); $templateMgr = &TemplateManager::getManager(); $templateMgr->assign('paperId', $paper->getPaperId()); $templateMgr->assign('commentTitle', strip_tags($paper->getPaperTitle())); $templateMgr->assign('userId', $this->user->getUserId()); $templateMgr->assign('paperComments', $paperComments); parent::display(); } /** * Assign form data to user-submitted data. */ function readInputData() { $this->readUserVars( array( 'commentTitle', 'comments', 'viewable' ) ); } /** * Add the comment. */ function execute() { $commentDao = &DAORegistry::getDAO('PaperCommentDAO'); $paper = $this->paper; // Insert new comment $comment = &new PaperComment(); $comment->setCommentType($this->commentType); $comment->setRoleId($this->roleId); $comment->setPaperId($paper->getPaperId()); $comment->setAssocId($this->assocId); $comment->setAuthorId($this->user->getUserId()); $comment->setCommentTitle($this->getData('commentTitle')); $comment->setComments($this->getData('comments')); $comment->setDatePosted(Core::getCurrentDate()); $comment->setViewable($this->getData('viewable')); $this->commentId = $commentDao->insertPaperComment($comment); } /** * Email the comment. * @param $recipients array of recipients (email address => name) */ function email($recipients) { $paper = $this->paper; $paperCommentDao = &DAORegistry::getDAO('PaperCommentDAO'); $schedConf = &Request::getSchedConf(); import('mail.PaperMailTemplate'); $email = &new PaperMailTemplate($paper, 'SUBMISSION_COMMENT'); $email->setFrom($this->user->getEmail(), $this->user->getFullName()); $commentText = $this->getData('comments'); // Individually send an email to each of the recipients. foreach ($recipients as $emailAddress => $name) { $email->addRecipient($emailAddress, $name); $paramArray = array( 'name' => $name, 'commentName' => $this->user->getFullName(), 'comments' => $commentText ); $email->sendWithParams($paramArray); $email->clearRecipients(); } } } ?>