From d968b4f315685c3d64feaedf806ae2d41a92f8be Mon Sep 17 00:00:00 2001 From: mcfly Date: Tue, 2 Dec 2008 21:34:18 +0000 Subject: [PATCH] More forum progress --- e107_plugins/forum/e_url/thread.php | 18 +- e107_plugins/forum/forum_class.php | 51 ++-- e107_plugins/forum/forum_post.php | 8 +- e107_plugins/forum/forum_shortcodes.php | 11 +- e107_plugins/forum/forum_viewtopic.php | 376 +++++++++++------------- e107_plugins/forum/plugin.xml | 4 +- e107_plugins/forum/viewforum.php | 52 ++-- 7 files changed, 256 insertions(+), 264 deletions(-) diff --git a/e107_plugins/forum/e_url/thread.php b/e107_plugins/forum/e_url/thread.php index 544e0b3d0..760048032 100644 --- a/e107_plugins/forum/e_url/thread.php +++ b/e107_plugins/forum/e_url/thread.php @@ -1,5 +1,5 @@ fieldTypes['forum']['forum_lastpost_user'] = 'int'; -// print_a($this->permList); +// var_dump($this->permList); } function loadPermList() @@ -103,6 +103,7 @@ class e107forum } } } + //var_dump($this->permList); } @@ -144,7 +145,7 @@ class e107forum $forumInfo['forum_lastpost_user_anon'] = $postInfo['post_anon_name']; } $threadInfo['thread_lastpost'] = $postInfo['post_datestamp']; - $threadInfo['thread_total_replies'] = 'thread-total_replies + 1'; + $threadInfo['thread_total_replies'] = 'thread_total_replies + 1'; $threadInfo['WHERE'] = 'thread_id = '.$postInfo['post_thread']; $threadInfo['_FIELD_TYPES'] = $this->fieldTypes['forum_thread']; @@ -166,7 +167,7 @@ class e107forum $forumInfo['forum_lastpost_user_anon'] = $postInfo['post_anon_name']; } - //If we updated the thread, then we assume it was a reply, otherwise we've added a reply only.' + //If we update the thread, then we assume it was a reply, otherwise we've added a reply only. $forumInfo['_FIELD_TYPES'] = $this->fieldTypes['forum']; if($updateThread) { @@ -190,7 +191,7 @@ class e107forum VALUES ('.USERID.', 1) ON DUPLICATE KEY UPDATE user_plugin_forum_posts = user_plugin_forum_posts + 1 '; - $result = $e107->sql->db_Select_gen($qry, true); + $result = $e107->sql->db_Select_gen($qry); } } @@ -236,7 +237,7 @@ class e107forum FROM `#forum_thread` WHERE thread_id = '.$id; } - if($e107->sql->db_Select_gen($qry, true)) + if($e107->sql->db_Select_gen($qry)) { $tmp = $e107->sql->db_Fetch(MYSQL_ASSOC); if($tmp) @@ -268,7 +269,7 @@ class e107forum ORDER BY p.post_datestamp ASC LIMIT {$start}, {$num} "; - if($e107->sql->db_Select_gen($qry, true)) + if($e107->sql->db_Select_gen($qry)) { $ret = array(); while($row = $e107->sql->db_Fetch(MYSQL_ASSOC)) @@ -386,18 +387,22 @@ class e107forum $u_new .= USERVIEWED; $t = array_unique(explode('.',$u_new)); // Filter duplicates $u_new = implode('.',$t); - $sql->db_Update("user", "user_viewed='{$u_new}' WHERE user_id=".USERID); + $sql->db_Update('user', "user_viewed='{$u_new}' WHERE user_id=".USERID); header("location:".e_SELF); exit; } } - function thread_markasread($thread_id) + function threadMarkAsRead($threadId) { - global $sql; - $thread_id = intval($thread_id); - $u_new = USERVIEWED.".".$thread_id; - return $sql->db_Update("user", "user_viewed='$u_new' WHERE user_id=".USERID); + $e107 = e107::getInstance(); + $threadId = (int)$threadId; + $currentUser['user_plugin_forum_viewed'] = '4..5..6.7.8'; + $_tmp = preg_split('#\.+#', $currentUser['user_plugin_forum_viewed']); + $_tmp[] = $threadId; + $viewed = '.'.implode('.', $_tmp).'.'; + unset($_tmp); + return $e107->sql->db_Update('user_extended', "user_plugin_forum_viewed = '{$viewed}' WHERE user_extended_id = ".USERID); } function forum_getparents() @@ -418,7 +423,7 @@ class e107forum global $sql; if($uclass == e_UC_ADMIN || trim($uclass) == '') { - $sql->db_Select('user', 'user_id, user_name',"user_admin = 1"); + $sql->db_Select('user', 'user_id, user_name','user_admin = 1'); } else { @@ -634,15 +639,15 @@ class e107forum return $sql->db_Update('forum_t', $newString); } - function forum_get_topics($forum_id, $from, $view) + function forumGetThreads($forumId, $from, $view) { $e107 = e107::getInstance(); - $forum_id = (int)$forum_id; + $forumId = (int)$forumId; $qry = " SELECT t.*, u.user_name, lpu.user_name AS lastpost_username from `#forum_thread` as t LEFT JOIN `#user` AS u ON t.thread_user = u.user_id LEFT JOIN `#user` AS lpu ON t.thread_lastuser = lpu.user_id - WHERE t.thread_forum_id = {$forum_id} + WHERE t.thread_forum_id = {$forumId} ORDER BY t.thread_s DESC, t.thread_lastpost DESC @@ -684,11 +689,11 @@ class e107forum return FALSE; } - function forum_get_topic_count($forum_id) - { - $e107 = e107::getInstance(); - return $e107->sql->db_Count('forum_thread', '(*)', 'WHERE thread_forum_id='.(int)$forum_id); - } +// function forum_get_topic_count($forum_id) +// { +// $e107 = e107::getInstance(); +// return $e107->sql->db_Count('forum_thread', '(*)', 'WHERE thread_forum_id='.(int)$forum_id); +// } function thread_getnext($thread_id, $forum_id, $from = 0, $limit = 100) { diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 61e6cb552..f7ae87eeb 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $ -| $Revision: 1.21 $ -| $Date: 2008-12-01 21:11:01 $ +| $Revision: 1.22 $ +| $Date: 2008-12-02 21:34:18 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -47,7 +47,7 @@ switch($action) case 'rp': $threadInfo = $forum->threadGet($id, false); $forumId = $threadInfo['thread_forum_id']; - print_a($threadInfo); + var_dump($threadInfo); // if (!is_array($thread_info) || !count($thread_info)) // { // $forum_info = false; // Someone fed us a dud forum id - should exist if replying @@ -265,7 +265,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply'])) case 'nt': $threadInfo['thread_s'] = (MODERATOR ? $_POST['threadtype'] : 0); $threadInfo['thread_name'] = $_POST['subject']; - $threadInfo['thread_forum_id'] = $forum_id; + $threadInfo['thread_forum_id'] = $forumId; $threadInfo['thread_active'] = 1; $threadInfo['thread_datestamp'] = $time; $result = $forum->threadAdd($threadInfo, $postInfo); diff --git a/e107_plugins/forum/forum_shortcodes.php b/e107_plugins/forum/forum_shortcodes.php index c3ceefa93..40fd61fe2 100644 --- a/e107_plugins/forum/forum_shortcodes.php +++ b/e107_plugins/forum/forum_shortcodes.php @@ -115,8 +115,17 @@ if($post_info['thread_parent'] == 0) SC_END SC_BEGIN SIGNATURE -global $postInfo; +if(!USER) { return ''; } +global $postInfo, $pref; +static $forum_sig_shown; $e107 = e107::getInstance(); +//$pref['forum_sig_once'] = true; +if(varsettrue($pref['forum_sig_once'])) +{ + $_tmp = 'forum_sig_shown_'.$postInfo['post_user']; + if(getcachedvars($_tmp)) { return ''; } + cachevars($_tmp, 1); +} return ($postInfo['user_signature'] ? "

