public function handleActions() { if (!empty($this->scriptProperties['spam-thread'])) { if ($this->thread->remove(array(), true, true)) { $this->discuss->logActivity('thread_spam_remove', $this->thread->toArray(), $this->thread->getUrl()); $url = $this->discuss->request->makeUrl('board', array('board' => $this->thread->get('board'))); $this->modx->sendRedirect($url); } } }
public function process() { /* get breadcrumb trail */ $postArray = $this->post->toArray(); $this->post->renderAuthorMeta($postArray); $this->setPlaceholders($postArray); $this->setPlaceholder('url', $this->post->getUrl()); /* output */ $this->modx->setPlaceholder('discuss.thread', $this->thread->get('title')); }
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); }
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); } }
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); }
public function getBreadcrumbs() { $defaults = array(); if (!empty($this->options['showTitleInBreadcrumbs'])) { $defaults[] = array('text' => $this->modx->lexicon('discuss.reply_to_post', array('post' => '<a class="active" href="' . $this->discuss->request->makeUrl('thread', array('thread' => $this->thread->get('id'))) . '">' . $this->post->get('title') . '</a>')), 'active' => true); } return $this->board->buildBreadcrumbs($defaults, true); }
public function getAnswers() { if ($this->thread->get('class_key') == 'disThreadQuestion' && $this->thread->get('answered')) { $c = $this->modx->newQuery('disPost'); $c->innerJoin('disUser', 'Author'); $c->where(array('board' => $this->thread->get('board'), 'thread' => $this->thread->get('id'), 'answer' => 1)); $c->sortby('createdon', 'ASC'); $c->select($this->modx->getSelectColumns('disPost', 'disPost')); $c->select($this->modx->getSelectColumns('disUser', 'Author', 'author_', array('password', 'hash_class'), true)); $answers = $this->modx->getCollection('disPost', $c); if (!empty($answers)) { $urls = array(); foreach ($answers as $post) { /* @var disPost $post */ $urls[$post->get('id')] = $post->toArray(); $urls[$post->get('id')]['url'] = $post->getUrl(); } $this->answerPosts = $urls; } $this->setPlaceholder('answer_count', count($this->answerPosts)); } }
public function getBreadcrumbs() { $trail = array(array('url' => $this->discuss->request->makeUrl(), 'text' => $this->modx->getOption('discuss.forum_title')), array('text' => $this->modx->lexicon('discuss.messages'), 'url' => $this->discuss->request->makeUrl('messages')), array('text' => $this->post->get('title'), 'url' => $this->discuss->request->makeUrl('messages/view', array('thread' => $this->thread->get('id')))), array('text' => $this->modx->lexicon('discuss.modify'), 'active' => true)); return $trail; }
/** * Overrides xPDOObject::get to provide Solved tag on title if thread is solved * * @param string $k * @param string $format * @param string $formatTemplate * @return mixed|string */ public function get($k, $format = '', $formatTemplate = '') { $v = parent::get($k, $format, $formatTemplate); if ($k == 'title' && $this->xpdo->lexicon && $this->xpdo->getOption('discuss.title_suffix_if_answered')) { $answered = $this->get('answered'); if (!empty($answered)) { $v .= $this->xpdo->lexicon($this->xpdo->getOption('discuss.title_suffix_if_answered')); } } return $v; }
public function buildPagination() { $this->discuss->hooks->load('pagination/build', array_merge(array('count' => $this->list['total'], 'id' => $this->thread->get('id'), 'view' => 'messages/view', 'limit' => $this->list['limit'], 'showPaginationIfOnePage' => $this->getOption('showPaginationIfOnePage', true, 'isset')), $this->options)); }
/** * Import all posts for the specified thread * * @param disThread $thread * @param disPost $threadPost * @param array $trow * @return array */ public function importPosts(disThread $thread, disPost $threadPost, array $trow = array()) { $sql = ' SELECT * FROM ' . $this->getFullTableName('messages') . ' WHERE `ID_TOPIC` = ' . $trow['ID_TOPIC'] . ' AND `ID_MSG` != ' . $trow['ID_MSG'] . ' AND `ID_BOARD` = ' . $trow['ID_BOARD'] . ' ORDER BY posterTime ASC ' . (!$this->config['live'] ? 'LIMIT 10' : ''); $pst = $this->pdo->query($sql); if (!$pst) { return array('total' => 0); } $pIdx = 0; while ($prow = $pst->fetch(PDO::FETCH_ASSOC)) { $this->log('Importing response: ' . $prow['subject']); /** @var disPost $post */ $post = $this->modx->newObject('disPost'); $post->set('thread', $thread->get('id')); $post->fromArray(array('board' => $thread->get('board'), 'thread' => $thread->get('id'), 'parent' => $threadPost->get('id'), 'title' => mb_convert_encoding($prow['subject'], $this->config['to_encoding'], $this->config['from_encoding']), 'message' => mb_convert_encoding($prow['body'], $this->config['to_encoding'], $this->config['from_encoding']), 'author' => isset($this->memberCache[$prow['ID_MEMBER']]) ? $this->memberCache[$prow['ID_MEMBER']] : 0, 'createdon' => strftime(DisSmfImport::DATETIME_FORMATTED, $prow['posterTime']), 'editedby' => !empty($prow['modifiedName']) && isset($this->memberNameCache[$prow['modifiedName']]) ? $this->memberNameCache[$prow['modifiedName']] : 0, 'editedon' => !empty($prow['modifiedTime']) ? strftime(DisSmfImport::DATETIME_FORMATTED, $prow['modifiedTime']) : null, 'icon' => $prow['icon'], 'allow_replies' => $thread->get('locked'), 'rank' => $pIdx, 'ip' => $prow['posterIP'], 'integrated_id' => $prow['ID_MSG'], 'depth' => 1)); if ($this->config['live']) { $post->save(); } $this->importAttachments($post, $prow); $pIdx++; } $pst->closeCursor(); return array('total' => $pIdx, 'lastPost' => isset($post) ? $post : null); }
public function process() { $this->setPlaceholders($this->thread->toArray()); $this->modx->setPlaceholder('discuss.thread', $this->thread->get('title')); }
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('[', ']', '<', '>'), $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); }