diff --git a/e107_plugins/forum/forum.php b/e107_plugins/forum/forum.php
index fecea1d01..44d2122ca 100644
--- a/e107_plugins/forum/forum.php
+++ b/e107_plugins/forum/forum.php
@@ -1,20 +1,16 @@
PARENTSTATUS = $status[0];
- if ($status[1])
+ $pVars->PARENTSTATUS = $status;
+
+ $pVars->PARENTNAME = $parent['forum_name'];
+ $forum_string .= $tp->simpleParse($FORUM_MAIN_PARENT, $pVars);
+ if (!count($forumList['forums'][$parent['forum_id']]))
{
- $pVars->PARENTNAME = $parent['forum_name'];
- $forum_string .= $tp->simpleParse($FORUM_MAIN_PARENT, $pVars);
- if (!count($forumList['forums'][$parent['forum_id']]))
+ $text .= "
";
+ }
+ else
+ {
+//TODO: Rework the restricted string
+ foreach($forumList['forums'][$parent['forum_id']] as $f)
{
- $text .= "";
+ if ($f['forum_class'] == e_UC_ADMIN && ADMIN)
+ {
+ $forum_string .= parse_forum($f, LAN_406);
+ }
+ elseif($f['forum_class'] == e_UC_MEMBER && USER)
+ {
+ $forum_string .= parse_forum($f, LAN_407);
+ }
+ elseif($f['forum_class'] == e_UC_READONLY)
+ {
+ $forum_string .= parse_forum($f, LAN_408);
+ }
+ elseif($f['forum_class'] && check_class($f['forum_class']))
+ {
+ $forum_string .= parse_forum($f, LAN_409);
+ }
+ elseif(!$f['forum_class'])
+ {
+ $forum_string .= parse_forum($f);
+ }
}
- else
+ if (isset($FORUM_MAIN_PARENT_END))
{
- foreach($forumList['forums'][$parent['forum_id']] as $f)
- {
- if ($f['forum_class'] == e_UC_ADMIN && ADMIN)
- {
- $forum_string .= parse_forum($f, LAN_406);
- }
- elseif($f['forum_class'] == e_UC_MEMBER && USER)
- {
- $forum_string .= parse_forum($f, LAN_407);
- }
- elseif($f['forum_class'] == e_UC_READONLY)
- {
- $forum_string .= parse_forum($f, LAN_408);
- }
- elseif($f['forum_class'] && check_class($f['forum_class']))
- {
- $forum_string .= parse_forum($f, LAN_409);
- }
- elseif(!$f['forum_class'])
- {
- $forum_string .= parse_forum($f);
- }
- }
- if (isset($FORUM_MAIN_PARENT_END))
- {
- $forum_string .= $tp->simpleParse($FORUM_MAIN_PARENT_END, $pVars);
- }
+ $forum_string .= $tp->simpleParse($FORUM_MAIN_PARENT_END, $pVars);
}
}
}
function parse_parent($parent)
{
- if(check_class($parent['forum_class']))
+ if(!check_class($parent['forum_postclass']))
{
- $status[0] = '';
- $status[1] = true;
- if(!check_class($parent['forum_postclass']))
- {
- $status[0] = '( '.LAN_405.' )';
- }
- }
- else
- {
- $status[1] = false;
+ $status = '( '.LAN_405.' )';
}
return $status;
}
@@ -335,7 +321,7 @@ function parse_forum($f, $restricted_string = '')
list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']);
if ($f['user_name'])
{
-
+
$lastpost_name = "{$f['user_name']}";
}
else
@@ -444,11 +430,11 @@ if (e_QUERY == 'new')
{
$nVars->NEWSPOSTNAME = LAN_198;
$forum_newstring = $e107->tp->simpleParse($FORUM_NEWPOSTS_MAIN, $nVars);
-
+
}
$forum_new_start = $e107->tp->simpleParse($FORUM_NEWPOSTS_START, $nVars);
$forum_new_end = $e107->tp->simpleParse($FORUM_NEWPOSTS_END, $nVars);
-
+
if ($forum->prefs->get('enclose'))
{
$ns->tablerender($forum->prefs->get('title'), $forum_new_start.$forum_newstring.$forum_new_end, array('forum', 'main2'));
diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php
index d44948d35..b7d564064 100644
--- a/e107_plugins/forum/forum_class.php
+++ b/e107_plugins/forum/forum_class.php
@@ -70,7 +70,6 @@ class e107forum
$this->getForumPermList();
$tmp = $e107->arrayStorage->WriteArray($this->permList, false);
$e107->ecache->set_sys('forum_perms', $tmp);
-
}
unset($tmp);
}
@@ -98,21 +97,21 @@ class e107forum
$qryList = array();
$qryList['view'] = "
- SELECT f.forum_id
+ SELECT f.forum_id, f.forum_parent
FROM `#forum` AS f
LEFT JOIN `#forum` AS fp ON f.forum_parent = fp.forum_id AND fp.forum_class IN (".USERCLASS_LIST.")
WHERE f.forum_class IN (".USERCLASS_LIST.") AND f.forum_parent != 0 AND fp.forum_id IS NOT NULL
";
$qryList['post'] = "
- SELECT f.forum_id
+ SELECT f.forum_id, f.forum_parent
FROM `#forum` AS f
LEFT JOIN `#forum` AS fp ON f.forum_parent = fp.forum_id AND fp.forum_postclass IN (".USERCLASS_LIST.")
WHERE f.forum_postclass IN (".USERCLASS_LIST.") AND f.forum_parent != 0 AND fp.forum_id IS NOT NULL
";
$qryList['thread'] = "
- SELECT f.forum_id
+ SELECT f.forum_id, f.forum_parent
FROM `#forum` AS f
LEFT JOIN `#forum` AS fp ON f.forum_parent = fp.forum_id AND fp.forum_threadclass IN (".USERCLASS_LIST.")
WHERE f.forum_threadclass IN (".USERCLASS_LIST.") AND f.forum_parent != 0 AND fp.forum_id IS NOT NULL
@@ -122,10 +121,15 @@ class e107forum
{
if($e107->sql->db_Select_gen($qry))
{
- while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
+ $tmp = array();
+ while($row = $e107->sql->db_Fetch())
{
- $this->permList[$key][] = $row['forum_id'];
+ $tmp[$row['forum_id']] = 1;
+ $tmp[$row['forum_parent']] = 1;
}
+ ksort($tmp);
+ $this->permList[$key] = array_keys($tmp);
+ $this->permList[$key.'_list'] = implode(',', array_keys($tmp));
}
}
}
@@ -698,18 +702,20 @@ class e107forum
return ($uid && in_array($uid, array_keys($this->modArray)));
}
- function forumGetForumList()
+ function forumGetForumList($all=false)
{
$e107 = e107::getInstance();
+ $where = ($all ? '' : " WHERE forum_id IN ({$this->permList['view_list']}) ");
+
$qry = '
SELECT f.*, u.user_name FROM `#forum` AS f
LEFT JOIN `#user` AS u ON f.forum_lastpost_user IS NOT NULL AND u.user_id = f.forum_lastpost_user
- ORDER BY f.forum_order ASC
- ';
+ '.$where.
+ 'ORDER BY f.forum_order ASC';
if ($e107->sql->db_Select_gen($qry))
{
$ret = array();
- while ($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
+ while ($row = $e107->sql->db_Fetch())
{
if(!$row['forum_parent'])
{
@@ -717,7 +723,6 @@ class e107forum
}
elseif($row['forum_sub'])
{
-// $ret['subs'][$row['forum_parent']][$row['forum_sub']][] = $row;
$ret['subs'][$row['forum_sub']][] = $row;
}
else
@@ -875,8 +880,9 @@ class e107forum
return $result;
}
- function forum_get($forum_id)
+ function forumGet($forum_id)
{
+ $sql = e107::getDb();
$forum_id = (int)$forum_id;
$qry = "
SELECT f.*, fp.forum_class as parent_class, fp.forum_name as parent_name, fp.forum_id as parent_id, fp.forum_postclass as parent_postclass, sp.forum_name AS sub_parent FROM #forum AS f
@@ -884,7 +890,6 @@ class e107forum
LEFT JOIN #forum AS sp ON f.forum_sub = sp.forum_id AND f.forum_sub > 0
WHERE f.forum_id = {$forum_id}
";
- global $sql;
if ($sql->db_Select_gen($qry))
{
return $sql->db_Fetch(MYSQL_ASSOC);
diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php
index 1b15164f6..5ea9525ec 100644
--- a/e107_plugins/forum/forum_post.php
+++ b/e107_plugins/forum/forum_post.php
@@ -42,7 +42,7 @@ switch($action)
break;
case 'nt':
- $forumInfo = $forum->forum_get($id);
+ $forumInfo = $forum->forumGet($id);
$forumId = $id;
break;
diff --git a/e107_plugins/forum/forum_viewforum.php b/e107_plugins/forum/forum_viewforum.php
index 6855af8ff..6bdfdbf2d 100644
--- a/e107_plugins/forum/forum_viewforum.php
+++ b/e107_plugins/forum/forum_viewforum.php
@@ -8,10 +8,8 @@
*
* View specific forums
*
-* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewforum.php,v $
-* $Revision$
-* $Date$
-* $Author$
+* $URL$
+* $Id$
*
*/
@@ -55,11 +53,9 @@ if (!$forum->checkPerm($forumId, 'view'))
exit;
}
-$forumInfo = $forum->forum_get($forumId);
+$forumInfo = $forum->forumGet($forumId);
$threadsViewed = $forum->threadGetUserViewed();
-//var_dump($forumInfo);
-
if (!$FORUM_VIEW_START)
{
if (file_exists(THEME.'forum_viewforum_template.php'))
@@ -471,22 +467,22 @@ function parse_thread($thread_info)
$tVars->REPLIES = LAN_317; // 'None'
$tVars->LASTPOST = ' - ';
}
-
+
switch($thread_info['thread_sticky'])
{
case 1:
$_TEMPLATE = ($FORUM_VIEW_FORUM_STICKY ? $FORUM_VIEW_FORUM_STICKY : $FORUM_VIEW_FORUM);
break;
-
+
case 2:
$_TEMPLATE = ($FORUM_VIEW_FORUM_ANNOUNCE ? $FORUM_VIEW_FORUM_ANNOUNCE : $FORUM_VIEW_FORUM);
break;
-
+
default:
$_TEMPLATE = $FORUM_VIEW_FORUM;
break;
}
-
+
return $tp->simpleParse($_TEMPLATE, $tVars);
}
@@ -502,7 +498,7 @@ function parse_sub($subInfo)
$tVars->SUB_REPLIES = $subInfo['forum_replies'];
if(USER && is_array($newflag_list) && in_array($subInfo['forum_id'], $newflag_list))
{
-
+
$tVars->NEWFLAG = "".IMAGE_new.'';
}
else
diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php
index 3660bf492..ddebdf374 100644
--- a/e107_plugins/forum/forum_viewtopic.php
+++ b/e107_plugins/forum/forum_viewtopic.php
@@ -8,16 +8,13 @@
*
* Forum View Topic
*
- * $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
- * $Revision$
- * $Date$
- * $Author$
+ * $URL$
+ * $Id$
*
*/
require_once ('../../class2.php');
-
if (isset($_POST['fjsubmit']))
{
header('location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $_POST['forumjump'])));
@@ -51,7 +48,6 @@ if(isset($_POST['track_toggle']))
$thread->toggle_track();
exit;
}
-//print_a($_POST);
if(isset($_GET['f']))
{