function ListViewIndexBarReadPosting(&$_posting, $_prev_posting_id, $_next_posting_id)
 {
     $this->Menu();
     if (!$_posting) {
         $this->add_separator();
         return;
     }
     $url = new FreechURL();
     $url->set_var('action', 'read');
     $url->set_var('msg_id', 1);
     $url->set_var('forum_id', $_posting->get_forum_id());
     // "Previous/Next Posting" buttons.
     if ($_prev_posting_id) {
         $url->set_var('msg_id', $_prev_posting_id);
         $url->set_label('<<');
         $this->add_link($url);
     } else {
         $this->add_text('<<');
     }
     $this->add_text(_('Message'));
     if ($_next_posting_id) {
         $url = clone $url;
         $url->set_var('msg_id', $_next_posting_id);
         $url->set_label('>>');
         $this->add_link($url);
     } else {
         $this->add_text('>>');
     }
 }
 function ThreadViewIndexBarReadPosting(&$_posting, $_prev_posting_id, $_next_posting_id, $_prev_thread_id, $_next_thread_id)
 {
     $this->Menu();
     if (!$_posting) {
         $this->add_separator();
         return;
     }
     $url = new FreechURL();
     $url->set_var('action', 'read');
     $url->set_var('msg_id', 1);
     $url->set_var('forum_id', $_posting->get_forum_id());
     // "Previous/Next Posting" buttons.
     if ($_prev_posting_id) {
         $url->set_var('msg_id', $_prev_posting_id);
         $url->set_label('<<');
         $this->add_link($url);
     } else {
         $this->add_text('<<');
     }
     $this->add_text(_('Message'));
     if ($_next_posting_id) {
         $url = clone $url;
         $url->set_var('msg_id', $_next_posting_id);
         $url->set_label('>>');
         $this->add_link($url);
     } else {
         $this->add_text('>>');
     }
     // "Previous Thread" button.
     $this->add_separator();
     if (cfg('thread_arrow_reverse')) {
         $prev_id = $_next_thread_id;
     } else {
         $prev_id = $_prev_thread_id;
     }
     if ($prev_id) {
         $url = clone $url;
         $url->set_var('msg_id', $prev_id);
         $url->set_label('<<');
         $this->add_link($url);
     } else {
         $this->add_text('<<');
     }
     // "Next Thread" button.
     $this->add_text(_('Thread'));
     $url = clone $url;
     if (cfg('thread_arrow_reverse')) {
         $next_id = $_prev_thread_id;
     } else {
         $next_id = $_next_thread_id;
     }
     if ($next_id) {
         $url = clone $url;
         $url->set_var('msg_id', $next_id);
         $url->set_label('>>');
         $this->add_link($url);
     } else {
         $this->add_text('>>');
     }
 }
Exemplo n.º 3
0
 function show_posting(&$_posting)
 {
     trace('enter');
     $user = $this->api->user();
     $group = $this->api->group();
     $db = $this->forumdb;
     $prev_posting_id = $db->get_prev_posting_id_in_thread($_posting);
     $next_posting_id = $db->get_next_posting_id_in_thread($_posting);
     trace('previous/next postings found');
     $prev_thread_id = $db->get_prev_thread_id($_posting);
     $next_thread_id = $db->get_next_thread_id($_posting);
     trace('previous/next threads found');
     $posting_uid = $_posting ? $_posting->get_user_id() : -1;
     $may_write = $group->may('write');
     $may_edit = $may_write && cfg('postings_editable') && !$user->is_anonymous() && $user->get_id() === $posting_uid && $_posting->is_editable();
     $showthread = $_posting && $_posting->has_thread() && $_COOKIE[thread] != 'hide';
     include dirname(__FILE__) . '/indexbar_read_posting.class.php';
     $indexbar = new ThreadViewIndexBarReadPosting($_posting, $prev_posting_id, $next_posting_id, $prev_thread_id, $next_thread_id);
     trace('indexbar built');
     // Add the 'respond' button.
     if ($may_write) {
         $url = $_posting->get_respond_url();
         if ($_posting->is_active() && $_posting->get_allow_answer()) {
             $this->api->links('page')->add_link($url, 250);
         } else {
             $this->api->links('page')->add_text($url->get_label(), 200);
         }
     }
     // Add the 'edit' button.
     if ($may_edit) {
         $url = $_posting->get_edit_url();
         $this->api->links('page')->add_link($url, 300);
     }
     // Add 'show/hide thread' buttons.
     $url = new FreechURL();
     $url->set_var('action', 'read');
     $url->set_var('forum_id', $_posting->get_forum_id());
     $url->set_var('msg_id', $_posting->get_id());
     $url->set_var('refer_to', $_SERVER['REQUEST_URI']);
     if ($_posting->has_thread()) {
         if ($_COOKIE[thread] === 'hide') {
             $url->set_var('showthread', 1);
             $url->set_label(_('Show Thread'));
         } else {
             $url->set_var('showthread', -1);
             $url->set_label(_('Hide Thread'));
         }
         $this->api->links('view')->add_link($url);
     }
     trace('links updated');
     // Load the thread.
     $this->clear_all_assign();
     $this->assign_by_ref('showthread', $showthread);
     if ($showthread) {
         trace('loading thread');
         $state = new ThreadState(THREAD_STATE_UNFOLDED, '');
         $func = array(&$this, '_format_posting');
         $thread_ids = array($_posting->get_thread_id());
         $threads = $this->forumdb->get_threads_from_id($thread_ids, TRUE);
         trace('thread loaded');
         $threads[0]->foreach_posting($func);
         trace('thread formatted');
         $this->assign('n_rows', 1);
         $this->assign_by_ref('threads', $threads);
     }
     // Render.
     $this->assign_by_ref('indexbar', $indexbar);
     $this->assign_by_ref('posting', $_posting);
     $this->assign('max_usernamelength', cfg('max_usernamelength'));
     $this->assign('max_subjectlength', cfg('max_subjectlength'));
     $this->render_php(dirname(__FILE__) . '/threadview_read_posting.php.tmpl');
     $this->api->set_title($_posting->get_subject());
     trace('leave');
 }
