mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Easy editing of administrator perms from admin->users.
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
* Administrators Management
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_admin/administrator.php,v $
|
||||
* $Revision: 1.16 $
|
||||
* $Date: 2009-11-12 01:53:16 $
|
||||
* $Revision: 1.17 $
|
||||
* $Date: 2009-11-12 05:11:41 $
|
||||
* $Author: e107coders $
|
||||
*
|
||||
*/
|
||||
@@ -37,7 +37,8 @@ require_once('auth.php');
|
||||
require_once(e_HANDLER."form_handler.php");
|
||||
require_once(e_HANDLER."message_handler.php");
|
||||
$frm = new e_form(true);
|
||||
$emessage = &eMessage::getInstance();
|
||||
$emessage = e107::getMessage();
|
||||
$prm = e107::getUserPerms();
|
||||
|
||||
$action = '';
|
||||
$sub_action = -1;
|
||||
@@ -50,38 +51,9 @@ if (e_QUERY)
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['update_admin']))
|
||||
{ // Permissions updated
|
||||
$modID = intval($_POST['a_id']);
|
||||
if ($modID == 0)
|
||||
{
|
||||
exit;
|
||||
}
|
||||
$sql->db_Select("user", "*", "user_id=".$modID);
|
||||
$row = $sql->db_Fetch();
|
||||
$a_name = $row['user_name'];
|
||||
|
||||
$perm = "";
|
||||
|
||||
foreach($_POST['perms'] as $value)
|
||||
{
|
||||
$value = $tp->toDB($value);
|
||||
if ($value == "0")
|
||||
{
|
||||
if (!getperms('0')) { $value = ""; break; }
|
||||
$perm = "0"; break;
|
||||
}
|
||||
|
||||
if ($value)
|
||||
{
|
||||
$perm .= $value.".";
|
||||
}
|
||||
}
|
||||
|
||||
admin_update($sql->db_Update("user", "user_perms='{$perm}' WHERE user_id='{$modID}' "), 'update', sprintf(ADMSLAN_2, $tp->toDB($_POST['ad_name'])), false, false);
|
||||
$logMsg = str_replace(array('--ID--', '--NAME--'),array($modID, $a_name),ADMSLAN_72).$perm;
|
||||
$admin_log->log_event('ADMIN_01',$logMsg,E_LOG_INFORMATIVE,'');
|
||||
unset($modID, $ad_name, $a_perms);
|
||||
if (isset($_POST['update_admin'])) // Permissions updated
|
||||
{
|
||||
$prm->updatePerms($_POST['a_id'],$_POST['perms']);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +97,7 @@ if (isset($_POST['del_admin']) && count($_POST['del_admin']))
|
||||
|
||||
if(isset($_POST['edit_admin']) || $action == "edit")
|
||||
{
|
||||
edit_administrator($row);
|
||||
$prm->edit_administrator($row);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -139,10 +111,9 @@ function show_admins()
|
||||
$frm = e107::getForm();
|
||||
$ns = e107::getRender();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$tp = e107::getParser();
|
||||
$prm = e107::getUserPerms();
|
||||
|
||||
require_once(e_HANDLER."user_handler.php");
|
||||
$prm = new e_userperms;
|
||||
|
||||
|
||||
$sql->db_Select("user", "*", "user_admin='1'");
|
||||
@@ -176,7 +147,7 @@ function show_admins()
|
||||
$text .= "
|
||||
<tr>
|
||||
<td>".$row['user_id']."</td>
|
||||
<td><a href='".$e107->url->getUrl('core:user', 'main', "func=profile&id={$row['user_id']}")."'>".$row['user_name']."</a></td>
|
||||
<td><a href='".e107::getUrl()->getUrl('core:user', 'main', "func=profile&id={$row['user_id']}")."'>".$row['user_name']."</a></td>
|
||||
<td>
|
||||
".$prm->renderperms($row['user_perms'],$row['user_id'],"words")."
|
||||
</td>
|
||||
@@ -186,7 +157,7 @@ function show_admins()
|
||||
{
|
||||
$text .= "
|
||||
".$frm->submit_image("edit_admin[{$row['user_id']}]", 'edit', 'edit', LAN_EDIT)."
|
||||
".$frm->submit_image("del_admin[{$row['user_id']}]", 'del', 'delete', $e107->tp->toJS(ADMSLAN_59."? [".$row['user_name']."]"))."
|
||||
".$frm->submit_image("del_admin[{$row['user_id']}]", 'del', 'delete', $tp->toJS(ADMSLAN_59."? [".$row['user_name']."]"))."
|
||||
|
||||
";
|
||||
}
|
||||
@@ -208,75 +179,7 @@ function show_admins()
|
||||
$ns->tablerender(ADMSLAN_13, $mes->render().$text);
|
||||
}
|
||||
|
||||
function edit_administrator($row)
|
||||
{
|
||||
global $pref;
|
||||
$lanlist = explode(",",e_LANLIST);
|
||||
require_once(e_HANDLER."user_handler.php");
|
||||
$prm = new e_userperms;
|
||||
$ns = e107::getRender();
|
||||
$sql = e107::getDb();
|
||||
$frm = e107::getForm();
|
||||
|
||||
|
||||
$a_id = $row['user_id'];
|
||||
$ad_name = $row['user_name'];
|
||||
$a_perms = $row['user_perms'];
|
||||
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."' id='myform'>
|
||||
<fieldset id='core-administrator-edit'>
|
||||
<legend class='e-hideme'>".ADMSLAN_52."</legend>
|
||||
<table cellpadding='0' cellspacing='0' class='adminform'>
|
||||
<colgroup span='2'>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class='label'>".ADMSLAN_16.": </td>
|
||||
<td class='control'>
|
||||
".$ad_name."
|
||||
<input type='hidden' name='ad_name' size='60' value='{$ad_name}' />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='label'>".ADMSLAN_18."</td>
|
||||
<td class='control'>
|
||||
|
||||
";
|
||||
|
||||
$groupedList = $prm->getPermList('grouped');
|
||||
|
||||
foreach($groupedList as $section=>$list)
|
||||
{
|
||||
$text .= "\t\t<div class='field-section'><h4>".$prm->renderSectionDiz($section)."</h4>"; //XXX Lan - General
|
||||
foreach($list as $key=>$diz)
|
||||
{
|
||||
$text .= $prm->checkb($key, $a_perms, $diz);
|
||||
}
|
||||
$text .= "</div>";
|
||||
}
|
||||
|
||||
$text .= "<div class='field-section'>
|
||||
".$frm->admin_button('check_all', 'jstarget:perms', 'action', LAN_CHECKALL)."
|
||||
".$frm->admin_button('uncheck_all', 'jstarget:perms', 'action', LAN_UNCHECKALL)."
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class='buttons-bar center'>
|
||||
<input type='hidden' name='a_id' value='{$a_id}' />
|
||||
".$frm->admin_button('update_admin', ADMSLAN_52, 'update')."
|
||||
".$frm->admin_button('go_back', ADMSLAN_70)."
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
";
|
||||
|
||||
$ns->tablerender(ADMSLAN_52, $text);
|
||||
}
|
||||
require_once("footer.php");
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user