From 8264c99e1151277d48a1a7f2d5f6c2a070683cd4 Mon Sep 17 00:00:00 2001 From: Tijn Kuyper Date: Sat, 1 Dec 2012 13:31:54 +0100 Subject: [PATCH] More forum clean-up (globals, GUI) --- e107_plugins/forum/forum_admin_class.php | 134 ++++++++++++++--------- 1 file changed, 81 insertions(+), 53 deletions(-) diff --git a/e107_plugins/forum/forum_admin_class.php b/e107_plugins/forum/forum_admin_class.php index f8331d78e..505b7c442 100755 --- a/e107_plugins/forum/forum_admin_class.php +++ b/e107_plugins/forum/forum_admin_class.php @@ -17,7 +17,8 @@ class forumAdmin function show_options($action) { - global $sql; + + $sql = e107::getDb(); if ($action == '') { $action = 'main'; } // ##### Display options --------------------------------------------------------------------------------------------------------- $var['main']['text'] = FORLAN_76; @@ -49,7 +50,7 @@ class forumAdmin function delete_item($id) { - global $sql; + $sql = e107::getDb(); $id = (int)$id; $confirm = isset($_POST['confirm']) ? true : false; @@ -82,7 +83,7 @@ class forumAdmin function delete_parent($id, $confirm = false) { - global $sql; + $sql = e107::getDb(); $ret = ''; if($sql->db_Select('forum', 'forum_id', "forum_parent = {$id} AND forum_sub = 0")) { @@ -110,13 +111,13 @@ class forumAdmin function deleteForum($forumId) { - $e107 = e107::getInstance(); + $sql = e107::getDb(); $forumId = (int)$forumId; // echo "id = $forumId
"; // Check for any sub forums - if($e107->sql->db_Select('forum', 'forum_id', "forum_sub = {$forumId}")) + if($sql->db_Select('forum', 'forum_id', "forum_sub = {$forumId}")) { - $list = $e107->sql->db_getList(); + $list = $sql->db_getList(); foreach($list as $f) { $ret .= $this->deleteForum($f['forum_id']); @@ -124,7 +125,7 @@ class forumAdmin } require_once(e_PLUGIN.'forum/forum_class.php'); $f = new e107Forum; - if($e107->sql->db_Select('forum_thread', 'thread_id','thread_forum_id='.$forumId)) + if($sql->db_Select('forum_thread', 'thread_id','thread_forum_id='.$forumId)) { $list = $e107->sql->db_getList(); foreach($list as $t) @@ -132,14 +133,15 @@ class forumAdmin $f->threadDelete($t['thread_id'], false); } } - return $e107->sql->db_Delete('forum', 'forum_id = '.$forumId); + return $sql->db_Delete('forum', 'forum_id = '.$forumId); } function delete_forum($id, $confirm = false) { - $e107 = e107::getInstance(); + $sql = e107::getDb(); + $tp = e107::getParser(); $ret = ''; - if($e107->sql->db_Select('forum', 'forum_id', 'forum_sub = '.$id)) + if($sql->db_Select('forum', 'forum_id', 'forum_sub = '.$id)) { $fList = $sql->db_getList(); foreach($fList as $f) @@ -160,14 +162,15 @@ class forumAdmin return $ret; } - $e107->sql->db_Select('forum', 'forum_name, forum_threads, forum_replies', 'forum_id = '.$id); - $row = $e107->sql->db_Fetch(); - return "Forum {$id} [".$e107->tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies.
".$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) { - $e107 = e107::getInstance(); + $sql = e107::getDb(); + $tp = e107::getParser(); if($confirm) { if($this->deleteForum($id)) @@ -181,14 +184,14 @@ class forumAdmin return $ret; } - $e107->sql->db_Select('forum', '*', 'forum_id = '.$id); - $row = $e107->sql->db_Fetch(); - return "Sub-forum {$id} [".$e107->tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies.
".$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; + $ns = e107::getRender(); $this->show_message($txt); $txt = "
@@ -203,7 +206,9 @@ class forumAdmin function show_subs($id) { - global $sql, $tp, $ns; + $sql = e107::getDb(); + $tp = e107::getParser(); + $ns = e107::getRender(); $txt = " @@ -275,12 +280,14 @@ class forumAdmin { global $e107, $for; $frm = e107::getForm(); + $sql = e107::getDb(); + $tp = e107::getParser(); $subList = $for->forumGetSubs(); if (!$mode) { - $text = "
"; + $text = "
"; } else { @@ -293,13 +300,13 @@ class forumAdmin
"; - if (!$parent_amount = $e107->sql->db_Select('forum', '*', "forum_parent='0' ORDER BY forum_order ASC")) + if (!$parent_amount = $sql->db_Select('forum', '*', "forum_parent='0' ORDER BY forum_order ASC")) { $text .= ""; } else { - while ($row = $e107->sql->db_Fetch(MYSQL_ASSOC)) + while ($row = $sql->db_Fetch(MYSQL_ASSOC)) { $parentList[] = $row; } @@ -333,7 +340,7 @@ class forumAdmin } $text .= ""; - $forumCount = $e107->sql->db_Select('forum', '*', "forum_parent='".$parent['forum_id']."' AND forum_sub = 0 ORDER BY forum_order ASC"); + $forumCount = $sql->db_Select('forum', '*', "forum_parent='".$parent['forum_id']."' AND forum_sub = 0 ORDER BY forum_order ASC"); if (!$forumCount) { $text .= ""; @@ -341,7 +348,7 @@ class forumAdmin else { $forumList = array(); - while ($row = $e107->sql->db_Fetch(MYSQL_ASSOC)) + while ($row = $sql->db_Fetch(MYSQL_ASSOC)) { $forumList[] = $row; } @@ -349,7 +356,7 @@ class forumAdmin { $text .= " - \n\n\n @@ -466,18 +476,21 @@ class forumAdmin "; - $e107->ns->tablerender(FORLAN_75, $text); + $ns->tablerender(FORLAN_75, $text); } function create_forums($sub_action, $id) { global $e107; $frm = e107::getForm(); + $sql = e107::getDb(); + $tp = e107::getParser(); + $ns = e107::getRender(); $id = (int)$id; if ($sub_action == 'edit' && !$_POST['update_forum']) { - if ($e107->sql->db_Select('forum', '*', "forum_id=$id")) + if ($sql->db_Select('forum', '*', "forum_id=$id")) { $fInfo = $e107->sql->db_Fetch(MYSQL_ASSOC); } @@ -495,14 +508,14 @@ class forumAdmin $text = "
\n -
".FORLAN_80."
".FORLAN_29."
".FORLAN_29."
".IMAGE_new."".$e107->tp->toHTML($forum['forum_name']).""; + ".IMAGE_new."".$tp->toHTML($forum['forum_name']).""; // ".IMAGE_new."".$e107->tp->toHTML($forum['forum_name']).""; $text .= " @@ -404,13 +411,16 @@ class forumAdmin { global $e107; $frm = e107::getForm(); + $sql = e107::getDb(); + $tp = e107::getParser(); + $ns = e107::getRender(); $id = (int)$id; if ($sub_action == 'edit' && !$_POST['update_parent']) { - if ($e107->sql->db_Select('forum', '*', "forum_id=$id")) + if ($sql->db_Select('forum', '*', "forum_id=$id")) { - $row = $e107->sql->db_Fetch(MYSQL_ASSOC); + $row = $sql->db_Fetch(MYSQL_ASSOC); } } else @@ -429,7 +439,7 @@ class forumAdmin
".FORLAN_31.": - +
+
@@ -564,23 +577,25 @@ class forumAdmin
".FORLAN_22.": "; - $e107->sql->db_Select('forum', '*', 'forum_parent=0'); + $sql->db_Select('forum', '*', 'forum_parent=0'); $text .= " - +
".FORLAN_32.": - +
"; - $e107->ns->tablerender(FORLAN_28, $text); + $ns->tablerender(FORLAN_28, $text); } function show_message($message) { - global $e107; - $e107->ns->tablerender('', "
".$message."
"); //FIX: v2 style = render? + $ns = e107::getRender(); + $ns->tablerender('', "
".$message."
"); //FIX: v2 style = render? } function show_tools() { - global $sql, $ns, $tp; + $sql = e107::getDb(); + $ns = e107::getRender(); + $tp = e107::getParser(); $frm = e107::getForm(); $txt = "
- +
@@ -638,7 +653,9 @@ class forumAdmin function show_prefs() { - global $fPref, $ns, $sql; + global $fPref; + $ns = e107::getRender(); + $sql = e107::getDb(); $e107 = e107::getInstance(); $emessage = eMessage::getInstance(); $frm = e107::getForm(); @@ -657,7 +674,7 @@ class forumAdmin $text = "
\n -
".FORLAN_156."
+
@@ -784,7 +801,11 @@ class forumAdmin function show_reported ($sub_action, $id) { - global $sql, $rs, $ns, $tp; + global $rs; //FIX: needed? + $sql = e107::getDb(); + $ns = e107::getRender(); + $tp = e107::getParser(); + if ($sub_action) { $sql -> db_Select("generic", "*", "gen_id='".$sub_action."'"); $row = $sql -> db_Fetch(); @@ -792,7 +813,7 @@ class forumAdmin $user = $sql -> db_Fetch(); $con = new convert; $text = "
-
".FORLAN_44."
".FORLAN_45."
+
@@ -846,7 +867,7 @@ class forumAdmin $text = "
"; if ($reported_total = $sql->db_Select("generic", "*", "gen_type='reported_post' OR gen_type='Reported Forum Post'")) { - $text .= "
".FORLAN_171.":
+ $text .= "
@@ -875,7 +896,8 @@ class forumAdmin function show_prune() { - global $ns, $sql; + $ns = e107::getRender(); + $sql = e107::getDB(); $frm = e107::getForm(); // $sql -> db_Select("forum", "forum_id, forum_name", "forum_parent!=0 ORDER BY forum_order ASC"); @@ -892,7 +914,7 @@ class forumAdmin $text = " \n -
".FORLAN_170." ".FORLAN_80."
+
@@ -935,14 +957,17 @@ class forumAdmin function show_mods() { - global $sql, $ns, $for, $tp; - $e107 = e107::getInstance(); + global $for; + $ns = e107::getRender(); + $sql = e107::getDB(); + $e107 = e107::getInstance(); // FIX: needed? $forumList = $for->forum_getforums('all'); $parentList = $for->forum_getparents('list'); $subList = $for->forumGetSubs('bysub'); $frm = e107::getForm(); + $tp = e107::getParser(); - $txt = "
".FORLAN_60."
"; + $txt = "
"; foreach($parentList as $p) { @@ -984,7 +1009,10 @@ class forumAdmin function show_rules() { - global $sql, $pref, $ns, $tp; + $pref = e107::getPref(); + $ns = e107::getRender(); + $sql = e107::getDB(); + $tp = e107::getParser(); $frm = e107::getForm(); $sql->db_Select("wmessage"); @@ -1015,7 +1043,7 @@ class forumAdmin $text = "
-
+
"; $text .= " @@ -1120,4 +1148,4 @@ class forumAdmin "; } - } + } \ No newline at end of file