Commit f9df4803 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) some minor style fixes in system_usermanager.php

parent 19918879
...@@ -31,36 +31,43 @@ ...@@ -31,36 +31,43 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
function get_user_privdesc(& $user) { function get_user_privdesc(& $user)
{
global $priv_list; global $priv_list;
$privs = array(); $privs = array();
$user_privs = $user['priv']; $user_privs = $user['priv'];
if (!is_array($user_privs)) if (!is_array($user_privs)) {
$user_privs = array(); $user_privs = array();
}
$names = local_user_get_groups($user, true); $names = local_user_get_groups($user, true);
foreach ($names as $name) { foreach ($names as $name) {
$group = getGroupEntry($name); $group = getGroupEntry($name);
$group_privs = $group['priv']; $group_privs = $group['priv'];
if (!is_array($group_privs)) if (!is_array($group_privs)) {
continue; continue;
}
foreach ($group_privs as $pname) { foreach ($group_privs as $pname) {
if (in_array($pname,$user_privs)) if (in_array($pname, $user_privs)) {
continue; continue;
if (!$priv_list[$pname]) }
if (!$priv_list[$pname]) {
continue; continue;
}
$priv = $priv_list[$pname]; $priv = $priv_list[$pname];
$priv['group'] = $group['name']; $priv['group'] = $group['name'];
$privs[] = $priv; $privs[] = $priv;
} }
} }
foreach ($user_privs as $pname) foreach ($user_privs as $pname) {
if($priv_list[$pname]) if ($priv_list[$pname]) {
$privs[] = $priv_list[$pname]; $privs[] = $priv_list[$pname];
}
}
return $privs; return $privs;
} }
...@@ -70,6 +77,8 @@ function get_user_privdesc(& $user) { ...@@ -70,6 +77,8 @@ function get_user_privdesc(& $user) {
// start admin user code // start admin user code
$pgtitle = array(gettext("System"),gettext("User Manager")); $pgtitle = array(gettext("System"),gettext("User Manager"));
$input_errors = array();
if (isset($_POST['userid']) && is_numericint($_POST['userid'])) { if (isset($_POST['userid']) && is_numericint($_POST['userid'])) {
$id = $_POST['userid']; $id = $_POST['userid'];
} }
...@@ -181,8 +190,7 @@ if ($_POST['act'] == "deluser") { ...@@ -181,8 +190,7 @@ if ($_POST['act'] == "deluser") {
$pconfig['lifetime'] = 365; $pconfig['lifetime'] = 365;
} }
if ($_POST['save']) { if (isset($_POST['save'])) {
unset($input_errors);
$pconfig = $_POST; $pconfig = $_POST;
/* input validation */ /* input validation */
...@@ -227,7 +235,7 @@ if ($_POST['save']) { ...@@ -227,7 +235,7 @@ if ($_POST['save']) {
$oldusername = ""; $oldusername = "";
} }
/* make sure this user name is unique */ /* make sure this user name is unique */
if (!$input_errors) { if (count($input_errors) == 0) {
foreach ($a_user as $userent) { foreach ($a_user as $userent) {
if ($userent['name'] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) { if ($userent['name'] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) {
$input_errors[] = gettext("Another entry with the same username already exists."); $input_errors[] = gettext("Another entry with the same username already exists.");
...@@ -236,7 +244,7 @@ if ($_POST['save']) { ...@@ -236,7 +244,7 @@ if ($_POST['save']) {
} }
} }
/* also make sure it is not reserved */ /* also make sure it is not reserved */
if (!$input_errors) { if (count($input_errors) == 0) {
$system_users = explode("\n", file_get_contents("/etc/passwd")); $system_users = explode("\n", file_get_contents("/etc/passwd"));
foreach ($system_users as $s_user) { foreach ($system_users as $s_user) {
$ent = explode(":", $s_user); $ent = explode(":", $s_user);
...@@ -278,7 +286,7 @@ if ($_POST['save']) { ...@@ -278,7 +286,7 @@ if ($_POST['save']) {
exit; exit;
} }
if (!$input_errors) { if (count($input_errors)==0) {
$userent = array(); $userent = array();
if (isset($id) && $a_user[$id]) { if (isset($id) && $a_user[$id]) {
...@@ -482,7 +490,7 @@ function sshkeyClicked(obj) { ...@@ -482,7 +490,7 @@ function sshkeyClicked(obj) {
<div class="tab-content content-box col-xs-12 table-responsive"> <div class="tab-content content-box col-xs-12 table-responsive">
<?php <?php
if ($_POST['act'] == "new" || $_POST['act'] == "edit" || $input_errors) : if ($_POST['act'] == "new" || $_POST['act'] == "edit" || count($input_errors) > 0 ) :
?> ?>
<form action="system_usermanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()"> <form action="system_usermanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment