1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Issue #90 - Forum plugin (also #6 and GUI styling)

This commit is contained in:
Tijn Kuyper 2013-02-06 17:09:22 +01:00
parent 50fc673a7b
commit c923ed8e95
3 changed files with 126 additions and 102 deletions

View File

@ -29,10 +29,12 @@ require_once(e_HANDLER.'form_handler.php');
require_once(e_HANDLER.'ren_help.php');
require_once(e_PLUGIN.'forum/forum_class.php');
require_once(e_PLUGIN.'forum/forum_admin_class.php');
$emessage = eMessage::getInstance();
$rs = new form;
//$emessage = eMessage::getInstance();
$mes = e107::getMessage();
$rs = new form; // FIX TODO needs $frm
$for = new e107forum;
$forum = new forumAdmin;
$sql = e107::getDb();
$fPref = e107::getPlugConfig('forum', '', false);
@ -61,11 +63,14 @@ if(isset($_POST['setMods']))
{
foreach($_POST['mods'] as $fid => $modid)
{
$e107->sql->db_Update('forum',"forum_moderators = '{$modid}' WHERE forum_id = {$fid}");
$sql->db_Update('forum',"forum_moderators = '{$modid}' WHERE forum_id = {$fid}");
}
$forum->show_message(FORLAN_144);
//$forum->show_message(FORLAN_144);
$mes->addSuccess(FORLAN_144);
}
$ns->tablerender($caption, $mes->render() . $text);
if(isset($_POST['tools']))
{
$msg = '';
@ -106,9 +111,12 @@ if(isset($_POST['tools']))
}
$msg .= FORLAN_169.' <br />';
}
$forum->show_message($msg);
//$forum->show_message($msg);
$mes->addSuccess($msg);
}
$ns->tablerender($caption, $mes->render() . $text);
if(isset($_POST['create_sub']))
{
$fid = (int)($sub_action);
@ -117,25 +125,29 @@ if(isset($_POST['create_sub']))
$tmp['forum_description'] = $e107->tp->toDB($_POST['subdesc_new']);
$tmp['forum_order'] = (int)$_POST['suborder_new'];
if($tmp['forum_name'] != '' && $e107->sql->db_Select('forum', '*', "forum_id = {$fid}"))
if($tmp['forum_name'] != '' && $sql->db_Select('forum', '*', "forum_id = {$fid}"))
{
$row = $e107->sql->db_Fetch();
$row = $sql->db_Fetch();
$tmp['forum_parent'] = $row['forum_parent'];
$tmp['forum_moderators'] = $row['forum_moderators'];
$tmp['forum_class'] = $row['forum_class'];
$tmp['forum_postclass'] = $row['forum_postclass'];
$tmp['forum_sub'] = $fid;
if($e107->sql->db_Insert('forum', $tmp))
if($sql->db_Insert('forum', $tmp))
{
$forum->show_message(FORLAN_150.' - '.LAN_CREATED);
//$forum->show_message(FORLAN_150.' - '.LAN_CREATED);
$mes->addSuccess(LAN_CREATED);
}
else
{
$forum->show_message(FORLAN_150.' - '.LAN_CREATED_FAILED);
//$forum->show_message(FORLAN_150.' - '.LAN_CREATED_FAILED);
$mes->addSuccess(LAN_CREATED_FAILED);
}
}
}
$ns->tablerender($caption, $mes->render() . $text);
if(isset($_POST['update_subs']))
{
$msg = "";
@ -143,10 +155,10 @@ if(isset($_POST['update_subs']))
{
if($_POST['subname'][$id] == "")
{
if ($e107->sql->db_Delete("forum", "forum_id='$id' "))
if ($sql->db_Delete("forum", "forum_id='$id' "))
{
$msg .= FORLAN_150." ".$id." ".LAN_DELETED."<br />";
$cnt = $e107->sql->db_Delete("forum_t", "thread_forum_id = {$id}");
$msg .= FORLAN_150." ". LAN_ID.":"." ".$id." ".LAN_DELETED."<br />";
$cnt = $sql->db_Delete("forum_t", "thread_forum_id = {$id}");
$msg .= $cnt." ".FORLAN_152." ".LAN_DELETED."<br />";
}
}
@ -155,15 +167,17 @@ if(isset($_POST['update_subs']))
$_name = $e107->tp->toDB($_POST['subname'][$id]);
$_desc = $e107->tp->toDB($_POST['subdesc'][$id]);
$_order = (int)$_POST['suborder'][$id];
if($e107->sql->db_Update('forum', "forum_name='{$_name}', forum_description='{$_desc}', forum_order='{$_order}' WHERE forum_id = {$id}"))
if($sql->db_Update('forum', "forum_name='{$_name}', forum_description='{$_desc}', forum_order='{$_order}' WHERE forum_id = {$id}"))
{
$msg .= FORLAN_150.' '.$id.' '.LAN_UPDATED.'<br />';
$msg .= FORLAN_150 ." ". LAN_ID.":"." ".$id." ".LAN_UPDATED."<br />";
}
}
}
if($msg)
{
$forum->show_message($msg);
//$forum->show_message($msg);
$mes->addSuccess($msg);
$ns->tablerender($caption, $mes->render() . $text);
}
}
@ -175,7 +189,7 @@ if(isset($_POST['submit_parent']))
$tmp['forum_class'] = (int)$_POST['forum_class'];
$tmp['forum_postclass'] = (int)$_POST['forum_postclass'];
$tmp['forum_threadclass'] = (int)$_POST['forum_threadclass'];
if($e107->sql->db_Insert('forum',$tmp))
if($sql->db_Insert('forum',$tmp))
{
$forum->show_message(FORLAN_22.' - '.LAN_CREATED);
}
@ -199,7 +213,7 @@ if(isset($_POST['update_parent']))
$tmp['data']['forum_class'] = $_POST['forum_class'];
$tmp['data']['forum_postclass'] = $_POST['forum_postclass'];
$tmp['data']['forum_threadclass'] = $_POST['forum_threadclass'];
e107::getDb()->db_Update('forum', $tmp);
$sql->db_Update('forum', $tmp);
$forum->show_message(FORLAN_14);
$action = 'main';
}
@ -215,7 +229,7 @@ if(isset($_POST['submit_forum']))
$tmp['forum_postclass'] = (int)$_POST['forum_postclass'];
$tmp['forum_threadclass'] = (int)$_POST['forum_threadclass'];
$tmp['forum_parent'] = (int)$_POST['forum_parent'];
if($e107->sql->db_Insert('forum',$tmp))
if($sql->db_Insert('forum',$tmp))
{
$forum->show_message(FORLAN_36.' - '.LAN_CREATED);
}
@ -237,8 +251,8 @@ if(isset($_POST['update_forum']))
$tmp2['forum_threadclass'] = $tmp['forum_threadclass'];
$tmp2['WHERE'] = 'forum_sub = '.(int)$id;
$e107->sql->db_Update('forum', $tmp);
$e107->sql->db_Update('forum', $tmp2);
$sql->db_Update('forum', $tmp);
$sql->db_Update('forum', $tmp2);
$forum->show_message(FORLAN_12);
$action = 'main';
@ -249,11 +263,14 @@ if (isset($_POST['update_order']))
while (list($key, $id) = each($_POST['forum_order']))
{
$tmp = explode('.', $id);
$e107->sql->db_Update('forum', "forum_order=".$tmp[1]." WHERE forum_id=".$tmp[0]);
$sql->db_Update('forum', "forum_order=".$tmp[1]." WHERE forum_id=".$tmp[0]);
}
$forum->show_message(FORLAN_73);
//$forum->show_message(FORLAN_73);
$mes->addSuccess(LAN_UPDATED);
}
$ns->tablerender($caption, $mes->render() . $text);
if (isset($_POST['updateoptions']))
{
$fPref->set('notify', $_POST['email_notify']);
@ -276,7 +293,9 @@ if (isset($_POST['updateoptions']))
$fPref->set('maxwidth', $_POST['forum_maxwidth']);
$fPref->set('linkimg', $_POST['forum_linkimg']);
$fPref->save(true, true);
$emessage->add(FORLAN_10, E_MESSAGE_SUCCESS);
//$emessage->add(FORLAN_10, E_MESSAGE_SUCCESS);
$mes->addSuccess();
// $forum->show_message(FORLAN_10);
}
@ -292,30 +311,30 @@ if (isset($_POST['frsubmit']))
$guestrules = $e107->tp->toDB($_POST['guestrules']);
$memberrules = $e107->tp->toDB($_POST['memberrules']);
$adminrules = $e107->tp->toDB($_POST['adminrules']);
if(!$e107->sql->db_Update("generic", "gen_chardata ='$guestrules', gen_intdata='".$_POST['guest_active']."' WHERE gen_type='forum_rules_guest' "))
if(!$sql->db_Update("generic", "gen_chardata ='$guestrules', gen_intdata='".$_POST['guest_active']."' WHERE gen_type='forum_rules_guest' "))
{
$e107->sql->db_Insert("generic", "0, 'forum_rules_guest', '".time()."', 0, '', '".$_POST['guest_active']."', '$guestrules' ");
$sql->db_Insert("generic", "0, 'forum_rules_guest', '".time()."', 0, '', '".$_POST['guest_active']."', '$guestrules' ");
}
if(!$e107->sql->db_Update("generic", "gen_chardata ='$memberrules', gen_intdata='".$_POST['member_active']."' WHERE gen_type='forum_rules_member' "))
if(!$sql->db_Update("generic", "gen_chardata ='$memberrules', gen_intdata='".$_POST['member_active']."' WHERE gen_type='forum_rules_member' "))
{
$e107->sql->db_Insert("generic", "0, 'forum_rules_member', '".time()."', 0, '', '".$_POST['member_active']."', '$memberrules' ");
$sql->db_Insert("generic", "0, 'forum_rules_member', '".time()."', 0, '', '".$_POST['member_active']."', '$memberrules' ");
}
if(!$e107->sql->db_Update("generic", "gen_chardata ='$adminrules', gen_intdata='".$_POST['admin_active']."' WHERE gen_type='forum_rules_admin' "))
if(!$sql->db_Update("generic", "gen_chardata ='$adminrules', gen_intdata='".$_POST['admin_active']."' WHERE gen_type='forum_rules_admin' "))
{
$e107->sql->db_Insert("generic", "0, 'forum_rules_admin', '".time()."', 0, '', '".$_POST['admin_active']."', '$adminrules' ");
$sql->db_Insert("generic", "0, 'forum_rules_admin', '".time()."', 0, '', '".$_POST['admin_active']."', '$adminrules' ");
}
}
if (vartrue($delete) == 'main') {
if ($e107->sql->db_Delete('forum', "forum_id='$del_id' ")) {
if ($sql->db_Delete('forum', "forum_id='$del_id' ")) {
$forum->show_message(FORLAN_96);
}
}
if (vartrue($action) == 'create')
{
if ($e107->sql->db_Select('forum', '*', "forum_parent='0' "))
if ($sql->db_Select('forum', '*', "forum_parent='0' "))
{
$forum->create_forums($sub_action, $id);
}
@ -328,9 +347,9 @@ if (vartrue($action) == 'create')
if ($delete == 'cat')
{
if ($e107->sql->db_Delete('forum', "forum_id='$del_id' "))
if ($sql->db_Delete('forum', "forum_id='$del_id' "))
{
$e107->sql->db_Delete('forum', "forum_parent='$del_id' ");
$sql->db_Delete('forum', "forum_parent='$del_id' ");
$forum->show_message(FORLAN_97);
$action = 'main';
}
@ -382,12 +401,13 @@ switch($action)
if ($delete == 'reported')
{
$e107->sql->db_Delete("generic", "gen_id='$del_id' ");
$sql->db_Delete("generic", "gen_id='$del_id' ");
$forum->show_message(FORLAN_118);
}
if (!e_QUERY || $action == 'main')
{
$forum->show_existing_forums(vartrue($sub_action), vartrue($id));
@ -419,4 +439,6 @@ function forum_admin_adminmenu()
global $action;
$forum->show_options($action);
}
?>

View File

@ -12,6 +12,12 @@
* $Id$
*
*/
/* TODO
- Needs rewriting to V2 style including $msg->
- LAN
*/
class forumAdmin
{
@ -97,15 +103,15 @@ class forumAdmin
{
if($sql->db_Delete('forum', "forum_id = {$id}"))
{
$ret .= 'Forum parent successfully deleted';
$ret .= 'Forum parent successfully deleted'; // TODO LAN
}
else
{
$ret .= 'Forum parent could not be deleted';
$ret .= 'Forum parent could not be deleted'; // TODO LAN
}
return $ret;
}
return 'The forum parent has the following info: <br />'.$ret;
return 'The forum parent has the following info: <br />'.$ret; // TODO LAN
}
@ -153,12 +159,12 @@ class forumAdmin
{
if($this->deleteForum($id))
{
$ret .= "Forum {$id} successfully deleted";
$ret .= "Forum {$id} successfully deleted"; // TODO LAN
}
else
{
$ret .= "Forum {$id} could not be deleted";
}
$ret .= "Forum {$id} could not be deleted"; // TODO LAN
}
return $ret;
}
@ -175,11 +181,11 @@ class forumAdmin
{
if($this->deleteForum($id))
{
$ret .= "Sub-forum {$id} successfully deleted";
$ret .= "Sub-forum {$id} successfully deleted"; // TODO LAN
}
else
{
$ret .= "Sub-forum {$id} could not be deleted";
$ret .= "Sub-forum {$id} could not be deleted"; // TODO LAN
}
return $ret;
}
@ -193,10 +199,11 @@ class forumAdmin
{
$ns = e107::getRender();
$this->show_message($txt);
$frm = e107::getForm();
$txt = "
<form method='post' action='".e_SELF.'?'.e_QUERY."'>
<div style='text-align:center'>".FORLAN_180."<br /><br />
".$frm->admin_button('confirm', LAN_UI_DELETE_LABEL, 'submit')."
<div style='text-align:center'>".LAN_CONFDELETE."<br /><br />
".$frm->admin_button('confirm', LAN_UI_DELETE_LABEL, 'submit')."
<input type='submit' class='button' name='confirm' value='".LAN_DELETE."' />
</div>
</form>
@ -214,9 +221,9 @@ class forumAdmin
<form method='post' action='".e_SELF.'?'.e_QUERY."'>
<table class='table adminlist'>
<tr>
<td>".FORLAN_151."</td>
<td>".FORLAN_31."</td>
<td>".FORLAN_32."</td>
<td>".LAN_ID."</td>
<td>".LAN_NAME."</td>
<td>".LAN_DESCRIPTION."</td>
<td>".FORLAN_37."</td>
<td>".FORLAN_20."</td>
</tr>
@ -255,26 +262,26 @@ class forumAdmin
$txt .= "
<tr>
<td>".FORLAN_151."</td>
<td>".FORLAN_31."</td>
<td>".FORLAN_32."</td>
<td>".FORLAN_37."</td>
<td>&nbsp;</td>
<td>".LAN_ID."</td>
<td>".LAN_NAME."</td>
<td>".LAN_DESCRIPTION."</td>
<td>".FORLAN_37."</td>
<td>&nbsp;</td>
</tr>
<tr>
<td style='vertical-align:top'>&nbsp;</td>
<td><input class='tbox' type='text' name='subname_new' value='' size='30' maxlength='255' /></td>
<td><textarea cols='60' rows='2' class='tbox' name='subdesc_new'></textarea></td>
<td><input class='tbox' type='text' name='suborder_new' value='' size='3' maxlength='4' /></td>
<td>&nbsp;</td>
<td style='vertical-align:top'>&nbsp;</td>
<td><input class='tbox' type='text' name='subname_new' value='' size='30' maxlength='255' /></td>
<td><textarea cols='60' rows='2' class='tbox' name='subdesc_new'></textarea></td>
<td><input class='tbox' type='text' name='suborder_new' value='' size='3' maxlength='4' /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan='5' style='text-align:center'>".$frm->admin_button('create_sub', FORLAN_148, 'submit')."</td>
<td colspan='5' style='text-align:center'>".$frm->admin_button('create_sub', LAN_CREATE, 'submit')."</td>
</tr>
</table>
</form>
";
$ns->tablerender(FORLAN_149, $txt); // LAN
$ns->tablerender(FORLAN_149, $txt); // TODO LAN
}
function show_existing_forums($sub_action, $id, $mode = false)
@ -438,7 +445,7 @@ class forumAdmin
<table class='table adminform'>
<tr>
<td>".FORLAN_31.":</td>
<td>".LAN_NAME.":</td>
<td>
<input class='tbox' type='text' name='forum_name' size='60' value='".$tp->toForm($row['forum_name'])."' maxlength='250' />
</td>
@ -525,43 +532,39 @@ class forumAdmin
</tr>
<tr>
<td>".FORLAN_31.":</td>
<td>
<input class='tbox' type='text' name='forum_name' size='60' value='".$tp->toForm(vartrue($fInfo['forum_name']))."' maxlength='250' /><span class='field-help'>".FORLAN_179."</span>
</td>
<td>".LAN_NAME.":</td>
<td><input class='tbox' type='text' name='forum_name' size='60' value='".$tp->toForm(vartrue($fInfo['forum_name']))."' maxlength='250' /><span class='field-help'>".FORLAN_179."</span></td>
</tr>
<tr>
<td>".FORLAN_32.":</td>
<td>
<textarea class='tbox' name='forum_description' cols='50' rows='5'>".$tp->toForm(vartrue($fInfo['forum_description']))."</textarea>
</td>
<td>".LAN_DESCRIPTION.":</td>
<td><textarea class='tbox' name='forum_description' cols='50' rows='5'>".$tp->toForm(vartrue($fInfo['forum_description']))."</textarea></td>
</tr>
<tr>
<td>".FORLAN_33.":</td>
<td>";
$text .= $e107->user_class->uc_dropdown('forum_moderators', $fInfo['forum_moderators'], 'admin,classes')."<span class='field-help'>".FORLAN_34."</span>";
$text .= "</td>
<td>".FORLAN_33.":</td>
<td>";
$text .= $e107->user_class->uc_dropdown('forum_moderators', $fInfo['forum_moderators'], 'admin,classes')."<span class='field-help'>".FORLAN_34."</span>";
$text .= "</td>
</tr>
<tr>
<td>".FORLAN_23.":</td>
<td>".$e107->user_class->uc_dropdown('forum_class', $fInfo['forum_class'], 'nobody,public,member,admin,classes')."<span class='field-help'>".FORLAN_24."</span></td>
<td>".FORLAN_23.":</td>
<td>".$e107->user_class->uc_dropdown('forum_class', $fInfo['forum_class'], 'nobody,public,member,admin,classes')."<span class='field-help'>".FORLAN_24."</span></td>
</tr>
<tr>
<td>".FORLAN_142.":</td>
<td>".$e107->user_class->uc_dropdown('forum_postclass', $fInfo['forum_postclass'], 'nobody,public,member,admin,classes')."<span class='field-help'>".FORLAN_143."</span></td>
<td>".FORLAN_142.":</td>
<td>".$e107->user_class->uc_dropdown('forum_postclass', $fInfo['forum_postclass'], 'nobody,public,member,admin,classes')."<span class='field-help'>".FORLAN_143."</span></td>
</tr>
<tr>
<td>".FORLAN_184.":</td>
<td>".$e107->user_class->uc_dropdown('forum_threadclass', $fInfo['forum_threadclass'], 'nobody,public,member,admin,classes')."<span class='field-help'>".FORLAN_185."</span></td>
<td>".FORLAN_184.":</td>
<td>".$e107->user_class->uc_dropdown('forum_threadclass', $fInfo['forum_threadclass'], 'nobody,public,member,admin,classes')."<span class='field-help'>".FORLAN_185."</span></td>
</tr>
<tr style='vertical-align:top'>
<td colspan='2' style='text-align:center'>";
</table>
<div class='buttons-bar center'>";
if ($sub_action == "edit")
{
$text .= $frm->admin_button('update_forum', LAN_UPDATE, 'update');
@ -570,10 +573,10 @@ class forumAdmin
{
$text .= $frm->admin_button('submit_forum', LAN_CREATE, 'submit');
}
$text .= "</td>
</tr>
</table>
</form>";
$text .= "
</div>
</form>
";
$ns->tablerender(FORLAN_28, $text);
}
@ -784,14 +787,14 @@ class forumAdmin
<td style='width:75%'>".FORLAN_132.":</td>
<td style='width:25%'>".($fPref->get('hilightsticky') ? "<input type='checkbox' name='forum_hilightsticky' value='1' checked='checked' />" : "<input type='checkbox' name='forum_hilightsticky' value='1' />")."<span class='field-help'>".FORLAN_133."</span></td>
</tr>
<tr>
<td colspan='2' style='text-align:center'>
".$frm->admin_button('updateoptions', LAN_UPDATE, 'update')."
</td>
</tr>
</table>
</form>";
<div class='buttons-bar center'>
".$frm->admin_button('updateoptions', LAN_UPDATE, 'update')."
</div>
</form>
";
$ns->tablerender(FORLAN_62, $emessage->render().$text);
}

View File

@ -18,7 +18,7 @@ define("FORLAN_6", "Cancel");
define("FORLAN_7", "Forum Options");
define("FORLAN_8", "Forums pruned.");
define("FORLAN_9", "Prune not required.");
define("FORLAN_10", "Options Saved");
//define("FORLAN_10", "Options Saved");
define("FORLAN_11", "Forum created");
define("FORLAN_12", "Forum updated");
define("FORLAN_13", "Parent created");
@ -39,8 +39,8 @@ define("FORLAN_27", "You need to define at least one forum parent before creatin
define("FORLAN_28", "Forums");
define("FORLAN_29", "No forums yet.");
define("FORLAN_30", "Existing Forums");
define("FORLAN_31", "Name");
define("FORLAN_32", "Description");
//define("FORLAN_31", "Name");
//define("FORLAN_32", "Description");
define("FORLAN_33", "Moderators");
define("FORLAN_34", "Choose userclass for moderators of this forum");
//define("FORLAN_35", "Update Forum");
@ -79,7 +79,7 @@ define('FORLAN_66', 'Not installed');
define("FORLAN_70", "Enable file / image attachments");
define("FORLAN_71", "Allow users to upload file or image with their forum post,");
//define("FORLAN_72", "Update Order");
define("FORLAN_73", "Order Updated");
//define("FORLAN_73", "Order Updated");
define("FORLAN_75", "Parents");
define("FORLAN_76", "Forums Front Page");
@ -165,11 +165,11 @@ define("FORLAN_143", "Indicates who can post to the forum");
define("FORLAN_144", "Moderators set");
define("FORLAN_145", "Configure sub-forums");
define("FORLAN_146", "No sub-forums yet");
define("FORLAN_147", "Update sub-forums");
define("FORLAN_148", "Create sub-forums");
//define("FORLAN_147", "Update sub-forums");
//define("FORLAN_148", "Create sub-forums");
define("FORLAN_149", "sub-forums");
define("FORLAN_150", "sub-forum");
define("FORLAN_151", "ID");
//define("FORLAN_151", "ID");
define("FORLAN_152", "posts");
define("FORLAN_153", "Tools");
define("FORLAN_154", "Reply Deleted");
@ -212,5 +212,4 @@ define('FORLAN_185', 'Indicates who can create new threads');
define('FORLAN_186', 'Threads per page');
define('FORLAN_187', 'Number of threads displayed per page');
?>