mirror of
https://github.com/e107inc/e107.git
synced 2025-07-30 03:10:50 +02:00
Forum plugin admin clean-up, lots more work to do (not quite functional now)
This commit is contained in:
@@ -519,8 +519,10 @@ class forumAdmin
|
|||||||
show_admin_menu(FORLAN_7, $action, $var);
|
show_admin_menu(FORLAN_7, $action, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initial delete function. Determines which delete routine should be applied.
|
||||||
function delete_item($id)
|
function delete_item($id)
|
||||||
{
|
{
|
||||||
|
// If a delete routine is cancelled, redirect back to forum listing
|
||||||
if($_POST['cancel'])
|
if($_POST['cancel'])
|
||||||
{
|
{
|
||||||
$this->show_existing_forums(vartrue($sub_action), vartrue($id));
|
$this->show_existing_forums(vartrue($sub_action), vartrue($id));
|
||||||
@@ -529,44 +531,44 @@ class forumAdmin
|
|||||||
|
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
$id = (int)$id;
|
$id = (int)$id;
|
||||||
|
|
||||||
$confirm = isset($_POST['confirm']) ? true : false;
|
$confirm = isset($_POST['confirm']) ? true : false;
|
||||||
|
|
||||||
if($sql->select('forum', 'forum_parent, forum_sub', "forum_id = {$id}"))
|
|
||||||
{
|
|
||||||
$txt = "";
|
|
||||||
$row = $sql->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)
|
if($confirm)
|
||||||
{
|
{
|
||||||
e107::getRender()->tablerender('', e107::getMessage()->render().$txt);
|
e107::getRender()->tablerender('Forums', e107::getMessage()->render().$txt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->delete_show_confirm($txt);
|
$this->delete_show_confirm($txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($row = $sql->retrieve('forum', 'forum_parent, forum_sub', "forum_id = {$id}"))
|
||||||
|
{
|
||||||
|
$txt = "";
|
||||||
|
|
||||||
|
// is parent
|
||||||
|
if($row['forum_parent'] == 0)
|
||||||
|
{
|
||||||
|
$txt .= $this->delete_parent($id, $confirm);
|
||||||
}
|
}
|
||||||
|
// is subforum
|
||||||
|
elseif($row['forum_sub'] > 0)
|
||||||
|
{
|
||||||
|
$txt .= $this->delete_sub($id, $confirm);
|
||||||
|
}
|
||||||
|
// is forum
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$txt .= $this->delete_forum($id, $confirm);
|
||||||
|
}
|
||||||
|
}
|
||||||
// forum_id not found, should not happen.
|
// forum_id not found, should not happen.
|
||||||
|
else
|
||||||
|
{
|
||||||
$this->show_existing_forums(vartrue($sub_action), vartrue($id));
|
$this->show_existing_forums(vartrue($sub_action), vartrue($id));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_parent($id, $confirm = false)
|
function delete_parent($id, $confirm = false)
|
||||||
@@ -575,10 +577,10 @@ class forumAdmin
|
|||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
|
|
||||||
|
// check if parent contains forums and delete them if needed
|
||||||
if($sql->select('forum', 'forum_id', "forum_parent = {$id} AND forum_sub = 0"))
|
if($sql->select('forum', 'forum_id', 'forum_parent = '.$id))
|
||||||
{
|
{
|
||||||
$fList = $sql->db_getList();
|
$fList = $sql->rows();
|
||||||
foreach($fList as $f)
|
foreach($fList as $f)
|
||||||
{
|
{
|
||||||
$this->delete_forum($f['forum_id'], $confirm);
|
$this->delete_forum($f['forum_id'], $confirm);
|
||||||
@@ -589,42 +591,43 @@ class forumAdmin
|
|||||||
{
|
{
|
||||||
if($sql->delete('forum', "forum_id = {$id}"))
|
if($sql->delete('forum', "forum_id = {$id}"))
|
||||||
{
|
{
|
||||||
return LAN_DELETED;
|
$mes->addSuccess(LAN_DELETED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return LAN_DELETED_FAILED;
|
$mes->addError(LAN_DELETED_FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteForum($forumId)
|
// function deleteForum($forumId)
|
||||||
{
|
// {
|
||||||
$sql = e107::getDb();
|
// $sql = e107::getDb();
|
||||||
$forumId = (int)$forumId;
|
// $forumId = (int)$forumId;
|
||||||
|
|
||||||
// Check for any sub forums
|
// // Check for any sub forums
|
||||||
if($sql->select('forum', 'forum_id', "forum_sub = {$forumId}"))
|
// if($sql->select('forum', 'forum_id', "forum_sub = {$forumId}"))
|
||||||
{
|
// {
|
||||||
$list = $sql->db_getList();
|
// $list = $sql->rows();
|
||||||
foreach($list as $f)
|
// foreach($list as $f)
|
||||||
{
|
// {
|
||||||
$ret .= $this->deleteForum($f['forum_id']);
|
// $ret .= $this->deleteForum($f['forum_id']);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
require_once(e_PLUGIN.'forum/forum_class.php');
|
// require_once(e_PLUGIN.'forum/forum_class.php');
|
||||||
$f = new e107Forum;
|
// $f = new e107Forum;
|
||||||
if($sql->delete('forum_thread', 'thread_id','thread_forum_id='.$forumId))
|
// if($sql->delete('forum_thread', 'thread_id','thread_forum_id='.$forumId))
|
||||||
{
|
// {
|
||||||
$list = $sql->db_getList();
|
// $list = $sql->rows();
|
||||||
foreach($list as $t)
|
// foreach($list as $t)
|
||||||
{
|
// {
|
||||||
$f->threadDelete($t['thread_id'], false);
|
// $f->threadDelete($t['thread_id'], false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return $sql->delete('forum', 'forum_id = '.$forumId);
|
// return $sql->delete('forum', 'forum_id = '.$forumId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// delete forum
|
||||||
function delete_forum($id, $confirm = false)
|
function delete_forum($id, $confirm = false)
|
||||||
{
|
{
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
@@ -632,10 +635,10 @@ class forumAdmin
|
|||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
|
// check if forum contains subforums
|
||||||
if($sql->select('forum', 'forum_id', 'forum_sub = '.$id))
|
if($sql->select('forum', 'forum_id', 'forum_sub = '.$id))
|
||||||
{
|
{
|
||||||
$fList = $sql->db_getList();
|
$fList = $sql->rows();
|
||||||
foreach($fList as $f)
|
foreach($fList as $f)
|
||||||
{
|
{
|
||||||
$this->delete_sub($f['forum_id'], $confirm);
|
$this->delete_sub($f['forum_id'], $confirm);
|
||||||
@@ -1492,6 +1495,7 @@ class forumAdmin
|
|||||||
$ns->tablerender(FORLAN_33, $txt); // FIX: LAN button update was WMGLAN_4." ".FORLAN_33)
|
$ns->tablerender(FORLAN_33, $txt); // FIX: LAN button update was WMGLAN_4." ".FORLAN_33)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: check media category on $frm->bbarea()
|
||||||
function show_rules()
|
function show_rules()
|
||||||
{
|
{
|
||||||
$pref = e107::getPref();
|
$pref = e107::getPref();
|
||||||
@@ -1524,9 +1528,9 @@ class forumAdmin
|
|||||||
$admin_rules = $sql->fetch();
|
$admin_rules = $sql->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
$guesttext = $tp->toFORM(vartrue($guest_rules['gen_chardata']));
|
$guesttext = $tp->toForm(vartrue($guest_rules['gen_chardata']));
|
||||||
$membertext = $tp->toFORM(vartrue($member_rules['gen_chardata']));
|
$membertext = $tp->toForm(vartrue($member_rules['gen_chardata']));
|
||||||
$admintext = $tp->toFORM(vartrue($admin_rules['gen_chardata']));
|
$admintext = $tp->toForm(vartrue($admin_rules['gen_chardata']));
|
||||||
|
|
||||||
$text = "
|
$text = "
|
||||||
<form method='post' action='".e_SELF."?rules' id='wmform'>
|
<form method='post' action='".e_SELF."?rules' id='wmform'>
|
||||||
@@ -1549,11 +1553,7 @@ class forumAdmin
|
|||||||
$text .= "</td>
|
$text .= "</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<textarea class='tbox input-xxlarge' name='guestrules' cols='70' rows='8'>$guesttext</textarea>
|
".$frm->bbarea('guestrules', $guesttext)."
|
||||||
<br />
|
|
||||||
<input class='helpbox' type='text' name='helpguest' size='100' />
|
|
||||||
<br />
|
|
||||||
".display_help('helpb', 1, 'addtext1', 'help1')."
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -1571,11 +1571,7 @@ class forumAdmin
|
|||||||
$text .= "</td>
|
$text .= "</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<textarea class='tbox input-xxlarge' name='memberrules' cols='70' rows='8'>$membertext</textarea>
|
".$frm->bbarea('memberrules', $membertext)."
|
||||||
<br />
|
|
||||||
<input class='helpbox' type='text' name='helpmember' size='100' />
|
|
||||||
<br />
|
|
||||||
".display_help('helpb', 1, 'addtext2', 'help2')."
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -1594,11 +1590,7 @@ class forumAdmin
|
|||||||
|
|
||||||
$text .= "</td>
|
$text .= "</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea class='tbox input-xxlarge' name='adminrules' cols='70' rows='8'>$admintext</textarea>
|
".$frm->bbarea('adminrules', $admintext)."
|
||||||
<br />
|
|
||||||
<input class='helpbox' type='text' name='helpadmin' size='100' />
|
|
||||||
<br />
|
|
||||||
".display_help('helpb', 1, 'addtext3', 'help3')."
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
Reference in New Issue
Block a user