コード例 #1
1
 /**
  * Import all attachments for this post
  * @param disPost $post
  * @param array $prow
  * @return array
  */
 public function importAttachments(disPost $post, array $prow = array())
 {
     $ast = $this->pdo->query('
         SELECT
             *
         FROM ' . $this->getFullTableName('attachments') . '
         WHERE
             `ID_MSG` = ' . $prow['ID_MSG'] . '
     ');
     if (!$ast) {
         return array();
     }
     $aIdx = 0;
     while ($arow = $ast->fetch(PDO::FETCH_ASSOC)) {
         $this->log('Adding attachment: ' . $arow['filename']);
         /** @var disPostAttachment $attachment */
         $attachment = $this->modx->newObject('disPostAttachment');
         $attachment->fromArray(array('post' => $post->get('id'), 'board' => $post->get('board'), 'filename' => $arow['filename'], 'filesize' => $arow['size'], 'downloads' => $arow['downloads'], 'integrated_id' => $arow['ID_ATTACH'], 'integrated_data' => $this->modx->toJSON(array('filename' => $arow['filename'], 'file_hash' => $arow['file_hash'], 'width' => $arow['width'], 'height' => $arow['height'], 'attachmentType' => $arow['attachmentType'], 'ID_MEMBER' => $arow['ID_MEMBER'], 'ID_MESSAGE' => !empty($arow['ID_MESSAGE']) ? $arow['ID_MESSAGE'] : 0, 'ID_THUMB' => $arow['ID_THUMB']))));
         if ($this->config['live']) {
             $attachment->save();
         }
         $aIdx++;
     }
     $ast->closeCursor();
 }
コード例 #2
0
ファイル: spam.class.php プロジェクト: oneismore/Discuss
 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
ファイル: remove.class.php プロジェクト: oneismore/Discuss
 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);
 }
コード例 #4
0
ファイル: report.class.php プロジェクト: oneismore/Discuss
 /**
  * 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);
 }
コード例 #5
0
ファイル: reply.class.php プロジェクト: oneismore/Discuss
 /**
  * Handle Quote functionality that will append the quoted post into the initial message
  * @return void
  */
 public function handleQuote()
 {
     if (empty($_POST) && !empty($this->scriptProperties['quote'])) {
         $message = str_replace(array('[', ']'), array('&#91;', '&#93;'), $this->post->br2nl($this->post->get('message')));
         $message = '[quote author=' . $this->author->get('username') . ' date=' . strtotime($this->post->get('createdon')) . ']' . $message . '[/quote]' . "\n";
         $this->setPlaceholder('message', $message);
     } elseif (empty($_POST) && empty($this->scriptProperties['quote'])) {
         $this->setPlaceholder('message', '');
     }
 }
コード例 #6
0
ファイル: modify.class.php プロジェクト: oneismore/Discuss
 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;
 }
コード例 #7
0
 public function checkPermissions()
 {
     return $this->discuss->user->isLoggedIn && $this->post->get('author') == $this->discuss->user->get('id');
 }
コード例 #8
0
ファイル: modify.class.php プロジェクト: oneismore/Discuss
 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;
 }