diff --git a/lam/lib/.htaccess b/lam/lib/.htaccess index 053b54e1..9e4eb6a5 100644 --- a/lam/lib/.htaccess +++ b/lam/lib/.htaccess @@ -2,10 +2,6 @@ Order allow,deny Deny from all - - Order allow,deny - Allow from all - Order allow,deny Allow from all diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index b04c4e43..b2f0bfac 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -336,5 +336,59 @@ function listGetAttributeHostArray() { ); } +/** +* Prints a combobox with possible sub-DNs. +* +* @param array $units list of OUs +* @param string $suffix current LDAP suffix +*/ +function listShowOUSelection($units, $suffix) { + if (sizeof($units) > 1) { + echo ("

\n"); + echo ("" . _("Suffix") . ": "); + echo ("\n"); + echo (""); + echo ("

\n"); + } +} + +/** +* Prints JavaScript code needed for mouse-over effects. +*/ +function listPrintJavaScript() { + echo "\n"; +} ?> \ No newline at end of file diff --git a/lam/templates/lists/listdomains.php b/lam/templates/lists/listdomains.php index b722d419..52ea1664 100644 --- a/lam/templates/lists/listdomains.php +++ b/lam/templates/lists/listdomains.php @@ -51,17 +51,17 @@ $scope = 'domain'; $_POST = $_POST + $_GET; $info = $_SESSION[$scope . 'info']; -$dom_units = $_SESSION['dom_units']; +$units = $_SESSION[$scope . '_units']; // check if button was pressed and if we have to add/delete a domain -if (isset($_POST['new_domain']) || isset($_POST['del_domain'])){ +if (isset($_POST['new']) || isset($_POST['del'])){ // add new domain - if (isset($_POST['new_domain'])){ + if (isset($_POST['new'])){ metaRefresh("../domain.php?action=new"); exit; } // delete domain(s) - if (isset($_POST['del_domain'])){ + if (isset($_POST['del'])){ // search for checkboxes $domains = array_keys($_POST, "on"); $domainstr = implode(";", $domains); @@ -76,7 +76,8 @@ echo $_SESSION['header']; echo "listdomains\n"; echo "\n"; echo "\n"; -echo "\n"; + +listPrintJavaScript(); // get current page if (isset($_GET["page"])) $page = $_GET["page"]; @@ -103,9 +104,9 @@ if (isset($_GET["sort"])) $sort = $_GET["sort"]; else $sort = strtolower($attr_array[0]); // check search suffix -if (isset($_POST['dom_suffix'])) $dom_suffix = $_POST['dom_suffix']; // new suffix selected via combobox -elseif (isset($_SESSION['dom_suffix'])) $dom_suffix = $_SESSION['dom_suffix']; // old suffix from session -else $dom_suffix = $_SESSION["config"]->get_DomainSuffix(); // default suffix +if (isset($_POST['suffix'])) $suffix = $_POST['suffix']; // new suffix selected via combobox +elseif (isset($_SESSION[$scope . '_suffix'])) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session +else $suffix = $_SESSION["config"]->get_DomainSuffix(); // default suffix $refresh = true; if (isset($_GET['norefresh'])) $refresh = false; @@ -115,7 +116,7 @@ if ($refresh) { // configure search filter $filter = "(objectClass=sambaDomain)"; $attrs = $attr_array; - $sr = @ldap_search($_SESSION["ldap"]->server(), $dom_suffix, $filter, $attrs); + $sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs); if (ldap_errno($_SESSION["ldap"]->server()) == 4) { StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem.")); } @@ -166,11 +167,11 @@ else $table_end = ($page * $max_page_entries); // print domain list for ($i = $table_begin; $i < $table_end; $i++) { - echo("" . - " " . + " " . " " . _("Edit") . ""); for ($k = 0; $k < sizeof($attr_array); $k++) { echo (""); @@ -197,27 +198,15 @@ echo ("
\n"); if ($refresh) { // generate list of possible suffixes - $dom_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_DomainSuffix()); + $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_DomainSuffix()); } // print combobox with possible sub-DNs -if (sizeof($dom_units) > 1) { - echo ("

\n"); - echo ("" . _("Suffix") . ": "); - echo ("\n"); - echo (""); - echo ("

\n"); - echo ("

 

\n"); -} +listShowOUSelection($units, $suffix); echo ("

\n"); -echo ("\n"); -if (sizeof($info) > 0) echo ("\n"); +echo ("\n"); +if (sizeof($info) > 0) echo ("\n"); echo ("

\n"); echo ("\n"); @@ -227,7 +216,7 @@ echo "\n"; // save variables to session $_SESSION[$scope . 'info'] = $info; -$_SESSION['dom_units'] = $dom_units; -$_SESSION['dom_suffix'] = $dom_suffix; +$_SESSION[$scope . '_units'] = $units; +$_SESSION[$scope . '_suffix'] = $suffix; ?> diff --git a/lam/templates/lists/listgroups.php b/lam/templates/lists/listgroups.php index 5b6eb95c..8eb6dae1 100644 --- a/lam/templates/lists/listgroups.php +++ b/lam/templates/lists/listgroups.php @@ -55,7 +55,7 @@ $scope = 'group'; $_POST = $_POST + $_GET; $info = $_SESSION[$scope . 'info']; -$grp_units = $_SESSION['grp_units']; +$units = $_SESSION[$scope . '_units']; listDoPost($scope); @@ -63,7 +63,8 @@ echo $_SESSION['header']; echo "listgroups\n"; echo "\n"; echo "\n"; -echo "\n"; + +listPrintJavaScript(); // generate attribute-description table $attr_array = array(); // list of LDAP attributes to show @@ -105,9 +106,9 @@ if (isset($_GET["sort"])) $sort = $_GET["sort"]; else $sort = strtolower($attr_array[0]); // check search suffix -if ($_POST['grp_suffix']) $grp_suffix = $_POST['grp_suffix']; // new suffix selected via combobox -elseif ($_SESSION['grp_suffix']) $grp_suffix = $_SESSION['grp_suffix']; // old suffix from session -else $grp_suffix = $_SESSION["config"]->get_GroupSuffix(); // default suffix +if ($_POST['suffix']) $suffix = $_POST['suffix']; // new suffix selected via combobox +elseif ($_SESSION[$scope . '_suffix']) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session +else $suffix = $_SESSION["config"]->get_GroupSuffix(); // default suffix $refresh = true; if (isset($_GET['norefresh'])) $refresh = false; @@ -115,10 +116,10 @@ if (isset($_POST['refresh'])) $refresh = true; if ($refresh) { // configure search filter - $module_filter = get_ldap_filter("group"); // basic filter is provided by modules + $module_filter = get_ldap_filter($scope); // basic filter is provided by modules $filter = "(&" . $module_filter . ")"; $attrs = $attr_array; - $sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs); + $sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs); if (ldap_errno($_SESSION["ldap"]->server()) == 4) { StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem.")); } @@ -163,12 +164,12 @@ echo ("
\n"); // draw navigation bar if group accounts were found if (sizeof($info) > 0) { -listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, "group", _("%s group(s) found")); +listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, $scope, _("%s group(s) found")); echo ("
"); } // account table head -listPrintTableHeader("group", $searchFilter, $desc_array, $attr_array, $_POST, $sort); +listPrintTableHeader($scope, $searchFilter, $desc_array, $attr_array, $_POST, $sort); // calculate which rows to show $table_begin = ($page - 1) * $max_page_entries; @@ -178,16 +179,16 @@ else $table_end = ($page * $max_page_entries); if (sizeof($info) > 0) { // print group list for ($i = $table_begin; $i < $table_end; $i++) { - echo(""); if (isset($_GET['selectall'])) { - echo " "; } else { - echo " "; } echo (" " . _("Edit") . ""); @@ -239,29 +240,17 @@ echo ("
"); // draw navigation bar if group accounts were found if (sizeof($info) > 0) { -listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, "group", _("%s group(s) found")); +listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, $scope, _("%s group(s) found")); echo ("
\n"); } if ($refresh) { // generate list of possible suffixes - $grp_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_GroupSuffix()); + $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_GroupSuffix()); } // print combobox with possible sub-DNs -if (sizeof($grp_units) > 1) { - echo ("

\n"); - echo ("" . _("Suffix") . ": "); - echo ("\n"); - echo (""); - echo ("

\n"); - echo ("

 

\n"); -} +listShowOUSelection($units, $suffix); echo ("\n"); if (sizeof($info) > 0) { @@ -269,7 +258,7 @@ if (sizeof($info) > 0) { echo ("


\n"); echo "
PDF\n"; echo ("" . _('PDF structure') . ":  "; } else { - echo " "; } echo (" " . _("Edit") . ""); @@ -229,23 +230,11 @@ echo ("
\n"); if ($refresh) { // generate list of possible suffixes - $hst_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_HostSuffix()); + $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_HostSuffix()); } // print combobox with possible sub-DNs -if (sizeof($hst_units) > 1) { -echo ("

\n"); -echo ("" . _("Suffix") . ": "); -echo ("\n"); -echo (""); -echo ("

\n"); -echo ("

 

\n"); -} +listShowOUSelection($units, $suffix); // add/delete/PDF buttons echo ("\n"); @@ -269,7 +258,7 @@ echo ("\n"); echo "\n"; // save variables to session -$_SESSION['hst_units'] = $hst_units; -$_SESSION['hst_suffix'] = $hst_suffix; +$_SESSION[$scope . '_units'] = $units; +$_SESSION[$scope . '_suffix'] = $suffix; ?> diff --git a/lam/templates/lists/listusers.php b/lam/templates/lists/listusers.php index e4ff78e8..1126ee43 100644 --- a/lam/templates/lists/listusers.php +++ b/lam/templates/lists/listusers.php @@ -68,10 +68,10 @@ else $trans_primary_hash = array(); // generate hash table for group translation if ($trans_primary == "on" && ($refresh || (sizeof($trans_primary_hash) == 0))) { $trans_primary_hash = array(); - $suffix = $_SESSION['config']->get_groupSuffix(); + $grp_suffix = $_SESSION['config']->get_groupSuffix(); $filter = "objectClass=posixGroup"; $attrs = array("cn", "gidNumber"); - $sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs); + $sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs); if ($sr) { $info = @ldap_get_entries($_SESSION["ldap"]->server(), $sr); unset($info['count']); // delete count entry @@ -83,8 +83,8 @@ if ($trans_primary == "on" && ($refresh || (sizeof($trans_primary_hash) == 0))) } -$info = $_SESSION[$scope . 'info']; -$usr_units = $_SESSION['usr_units']; +if (isset($_SESSION[$scope . 'info'])) $info = $_SESSION[$scope . 'info']; +if (isset($_SESSION[$scope . '_units'])) $units = $_SESSION[$scope . '_units']; listDoPost($scope); @@ -93,7 +93,8 @@ echo $_SESSION['header']; echo "listusers\n"; echo "\n"; echo "\n"; -echo "\n"; + +listPrintJavaScript(); // get current page if (isset($_GET["page"])) $page = $_GET["page"]; @@ -134,18 +135,18 @@ if (isset($_GET["sort"])) $sort = $_GET["sort"]; else $sort = strtolower($attr_array[0]); // check search suffix -if ($_POST['usr_suffix']) $usr_suffix = $_POST['usr_suffix']; // new suffix selected via combobox -elseif ($_SESSION['usr_suffix']) $usr_suffix = $_SESSION['usr_suffix']; // old suffix from session -else $usr_suffix = $_SESSION["config"]->get_UserSuffix(); // default suffix +if (isset($_POST['suffix'])) $suffix = $_POST['suffix']; // new suffix selected via combobox +elseif (isset($_SESSION[$scope . '_suffix'])) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session +else $suffix = $_SESSION["config"]->get_UserSuffix(); // default suffix // configure search filter for LDAP -$module_filter = get_ldap_filter("user"); // basic filter is provided by modules +$module_filter = get_ldap_filter($scope); // basic filter is provided by modules $filter = "(&" . $module_filter . ")"; if ($refresh) { $attrs = $attr_array; - $sr = @ldap_search($_SESSION["ldap"]->server(), $usr_suffix, $filter, $attrs); + $sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs); if (ldap_errno($_SESSION["ldap"]->server()) == 4) { StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem.")); } @@ -188,27 +189,25 @@ else { $searchFilter = ""; } -$user_count = sizeof($info); - echo ("
\n"); // display table only if users exist in LDAP -if ($user_count != 0) { +if (sizeof($info) != 0) { // create navigation bar on top of user table - listDrawNavigationBar($user_count, $max_page_entries, $page, $sort, - $searchFilter . "&trans_primary=" . $trans_primary, "user", _("%s user(s) found")); + listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, + $searchFilter . "&trans_primary=" . $trans_primary, $scope, _("%s user(s) found")); echo ("
"); } // account table head -listPrintTableHeader("user", $searchFilter . "&trans_primary=" . $trans_primary, $desc_array, $attr_array, $_POST, $sort); +listPrintTableHeader($scope, $searchFilter . "&trans_primary=" . $trans_primary, $desc_array, $attr_array, $_POST, $sort); // calculate which rows to show $table_begin = ($page - 1) * $max_page_entries; if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info); else $table_end = ($page * $max_page_entries); -if ($user_count != 0) { +if (sizeof($info) != 0) { // translate GIDs and resort array if selected if ($trans_primary == "on") { // translate GIDs @@ -225,17 +224,17 @@ if ($user_count != 0) { } // print user list for ($i = $table_begin; $i < $table_end; $i++) { - echo("\n"); // checkboxes if selectall = "yes" if (isset($_GET['selectall'])) { - echo "\n\n\n\n"; } else { - echo "\n\n\n\n"; } echo ("\n" . @@ -270,30 +269,19 @@ if ($user_count != 0) { echo ("\n"); echo ("
"); -if ($user_count != 0) { - listDrawNavigationBar($user_count, $max_page_entries, $page, $sort, - $searchFilter . "&trans_primary=" . $trans_primary, "user", _("%s user(s) found")); +if (sizeof($info) != 0) { + listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, + $searchFilter . "&trans_primary=" . $trans_primary, $scope, _("%s user(s) found")); echo ("
"); } if ($refresh) { // generate list of possible suffixes - $usr_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_UserSuffix()); + $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_UserSuffix()); } // print combobox with possible sub-DNs -if (sizeof($usr_units) > 1) { - echo ("

\n"); - echo ("" . _("Suffix") . ": "); - echo ("\n"); - echo (""); - echo ("

\n"); -} +listShowOUSelection($units, $suffix); // show translate GID to group name box if there is a column with gidnumber if (in_array("gidnumber", $attr_array)) { @@ -311,12 +299,12 @@ echo ("

 

\n"); // new/delete/PDF buttons echo ("\n"); -if ($user_count != 0) { +if (sizeof($info) != 0) { echo ("\n"); echo ("


\n"); echo "
PDF\n"; echo ("" . _('PDF structure') . ":