Exemple #1
0
 public function process()
 {
     if ($this->request()->segment(2) == 'search') {
         return false;
     }
     $title = '';
     $threads = [];
     $type = 'threads';
     if (Phpfox_Module::instance()->getFullControllerName() == 'forum.forum') {
         $title = 'Recent Posts';
         $threads = Forum_Service_Post_Post::instance()->getRecentForForum($this->request()->segment(2));
         $type = 'posts';
     } else {
         $title = 'Recent Discussions';
         $ids = [];
         $forums = Forum_Service_Forum::instance()->getForums();
         foreach ($forums as $forum) {
             $ids[] = $forum['forum_id'];
             $childs = Forum_Service_Forum::instance()->id($forum['forum_id'])->getChildren();
             if ($childs) {
                 foreach ($childs as $id) {
                     $ids[] = $id;
                 }
             }
         }
         $cond[] = 'ft.forum_id IN(' . implode(',', $ids) . ') AND ft.group_id = 0 AND ft.view_id >= 0';
         list($cnt, $threads) = Forum_Service_Thread_Thread::instance()->get($cond, 'ft.time_update DESC', 0, 20);
     }
     $this->template()->assign(['sHeader' => $title, 'threads' => $threads, 'type' => $type]);
     return 'block';
 }
Exemple #2
0
 /**
  * Controller
  */
 public function process()
 {
     $aThread = Forum_Service_Thread_Thread::instance()->getActualThread($this->request()->get('thread_id'));
     if (!isset($aThread['thread_id'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread_to_move'));
     }
     $this->template()->assign(array('sForums' => Phpfox::getService('forum')->active($aThread['forum_id'])->getJumpTool(true), 'aThread' => $aThread));
 }
Exemple #3
0
 /**
  * Controller
  */
 public function process()
 {
     $aGroup = $this->getParam('aGroup');
     $aThreads = Forum_Service_Thread_Thread::instance()->getForParent($aGroup['group_id']);
     if (!count($aThreads) && !defined('PHPFOX_IN_DESIGN_MODE')) {
         return false;
     }
     if (!Phpfox::getService('group')->hasAccess($aGroup['group_id'], 'can_use_forum')) {
         return false;
     }
     $this->template()->assign(array('sHeader' => Phpfox::getPhrase('forum.recent_topics'), 'aThreads' => $aThreads, 'aGroup' => $aGroup));
     return 'block';
 }
Exemple #4
0
 public function process()
 {
     header('Content-type: application/javascript');
     $ids = [];
     $forums = Forum_Service_Forum::instance()->getForums();
     foreach ($forums as $forum) {
         $ids[] = $forum['forum_id'];
         $childs = Forum_Service_Forum::instance()->id($forum['forum_id'])->getChildren();
         if ($childs) {
             foreach ($childs as $id) {
                 $ids[] = $id;
             }
         }
     }
     $cond[] = 'ft.forum_id IN(' . implode(',', $ids) . ') AND ft.group_id = 0 AND ft.view_id >= 0';
     list($cnt, $threads) = Forum_Service_Thread_Thread::instance()->get($cond, 'ft.time_update DESC', 0, 20);
     $json = [];
     foreach ($threads as $thread) {
         $json[] = (object) ['thread_id' => $thread['thread_id'], 'title' => $thread['title'], 'permalink' => Phpfox::permalink('forum.thread', $thread['thread_id'], $thread['title']), 'user' => htmlspecialchars($thread['full_name']), 'created' => Phpfox::getLib('date')->convertTime($thread['time_stamp'])];
     }
     echo ';function __Threads(callback) { var threads = ' . json_encode($json) . '; if (typeof(callback) == \'function\') { callback(threads); } };';
     exit;
 }
Exemple #5
0
 public function thread($iId = 0)
 {
     /*
     @title
     @info Get a specific thread and all of its posts.
     @method GET
     @extra
     @return thread_id=#{Thread ID#|int}&title=#{Title of the thread|string}&last_time_stamp=#{Last time the thread was updated|int}&permalink=#{URL to the thread|string}&posts=#{Array of posts|array}
     */
     if ((int) $this->_oApi->get('id') !== 0) {
         $iId = $this->_oApi->get('id');
     }
     $aCond = array();
     $aCond[] = 'ft.thread_id = ' . $iId;
     list($iCnt, $aThread) = Forum_Service_Thread_Thread::instance()->getThread($aCond, array(), 'fp.time_stamp ASC', $this->_oApi->get('page'), 20);
     $aReturn = array('thread_id' => $aThread['thread_id'], 'title' => $aThread['title'], 'last_time_stamp' => $aThread['last_time_stamp'], 'permalink' => Phpfox::permalink('forum.thread', $aThread['thread_id'], $aThread['title']));
     if (isset($aThread['posts']) && !empty($aThread['posts'])) {
         foreach ($aThread['posts'] as $aPost) {
             $aReturn['posts'][] = array('post_id' => $aPost['post_id'], 'time_stamp' => $aPost['time_stamp'], 'lkes' => $aPost['total_like'], 'post' => Phpfox::getLib('parse.output')->parse($aPost['text']), 'posted_by' => $aPost['full_name'], 'posted_by_url' => Phpfox_Url::instance()->makeUrl($aPost['user_name']));
         }
     }
     return $aReturn;
 }
Exemple #6
0
 /**
  * Controller
  */
 public function process()
 {
     if ($this->request()->getInt('forum')) {
         if (!Phpfox::getParam('forum.rss_feed_on_each_forum')) {
             return Phpfox_Error::set(Phpfox::getPhrase('forum.rss_feeds_are_disabled_for_threads'));
         }
         if (!Phpfox::getService('forum')->hasAccess($this->request()->getInt('forum'), 'can_view_forum')) {
             return Phpfox_Error::set(Phpfox::getPhrase('forum.rss_feeds_are_disabled_for_threads'));
         }
         $aRss = Phpfox::getService('forum')->getForRss($this->request()->getInt('forum'));
     } elseif ($this->request()->getInt('thread')) {
         if (!Phpfox::getParam('forum.enable_rss_on_threads')) {
             return Phpfox_Error::set(Phpfox::getPhrase('forum.rss_feeds_are_disabled_for_threads'));
         }
         if (!Phpfox::getService('forum')->hasAccess($this->request()->getInt('thread'), 'can_view_thread_content')) {
             return Phpfox_Error::set(Phpfox::getPhrase('forum.rss_feeds_are_disabled_for_threads'));
         }
         $aRss = Phpfox::getService('forum.post')->getForRss($this->request()->getInt('thread'));
         if (isset($aRss['items']) && is_array($aRss['items']) && count($aRss['items'])) {
             if (!Phpfox::getService('forum')->hasAccess($aRss['items'][0]['forum_id'], 'can_view_forum')) {
                 return Phpfox_Error::set(Phpfox::getPhrase('forum.rss_feeds_are_disabled_for_threads'));
             }
         }
     } elseif ($this->request()->getInt('pages')) {
         if (!Phpfox::getParam('forum.rss_feed_on_each_forum')) {
             return Phpfox_Error::set(Phpfox::getPhrase('forum.rss_feeds_are_disabled_for_threads'));
         }
         $aGroup = Phpfox::getService('pages')->getPage($this->request()->getInt('pages'), true);
         if (!isset($aGroup['page_id'])) {
             return Phpfox_Error::set(Phpfox::getPhrase('forum.not_a_valid_group'));
         }
         $aItems = Forum_Service_Thread_Thread::instance()->getForRss(Phpfox::getParam('rss.total_rss_display'), null, $aGroup['page_id']);
         $aRss = array('href' => '', 'title' => Phpfox::getPhrase('forum.latest_threads_in_group_forum') . ': ' . $aGroup['title'], 'description' => Phpfox::getPhrase('forum.latest_threads_on') . ': ' . $aGroup['title'], 'items' => $aItems);
     }
     Phpfox::getService('rss')->output($aRss);
 }
Exemple #7
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::isUser(true);
     $bCanEditPersonalData = true;
     $aCallback = false;
     if ($this->request()->get('module')) {
         $this->template()->assign(array('bIsGroup' => '1'));
     }
     if (($sModule = $this->request()->get('module')) && Phpfox::isModule($sModule) && ($iItemId = $this->request()->getInt('item')) && Phpfox::hasCallback($sModule, 'addForum')) {
         $aCallback = Phpfox::callback($sModule . '.addForum', $iItemId);
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.pages'), $this->url()->makeUrl('pages'));
         $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.discussions'), $aCallback['url_home'] . 'forum/');
         if ($sModule == 'pages' && !Phpfox::getService('pages')->hasPerm($iItemId, 'forum.share_forum')) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.unable_to_view_this_item_due_to_privacy_settings'));
         }
     } else {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.forum'), $this->url()->makeUrl('forum'));
     }
     $iId = $this->request()->getInt('id');
     $aAccess = Forum_Service_Forum::instance()->getUserGroupAccess($iId, Phpfox::getUserBy('user_group_id'));
     if ($aAccess['can_view_thread_content']['value'] != true) {
         return Phpfox_Error::display(Phpfox::getPhrase('forum.unable_to_view_this_item_due_to_privacy_settings'));
     }
     if (Phpfox::isModule('poll')) {
         $this->template()->setHeader('cache', array('poll.js' => 'module_poll', '<script type="text/javascript">$Behavior.loadSortableAnswers = function() {$(".sortable").sortable({placeholder: "placeholder", axis: "y"});}</script>'));
     }
     $this->template()->setEditor()->setTitle(Phpfox::getPhrase('forum.forum'))->setHeader('cache', array('switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'pager.css' => 'style_css', 'forum.css' => 'style_css'));
     $bIsEdit = false;
     if ($this->request()->get('req3') == 'thread') {
         if ($iEditId = $this->request()->getInt('edit')) {
             $aThread = Forum_Service_Thread_Thread::instance()->getForEdit($iEditId);
             if (!isset($aThread['thread_id'])) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread'));
             }
             if (Phpfox::getUserParam('forum.can_edit_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'edit_post')) {
                 $bIsEdit = true;
                 if (Phpfox::getUserParam('forum.can_edit_other_posts') && Phpfox::getUserId() != $aThread['user_id']) {
                     $bCanEditPersonalData = false;
                 }
                 $iId = $aThread['forum_id'];
                 if (Phpfox::isModule('tag')) {
                     $aThread['tag_list'] = Tag_Service_Tag::instance()->getForEdit('forum', $aThread['thread_id']);
                 }
                 $this->template()->assign(array('aForms' => $aThread, 'iEditId' => $aThread['thread_id']));
             } else {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_edit_this_thread'));
             }
         }
         if ($aCallback === false) {
             $aForum = Phpfox::getService('forum')->id($iId)->getForum();
             if (!isset($aForum['forum_id'])) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_forum'));
             }
             if ($aForum['is_closed']) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.forum_is_closed'));
             }
         }
         if (!$bIsEdit) {
             $bPass = false;
             if (Phpfox::getUserParam('forum.can_add_new_thread') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'add_thread')) {
                 $bPass = true;
             }
             if ($bPass === false) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_reply_to_this_thread'));
             }
         }
         if (!Forum_Service_Forum::instance()->hasAccess($iId, 'can_start_thread')) {
             return Phpfox_Error::display('You are unable to create a new post in this forum.');
         }
         $aValidation = array('title' => Phpfox::getPhrase('forum.provide_a_title_for_your_thread'), 'text' => Phpfox::getPhrase('forum.provide_some_text'));
         if (Phpfox::isModule('captcha') && Phpfox::getUserParam('forum.enable_captcha_on_posting')) {
             $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge');
         }
         $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
         $bPosted = false;
         if ($aVals = $this->request()->getArray('val')) {
             if (isset($aVals['type_id']) && $aVals['type_id'] == 'announcement') {
                 $bPosted = true;
             }
             if ($oValid->isValid($aVals)) {
                 if ($bIsEdit) {
                     $aVals['post_id'] = $aThread['start_id'];
                     $aVals['was_announcement'] = $aThread['is_announcement'];
                     $aVals['forum_id'] = $aThread['forum_id'];
                     if (Phpfox::getService('forum.thread.process')->update($aThread['thread_id'], $aThread['user_id'], $aVals)) {
                         $this->url()->permalink('forum.thread', $aThread['thread_id'], Phpfox::getLib('parse.input')->clean($aVals['title'], 255), true, Phpfox::getPhrase('forum.thread_successfully_updated'));
                     }
                 } else {
                     if (($iFlood = Phpfox::getUserParam('forum.forum_thread_flood_control')) !== 0) {
                         $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('forum_thread'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
                         // actually check if flooding
                         if (Phpfox::getLib('spam')->check($aFlood)) {
                             Phpfox_Error::set(Phpfox::getPhrase('forum.posting_a_new_thread_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime());
                         }
                     }
                     if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('forum.thread.process')->add($aVals, $aCallback))) {
                         $this->url()->permalink('forum.thread', $iId, Phpfox::getLib('parse.input')->clean($aVals['title'], 255), true);
                     }
                 }
             }
         }
         if ($aCallback === false) {
             $this->template()->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb($aForum['name'], $this->url()->permalink('forum', $aForum['forum_id'], $aForum['name']))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_thread') . ': ' . $aThread['title'] : Phpfox::getPhrase('forum.post_new_thread'), $this->url()->makeUrl('forum.post.thread'), true);
         } else {
             $this->template()->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_thread') . ': ' . $aThread['title'] : Phpfox::getPhrase('forum.post_new_thread'), $this->url()->makeUrl('forum.post.thread'), true);
         }
         $this->template()->assign(array('iForumId' => $iId, 'iActualForumId' => $iId, 'sFormLink' => $aCallback == false ? $this->url()->makeUrl('forum.post.thread', array('id' => $iId)) : $this->url()->makeUrl('forum.post.thread', array('module' => $sModule, 'item' => $iItemId)), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'sForumParents' => $aCallback === false ? Phpfox::getUserParam('forum.can_post_announcement') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'post_announcement') ? Phpfox::getService('forum')->active($aForum['forum_id'])->getJumpTool(true) : '' : '', 'bPosted' => $bPosted, 'sReturnLink' => $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']) : '', 'bIsEdit' => $bIsEdit, 'aCallback' => $aCallback));
         if (Phpfox::getUserParam('forum.can_add_forum_attachments')) {
             $this->setParam('attachment_share', array('type' => 'forum', 'id' => 'js_forum_form'));
         }
     } else {
         if ($iEditId = $this->request()->getInt('edit')) {
             $aPost = Phpfox::getService('forum.post')->getForEdit($iEditId);
             if (!isset($aPost['post_id'])) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_post'));
             }
             $bCanEditPost = Phpfox::getUserParam('forum.can_edit_own_post') && $aPost['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aPost['forum_id'], 'edit_post');
             if ($bCanEditPost) {
                 $bIsEdit = true;
                 if (Phpfox::getUserParam('forum.can_edit_other_posts') && Phpfox::getUserId() != $aPost['user_id']) {
                     $bCanEditPersonalData = false;
                 }
                 $iId = $aPost['thread_id'];
                 $this->template()->assign(array('aForms' => $aPost, 'iEditId' => $aPost['post_id']));
                 if (PHPFOX_IS_AJAX) {
                     Phpfox_Ajax::instance()->setTitle(Phpfox::getPhrase('forum.editing_post') . ': ' . (empty($aPost['title']) ? '#' . $aPost['post_id'] : Phpfox::getLib('parse.output')->shorten($aPost['title'], 80, '...')));
                 }
             } else {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_edit_this_thread'));
             }
         }
         $aThread = Forum_Service_Thread_Thread::instance()->getActualThread($iId, $aCallback);
         if (!isset($aThread['thread_id'])) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread'));
         }
         if ($aThread['is_closed'] && (isset($bCanEditPost) && !$bCanEditPost || !isset($bCanEditPost))) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.thread_is_closed'));
         }
         if ($aCallback === false && $aThread['forum_is_closed']) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.forum_is_closed'));
         }
         if (!$iEditId && $aThread['is_announcement']) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.thread_is_an_announcement_not_allowed_to_leave_a_reply'));
         }
         if (!$bIsEdit) {
             $bPass = false;
             if (Phpfox::getUserParam('forum.can_reply_to_own_thread') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_reply_on_other_threads') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'can_reply')) {
                 $bPass = true;
             }
             if ($bPass === false) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_reply_to_this_thread'));
             }
         }
         $sExtraText = '';
         if ($sSavedText = $this->request()->get('save_text')) {
             $sExtraText .= Phpfox::getLib('parse.output')->clean($sSavedText);
         }
         if (Phpfox::getUserParam('forum.can_multi_quote_forum') && (($iQuote = $this->request()->getInt('quote')) || ($sCookie = Phpfox::getCookie('forum_quote')) && !empty($sCookie))) {
             $sCookie = Phpfox::getCookie('forum_quote');
             if (!empty($sCookie)) {
                 $iQuote = $sCookie . $iQuote;
             }
             $sExtraText .= Phpfox::getService('forum.post')->getQuotes($aThread['thread_id'], $iQuote);
         }
         if (($iQuoteId = $this->request()->getInt('quote')) && ($aQuotePost = Phpfox::getService('forum.post')->getForEdit($iQuoteId))) {
             Phpfox_Ajax::instance()->setTitle(Phpfox::getPhrase('forum.replying_to_a_post_by_full_name', array('full_name' => Phpfox::getLib('parse.output')->shorten($aQuotePost['full_name'], 80, '...'))));
         }
         $aSubForms = array();
         if (isset($aThread['is_subscribed'])) {
             $aSubForms['is_subscribed'] = $aThread['is_subscribed'];
         }
         if (!empty($sExtraText)) {
             $aSubForms['text'] = $sExtraText;
         }
         if (isset($bCanEditPost) && $bCanEditPost) {
             $aSubForms = array_merge($aSubForms, $aPost);
         }
         $this->template()->assign('aForms', $aSubForms);
         $aValidation = array('text' => Phpfox::getPhrase('forum.provide_some_text'));
         if (Phpfox::isModule('captcha') && Phpfox::getUserParam('forum.enable_captcha_on_posting')) {
             $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge');
         }
         $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
         $aForum = Phpfox::getService('forum')->id($aThread['forum_id'])->getForum();
         if ($aVals = $this->request()->getArray('val')) {
             $aVals['forum_id'] = $aThread['forum_id'];
             if ($oValid->isValid($aVals)) {
                 Phpfox::setCookie('forum_quote', '', -1);
                 if ($bIsEdit) {
                     if (Phpfox::getService('forum.post.process')->update($aPost['post_id'], $aPost['user_id'], $aVals)) {
                         $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, null, array('post' => $aPost['post_id']));
                     }
                 } else {
                     if (($iFlood = Phpfox::getUserParam('forum.forum_post_flood_control')) !== 0) {
                         $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('forum_post'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
                         // actually check if flooding
                         if (Phpfox::getLib('spam')->check($aFlood)) {
                             Phpfox_Error::set(Phpfox::getPhrase('forum.posting_a_reply_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime());
                         }
                     }
                     if (Phpfox_Error::isPassed()) {
                         if ($iId = Phpfox::getService('forum.post.process')->add($aVals, $aCallback)) {
                             $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, null, array('post' => $iId));
                         } else {
                             if (Phpfox::getUserParam('forum.approve_forum_post')) {
                                 $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, Phpfox::getPhrase('forum.your_post_has_successfully_been_added_however_it_is_pending_an_admins_approval_before_it_can_be_displayed_publicly'), array('post' => $iId));
                             }
                         }
                     }
                 }
             }
         }
         if ($aCallback === false) {
             $this->template()->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb($aForum['name'], $this->url()->makeUrl('forum', $aForum['name_url'] . '-' . $aForum['forum_id']));
         } else {
         }
         $this->template()->setBreadcrumb($aThread['title'], $aCallback === false ? $this->url()->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_post') . ': ' . (empty($aPost['title']) ? '#' . $aPost['post_id'] : $aPost['title']) : Phpfox::getPhrase('forum.post_new_reply'), $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'], 'post_' . $aPost['post_id'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', array($aThread['title_url'], 'post' => $aPost['post_id'])) : null, true)->assign(array('iThreadId' => $iId, 'iActualForumId' => $aForum['forum_id'], 'sFormLink' => $aCallback === false ? $this->url()->makeUrl('forum.post.reply', array('id' => $iId)) : $this->url()->makeUrl('forum.post.reply', array('id' => $iId, 'module' => $sModule, 'item' => $iItemId)), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(PHPFOX_IS_AJAX ? false : true), 'sReturnLink' => $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'], 'post_' . $aPost['post_id'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']) : '', 'sThreadReturnLink' => $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'], array('forum', $aThread['title_url'])), 'aPreviews' => Phpfox::getService('forum.post')->getPreview($aThread['thread_id']), 'iTotalPosts' => $aThread['total_post'], 'bIsEdit' => $bIsEdit, 'aCallback' => $aCallback, 'iTotalPostPreview' => Phpfox::getParam('forum.total_forum_post_preview')));
         if (Phpfox::getUserParam('forum.can_add_forum_attachments')) {
             $this->setParam('attachment_share', array('type' => 'forum', 'inline' => PHPFOX_IS_AJAX ? true : false, 'id' => 'js_forum_form', 'edit_id' => $bIsEdit ? $aPost['post_id'] : ''));
         }
     }
 }
 /**
  * Controller
  */
 public function process()
 {
     define('PHPFOX_PAGER_FORCE_COUNT', true);
     Phpfox::getUserParam('forum.can_view_forum', true);
     $iPage = $this->request()->getInt('page');
     $iPageSize = Phpfox::getParam('forum.total_posts_per_thread');
     $aThreadCondition = array();
     $aCallback = $this->getParam('aCallback', null);
     if (($iPostRedirect = $this->request()->getInt('permalink')) && ($sUrl = Phpfox::getService('forum.callback')->getFeedRedirectPost($iPostRedirect))) {
         $this->url()->forward(preg_replace('/\\/post_(.*)\\//i', '/view_\\1/', $sUrl));
     }
     if (Phpfox::isUser() && ($iView = $this->request()->getInt('view')) && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('forum_subscribed_post', $iView, Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('forum_post_like', $iView, Phpfox::getUserId());
     }
     if (($iRedirect = $this->request()->getInt('redirect')) && ($aThread = Forum_Service_Thread_Thread::instance()->getForRedirect($iRedirect))) {
         if ($aThread['group_id'] > 0) {
             $aCallback = Phpfox::callback('group.addForum', $aThread['group_id']);
             if (isset($aCallback['module'])) {
                 $this->url()->send($aCallback['url_home'], array('forum', $aThread['title_url']));
             }
         }
         $this->url()->send('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url']));
     }
     $threadId = $this->request()->getInt('req3');
     if ($this->request()->segment(3) == 'replies' && $this->request()->getInt('id')) {
         $threadId = $this->request()->getInt('id');
         $iPage = 1;
         $iPageSize = 200;
         $this->template()->setBreadCrumb('Latest Replies', $this->url()->current(), true);
         $this->template()->assign(['isReplies' => true]);
     }
     $aThreadCondition[] = 'ft.thread_id = ' . $threadId . '';
     $sPermaView = $this->request()->get('view', null);
     if ((int) $sPermaView <= 0) {
         $sPermaView = null;
     }
     list($iCnt, $aThread) = Forum_Service_Thread_Thread::instance()->getThread($aThreadCondition, array(), 'fp.time_stamp ASC', $iPage, $iPageSize, $sPermaView);
     if (!isset($aThread['thread_id'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread'));
     }
     if ($aThread['group_id'] > 0) {
         $aCallback = Phpfox::callback('pages.addForum', $aThread['group_id']);
         if (!Phpfox::getService('pages')->hasPerm($aThread['group_id'], 'forum.view_browse_forum')) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread'));
         }
     }
     Phpfox::getService('core.redirect')->check($aThread['title'], 'req4');
     if ($aThread['view_id'] != '0' && $aThread['user_id'] != Phpfox::getUserId()) {
         if (!Phpfox::getUserParam('forum.can_approve_forum_thread') && !Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'approve_thread')) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread'));
         }
     }
     if ($aCallback === null && !Phpfox::getService('forum')->hasAccess($aThread['forum_id'], 'can_view_forum')) {
         if (Phpfox::isUser()) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.you_do_not_have_the_proper_permission_to_view_this_thread'));
         } else {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.log_in_to_view_thread'));
         }
     }
     if ($aCallback === null && !Phpfox::getService('forum')->hasAccess($aThread['forum_id'], 'can_view_thread_content')) {
         $this->url()->send('forum', null, Phpfox::getPhrase('forum.you_do_not_have_the_proper_permission_to_view_this_thread'));
     }
     Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt));
     $aForum = Phpfox::getService('forum')->id($aThread['forum_id'])->getForum();
     if ($this->request()->get('approve') && (Phpfox::getUserParam('forum.can_approve_forum_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'approve_thread')) && $aThread['view_id']) {
         $sCurrentUrl = $this->url()->permalink('forum.thread', $aThread['thread_id'], $aThread['title']);
         if (Phpfox::getService('forum.thread.process')->approve($aThread['thread_id'], $sCurrentUrl)) {
             $this->url()->forward($sCurrentUrl);
         }
     }
     if ($iPostId = $this->request()->getInt('post')) {
         $iCurrentPage = Forum_Service_Post_Post::instance()->getPostPage($aThread['thread_id'], $iPostId, $iPageSize);
         $sFinalLink = $this->url()->permalink('forum.thread', $aThread['thread_id'], $aThread['title'], false, null, array('page' => $iCurrentPage));
         $this->url()->forward($sFinalLink . '#post' . $iPostId);
     }
     if (!$aThread['is_seen']) {
         if ($aCallback === null) {
             Phpfox::getService('forum.process')->updateTrack($aForum['forum_id']);
         }
         Phpfox::getService('forum.thread.process')->updateTrack($aThread['thread_id']);
     }
     if (Phpfox::isModule('tag') && $aCallback === null) {
         $aTags = Tag_Service_Tag::instance()->getTagsById($aCallback === null ? 'forum' : 'forum_group', $aThread['thread_id']);
         if (isset($aTags[$aThread['thread_id']])) {
             $aThread['tag_list'] = $aTags[$aThread['thread_id']];
         }
     }
     // Add tags to meta keywords
     if (!empty($aThread['tag_list']) && $aThread['tag_list'] && Phpfox::isModule('tag')) {
         $this->template()->setMeta('keywords', Tag_Service_Tag::instance()->getKeywords($aThread['tag_list']));
     }
     $this->setParam('iActiveForumId', $aForum['forum_id']);
     if (Phpfox::getParam('forum.rss_feed_on_each_forum')) {
         if ($aCallback === null) {
             $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('forum.forum') . ': ' . $aForum['name'] . '" href="' . $this->url()->makeUrl('forum', array('rss', 'forum' => $aForum['forum_id'])) . '" />');
         } else {
             $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('forum.group_forum') . ': ' . $aCallback['title'] . '" href="' . $this->url()->makeUrl('forum', array('rss', 'group' => $aCallback['group_id'])) . '" />');
         }
     }
     if (Phpfox::getParam('forum.enable_rss_on_threads')) {
         $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('forum.thread') . ': ' . $aThread['title'] . '" href="' . $this->url()->makeUrl('forum', array('rss', 'thread' => $aThread['thread_id'])) . '" />');
     }
     if ($aCallback === null) {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.forum'), $this->url()->makeUrl('forum'))->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb(Phpfox_Locale::instance()->convert($aForum['name']), $this->url()->permalink('forum', $aForum['forum_id'], $aForum['name']));
     } else {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.pages'), $this->url()->makeUrl('pages'));
         $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.discussions'), $aCallback['url_home'] . 'forum/');
     }
     $bCanManageThread = false;
     $bCanEditThread = false;
     $bCanDeleteThread = false;
     $bCanStickThread = false;
     $bCanCloseThread = false;
     $bCanMergeThread = false;
     if ($aCallback === null) {
         if (Phpfox::getUserParam('forum.can_edit_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'edit_post')) {
             $bCanEditThread = true;
         }
         if (Phpfox::getUserParam('forum.can_delete_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_delete_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'delete_post')) {
             $bCanDeleteThread = true;
         }
         if (Phpfox::getUserParam('forum.can_stick_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'post_sticky')) {
             $bCanStickThread = true;
         }
         if (Phpfox::getUserParam('forum.can_close_a_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'close_thread')) {
             $bCanCloseThread = true;
         }
         if (Phpfox::getUserParam('forum.can_merge_forum_threads') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'merge_thread')) {
             $bCanMergeThread = true;
         }
         if (Phpfox::getUserParam('forum.can_edit_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'edit_post') || (Phpfox::getUserParam('forum.can_move_forum_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'move_thread')) || (Phpfox::getUserParam('forum.can_copy_forum_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'copy_thread')) || Phpfox::getUserParam('forum.can_delete_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_delete_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'delete_post') || (Phpfox::getUserParam('forum.can_stick_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'post_sticky')) || (Phpfox::getUserParam('forum.can_close_a_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'close_thread')) || (Phpfox::getUserParam('forum.can_merge_forum_threads') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'merge_thread'))) {
             $bCanManageThread = true;
         }
     } else {
         if (Phpfox::getService('pages')->isAdmin($aCallback['item'])) {
             $bCanEditThread = true;
             $bCanDeleteThread = true;
             $bCanStickThread = true;
             $bCanCloseThread = true;
             $bCanMergeThread = true;
             $bCanManageThread = true;
         }
     }
     $bCanPurchaseSponsor = false;
     if ((Phpfox::getUserParam('forum.can_purchase_sponsor') && $aThread['user_id'] == Phpfox::getUserId() || ($bCanCloseThread || $bCanStickThread) || Phpfox::getUserParam('forum.can_sponsor_thread')) && !defined('PHPFOX_IS_GROUP_VIEW')) {
         $bCanPurchaseSponsor = true;
     }
     $sCurrentThreadLink = $aCallback === null ? $this->url()->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'], $aThread['title_url']);
     if ($this->request()->get('view')) {
         Phpfox_Module::instance()->appendPageClass('single_mode');
     }
     if (Phpfox::isUser()) {
         $this->template()->menu('Reply', '#', 'onclick="$Core.box(\'forum.reply\', 800, \'id=' . $aThread['thread_id'] . '\'); return false;"');
     }
     $this->template()->setTitle($aThread['title'])->setBreadcrumb($aThread['title'], $this->url()->permalink('forum.thread', $aThread['thread_id'], $aThread['title']), true)->setMeta('description', $aThread['title'] . ' - ' . $aForum['name'])->setMeta('keywords', $this->template()->getKeywords($aThread['title']))->setPhrase(array('forum.provide_a_reply', 'forum.adding_your_reply', 'forum.are_you_sure', 'forum.post_successfully_deleted'))->setEditor()->setHeader('cache', array('jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'forum.js' => 'module_forum', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'feed.js' => 'module_feed'))->assign(array('aThread' => $aThread, 'aPost' => isset($aThread['post_starter']) ? $aThread['post_starter'] : '', 'iTotalPosts' => $iCnt, 'sCurrentThreadLink' => $sCurrentThreadLink, 'aCallback' => $aCallback, 'bCanManageThread' => $bCanManageThread, 'bCanEditThread' => $bCanEditThread, 'bCanDeleteThread' => $bCanDeleteThread, 'bCanStickThread' => $bCanStickThread, 'bCanCloseThread' => $bCanCloseThread, 'bCanMergeThread' => $bCanMergeThread, 'bCanPurchaseSponsor' => $bCanPurchaseSponsor, 'sPermaView' => $sPermaView, 'aPoll' => empty($aThread['poll']) ? false : $aThread['poll'], 'bIsViewingPoll' => true, 'bIsCustomPoll' => true, 'sMicroPropType' => 'CreativeWork'));
     $this->setParam('global_moderation', array('name' => 'forumpost', 'ajax' => 'forum.postModeration', 'menu' => array(array('phrase' => Phpfox::getPhrase('forum.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('forum.approve'), 'action' => 'approve'))));
     Phpfox::getLib('parse.output')->setEmbedParser(array('width' => 640, 'height' => 360));
     if ($this->request()->get('is_ajax_get')) {
         $this->template()->assign('isReplies', true);
         Phpfox_Module::instance()->getControllerTemplate();
         $content = ob_get_contents();
         ob_clean();
         return ['run' => "\$('.thread_replies .fa').remove();", 'html' => ['to' => '.tr_content', 'with' => $content]];
     }
 }
Exemple #9
0
 public function buildMenu()
 {
     $aFilterMenu = array(Phpfox::getPhrase('forum.forums') => '', Phpfox::getPhrase('forum.new_posts') => 'forum.search.view_new', Phpfox::getPhrase('forum.my_threads') => 'forum.search.view_my-thread', Phpfox::getPhrase('forum.subscribed_threads') => 'forum.search.view_subscribed');
     if (Phpfox::getUserParam('forum.can_approve_forum_thread')) {
         $aFilterMenu[] = true;
         $iPendingThreads = Forum_Service_Thread_Thread::instance()->getPendingThread();
         if ($iPendingThreads) {
             $aFilterMenu[Phpfox::getPhrase('forum.pending_threads') . ' <span class="pending">' . $iPendingThreads . '</span>'] = 'forum.search.view_pending-thread';
         }
         $iPendingPosts = Phpfox::getService('forum.post')->getPendingPost();
         if ($iPendingPosts) {
             $aFilterMenu[Phpfox::getPhrase('forum.pending_posts') . ' <span class="pending">' . $iPendingPosts . '</span>'] = 'forum.search.view_pending-post';
         }
     }
     Phpfox_Template::instance()->buildSectionMenu('forum', $aFilterMenu);
 }
Exemple #10
0
 public function processMerge()
 {
     Phpfox::isUser(true);
     $this->error(false);
     $aThread = Forum_Service_Thread_Thread::instance()->getActualThread($this->get('thread_id'));
     $bHasAccess = false;
     $mReturn = false;
     if ((int) $aThread['group_id'] > 0) {
         $aPage = Phpfox::getService('pages')->getForView($aThread['group_id']);
         if (isset($aPage['is_admin']) && $aPage['is_admin']) {
             $bHasAccess = true;
         }
     } else {
         if (Phpfox::getUserParam('forum.can_merge_forum_threads') || Phpfox::getService('forum.moderate')->hasAccess($this->get('forum_id'), 'merge_thread')) {
             $bHasAccess = true;
         }
     }
     if ($bHasAccess) {
         $mReturn = Phpfox::getService('forum.thread.process')->merge($this->get('thread_id'), $this->get('forum_id'), $this->get('url'));
     } else {
         Phpfox_Error::set(Phpfox::getPhrase('forum.not_allowed_to_merge_threads_from_this_specific_forum'));
     }
     if ($mReturn !== false) {
         Phpfox::addMessage(Phpfox::getPhrase('forum.threads_successfully_merged'));
         $this->call('window.location.href = \'' . $mReturn . '\';');
     } else {
         $aErrors = Phpfox_Error::get();
         $sErrors = '';
         foreach ($aErrors as $sError) {
             $sErrors .= '<div class="error_message">' . $sError . '</div>';
         }
         $this->html('#js_error_message', '' . $sErrors . '');
     }
 }
Exemple #11
0
 /**
  * Controller
  */
 public function process()
 {
     if (Phpfox::isMobile() && Phpfox_Module::instance()->getFullControllerName() == 'forum.forum' && !$this->request()->getInt('req2') && !in_array($this->request()->get('view'), array('subscribed', 'new', 'my-thread'))) {
         return Phpfox_Module::instance()->setController('forum.index');
     }
     Phpfox::getUserParam('forum.can_view_forum', true);
     $aParentModule = $this->getParam('aParentModule');
     $bIsSearch = $this->request()->get('search') ? true : false;
     $aCallback = $this->getParam('aCallback', null);
     $sView = $this->request()->get('view');
     $bShowPosts = false;
     $bIsTagSearch = false;
     $bIsModuleTagSearch = false;
     if ($this->request()->get('req2') == 'tag' && $this->request()->get('req3')) {
         $bIsSearch = true;
         $bIsTagSearch = true;
     }
     if ($this->request()->get('req2') == 'tag' && $this->request()->get('req5') && $this->request()->get('module')) {
         if ($aCallback = Phpfox::getService('group')->getGroup($this->request()->get('item'))) {
             $bIsSearch = true;
             $bIsTagSearch = true;
             $bIsModuleTagSearch = true;
             $aCallback['url_home'] = 'group.' . $aCallback['title_url'] . '.forum';
         }
     }
     $oSearch = Forum_Service_Forum::instance()->getSearchFilter($this->getParam('bIsSearchQuery', false), $this->request()->get('forum_id') ? $this->request()->get('forum_id') : $this->request()->getInt('req2'));
     if ($oSearch->isSearch() && $this->request()->getInt('req2') == 'search') {
         $aIds = [];
         $aForums = $this->request()->get('forum_id') ? Forum_Service_Forum::instance()->id($this->request()->get('forum_id'))->live()->getForums() : Forum_Service_Forum::instance()->live()->getForums();
         if ($this->request()->get('forum_id')) {
             $aIds[] = $this->request()->get('forum_id');
         }
         foreach ($aForums as $aForum) {
             $aIds[] = $aForum['forum_id'];
             $aChilds = (array) Forum_Service_Forum::instance()->id($aForum['forum_id'])->getChildren();
             foreach ($aChilds as $iId) {
                 $aIds[] = $iId;
             }
         }
         $oSearch->setCondition('AND ft.forum_id IN(' . implode(',', $aIds) . ')');
     }
     define('PHPFOX_PAGER_FORCE_COUNT', true);
     $iPage = $this->request()->getInt('page');
     $iPageSize = $oSearch->getDisplay();
     $sViewId = 'ft.view_id = 0';
     if ($aCallback === null) {
         $iForumId = $this->request()->getInt('req2');
         if (Phpfox::getUserParam('forum.can_approve_forum_thread') || Phpfox::getService('forum.moderate')->hasAccess($iForumId, 'approve_thread')) {
             $sViewId = 'ft.view_id >= 0';
         }
     }
     if ($aParentModule == null) {
         $iForumId = $this->request()->getInt('req2');
         $aForums = Forum_Service_Forum::instance()->live()->id($iForumId)->getForums();
         // $aForums = array();
         $aForum = Forum_Service_Forum::instance()->id($iForumId)->getForum();
         $this->template()->assign('isSubForumList', true);
     } else {
         $aForum = array();
         $aForums = array();
     }
     if (!$bIsSearch && $this->request()->get('view') != 'pending-post') {
         if ($aParentModule === null) {
             if (!isset($aForum['forum_id']) && empty($sView)) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_forum'));
             }
             if (isset($aForum['forum_id'])) {
                 $this->setParam('iActiveForumId', $aForum['forum_id']);
             }
             if (!empty($sView)) {
                 switch ($sView) {
                     case 'my-thread':
                         $oSearch->setCondition('AND ft.user_id = ' . Phpfox::getUserId());
                         // $bShowPosts = true;
                         break;
                     case 'pending-thread':
                         if (Phpfox::getUserParam('forum.can_approve_forum_thread')) {
                             $sViewId = 'ft.view_id = 1';
                         }
                         break;
                     default:
                         break;
                 }
                 $oSearch->setCondition('AND ft.group_id = 0 AND ' . $sViewId . ' AND ft.is_announcement = 0');
                 $bIsSearch = true;
             } else {
                 $oSearch->setCondition('AND ft.forum_id = ' . $aForum['forum_id'] . ' AND ft.group_id = 0 AND ' . $sViewId . ' AND ft.is_announcement = 0');
             }
         } else {
             $oSearch->setCondition('AND ft.forum_id = 0 AND ft.group_id = ' . $aParentModule['item_id'] . ' AND ' . $sViewId . ' AND ft.is_announcement = 0');
         }
         // get the forums that we cant access
         $aForbiddenForums = Forum_Service_Forum::instance()->getForbiddenForums();
         if (!empty($aForbiddenForums)) {
             $oSearch->setCondition(' AND ft.forum_id NOT IN (' . implode(',', $aForbiddenForums) . ')');
         }
     }
     if ($oSearch->get('result') || $this->request()->get('view') == 'pending-post') {
         if ($this->request()->get('view') == 'pending-post') {
             $bIsSearch = true;
             $bForceResult = true;
             $oSearch->setCondition('AND fp.view_id = 1');
         }
         list($iCnt, $aThreads) = Phpfox::getService('forum.post')->callback($aCallback)->get($oSearch->getConditions(), $oSearch->getSort(), $oSearch->getPage(), $iPageSize);
     } else {
         if (($iDaysPrune = $oSearch->get('days_prune')) && $iDaysPrune != '-1') {
             $oSearch->setCondition('AND ft.time_stamp >= ' . (PHPFOX_TIME - $iDaysPrune * 86400));
         }
         if ($bIsTagSearch === true) {
             if ($bIsModuleTagSearch) {
                 $oSearch->setCondition("AND ft.group_id = " . (int) $aCallback['group_id'] . " AND tag.tag_url = '" . Phpfox_Database::instance()->escape($this->request()->get('req5')) . "'");
             } else {
                 $oSearch->setCondition("AND ft.group_id = 0 AND tag.tag_url = '" . Phpfox_Database::instance()->escape($this->request()->get('req3')) . "'");
             }
         }
         list($iCnt, $aThreads) = Forum_Service_Thread_Thread::instance()->isSearch($bIsSearch)->isTagSearch($bIsTagSearch)->isNewSearch($sView == 'new' ? true : false)->isSubscribeSearch($sView == 'subscribed' ? true : false)->isModuleSearch($bIsModuleTagSearch)->get($oSearch->getConditions(), 'ft.order_id DESC, ' . $oSearch->getSort(), $oSearch->getPage(), $iPageSize);
     }
     $aAccess = Forum_Service_Forum::instance()->getUserGroupAccess($iForumId, Phpfox::getUserBy('user_group_id'));
     Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt));
     $this->template()->assign(array('aThreads' => $aThreads, 'iSearchId' => $this->request()->getInt('search-id'), 'aCallback' => $aParentModule, 'sView' => $sView, 'aPermissions' => $aAccess))->setHeader('cache', array('forum.css' => 'style_css', 'pager.css' => 'style_css', 'selector.js' => 'static_script'));
     if ($bIsSearch && !isset($aForum['forum_id'])) {
         if (is_array($aCallback)) {
             $this->template()->setBreadcrumb('Pages', $this->url()->makeUrl('pages'))->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
         } else {
             $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.forum'), $this->url()->makeUrl('forum'));
         }
         if ($bIsTagSearch) {
             $aTag = Tag_Service_Tag::instance()->getTagInfo('forum', $bIsModuleTagSearch ? $this->request()->get('req5') : $this->request()->get('req3'));
             if (!empty($aTag['tag_text'])) {
                 if ($bIsModuleTagSearch) {
                     $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.threads_tagged_with') . ': ' . $aTag['tag_text'], $this->url()->makeUrl('forum.tag.module_group.item_' . $this->request()->get('item') . '.' . $this->request()->get('req5')), true);
                 } else {
                     $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.tags'), $this->url()->makeUrl('forum.tag'))->setBreadcrumb(Phpfox::getPhrase('forum.threads_tagged_with') . ': ' . $aTag['tag_text'], $this->url()->makeUrl('forum.tag.' . $this->request()->get('req3')), true);
                 }
             }
         } else {
             if (is_array($aCallback)) {
                 // $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.search'), $this->url()->makeUrl('forum.search', array('module' => 'pages', 'item' => $aCallback['group_id'])));
             } else {
                 // $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.search'), $this->url()->makeUrl('forum.search'));
             }
         }
         $this->template()->assign(array('bIsSearch' => true, 'bResult' => isset($bForceResult) ? true : $oSearch->get('result'), 'aForumResults' => $oSearch->get('forum'), 'bIsTagSearch' => $bIsTagSearch));
     } else {
         if (Phpfox::getParam('forum.rss_feed_on_each_forum')) {
             if ($aParentModule === null) {
                 $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('forum.forum') . ': ' . $aForum['name'] . '" href="' . $this->url()->makeUrl('forum', array('rss', 'forum' => $aForum['forum_id'])) . '" />');
             } else {
                 $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('forum.group_forum') . ': ' . $aCallback['title'] . '" href="' . $this->url()->makeUrl('forum', array('rss', 'group' => $aCallback['group_id'])) . '" />');
             }
         }
         if ($aCallback === null && $aParentModule === null) {
             if (!$aForum['is_closed'] && Phpfox::getUserParam('forum.can_add_new_thread') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'add_thread')) {
                 $this->template()->setMenu(['forum.forum' => ['menu_id' => null, 'module' => 'forum', 'url' => $this->url()->makeUrl('forum.post.thread', ['id' => $aForum['forum_id']]), 'var_name' => 'new_thread']]);
             }
         } else {
             if ($aParentModule !== null) {
                 $this->template()->setMenu(['forum.forum' => ['menu_id' => null, 'module' => 'forum', 'url' => $this->url()->makeUrl('forum.post.thread', ['module' => $aParentModule['module_id'], 'item' => $aParentModule['item_id']]), 'var_name' => 'new_thread']]);
                 // d($aParentModule); exit;
             }
         }
         /*
         {if !$aForumData.is_closed && Phpfox::getUserParam('forum.can_add_new_thread') || Phpfox::getService('forum.moderate')->hasAccess('' . $aForumData.forum_id . '', 'add_thread')}
         <div class="sub_menu_bar_main"><a href="{url link='forum.post.thread' id=$aForumData.forum_id}">{phrase var='forum.new_thread'}</a></div>
         		{/if}
         	{else}
         		<div class="sub_menu_bar_main"><a href="{url link='forum.post.thread' module=$aCallback.module_id item=$aCallback.item_id}">{phrase var='forum.new_thread'}</a></div>
         	{/if}
         */
         if ($aParentModule === null) {
             if (!Forum_Service_Forum::instance()->hasAccess($aForum['forum_id'], 'can_view_forum')) {
                 $this->url()->send('forum');
             }
             $this->template()->setTitle(Phpfox_Locale::instance()->convert($aForum['name']))->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb(Phpfox_Locale::instance()->convert($aForum['name']), $this->url()->permalink('forum', $aForum['forum_id'], $aForum['name']), true)->assign(array('bDisplayThreads' => true, 'aAnnouncements' => Forum_Service_Thread_Thread::instance()->getAnnoucements($iForumId), 'aForums' => $aForums, 'aForumData' => $aForum, 'bHasCategory' => false, 'bIsSubForum' => true, 'bIsSearch' => false, 'bIsTagSearch' => false));
         } else {
             $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.forum'), $this->url()->makeUrl(''))->setTitle(Phpfox::getPhrase('forum.discussions'))->assign(array('bDisplayThreads' => true, 'bHasCategory' => false, 'bIsSubForum' => true, 'bIsSearch' => false, 'bIsTagSearch' => false, 'aAnnouncements' => Forum_Service_Thread_Thread::instance()->getAnnoucements(null, isset($aParentModule['item_id']) ? $aParentModule['item_id'] : 1)));
         }
     }
     if ($bIsSearch && (isset($bForceResult) || $oSearch->get('result'))) {
         if (isset($bForceResult)) {
             $this->setParam('global_moderation', array('name' => 'forumpost', 'ajax' => 'forum.postModeration', 'menu' => array(array('phrase' => Phpfox::getPhrase('forum.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('forum.approve'), 'action' => 'approve'))));
         } else {
             $this->template()->assign('bIsPostSearch', true);
         }
     } else {
         $this->setParam('global_moderation', array('name' => 'forum', 'ajax' => 'forum.moderation', 'menu' => array(array('phrase' => Phpfox::getPhrase('forum.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('forum.approve'), 'action' => 'approve'))));
     }
 }
Exemple #12
0
 public function approve($iPostId)
 {
     $aPost = $this->database()->select('*')->from(Phpfox::getT('forum_post'))->where('post_id = ' . (int) $iPostId)->execute('getSlaveRow');
     if (!isset($aPost['post_id'])) {
         return false;
     }
     $aThread = Forum_Service_Thread_Thread::instance()->getActualThread($aPost['thread_id']);
     $this->database()->update(Phpfox::getT('forum_post'), array('view_id' => '0'), 'post_id = ' . (int) $iPostId);
     foreach (Phpfox::getService('forum')->id($aThread['forum_id'])->getParents() as $iForumid) {
         $this->database()->update(Phpfox::getT('forum'), array('thread_id' => $aPost['thread_id'], 'post_id' => $iPostId, 'last_user_id' => $aPost['user_id']), 'forum_id = ' . $iForumid);
         Phpfox::getService('forum.process')->updateCounter($iForumid, 'total_post');
     }
     $this->database()->update(Phpfox::getT('forum_thread'), array('total_post' => array('= total_post +', 1), 'post_id' => $iPostId, 'time_update' => PHPFOX_TIME, 'last_user_id' => $aPost['user_id']), 'thread_id = ' . (int) $aPost['thread_id']);
     Phpfox::getService('user.field.process')->updateCounter($aPost['user_id'], 'total_post');
     Phpfox::getService('user.activity')->update($aPost['user_id'], 'forum');
     Phpfox::getService('forum.subscribe')->sendEmails($aPost['thread_id'], $iPostId);
     ($sPlugin = Phpfox_Plugin::get('forum.service_post_process_approve__1')) ? eval($sPlugin) : false;
     Phpfox::isModule('feed') && !defined('PHPFOX_SKIP_FEED_ENTRY') ? Phpfox::getService('feed.process')->add('forum_post', $iPostId, 0, 0, 0, $aPost['user_id']) : null;
     $sCurrentUrl = Phpfox_Url::instance()->permalink('forum.thread', $aThread['thread_id'], $aThread['title'], false, null, array('view' => $aPost['post_id']));
     Phpfox::getLib('mail')->to($aPost['user_id'])->subject(array('forum.forum_post_approved_on_site_title', array('site_title' => Phpfox::getParam('core.site_title'))))->message(array('forum.your_post_that_is_part_of_the_forum_thread_title_on_site_title', array('thread_title' => $aThread['title'], 'site_title' => Phpfox::getParam('core.site_title'), 'link' => $sCurrentUrl)))->send();
     return true;
 }
Exemple #13
0
 public function markRead($iForumId, $iGroupId = 0)
 {
     list($iCnt, $aThreads) = Forum_Service_Thread_Thread::instance()->get(array('ft.forum_id = ' . (int) $iForumId . ' AND ft.group_id = ' . (int) $iGroupId . ' AND ft.view_id = 0'));
     foreach ($aThreads as $aThread) {
         if ($iGroupId === 0) {
             Phpfox::getService('forum.process')->updateTrack($iForumId);
         }
         Phpfox::getService('forum.thread.process')->updateTrack($aThread['thread_id']);
     }
     return true;
 }