diff --git a/class2.php b/class2.php
index 8e5d10821..1715c5b57 100644
--- a/class2.php
+++ b/class2.php
@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/class2.php,v $
-| $Revision: 1.79 $
-| $Date: 2008-11-30 23:15:15 $
+| $Revision: 1.80 $
+| $Date: 2008-12-01 01:10:50 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -1265,7 +1265,7 @@ function get_user_data($uid, $extra = '')
}
}
}
- $tmp = $e107->arrayStorage->WriteArray($extended_struct);
+ $tmp = $e107->arrayStorage->WriteArray($extended_struct, false);
$e107->ecache->set_sys('nomd5_extended_struct', $tmp);
unset($tmp);
}
diff --git a/e107_plugins/forum/forum.php b/e107_plugins/forum/forum.php
index e7bf8e29d..91efaaec1 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.5 $
-| $Date: 2008-11-26 04:00:36 $
+| $Revision: 1.6 $
+| $Date: 2008-12-01 01:10:50 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -305,7 +305,7 @@ function parse_forum($f, $restricted_string = "")
$f['forum_name'] = $tp -> toHTML($f['forum_name'], TRUE, "no_hook");
$f['forum_description'] = $tp -> toHTML($f['forum_description'], TRUE, "no_hook");
- $FORUMNAME = "{$f['forum_name']}";
+ $FORUMNAME = "{$f['forum_name']}";
$FORUMDESCRIPTION = $f['forum_description'].($restricted_string ? "
$restricted_string" : "");
$THREADS = $f['forum_threads'];
$REPLIES = $f['forum_replies'];
diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php
index a6247e293..3271a7235 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.12 $
-| $Date: 2008-11-30 22:05:12 $
+| $Revision: 1.13 $
+| $Date: 2008-12-01 01:10:50 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -56,7 +56,7 @@ class e107forum
else
{
$this->getForumPermList();
- $tmp = $e107->arrayStorage->WriteArray($this->permList);
+ $tmp = $e107->arrayStorage->WriteArray($this->permList, false);
$e107->ecache->set_sys('forum_perms', $tmp);
}
@@ -195,8 +195,66 @@ class e107forum
function threadUpdate($threadInfo, $inc)
{
$e107 = e107::getInstance();
+ //TODO: Add this
}
+
+ function threadGet($id, $joinForum = true, $uid = USERID)
+ {
+ $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
+ $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.'
+ WHERE thread_id = '.$id;
+ }
+ else
+ {
+ $qry = '
+ SELECT *
+ FROM `#forum_thread`
+ WHERE thread_id = '.$id;
+ }
+ if($e107->sql->db_Select_gen($qry, true))
+ {
+ $tmp = $e107->sql->db_Fetch(MYSQL_ASSOC);
+ if($tmp)
+ {
+ if(trim($tmp['thread_options']) != '')
+ {
+ $tmp['thread_options'] = inserialize($tmp['thread_options']);
+ }
+ return $tmp;
+ }
+ }
+ return false;
+ }
+
+ function postGet($threadId, $start, $num)
+ {
+ $e107 = e107::getInstance();
+ $qry = '
+ SELECT p.*, u.user_name, u.user_customtitle, 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
+ 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);
+ }
+ return false;
+ }
+
function thread_postnum($thread_id)
{
global $sql;
@@ -465,7 +523,7 @@ class e107forum
function track($which, $uid, $threadId)
{
- global $e107;
+ $e107 = e107::getInstance();
$threadId = (int)$threadId;
$uid = (int)$uid;
$result = false;
@@ -481,8 +539,12 @@ class e107forum
case 'delete':
case 'del':
- $result = $e107->sql->db_Delete('forum_track', 'WHERE `track_userid` = {$uid} AND `track_thread');
+ $result = $e107->sql->db_Delete('forum_track', "`track_userid` = {$uid} AND `track_thread` = {$threadId}");
break;
+
+ case 'check':
+ $result = $e107->sql->db_Count('forum_track', '(*)', "WHERE `track_userid` = {$uid} AND `track_thread` = {$threadId}");
+ break;
}
return $result;
}
@@ -789,11 +851,11 @@ class e107forum
return $ret;
}
- function thread_incview($thread_id)
+ function threadIncView($id)
{
- $thread_id = intval($thread_id);
- global $sql;
- return $sql->db_Update("forum_t", "thread_views=thread_views+1 WHERE thread_id=".$thread_id);
+ $e107 = e107::getInstance();
+ $id = (int)($id);
+ return $e107->sql->db_Update('forum_thread', 'thread_views=thread_views+1 WHERE thread_id='.$id);
}
diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php
index 19e2e0cc3..93329a2e6 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.19 $
-| $Date: 2008-11-29 01:24:27 $
+| $Revision: 1.20 $
+| $Date: 2008-12-01 01:10:50 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -242,7 +242,6 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
$postInfo['post_datestamp'] = $time;
$threadInfo['thread_lastpost'] = $time;
-
switch($action)
{
// Reply only. Add the post, update thread record with latest post info.
diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php
index fe7fb1bed..45d82c4a3 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.2 $
-| $Date: 2008-11-29 01:24:27 $
+| $Revision: 1.3 $
+| $Date: 2008-12-01 01:10:50 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -22,7 +22,6 @@ 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');
@@ -31,7 +30,7 @@ if (file_exists(THEME.'forum_design.php'))
$forum = new e107forum;
if (isset($_POST['fjsubmit']))
{
- header("location:".e_PLUGIN."forum/forum_viewforum.php?".$_POST['forumjump']);
+ header('location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id'=>$_POST['forumjump'])));
exit;
}
$highlight_search = isset($_POST['highlight_search']);
@@ -39,22 +38,39 @@ $highlight_search = isset($_POST['highlight_search']);
if (!e_QUERY)
{
//No paramters given, redirect to forum home
- header("Location:".e_PLUGIN."forum/forum.php");
+ header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
-else
+
+$threadId = (int)varset($_GET['id']);
+$perPage = (varset($_REQUEST['perpage']) ? (int)$_REQUEST['perpage'] : $pref['forum_postspage']);
+$start = (varset($_REQUEST['start']) ? (int)$_REQUEST['start'] : 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 || !$threadInfo = $forum->threadGet($threadId))
{
- $tmp = explode(".", e_QUERY);
- $thread_id = varset($tmp[0]);
- $topic_from = varset($tmp[1], 0);
- $action = varset($tmp[2]);
- if (!$thread_id || !is_numeric($thread_id))
- {
- header("Location:".e_PLUGIN."forum/forum.php");
- exit;
- }
+ header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
+ exit;
}
+if(!in_array($threadInfo['thread_forum_id'], $forum->permList['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)
@@ -70,28 +86,28 @@ if($topic_from === 'post')
}
else
{
- header("Location:".e_PLUGIN."forum/forum.php");
+ header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
}
require_once(e_PLUGIN.'forum/forum_shortcodes.php');
-if ($action == "track" && USER)
+if ($action == 'track' && USER)
{
$forum->track($thread_id);
header("location:".e_SELF."?{$thread_id}.{$topic_from}");
exit;
}
-if ($action == "untrack" && USER)
+if ($action == 'untrack' && USER)
{
$forum->untrack($thread_id);
header("location:".e_SELF."?{$thread_id}.{$topic_from}");
exit;
}
-if ($action == "next")
+if ($action == 'next')
{
$next = $forum->thread_getnext($thread_id, $topic_from);
if ($next)
@@ -108,26 +124,32 @@ if ($action == "next")
}
}
-if ($action == "prev") {
+if ($action == 'prev')
+{
$prev = $forum->thread_getprev($thread_id, $topic_from);
- if ($prev) {
+ if ($prev)
+ {
header("location:".e_SELF."?{$prev}");
exit;
- } else {
+ }
+ else
+ {
require_once(HEADERF);
$ns->tablerender('', LAN_404, array('forum_viewtopic', '404'));
require_once(FOOTERF);
exit;
}
-
}
-if ($action == "report") {
+if ($action == 'report')
+{
$thread_info = $forum->thread_get_postinfo($thread_id, TRUE);
- if (isset($_POST['report_thread'])) {
+ if (isset($_POST['report_thread']))
+ {
$report_add = $tp -> toDB($_POST['report_add']);
- if ($pref['reported_post_email']) {
+ 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;
@@ -138,7 +160,9 @@ if ($action == "report") {
require_once(HEADERF);
$text = LAN_424."
".LAN_429."tablerender(LAN_414, $text, array('forum_viewtopic', 'report'));
- } else {
+ }
+ 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);
@@ -169,38 +193,40 @@ if ($action == "report") {
require_once(FOOTERF);
exit;
}
-$pm_installed = ($pref['pm_title'] ? TRUE : FALSE);
+$pm_installed = plugInstalled('pm');
-$replies = $forum->thread_count($thread_id)-1;
-if ($topic_from === 'last') {
+//$replies = $forum->thread_count($thread_id)-1;
+
+if ($topic_from === 'last')
+{
$pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);
- $pages = ceil(($replies+1)/$pref['forum_postspage']);
+ $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']);
+//$thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']);
+$postList = $forum->PostGet($threadId, $start, $perPage);
+print_a($postList);
+//if(intval($thread_info['head']['thread_forum_id']) == 0)
+//{
+// require_once(HEADERF);
+// $ns->tablerender(LAN_01, FORLAN_104, array('forum_viewtopic', '104'));
+// require_once(FOOTERF);
+// exit;
+//}
-if(intval($thread_info['head']['thread_forum_id']) == 0)
-{
- require_once(HEADERF);
- $ns->tablerender(LAN_01, FORLAN_104, array('forum_viewtopic', '104'));
- require_once(FOOTERF);
- exit;
-}
-$forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
+//$forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
+//
+//if (!check_class($forum_info['forum_class']) || !check_class($forum_info['parent_class'])) {
+// header("Location:".e_PLUGIN."forum/forum.php");
+// exit;
+//}
-if (!check_class($forum_info['forum_class']) || !check_class($forum_info['parent_class'])) {
- header("Location:".e_PLUGIN."forum/forum.php");
- exit;
-}
-
-$forum->thread_incview($thread_id);
-
-define("e_PAGETITLE", LAN_01." / ".$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($forum_info['forum_name'], true, 'no_hook, emotes_off')." / ".$tp->toHTML($thread_info['head']['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']);
+define('MODERATOR', ($forum_info['forum_moderators'] != '' && check_class($forum_info['forum_moderators'])));
+//$modArray = $forum->forum_getmods($forum_info['forum_moderators']);
$message = '';
if (MODERATOR)
@@ -212,54 +238,63 @@ 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");
+require_once(e_HANDLER.'level_handler.php');
if ($message)
{
- $ns->tablerender("", $message, array('forum_viewtopic', 'msg'));
+ $ns->tablerender('', $message, array('forum_viewtopic', 'msg'));
}
-if (stristr($thread_info['head']['thread_name'], "[".LAN_430."]"))
+if(isset($threadInfo['thread_options']['poll']))
+//if (stristr($thread_info['head']['thread_name'], "[".LAN_430."]"))
{
- if(!defined("POLLCLASS"))
+ if(!defined('POLLCLASS'))
{
- require(e_PLUGIN."poll/poll_class.php");
+ include(e_PLUGIN.'poll/poll_class.php');
}
- $_qry = "SELECT * FROM #polls WHERE `poll_datestamp` = '{$thread_info['head']['thread_id']}'";
+ $_qry = 'SELECT * FROM `#polls` WHERE `poll_datestamp` = '.$threadId;
$poll = new poll;
- $pollstr = "