1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 12:48:26 +02:00

Forum plugin - major clean up to admin area (preparation for convertion to new admin UI)

- Removal of obsolete code
- Updating to v2 functions
- Clean code structure
- LAN
- Fixed several issues with deleting forums

Still more to do ('reported posts' for example)
This commit is contained in:
Moc
2014-07-05 16:40:09 +02:00
parent 7faa098d97
commit d13c295a4d
3 changed files with 184 additions and 164 deletions

View File

@@ -2,7 +2,7 @@
/* /*
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2013 e107 Inc (e107.org) * Copyright (C) 2008-2014 e107 Inc (e107.org)
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* *
@@ -22,24 +22,23 @@ $e_sub_cat = 'forum';
require_once(e_ADMIN.'auth.php'); require_once(e_ADMIN.'auth.php');
require_once(e_HANDLER.'userclass_class.php'); require_once(e_HANDLER.'userclass_class.php');
require_once(e_HANDLER.'form_handler.php'); require_once(e_HANDLER.'form_handler.php');
require_once(e_HANDLER.'ren_help.php'); // FIXME
require_once(e_PLUGIN.'forum/forum_class.php'); require_once(e_PLUGIN.'forum/forum_class.php');
// require_once(e_PLUGIN.'forum/forum_admin_class.php');
$mes = e107::getMessage(); $for = new e107forum;
$for = new e107forum; $forum = new forumAdmin;
$forum = new forumAdmin;
$sql = e107::getDb(); $mes = e107::getMessage();
$tp = e107::GetParser(); $sql = e107::getDb();
$tp = e107::getParser();
$fPref = e107::getPlugConfig('forum', '', false); $fPref = e107::getPlugConfig('forum', '', false);
define('IMAGE_new', "<img src='".img_path('new.png')."' alt='' />");
define('IMAGE_new', "<img src='".img_path('new.png')."' alt='' />"); define('IMAGE_sub', "<img src='".e_PLUGIN."forum/images/forums_16.png' alt='".FORLAN_145."' title='".FORLAN_145."' />");
define('IMAGE_sub', "<img src='".e_PLUGIN."forum/images/forums_16.png' alt='".FORLAN_145."' title='".FORLAN_145."' />"); define('IMAGE_nosub', "<img src='".e_PLUGIN."forum/images/sub_forums_16.png' alt='".FORLAN_145."' title='".FORLAN_145."' />");
define('IMAGE_nosub', "<img src='".e_PLUGIN."forum/images/sub_forums_16.png' alt='".FORLAN_145."' title='".FORLAN_145."' />");
$deltest = array_flip($_POST); $deltest = array_flip($_POST);
if (e_QUERY) if (e_QUERY)
{ {
$tmp = explode('.', e_QUERY); $tmp = explode('.', e_QUERY);
@@ -59,13 +58,20 @@ if(isset($_POST['setMods']))
{ {
foreach($_POST['mods'] as $fid => $modid) foreach($_POST['mods'] as $fid => $modid)
{ {
$sql->update('forum',"forum_moderators = '{$modid}' WHERE forum_id = {$fid}"); if($sql->update('forum',"forum_moderators = '{$modid}' WHERE forum_id = {$fid}"))
{
$mes->addSuccess(LAN_UPDATED);
}
else
{
$mes->addError(LAN_UPDATED_FAILED);
}
} }
//$forum->show_message(FORLAN_144);
$mes->addSuccess(FORLAN_144); $ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if(isset($_POST['tools'])) if(isset($_POST['tools']))
{ {
@@ -107,19 +113,19 @@ if(isset($_POST['tools']))
} }
$msg .= FORLAN_169.' <br />'; $msg .= FORLAN_169.' <br />';
} }
//$forum->show_message($msg);
$mes->addSuccess($msg); $mes->addSuccess($msg);
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if(isset($_POST['create_sub'])) if(isset($_POST['create_sub']))
{ {
$fid = (int)($sub_action); $fid = (int)($sub_action);
$tmp = array(); $tmp = array();
$tmp['forum_name'] = $tp->toDB($_POST['subname_new']); $tmp['forum_name'] = $tp->toDB($_POST['subname_new']);
$tmp['forum_description'] = $tp->toDB($_POST['subdesc_new']); $tmp['forum_description'] = $tp->toDB($_POST['subdesc_new']);
$tmp['forum_order'] = (int)$_POST['suborder_new']; $tmp['forum_order'] = (int)$_POST['suborder_new'];
if($tmp['forum_name'] != '' && $sql->select('forum', '*', "forum_id = {$fid}")) if($tmp['forum_name'] != '' && $sql->select('forum', '*', "forum_id = {$fid}"))
{ {
@@ -131,18 +137,16 @@ if(isset($_POST['create_sub']))
$tmp['forum_sub'] = $fid; $tmp['forum_sub'] = $fid;
if($sql->insert('forum', $tmp)) if($sql->insert('forum', $tmp))
{ {
//$forum->show_message(FORLAN_150.' - '.LAN_CREATED);
$mes->addSuccess(LAN_CREATED); $mes->addSuccess(LAN_CREATED);
} }
else else
{ {
//$forum->show_message(FORLAN_150.' - '.LAN_CREATED_FAILED); $mes->addError(LAN_CREATED_FAILED);
$mes->addSuccess(LAN_CREATED_FAILED);
} }
} }
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if(isset($_POST['update_subs'])) if(isset($_POST['update_subs']))
{ {
@@ -172,19 +176,22 @@ if(isset($_POST['update_subs']))
if($msg) if($msg)
{ {
$mes->addSuccess($msg); $mes->addSuccess($msg);
$ns->tablerender($caption, $mes->render() . $text); $ns->tablerender($caption, $mes->render().$text);
} }
} }
if(isset($_POST['submit_parent'])) if(isset($_POST['submit_parent']))
{ {
$tmp = array(); unset($insert);
$tmp['forum_name'] = $tp->toDB($_POST['forum_name']); $insert = array(
$tmp['forum_datestamp'] = time(); 'forum_name' => $tp->toDB($_POST['forum_name']),
$tmp['forum_class'] = (int)$_POST['forum_class']; 'forum_datestamp' => time(),
$tmp['forum_postclass'] = (int)$_POST['forum_postclass']; 'forum_class' => (int)$_POST['forum_class'],
$tmp['forum_threadclass'] = (int)$_POST['forum_threadclass']; 'forum_postclass' => (int)$_POST['forum_postclass'],
if($sql->insert('forum',$tmp)) 'forum_threadclass' => (int)$_POST['forum_threadclass'],
);
if($sql->insert('forum', $insert))
{ {
$mes->addSuccess(LAN_CREATED); $mes->addSuccess(LAN_CREATED);
} }
@@ -192,43 +199,51 @@ if(isset($_POST['submit_parent']))
{ {
$mes->addError(LAN_CREATED_FAILED); $mes->addError(LAN_CREATED_FAILED);
} }
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if(isset($_POST['update_parent'])) if(isset($_POST['update_parent']))
{ {
$tmp = $_POST; unset($update);
unset($tmp['update_parent']); $update = array(
$tmp['_FIELD_TYPES']['forum_name'] = 'todb'; 'forum_name' => $tp->toDb($_POST['forum_name']),
$tmp['_FIELD_TYPES']['forum_class'] = 'int'; 'forum_datestamp' => time(),
$tmp['_FIELD_TYPES']['forum_postclass'] = 'int'; 'forum_class' => (int)$_POST['forum_class'],
$tmp['_FIELD_TYPES']['forum_threadclass'] = 'int'; 'forum_postclass' => (int)$_POST['forum_postclass'],
$tmp['WHERE'] = 'forum_id = '.(int)$id; 'forum_threadclass' => (int)$_POST['forum_threadclass'],
$tmp['data']['forum_name'] = $_POST['forum_name']; 'WHERE' => 'forum_id = '.(int)$id
$tmp['data']['forum_datestamp'] = time(); );
$tmp['data']['forum_class'] = $_POST['forum_class'];
$tmp['data']['forum_postclass'] = $_POST['forum_postclass']; if($sql->update('forum', $update))
$tmp['data']['forum_threadclass'] = $_POST['forum_threadclass']; {
$sql->update('forum', $tmp); $mes->addSuccess(LAN_UPDATED);
}
else
{
$mes->addError(LAN_UPDATED_FAILED);
}
$mes->addSuccess(LAN_UPDATED);
$action = 'main'; $action = 'main';
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if(isset($_POST['submit_forum'])) if(isset($_POST['submit_forum']))
{ {
$tmp = array(); $tmp = array();
$tmp['forum_moderators'] = (int)$_POST['forum_moderators']; $tmp['forum_moderators'] = (int)$_POST['forum_moderators'];
$tmp['forum_name'] = $tp->toDB($_POST['forum_name']); $tmp['forum_name'] = $tp->toDB($_POST['forum_name']);
$tmp['forum_description'] = $tp->toDB($_POST['forum_description']); $tmp['forum_description'] = $tp->toDB($_POST['forum_description']);
$tmp['forum_datestamp'] = time(); $tmp['forum_datestamp'] = time();
$tmp['forum_class'] = (int)$_POST['forum_class']; $tmp['forum_class'] = (int)$_POST['forum_class'];
$tmp['forum_postclass'] = (int)$_POST['forum_postclass']; $tmp['forum_postclass'] = (int)$_POST['forum_postclass'];
$tmp['forum_threadclass'] = (int)$_POST['forum_threadclass']; $tmp['forum_threadclass'] = (int)$_POST['forum_threadclass'];
$tmp['forum_parent'] = (int)$_POST['forum_parent']; $tmp['forum_parent'] = (int)$_POST['forum_parent'];
if($sql->insert('forum', $tmp)) if($sql->insert('forum', $tmp))
{ {
$mes->addSuccess(LAN_CREATED); $mes->addSuccess(LAN_CREATED);
@@ -237,30 +252,32 @@ if(isset($_POST['submit_forum']))
{ {
$mes->addError(LAN_CREATED_FAILED); $mes->addError(LAN_CREATED_FAILED);
} }
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if(isset($_POST['update_forum'])) if(isset($_POST['update_forum']))
{ {
unset($_POST['update_forum']); unset($_POST['update_forum']);
$tmp['data'] = $_POST; $tmp['data'] = $_POST;
$tmp['WHERE'] = 'forum_id = '.(int)$id; $tmp['WHERE'] = 'forum_id = '.(int)$id;
$tmp2['forum_moderators'] = $tmp['forum_moderators']; $tmp2['forum_moderators'] = $tmp['forum_moderators'];
$tmp2['forum_class'] = $tmp['forum_class']; $tmp2['forum_class'] = $tmp['forum_class'];
$tmp2['forum_postclass'] = $tmp['forum_postclass']; $tmp2['forum_postclass'] = $tmp['forum_postclass'];
$tmp2['forum_threadclass'] = $tmp['forum_threadclass']; $tmp2['forum_threadclass'] = $tmp['forum_threadclass'];
$tmp2['WHERE'] = 'forum_sub = '.(int)$id; $tmp2['WHERE'] = 'forum_sub = '.(int)$id;
$sql->update('forum', $tmp); $sql->update('forum', $tmp);
$sql->update('forum', $tmp2); $sql->update('forum', $tmp2);
$mes->addSuccess(LAN_UPDATED); $mes->addSuccess(LAN_UPDATED);
$ns->tablerender($caption, $mes->render().$text);
$action = 'main'; $action = 'main';
} }
$ns->tablerender($caption, $mes->render() . $text);
if (isset($_POST['update_order'])) if (isset($_POST['update_order']))
{ {
@@ -270,9 +287,10 @@ if (isset($_POST['update_order']))
$sql->update('forum', "forum_order=".$tmp[1]." WHERE forum_id=".$tmp[0]); $sql->update('forum', "forum_order=".$tmp[1]." WHERE forum_id=".$tmp[0]);
} }
$mes->addSuccess(LAN_UPDATED); $mes->addSuccess(LAN_UPDATED);
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if (isset($_POST['updateoptions'])) if (isset($_POST['updateoptions']))
{ {
@@ -298,24 +316,26 @@ if (isset($_POST['updateoptions']))
$fPref->save(true, true); $fPref->save(true, true);
$mes->addSuccess(); $mes->addSuccess();
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if (isset($_POST['do_prune'])) if (isset($_POST['do_prune']))
{ {
$msg = $for->forumPrune($_POST['prune_type'], $_POST['prune_days'], $_POST['pruneForum']); $msg = $for->forumPrune($_POST['prune_type'], $_POST['prune_days'], $_POST['pruneForum']);
$mes->addSuccess($msg); $mes->addSuccess($msg);
$action = 'main'; $action = 'main';
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if (isset($_POST['frsubmit'])) if (isset($_POST['frsubmit']))
{ {
$guestrules = $tp->toDB($_POST['guestrules']); $guestrules = $tp->toDB($_POST['guestrules']);
$memberrules = $tp->toDB($_POST['memberrules']); $memberrules = $tp->toDB($_POST['memberrules']);
$adminrules = $tp->toDB($_POST['adminrules']); $adminrules = $tp->toDB($_POST['adminrules']);
if(!$sql->update("generic", "gen_chardata ='$guestrules', gen_intdata='".$_POST['guest_active']."' WHERE gen_type='forum_rules_guest' ")) if(!$sql->update("generic", "gen_chardata ='$guestrules', gen_intdata='".$_POST['guest_active']."' WHERE gen_type='forum_rules_guest' "))
{ {
$sql->insert("generic", "0, 'forum_rules_guest', '".time()."', 0, '', '".$_POST['guest_active']."', '$guestrules' "); $sql->insert("generic", "0, 'forum_rules_guest', '".time()."', 0, '', '".$_POST['guest_active']."', '$guestrules' ");
@@ -328,10 +348,9 @@ if (isset($_POST['frsubmit']))
{ {
$sql->insert("generic", "0, 'forum_rules_admin', '".time()."', 0, '', '".$_POST['admin_active']."', '$adminrules' "); $sql->insert("generic", "0, 'forum_rules_admin', '".time()."', 0, '', '".$_POST['admin_active']."', '$adminrules' ");
} }
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if (vartrue($delete) == 'main') { if (vartrue($delete) == 'main') {
if ($sql->delete('forum', "forum_id='$del_id' ")) if ($sql->delete('forum', "forum_id='$del_id' "))
{ {
@@ -341,9 +360,9 @@ if (vartrue($delete) == 'main') {
{ {
$mes->addError(LAN_DELETED_FAILED); $mes->addError(LAN_DELETED_FAILED);
} }
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
if (vartrue($action) == 'create') if (vartrue($action) == 'create')
{ {
@@ -369,10 +388,12 @@ if ($delete == 'cat')
else else
{ {
$mes->addError(LAN_DELETED_FAILED); $mes->addError(LAN_DELETED_FAILED);
} }
$ns->tablerender($caption, $mes->render().$text);
} }
$ns->tablerender($caption, $mes->render() . $text);
switch($action) switch($action)
{ {
@@ -425,34 +446,31 @@ if ($delete == 'reported')
} }
if (!e_QUERY || $action == 'main') if (!e_QUERY || $action == 'main')
{ {
$forum->show_existing_forums(vartrue($sub_action), vartrue($id)); $forum->show_existing_forums(vartrue($sub_action), vartrue($id));
} }
//$forum->show_options($action);
require_once(e_ADMIN.'footer.php'); require_once(e_ADMIN.'footer.php');
function headerjs() // function headerjs()
{ // {
$e107 = e107::getInstance(); // $e107 = e107::getInstance();
$tp = e107::getParser(); // $tp = e107::getParser();
// These functions need to be removed and replaced with the generic jsconfirm() function. // // These functions need to be removed and replaced with the generic jsconfirm() function.
$headerjs = "<script type=\"text/javascript\"> // $headerjs = "<script type=\"text/javascript\">
function confirm_(mode, forum_id, forum_name) { // function confirm_(mode, forum_id, forum_name) {
if (mode == 'sr') { // if (mode == 'sr') {
return confirm(\"".$tp->toJS(FORLAN_117)."\"); // return confirm(\"".$tp->toJS(FORLAN_117)."\");
} else if(mode == 'parent') { // } else if(mode == 'parent') {
return confirm(\"".$tp->toJS(FORLAN_81)." [ID: \" + forum_name + \"]\"); // return confirm(\"".$tp->toJS(FORLAN_81)." [ID: \" + forum_name + \"]\");
} else { // } else {
return confirm(\"".$tp->toJS(FORLAN_82)." [ID: \" + forum_name + \"]\"); // return confirm(\"".$tp->toJS(FORLAN_82)." [ID: \" + forum_name + \"]\");
} // }
} // }
</script>"; // </script>";
return $headerjs; // return $headerjs;
} // }
function forum_admin_adminmenu() function forum_admin_adminmenu()
{ {
@@ -472,6 +490,7 @@ class forumAdmin
$sql = e107::getDb(); $sql = e107::getDb();
if ($action == '') { $action = 'main'; } if ($action == '') { $action = 'main'; }
// ##### Display options --------------------------------------------------------------------------------------------------------- // ##### Display options ---------------------------------------------------------------------------------------------------------
$var['main']['text'] = FORLAN_76; $var['main']['text'] = FORLAN_76;
$var['main']['link'] = e_SELF; $var['main']['link'] = e_SELF;
@@ -502,14 +521,21 @@ class forumAdmin
function delete_item($id) function delete_item($id)
{ {
if($_POST['cancel'])
{
$this->show_existing_forums(vartrue($sub_action), vartrue($id));
return;
}
$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_id = {$id}")) if($sql->select('forum', 'forum_parent, forum_sub', "forum_id = {$id}"))
{ {
$txt = ""; $txt = "";
$row = $sql->fetch(); $row = $sql->fetch();
if($row['forum_parent'] == 0) if($row['forum_parent'] == 0)
{ {
$txt .= $this->delete_parent($id, $confirm); $txt .= $this->delete_parent($id, $confirm);
@@ -522,15 +548,25 @@ class forumAdmin
{ {
$txt .= $this->delete_forum($id, $confirm); $txt .= $this->delete_forum($id, $confirm);
} }
if($confirm) if($confirm)
{ {
$this->show_message($txt); e107::getRender()->tablerender('', e107::getMessage()->render().$txt);
} }
else else
{ {
$this->delete_show_confirm($txt); $this->delete_show_confirm($txt);
} }
} }
else
{
// forum_id not found, should not happen.
$this->show_existing_forums(vartrue($sub_action), vartrue($id));
return;
}
} }
function delete_parent($id, $confirm = false) function delete_parent($id, $confirm = false)
@@ -539,41 +575,34 @@ class forumAdmin
$mes = e107::getMessage(); $mes = e107::getMessage();
$ns = e107::getRender(); $ns = e107::getRender();
//$ret = '';
if($sql->select('forum', 'forum_id', "forum_parent = {$id} AND forum_sub = 0")) if($sql->select('forum', 'forum_id', "forum_parent = {$id} AND forum_sub = 0"))
{ {
$fList = $sql->db_getList(); $fList = $sql->db_getList();
foreach($fList as $f) foreach($fList as $f)
{ {
$ret .= $this->delete_forum($f['forum_id'], $confirm); $this->delete_forum($f['forum_id'], $confirm);
} }
} }
if($confirm) if($confirm)
{ {
if($sql->delete('forum', "forum_id = {$id}")) if($sql->delete('forum', "forum_id = {$id}"))
{ {
//$ret .= 'Forum parent successfully deleted'; return LAN_DELETED;
$mes->addSuccess(LAN_DELETED);
} }
else else
{ {
//$ret .= 'Forum parent could not be deleted'; // TODO LAN return LAN_DELETED_FAILED;
$mes->addError(LAN_DELETED_FAILED);
} }
//return $ret;
$ns->tablerender($caption, $mes->render(). $text);
} }
//return 'The forum parent has the following info: <br />'.$ret; // TODO LAN
} }
function deleteForum($forumId) function deleteForum($forumId)
{ {
$sql = e107::getDb(); $sql = e107::getDb();
$forumId = (int)$forumId; $forumId = (int)$forumId;
// echo "id = $forumId <br />";
// 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}"))
{ {
@@ -603,35 +632,31 @@ class forumAdmin
$ns = e107::getRender(); $ns = e107::getRender();
$mes = e107::getMessage(); $mes = e107::getMessage();
//$ret = '';
if($sql->select('forum', 'forum_id', 'forum_sub = '.$id)) if($sql->select('forum', 'forum_id', 'forum_sub = '.$id))
{ {
$fList = $sql->db_getList(); $fList = $sql->db_getList();
foreach($fList as $f) foreach($fList as $f)
{ {
$ret .= $this->delete_sub($f['forum_id'], $confirm); $this->delete_sub($f['forum_id'], $confirm);
} }
} }
if($confirm) if($confirm)
{ {
if($this->deleteForum($id)) if($this->deleteForum($id))
{ {
//$ret .= "Forum {$id} successfully deleted"; // TODO LAN
$mes->addSuccess(LAN_DELETED); $mes->addSuccess(LAN_DELETED);
} }
else else
{ {
//$ret .= "Forum {$id} could not be deleted"; // TODO LAN
$mes->addError(LAN_DELETED_FAILED); $mes->addError(LAN_DELETED_FAILED);
} }
} }
$sql->select('forum', 'forum_name, forum_threads, forum_replies', 'forum_id = '.$id); $sql->select('forum', 'forum_name, forum_threads, forum_replies', 'forum_id = '.$id);
$row = $sql->fetch(); $row = $sql->fetch();
//return "Forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies. <br />".$ret;
$mes->addInfo("Forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads and {$row['forum_replies']} replies."); //FIXME combine multiple info's into one message $mes->addInfo("Forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads and {$row['forum_replies']} replies.");
$ns->tablerender($caption, $mes->render() . $text);
} }
function delete_sub($id, $confirm = FALSE) function delete_sub($id, $confirm = FALSE)
@@ -645,38 +670,34 @@ class forumAdmin
{ {
if($this->deleteForum($id)) if($this->deleteForum($id))
{ {
//$ret .= "Sub-forum {$id} successfully deleted"; // TODO LAN
$mes->addSuccess(LAN_DELETED); $mes->addSuccess(LAN_DELETED);
} }
else else
{ {
//$ret .= "Sub-forum {$id} could not be deleted"; // TODO LAN
$mes->addError(LAN_DELETED); $mes->addError(LAN_DELETED);
} }
//return $ret;
} }
$sql->select('forum', '*', 'forum_id = '.$id); $sql->select('forum', '*', 'forum_id = '.$id);
$row = $sql->fetch(); $row = $sql->fetch();
//return "Sub-forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies. <br />".$ret; $mes->addInfo("Sub-forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies.");
$mes->addInfo("Sub-forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies."); // FIXME show just once on confirm and not LAN_DELETED
$ns->tablerender($caption, $mes->render() . $text);
} }
function delete_show_confirm($txt) function delete_show_confirm($message)
{ {
$ns = e107::getRender(); $mes = e107::getMessage();
$this->show_message($txt);
$frm = e107::getForm(); $mes->addInfo($message);
$txt = "
$text = "
<form method='post' action='".e_SELF.'?'.e_QUERY."'> <form method='post' action='".e_SELF.'?'.e_QUERY."'>
<div style='text-align:center'>".LAN_CONFDELETE."<br /><br /> <div align='center'>
".$frm->admin_button('confirm', LAN_UI_DELETE_LABEL, 'submit')." ".e107::getForm()->admin_button('confirm', LAN_UI_DELETE_LABEL, 'delete')."
<input type='submit' class='btn btn-warning button' name='confirm' value='".LAN_DELETE."' /> ".e107::getForm()->admin_button('cancel', LAN_CANCEL, 'cancel')."
</div> </div>
</form> </form>
"; ";
$ns->tablerender(LAN_UI_DELETE_LABEL, $txt); e107::getRender()->tablerender('Forum'.SEP.'Delete forum(s)', $mes->render().$text);
} }
function show_subs($id) function show_subs($id)
@@ -891,7 +912,6 @@ class forumAdmin
function create_parents($sub_action, $id) function create_parents($sub_action, $id)
{ {
//global $e107;
$frm = e107::getForm(); $frm = e107::getForm();
$sql = e107::getDb(); $sql = e107::getDb();
$tp = e107::getParser(); $tp = e107::getParser();
@@ -1052,11 +1072,11 @@ class forumAdmin
} }
function show_message($message) // FIX // function show_message($message)
{ // {
$ns = e107::getRender();
$ns->tablerender('', "<div style='text-align:center'><b>".$message."</b></div>"); //FIX: v2 style = render? // e107::getRender();->tablerender('', $message);
} // }
function show_tools() function show_tools()
@@ -1273,9 +1293,8 @@ class forumAdmin
$ns->tablerender(FORLAN_62, $mes->render() . $text); $ns->tablerender(FORLAN_62, $mes->render() . $text);
} }
function show_reported ($sub_action, $id) // FIXME - $id does not seem to be in use.. remove? function show_reported($sub_action)
{ {
//global $rs; // FIX replace by $frm
$rs = new form; // FIXME - update to $frm $rs = new form; // FIXME - update to $frm
$sql = e107::getDb(); $sql = e107::getDb();
$ns = e107::getRender(); $ns = e107::getRender();
@@ -1287,7 +1306,7 @@ class forumAdmin
$row = $sql->fetch(); $row = $sql->fetch();
$sql->select("user", "*", "user_id='". $row['gen_user_id']."'"); $sql->select("user", "*", "user_id='". $row['gen_user_id']."'");
$user = $sql->fetch(); $user = $sql->fetch();
$con = new convert; //$con = new convert;
$text = " $text = "
<table class='table adminlist'> <table class='table adminlist'>
<colgroup span='2'> <colgroup span='2'>
@@ -1309,7 +1328,7 @@ class forumAdmin
</tr> </tr>
<tr> <tr>
<td>".FORLAN_175.":</td> <td>".FORLAN_175.":</td>
<td>".$con -> convert_date($row['gen_datestamp'], "long")."</td> <td>".e107::getDate()->convert_date($row['gen_datestamp'], "long")."</td>
</tr> </tr>
<tr> <tr>
<td>".FORLAN_176.":</td> <td>".FORLAN_176.":</td>
@@ -1324,7 +1343,7 @@ class forumAdmin
</tr> </tr>
</table>"; </table>";
$ns -> tablerender(FORLAN_116, $text); $ns->tablerender(FORLAN_116, $text);
} }
else else
@@ -1339,14 +1358,15 @@ class forumAdmin
</tr>"; </tr>";
while ($row = $sql->fetch()) while ($row = $sql->fetch())
{ {
$text .= "<tr> $text .= "
<td<a href='".e_SELF."?sr.".$row['gen_id']."'>".FORLAN_171." #".$row['gen_intdata']."</a></td> <tr>
<td text-align:center; vertical-align:top; white-space: nowrap'> <td<a href='".e_SELF."?sr.".$row['gen_id']."'>".FORLAN_171." #".$row['gen_intdata']."</a></td>
".$rs->form_open("post", e_SELF."?sr", "", "", "", " onsubmit=\"return confirm_('sr',".$row['gen_datestamp'].")\"")." <td text-align:center; vertical-align:top; white-space: nowrap'>
".$rs->form_button("submit", "delete[reported_{$row['gen_id']}]", FORLAN_172)." ".$rs->form_open("post", e_SELF."?sr", "", "", "", " onsubmit=\"return confirm_('sr',".$row['gen_datestamp'].")\"")."
".$rs->form_close()." ".$rs->form_button("submit", "delete[reported_{$row['gen_id']}]", FORLAN_172)."
</td> ".$rs->form_close()."
</tr>\n"; </td>
</tr>";
} }
$text .= "</table>"; $text .= "</table>";
} }
@@ -1355,7 +1375,7 @@ class forumAdmin
//$text = "<div style='text-align:center'>".FORLAN_121."</div>"; //$text = "<div style='text-align:center'>".FORLAN_121."</div>";
$mes->addInfo(FORLAN_121); $mes->addInfo(FORLAN_121);
} }
$ns->tablerender(FORLAN_116, $mes->render() . $text); $ns->tablerender(FORLAN_116, $mes->render().$text);
} }
} }

View File

@@ -717,16 +717,16 @@ class e107ForumThread
break; break;
case 'report': case 'report':
$threadId = (int)$_GET['id']; $threadId = (int)$_GET['id'];
$postId = (int)$_GET['post']; $postId = (int)$_GET['post'];
$postInfo = $forum->postGet($postId, 'post'); $postInfo = $forum->postGet($postId, 'post');
if (isset($_POST['report_thread'])) if(isset($_POST['report_thread']))
{ {
$report_add = $tp->toDB($_POST['report_add']); $report_add = $tp->toDB($_POST['report_add']);
if ($forum->prefs->get('reported_post_email')) if($forum->prefs->get('reported_post_email'))
{ {
require_once (e_HANDLER . 'mail.php'); require_once(e_HANDLER.'mail.php');
$report = LAN_FORUM_2018." ".SITENAME." : ".(substr(SITEURL, -1) == "/" ? SITEURL : SITEURL."/") . $e107->getFolder('plugins') . "forum/forum_viewtopic.php?" . $this->threadId . ".post\n $report = LAN_FORUM_2018." ".SITENAME." : ".(substr(SITEURL, -1) == "/" ? SITEURL : SITEURL."/") . $e107->getFolder('plugins') . "forum/forum_viewtopic.php?" . $this->threadId . ".post\n
".LAN_FORUM_2019.": ".USERNAME. "\n" . $report_add; ".LAN_FORUM_2019.": ".USERNAME. "\n" . $report_add;
$subject = LAN_FORUM_2020." ". SITENAME; $subject = LAN_FORUM_2020." ". SITENAME;
@@ -737,7 +737,7 @@ class e107ForumThread
define('e_PAGETITLE', LAN_FORUM_1001 . " / " . LAN_FORUM_2021); define('e_PAGETITLE', LAN_FORUM_1001 . " / " . LAN_FORUM_2021);
$url = $e107->url->create('forum/thread/post', array('id' => $postId, 'name' => $postInfo['thread_name'], 'thread' => $threadId)); // both post info and thread info contain thread name $url = $e107->url->create('forum/thread/post', array('id' => $postId, 'name' => $postInfo['thread_name'], 'thread' => $threadId)); // both post info and thread info contain thread name
$text = LAN_FORUM_2021 . "<br /><br /><a href='{$url}'>".LAN_FORUM_2022.'</a>'; $text = LAN_FORUM_2021 . "<br /><br /><a href='{$url}'>".LAN_FORUM_2022.'</a>';
return $ns->tablerender(LAN_FORUM_2023, $text, array('forum_viewtopic', 'report'), true); return $ns->tablerender(LAN_FORUM_2023, $text, array('forum_viewtopic', 'report'), false);
} }
else else
{ {
@@ -763,7 +763,7 @@ class e107ForumThread
<td colspan='2' style='text-align:center;'><br /><input class='btn btn-default button' type='submit' name='report_thread' value='".LAN_FORUM_2029."' /></td> <td colspan='2' style='text-align:center;'><br /><input class='btn btn-default button' type='submit' name='report_thread' value='".LAN_FORUM_2029."' /></td>
</tr> </tr>
</table>"; </table>";
return e107::getRender()->tablerender(LAN_FORUM_2023, $text, array('forum_viewtopic', 'report2'), true); return e107::getRender()->tablerender(LAN_FORUM_2023, $text, array('forum_viewtopic', 'report2'), false);
} }
exit; exit;

View File

@@ -162,7 +162,7 @@ define("FORLAN_140", "View");
define("FORLAN_141", "Post"); define("FORLAN_141", "Post");
define("FORLAN_142", "Post permission"); define("FORLAN_142", "Post permission");
define("FORLAN_143", "Indicates who can post to the forum"); define("FORLAN_143", "Indicates who can post to the forum");
define("FORLAN_144", "Moderators set"); //define("FORLAN_144", "Moderators set");
define("FORLAN_145", "Configure sub-forums"); define("FORLAN_145", "Configure sub-forums");
define("FORLAN_146", "No sub-forums yet"); define("FORLAN_146", "No sub-forums yet");
//define("FORLAN_147", "Update sub-forums"); //define("FORLAN_147", "Update sub-forums");