".$e107->tp->toHTML($postInfo['user_signature'], true).'' : ''); SC_END diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index 18be1ff1f..0314135d7 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -11,23 +11,15 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $ -| $Revision: 1.4 $ -| $Date: 2008-12-01 21:11:01 $ +| $Revision: 1.5 $ +| $Date: 2008-12-02 21:34:18 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ require_once('../../class2.php'); -include_lan(e_PLUGIN.'forum/languages/English/lan_forum_viewtopic.php'); -include_once(e_PLUGIN.'forum/forum_class.php'); -if (file_exists(THEME.'forum_design.php')) -{ - include_once(THEME.'forum_design.php'); -} - -$forum = new e107forum; if (isset($_POST['fjsubmit'])) { header('location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id'=>$_POST['forumjump']))); @@ -42,172 +34,38 @@ if (!e_QUERY) exit; } -global $page; +include_lan(e_PLUGIN.'forum/languages/English/lan_forum_viewtopic.php'); +include_once(e_PLUGIN.'forum/forum_class.php'); + +$forum = new e107forum; + +if(isset($_REQUEST['f'])) +{ + processFunction(); +} + $threadId = (int)varset($_GET['id']); $perPage = (varset($_REQUEST['perpage']) ? (int)$_REQUEST['perpage'] : $pref['forum_postspage']); $page = (varset($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0); -// $tmp = explode(".", e_QUERY); -// $thread_id = varset($tmp[0]); -// $topic_from = varset($tmp[1], 0); -// $action = varset($tmp[2]); - -//$threadInfo = $forum->threadGet($threadId); -//print_a($threadInfo); -//exit; - +//If threadId doesn't exist, or not given, redirect to main forum page if (!$threadId || !$threadInfo = $forum->threadGet($threadId)) { header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main'))); exit; } - +//If not permitted to view forum, redirect to main forum page if(!$forum->checkPerm($threadInfo['thread_forum_id'], 'view')) { header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main'))); exit; } -print_a($threadInfo); -//print_a($forum->permList); -//die('here'); - -if($topic_from === 'post') -{ - if($thread_id) - { - $post_num = $forum->thread_postnum($thread_id); - $pages = ceil(($post_num['post_num']+1)/$pref['forum_postspage']); - $topic_from = ($pages-1) * $pref['forum_postspage']; - if($post_num['parent'] != $thread_id) - { - header("location: ".e_SELF."?{$post_num['parent']}.{$topic_from}#post_{$thread_id}"); - exit; - } - } - else - { - header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main'))); - exit; - } -} - require_once(e_PLUGIN.'forum/forum_shortcodes.php'); -if ($action == 'track' && USER) -{ - $forum->track($thread_id); - header("location:".e_SELF."?{$thread_id}.{$topic_from}"); - exit; -} - -if ($action == 'untrack' && USER) -{ - $forum->untrack($thread_id); - header("location:".e_SELF."?{$thread_id}.{$topic_from}"); - exit; -} - -if ($action == 'next') -{ - $next = $forum->thread_getnext($thread_id, $topic_from); - if ($next) - { - header("location:".e_SELF."?{$next}"); - exit; - } - else - { - require_once(HEADERF); - $ns->tablerender('', LAN_405, array('forum_viewtopic', '405')); - require_once(FOOTERF); - exit; - } -} - -if ($action == 'prev') -{ - $prev = $forum->thread_getprev($thread_id, $topic_from); - if ($prev) - { - header("location:".e_SELF."?{$prev}"); - exit; - } - else - { - require_once(HEADERF); - $ns->tablerender('', LAN_404, array('forum_viewtopic', '404')); - require_once(FOOTERF); - exit; - } -} - -if ($action == 'report') -{ - $thread_info = $forum->thread_get_postinfo($thread_id, TRUE); - - if (isset($_POST['report_thread'])) - { - $report_add = $tp -> toDB($_POST['report_add']); - if ($pref['reported_post_email']) - { - require_once(e_HANDLER."mail.php"); - $report = LAN_422.SITENAME." : ".(substr(SITEURL, -1) == "/" ? SITEURL : SITEURL."/").$PLUGINS_DIRECTORY."forum/forum_viewtopic.php?".$thread_id.".post\n".LAN_425.USERNAME."\n".$report_add; - $subject = LAN_421." ".SITENAME; - sendemail(SITEADMINEMAIL, $subject, $report); - } - $sql->db_Insert('generic', "0, 'reported_post', ".time().", '".USERID."', '{$thread_info['head']['thread_name']}', ".intval($thread_id).", '{$report_add}'"); - define("e_PAGETITLE", LAN_01." / ".LAN_428); - require_once(HEADERF); - $text = LAN_424."

