diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc
index 9678d984..e3c0748d 100644
--- a/lam/lib/lists.inc
+++ b/lam/lib/lists.inc
@@ -222,6 +222,62 @@ function listPrintTableHeader($scope, $searchFilter, $desc_array, $attr_array, $
echo "\n";
}
+/**
+* Manages all POST actions (e.g. button pressed) for the account lists.
+*
+* @param string $scope account type
+*/
+function listDoPost($scope) {
+ // check if button was pressed and if we have to add/delete an account
+ if ($_POST['new'] || $_POST['del'] || $_POST['pdf'] || $_POST['pdf_all']){
+ // add new account
+ if ($_POST['new']){
+ metaRefresh("../account/edit.php?type=" . $scope);
+ exit;
+ }
+ // delete account(s)
+ elseif ($_POST['del']){
+ // search for checkboxes
+ $accounts = array_keys($_POST, "on");
+ $_SESSION['delete_dn'] = $accounts;
+ if (sizeof($accounts) > 0) {
+ metaRefresh("../delete.php?type=" . $scope);
+ exit;
+ }
+ }
+ // PDF for selected accounts
+ elseif ($_POST['pdf']){
+ $pdf_structure = $_POST['pdf_structure'];
+ // search for checkboxes
+ $accounts = array_keys($_POST, "on");
+ $list = array();
+ // load accounts from LDAP
+ for ($i = 0; $i < sizeof($accounts); $i++) {
+ $_SESSION["accountPDF-$i"] = new accountContainer($scope, "accountPDF-$i");
+ $_SESSION["accountPDF-$i"]->load_account($accounts[$i]);
+ $list[$i] = $_SESSION["accountPDF-$i"];
+ }
+ if (sizeof($list) > 0) {
+ createModulePDF($list,$pdf_structure);
+ exit;
+ }
+ }
+ // PDF for all accounts
+ elseif ($_POST['pdf_all']){
+ $list = array();
+ for ($i = 0; $i < sizeof($_SESSION[$scope . 'info']); $i++) {
+ $_SESSION["accountPDF-$i"] = new accountContainer($scope, "accountPDF-$i");
+ $_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$i]['dn']);
+ $list[$i] = $_SESSION["accountPDF-$i"];
+ }
+ if (sizeof($list) > 0) {
+ createModulePDF($list,$_POST['pdf_structure']);
+ exit;
+ }
+ }
+ }
+}
+
/**
* Returns the LDAP attribute names and their description for the user list
diff --git a/lam/templates/lists/listgroups.php b/lam/templates/lists/listgroups.php
index 182efa5e..a0c1a1e9 100644
--- a/lam/templates/lists/listgroups.php
+++ b/lam/templates/lists/listgroups.php
@@ -60,54 +60,7 @@ $_POST = $_POST + $_GET;
$info = $_SESSION[$scope . 'info'];
$grp_units = $_SESSION['grp_units'];
-// check if button was pressed and if we have to add/delete a group
-if ($_POST['new_group'] || $_POST['del_group'] || $_POST['pdf_group'] || $_POST['pdf_all']){
- // add new group
- if ($_POST['new_group']){
- metaRefresh("../account/edit.php?type=group");
- exit;
- }
- // delete group(s)
- elseif ($_POST['del_group']){
- // search for checkboxes
- $groups = array_keys($_POST, "on");
- $_SESSION['delete_dn'] = $groups;
- if (sizeof($groups) > 0) {
- metaRefresh("../delete.php?type=group");
- exit;
- }
- }
- // PDF for selected groups
- elseif ($_POST['pdf_group']){
- $pdf_structure = $_POST['pdf_structure'];
- // search for checkboxes
- $groups = array_keys($_POST, "on");
- $list = array();
- // load groups from LDAP
- for ($i = 0; $i < sizeof($groups); $i++) {
- $_SESSION["accountPDF-$i"] = new accountContainer("group", "accountPDF-$i");
- $_SESSION["accountPDF-$i"]->load_account($groups[$i]);
- $list[$i] = $_SESSION["accountPDF-$i"];
- }
- if (sizeof($list) > 0) {
- createModulePDF($list,$pdf_structure);
- exit;
- }
- }
- // PDF for all groups
- elseif ($_POST['pdf_all']){
- $list = array();
- for ($i = 0; $i < sizeof($_SESSION[$scope . 'info']); $i++) {
- $_SESSION["accountPDF-$i"] = new accountContainer("group", "accountPDF-$i");
- $_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$i]['dn']);
- $list[$i] = $_SESSION["accountPDF-$i"];
- }
- if (sizeof($list) > 0) {
- createModulePDF($list,$_POST['pdf_structure']);
- exit;
- }
- }
-}
+listDoPost($scope);
echo $_SESSION['header'];
echo "
listgroups\n";
@@ -305,9 +258,9 @@ if (sizeof($grp_units) > 1) {
echo ("
\n");
}
-echo ("\n");
+echo ("\n");
if (sizeof($info) > 0) {
- echo ("\n");
+ echo ("\n");
echo ("
\n");
echo "";
diff --git a/lam/templates/lists/listhosts.php b/lam/templates/lists/listhosts.php
index e121599b..7fd24023 100644
--- a/lam/templates/lists/listhosts.php
+++ b/lam/templates/lists/listhosts.php
@@ -60,54 +60,7 @@ $_POST = $_POST + $_GET;
$info = $_SESSION[$scope . 'info'];
$hst_units = $_SESSION['hst_units'];
-// check if button was pressed and if we have to add/delete a host
-if ($_POST['new_host'] || $_POST['del_host'] || $_POST['pdf_host'] || $_POST['pdf_all']){
- // add new host
- if ($_POST['new_host']){
- metaRefresh("../account/edit.php?type=host");
- exit;
- }
- // delete host(s)
- elseif ($_POST['del_host']){
- // search for checkboxes
- $hosts = array_keys($_POST, "on");
- $_SESSION['delete_dn'] = $hosts;
- if (sizeof($hosts) > 0) {
- metaRefresh("../delete.php?type=host");
- exit;
- }
- }
- // PDF for selected hosts
- elseif ($_POST['pdf_host']){
- $pdf_structure = $_POST['pdf_structure'];
- // search for checkboxes
- $hosts = array_keys($_POST, "on");
- $list = array();
- // load hosts from LDAP
- for ($i = 0; $i < sizeof($hosts); $i++) {
- $_SESSION["accountPDF-$i"] = new accountContainer("host", "accountPDF-$i");
- $_SESSION["accountPDF-$i"]->load_account($hosts[$i]);
- $list[$i] = $_SESSION["accountPDF-$i"];
- }
- if (sizeof($list) > 0) {
- createModulePDF($list,$pdf_structure);
- exit;
- }
- }
- // PDF for all hosts
- elseif ($_POST['pdf_all']){
- $list = array();
- for ($i = 0; $i < sizeof($_SESSION[$scope . 'info']); $i++) {
- $_SESSION["accountPDF-$i"] = new accountContainer("host", "accountPDF-$i");
- $_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$i]['dn']);
- $list[$i] = $_SESSION["accountPDF-$i"];
- }
- if (sizeof($list) > 0) {
- createModulePDF($list,$_POST['pdf_structure']);
- exit;
- }
- }
-}
+listDoPost($scope);
echo $_SESSION['header'];
echo "listhosts\n";
@@ -290,9 +243,9 @@ echo ("
\n");
}
// add/delete/PDF buttons
-echo ("\n");
+echo ("\n");
if (sizeof($info) > 0) {
- echo ("\n");
+ echo ("\n");
echo ("
\n");
echo "";
diff --git a/lam/templates/lists/listusers.php b/lam/templates/lists/listusers.php
index 6571ab21..2be77119 100644
--- a/lam/templates/lists/listusers.php
+++ b/lam/templates/lists/listusers.php
@@ -81,58 +81,7 @@ if ($trans_primary == "on" && !$_GET["norefresh"]) {
$info = $_SESSION[$scope . 'info'];
$usr_units = $_SESSION['usr_units'];
-// check if button was pressed and if we have to add/delete a user or create a PDF
-if ($_POST['new_user'] || $_POST['del_user'] || $_POST['pdf_user'] || $_POST['pdf_all']){
- // add new user
- if ($_POST['new_user']){
- metaRefresh("../account/edit.php?type=user");
- exit;
- }
- // delete user(s)
- elseif ($_POST['del_user']){
- // search for checkboxes
- while ($entry = @array_pop($_POST)) {
- if (eregi("^uid=.*$", $entry)) $users[] = $entry;
- }
- $_SESSION['delete_dn'] = $users;
- if (sizeof($users) > 0) {
- metaRefresh("../delete.php?type=user");
- exit;
- }
- }
- // PDF for selected users
- elseif ($_POST['pdf_user']){
- $pdf_structure = $_POST['pdf_structure'];
- // search for checkboxes
- while ($entry = @array_pop($_POST)) {
- if (eregi("^uid=.*$", $entry)) $users[] = $entry;
- }
- $list = array();
- // load users from LDAP
- for ($i = 0; $i < sizeof($users); $i++) {
- $_SESSION["accountPDF-$i"] = new accountContainer("user", "accountPDF-$i");
- $_SESSION["accountPDF-$i"]->load_account($users[$i]);
- $list[$i] = $_SESSION["accountPDF-$i"];
- }
- if (sizeof($list) > 0) {
- createModulePDF($list,$pdf_structure);
- exit;
- }
- }
- // PDF for all users
- elseif ($_POST['pdf_all']){
- $list = array();
- for ($i = 0; $i < sizeof($_SESSION[$scope . 'info']); $i++) {
- $_SESSION["accountPDF-$i"] = new accountContainer("user", "accountPDF-$i");
- $_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$i]['dn']);
- $list[$i] = $_SESSION["accountPDF-$i"];
- }
- if (sizeof($list) > 0) {
- createModulePDF($list,$_POST['pdf_structure']);
- exit;
- }
- }
-}
+listDoPost($scope);
echo $_SESSION['header'];
@@ -278,11 +227,11 @@ if ($user_count != 0) {
// checkboxes if selectall = "yes"
if ($_GET['selectall'] == "yes") {
echo "\n\n | \n";
+ $info[$i]["dn"] . "\" checked>\n\n";
}
else {
echo "\n\n | \n";
+ $info[$i]["dn"] . "\">\n\n";
}
echo ("\n" .
_("Edit") . "\n | \n");
@@ -356,9 +305,9 @@ if (in_array("gidnumber", $attr_array)) {
echo ("
\n");
// new/delete/PDF buttons
-echo ("\n");
+echo ("\n");
if ($user_count != 0) {
- echo ("\n");
+ echo ("\n");
echo ("
\n");
echo "";