// // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // // Author: Kazumi Ono (AKA onokazu) // // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // // Project: The XOOPS Project // // ------------------------------------------------------------------------- // include 'header.php'; $start = !empty($_GET['start']) ? intval($_GET['start']) : 0; $forum_id = !empty($_GET['forum']) ? intval($_GET['forum']) : 0; $order = isset($_GET['order'])?$_GET['order']:"DESC"; $uid = !empty($_GET['uid']) ? intval($_GET['uid']) : 0; $type = (!empty($_GET['type']) && in_array($_GET['type'], array("active", "pending", "deleted", "new")))? $_GET['type'] : ""; $mode = !empty($_GET['mode']) ? intval($_GET['mode']) : 0; $mode = (!empty($type) && in_array($type, array("active", "pending", "deleted")) )?2:$mode; $forum_handler =& xoops_getmodulehandler('forum', 'newbb'); $post_handler =& xoops_getmodulehandler('post', 'newbb'); $isadmin = newbb_isAdmin($forum_id); /* Only admin has access to admin mode */ if(!$isadmin){ $type = in_array($type, array("active", "pending", "deleted"))?"":$type; $mode = 0; } if($mode){ $_GET['viewmode'] = "flat"; } if(empty($forum_id)){ $forums = $forum_handler->getForums(0, "view"); $access_forums = array_keys($forums); } else{ $forum =& $forum_handler->get($forum_id); $forums[$forum_id] =& $forum; $access_forums = array($forum_id); } $post_perpage = $xoopsModuleConfig['posts_per_page']; $criteria_count = new CriteriaCompo(new Criteria("forum_id", "(".implode(",",$access_forums).")", "IN")); $criteria_post = new CriteriaCompo(new Criteria("p.forum_id", "(".implode(",",$access_forums).")", "IN")); $criteria_post->setSort("p.post_time"); $criteria_post->setOrder($order); if(!empty($uid)){ $criteria_count->add(new Criteria("uid", $uid)); $criteria_post->add(new Criteria("p.uid", $uid)); } switch($type){ case "pending": $criteria_type_count = new Criteria("approved", 0); $criteria_type_post = new Criteria("p.approved", 0); break; case "deleted": $criteria_type_count = new Criteria("approved", -1); $criteria_type_post = new Criteria("p.approved", -1); break; case "new": $criteria_type_count = new CriteriaCompo(new Criteria("post_time", intval($last_visit), ">")); $criteria_type_post = new CriteriaCompo(new Criteria("p.post_time", intval($last_visit), ">")); $criteria_type_count->add(new Criteria("approved", 1)); $criteria_type_post->add(new Criteria("p.approved", 1)); break; default: $criteria_type_count = new Criteria("approved", 1); $criteria_type_post = new Criteria("p.approved", 1); break; } $criteria_count->add($criteria_type_count); $criteria_post->add($criteria_type_post); $karma_handler =& xoops_getmodulehandler('karma', 'newbb'); $user_karma = $karma_handler->getUserKarma(); $valid_modes = array("flat", "compact"); $viewmode_cookie = newbb_getcookie("V"); if(isset($_GET['viewmode'])&&$_GET['viewmode']=="compact") newbb_setcookie("V", "compact", $forumCookie['expire']); $viewmode = isset($_GET['viewmode'])? $_GET['viewmode']: ( !empty($viewmode_cookie)? $viewmode_cookie: ( is_object($xoopsUser)? $xoopsUser->getVar('umode'): $valid_modes[$xoopsModuleConfig['view_mode']-1] ) ); $viewmode = in_array($viewmode, $valid_modes)?$viewmode:"flat"; $postCount = $post_handler->getPostCount($criteria_count); $posts = $post_handler->getPostsByLimit($post_perpage, $start, $criteria_post); $poster_array = array(); $topic_lastread = newbb_getcookie('LT',true); if(count($posts)>0) foreach (array_keys($posts) as $id) { $poster_array[$posts[$id]->getVar('uid')] = 1; $topic_lastread[$posts[$id]->getVar('topic_id')] = time(); } newbb_setcookie("LT", $topic_lastread); $xoops_pagetitle = $xoopsModule->getVar('name'). ' - ' ._MD_VIEWALLPOSTS; $xoopsOption['xoops_pagetitle']= $xoops_pagetitle; $xoopsOption['xoops_module_header']= $xoops_module_header; $xoopsOption['template_main'] = 'newbb_viewpost.html'; include XOOPS_ROOT_PATH."/header.php"; if(!empty($forum_id)){ if (!$forum_handler->getPermission($forum, "view")){ redirect_header("index.php", 2, _MD_NORIGHTTOACCESS); exit(); } if($forum->isSubforum()) { $q = "select forum_name from ".$xoopsDB->prefix('bb_forums')." WHERE forum_id=".$forum->getVar('parent_forum'); $row = $xoopsDB->fetchArray($xoopsDB->query($q)); $xoopsTpl->assign(array('parent_forum' => $forum->getVar('parent_forum'), 'parent_name' => $myts->htmlSpecialChars($row['forum_name']))); } $xoopsTpl->assign('forum_name', $forum->getVar('forum_name')); $xoopsTpl->assign('forum_moderators', $forum->disp_forumModerators()); $forum_lastview = newbb_getcookie('LF',true); $forum_lastview[$forum_id] = time(); newbb_setcookie("LF", $forum_lastview); $xoops_pagetitle = $xoopsModule->getVar('name'). ' - ' .$forum->getVar('forum_name'). ' - ' ._MD_VIEWALLPOSTS; $xoopsTpl->assign("forum_id", $forum->getVar('forum_id')); if(!empty($xoopsModuleConfig['rss_enable'])){ $xoops_module_header .= ''; } }elseif(!empty($xoopsModuleConfig['rss_enable'])){ $xoops_module_header .= ''; } $xoopsTpl->assign('xoops_module_header', $xoops_module_header); $xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle); $userid_array=array(); if(count($poster_array)>0){ $member_handler =& xoops_gethandler('member'); $userid_array = array_keys($poster_array); $user_criteria = "(".implode(",",$userid_array).")"; $users = $member_handler->getUsers( new Criteria('uid', $user_criteria, 'IN'), true); }else{ $user_criteria = ''; $users = null; } if ($xoopsModuleConfig['wol_enabled']){ $online = array(); if(!empty($user_criteria)){ $online_handler =& xoops_getmodulehandler('online', 'newbb'); $online_handler->init($forum_id); $online_full = $online_handler->getAll(new Criteria('online_uid', $user_criteria, 'IN')); if(is_array($online_full)&&count($online_full)>0){ foreach ($online_full as $thisonline) { if ($thisonline['online_uid'] > 0) $online[$thisonline['online_uid']] = 1; } } } } if($xoopsModuleConfig['groupbar_enabled']){ $groups_disp = array(); $groups =& $member_handler->getGroups(); $count = count($groups); for ($i = 0; $i < $count; $i++) { $groups_disp[$groups[$i]->getVar('groupid')] = $groups[$i]->getVar('name'); } unset($groups); } $viewtopic_users = array(); if(count($userid_array)>0){ $user_handler =& xoops_getmodulehandler('user', 'newbb'); $user_handler->setUsers($users); $user_handler->setGroups($groups_disp); $user_handler->setStatus($online); foreach($userid_array as $userid){ $viewtopic_users[$userid] =& $user_handler->get($userid); } } unset($users); unset($groups_disp); $pn =0; $topic_handler = &xoops_getmodulehandler('topic', 'newbb'); static $suspension = array(); foreach(array_keys($posts) as $id){ $pn++; $post =& $posts[$id]; $post_title = $post->getVar('subject'); $posticon = $post->getVar('icon'); if (!empty($posticon) && is_file(XOOPS_ROOT_PATH . '/images/subject/'.$posticon) ){ $post_image = ''; }else{ $post_image = ''; } if($post->getVar('uid')>0 && isset($viewtopic_users[$post->getVar('uid')])) { $poster = $viewtopic_users[$post->getVar('uid')]; } else $poster= array( 'uid' => 0, 'name' => $post->getVar('poster_name')?$post->getVar('poster_name'):$myts->HtmlSpecialChars($xoopsConfig['anonymous']), 'link' => $post->getVar('poster_name')?$post->getVar('poster_name'):$myts->HtmlSpecialChars($xoopsConfig['anonymous']) ); if ($isadmin or $post->checkIdentity()) { $post_text = $post->getVar('post_text'); $post_attachment = $post->displayAttachment(); } elseif ($xoopsModuleConfig['enable_karma'] && $post->getVar('post_karma') > $user_karma) { $post_text = "