00001 <?php
00014 import('handler.validation.HandlerValidator');
00015
00016 class HandlerValidatorSubmissionComment extends HandlerValidator {
00017 var $commentId;
00018
00019 var $user;
00020
00027 function HandlerValidatorSubmissionComment(&$handler, $commentId, &$user = null) {
00028 parent::HandlerValidator($handler);
00029 $this->commentId = $commentId;
00030 if ( $user ) {
00031 $this->user =& $user;
00032 } else {
00033 $this->user =& Request::getUser();
00034 }
00035 }
00036
00042 function isValid() {
00043 $isValid = true;
00044
00045 $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
00046 $user =& $this->user;
00047
00048 $comment =& $paperCommentDao->getPaperCommentById($this->commentId);
00049
00050 if ($comment == null) {
00051 $isValid = false;
00052
00053 } else if ($comment->getAuthorId() != $user->getId()) {
00054 $isValid = false;
00055 }
00056
00057 if (!$isValid) {
00058 Request::redirect(null, null, Request::getRequestedPage());
00059 }
00060
00061 $handler =& $this->handler;
00062 $handler->comment =& $comment;
00063 return true;
00064 }
00065 }
00066
00067 ?>