// // ------------------------------------------------------------------------ // // 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: phppp (D.J., infomax@gmail.com) // // URL: http://xoopsforge.com, http://xoops.org.cn // // Project: Article Project // // ------------------------------------------------------------------------ // include 'header.php'; // To enable image auto-resize by js $xoops_module_header .= ''; $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_obj =& $forum_handler->get($forum_id); $forums[$forum_id] =& $forum_obj; $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)); } $join = null; 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)); // following is for "unread" -- not finished /* if(empty($xoopsModuleConfig["read_mode"])){ }elseif($xoopsModuleConfig["read_mode"] ==2){ $join = ' LEFT JOIN ' . $this->db->prefix('bb_reads_topic') . ' r ON r.read_item = p.topic_id'; $criteria_type_post = new CriteriaCompo(new Criteria("p.post_id", "r.post_id", ">")); $criteria_type_post->add(new Criteria("r.read_id", "NULL", "IS"), "OR"); $criteria_type_post->add(new Criteria("p.approved", 1)); $criteria_type_count =& $criteria_type_post; }elseif($xoopsModuleConfig["read_mode"] == 1){ $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($criteria_post, $post_perpage, $start/*, $join*/); $poster_array = array(); if(count($posts)>0) foreach (array_keys($posts) as $id) { $poster_array[$posts[$id]->getVar('uid')] = 1; } $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($xoopsTpl->xoops_canUpdateFromFile() && is_dir(XOOPS_THEME_PATH."/".$xoopsConfig['theme_set']."/templates/".$xoopsModule->getVar("dirname"))){ $xoopsTpl->assign('newbb_template_path', XOOPS_THEME_PATH."/".$xoopsConfig['theme_set']."/templates/".$xoopsModule->getVar("dirname")); }else{ $xoopsTpl->assign('newbb_template_path', XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar("dirname")."/templates"); } if(!empty($forum_id)){ if (!$forum_handler->getPermission($forum_obj, "view")){ redirect_header("index.php", 2, _MD_NORIGHTTOACCESS); exit(); } if($forum_obj->getVar('parent_forum')){ $parent_forum_obj =& $forum_handler->get($forum_obj->getVar('parent_forum'), array("forum_name")); $parentforum = array("id"=>$forum_obj->getVar('parent_forum'), "name"=>$parent_forum_obj->getVar("forum_name")); unset($parent_forum_obj); $xoopsTpl->assign_by_ref("parentforum", $parentforum); } $xoopsTpl->assign('forum_name', $forum_obj->getVar('forum_name')); $xoopsTpl->assign('forum_moderators', $forum_obj->disp_forumModerators()); $xoops_pagetitle = $forum_obj->getVar('forum_name'). ' - ' ._MD_VIEWALLPOSTS. ' [' . $xoopsModule->getVar('name'). ']'; $xoopsTpl->assign("forum_id", $forum_obj->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'); if ( $posticon = $post->getVar('icon') ){ $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 || $post->checkIdentity()) { $post_text = $post->getVar('post_text'); $post_attachment = $post->displayAttachment(); } elseif ($xoopsModuleConfig['enable_karma'] && $post->getVar('post_karma') > $user_karma) { $post_text = "