diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php
index 3271a7235..766fec944 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.13 $
-| $Date: 2008-12-01 01:10:50 $
+| $Revision: 1.14 $
+| $Date: 2008-12-01 21:11:01 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -119,6 +119,9 @@ class e107forum
*/
function postAdd($postInfo, $updateThread = true, $updateForum = true)
{
+ //Future option, will just set to true here
+ $addUserPostCount = true;
+
$e107 = e107::getInstance();
$result = $e107->sql->db_Insert('forum_post', $postInfo, true);
$forumInfo = array();
@@ -149,6 +152,7 @@ class e107forum
$result = $e107->sql->db_Update('forum_thread', $threadInfo, true);
}
+
if($result && $updateForum)
{
if(varset($postInfo['post_user']))
@@ -178,6 +182,17 @@ class e107forum
$forumInfo['WHERE'] = 'forum_id = '.$postInfo['post_forum'];
$result = $e107->sql->db_Update('forum', $forumInfo, true);
}
+
+ if($result && USER && $addUserPostCount)
+ {
+ $qry = '
+ INSERT INTO `#user_extended` (user_extended_id, user_plugin_forum_posts)
+ VALUES ('.USERID.', 1)
+ ON DUPLICATE KEY UPDATE user_plugin_forum_posts = user_plugin_forum_posts + 1
+ ';
+ $result = $e107->sql->db_Select_gen($qry, true);
+ }
+
}
function threadAdd($threadInfo, $postInfo)
@@ -197,21 +212,21 @@ class e107forum
$e107 = e107::getInstance();
//TODO: Add this
}
-
+
function threadGet($id, $joinForum = true, $uid = USERID)
{
- $e107 = e107::getInstance();
+ $e107 = e107::getInstance();
$id = (int)$id;
$uid = (int)$uid;
if($joinForum)
{
- //TODO: Fix query to get only forum and parent info needed, with correct naming
+ //TODO: Fix query to get only forum and parent info needed, with correct naming
$qry = '
SELECT t.*, f.*, tr.track_userid
FROM `#forum_thread` AS t
LEFT JOIN `#forum` AS f ON t.thread_forum_id = f.forum_id
- LEFT JOIN `#forum_track` AS tr ON tr.track_thread = t.thread_id AND tr.track_userid = '.$uid.'
+ LEFT JOIN `#forum_track` AS tr ON tr.track_thread = t.thread_id AND tr.track_userid = '.$uid.'
WHERE thread_id = '.$id;
}
else
@@ -235,26 +250,35 @@ class e107forum
}
return false;
}
-
+
function postGet($threadId, $start, $num)
{
+ $ret = false;
$e107 = e107::getInstance();
$qry = '
- SELECT p.*, u.user_name, u.user_customtitle, eu.user_name AS edit_name
+ SELECT p.*,
+ u.user_name, u.user_customtitle, u.user_hideemail, u.user_email, u.user_signature,
+ u.user_admin, u.user_image, u.user_join, ue.user_plugin_forum_posts,
+ eu.user_name AS edit_name
FROM `#forum_post` AS p
LEFT JOIN `#user` AS u ON p.post_user = u.user_id
- LEFT JOIN `#user` AS eu ON p.post_edit_user IS NOT NULL AND p.post_edit_user = eu.user_id
+ LEFT JOIN `#user` AS eu ON p.post_edit_user IS NOT NULL AND p.post_edit_user = eu.user_id
+ LEFT JOIN `#user_extended` AS ue ON ue.user_extended_id = p.post_user
WHERE p.post_thread = '.$threadId."
ORDER BY p.post_datestamp ASC
LIMIT {$start}, {$num}
";
if($e107->sql->db_Select_gen($qry, true))
{
- return $e107->sql->db_Fetch(MYSQL_ASSOC);
+ $ret = array();
+ while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
+ {
+ $ret[] = $row;
+ }
}
- return false;
+ return $ret;
}
-
+
function thread_postnum($thread_id)
{
global $sql;
@@ -1140,9 +1164,9 @@ class e107forum
* $forum_href override ONLY applies when template is missing FORUM_CRUMB
* $thread_title is needed for post-related breadcrumbs
*/
- function set_crumb($forum_href=FALSE,$thread_title="")
+ function set_crumb($forum_href=false, $thread_title='')
{
- global $FORUM_CRUMB,$forum_info,$thread_info,$tp;
+ global $FORUM_CRUMB, $forum_info, $threadInfo, $tp;
global $BREADCRUMB,$BACKLINK; // Eventually we should deprecate BACKLINK
if(is_array($FORUM_CRUMB))
diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php
index 93329a2e6..61e6cb552 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.20 $
-| $Date: 2008-12-01 01:10:50 $
+| $Revision: 1.21 $
+| $Date: 2008-12-01 21:11:01 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -41,33 +41,27 @@ if (!e_QUERY || !isset($_REQUEST['id']))
$action = $_REQUEST['f'];
$id = (int)$_REQUEST['id'];
-// check if user can post to this forum ...
-if (!$forum->checkPerm($id, 'post'))
-{
- require_once(HEADERF);
- $ns->tablerender(LAN_20, "
".LAN_399."
");
- require_once(FOOTERF);
- exit;
-}
switch($action)
{
case 'rp':
- $thread_info = $forum->thread_get($id, 'last', 11);
- if (!is_array($thread_info) || !count($thread_info))
- {
- $forum_info = false; // Someone fed us a dud forum id - should exist if replying
- }
- else
- {
- $forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
- }
- $forum_id = $forum_info['forum_id'];
+ $threadInfo = $forum->threadGet($id, false);
+ $forumId = $threadInfo['thread_forum_id'];
+ print_a($threadInfo);
+// if (!is_array($thread_info) || !count($thread_info))
+// {
+// $forum_info = false; // Someone fed us a dud forum id - should exist if replying
+// }
+// else
+// {
+// $forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
+// }
+// $forum_id = $forum_info['forum_id'];
break;
case 'nt':
$forum_info = $forum->forum_get($id);
- $forum_id = $id;
+ $forumId = $id;
break;
case 'quote':
@@ -78,8 +72,22 @@ switch($action)
{
$id = $thread_info['head']['thread_id'];
}
- $forum_id = $forum_info['forum_id'];
+ $forumId = $forum_info['forum_id'];
break;
+
+ default:
+ header("Location:".$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
+ exit;
+
+}
+
+// check if user can post to this forum ...
+if (!$forum->checkPerm($forumId, 'post'))
+{
+ require_once(HEADERF);
+ $ns->tablerender(LAN_20, "".LAN_399.'
');
+ require_once(FOOTERF);
+ exit;
}
define("MODERATOR", check_class($forum_info['forum_moderators']));
@@ -93,16 +101,16 @@ $e107 = e107::getInstance();
//if thread is not active and not new thread, show warning
-if ($action != "nt" && !$thread_info['head']['thread_active'] && !MODERATOR)
+if ($action != 'nt' && !$threadInfo['thread_active'] && !MODERATOR)
{
require_once(HEADERF);
- $ns->tablerender(LAN_20, "".LAN_397."
");
+ $ns->tablerender(LAN_20, "".LAN_397.'
');
require_once(FOOTERF);
exit;
}
$forum_info['forum_name'] = $tp->toHTML($forum_info['forum_name'], true);
-define("e_PAGETITLE", LAN_01." / ".$forum_info['forum_name']." / ".($action == 'rp' ? LAN_02.$forum_info['thread_name'] : LAN_03));
+define('e_PAGETITLE', LAN_01.' / '.$forumInfo['forum_name'].' / '.($action == 'rp' ? LAN_02.$threadInfo['thread_name'] : LAN_03));
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -198,10 +206,10 @@ if (isset($_POST['fpreview']))
}
$eaction = TRUE;
}
- else if($action == "quote")
+ else if($action == 'quote')
{
- $action = "reply";
- $eaction = FALSE;
+ $action = 'reply';
+ $eaction = false;
}
}
@@ -211,7 +219,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
$threadInfo = array();
if ((isset($_POST['newthread']) && trim($_POST['subject']) == '') || trim($_POST['post']) == '')
{
- message_handler("ALERT", 5);
+ message_handler('ALERT', 5);
}
else
{
@@ -238,7 +246,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
}
$time = time();
$postInfo['post_entry'] = $_POST['post'];
- $postInfo['post_forum'] = $forum_id;
+ $postInfo['post_forum'] = $forumId;
$postInfo['post_datestamp'] = $time;
$threadInfo['thread_lastpost'] = $time;
@@ -443,36 +451,36 @@ if (!$FORUMPOST)
include_once(e_PLUGIN."forum/templates/forum_post_template.php");
}
}
-/* check post access (bugtracker #1424) */
-if($action == "rp" && !$sql -> db_Select("forum_t", "*", "thread_id='{$id}'"))
-{
- $ns -> tablerender(LAN_20, "".LAN_399."
");
- require_once(FOOTERF);
- exit;
-}
-elseif($action == "nt")
-{
- if (!$sact && !$sql -> db_Select("forum", "*", "forum_id='{$id}'"))
- {
- $ns -> tablerender(LAN_20, "".LAN_399."
");
- require_once(FOOTERF);
- exit;
- }
-}
-else
-{
- // DB access should pass - after all, the thread should exist
- $sql->db_Select_gen("SELECT t.*, p.forum_postclass FROM #forum_t AS t
- LEFT JOIN #forum AS p ON t.thread_forum_id=p.forum_id WHERE thread_id='{$id}'");
- $fpr = $sql -> db_Fetch();
- if(!check_class($fpr['forum_postclass']))
- {
- $ns -> tablerender(LAN_20, "".LAN_399."
");
- require_once(FOOTERF);
- exit;
- }
-}
+/* check post access (bugtracker #1424) */
+//if($action == "rp" && !$sql -> db_Select("forum_t", "*", "thread_id='{$id}'"))
+//{
+// $ns -> tablerender(LAN_20, "".LAN_399."
");
+// require_once(FOOTERF);
+// exit;
+//}
+//elseif($action == "nt")
+//{
+// if (!$sact && !$sql -> db_Select("forum", "*", "forum_id='{$id}'"))
+// {
+// $ns -> tablerender(LAN_20, "".LAN_399."
");
+// require_once(FOOTERF);
+// exit;
+// }
+//}
+//else
+//{
+// // DB access should pass - after all, the thread should exist
+// $sql->db_Select_gen("SELECT t.*, p.forum_postclass FROM #forum_t AS t
+// LEFT JOIN #forum AS p ON t.thread_forum_id=p.forum_id WHERE thread_id='{$id}'");
+// $fpr = $sql -> db_Fetch();
+// if(!check_class($fpr['forum_postclass']))
+// {
+// $ns -> tablerender(LAN_20, "".LAN_399."
");
+// require_once(FOOTERF);
+// exit;
+// }
+//}
if($action == 'rp')
{
@@ -493,9 +501,8 @@ else
function isAuthor()
{
- global $thread_info;
- $tmp = explode(".", $thread_info[0]['thread_user'], 2);
- return ($tmp[0] == USERID || MODERATOR);
+ global $threadInfo;
+ return ((USERID === $postInfo['post_user']) || MODERATOR);
}
function getuser($name)
diff --git a/e107_plugins/forum/forum_shortcodes.php b/e107_plugins/forum/forum_shortcodes.php
index 27504c738..c3ceefa93 100644
--- a/e107_plugins/forum/forum_shortcodes.php
+++ b/e107_plugins/forum/forum_shortcodes.php
@@ -6,29 +6,27 @@ $forum_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__);
SC_BEGIN TOP
return "".LAN_10."";
SC_END
-
+
SC_BEGIN JOINED
-global $post_info, $gen;
-if ($post_info['user_id']) {
-return LAN_06.': '.$gen->convert_date($post_info['user_join'], 'forum').'
';
+global $postInfo, $gen;
+if ($postInfo['post_user'])
+{
+ return LAN_06.': '.$gen->convert_date($postInfo['user_join'], 'forum').'
';
}
SC_END
-
+
SC_BEGIN THREADDATESTAMP
-global $post_info, $gen, $thread_id;
-return "".IMAGE_post." ".$gen->convert_date($post_info['thread_datestamp'], "forum");
+global $postInfo, $gen;
+$e107 = e107::getInstance();
+return " 'post', 'id' => $postInfo['post_id']))."'>".IMAGE_post." ".$gen->convert_date($postInfo['post_datestamp'], 'forum');
SC_END
-
+
SC_BEGIN POST
-global $post_info, $tp, $iphost;
-$ret = "";
-$ret = $tp->toHTML($post_info["thread_thread"], TRUE, "USER_BODY", 'class:'.$post_info["user_class"]);
-if (ADMIN && $iphost) {
-$ret .= "
".$iphost;
-}
-return $ret;
+global $postInfo;
+$e107 = e107::getInstance();
+return $e107->tp->toHTML($postInfo['post_entry'], true, 'USER_BODY', 'class:'.$post_info['user_class']);
SC_END
-
+
SC_BEGIN PRIVMESSAGE
global $pref, $post_info, $tp;
if(isset($pref['plug_installed']['pm']) && ($post_info['user_id'] > 0))
@@ -36,61 +34,70 @@ if(isset($pref['plug_installed']['pm']) && ($post_info['user_id'] > 0))
return $tp->parseTemplate("{SENDPM={$post_info['user_id']}}");
}
SC_END
-
+
SC_BEGIN AVATAR
-global $post_info;
-if ($post_info['user_id']) {
-if ($post_info["user_image"]) {
-require_once(e_HANDLER."avatar_handler.php");
-return "
";
-} else {
-return "";
+global $postInfo;
+if ($postInfo['post_user'])
+{
+ if(!$avatar = getcachedvars('forum_avatar_'.$postInfo['post_user']))
+ {
+ if ($postInfo['user_image'])
+ {
+ require_once(e_HANDLER.'avatar_handler.php');
+ $avatar = "
";
+ }
+ else
+ {
+ $avatar = '';
+ }
+ cachevars('forum_avatar_'.$postInfo['post_user'], $avatar);
+ }
+ return $avatar;
}
-} else {
-return "".LAN_194."";
+return '';
+SC_END
+
+SC_BEGIN ANON_IP
+global $postInfo;
+$e107 = e107::getInstance();
+if(ADMIN || MODERATOR)
+{
+ return $e107->ipDecode($postInfo['post_ip']);
}
SC_END
-
-SC_BEGIN ANON_IP
-global $post_info;
-//die($post_info['thread_user']);
-$x = explode(chr(1), $post_info['thread_user']);
-if($x[1] && ADMIN)
+
+SC_BEGIN IP
+global $postInfo;
+$e107 = e107::getInstance();
+if((ADMIN || MODERATOR) && !$postInfo['user_admin'])
{
- return $x[1];
+ return $e107->ipDecode($postInfo['post_ip']);
}
SC_END
SC_BEGIN POSTER
-global $post_info, $tp;
-if($post_info['user_name'])
+global $postInfo;
+$e107 = e107::getInstance();
+if($postInfo['user_name'])
{
- return "".$post_info['user_name']."";
+ return " 'profile', 'id' => $postInfo['post_user']))."'>{$postInfo['user_name']}";
}
else
{
- $x = explode(chr(1), $post_info['thread_user']);
- $tmp = explode(".", $x[0], 2);
- if(!$tmp[1])
- {
- return FORLAN_103;
- }
- else
- {
- return "".$tp->toHTML($tmp[1])."";
- }
+ return ''.$e107->tp->toHTML($postInfo['post_anon_name']).'';
}
SC_END
-
+
SC_BEGIN EMAILIMG
-global $post_info, $tp;
-if($post_info['user_id'])
+global $postInfo;
+$e107 = e107::getInstance();
+if($postInfo['user_name'])
{
- return (!$post_info['user_hideemail'] ? $tp->parseTemplate("{EMAILTO={$post_info['user_email']}}") : "");
+ return (!$post_info['user_hideemail'] ? $e107->tp->parseTemplate("{EMAILTO={$postInfo['user_email']}}") : '');
}
-return "";
+return '';
SC_END
-
+
SC_BEGIN EMAILITEM
global $post_info, $tp;
if($post_info['thread_parent'] == 0)
@@ -106,12 +113,13 @@ if($post_info['thread_parent'] == 0)
return $tp->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$post_info['thread_id']}}");
}
SC_END
-
+
SC_BEGIN SIGNATURE
-global $post_info, $tp;
-return ($post_info['user_signature'] ? "
".$tp->toHTML($post_info['user_signature'],TRUE)."" : "");
+global $postInfo;
+$e107 = e107::getInstance();
+return ($postInfo['user_signature'] ? "
".$e107->tp->toHTML($postInfo['user_signature'], true).'' : '');
SC_END
-
+
SC_BEGIN PROFILEIMG
global $post_info, $tp;
if (USER && $post_info['user_id']) {
@@ -120,70 +128,82 @@ return $tp->parseTemplate("{PROFILE={$post_info['user_id']}}");
return "";
}
SC_END
-
+
SC_BEGIN POSTS
-global $post_info;
-if ($post_info['user_id']) {
-return LAN_67.": ".$post_info['user_forums']."
";
+global $postInfo;
+if ($postInfo['post_user'])
+{
+ return LAN_67.': '.(int)$postInfo['user_plugin_forum_posts'].'
';
}
SC_END
-
+
SC_BEGIN VISITS
global $post_info;
if ($post_info['user_id']) {
return LAN_09.": ".$post_info['user_visits']."
";
}
SC_END
-
-SC_BEGIN EDITIMG
-global $post_info, $thread_info, $thread_id;
-if ($post_info['user_id'] != '0' && $post_info['user_name'] === USERNAME && $thread_info['head']['thread_active']) {
-return "".IMAGE_edit." ";
-} else {
-return "";
-}
-SC_END
-
+
SC_BEGIN CUSTOMTITLE
-global $post_info, $tp;
-if ($post_info['user_customtitle']) {
-return $tp->toHTML($post_info['user_customtitle'])."
";
+global $postInfo;
+$e107 = e107::getInstance();
+if ($postInfo['user_customtitle'])
+{
+ return $e107->tp->toHTML($postInfo['user_customtitle']).'
';
}
SC_END
-
+
SC_BEGIN WEBSITE
global $post_info, $tp;
if ($post_info['user_homepage']) {
return LAN_08.": ".$post_info['user_homepage']."
";
}
SC_END
-
+
SC_BEGIN WEBSITEIMG
global $post_info;
if ($post_info['user_homepage'] && $post_info['user_homepage'] != "http://") {
return "".IMAGE_website."";
}
SC_END
-
+
+SC_BEGIN EDITIMG
+global $postInfo, $threadInfo;
+$e107 = e107::getInstance();
+if (USER && $postInfo['post_user'] == USERID && $threadInfo['thread_active'])
+{
+ return " 'edit', 'id' => $postInfo['post_id']))."'>".IMAGE_edit.' ';
+}
+return '';
+SC_END
+
SC_BEGIN QUOTEIMG
-global $thread_info, $post_info, $forum_info;
-if (check_class($forum_info['forum_postclass']) && check_class($forum_info['parent_postclass']) && $thread_info["head"]["thread_active"]) {
-return "".IMAGE_quote."";
+global $postInfo, $forum;
+$e107 = e107::getInstance();
+if($forum->checkperm($postInfo['post_forum'], 'post'))
+{
+ return " 'quote', 'id' => $postInfo['post_id']))."'>".IMAGE_quote.' ';
}
SC_END
-
+
SC_BEGIN REPORTIMG
-global $post_info, $from;
+global $postInfo, $page;
if (USER) {
-return "".IMAGE_report." ";
+ $e107 = e107::getInstance();
+ $tmp = array (
+ 'func' => 'report',
+ 'id' => $postInfo['post_thread'],
+ 'report' => $postInfo['post_id']
+ );
+ return "".IMAGE_report.' ';
}
SC_END
-
+
SC_BEGIN RPG
global $post_info;
return rpg($post_info['user_join'],$post_info['user_forums']);
SC_END
-
+
SC_BEGIN MEMBERID
global $post_info, $ldata, $pref, $forum_info;
if ($post_info['anon']) {
@@ -200,7 +220,7 @@ if (!array_key_exists($post_info['user_id'],$ldata)) {
}
return $ldata[$post_info['user_id']][0];
SC_END
-
+
SC_BEGIN LEVEL
global $post_info, $ldata, $pref, $forum_info;
if ($post_info['anon']) {
@@ -232,19 +252,30 @@ return $ldata[$post_info['user_id']]['userid'];
}
return $ldata[$post_info['user_id']][1];
SC_END
-
+
SC_BEGIN MODOPTIONS
if (MODERATOR) {
return showmodoptions();
}
SC_END
-
+
SC_BEGIN LASTEDIT
-global $post_info, $gen;
-if ($post_info['thread_edit_datestamp']) {
-return $gen->convert_date($post_info['thread_edit_datestamp'],'forum');
+global $postInfo, $gen;
+if ($postInfo['post_edit_datestamp'])
+{
+ return $gen->convert_date($postInfo['thread_edit_datestamp'],'forum');
}
-return "";
+return '';
+SC_END
+
+SC_BEGIN LASTEDITBY
+global $postInfo;
+$e107 = e107::getInstance();
+if ($postInfo['post_edit_datestamp'])
+{
+ return $postInfo['edit_name'];
+}
+return '';
SC_END
SC_BEGIN POLL
diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php
index 45d82c4a3..18be1ff1f 100644
--- a/e107_plugins/forum/forum_viewtopic.php
+++ b/e107_plugins/forum/forum_viewtopic.php
@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
-| $Revision: 1.3 $
-| $Date: 2008-12-01 01:10:50 $
+| $Revision: 1.4 $
+| $Date: 2008-12-01 21:11:01 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -42,9 +42,10 @@ if (!e_QUERY)
exit;
}
+global $page;
$threadId = (int)varset($_GET['id']);
$perPage = (varset($_REQUEST['perpage']) ? (int)$_REQUEST['perpage'] : $pref['forum_postspage']);
-$start = (varset($_REQUEST['start']) ? (int)$_REQUEST['start'] : 0);
+$page = (varset($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0);
// $tmp = explode(".", e_QUERY);
// $thread_id = varset($tmp[0]);
@@ -61,14 +62,15 @@ if (!$threadId || !$threadInfo = $forum->threadGet($threadId))
exit;
}
-if(!in_array($threadInfo['thread_forum_id'], $forum->permList['view']))
+
+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);
+//print_a($forum->permList);
//die('here');
if($topic_from === 'post')
@@ -205,7 +207,14 @@ if ($topic_from === 'last')
}
$gen = new convert;
//$thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']);
-$postList = $forum->PostGet($threadId, $start, $perPage);
+$postList = $forum->PostGet($threadId, $page * $perPage, $perPage);
+
+//Only increment thread views if not being viewed by thread starter
+if(!USER || USER != $threadInfo['thread_user'])
+{
+ $forum->threadIncview($threadId);
+}
+
print_a($postList);
//if(intval($thread_info['head']['thread_forum_id']) == 0)
//{
@@ -238,7 +247,6 @@ if (MODERATOR)
$thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']);
}
}
-$forum->threadIncview($threadId);
require_once(HEADERF);
require_once(e_HANDLER.'level_handler.php');
@@ -275,47 +283,51 @@ if (!$FORUMSTART) {
}
}
-$forum_info['forum_name'] = $e107->tp->toHTML($forum_info['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 -------------------------------------------------------------------------------------------------------------------------------------------------------------------
-$forum->set_crumb(TRUE); // Set $BREADCRUMB (and BACKLINK)
+//$e107->url->getUrl('forum', 'thread', array('func' => 'next', 'id' => $threadId))
+$forum->set_crumb(true); // Set $BREADCRUMB (and BACKLINK)
$THREADNAME = $e107->tp->toHTML($threadInfo['thread_name'], true, 'no_hook, emotes_off');
-$NEXTPREV = "<< ".LAN_389."";
-$NEXTPREV .= " | ";
-$NEXTPREV .= "".LAN_390." >>";
+$NEXTPREV = "<< 'prev', 'id' => $threadId))."'>".LAN_389."";
+$NEXTPREV .= ' | ';
+$NEXTPREV .= " 'next', 'id' => $threadId))."'>".LAN_390." >>";
if ($pref['forum_track'] && USER)
{
if($forum->track('check', USERID, $threadId))
{
- $TRACK = "".LAN_392."";
+ $TRACK = " 'untrack', 'id' => $threadId))."'>".LAN_392."";
}
else
{
- $TRACK = "".LAN_391."";
+ $TRACK = " 'track', 'id' => $threadId))."'>".LAN_391."";
}
}
$MODERATORS = LAN_321.implode(", ", $modArray);
-$THREADSTATUS = (!$thread_info['head']['thread_active'] ? LAN_66 : "");
+$THREADSTATUS = (!$threadInfo['thread_active'] ? LAN_66 : '');
+
+//$pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);
+
+$pages = ceil(($threadInfo['thread_total_replies']+1) / $perPage);
-$pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);
-$pages = ceil(($replies+1)/$pref['forum_postspage']);
if ($pages > 1)
{
- $parms = ($replies+1).",{$pref['forum_postspage']},{$topic_from},".e_SELF.'?'.$thread_id.'.[FROM],off';
+ $parms = ($threadInfo['thread_total_replies']+1).",{$perPage},{$topic_from},".e_SELF.'?'.$thread_id.'.[FROM],off';
$GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}");
}
-if ((check_class($forum_info['forum_postclass']) && check_class($forum_info['parent_postclass'])) || MODERATOR)
+$BUTTONS = '';
+if($forum->checkPerm($threadInfo['thread_forum_id'], 'post') && $threadInfo['thread_active'])
{
- if ($thread_info['head']['thread_active'])
- {
- $BUTTONS = "".IMAGE_reply."";
- }
- $BUTTONS .= "".IMAGE_newthread."";
+ $BUTTONS .= " 'rp', 'id' => $threadId))."'>".IMAGE_reply."";
+}
+if($forum->checkPerm($threadInfo['thread_forum_id'], 'thread'))
+{
+ $BUTTONS .= " 'nt', 'id' => $threadInfo['thread_forum_id']))."'>".IMAGE_newthread."";
}
$POLL = $pollstr;
@@ -326,44 +338,51 @@ $forstr = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMSTART);
unset($forrep);
if (!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE;
-$alt = FALSE;
-for($i = 0; $i < count($thread_info)-1; $i++)
+$alt = false;
+//for($i = 0; $i < count($thread_info)-1; $i++)
+
+$i=$page;
+global $postInfo;
+foreach($postList as $postInfo)
{
- unset($post_info);
- $post_info = $thread_info[$i];
- $loop_uid = intval($post_info['user_id']);
- if (!$post_info['thread_user'])
+ 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'] = TRUE;
+ $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;
$e_hide_hidden = FORLAN_HIDDEN;
$e_hide_allowed = USER;
- if($post_info['thread_parent'])
+ if($i > 1)
{
$alt = !$alt;
if(isset($FORUMREPLYSTYLE_ALT) && $alt)
{
- $forrep .= $tp->parseTemplate($FORUMREPLYSTYLE_ALT, TRUE, $forum_shortcodes)."\n";
+ $forrep .= $tp->parseTemplate($FORUMREPLYSTYLE_ALT, true, $forum_shortcodes)."\n";
}
else
{
- $forrep .= $tp->parseTemplate($FORUMREPLYSTYLE, TRUE, $forum_shortcodes)."\n";
+ $forrep .= $tp->parseTemplate($FORUMREPLYSTYLE, true, $forum_shortcodes)."\n";
}
}
else
{
- $forthr = $tp->parseTemplate($FORUMTHREADSTYLE, TRUE, $forum_shortcodes)."\n";
+ $forthr = $tp->parseTemplate($FORUMTHREADSTYLE, true, $forum_shortcodes)."\n";
}
}
unset($loop_uid);
@@ -388,9 +407,12 @@ if ($thread_info['head']['thread_lastpost'] > USERLV && (strpos(USERVIEWED, ".{$
$tst = $forum->thread_markasread($thread_info['head']['thread_id']);
}
-if ($pref['forum_enclose']) {
+if ($pref['forum_enclose'])
+{
$ns->tablerender(LAN_01, $forumstring, array('forum_viewtopic', 'main'));
-} else {
+}
+else
+{
echo $forumstring;
}
diff --git a/e107_plugins/forum/url/thread.php b/e107_plugins/forum/url/thread.php
index 15a18a492..a00c5dae8 100755
--- a/e107_plugins/forum/url/thread.php
+++ b/e107_plugins/forum/url/thread.php
@@ -1,21 +1,55 @@