. */ include("./include/include.php"); require_once(FILESYSTEMROOTPATH."jc/include/classes/DefaultLayout.php"); require_once(FILESYSTEMROOTPATH."include/form/AbstractForm.php"); require_once(FILESYSTEMROOTPATH."jc/include/classes/BBParse.php"); /** * Helper classes */ class CommentForm extends AbstractForm { private $commentsService; public function __construct(Layout $layout, IModel $model, commentsService $commentsService) { parent::__construct($layout, $model); $this->commentsService = $commentsService; } /*public function process () { //All form operations, seperated from the dislay() function so comments can be loaded AFTER operations! if($_POST['text']) { if( $this->setFieldValuesOnModel() && $this->isValid($this->model) && $_SESSION['sess_uid']) $this->save($this->model); } }*/ public function save(IModel $model) { $model->setTime(time()); $model->setCommenter_uid($_SESSION['sess_uid']); $model->setDeleted(0); $result = $this->commentsService->SaveOrUpdate($model); if($result==1 ) { $this->layout->redirect('view_public.php?proposal_id='.$model->getProposal_id()); } elseif($result==2){ $this->layout->echoln("You already posted the exact same thing right before this.
"); }elseif($result==3){ $this->layout->echoln("Don't spam it! You can't post more than 3 comments in 10 minutes.
"); } else{ if( $model->getId()==NULL ) { // New comment $this->layout->echoln(_("Failed creating comment.
")); }else { // comment edited $this->layout->echoln(_("Failed saving comment.
")); } } } } /** * End of helper classes */ $layout = new DefaultLayout(Access::VISITOR, "./jc/"); $layout->init(); $proposalsService = $GLOBALS['ClassFactory']->getProposalsService(); $commentsService = $GLOBALS['ClassFactory']->getCommentsService(); if(ctype_digit($_GET['proposal_id'])){ $proposal_id = $_GET['proposal_id']; } else { $layout->page_footer(); exit(); } $comment = new Comments(''); $comment->setProposal_id($proposal_id); if( isset( $_SESSION['sess_access_bodyCodes']['XJU']['JC_MANAGE']) && isset($_GET['action'])){ //JC can delete and undelete posts if($_GET['action'] == 'delete_comment') $commentsService->delete($_GET['comment_id']); if($_GET['action'] == 'undelete_comment') $commentsService->approve($_GET['comment_id']); } $form = new CommentForm($layout, $comment, $commentsService); $commentArea = new TextAreaField('text','Comment',5,60); $commentArea->setExplanation($layout->bbcodeexplanation); $form->addField($commentArea->setCompulsory(true)); $form->setSubmitText("Submit"); //$form->process();//processing actions like new comment etc. $proposal = $proposalsService->load($proposal_id); $layout->echoln('Title:
'.$proposal->getTitle().'

'); $layout->echoln('Proposers:
'.$proposal->getProposers().'

'); $layout->echoln('Motivation:
'.nl2br(showBBcodes($proposal->getMotivation())).'

'); $layout->echoln('Next

'); //loading & displayingthe comments $layout->echoln($commentsService->loadByPID($proposal_id)); //Displaying the form $commentArea->setValue(""); $layout->echoln(""); //$form->printForm(); $form->display(); $layout->echoln(""); $layout->page_footer(); ?>