Пример #1
0
 public function process()
 {
     $this->setPlaceholders($this->post->toArray());
     $this->setPlaceholders(array('post' => $this->post->get('id'), 'participants_usernames' => $this->thread->get('participants_usernames'), 'thread' => $this->thread->get('id'), 'message' => str_replace(array('[', ']'), array('[', ']'), $this->post->br2nl($this->post->get('message')))));
     $this->getAttachments();
     $this->getButtons();
     $this->getThreadSummary();
     /* output form to browser */
     $this->modx->setPlaceholder('discuss.error_panel', $this->discuss->getChunk('disError'));
     $this->modx->setPlaceholders($this->getPlaceholders(), 'fi.');
 }
Пример #2
0
 public function process()
 {
     if (!$this->post->remove(array(), true, true)) {
         $this->modx->log(modX::LOG_LEVEL_ERROR, '[Discuss] Could not remove post: ' . print_r($this->post->toArray(), true));
     } else {
         $this->discuss->logActivity('post_spam_remove', $this->post->toArray(), $this->post->getUrl());
     }
     if ($this->thread->get('post_first') == $this->post->get('id')) {
         $redirectTo = $this->discuss->request->makeUrl('board', array('board' => $this->post->get('board')));
     } else {
         $redirectTo = $this->thread->getUrl();
     }
     $this->modx->sendRedirect($redirectTo);
 }
Пример #3
0
 public function process()
 {
     $this->setPlaceholders($this->thread->toArray());
     if ($this->post->remove()) {
         $this->discuss->logActivity('message_post_remove', $this->post->toArray(), $this->post->getUrl());
         $posts = $this->thread->getMany('Posts');
         if (count($posts) <= 0) {
             $url = $this->discuss->request->makeUrl('messages');
         } else {
             $url = $this->discuss->request->makeUrl('messages/view', array('thread' => $this->thread->get('id')));
         }
         $this->modx->sendRedirect($url);
     }
 }
Пример #4
0
 public function process()
 {
     if (!$this->post->remove(array(), true)) {
         $this->modx->log(modX::LOG_LEVEL_ERROR, '[Discuss] Could not remove post: ' . print_r($this->post->toArray(), true));
     } else {
         $this->discuss->logActivity('post_remove', $this->post->toArray(), $this->post->getUrl());
     }
     /* If the thread no longer exists (last post in thread was removed), redirect to the board instead of thread */
     if ($this->modx->getCount('disThread', $this->thread->get('id')) < 1) {
         $redirectTo = $this->discuss->request->makeUrl('board', array('board' => $this->post->get('board')));
     } else {
         $redirectTo = $this->thread->getUrl();
     }
     $this->modx->sendRedirect($redirectTo);
 }
Пример #5
0
 /**
  * Send a spam report via email
  * @return void
  */
 public function report()
 {
     $author = $this->post->getOne('Author');
     /* setup default properties */
     $subject = $this->modx->getOption('subject', $this->scriptProperties, $this->modx->getOption('discuss.email_reported_post_subject', null, 'Reported Post: [[+title]]'));
     $subject = str_replace('[[+title]]', $this->post->get('title'), $subject);
     $tpl = $this->modx->getOption('tpl', $this->scriptProperties, $this->modx->getOption('discuss.email_reported_post_chunk', null, 'emails/disReportedEmail'));
     /* build post url */
     $url = $this->post->getUrl();
     /* setup email properties */
     $emailProperties = array_merge($this->scriptProperties, $this->post->toArray());
     $emailProperties['tpl'] = $tpl;
     $emailProperties['title'] = $this->post->get('title');
     if ($author) {
         $emailProperties['author'] = $author->get('username');
     }
     $emailProperties['reporter'] = $this->discuss->user->get('username');
     $emailProperties['url'] = $url;
     $emailProperties['forum_title'] = $this->modx->getOption('discuss.forum_title');
     $emailProperties['message'] = nl2br(strip_tags($this->scriptProperties['message']));
     /* send reported email */
     $moderators = $this->thread->getModerators();
     /** @var disUser $moderator */
     foreach ($moderators as $moderator) {
         $sent = $this->discuss->sendEmail($moderator->get('email'), $moderator->get('username'), $subject, $emailProperties);
     }
     unset($emailProperties);
     $this->discuss->logActivity('post_report', $this->post->toArray(), $this->post->getUrl());
     /* redirect to thread */
     $this->modx->sendRedirect($url);
 }
Пример #6
0
 public function process()
 {
     $replyPrefix = $this->modx->getOption('replyPrefix', $this->scriptProperties, 'Re: ');
     $this->setPlaceholders($this->post->toArray());
     $this->setPlaceholders(array('url' => $this->post->getUrl(), 'buttons' => $this->discuss->getChunk('disPostButtons', array('buttons_url' => $this->discuss->config['imagesUrl'] . 'buttons/')), 'post' => $this->post->get('id'), 'thread' => $this->thread->get('id'), 'title' => $replyPrefix . str_replace($replyPrefix, '', $this->post->get('title'))));
     $this->getThreadSummary();
     $this->checkThreadPermissions();
     $this->handleAttachments();
     $this->handleQuote();
     $this->modx->setPlaceholder('discuss.error_panel', $this->discuss->getChunk('disError'));
     /* set placeholders for FormIt inputs */
     $this->modx->setPlaceholders($this->getPlaceholders(), 'fi.');
 }
Пример #7
0
 public function process()
 {
     /* setup default snippet properties */
     $replyPrefix = $this->modx->getOption('replyPrefix', $this->scriptProperties, 'Re: ');
     /* setup placeholders */
     $postArray = $this->post->toArray();
     $postArray['participants_usernames'] = $this->thread->get('participants_usernames');
     $postArray['post'] = $postArray['id'];
     $postArray['thread'] = $this->thread->get('id');
     $postArray['attachmentCurIdx'] = 1;
     $postArray['is_author'] = $this->thread->get('author_first') == $this->discuss->user->get('id') ? true : false;
     $this->setPlaceholders($postArray);
     $this->getThreadSummary();
     /* default values */
     if (empty($_POST)) {
         $this->setPlaceholder('title', $replyPrefix . $this->post->get('title'));
     }
     $this->handleQuote();
     $this->handleAttachments();
     $this->getButtons();
     /* output form to browser */
     $this->modx->setPlaceholder('discuss.error_panel', $this->discuss->getChunk('disError'));
     $this->modx->setPlaceholders($this->getPlaceholders(), 'fi.');
 }
Пример #8
0
 /**
  * Get the last post of the thread and set it as a placeholder
  * @return void
  */
 public function getLastPost()
 {
     $this->lastPost = $this->thread->getOne('LastPost');
     $lastPostArray = $this->lastPost->toArray('lastPost.');
     $this->setPlaceholders($lastPostArray);
 }