".LAN_429."tablerender(LAN_414, $text, array('forum_viewtopic', 'report')); - } - else - { - $thread_name = $tp -> toHTML($thread_info['head']['thread_name'], TRUE, 'no_hook, emotes_off'); - define("e_PAGETITLE", LAN_01." / ".LAN_426." ".$thread_name); - require_once(HEADERF); - $text = "
- - - - - - - - - - - -
- ".LAN_415.": ".$thread_name." ".LAN_420." - - -
".LAN_417."
".LAN_418." -
- -

- -
"; - $ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report2')); - } - require_once(FOOTERF); - exit; -} $pm_installed = plugInstalled('pm'); -//$replies = $forum->thread_count($thread_id)-1; - -if ($topic_from === 'last') -{ - $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10); - $pages = ceil(($threadInfo['thread_total_replies']+1)/$pref['forum_postspage']); - $topic_from = ($pages-1) * $pref['forum_postspage']; -} -$gen = new convert; -//$thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']); -$postList = $forum->PostGet($threadId, $page * $perPage, $perPage); //Only increment thread views if not being viewed by thread starter if(!USER || USER != $threadInfo['thread_user']) @@ -215,7 +73,7 @@ if(!USER || USER != $threadInfo['thread_user']) $forum->threadIncview($threadId); } -print_a($postList); +//print_a($postList); //if(intval($thread_info['head']['thread_forum_id']) == 0) //{ // require_once(HEADERF); @@ -231,44 +89,43 @@ print_a($postList); // exit; //} - -define('e_PAGETITLE', LAN_01.' / '.$e107->tp->toHTML($forum_info['forum_name'], true, 'no_hook, emotes_off')." / ".$tp->toHTML($thread_info['head']['thread_name'], TRUE, 'no_hook, emotes_off')); +define('e_PAGETITLE', LAN_01.' / '.$e107->tp->toHTML($threadInfo['forum_name'], true, 'no_hook, emotes_off')." / ".$tp->toHTML($threadInfo['thread_name'], true, 'no_hook, emotes_off')); //define("MODERATOR", (preg_match("/".preg_quote(ADMINNAME)."/", $forum_info['forum_moderators']) && getperms('A') ? TRUE : FALSE)); define('MODERATOR', ($forum_info['forum_moderators'] != '' && check_class($forum_info['forum_moderators']))); -//$modArray = $forum->forum_getmods($forum_info['forum_moderators']); +$modArray = $forum->forum_getmods($threadInfo['forum_moderators']); +//var_dump($modArray); $message = ''; -if (MODERATOR) +if (MODERATOR && isset($_POST['mod'])) { - if ($_POST) - { - require_once(e_PLUGIN.'forum/forum_mod.php'); - $message = forum_thread_moderate($_POST); - $thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']); - } + require_once(e_PLUGIN.'forum/forum_mod.php'); + $message = forum_thread_moderate($_POST); + $threadInfo = $forum->threadGet($threadId); } +$postList = $forum->PostGet($threadId, $page * $perPage, $perPage); + +var_dump($threadInfo); require_once(HEADERF); require_once(e_HANDLER.'level_handler.php'); +$gen = new convert; if ($message) { $ns->tablerender('', $message, array('forum_viewtopic', 'msg')); } if(isset($threadInfo['thread_options']['poll'])) -//if (stristr($thread_info['head']['thread_name'], "[".LAN_430."]")) { - if(!defined('POLLCLASS')) - { - include(e_PLUGIN.'poll/poll_class.php'); - } + if(!defined('POLLCLASS')) { include(e_PLUGIN.'poll/poll_class.php'); } $_qry = 'SELECT * FROM `#polls` WHERE `poll_datestamp` = '.$threadId; $poll = new poll; $pollstr = "
".$poll->render_poll($_qry, 'forum', 'query', true).'
'; } //Load forum templates -if (!$FORUMSTART) { +if (file_exists(THEME.'forum_design.php')) { include_once(THEME.'forum_design.php'); } +if (!$FORUMSTART) +{ if (file_exists(THEME.'forum_viewtopic_template.php')) { require_once(THEME.'forum_viewtopic_template.php'); @@ -283,7 +140,7 @@ if (!$FORUMSTART) { } } -$forum_info['forum_name'] = $e107->tp->toHTML($threadInfo['forum_name'], true, 'no_hook,emotes_off'); +//$forum_info['forum_name'] = $e107->tp->toHTML($threadInfo['forum_name'], true, 'no_hook,emotes_off'); // get info for main thread ------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -296,7 +153,7 @@ $NEXTPREV .= "
' if ($pref['forum_track'] && USER) { - if($forum->track('check', USERID, $threadId)) + if($threadInfo['track_userid']) { $TRACK = " 'untrack', 'id' => $threadId))."'>".LAN_392.""; } @@ -306,12 +163,10 @@ if ($pref['forum_track'] && USER) } } -$MODERATORS = LAN_321.implode(", ", $modArray); +$MODERATORS = LAN_321.implode(', ', $modArray); $THREADSTATUS = (!$threadInfo['thread_active'] ? LAN_66 : ''); -//$pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10); - $pages = ceil(($threadInfo['thread_total_replies']+1) / $perPage); if ($pages > 1) @@ -339,32 +194,17 @@ $forstr = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMSTART); unset($forrep); if (!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE; $alt = false; -//for($i = 0; $i < count($thread_info)-1; $i++) $i=$page; global $postInfo; foreach($postList as $postInfo) { - print_a($postInfo); +// print_a($postInfo); $loop_uid = (int)$postInfo['post_user']; $i++; -/* - if (!$postInfo['user_name']) - { - // guest - $tmp = explode(chr(1), $post_info['thread_anon']); - $ip = $tmp[1]; - $host = $e107->get_host_name($ip); - $post_info['iphost'] = ""; - $post_info['anon'] = false; - } - else - { - $post_info['anon'] = FALSE; - } -*/ - $e_hide_query = "SELECT thread_id FROM #forum_t WHERE (`thread_parent` = {$thread_id} OR `thread_id` = {$thread_id}) AND SUBSTRING_INDEX(thread_user,'.',1) = ".USERID; + //TODO: Look into fixing this, to limit to a single query per pageload + $e_hide_query = "SELECT post_id FROM `#forum_post` WHERE (`post_thread` = {$threadId} AND post_user= ".USERID.' LIMIT 1'; $e_hide_hidden = FORLAN_HIDDEN; $e_hide_allowed = USER; @@ -387,11 +227,11 @@ foreach($postList as $postInfo) } unset($loop_uid); -if (((check_class($forum_info['forum_postclass']) && check_class($forum_info['parent_postclass'])) || MODERATOR) && $thread_info['head']['thread_active'] ) +if($forum->checkPerm($threadInfo['thread_forum_id'], 'post') && $threadInfo['thread_active']) { if (!$forum_quickreply) { - $QUICKREPLY = "\n

\n".LAN_393.":

 \n\n\n

\n
"; + $QUICKREPLY = "
'rp', 'id' => $threadId))."' method='post'>\n