Exemplo n.º 4
0
 function show_posting(&$_posting)
 {
     $user = $this->api->user();
     $group = $this->api->group();
     $db = $this->forumdb;
     $msg_uid = $_posting ? $_posting->get_user_id() : -1;
     $showlist = $_posting && $_COOKIE['thread'] != 'hide';
     //FIXME: rename "thread" cookie
     $may_write = $group->may('write');
     $may_edit = $may_write && cfg('postings_editable') && !$user->is_anonymous() && $user->get_id() === $msg_uid && $_posting->is_editable();
     // Add the 'respond' button.
     if ($may_write) {
         $url = $_posting->get_respond_url();
         if ($_posting->is_active() && $_posting->get_allow_answer()) {
             $this->api->links('page')->add_link($url, 250);
         } else {
             $this->api->links('page')->add_text($url->get_label(), 200);
         }
     }
     // Add the 'edit' button.
     if ($may_edit) {
         $url = $_posting->get_edit_url();
         $this->api->links('page')->add_link($url, 300);
     }
     // Add 'show/hide thread' buttons.
     $url = new FreechURL();
     $url->set_var('action', 'read');
     $url->set_var('forum_id', $_posting->get_forum_id());
     $url->set_var('msg_id', $_posting->get_id());
     $url->set_var('refer_to', $_SERVER['REQUEST_URI']);
     if ($_posting->has_thread()) {
         if ($_COOKIE[thread] === 'hide') {
             $url->set_var('showthread', 1);
             $url->set_label(_('Show Posting List'));
         } else {
             $url->set_var('showthread', -1);
             $url->set_label(_('Hide Posting List'));
         }
         $this->api->links('view')->add_link($url);
     }
     // Create the indexbar.
     if (cfg('posting_arrow_reverse')) {
         $prev_posting_id = $db->get_next_posting_id_in_forum($_posting);
         $next_posting_id = $db->get_prev_posting_id_in_forum($_posting);
     } else {
         $prev_posting_id = $db->get_prev_posting_id_in_forum($_posting);
         $next_posting_id = $db->get_next_posting_id_in_forum($_posting);
     }
     include dirname(__FILE__) . '/indexbar_read_posting.class.php';
     $indexbar = new ListViewIndexBarReadPosting($_posting, $prev_posting_id, $next_posting_id);
     $this->clear_all_assign();
     $this->assign_by_ref('showlist', $showlist);
     if ($showlist) {
         $current_id = (int) $_GET['msg_id'];
         $func = array(&$this, '_append_posting');
         $_posting->set_selected($_posting->get_id() == $current_id);
         $this->posting_map[$_posting->get_id()] = $_posting;
         $db->foreach_prev_posting($_posting, cfg('epp') / 2, $func);
         $db->foreach_next_posting($_posting, cfg('epp') / 2, $func);
         krsort($this->posting_map);
         $this->assign('n_rows', count($this->posting_map));
         $this->assign('postings', array_values($this->posting_map));
     }
     $this->assign_by_ref('indexbar', $indexbar);
     $this->assign_by_ref('posting', $_posting);
     $this->assign('max_usernamelength', cfg('max_usernamelength'));
     $this->assign('max_subjectlength', cfg('max_subjectlength'));
     $this->render_php(dirname(__FILE__) . '/listview_read_posting.php.tmpl');
     $this->api->set_title($_posting->get_subject());
 }