public function initialize() { $thread = $this->getProperty('thread', false); if (empty($thread)) { $post = $this->getProperty('post', false); if (empty($post)) { $this->modx->sendErrorPage(); } $this->post = $this->modx->getObject('disPost', $post); if (empty($this->post)) { $this->discuss->sendErrorPage(); } /* get thread root */ $this->thread = $this->post->getOne('Thread'); if (empty($this->thread)) { $this->discuss->sendErrorPage(); } } else { $this->thread = $this->modx->getObject('disThread', $thread); if (empty($this->thread)) { $this->discuss->sendErrorPage(); } $this->post = $this->thread->getOne('FirstPost'); if (empty($this->post)) { $this->discuss->sendErrorPage(); } } $this->author = $this->post->getOne('Author'); $this->board = $this->thread->getOne('Board'); $this->modx->lexicon->load('discuss:post'); if ($this->board) { $this->discuss->user->isModerator($this->board->get('id')); } }
public function initialize() { if (empty($this->scriptProperties['thread']) && empty($this->scriptProperties['post'])) { $this->modx->sendErrorPage(); } if (!empty($this->scriptProperties['post']) && empty($this->scriptProperties['thread'])) { $this->post = $this->modx->getObject('disPost', $this->scriptProperties['post']); if (empty($this->post)) { $this->discuss->sendErrorPage(); } $this->scriptProperties['thread'] = $this->post->get('thread'); } if (!class_exists('disThread')) { $this->modx->loadClass('disThread'); } $this->thread = $this->modx->call('disThread', 'fetch', array(&$this->modx, $this->scriptProperties['thread'], disThread::TYPE_MESSAGE)); if (empty($this->thread)) { $this->modx->sendErrorPage(); } if (empty($this->post)) { $this->post = $this->thread->getOne('FirstPost'); if (empty($this->post)) { $this->discuss->sendErrorPage(); } } $this->author = $this->post->getOne('Author'); $this->modx->lexicon->load('discuss:post'); }
/** * 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); }