diff --git a/e107_plugins/forum/forum_admin_class.php b/e107_plugins/forum/forum_admin_class.php
index 97d33c140..998b83210 100755
--- a/e107_plugins/forum/forum_admin_class.php
+++ b/e107_plugins/forum/forum_admin_class.php
@@ -1,1117 +1,1118 @@
-db_Select("forum", "*", "forum_parent='0' "))
- {
- $var['create']['text'] = FORLAN_77;
- $var['create']['link'] = e_SELF."?create";
- }
- $var['order']['text'] = FORLAN_78;
- $var['order']['link'] = e_SELF."?order";
- $var['opt']['text'] = FORLAN_79;
- $var['opt']['link'] = e_SELF."?opt";
- $var['prune']['text'] = FORLAN_59;
- $var['prune']['link'] = e_SELF."?prune";
- $var['rank']['text'] = FORLAN_63;
- $var['rank']['link'] = e_SELF."?rank";
- $var['rules']['text'] = FORLAN_123;
- $var['rules']['link'] = e_SELF."?rules";
- $var['sr']['text'] = FORLAN_116;
- $var['sr']['link'] = e_SELF."?sr";
- $var['mods']['text'] = FORLAN_33;
- $var['mods']['link'] = e_SELF."?mods";
- $var['tools']['text'] = FORLAN_153;
- $var['tools']['link'] = e_SELF."?tools";
-
- show_admin_menu(FORLAN_7, $action, $var);
- }
-
- function delete_item($id)
- {
- global $sql;
- $id = intval($id);
- $confirm = isset($_POST['confirm']) ? TRUE : FALSE;
-
- if($sql->db_Select('forum', '*', "forum_id = {$id}"))
- {
- $txt = "";
- $row = $sql->db_Fetch();
- if($row['forum_parent'] == 0)
- {
- $txt .= $this->delete_parent($id, $confirm);
- }
- elseif($row['forum_sub'] > 0)
- {
- $txt .= $this->delete_sub($id, $confirm);
- }
- else
- {
- $txt .= $this->delete_forum($id, $confirm);
- }
- if($confirm)
- {
- $this->show_message($txt);
- }
- else
- {
- $this->delete_show_confirm($txt);
- }
- }
- }
-
- function delete_parent($id, $confirm = FALSE)
- {
- global $sql;
- $ret = "";
- if($sql->db_Select("forum", "forum_id", "forum_parent = {$id} AND forum_sub = 0"))
- {
- $fList = $sql->db_getList();
- foreach($fList as $f)
- {
- $ret .= $this->delete_forum($f['forum_id'], $confirm);
- }
- }
- if($confirm)
- {
- if($sql->db_Delete("forum", "forum_id = {$id}"))
- {
- $ret .= "Forum parent successfully deleted";
- }
- else
- {
- $ret .= "Forum parent could not be deleted";
- }
- return $ret;
- }
- return "The forum parent has the following info:
".$ret;
-
- }
-
- function delete_forum($id, $confirm = FALSE)
- {
- global $sql, $tp;
- $ret = "";
- if($sql->db_Select("forum", "forum_id", "forum_sub = {$id}"))
- {
- $fList = $sql->db_getList();
- foreach($fList as $f)
- {
- $ret .= $this->delete_sub($f['forum_id'], $confirm);
- }
- }
- if($confirm)
- {
- $cnt = $sql->db_Delete("forum_t","thread_forum_id = {$id}");
- $ret .= $cnt." forum {$id} thread(s) deleted
";
- if($sql->db_Delete("forum", "forum_id = {$id}"))
- {
- $ret .= "Forum {$id} successfully deleted";
- }
- else
- {
- $ret .= "Forum {$id} could not be deleted";
- }
- return $ret;
- }
-
- $sql->db_Select("forum", "*", "forum_id = {$id}");
- $row = $sql->db_Fetch();
- return "Forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies.
".$ret;
- }
-
- function delete_sub($id, $confirm = FALSE)
- {
- global $sql, $tp;
- if($confirm)
- {
- $cnt = $sql->db_Delete("forum_t","thread_forum_id = {$id}");
- $ret .= $cnt." Sub-forum {$id} thread(s) deleted
";
- if($sql->db_Delete("forum", "forum_id = {$id}"))
- {
- $ret .= "Sub-forum {$id} successfully deleted";
- }
- else
- {
- $ret .= "Sub-forum {$id} could not be deleted";
- }
- return $ret;
- }
-
- $sql->db_Select("forum", "*", "forum_id = {$id}");
- $row = $sql->db_Fetch();
- return "Sub-forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies.
".$ret;
- }
-
- function delete_show_confirm($txt)
- {
- global $ns;
- $this->show_message($txt);
- $txt = "
-
- ";
- $ns->tablerender(FORLAN_181, $txt);
- }
-
- function show_subs($id)
- {
- global $sql, $tp, $ns;
- $txt = "
-
- ";
- $ns->tablerender(FORLAN_149, $txt);
- }
-
- function show_existing_forums($sub_action, $id, $mode = false)
- {
- global $e107, $for;
-
- $subList = $for->forum_getsubs();
-
- if (!$mode)
- {
- $text = "";
- }
- else
- {
- $text = "
";
- $e107->ns->tablerender(FORLAN_30, $text);
- }
- else
- {
- $text .= "\n\n
\n\n";
- $e107->ns->tablerender(FORLAN_37, $text);
- }
-
- }
-
- function create_parents($sub_action, $id)
- {
- global $e107;
-
- $id = (int)$id;
- if ($sub_action == 'edit' && !$_POST['update_parent'])
- {
- if ($e107->sql->db_Select('forum', '*', "forum_id=$id"))
- {
- $row = $e107->sql->db_Fetch(MYSQL_ASSOC);
- }
- }
- $text = "";
-
- $e107->ns->tablerender(FORLAN_75, $text);
- }
-
- function create_forums($sub_action, $id)
- {
- global $e107;
-
- $id = (int)$id;
- if ($sub_action == 'edit' && !$_POST['update_forum'])
- {
- if ($e107->sql->db_Select('forum', '*', "forum_id=$id"))
- {
- $fInfo = $e107->sql->db_Fetch();
- }
- }
-
- $text = "";
- $e107->ns->tablerender(FORLAN_28, $text);
- }
-
- function show_message($message)
- {
- global $e107;
- $e107->ns->tablerender('', "".$message."
");
- }
-
- function show_tools()
- {
- global $sql, $ns, $tp;
- $txt = "
-
- ";
- $ns->tablerender(FORLAN_166, $txt);
- }
-
- function show_prefs()
- {
- global $pref, $ns, $sql;
-
- if($sql->db_Count('plugin','(*)', "where plugin_path = 'poll' AND plugin_installflag = 1"))
- {
- $poll_installed = true;
- }
- else
- {
- $poll_installed = false;
- if($pref['forum_poll'] == 1)
- {
- $pref['forum_poll'] = 0;
- save_prefs();
- }
- }
-
- $text = "";
- $ns->tablerender(FORLAN_62, $text);
- }
-
- function show_reported ($sub_action, $id)
- {
- global $sql, $rs, $ns, $tp;
- if ($sub_action) {
- $sql -> db_Select("generic", "*", "gen_id='".$sub_action."'");
- $row = $sql -> db_Fetch();
- $sql -> db_Select("user", "*", "user_id='". $row['gen_user_id']."'");
- $user = $sql -> db_Fetch();
- $con = new convert;
- $text = "
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\n";
- $text .= "
";
- $text .= "
";
- $ns -> tablerender(FORLAN_116, $text);
- } else {
- $text = "";
- if ($reported_total = $sql->db_Select("generic", "*", "gen_type='reported_post' OR gen_type='Reported Forum Post'"))
- {
- $text .= "
-
- ".FORLAN_170." |
- ".FORLAN_80." |
-
";
- while ($row = $sql->db_Fetch())
- {
- $text .= "
-
-
-
\n";
- }
- $text .= "
";
- }
- else
- {
- $text .= "
".FORLAN_121."
";
- }
- $text .= "
";
- $ns->tablerender(FORLAN_116, $text);
- }
- }
-
- function show_prune()
- {
- global $ns, $sql;
-
- // $sql -> db_Select("forum", "forum_id, forum_name", "forum_parent!=0 ORDER BY forum_order ASC");
- $qry = "
- SELECT f.forum_id, f.forum_name, sp.forum_name AS sub_parent, fp.forum_name AS forum_parent
- FROM #forum AS f
- LEFT JOIN #forum AS sp ON sp.forum_id = f.forum_sub
- LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent
- WHERE f.forum_parent != 0
- ORDER BY f.forum_parent ASC, f.forum_sub, f.forum_order ASC
- ";
- $sql -> db_Select_gen($qry);
- $forums = $sql -> db_getList();
-
- $text = "";
- $ns->tablerender(FORLAN_59, $text);
- }
-
- function show_levels()
- {
- global $sql, $pref, $ns, $rs;
-
- $rank_names = explode(",", $pref['forum_levels']);
- $rank_thresholds = ($pref['forum_thresholds'] ? explode(",", $pref['forum_thresholds']) : array(20, 100, 250, 410, 580, 760, 950, 1150, 1370, 1600));
- $rank_images = ($pref['forum_images'] ? explode(",", $pref['forum_images']) : array("lev1.png", "lev2.png", "lev3.png", "lev4.png", "lev5.png", "lev6.png", "lev7.png", "lev8.png", "lev9.png", "lev10.png"));
-
- $text = "";
- $ns->tablerender("Ranks", $text);
- }
-
- function show_mods()
- {
- global $sql, $ns, $for, $tp;
- $forumList = $for->forum_getforums('all');
- $parentList = $for->forum_getparents('list');
- $subList = $for->forum_getsubs('bysub');
-
- $txt = "";
- $ns->tablerender(FORLAN_33, $txt);
- }
-
- function show_rules()
- {
- global $sql, $pref, $ns, $tp;
-
- $sql->db_Select("wmessage");
- list($null) = $sql->db_Fetch();
- list($null) = $sql->db_Fetch();
- list($null) = $sql->db_Fetch();
- list($id, $guestrules, $wm_active4) = $sql->db_Fetch();
- list($id, $memberrules, $wm_active5) = $sql->db_Fetch();
- list($id, $adminrules, $wm_active6) = $sql->db_Fetch();
-
- if($sql->db_Select('generic','*',"gen_type='forum_rules_guest'"))
- {
- $guest_rules = $sql->db_Fetch();
- }
- if($sql->db_Select('generic','*',"gen_type='forum_rules_member'"))
- {
- $member_rules = $sql->db_Fetch();
- }
- if($sql->db_Select('generic','*',"gen_type='forum_rules_admin'"))
- {
- $admin_rules = $sql->db_Fetch();
- }
-
- $guesttext = $tp->toFORM($guest_rules['gen_chardata']);
- $membertext = $tp->toFORM($member_rules['gen_chardata']);
- $admintext = $tp->toFORM($admin_rules['gen_chardata']);
-
- $text = "
- ";
-
- $ns->tablerender(WMGLAN_5, $text);
-
- echo "
-
- ";
-
- }
- }
+db_Select('forum', 'forum_id', "forum_parent='0' LIMIT 1"))
+ {
+ $var['create']['text'] = FORLAN_77;
+ $var['create']['link'] = e_SELF."?create";
+ }
+ $var['order']['text'] = FORLAN_78;
+ $var['order']['link'] = e_SELF."?order";
+ $var['opt']['text'] = FORLAN_79;
+ $var['opt']['link'] = e_SELF."?opt";
+ $var['prune']['text'] = FORLAN_59;
+ $var['prune']['link'] = e_SELF."?prune";
+ $var['rank']['text'] = FORLAN_63;
+ $var['rank']['link'] = e_SELF."?rank";
+ $var['rules']['text'] = FORLAN_123;
+ $var['rules']['link'] = e_SELF."?rules";
+ $var['sr']['text'] = FORLAN_116;
+ $var['sr']['link'] = e_SELF."?sr";
+ $var['mods']['text'] = FORLAN_33;
+ $var['mods']['link'] = e_SELF."?mods";
+ $var['tools']['text'] = FORLAN_153;
+ $var['tools']['link'] = e_SELF."?tools";
+
+ show_admin_menu(FORLAN_7, $action, $var);
+ }
+
+ function delete_item($id)
+ {
+ global $sql;
+ $id = (int)$id;
+ $confirm = isset($_POST['confirm']) ? true : false;
+
+ if($sql->db_Select('forum', '*', "forum_id = {$id}"))
+ {
+ $txt = "";
+ $row = $sql->db_Fetch();
+ if($row['forum_parent'] == 0)
+ {
+ $txt .= $this->delete_parent($id, $confirm);
+ }
+ elseif($row['forum_sub'] > 0)
+ {
+ $txt .= $this->delete_sub($id, $confirm);
+ }
+ else
+ {
+ $txt .= $this->delete_forum($id, $confirm);
+ }
+ if($confirm)
+ {
+ $this->show_message($txt);
+ }
+ else
+ {
+ $this->delete_show_confirm($txt);
+ }
+ }
+ }
+
+ function delete_parent($id, $confirm = false)
+ {
+ global $sql;
+ $ret = "";
+ if($sql->db_Select('forum', 'forum_id', "forum_parent = {$id} AND forum_sub = 0"))
+ {
+ $fList = $sql->db_getList();
+ foreach($fList as $f)
+ {
+ $ret .= $this->delete_forum($f['forum_id'], $confirm);
+ }
+ }
+ if($confirm)
+ {
+ if($sql->db_Delete('forum', "forum_id = {$id}"))
+ {
+ $ret .= 'Forum parent successfully deleted';
+ }
+ else
+ {
+ $ret .= 'Forum parent could not be deleted';
+ }
+ return $ret;
+ }
+ return 'The forum parent has the following info:
'.$ret;
+
+ }
+
+ function delete_forum($id, $confirm = false)
+ {
+ global $sql, $tp;
+ $ret = '';
+ if($sql->db_Select('forum', 'forum_id', "forum_sub = {$id}"))
+ {
+ $fList = $sql->db_getList();
+ foreach($fList as $f)
+ {
+ $ret .= $this->delete_sub($f['forum_id'], $confirm);
+ }
+ }
+ if($confirm)
+ {
+ $cnt = $sql->db_Delete('forum_t',"thread_forum_id = {$id}");
+ $ret .= $cnt." forum {$id} thread(s) deleted
";
+ if($sql->db_Delete("forum", "forum_id = {$id}"))
+ {
+ $ret .= "Forum {$id} successfully deleted";
+ }
+ else
+ {
+ $ret .= "Forum {$id} could not be deleted";
+ }
+ return $ret;
+ }
+
+ $sql->db_Select('forum', 'forum_name, forum_threads, forum_replies', "forum_id = {$id}");
+ $row = $sql->db_Fetch();
+ return "Forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies.
".$ret;
+ }
+
+ function delete_sub($id, $confirm = FALSE)
+ {
+ global $sql, $tp;
+ if($confirm)
+ {
+ $cnt = $sql->db_Delete("forum_t","thread_forum_id = {$id}");
+ $ret .= $cnt." Sub-forum {$id} thread(s) deleted
";
+ if($sql->db_Delete("forum", "forum_id = {$id}"))
+ {
+ $ret .= "Sub-forum {$id} successfully deleted";
+ }
+ else
+ {
+ $ret .= "Sub-forum {$id} could not be deleted";
+ }
+ return $ret;
+ }
+
+ $sql->db_Select("forum", "*", "forum_id = {$id}");
+ $row = $sql->db_Fetch();
+ return "Sub-forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies.
".$ret;
+ }
+
+ function delete_show_confirm($txt)
+ {
+ global $ns;
+ $this->show_message($txt);
+ $txt = "
+
+ ";
+ $ns->tablerender(FORLAN_181, $txt);
+ }
+
+ function show_subs($id)
+ {
+ global $sql, $tp, $ns;
+ $txt = "
+
+ ";
+ $ns->tablerender(FORLAN_149, $txt);
+ }
+
+ function show_existing_forums($sub_action, $id, $mode = false)
+ {
+ global $e107, $for;
+
+ $subList = $for->forum_getsubs();
+
+ if (!$mode)
+ {
+ $text = "";
+ }
+ else
+ {
+ $text = "
";
+ $e107->ns->tablerender(FORLAN_30, $text);
+ }
+ else
+ {
+ $text .= "\n\n
\n\n";
+ $e107->ns->tablerender(FORLAN_37, $text);
+ }
+
+ }
+
+ function create_parents($sub_action, $id)
+ {
+ global $e107;
+
+ $id = (int)$id;
+ if ($sub_action == 'edit' && !$_POST['update_parent'])
+ {
+ if ($e107->sql->db_Select('forum', '*', "forum_id=$id"))
+ {
+ $row = $e107->sql->db_Fetch(MYSQL_ASSOC);
+ }
+ }
+
+ $text = "";
+
+ $e107->ns->tablerender(FORLAN_75, $text);
+ }
+
+ function create_forums($sub_action, $id)
+ {
+ global $e107;
+
+ $id = (int)$id;
+ if ($sub_action == 'edit' && !$_POST['update_forum'])
+ {
+ if ($e107->sql->db_Select('forum', '*', "forum_id=$id"))
+ {
+ $fInfo = $e107->sql->db_Fetch();
+ }
+ }
+
+ $text = "";
+ $e107->ns->tablerender(FORLAN_28, $text);
+ }
+
+ function show_message($message)
+ {
+ global $e107;
+ $e107->ns->tablerender('', "".$message."
");
+ }
+
+ function show_tools()
+ {
+ global $sql, $ns, $tp;
+ $txt = "
+
+ ";
+ $ns->tablerender(FORLAN_166, $txt);
+ }
+
+ function show_prefs()
+ {
+ global $pref, $ns, $sql;
+
+ if($sql->db_Count('plugin','(*)', "where plugin_path = 'poll' AND plugin_installflag = 1"))
+ {
+ $poll_installed = true;
+ }
+ else
+ {
+ $poll_installed = false;
+ if($pref['forum_poll'] == 1)
+ {
+ $pref['forum_poll'] = 0;
+ save_prefs();
+ }
+ }
+
+ $text = "";
+ $ns->tablerender(FORLAN_62, $text);
+ }
+
+ function show_reported ($sub_action, $id)
+ {
+ global $sql, $rs, $ns, $tp;
+ if ($sub_action) {
+ $sql -> db_Select("generic", "*", "gen_id='".$sub_action."'");
+ $row = $sql -> db_Fetch();
+ $sql -> db_Select("user", "*", "user_id='". $row['gen_user_id']."'");
+ $user = $sql -> db_Fetch();
+ $con = new convert;
+ $text = "
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\n";
+ $text .= "
";
+ $text .= "
";
+ $ns -> tablerender(FORLAN_116, $text);
+ } else {
+ $text = "";
+ if ($reported_total = $sql->db_Select("generic", "*", "gen_type='reported_post' OR gen_type='Reported Forum Post'"))
+ {
+ $text .= "
+
+ ".FORLAN_170." |
+ ".FORLAN_80." |
+
";
+ while ($row = $sql->db_Fetch())
+ {
+ $text .= "
+
+
+
\n";
+ }
+ $text .= "
";
+ }
+ else
+ {
+ $text .= "
".FORLAN_121."
";
+ }
+ $text .= "
";
+ $ns->tablerender(FORLAN_116, $text);
+ }
+ }
+
+ function show_prune()
+ {
+ global $ns, $sql;
+
+ // $sql -> db_Select("forum", "forum_id, forum_name", "forum_parent!=0 ORDER BY forum_order ASC");
+ $qry = "
+ SELECT f.forum_id, f.forum_name, sp.forum_name AS sub_parent, fp.forum_name AS forum_parent
+ FROM #forum AS f
+ LEFT JOIN #forum AS sp ON sp.forum_id = f.forum_sub
+ LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent
+ WHERE f.forum_parent != 0
+ ORDER BY f.forum_parent ASC, f.forum_sub, f.forum_order ASC
+ ";
+ $sql -> db_Select_gen($qry);
+ $forums = $sql -> db_getList();
+
+ $text = "";
+ $ns->tablerender(FORLAN_59, $text);
+ }
+
+ function show_levels()
+ {
+ global $sql, $pref, $ns, $rs;
+
+ $rank_names = explode(",", $pref['forum_levels']);
+ $rank_thresholds = ($pref['forum_thresholds'] ? explode(",", $pref['forum_thresholds']) : array(20, 100, 250, 410, 580, 760, 950, 1150, 1370, 1600));
+ $rank_images = ($pref['forum_images'] ? explode(",", $pref['forum_images']) : array("lev1.png", "lev2.png", "lev3.png", "lev4.png", "lev5.png", "lev6.png", "lev7.png", "lev8.png", "lev9.png", "lev10.png"));
+
+ $text = "";
+ $ns->tablerender("Ranks", $text);
+ }
+
+ function show_mods()
+ {
+ global $sql, $ns, $for, $tp;
+ $forumList = $for->forum_getforums('all');
+ $parentList = $for->forum_getparents('list');
+ $subList = $for->forum_getsubs('bysub');
+
+ $txt = "";
+ $ns->tablerender(FORLAN_33, $txt);
+ }
+
+ function show_rules()
+ {
+ global $sql, $pref, $ns, $tp;
+
+ $sql->db_Select("wmessage");
+ list($null) = $sql->db_Fetch();
+ list($null) = $sql->db_Fetch();
+ list($null) = $sql->db_Fetch();
+ list($id, $guestrules, $wm_active4) = $sql->db_Fetch();
+ list($id, $memberrules, $wm_active5) = $sql->db_Fetch();
+ list($id, $adminrules, $wm_active6) = $sql->db_Fetch();
+
+ if($sql->db_Select('generic','*',"gen_type='forum_rules_guest'"))
+ {
+ $guest_rules = $sql->db_Fetch();
+ }
+ if($sql->db_Select('generic','*',"gen_type='forum_rules_member'"))
+ {
+ $member_rules = $sql->db_Fetch();
+ }
+ if($sql->db_Select('generic','*',"gen_type='forum_rules_admin'"))
+ {
+ $admin_rules = $sql->db_Fetch();
+ }
+
+ $guesttext = $tp->toFORM($guest_rules['gen_chardata']);
+ $membertext = $tp->toFORM($member_rules['gen_chardata']);
+ $admintext = $tp->toFORM($admin_rules['gen_chardata']);
+
+ $text = "
+ ";
+
+ $ns->tablerender(WMGLAN_5, $text);
+
+ echo "
+
+ ";
+
+ }
+ }
diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php
index e90627e04..0f6bfe518 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.8 $
-| $Date: 2008-11-26 04:00:36 $
+| $Revision: 1.9 $
+| $Date: 2008-11-26 19:59:06 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -20,6 +20,83 @@ if (!defined('e107_INIT')) { exit; }
class e107forum
{
+ var $permList = array();
+
+ function e107forum()
+ {
+ $this->loadPermList();
+// print_a($this->permList);
+ }
+
+ function loadPermList()
+ {
+ global $e107;
+ if($tmp = $e107->ecache->retrieve_sys('forum_perms'))
+ {
+ $this->permList = $e107->arrayStorage->ReadArray($tmp);
+ }
+ else
+ {
+ $this->getForumPermList();
+ $tmp = $e107->arrayStorage->WriteArray($this->permList);
+ $e107->ecache->set_sys('forum_perms', $tmp);
+
+ }
+ unset($tmp);
+ }
+
+
+ function getForumPermList()
+ {
+
+ global $e107;
+
+ $this->permList = array();
+ $qryList = array();
+
+ $qryList[view] = "
+ SELECT f.forum_id
+ 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
+ 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
+ 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
+ ";
+
+ foreach($qryList as $key => $qry)
+ {
+ if($e107->sql->db_Select_gen($qry))
+ {
+ while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
+ {
+ $this->permList[$key][] = $row['forum_id'];
+ }
+ }
+ }
+
+// print_a($this->permList);
+
+// LEFT JOIN #forum_t AS ft ON ft.thread_parent = t.thread_parent AND ft.thread_id <= ".intval($thread_id)."
+// LEFT JOIN #forum_t as fp ON fp.thread_id = t.thread_parent
+// WHERE t.thread_id = ".intval($thread_id)." AND t.thread_parent != 0
+// ORDER BY ft.thread_datestamp ASC
+// ";
+
+
+ }
+
function thread_postnum($thread_id)
{
@@ -36,7 +113,7 @@ class e107forum
";
if($ret['post_num'] = $sql->db_Select_gen($query))
{
- $row = $sql->db_Fetch();
+ $row = $sql->db_Fetch(MYSQL_ASSOC);
$ret['parent'] = $row['parent'];
}
return $ret;
@@ -71,7 +148,7 @@ class e107forum
{
if ($sql->db_Select('forum', 'forum_id', 'forum_parent != 0'))
{
- while ($row = $sql->db_Fetch())
+ while ($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$parentList[] = $row['forum_id'];
}
@@ -91,7 +168,7 @@ class e107forum
{
if ($sql2->db_Select('forum_t', 'thread_id', "thread_forum_id = $id AND thread_parent = 0"))
{
- while ($row = $sql2->db_Fetch())
+ while ($row = $sql2->db_Fetch(MYSQL_ASSOC))
{
$this->update_lastpost('thread', $row['thread_id']);
}
@@ -99,7 +176,7 @@ class e107forum
}
if ($sql->db_Select("forum_t", "*", "thread_forum_id={$id} ORDER BY thread_datestamp DESC LIMIT 0,1"))
{
- $row = $sql->db_Fetch();
+ $row = $sql->db_Fetch(MYSQL_ASSOC);
$tmp = explode(chr(1), $row['thread_user']);
$forum_lp_user = $tmp[0];
$last_id = $row['thread_parent'] ? $row['thread_parent'] : $row['thread_id'];
@@ -110,18 +187,18 @@ class e107forum
}
}
- function forum_markasread($forum_id)
+ function forum_markasread($forum_id)
{
global $sql;
- if ($forum_id != 'all')
+ if ($forum_id != 'all')
{
$forum_id = intval($forum_id);
$extra = " AND thread_forum_id={$forum_id}";
}
$qry = "thread_lastpost > ".USERLV." AND thread_parent = 0 {$extra} ";
- if ($sql->db_Select('forum_t', 'thread_id', $qry))
+ if ($sql->db_Select('forum_t', 'thread_id', $qry))
{
- while ($row = $sql->db_Fetch())
+ while ($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$u_new .= $row['thread_id'].".";
}
@@ -147,7 +224,7 @@ class e107forum
global $sql;
if ($sql->db_Select('forum', '*', "forum_parent=0 ORDER BY forum_order ASC"))
{
- while ($row = $sql->db_Fetch()) {
+ while ($row = $sql->db_Fetch(MYSQL_ASSOC)) {
$ret[] = $row;
}
return $ret;
@@ -167,7 +244,7 @@ class e107forum
$regex = "(^|,)(".str_replace(",", "|", $uclass).")(,|$)";
$sql->db_Select("user", "user_id, user_name", "user_class REGEXP '{$regex}'");
}
- while($row = $sql->db_Fetch())
+ while($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$ret[$row['user_id']] = $row['user_name'];
}
@@ -185,7 +262,7 @@ class e107forum
";
if ($sql->db_Select_gen($qry))
{
- while ($row = $sql->db_Fetch())
+ while ($row = $sql->db_Fetch(MYSQL_ASSOC))
{
if($type == 'all')
{
@@ -258,7 +335,7 @@ class e107forum
";
if($sql->db_Select_gen($_newqry))
{
- while($row = $sql->db_Fetch())
+ while($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$ret[] = $row['thread_forum_id'];
if($row['forum_sub'])
@@ -302,7 +379,7 @@ class e107forum
$result = $e107->sql->db_Insert('forum_track', $tmp);
unset($tmp);
break;
-
+
case 'delete':
case 'del':
$result = $e107->sql->db_Delete('forum_track', 'WHERE `track_userid` = {$uid} AND `track_thread');
@@ -333,7 +410,7 @@ class e107forum
global $sql;
if ($sql->db_Select_gen($qry))
{
- return $sql->db_Fetch();
+ return $sql->db_Fetch(MYSQL_ASSOC);
}
return FALSE;
}
@@ -350,7 +427,7 @@ class e107forum
";
if ($sql->db_Select_gen($qry))
{
- while($row = $sql->db_Fetch())
+ while($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$ret[$row['forum_id']] = $row['forum_name'];
}
@@ -390,7 +467,7 @@ class e107forum
$ret = array();
if ($sql->db_Select_gen($qry))
{
- while ($row = $sql->db_Fetch())
+ while ($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$ret[] = $row;
}
@@ -418,7 +495,7 @@ class e107forum
";
if ($sql->db_Select_gen($qry))
{
- return $sql->db_Fetch();
+ return $sql->db_Fetch(MYSQL_ASSOC);
}
return FALSE;
}
@@ -449,7 +526,7 @@ class e107forum
if ($sql->db_Select_gen($qry))
{
$i = 0;
- while ($row = $sql->db_Fetch())
+ while ($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$threadList[$i++] = $row['thread_id'];
}
@@ -494,7 +571,7 @@ class e107forum
if ($sql->db_Select_gen($qry))
{
$i = 0;
- while ($row = $sql->db_Fetch())
+ while ($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$threadList[$i++] = $row['thread_id'];
}
@@ -560,7 +637,7 @@ class e107forum
if ($sql->db_Select_gen($qry))
{
$i = $array_start;
- while ($row = $sql->db_Fetch())
+ while ($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$ret[$i] = $row;
$i++;
@@ -577,7 +654,7 @@ class e107forum
";
if ($sql->db_Select_gen($qry))
{
- $row = $sql->db_Fetch();
+ $row = $sql->db_Fetch(MYSQL_ASSOC);
$ret['head'] = $row;
if (!array_key_exists(0, $ret))
{
@@ -606,7 +683,7 @@ class e107forum
";
if ($sql->db_Select_gen($qry))
{
- while ($row = $sql->db_Fetch())
+ while ($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$ret[$row['thread_parent']] = $row['thread_replies'];
}
@@ -636,7 +713,7 @@ class e107forum
";
if ($sql->db_Select_gen($qry))
{
- $ret[0] = $sql->db_Fetch();
+ $ret[0] = $sql->db_Fetch(MYSQL_ASSOC);
}
else
{
@@ -662,7 +739,7 @@ class e107forum
";
if ($sql->db_Select_gen($qry))
{
- $row = $sql->db_Fetch();
+ $row = $sql->db_Fetch(MYSQL_ASSOC);
$ret['head'] = $row;
}
}
@@ -755,7 +832,7 @@ class e107forum
{
include_once(e_HANDLER.'mail.php');
$message = LAN_385.SITENAME.".
". LAN_382.$datestamp."
". LAN_94.": ".$thread_poster['post_user_name']."
". LAN_385.$email_post."
". LAN_383."
".$mail_link;
- while ($row = $sql->db_Fetch())
+ while ($row = $sql->db_Fetch(MYSQL_ASSOC))
{ // Don't sent to self, nor to originator of thread if they've got 'notify' set
if ($row['user_email'] && ($row['user_email'] != $email_addy) && ($row['user_id'] != USERID)) // (May be wrong, but this could be faster than filtering current user in the query)
{
@@ -889,7 +966,7 @@ class e107forum
if($sql->db_Select_gen($qry))
{
$ret = array();
- while($row = $sql->db_Fetch())
+ while($row = $sql->db_Fetch(MYSQL_ASSOC))
{
$ret[$row['uid']] = $row['cnt'];
}
@@ -897,7 +974,7 @@ class e107forum
}
return FALSE;
}
-
+
/*
* set bread crumb
* $forum_href override ONLY applies when template is missing FORUM_CRUMB
@@ -907,17 +984,17 @@ class e107forum
{
global $FORUM_CRUMB,$forum_info,$thread_info,$tp;
global $BREADCRUMB,$BACKLINK; // Eventually we should deprecate BACKLINK
-
+
if(is_array($FORUM_CRUMB))
{
$search = array("{SITENAME}", "{SITENAME_HREF}");
$replace = array(SITENAME, "href='".e_BASE."index.php'");
$FORUM_CRUMB['sitename']['value'] = str_replace($search, $replace, $FORUM_CRUMB['sitename']['value']);
-
+
$search = array("{FORUMS_TITLE}", "{FORUMS_HREF}");
$replace = array(LAN_01, "href='".e_PLUGIN."forum/forum.php'");
$FORUM_CRUMB['forums']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forums']['value']);
-
+
$search = "{PARENT_TITLE}";
$replace = $tp->toHTML($forum_info['parent_name']);
$FORUM_CRUMB['parent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['parent']['value']);
@@ -964,7 +1041,7 @@ class e107forum
$forum_sub_parent = (substr($forum_info['sub_parent'], 0, 1) == "*" ? substr($forum_info['sub_parent'], 1) : $forum_info['sub_parent']);
$BREADCRUMB .= "{$forum_sub_parent}".$dfltsep;
}
-
+
$tmpFname = $forum_info['forum_name'];
if(substr($tmpFname, 0, 1) == "*") { $tmpFname = substr($tmpFname, 1); }
if ($forum_href)
diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php
index f638cf69e..2e7b6d8d9 100644
--- a/e107_plugins/forum/forum_post.php
+++ b/e107_plugins/forum/forum_post.php
@@ -11,69 +11,81 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $
-| $Revision: 1.16 $
-| $Date: 2008-01-18 21:07:47 $
-| $Author: e107steved $
+| $Revision: 1.17 $
+| $Date: 2008-11-26 19:59:06 $
+| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
-require_once("../../class2.php");
-$e_wysiwyg = "post";
+require_once('../../class2.php');
+$e_wysiwyg = 'post';
$lan_file = e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_post.php';
include(file_exists($lan_file) ? $lan_file : e_PLUGIN.'forum/languages/English/lan_forum_post.php');
-if (IsSet($_POST['fjsubmit'])) {
- header("location:".e_BASE.$PLUGINS_DIRECTORY."forum/forum_viewforum.php?".$_POST['forumjump']);
+if (isset($_POST['fjsubmit']))
+{
+ header('location:'.$e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id'=>$_POST['forumjump'])));
exit;
}
+
+//$_POST['forumjump']
require_once(e_PLUGIN.'forum/forum_class.php');
$forum = new e107forum;
-if (!e_QUERY) {
- header("Location:".e_PLUGIN."forum/forum.php");
+if (!e_QUERY || !isset($_REQUEST['id']))
+{
+ header("Location:".$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
-} else {
- $tmp = explode(".", e_QUERY);
- $action = preg_replace('#\W#', '', $tmp[0]);
- $id = intval($tmp[1]);
- $from = intval($tmp[2]);
}
+//else
+//{
+// $tmp = explode(".", e_QUERY);
+// $action = preg_replace('#\W#', '', $tmp[0]);
+// $id = intval($tmp[1]);
+// $from = intval($tmp[2]);
+//}
+
+$action = $_REQUEST['f'];
+$id = (int)$_REQUEST['id'];
// check if user can post to this forum ...
-if ($action == 'rp')
+if (!in_array($id, $forum->permList['post']))
{
- // reply to thread
- $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']);
- }
-}
-elseif ($action == 'nt')
-{
- // New post
- $forum_info = $forum->forum_get($id);
-}
-elseif ($action == 'quote' || $action == 'edit')
-{
- $thread_info = $forum->thread_get_postinfo($id, TRUE);
- $forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
- if($action == 'quote')
- {
- $id = $thread_info['head']['thread_id'];
- }
-}
-
-if (($forum_info === FALSE) || !check_class($forum_info['forum_postclass']) || !check_class($forum_info['parent_postclass'])) {
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']);
+ }
+ break;
+
+ case 'nt':
+ $forum_info = $forum->forum_get($id);
+ break;
+
+ case 'quote':
+ case 'edit':
+ $thread_info = $forum->thread_get_postinfo($id, true);
+ $forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
+ if($_REQUST['f'] == 'quote')
+ {
+ $id = $thread_info['head']['thread_id'];
+ }
+ break;
+}
+
define("MODERATOR", check_class($forum_info['forum_moderators']));
//require_once(e_HANDLER.'forum_include.php');
require_once(e_PLUGIN."forum/forum_post_shortcodes.php");
@@ -93,16 +105,6 @@ if ($sql->db_Select("tmp", "*", "tmp_ip='$ip' ")) {
$sql->db_Delete("tmp", "tmp_ip='$ip' ");
}
-//Check to see if user had post rights
-if (!check_class($forum_info['forum_postclass']))
-{
- require_once(HEADERF);
- $text .= "".LAN_399."
";
- $ns->tablerender(LAN_20, $text);
- require_once(FOOTERF);
- exit;
-}
-
//if thread is not active and not new thread, show warning
if ($action != "nt" && !$thread_info['head']['thread_active'] && !MODERATOR)
{
@@ -112,16 +114,17 @@ if ($action != "nt" && !$thread_info['head']['thread_active'] && !MODERATOR)
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));
+$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));
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-if (is_readable(e_ADMIN.'filetypes.php')) {
+if (is_readable(e_ADMIN.'filetypes.php'))
+{
$a_filetypes = trim(file_get_contents(e_ADMIN.'filetypes.php'));
$a_filetypes = explode(',', $a_filetypes);
- foreach ($a_filetypes as $ftype) {
+ foreach ($a_filetypes as $ftype)
+ {
$sa_filetypes[] = '.'.trim(str_replace('.', '', $ftype));
}
$allowed_filetypes = implode(' | ', $sa_filetypes);
@@ -193,7 +196,7 @@ if (isset($_POST['fpreview']))
$ns->tablerender(LAN_323, $text);
$anonname = $tp->post_toHTML($_POST['anonname'], FALSE);
- $post = $tp->post_toForm($_POST['post']);
+ $post = $tp->post_toForm($_POST['post']);
$subject = $tp->post_toHTML($_POST['subject'], false);
if ($action == "edit")
@@ -463,7 +466,7 @@ elseif($action == "nt")
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
+ $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']))
diff --git a/e107_plugins/forum/forum_sql.php b/e107_plugins/forum/forum_sql.php
index 6f0aeac8c..4d7c1e17c 100644
--- a/e107_plugins/forum/forum_sql.php
+++ b/e107_plugins/forum/forum_sql.php
@@ -48,6 +48,7 @@ CREATE TABLE forum_post (
`post_edit_datestamp` int(10) unsigned NOT NULL default '0',
`post_edit_user` int(10) unsigned NOT NULL,
`post_ip` varchar(45) NOT NULL,
+ `post_anon_name` varchar(30) NULL,
`post_attachments` text default NULL,
`post_options` text,
PRIMARY KEY (`post_id`),
diff --git a/e107_plugins/forum/url/forum.php b/e107_plugins/forum/url/forum.php
index f6770f0a6..e3641f6fe 100755
--- a/e107_plugins/forum/url/forum.php
+++ b/e107_plugins/forum/url/forum.php
@@ -1,16 +1,20 @@
-".IMAGE_newthread."";
+// $NEWTHREADBUTTON = "".IMAGE_newthread."";
+ $NEWTHREADBUTTON = " 'nt', 'id' => $forum_id))."'>".IMAGE_newthread.'';
}
if(substr($forum_info['forum_name'], 0, 1) == "*")
@@ -336,7 +337,7 @@ function parse_thread($thread_info)
$THREADDATE = $gen->convert_date($thread_info['thread_datestamp'], 'forum');
$ICON = ($newflag ? IMAGE_new : IMAGE_nonew);
- if ($REPLIES >= $pref['forum_popular'])
+ if ($REPLIES >= $pref['forum_popular'])
{
$ICON = ($newflag ? IMAGE_new_popular : IMAGE_nonew_popular);
}
@@ -458,7 +459,7 @@ function parse_thread($thread_info)
if (!$REPLIES)
{
- $REPLIES = LAN_317; // 'None'
+ $REPLIES = LAN_317; // 'None'
$LASTPOST = " - ";
}