\n".LAN_393.":

 \n\n\n

\n
"; } else { @@ -403,8 +243,10 @@ $forend = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMEND); $forumstring = $forstr.$forthr.$forrep.$forend; -if ($thread_info['head']['thread_lastpost'] > USERLV && (strpos(USERVIEWED, ".{$thread_info['head']['thread_id']}.") === FALSE)) { - $tst = $forum->thread_markasread($thread_info['head']['thread_id']); +//If last post came after USERLV and not yet marked as read, mark the thread id as read +if ($threadInfo['thread_lastpost'] > USERLV && (strpos($currentUser['user_plugin_forum_viewed'], '.'.$threadId.'.') === false)) +{ + $tst = $forum->threadMarkAsRead($threadId); } if ($pref['forum_enclose']) @@ -561,4 +403,138 @@ function rpg($user_join, $user_forums) return $rpg_info; } +function processFunction() +{ +if($topic_from === 'post') +{ + if($thread_id) + { + $post_num = $forum->thread_postnum($thread_id); + $pages = ceil(($post_num['post_num']+1)/$pref['forum_postspage']); + $topic_from = ($pages-1) * $pref['forum_postspage']; + if($post_num['parent'] != $thread_id) + { + header("location: ".e_SELF."?{$post_num['parent']}.{$topic_from}#post_{$thread_id}"); + exit; + } + } + else + { + header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main'))); + exit; + } +} + +if ($action == 'track' && USER) +{ + $forum->track($thread_id); + header("location:".e_SELF."?{$thread_id}.{$topic_from}"); + exit; +} + +if ($action == 'untrack' && USER) +{ + $forum->untrack($thread_id); + header("location:".e_SELF."?{$thread_id}.{$topic_from}"); + exit; +} + +if ($action == 'next') +{ + $next = $forum->thread_getnext($thread_id, $topic_from); + if ($next) + { + header("location:".e_SELF."?{$next}"); + exit; + } + else + { + require_once(HEADERF); + $ns->tablerender('', LAN_405, array('forum_viewtopic', '405')); + require_once(FOOTERF); + exit; + } +} + +if ($action == 'prev') +{ + $prev = $forum->thread_getprev($thread_id, $topic_from); + if ($prev) + { + header("location:".e_SELF."?{$prev}"); + exit; + } + else + { + require_once(HEADERF); + $ns->tablerender('', LAN_404, array('forum_viewtopic', '404')); + require_once(FOOTERF); + exit; + } +} + +if ($action == 'report') +{ + $thread_info = $forum->thread_get_postinfo($thread_id, TRUE); + + if (isset($_POST['report_thread'])) + { + $report_add = $tp -> toDB($_POST['report_add']); + if ($pref['reported_post_email']) + { + require_once(e_HANDLER."mail.php"); + $report = LAN_422.SITENAME." : ".(substr(SITEURL, -1) == "/" ? SITEURL : SITEURL."/").$PLUGINS_DIRECTORY."forum/forum_viewtopic.php?".$thread_id.".post\n".LAN_425.USERNAME."\n".$report_add; + $subject = LAN_421." ".SITENAME; + sendemail(SITEADMINEMAIL, $subject, $report); + } + $sql->db_Insert('generic', "0, 'reported_post', ".time().", '".USERID."', '{$thread_info['head']['thread_name']}', ".intval($thread_id).", '{$report_add}'"); + define("e_PAGETITLE", LAN_01." / ".LAN_428); + require_once(HEADERF); + $text = LAN_424."

