From 78b398f015cae030fbce10c11c321296776e4cd1 Mon Sep 17 00:00:00 2001 From: mcfly Date: Thu, 18 Dec 2008 14:08:33 +0000 Subject: [PATCH] new thread listing now working --- e107_plugins/forum/forum.php | 31 ++++++------- e107_plugins/forum/forum_class.php | 60 ++++++++++++-------------- e107_plugins/forum/forum_post.php | 6 +-- e107_plugins/forum/forum_viewforum.php | 6 +-- e107_plugins/forum/forum_viewtopic.php | 8 ++-- 5 files changed, 49 insertions(+), 62 deletions(-) diff --git a/e107_plugins/forum/forum.php b/e107_plugins/forum/forum.php index d1fd1ed9e..930c55cfb 100644 --- a/e107_plugins/forum/forum.php +++ b/e107_plugins/forum/forum.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum.php,v $ -| $Revision: 1.12 $ -| $Date: 2008-12-17 04:22:37 $ +| $Revision: 1.13 $ +| $Date: 2008-12-18 14:08:33 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -417,33 +417,26 @@ if (e_QUERY == 'track') if (e_QUERY == 'new') { - $newpostList = $forum->post_getnew(10); - foreach($newpostList as $post) + $newThreadList = $forum->threadGetNew(10); + foreach($newThreadList as $thread) { - list($author_id, $author_info) = explode('.', $post['thread_user'], 2); - list($author_name, $tmp) = explode(chr(1), $author_info); - $datestamp = $gen->convert_date($post['thread_datestamp'], "forum"); - if($author_id == 0) + $author_name = ($thread['user_name'] ? $thread['user_name'] : $thread['lastuser_anon']); + + $datestamp = $gen->convert_date($thread['thread_lastpost'], 'forum'); + if(!$thread['user_name']) { - $STARTERTITLE = $author_name."
".$datestamp; + $STARTERTITLE = $author_name.'
'.$datestamp; } else { - $STARTERTITLE = "$author_name
".$datestamp; - } - if($post['post_subject']) - { - $NEWSPOSTNAME = "".LAN_425.$tp->toHTML($post['post_subject'], TRUE, 'no_make_clickable, no_hook').""; - } - else - { - $NEWSPOSTNAME = "".$tp->toHTML($post['thread_name'], TRUE, 'no_make_clickable, no_hook').""; + $STARTERTITLE = "{$author_name}
".$datestamp; } + $NEWSPOSTNAME = "".$e107->tp->toHTML($thread['thread_name'], TRUE, 'no_make_clickable, no_hook').''; $forum_newstring .= preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_NEWPOSTS_MAIN); } - if (!$newpostList) + if (!$newThreadList) { $NEWSPOSTNAME = LAN_198; $forum_newstring = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_NEWPOSTS_MAIN); diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index 6364ddca5..abbd220da 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $ -| $Revision: 1.28 $ -| $Date: 2008-12-17 04:22:37 $ +| $Revision: 1.29 $ +| $Date: 2008-12-18 14:08:33 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -748,7 +748,7 @@ class e107forum return false; } } - + function thread_user($post_info) { if($post_info['user_name']) @@ -794,16 +794,6 @@ class e107forum return $result; } -/* - function track($uid, $thread_id) - { - $thread_id = (int)$thread_id; - $uid = (int)$uid; - global $sql; - return $sql->db_Update("user", "user_realm='".USERREALM."-".$thread_id."-' WHERE user_id=".USERID); - } -*/ - function forum_get($forum_id) { $forum_id = (int)$forum_id; @@ -821,15 +811,13 @@ class e107forum return FALSE; } - function forum_get_allowed() + function forumGetAllowed($type='view') { global $sql; + $forumList = implode(',', $this->permList[$type]); $qry = " - SELECT f.forum_id, f.forum_name FROM #forum AS f - LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent - WHERE f.forum_parent != 0 - AND fp.forum_class IN (".USERCLASS_LIST.") - AND f.forum_class IN (".USERCLASS_LIST.") + SELECT forum_id, forum_name FROM `#forum` + WHERE forum_id IN ({$forumList}) "; if ($sql->db_Select_gen($qry)) { @@ -945,20 +933,17 @@ class e107forum } - function post_getnew($count = 50, $userviewed = USERVIEWED) + function threadGetNew($count = 50, $unread = true, $uid = USERID) { - global $sql; - $viewed = ""; - if($userviewed) + $e107 = e107::getInstance(); + $viewed = ''; + if($unread) { - $viewed = preg_replace("#\.+#", ".", $userviewed); - $viewed = preg_replace("#^\.#", "", $viewed); - $viewed = preg_replace("#\.$#", "", $viewed); - $viewed = str_replace(".", ",", $viewed); - } - if($viewed != "") - { - $viewed = " AND ft.thread_id NOT IN (".$viewed.")"; + $viewed = implode(',', $this->threadGetUserViewed($uid)); + if($viewed != '') + { + $viewed = ' AND p.post_forum NOT IN ('.$viewed.')'; + } } $qry = " @@ -971,9 +956,18 @@ class e107forum AND f.forum_class IN (".USERCLASS_LIST.") {$viewed} ORDER BY ft.thread_datestamp DESC LIMIT 0, ".intval($count); - if($sql->db_Select_gen($qry)) + + $qry = " + SELECT t.*, u.user_name FROM `#forum_thread` AS t + LEFT JOIN `#user` AS u ON u.user_id = t.thread_lastuser + WHERE t.thread_lastpost > ".USERLV. " + {$viewed} + ORDER BY t.thread_lastpost DESC LIMIT 0, ".(int)$count; + + + if($e107->sql->db_Select_gen($qry)) { - $ret = $sql->db_getList(); + $ret = $e107->sql->db_getList(); } return $ret; } diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 56bf6a5e3..74eb79c90 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.33 $ -| $Date: 2008-12-17 18:48:02 $ +| $Revision: 1.34 $ +| $Date: 2008-12-18 14:08:33 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -543,7 +543,7 @@ function isAuthor() function forumjump() { global $forum; - $jumpList = $forum->forum_get_allowed(); + $jumpList = $forum->forumGetAllowed('view'); $text = "

".LAN_401.": "; foreach($jumpList as $key => $val) { diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index 3f3c24b64..221499020 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -12,8 +12,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $ -| $Revision: 1.17 $ -| $Date: 2008-12-17 04:22:37 $ +| $Revision: 1.18 $ +| $Date: 2008-12-18 14:08:33 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -325,7 +325,7 @@ function showmodoptions() function forumjump() { global $forum; - $jumpList = $forum->forum_get_allowed(); + $jumpList = $forum->forumGetAllowed(); $text = "

" . LAN_65 . ":