public function request() { if (is_null($this->getRequestVar('commentid'))) { $this->redirect('comments/list'); } $this->comment = new \fpcm\model\comments\comment($this->getRequestVar('commentid')); if (!$this->comment->exists()) { $this->view->setNotFound('LOAD_FAILED_COMMENT', 'comments/list'); return true; } if (!$this->comment->getEditPermission()) { $this->view = new \fpcm\model\view\error(); $this->view->addErrorMessage('PERMISSIONS_REQUIRED'); $this->view->render(); return false; } if ($this->buttonClicked('commentSave') && $this->getRequestVar('comment')) { $commentData = $this->getRequestVar('comment', array(4, 7)); $this->comment->setText($commentData['text']); unset($commentData['text']); foreach ($commentData as &$value) { $value = \fpcm\classes\http::filter($value, array(1, 3)); } $this->comment->setName($commentData['name']); $this->comment->setEmail($commentData['email']); $this->comment->setWebsite($commentData['website']); if ($this->approve) { $this->comment->setApproved(isset($commentData['approved']) ? true : false); $this->comment->setSpammer(isset($commentData['spam']) ? true : false); } if ($this->private) { $this->comment->setPrivate(isset($commentData['private']) ? true : false); } $this->comment->setChangetime(time()); $this->comment->setChangeuser($this->session->getUserId()); if ($this->comment->update()) { $this->view->addNoticeMessage('SAVE_SUCCESS_COMMENT'); } else { $this->view->addErrorMessage('SAVE_FAILED_COMMENT'); } } return true; }
/** * Kommentar-Formular initialisieren * @return string */ protected function assignCommentFormData() { if (!$this->config->system_comments_enabled || !$this->article->getComments()) { return ''; } $id = $this->session->exists() ? $this->session->getUserId() : null; $author = new \fpcm\model\users\author($id); if (!$this->buttonClicked('sendComment') && is_null($this->getRequestVar('newcomment')) && $this->session->exists()) { $this->newComment->setName($author->getDisplayname()); $this->newComment->setEmail($author->getEmail()); $this->newComment->setWebsite(\fpcm\classes\http::getHttpHost()); } $replacementTags = array('{{formHeadline}}' => $this->lang->translate('COMMENTS_PUBLIC_FORMHEADLINE'), '{{submitUrl}}' => $this->article->getArticleLink(), '{{nameDescription}}' => $this->lang->translate('COMMMENT_AUTHOR'), '{{nameField}}' => '<input type="text" class="fpcm-pub-textinput" name="newcomment[name]" value="' . $this->newComment->getName() . '">', '{{emailDescription}}' => $this->lang->translate('GLOBAL_EMAIL'), '{{emailField}}' => '<input type="text" class="fpcm-pub-textinput" name="newcomment[email]" value="' . $this->newComment->getEmail() . '">', '{{websiteDescription}}' => $this->lang->translate('COMMMENT_WEBSITE'), '{{websiteField}}' => '<input type="text" class="fpcm-pub-textinput" name="newcomment[website]" value="' . $this->newComment->getWebsite() . '">', '{{textfield}}' => '<textarea class="fpcm-pub-textarea" id="newcommenttext" name="newcomment[text]">' . $this->newComment->getText() . '</textarea>', '{{smileysDescription}}' => $this->lang->translate('HL_OPTIONS_SMILEYS'), '{{smileys}}' => $this->getSmileyList(), '{{tags}}' => htmlentities(\fpcm\model\comments\comment::COMMENT_TEXT_HTMLTAGS_FORM), '{{spampluginQuestion}}' => $this->captcha->createPluginText(), '{{spampluginField}}' => $this->captcha->createPluginInput(), '{{privateCheckbox}}' => '<input type="checkbox" class="fpcm-pub-checkboxinput" name="newcomment[private]" value="1">', '{{submitButton}}' => '<button type="submit" name="btnSendComment">' . $this->lang->translate('GLOBAL_SUBMIT') . '</button>', '{{resetButton}}' => '<button type="reset">' . $this->lang->translate('GLOBAL_RESET') . '</button>'); $this->commentFormTemplate->setReplacementTags($replacementTags); $parsed = $this->commentFormTemplate->parse(); if (!$this->isUtf8) { $parsed = utf8_decode($parsed); } return $parsed; }