Пример #9
0
 public function process()
 {
     /* setup defaults */
     $placeholders = $this->post->toArray();
     $placeholders['url'] = $this->post->getUrl();
     $placeholders['post'] = $this->post->get('id');
     $placeholders['buttons'] = $this->discuss->getChunk('disPostButtons', array('buttons_url' => $this->discuss->config['imagesUrl'] . 'buttons/'));
     $placeholders['message'] = str_replace(array('[', ']', '<', '>'), array('&#91;', '&#93;', '&lt;', '&gt;'), $placeholders['message']);
     /* get thread root */
     $placeholders['thread'] = $this->thread->get('id');
     $placeholders['locked'] = $this->thread->get('locked');
     $placeholders['sticky'] = $this->thread->get('sticky');
     $placeholders['class_key'] = $this->thread->get('class_key');
     $placeholders['is_root'] = $this->thread->get('post_first') == $this->post->get('id') ? 1 : 0;
     /* ensure user can modify this post */
     $isModerator = $this->discuss->user->isGlobalModerator() || $this->thread->isModerator($this->discuss->user->get('id')) || $this->discuss->user->isAdmin();
     $canModifyPost = $this->discuss->user->isLoggedIn && $this->modx->hasPermission('discuss.thread_modify');
     $canModify = $this->discuss->user->get('id') == $this->post->get('author') || $isModerator && $canModifyPost;
     if (!$canModify) {
         $this->modx->sendRedirect($this->thread->getUrl());
     }
     /* get attachments for post */
     $attachments = $this->post->getMany('Attachments');
     $idx = 1;
     $atts = array();
     $postAttachmentRowTpl = $this->modx->getOption('postAttachmentRowTpl', $this->scriptProperties, 'post/disPostEditAttachment');
     /** @var disPostAttachment $attachment */
     foreach ($attachments as $attachment) {
         $attachmentArray = $attachment->toArray();
         $attachmentArray['filesize'] = $attachment->convert();
         $attachmentArray['url'] = $attachment->getUrl();
         $attachmentArray['idx'] = $idx;
         $atts[] = $this->discuss->getChunk($postAttachmentRowTpl, $attachmentArray);
         $idx++;
     }
     /* attachments */
     $placeholders['attachment_fields'] = '';
     $placeholders['attachments'] = implode("\n", $atts);
     $placeholders['max_attachments'] = $this->modx->getOption('discuss.attachments_max_per_post', null, 5);
     $placeholders['attachmentCurIdx'] = count($attachments) + 1;
     if ($this->thread->canPostAttachments()) {
         $placeholders['attachment_fields'] = $this->discuss->getChunk('post/disAttachmentFields', $placeholders);
     }
     /* perms */
     if ($placeholders['is_root']) {
         if ($this->thread->canLock() || $this->thread->canUnlock()) {
             $checked = !empty($_POST) ? !empty($_POST['locked']) : $this->thread->get('locked');
             $placeholders['locked'] = $checked ? ' checked="checked"' : '';
             $placeholders['locked_cb'] = $this->discuss->getChunk('form/disCheckbox', array('name' => 'locked', 'value' => 1, 'text' => $this->getOption('textCheckboxLocked'), 'attributes' => $placeholders['locked']));
             $placeholders['can_lock'] = true;
         }
         if ($this->thread->canStick() || $this->thread->canUnstick()) {
             $checked = !empty($_POST) ? !empty($_POST['sticky']) : $this->thread->get('sticky');
             $placeholders['sticky'] = $checked ? ' checked="checked"' : '';
             $placeholders['sticky_cb'] = $this->discuss->getChunk('form/disCheckbox', array('name' => 'sticky', 'value' => 1, 'text' => $this->getOption('textCheckboxSticky'), 'attributes' => $placeholders['sticky']));
             $placeholders['can_stick'] = true;
         }
     }
     /* If the editing user is the author, show him the subscribe checkbox */
     if ($this->discuss->user->get('id') == $this->post->get('author') && ($this->thread->canSubscribe() || $this->thread->canUnsubscribe())) {
         $checked = !empty($_POST) ? !empty($_POST['notify']) : $this->thread->hasSubscription();
         $placeholders['notify'] = $checked ? ' checked="checked"' : '';
         $placeholders['notify_cb'] = $this->discuss->getChunk('form/disCheckbox', array('name' => 'notify', 'value' => 1, 'text' => $this->getOption('textCheckboxNotify'), 'attributes' => $placeholders['notify']));
         $placeholders['can_subscribe'] = true;
     }
     $this->getThreadSummary();
     /* output form to browser */
     $this->modx->regClientHTMLBlock('<script type="text/javascript">
         DIS.config.attachments_max_per_post = ' . $placeholders['max_attachments'] . ';
         DIS.DISModifyPost.init({
             attachments: ' . (count($attachments) + 1) . '
         });
     </script>');
     $this->modx->setPlaceholder('discuss.error_panel', $this->discuss->getChunk('disError'));
     $this->modx->setPlaceholders($placeholders, 'fi.');
     $this->setPlaceholders($placeholders);
 }