1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 21:27:25 +02:00

Forum progress

This commit is contained in:
mcfly
2008-12-01 21:11:01 +00:00
parent 3fc1ac2ffa
commit 1072b355ce
5 changed files with 328 additions and 210 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
| $Revision: 1.13 $ | $Revision: 1.14 $
| $Date: 2008-12-01 01:10:50 $ | $Date: 2008-12-01 21:11:01 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -119,6 +119,9 @@ class e107forum
*/ */
function postAdd($postInfo, $updateThread = true, $updateForum = true) function postAdd($postInfo, $updateThread = true, $updateForum = true)
{ {
//Future option, will just set to true here
$addUserPostCount = true;
$e107 = e107::getInstance(); $e107 = e107::getInstance();
$result = $e107->sql->db_Insert('forum_post', $postInfo, true); $result = $e107->sql->db_Insert('forum_post', $postInfo, true);
$forumInfo = array(); $forumInfo = array();
@@ -149,6 +152,7 @@ class e107forum
$result = $e107->sql->db_Update('forum_thread', $threadInfo, true); $result = $e107->sql->db_Update('forum_thread', $threadInfo, true);
} }
if($result && $updateForum) if($result && $updateForum)
{ {
if(varset($postInfo['post_user'])) if(varset($postInfo['post_user']))
@@ -178,6 +182,17 @@ class e107forum
$forumInfo['WHERE'] = 'forum_id = '.$postInfo['post_forum']; $forumInfo['WHERE'] = 'forum_id = '.$postInfo['post_forum'];
$result = $e107->sql->db_Update('forum', $forumInfo, true); $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) function threadAdd($threadInfo, $postInfo)
@@ -238,21 +253,30 @@ class e107forum
function postGet($threadId, $start, $num) function postGet($threadId, $start, $num)
{ {
$ret = false;
$e107 = e107::getInstance(); $e107 = e107::getInstance();
$qry = ' $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 FROM `#forum_post` AS p
LEFT JOIN `#user` AS u ON p.post_user = u.user_id 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." WHERE p.post_thread = '.$threadId."
ORDER BY p.post_datestamp ASC ORDER BY p.post_datestamp ASC
LIMIT {$start}, {$num} LIMIT {$start}, {$num}
"; ";
if($e107->sql->db_Select_gen($qry, true)) 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) function thread_postnum($thread_id)
@@ -1140,9 +1164,9 @@ class e107forum
* $forum_href override ONLY applies when template is missing FORUM_CRUMB * $forum_href override ONLY applies when template is missing FORUM_CRUMB
* $thread_title is needed for post-related breadcrumbs * $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 global $BREADCRUMB,$BACKLINK; // Eventually we should deprecate BACKLINK
if(is_array($FORUM_CRUMB)) if(is_array($FORUM_CRUMB))

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $
| $Revision: 1.20 $ | $Revision: 1.21 $
| $Date: 2008-12-01 01:10:50 $ | $Date: 2008-12-01 21:11:01 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -41,33 +41,27 @@ if (!e_QUERY || !isset($_REQUEST['id']))
$action = $_REQUEST['f']; $action = $_REQUEST['f'];
$id = (int)$_REQUEST['id']; $id = (int)$_REQUEST['id'];
// check if user can post to this forum ...
if (!$forum->checkPerm($id, 'post'))
{
require_once(HEADERF);
$ns->tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>");
require_once(FOOTERF);
exit;
}
switch($action) switch($action)
{ {
case 'rp': case 'rp':
$thread_info = $forum->thread_get($id, 'last', 11); $threadInfo = $forum->threadGet($id, false);
if (!is_array($thread_info) || !count($thread_info)) $forumId = $threadInfo['thread_forum_id'];
{ print_a($threadInfo);
$forum_info = false; // Someone fed us a dud forum id - should exist if replying // if (!is_array($thread_info) || !count($thread_info))
} // {
else // $forum_info = false; // Someone fed us a dud forum id - should exist if replying
{ // }
$forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']); // else
} // {
$forum_id = $forum_info['forum_id']; // $forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
// }
// $forum_id = $forum_info['forum_id'];
break; break;
case 'nt': case 'nt':
$forum_info = $forum->forum_get($id); $forum_info = $forum->forum_get($id);
$forum_id = $id; $forumId = $id;
break; break;
case 'quote': case 'quote':
@@ -78,8 +72,22 @@ switch($action)
{ {
$id = $thread_info['head']['thread_id']; $id = $thread_info['head']['thread_id'];
} }
$forum_id = $forum_info['forum_id']; $forumId = $forum_info['forum_id'];
break; 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, "<div style='text-align:center'>".LAN_399.'</div>');
require_once(FOOTERF);
exit;
} }
define("MODERATOR", check_class($forum_info['forum_moderators'])); 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 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); require_once(HEADERF);
$ns->tablerender(LAN_20, "<div style='text-align:center'>".LAN_397."</div>"); $ns->tablerender(LAN_20, "<div style='text-align:center'>".LAN_397.'</div>');
require_once(FOOTERF); require_once(FOOTERF);
exit; exit;
} }
$forum_info['forum_name'] = $tp->toHTML($forum_info['forum_name'], true); $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; $eaction = TRUE;
} }
else if($action == "quote") else if($action == 'quote')
{ {
$action = "reply"; $action = 'reply';
$eaction = FALSE; $eaction = false;
} }
} }
@@ -211,7 +219,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
$threadInfo = array(); $threadInfo = array();
if ((isset($_POST['newthread']) && trim($_POST['subject']) == '') || trim($_POST['post']) == '') if ((isset($_POST['newthread']) && trim($_POST['subject']) == '') || trim($_POST['post']) == '')
{ {
message_handler("ALERT", 5); message_handler('ALERT', 5);
} }
else else
{ {
@@ -238,7 +246,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
} }
$time = time(); $time = time();
$postInfo['post_entry'] = $_POST['post']; $postInfo['post_entry'] = $_POST['post'];
$postInfo['post_forum'] = $forum_id; $postInfo['post_forum'] = $forumId;
$postInfo['post_datestamp'] = $time; $postInfo['post_datestamp'] = $time;
$threadInfo['thread_lastpost'] = $time; $threadInfo['thread_lastpost'] = $time;
@@ -443,36 +451,36 @@ if (!$FORUMPOST)
include_once(e_PLUGIN."forum/templates/forum_post_template.php"); 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}'")) /* check post access (bugtracker #1424) */
{ //if($action == "rp" && !$sql -> db_Select("forum_t", "*", "thread_id='{$id}'"))
$ns -> tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>"); //{
require_once(FOOTERF); // $ns -> tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>");
exit; // require_once(FOOTERF);
} // exit;
elseif($action == "nt") //}
{ //elseif($action == "nt")
if (!$sact && !$sql -> db_Select("forum", "*", "forum_id='{$id}'")) //{
{ // if (!$sact && !$sql -> db_Select("forum", "*", "forum_id='{$id}'"))
$ns -> tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>"); // {
require_once(FOOTERF); // $ns -> tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>");
exit; // require_once(FOOTERF);
} // exit;
} // }
else //}
{ //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 // // DB access should pass - after all, the thread should exist
LEFT JOIN #forum AS p ON t.thread_forum_id=p.forum_id WHERE thread_id='{$id}'"); // $sql->db_Select_gen("SELECT t.*, p.forum_postclass FROM #forum_t AS t
$fpr = $sql -> db_Fetch(); // LEFT JOIN #forum AS p ON t.thread_forum_id=p.forum_id WHERE thread_id='{$id}'");
if(!check_class($fpr['forum_postclass'])) // $fpr = $sql -> db_Fetch();
{ // if(!check_class($fpr['forum_postclass']))
$ns -> tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>"); // {
require_once(FOOTERF); // $ns -> tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>");
exit; // require_once(FOOTERF);
} // exit;
} // }
//}
if($action == 'rp') if($action == 'rp')
{ {
@@ -493,9 +501,8 @@ else
function isAuthor() function isAuthor()
{ {
global $thread_info; global $threadInfo;
$tmp = explode(".", $thread_info[0]['thread_user'], 2); return ((USERID === $postInfo['post_user']) || MODERATOR);
return ($tmp[0] == USERID || MODERATOR);
} }
function getuser($name) function getuser($name)

View File

@@ -8,25 +8,23 @@ return "<a href='".e_SELF."?".e_QUERY."#top' onclick=\"window.scrollTo(0,0);\">"
SC_END SC_END
SC_BEGIN JOINED SC_BEGIN JOINED
global $post_info, $gen; global $postInfo, $gen;
if ($post_info['user_id']) { if ($postInfo['post_user'])
return LAN_06.': '.$gen->convert_date($post_info['user_join'], 'forum').'<br />'; {
return LAN_06.': '.$gen->convert_date($postInfo['user_join'], 'forum').'<br />';
} }
SC_END SC_END
SC_BEGIN THREADDATESTAMP SC_BEGIN THREADDATESTAMP
global $post_info, $gen, $thread_id; global $postInfo, $gen;
return "<a id='post_{$post_info['thread_id']}' href='".e_SELF."?{$post_info['thread_id']}.post'>".IMAGE_post."</a> ".$gen->convert_date($post_info['thread_datestamp'], "forum"); $e107 = e107::getInstance();
return "<a id='post_{$post_info['post_id']}' href='".$e107->url->getUrl('forum', 'thread', array('func' => 'post', 'id' => $postInfo['post_id']))."'>".IMAGE_post."</a> ".$gen->convert_date($postInfo['post_datestamp'], 'forum');
SC_END SC_END
SC_BEGIN POST SC_BEGIN POST
global $post_info, $tp, $iphost; global $postInfo;
$ret = ""; $e107 = e107::getInstance();
$ret = $tp->toHTML($post_info["thread_thread"], TRUE, "USER_BODY", 'class:'.$post_info["user_class"]); return $e107->tp->toHTML($postInfo['post_entry'], true, 'USER_BODY', 'class:'.$post_info['user_class']);
if (ADMIN && $iphost) {
$ret .= "<br />".$iphost;
}
return $ret;
SC_END SC_END
SC_BEGIN PRIVMESSAGE SC_BEGIN PRIVMESSAGE
@@ -38,57 +36,66 @@ if(isset($pref['plug_installed']['pm']) && ($post_info['user_id'] > 0))
SC_END SC_END
SC_BEGIN AVATAR SC_BEGIN AVATAR
global $post_info; global $postInfo;
if ($post_info['user_id']) { if ($postInfo['post_user'])
if ($post_info["user_image"]) { {
require_once(e_HANDLER."avatar_handler.php"); if(!$avatar = getcachedvars('forum_avatar_'.$postInfo['post_user']))
return "<div class='spacer'><img src='".avatar($post_info['user_image'])."' alt='' /></div><br />"; {
} else { if ($postInfo['user_image'])
return ""; {
} require_once(e_HANDLER.'avatar_handler.php');
} else { $avatar = "<div class='spacer'><img src='".avatar($postInfo['user_image'])."' alt='' /></div><br />";
return "<span class='smallblacktext'>".LAN_194."</span>"; }
else
{
$avatar = '';
}
cachevars('forum_avatar_'.$postInfo['post_user'], $avatar);
}
return $avatar;
} }
return '';
SC_END SC_END
SC_BEGIN ANON_IP SC_BEGIN ANON_IP
global $post_info; global $postInfo;
//die($post_info['thread_user']); $e107 = e107::getInstance();
$x = explode(chr(1), $post_info['thread_user']); if(ADMIN || MODERATOR)
if($x[1] && ADMIN)
{ {
return $x[1]; return $e107->ipDecode($postInfo['post_ip']);
}
SC_END
SC_BEGIN IP
global $postInfo;
$e107 = e107::getInstance();
if((ADMIN || MODERATOR) && !$postInfo['user_admin'])
{
return $e107->ipDecode($postInfo['post_ip']);
} }
SC_END SC_END
SC_BEGIN POSTER SC_BEGIN POSTER
global $post_info, $tp; global $postInfo;
if($post_info['user_name']) $e107 = e107::getInstance();
if($postInfo['user_name'])
{ {
return "<a href='".e_BASE."user.php?id.".$post_info['user_id']."'><b>".$post_info['user_name']."</b></a>"; return "<a href='".$e107->url->getUrl('core:user', 'main', array('func' => 'profile', 'id' => $postInfo['post_user']))."'>{$postInfo['user_name']}</a>";
} }
else else
{ {
$x = explode(chr(1), $post_info['thread_user']); return '<b>'.$e107->tp->toHTML($postInfo['post_anon_name']).'</b>';
$tmp = explode(".", $x[0], 2);
if(!$tmp[1])
{
return FORLAN_103;
}
else
{
return "<b>".$tp->toHTML($tmp[1])."</b>";
}
} }
SC_END SC_END
SC_BEGIN EMAILIMG SC_BEGIN EMAILIMG
global $post_info, $tp; global $postInfo;
if($post_info['user_id']) $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_END
SC_BEGIN EMAILITEM SC_BEGIN EMAILITEM
@@ -108,8 +115,9 @@ if($post_info['thread_parent'] == 0)
SC_END SC_END
SC_BEGIN SIGNATURE SC_BEGIN SIGNATURE
global $post_info, $tp; global $postInfo;
return ($post_info['user_signature'] ? "<br /><hr style='width:15%; text-align:left' /><span class='smalltext'>".$tp->toHTML($post_info['user_signature'],TRUE)."</span>" : ""); $e107 = e107::getInstance();
return ($postInfo['user_signature'] ? "<br /><hr style='width:15%; text-align:left' /><span class='smalltext'>".$e107->tp->toHTML($postInfo['user_signature'], true).'</span>' : '');
SC_END SC_END
SC_BEGIN PROFILEIMG SC_BEGIN PROFILEIMG
@@ -122,9 +130,10 @@ return "";
SC_END SC_END
SC_BEGIN POSTS SC_BEGIN POSTS
global $post_info; global $postInfo;
if ($post_info['user_id']) { if ($postInfo['post_user'])
return LAN_67.": ".$post_info['user_forums']."<br />"; {
return LAN_67.': '.(int)$postInfo['user_plugin_forum_posts'].'<br />';
} }
SC_END SC_END
@@ -135,19 +144,12 @@ return LAN_09.": ".$post_info['user_visits']."<br />";
} }
SC_END 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 "<a href='forum_post.php?edit.".$post_info['thread_id']."'>".IMAGE_edit."</a> ";
} else {
return "";
}
SC_END
SC_BEGIN CUSTOMTITLE SC_BEGIN CUSTOMTITLE
global $post_info, $tp; global $postInfo;
if ($post_info['user_customtitle']) { $e107 = e107::getInstance();
return $tp->toHTML($post_info['user_customtitle'])."<br />"; if ($postInfo['user_customtitle'])
{
return $e107->tp->toHTML($postInfo['user_customtitle']).'<br />';
} }
SC_END SC_END
@@ -165,17 +167,35 @@ return "<a href='{$post_info['user_homepage']}'>".IMAGE_website."</a>";
} }
SC_END SC_END
SC_BEGIN EDITIMG
global $postInfo, $threadInfo;
$e107 = e107::getInstance();
if (USER && $postInfo['post_user'] == USERID && $threadInfo['thread_active'])
{
return "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $postInfo['post_id']))."'>".IMAGE_edit.'</a> ';
}
return '';
SC_END
SC_BEGIN QUOTEIMG SC_BEGIN QUOTEIMG
global $thread_info, $post_info, $forum_info; global $postInfo, $forum;
if (check_class($forum_info['forum_postclass']) && check_class($forum_info['parent_postclass']) && $thread_info["head"]["thread_active"]) { $e107 = e107::getInstance();
return "<a href='".e_PLUGIN."forum/forum_post.php?quote.{$post_info['thread_id']}'>".IMAGE_quote."</a>"; if($forum->checkperm($postInfo['post_forum'], 'post'))
{
return "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'quote', 'id' => $postInfo['post_id']))."'>".IMAGE_quote.'</a> ';
} }
SC_END SC_END
SC_BEGIN REPORTIMG SC_BEGIN REPORTIMG
global $post_info, $from; global $postInfo, $page;
if (USER) { if (USER) {
return "<a href='".e_PLUGIN."forum/forum_viewtopic.php?{$post_info['thread_id']}.{$from}.report'>".IMAGE_report."</a> "; $e107 = e107::getInstance();
$tmp = array (
'func' => 'report',
'id' => $postInfo['post_thread'],
'report' => $postInfo['post_id']
);
return "<a href='".$e107->url->getUrl('forum', 'thread', $tmp)."'>".IMAGE_report.'</a> ';
} }
SC_END SC_END
@@ -240,11 +260,22 @@ return showmodoptions();
SC_END SC_END
SC_BEGIN LASTEDIT SC_BEGIN LASTEDIT
global $post_info, $gen; global $postInfo, $gen;
if ($post_info['thread_edit_datestamp']) { if ($postInfo['post_edit_datestamp'])
return $gen->convert_date($post_info['thread_edit_datestamp'],'forum'); {
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_END
SC_BEGIN POLL SC_BEGIN POLL

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
| $Revision: 1.3 $ | $Revision: 1.4 $
| $Date: 2008-12-01 01:10:50 $ | $Date: 2008-12-01 21:11:01 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -42,9 +42,10 @@ if (!e_QUERY)
exit; exit;
} }
global $page;
$threadId = (int)varset($_GET['id']); $threadId = (int)varset($_GET['id']);
$perPage = (varset($_REQUEST['perpage']) ? (int)$_REQUEST['perpage'] : $pref['forum_postspage']); $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); // $tmp = explode(".", e_QUERY);
// $thread_id = varset($tmp[0]); // $thread_id = varset($tmp[0]);
@@ -61,14 +62,15 @@ if (!$threadId || !$threadInfo = $forum->threadGet($threadId))
exit; 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'))); header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit; exit;
} }
print_a($threadInfo); print_a($threadInfo);
print_a($forum->permList); //print_a($forum->permList);
//die('here'); //die('here');
if($topic_from === 'post') if($topic_from === 'post')
@@ -205,7 +207,14 @@ if ($topic_from === 'last')
} }
$gen = new convert; $gen = new convert;
//$thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']); //$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); print_a($postList);
//if(intval($thread_info['head']['thread_forum_id']) == 0) //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']); $thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']);
} }
} }
$forum->threadIncview($threadId);
require_once(HEADERF); require_once(HEADERF);
require_once(e_HANDLER.'level_handler.php'); 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 ------------------------------------------------------------------------------------------------------------------------------------------------------------------- // 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'); $THREADNAME = $e107->tp->toHTML($threadInfo['thread_name'], true, 'no_hook, emotes_off');
$NEXTPREV = "&lt;&lt; <a href='".e_SELF."?{$thread_id}.{$forum_info['forum_id']}.prev'>".LAN_389."</a>"; $NEXTPREV = "&lt;&lt; <a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'prev', 'id' => $threadId))."'>".LAN_389."</a>";
$NEXTPREV .= " | "; $NEXTPREV .= ' | ';
$NEXTPREV .= "<a href='".e_SELF."?{$thread_id}.{$forum_info['forum_id']}.next'>".LAN_390."</a> &gt;&gt;"; $NEXTPREV .= "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'next', 'id' => $threadId))."'>".LAN_390."</a> &gt;&gt;";
if ($pref['forum_track'] && USER) if ($pref['forum_track'] && USER)
{ {
if($forum->track('check', USERID, $threadId)) if($forum->track('check', USERID, $threadId))
{ {
$TRACK = "<span class='smalltext'><a href='".e_SELF."?".$thread_id.".0."."untrack'>".LAN_392."</a></span>"; $TRACK = "<span class='smalltext'><a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'untrack', 'id' => $threadId))."'>".LAN_392."</a></span>";
} }
else else
{ {
$TRACK = "<span class='smalltext'><a href='".e_SELF."?".$thread_id.".0."."track'>".LAN_391."</a></span>"; $TRACK = "<span class='smalltext'><a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'track', 'id' => $threadId))."'>".LAN_391."</a></span>";
} }
} }
$MODERATORS = LAN_321.implode(", ", $modArray); $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) 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}}"); $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 .= "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'rp', 'id' => $threadId))."'>".IMAGE_reply."</a>";
{ }
$BUTTONS = "<a href='".e_PLUGIN."forum/forum_post.php?rp.".e_QUERY."'>".IMAGE_reply."</a>"; if($forum->checkPerm($threadInfo['thread_forum_id'], 'thread'))
} {
$BUTTONS .= "<a href='".e_PLUGIN."forum/forum_post.php?nt.".$forum_info['forum_id']."'>".IMAGE_newthread."</a>"; $BUTTONS .= "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'nt', 'id' => $threadInfo['thread_forum_id']))."'>".IMAGE_newthread."</a>";
} }
$POLL = $pollstr; $POLL = $pollstr;
@@ -326,44 +338,51 @@ $forstr = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMSTART);
unset($forrep); unset($forrep);
if (!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE; if (!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE;
$alt = FALSE; $alt = false;
for($i = 0; $i < count($thread_info)-1; $i++) //for($i = 0; $i < count($thread_info)-1; $i++)
$i=$page;
global $postInfo;
foreach($postList as $postInfo)
{ {
unset($post_info); print_a($postInfo);
$post_info = $thread_info[$i]; $loop_uid = (int)$postInfo['post_user'];
$loop_uid = intval($post_info['user_id']); $i++;
if (!$post_info['thread_user'])
/*
if (!$postInfo['user_name'])
{ {
// guest // guest
$tmp = explode(chr(1), $post_info['thread_anon']); $tmp = explode(chr(1), $post_info['thread_anon']);
$ip = $tmp[1]; $ip = $tmp[1];
$host = $e107->get_host_name($ip); $host = $e107->get_host_name($ip);
$post_info['iphost'] = "<div class='smalltext' style='text-align:right'>IP: <a href='".e_ADMIN."userinfo.php?$ip'>$ip ( $host )</a></div>"; $post_info['iphost'] = "<div class='smalltext' style='text-align:right'>IP: <a href='".e_ADMIN."userinfo.php?$ip'>$ip ( $host )</a></div>";
$post_info['anon'] = TRUE; $post_info['anon'] = false;
} }
else else
{ {
$post_info['anon'] = FALSE; $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_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_hidden = FORLAN_HIDDEN;
$e_hide_allowed = USER; $e_hide_allowed = USER;
if($post_info['thread_parent']) if($i > 1)
{ {
$alt = !$alt; $alt = !$alt;
if(isset($FORUMREPLYSTYLE_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 else
{ {
$forrep .= $tp->parseTemplate($FORUMREPLYSTYLE, TRUE, $forum_shortcodes)."\n"; $forrep .= $tp->parseTemplate($FORUMREPLYSTYLE, true, $forum_shortcodes)."\n";
} }
} }
else else
{ {
$forthr = $tp->parseTemplate($FORUMTHREADSTYLE, TRUE, $forum_shortcodes)."\n"; $forthr = $tp->parseTemplate($FORUMTHREADSTYLE, true, $forum_shortcodes)."\n";
} }
} }
unset($loop_uid); 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']); $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')); $ns->tablerender(LAN_01, $forumstring, array('forum_viewtopic', 'main'));
} else { }
else
{
echo $forumstring; echo $forumstring;
} }

View File

@@ -1,21 +1,55 @@
<?php <?php
// $Id: thread.php,v 1.3 2008-12-01 01:10:50 mcfly_e107 Exp $ // $Id: thread.php,v 1.4 2008-12-01 21:11:01 mcfly_e107 Exp $
function url_forum_thread($parms) function url_forum_thread($parms)
{ {
switch($parms['func']) switch($parms['func'])
{ {
case 'track':
return e_PLUGIN_ABS.'forum/forum.php?track';
break;
case 'nt': case 'nt':
return e_PLUGIN_ABS."forum/forum_post.php?f=nt&id={$parms['id']}"; return e_PLUGIN_ABS."forum/forum_post.php?f=nt&id={$parms['id']}";
break; break;
case 'rp':
return e_PLUGIN_ABS."forum/forum_post.php?f=rp&id={$parms['id']}";
break;
case 'view': case 'view':
return e_PLUGIN_ABS."forum/forum_viewtopic.php?id={$parms['id']}"; return e_PLUGIN_ABS."forum/forum_viewtopic.php?id={$parms['id']}";
break; break;
case 'post':
return e_PLUGIN_ABS."forum/forum_viewtopic.php?post={$parms['id']}";
break;
case 'report':
$page = (isset($parms['page']) ? (int)$parms['page'] : 0 );
return e_PLUGIN_ABS."forum/forum_viewtopic.php?id={$parms['id']}&report={$parms['report']}&page={$page}";
break;
case 'edit':
return e_PLUGIN_ABS."forum/forum_post.php?edit={$parms['id']}";
break;
case 'quote':
return e_PLUGIN_ABS."forum/forum_post.php?quote={$parms['id']}";
break;
case 'next':
return e_PLUGIN_ABS."forum/forum_viewtopic.php?next={$parms['id']}";
break;
case 'prev':
return e_PLUGIN_ABS."forum/forum_viewtopic.php?prev={$parms['id']}";
break;
case 'track':
return e_PLUGIN_ABS."forum/forum_viewtopic.php?track={$parms['id']}";
break;
case 'untrack':
return e_PLUGIN_ABS."forum/forum_viewtopic.php?untrack={$parms['id']}";
break;
} }
} }