From ab99775bc8aca7a16ad7e903db0953381de7fe92 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 8 Nov 2003 16:07:40 +0000 Subject: [PATCH] fixed deleting of usernames with spaces, display quota in PDF --- lam/templates/lists/listusers.php | 46 +++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/lam/templates/lists/listusers.php b/lam/templates/lists/listusers.php index 425e933b..34c506ba 100644 --- a/lam/templates/lists/listusers.php +++ b/lam/templates/lists/listusers.php @@ -71,14 +71,18 @@ if ($_POST['new_user'] || $_POST['del_user'] || $_POST['pdf_user'] || $_POST['pd // delete user(s) elseif ($_POST['del_user']){ // search for checkboxes - $users = array_keys($_POST, "on"); + while ($entry = @array_pop($_POST)) { + if (eregi("^uid=.*$", $entry)) $users[] = $entry; + } $_SESSION['delete_dn'] = $users; metaRefresh("../delete.php?type=user"); } // PDF for selected users elseif ($_POST['pdf_user']){ // search for checkboxes - $users = array_keys($_POST, "on"); + while ($entry = @array_pop($_POST)) { + if (eregi("^uid=.*$", $entry)) $users[] = $entry; + } $list = array(); // load users from LDAP for ($i = 0; $i < sizeof($users); $i++) { @@ -86,7 +90,11 @@ if ($_POST['new_user'] || $_POST['del_user'] || $_POST['pdf_user'] || $_POST['pd $list[$i]->unix_password = ""; $list[$i]->smb_password = ""; } - if (sizeof($list) > 0) createUserPDF($list); + if (sizeof($list) > 0) { + $list = quotas($list); + if ($list) createUserPDF($list); + else StatusMessage("ERROR", _("Unable to get quota information!"), ""); + } } // PDF for all users elseif ($_POST['pdf_all']){ @@ -96,7 +104,11 @@ if ($_POST['new_user'] || $_POST['del_user'] || $_POST['pdf_user'] || $_POST['pd $list[$i]->unix_password = ""; $list[$i]->smb_password = ""; } - if (sizeof($list) > 0) createUserPDF($list); + if (sizeof($list) > 0) { + $list = quotas($list); + if ($list) createUserPDF($list); + else StatusMessage("ERROR", _("Unable to get quota information!"), ""); + } } exit; } @@ -270,14 +282,14 @@ if ($user_count != 0) { "onMouseOut=\"user_out(this, '" . $userinfo[$i]["dn"] . "')\"\n" . "onClick=\"user_click(this, '" . $userinfo[$i]["dn"] . "')\"\n" . "onDblClick=\"parent.frames[1].location.href='../account/useredit.php?type=user&DN=" . $userinfo[$i]["dn"] . "'\">\n"); - // check boxes if selectall = "yes" + // checkboxes if selectall = "yes" if ($_GET['selectall'] == "yes") { echo "\n\n\n"; + $userinfo[$i]["dn"] . "\" value=\"" . $userinfo[$i]["dn"] . "\" checked>\n\n"; } else { echo "\n\n\n"; + $userinfo[$i]["dn"] . "\" value=\"" . $userinfo[$i]["dn"] . "\">\n\n"; } echo ("\n" . _("Edit") . "\n\n"); @@ -350,7 +362,6 @@ if (in_array("gidnumber", $attr_array)) { echo ("

 

\n"); // new/delete/PDF buttons -echo ("

\n"); echo ("\n"); if ($user_count != 0) { echo ("\n"); @@ -361,7 +372,6 @@ if ($user_count != 0) { echo ("\n"); echo ""; } -echo ("

\n"); echo ("

 

\n"); @@ -433,6 +443,24 @@ function cmp_array($a, $b) { } } +// takes an array of account and fill the accounts with quota information +function quotas($list) { + if (! is_array($list)) return false; + for ($i = 0; $i < sizeof($list); $i++) { + $usernames[] = $list[$i]->general_username; + } + $data = getquotas("user", $usernames); + if (sizeof($data) != sizeof($list)) { + return false; + } + for ($i = 0; $i < sizeof($data); $i++) { + $ret[$i] = $list[$i]; + $ret[$i]->quota = $data[$i]->quota; + } + return $ret; +} + + // save variables to session $_SESSION['usr_units'] = $usr_units; $_SESSION['usr_suffix'] = $usr_suffix;