示例#1
0
 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);
         }
     }
 }
示例#2
0
 public function prepareThread(disThread $thread)
 {
     $threadArray = $thread->toArray();
     if (!empty($threadArray['post_last_on'])) {
         $threadArray['post_last_on'] = strftime($this->getProperty('dateFormat'), strtotime($threadArray['post_last_on']));
     } else {
         $threadArray['post_last_on'] = '';
     }
     return $threadArray;
 }
示例#3
0
 public function handleActions()
 {
     /* process form */
     if (!empty($this->scriptProperties['remove-message'])) {
         if ($this->thread->remove()) {
             /* log activity */
             $this->discuss->logActivity('message_thread_remove', $this->thread->toArray(), $this->thread->getUrl());
             $url = $this->discuss->request->makeUrl('messages');
             $this->modx->sendRedirect($url);
         }
     }
 }
示例#4
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);
 }
示例#5
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);
     }
 }
示例#6
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);
 }
示例#7
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);
 }
示例#8
0
 /**
  * Handle the rendering and options of attachments being sent to the form
  * @return void
  */
 public function handleAttachments()
 {
     $this->setPlaceholder('max_attachments', $this->modx->getOption('discuss.attachments_max_per_post', null, 5));
     if ($this->thread->canPostAttachments()) {
         $this->setPlaceholder('attachment_fields', $this->discuss->getChunk('post/disAttachmentFields', $this->getPlaceholders()));
     } else {
         $this->setPlaceholder('attachment_fields', '');
     }
     $this->setPlaceholder('attachmentCurIdx', 1);
     $this->modx->regClientHTMLBlock('<script type="text/javascript">
     DIS.config.attachments_max_per_post = ' . $this->getPlaceholder('max_attachments') . ';
     </script>');
 }
示例#9
0
 public function getBreadcrumbs()
 {
     /* build breadcrumbs */
     $trail = '';
     if (empty($this->board)) {
         $this->board = $this->thread->getOne('Board');
     }
     if ($this->board) {
         $default = array();
         if (!empty($this->options['showTitleInBreadcrumbs'])) {
             $default[] = array('text' => $this->modx->lexicon('discuss.modify_post_header', array('post' => $this->post->get('title'))), 'active' => true);
         }
         $this->board->buildBreadcrumbs($default, true);
         $trail = $this->board->get('trail');
     }
     return $trail;
 }
示例#10
0
 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));
     }
 }
示例#11
0
 /**
  * Prepare the thread for iteration
  * @param disThread $thread
  * @return array
  */
 protected function prepareThread(disThread $thread)
 {
     $thread->calcLastPostPage();
     $thread->getUrl();
     $threadArray = $thread->toArray();
     $threadArray['createdon'] = strftime($this->getOption('dateFormat'), strtotime($threadArray['createdon']));
     $threadArray['icons'] = '';
     /* set css class */
     $class = $this->getOption('clsRow');
     $class = explode(',', $class);
     if ($this->getOption('enableHot')) {
         $threshold = $this->getOption('hotThreadThreshold');
         if ($this->discuss->user->get('id') == $threadArray['author'] && $this->discuss->user->isLoggedIn) {
             $class[] = $threadArray['replies'] < $threshold ? $this->getOption('clsMyNormalThread') : $this->getOption('clsMyHotThread');
         } else {
             $class[] = $threadArray['replies'] < $threshold ? $this->getOption('clsNormalThread') : $this->getOption('clsHotThread');
         }
     }
     $threadArray['class'] = implode(' ', $class);
     /* if sticky/locked */
     $icons = array();
     if ($threadArray['locked']) {
         $icons[] = $this->getOption('iconLocked');
     }
     if ($this->getOption('enableSticky') && $threadArray['sticky']) {
         $icons[] = $this->getOption('iconSticky');
     }
     $threadArray['icons'] = implode($this->getOption('iconSeparator'), $icons);
     $threadArray['views'] = number_format($threadArray['views']);
     $threadArray['replies'] = number_format($threadArray['replies']);
     /* unread class */
     $threadArray['unread'] = true;
     $threadArray['unread-cls'] = $this->getOption('clsUnread');
     $threadArray['author_link'] = $this->getOption('canViewProfiles') ? '<a class="dis-last-post-by" href="' . $this->discuss->request->makeUrl('user', array('type' => 'username', 'user' => $threadArray['author_username'])) . '">' . $threadArray['author_username'] . '</a>' : $threadArray['author_username'];
     return $threadArray;
 }
示例#12
0
 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;
 }
 /**
  * @param array $postArray
  * @return array
  */
 public function aggregateThreadActionButtons(array $postArray = array(), $defaultAvailableActions = 'mark_as_answer,reply,quote,modify,remove,spam')
 {
     return parent::aggregateThreadActionButtons($postArray, 'mark_as_answer,reply,quote,modify,remove,spam');
 }
示例#14
0
 public function getBreadcrumbs()
 {
     return $this->thread->buildBreadcrumbs(array(array('url' => $this->discuss->request->makeUrl(), 'text' => $this->modx->getOption('discuss.forum_title')), array('url' => $this->discuss->request->makeUrl('messages'), 'text' => $this->modx->lexicon('discuss.messages'))));
 }
示例#15
0
 /**
  * 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);
 }