".LAN_429."tablerender(LAN_414, $text, array('forum_viewtopic', 'report')); + } + else + { + $thread_name = $tp -> toHTML($thread_info['head']['thread_name'], TRUE, 'no_hook, emotes_off'); + define("e_PAGETITLE", LAN_01." / ".LAN_426." ".$thread_name); + require_once(HEADERF); + $text = "
+ + + + + + + + + + + +
+ ".LAN_415.": ".$thread_name." ".LAN_420." + + +
".LAN_417."
".LAN_418." +
+ +

+ +
"; + $ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report2')); + } + require_once(FOOTERF); + exit; +} + + +if ($topic_from === 'last') +{ + $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10); + $pages = ceil(($threadInfo['thread_total_replies']+1)/$pref['forum_postspage']); + $topic_from = ($pages-1) * $pref['forum_postspage']; +} + + +} + ?> \ No newline at end of file diff --git a/e107_plugins/forum/plugin.xml b/e107_plugins/forum/plugin.xml index 9beedcdea..1f6312158 100755 --- a/e107_plugins/forum/plugin.xml +++ b/e107_plugins/forum/plugin.xml @@ -29,11 +29,11 @@ - + - + diff --git a/e107_plugins/forum/viewforum.php b/e107_plugins/forum/viewforum.php index 9a322fd7f..85f7b4272 100755 --- a/e107_plugins/forum/viewforum.php +++ b/e107_plugins/forum/viewforum.php @@ -9,8 +9,8 @@ * View specific forums * * $Source: /cvs_backup/e107_0.8/e107_plugins/forum/viewforum.php,v $ -* $Revision: 1.4 $ -* $Date: 2008-12-01 01:10:50 $ +* $Revision: 1.5 $ +* $Date: 2008-12-02 21:34:18 $ * $Author: mcfly_e107 $ * */ @@ -31,7 +31,7 @@ if (!e_QUERY) } $view = 25; -$thread_from = (isset($_REQUEST['p']) ? $_REQUEST['p'] * $view : 0); +$threadFrom = (isset($_REQUEST['p']) ? $_REQUEST['p'] * $view : 0); /* else @@ -58,15 +58,15 @@ $VIEWTITLE = LAN_56; global $forum_info, $FORUM_CRUMB; -$forum_id = (int)$_REQUEST['id']; +$forumId = (int)$_REQUEST['id']; -if (!$forum->checkPerm($forum_id, 'view')) +if (!$forum->checkPerm($forumId, 'view')) { header("Location:".$e107->url->getUrl('forum', 'forum', array('func' => 'main'))); exit; } -$forum_info = $forum->forum_get($forum_id); +$forumInfo = $forum->forum_get($forumId); if (!$FORUM_VIEW_START) { if (file_exists(THEME.'forum_viewforum_template.php')) @@ -83,10 +83,10 @@ if (!$FORUM_VIEW_START) { } } -$forum_info['forum_name'] = $e107->tp->toHTML($forum_info['forum_name'], true, 'no_hook, emotes_off'); -$forum_info['forum_description'] = $e107->tp->toHTML($forum_info['forum_description'], true, 'no_hook'); +$forumInfo['forum_name'] = $e107->tp->toHTML($forumInfo['forum_name'], true, 'no_hook, emotes_off'); +$forumInfo['forum_description'] = $e107->tp->toHTML($forumInfo['forum_description'], true, 'no_hook'); -$_forum_name = (substr($forum_info['forum_name'], 0, 1) == '*' ? substr($forum_info['forum_name'], 1) : $forum_info['forum_name']); +$_forum_name = (substr($forumInfo['forum_name'], 0, 1) == '*' ? substr($forumInfo['forum_name'], 1) : $forumInfo['forum_name']); define('e_PAGETITLE', LAN_01.' / '.$_forum_name); define('MODERATOR', $forum_info['forum_moderators'] != '' && check_class($forum_info['forum_moderators'])); $modArray = $forum->forum_getmods($forum_info['forum_moderators']); @@ -102,8 +102,8 @@ if (MODERATOR) if(varset($pref['track_online'])) { - $member_users = $sql->db_Count('online', '(*)', "WHERE online_location REGEXP('viewforum.php.id=$forum_id\$') AND online_user_id != 0"); - $guest_users = $sql->db_Count('online', '(*)', "WHERE online_location REGEXP('viewforum.php.id=$forum_id\$') AND online_user_id = 0"); + $member_users = $sql->db_Count('online', '(*)', "WHERE online_location REGEXP('viewforum.php.id=$forumId\$') AND online_user_id != 0"); + $guest_users = $sql->db_Count('online', '(*)', "WHERE online_location REGEXP('viewforum.php.id=$forumId\$') AND online_user_id = 0"); $users = $member_users+$guest_users; } @@ -114,32 +114,34 @@ if ($message) $ns->tablerender('', $message, array('forum_viewforum', 'msg')); } -$topics = $forum->forum_get_topic_count($forum_id); -if ($topics > $view) +$threadCount = $forumInfo['forum_threads']; + +if ($threadCount > $view) { - $pages = ceil($topics/$view); + $pages = ceil($threadCount/$view); } else { $pages = false; } +//echo "pages = $pages
"; if ($pages) { - if(strpos($FORUM_VIEW_START, 'THREADPAGES') !== FALSE || strpos($FORUM_VIEW_END, 'THREADPAGES') !== FALSE) + if(strpos($FORUM_VIEW_START, 'THREADPAGES') !== false || strpos($FORUM_VIEW_END, 'THREADPAGES') !== false) { - $parms = "{$topics},{$view},{$thread_from},".e_SELF.'?'.$forum_id.'.[FROM],off'; + $parms = "{$threadCount},{$view},{$threadFrom},".e_SELF.'?'.$forumId.'.[FROM],off'; $THREADPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}"); } } -if($forum->checkPerm($forum_id, 'post')) +if($forum->checkPerm($forumId, 'post')) { - $NEWTHREADBUTTON = "
'nt', 'id' => $forum_id))."'>".IMAGE_newthread.''; + $NEWTHREADBUTTON = " 'nt', 'id' => $forumId))."'>".IMAGE_newthread.''; } -if(substr($forum_info['forum_name'], 0, 1) == '*') +if(substr($forumInfo['forum_name'], 0, 1) == '*') { $forum_info['forum_name'] = substr($forum_info['forum_name'], 1); $container_only = true; @@ -200,7 +202,7 @@ $SEARCH = "

"; -if($forum->checkPerm($forum_id, 'post')) +if($forum->checkPerm($forumId, 'post')) { $PERMS = LAN_204.' - '.LAN_206.' - '.LAN_208; } @@ -214,8 +216,8 @@ $stuck = false; $reg_threads = 0; $unstuck = false; -$thread_list = $forum->forum_get_topics($forum_id, $thread_from, $view); -$sub_list = $forum->forum_getsubs($forum_id); +$threadList = $forum->forumGetThreads($forumId, $threadFrom, $view); +$subList = $forum->forum_getsubs($forum_id); //print_a($sub_list); $gen = new convert; @@ -231,14 +233,14 @@ if(is_array($sub_list)) $SUBFORUMS = $FORUM_VIEW_SUB_START.$sub_info.$FORUM_VIEW_SUB_END; } -if (count($thread_list) ) +if (count($threadList) ) { - foreach($thread_list as $thread_info) + foreach($threadList as $thread_info) { $idArray[] = $thread_info['thread_id']; } $inList = '('.implode(',', $idArray).')'; - foreach($thread_list as $thread_info) + foreach($threadList as $thread_info) { if ($thread_info['thread_s']) {