. * * Comments & Questions @ joris.veenhuis@aegee.org */ /** * Comments Service */ require_once(FILESYSTEMROOTPATH."jc/include/dao/CommentsDao.php"); require_once(FILESYSTEMROOTPATH."jc/include/classes/BBParse.php"); class CommentsService { private $CommentsDao; /** * Default constructor * * @param CommentsDao */ public function __construct(CommentsDao $CommentsDao) { $this->CommentsDao = $CommentsDao; } /** * Load comments by proposal ID * * @param string id of the proposal for which to load the comments * @return html table with comments */ public function loadByPID($proposal_id) { $comments = $this->CommentsDao->loadByPID($proposal_id); $ret = ''; if($comments) { $ret = "\n"; foreach($comments as $comment) { $deletedclass = ''; $jccode = ''; $comment['text'] = nl2br(showBBcodes($comment['text'])); if( isset( $_SESSION['sess_access_bodyCodes']['XJU']['JC_MANAGE'] )){ //JC can delete and undelete posts if($comment['deleted']) { $jccode = "
undelete comment"; $deletedclass = " class='deleted'"; } else $jccode = "
delete comment"; } $ret .= "\n"; } $ret .= "
{$comment['commenter_uid']}
".date("j-n-Y G:i", $comment['time'])." $jccode
{$comment['text']}
\n"; } return $ret; } public function delete($comment_id) { if(ctype_digit($comment_id)) $this->CommentsDao->delete($comment_id); } public function approve($comment_id) { if(ctype_digit($comment_id)) $this->CommentsDao->approve($comment_id); } /** * Save or update Comment: * * @param Proposals object */ public function SaveOrUpdate($proposal){ //Check whether this is not a double if($this->CommentsDao->checkdouble($proposal)) { return 2; } //Check whether this is not spam (more than 3 comments in 10 minutes) if($this->CommentsDao->checkspam($proposal) > 2) { return 3; } //And submit! if( $this->CommentsDao->saveOrUpdate($proposal)){ return 1;} else{ return 0;} } } ?>