moved Java Script code to lists.inc,

reduced differences between lists
This commit is contained in:
Roland Gruber 2005-02-26 14:32:52 +00:00
parent a33f881f0d
commit 8fc845467a
6 changed files with 141 additions and 136 deletions

View File

@ -2,10 +2,6 @@
Order allow,deny
Deny from all
</Files>
<Files ~ functions.js>
Order allow,deny
Allow from all
</Files>
<Files ~ fpdf.php>
Order allow,deny
Allow from all

View File

@ -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 ("<p align=\"left\">\n");
echo ("<b>" . _("Suffix") . ": </b>");
echo ("<select size=1 name=\"suffix\">\n");
for ($i = 0; $i < sizeof($units); $i++) {
if ($suffix == $units[$i]) echo ("<option selected>" . $units[$i] . "</option>\n");
else echo("<option>" . $units[$i] . "</option>\n");
}
echo ("</select>\n");
echo ("<input type=\"submit\" name=\"refresh\" value=\"" . _("Change suffix") . "\">");
echo ("</p>\n");
}
}
/**
* Prints JavaScript code needed for mouse-over effects.
*/
function listPrintJavaScript() {
echo "<script type=\"text/javascript\" language=\"javascript\">\n";
echo "<!--\n";
// mouseOver function
echo "function list_over(list, box, scope) {\n";
echo "cbox = document.getElementsByName(box)[0];\n";
echo "if (cbox.checked == false) list.setAttribute('class', scope + 'list-over', 0);\n";
echo "}";
// mouseOut function
echo "function list_out(list, box, scope) {\n";
echo "cbox = document.getElementsByName(box)[0];\n";
echo "if (cbox.checked == false) list.setAttribute('class', scope + 'list', 0);\n";
echo "}\n";
// onClick function
echo "function list_click(list, box, scope) {\n";
echo "cbox = document.getElementsByName(box)[0];\n";
echo "if (cbox.checked == true) {\n";
echo "cbox.checked = false;\n";
echo "list.setAttribute('class', scope + 'list-over', 0);\n";
echo "}\n";
echo "else {\n";
echo "cbox.checked = true;\n";
echo "list.setAttribute('class', scope + 'list-checked', 0);\n";
echo "}\n";
echo "}\n";
echo "//-->\n";
echo "</script>\n";
}
?>

View File

@ -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 "<title>listdomains</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head><body>\n";
echo "<script src=\"../../lib/functions.js\" type=\"text/javascript\" language=\"javascript\"></script>\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("<tr class=\"domainlist\" onMouseOver=\"domain_over(this, '" . $info[$i]["dn"] . "')\"" .
" onMouseOut=\"domain_out(this, '" . $info[$i]["dn"] . "')\"" .
" onClick=\"domain_click(this, '" . $info[$i]["dn"] . "')\"" .
echo("<tr class=\"domainlist\" onMouseOver=\"list_over(this, '" . $info[$i]["dn"] . "', '" . $scope . "')\"" .
" onMouseOut=\"list_out(this, '" . $info[$i]["dn"] . "', '" . $scope . "')\"" .
" onClick=\"list_click(this, '" . $info[$i]["dn"] . "', '" . $scope . "')\"" .
" onDblClick=\"parent.frames[1].location.href='../domain.php?action=edit&amp;DN=" . $info[$i]["dn"] . "'\">" .
" <td height=22 align=\"center\"><input onClick=\"domain_click(this, '" . $info[$i]["dn"] . "')\" type=\"checkbox\" name=\"" . $info[$i]["dn"] . "\"></td>" .
" <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]["dn"] . "', '" . $scope . "')\" type=\"checkbox\" name=\"" . $info[$i]["dn"] . "\"></td>" .
" <td align='center'><a href=\"../domain.php?action=edit&amp;DN='" . $info[$i]["dn"] . "'\">" . _("Edit") . "</a></td>");
for ($k = 0; $k < sizeof($attr_array); $k++) {
echo ("<td>");
@ -197,27 +198,15 @@ echo ("<br>\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 ("<p align=\"left\">\n");
echo ("<b>" . _("Suffix") . ": </b>");
echo ("<select size=1 name=\"dom_suffix\">\n");
for ($i = 0; $i < sizeof($dom_units); $i++) {
if ($dom_suffix == $dom_units[$i]) echo ("<option selected>" . $dom_units[$i] . "</option>\n");
else echo("<option>" . $dom_units[$i] . "</option>\n");
}
echo ("</select>\n");
echo ("<input type=\"submit\" name=\"refresh\" value=\"" . _("Change Suffix") . "\">");
echo ("</p>\n");
echo ("<p>&nbsp;</p>\n");
}
listShowOUSelection($units, $suffix);
echo ("<p align=\"left\">\n");
echo ("<input type=\"submit\" name=\"new_domain\" value=\"" . _("New Domain") . "\">\n");
if (sizeof($info) > 0) echo ("<input type=\"submit\" name=\"del_domain\" value=\"" . _("Delete Domain(s)") . "\">\n");
echo ("<input type=\"submit\" name=\"new\" value=\"" . _("New Domain") . "\">\n");
if (sizeof($info) > 0) echo ("<input type=\"submit\" name=\"del\" value=\"" . _("Delete Domain(s)") . "\">\n");
echo ("</p>\n");
echo ("</form>\n");
@ -227,7 +216,7 @@ echo "</body></html>\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;
?>

View File

@ -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 "<title>listgroups</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head><body>\n";
echo "<script src=\"../../lib/functions.js\" type=\"text/javascript\" language=\"javascript\"></script>\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 ("<form action=\"listgroups.php?norefresh=true\" method=\"post\">\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 ("<br>");
}
// 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("<tr class=\"grouplist\" onMouseOver=\"group_over(this, '" . $i . "')\"" .
" onMouseOut=\"group_out(this, '" . $i . "')\"" .
" onClick=\"group_click(this, '" . $i . "')\"" .
echo("<tr class=\"grouplist\" onMouseOver=\"list_over(this, '" . $i . "', '" . $scope . "')\"" .
" onMouseOut=\"list_out(this, '" . $i . "', '" . $scope . "')\"" .
" onClick=\"list_click(this, '" . $i . "', '" . $scope . "')\"" .
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=group&amp;DN=" . $info[$i]['dn'] . "'\">");
if (isset($_GET['selectall'])) {
echo " <td height=22 align=\"center\"><input onClick=\"group_click(this, '" . $i . "')\" type=\"checkbox\"" .
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $i . "', '" . $scope . "')\" type=\"checkbox\"" .
" name=\"" . $i . "\" checked></td>";
}
else {
echo " <td height=22 align=\"center\"><input onClick=\"group_click(this, '" . $i . "')\" type=\"checkbox\"" .
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $i . "', '" . $scope . "')\" type=\"checkbox\"" .
" name=\"" . $i . "\"></td>";
}
echo (" <td align='center'><a href=\"../account/edit.php?type=group&amp;DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "</a></td>");
@ -239,29 +240,17 @@ echo ("<br>");
// 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 ("<br>\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 ("<p align=\"left\">\n");
echo ("<b>" . _("Suffix") . ": </b>");
echo ("<select size=1 name=\"grp_suffix\">\n");
for ($i = 0; $i < sizeof($grp_units); $i++) {
if ($grp_suffix == $grp_units[$i]) echo ("<option selected>" . $grp_units[$i] . "</option>\n");
else echo("<option>" . $grp_units[$i] . "</option>\n");
}
echo ("</select>\n");
echo ("<input type=\"submit\" name=\"refresh\" value=\"" . _("Change Suffix") . "\">");
echo ("</p>\n");
echo ("<p>&nbsp;</p>\n");
}
listShowOUSelection($units, $suffix);
echo ("<input type=\"submit\" name=\"new\" value=\"" . _("New Group") . "\">\n");
if (sizeof($info) > 0) {
@ -269,7 +258,7 @@ if (sizeof($info) > 0) {
echo ("<br><br><br>\n");
echo "<fieldset><legend><b>PDF</b></legend>\n";
echo ("<b>" . _('PDF structure') . ":</b>&nbsp;&nbsp;<select name=\"pdf_structure\">\n");
$pdf_structures = getAvailablePDFStructures('group');
$pdf_structures = getAvailablePDFStructures($scope);
foreach($pdf_structures as $pdf_structure) {
echo "<option value=\"" . $pdf_structure . "\"" . (($pdf_structure == 'default.xml') ? " selected" : "") . ">" . substr($pdf_structure,0,strlen($pdf_structure)-4) . "</option>";
}
@ -284,7 +273,7 @@ echo ("</form>\n");
echo "</body></html>\n";
// save variables to session
$_SESSION['grp_units'] = $grp_units;
$_SESSION['grp_suffix'] = $grp_suffix;
$_SESSION[$scope . '_units'] = $units;
$_SESSION[$scope . '_suffix'] = $suffix;
?>

View File

@ -55,7 +55,7 @@ $scope = 'host';
$_POST = $_POST + $_GET;
$info = $_SESSION[$scope . 'info'];
$hst_units = $_SESSION['hst_units'];
$units = $_SESSION[$scope . '_units'];
listDoPost($scope);
@ -63,7 +63,8 @@ echo $_SESSION['header'];
echo "<title>listhosts</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head><body>\n";
echo "<script src=\"../../lib/functions.js\" type=\"text/javascript\" language=\"javascript\"></script>\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['hst_suffix']) $hst_suffix = $_POST['hst_suffix']; // new suffix selected via combobox
elseif ($_SESSION['hst_suffix']) $hst_suffix = $_SESSION['hst_suffix']; // old suffix from session
else $hst_suffix = $_SESSION["config"]->get_HostSuffix(); // 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_HostSuffix(); // default suffix
$refresh = true;
if (isset($_GET['norefresh'])) $refresh = false;
@ -118,7 +119,7 @@ if ($refresh) {
$module_filter = get_ldap_filter("host"); // basic filter is provided by modules
$filter = "(&" . $module_filter . ")";
$attrs = $attr_array;
$sr = @ldap_search($_SESSION["ldap"]->server(), $hst_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."));
}
@ -178,16 +179,16 @@ else $table_end = ($page * $max_page_entries);
if (sizeof($info) > 0) {
// print host list
for ($i = $table_begin; $i < $table_end; $i++) {
echo("<tr class=\"hostlist\" onMouseOver=\"host_over(this, '" . $i . "')\"" .
" onMouseOut=\"host_out(this, '" . $i . "')\"" .
" onClick=\"host_click(this, '" . $i . "')\"" .
echo("<tr class=\"hostlist\" onMouseOver=\"list_over(this, '" . $i . "', '" . $scope . "')\"" .
" onMouseOut=\"list_out(this, '" . $i . "', '" . $scope . "')\"" .
" onClick=\"list_click(this, '" . $i . "', '" . $scope . "')\"" .
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=host&amp;DN=" . $info[$i]['dn'] . "'\">");
if (isset($_GET['selectall'])) {
echo " <td height=22 align=\"center\"><input onClick=\"host_click(this, '" . $i . "')\"" .
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $i . "', '" . $scope . "')\"" .
" type=\"checkbox\" checked name=\"" . $i . "\"></td>";
}
else {
echo " <td height=22 align=\"center\"><input onClick=\"host_click(this, '" . $i . "')\"" .
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $i . "', '" . $scope . "')\"" .
" type=\"checkbox\" name=\"" . $i . "\"></td>";
}
echo (" <td align='center'><a href=\"../account/edit.php?type=host&amp;DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "</a></td>");
@ -229,23 +230,11 @@ echo ("<br>\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 ("<p align=\"left\">\n");
echo ("<b>" . _("Suffix") . ": </b>");
echo ("<select size=1 name=\"hst_suffix\">\n");
for ($i = 0; $i < sizeof($hst_units); $i++) {
if ($hst_suffix == $hst_units[$i]) echo ("<option selected>" . $hst_units[$i] . "</option>\n");
else echo("<option>" . $hst_units[$i] . "</option>\n");
}
echo ("</select>\n");
echo ("<input type=\"submit\" name=\"refresh\" value=\"" . _("Change Suffix") . "\">");
echo ("</p>\n");
echo ("<p>&nbsp;</p>\n");
}
listShowOUSelection($units, $suffix);
// add/delete/PDF buttons
echo ("<input type=\"submit\" name=\"new\" value=\"" . _("New Host") . "\">\n");
@ -269,7 +258,7 @@ echo ("</form>\n");
echo "</body></html>\n";
// save variables to session
$_SESSION['hst_units'] = $hst_units;
$_SESSION['hst_suffix'] = $hst_suffix;
$_SESSION[$scope . '_units'] = $units;
$_SESSION[$scope . '_suffix'] = $suffix;
?>

View File

@ -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 "<title>listusers</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head><body>\n";
echo "<script src=\"../../lib/functions.js\" type=\"text/javascript\" language=\"javascript\"></script>\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 ("<form action=\"listusers.php?norefresh=true\" method=\"post\">\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 . "&amp;trans_primary=" . $trans_primary, "user", _("%s user(s) found"));
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort,
$searchFilter . "&amp;trans_primary=" . $trans_primary, $scope, _("%s user(s) found"));
echo ("<br />");
}
// account table head
listPrintTableHeader("user", $searchFilter . "&amp;trans_primary=" . $trans_primary, $desc_array, $attr_array, $_POST, $sort);
listPrintTableHeader($scope, $searchFilter . "&amp;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("<tr class=\"userlist\"\nonMouseOver=\"user_over(this, '" . $i . "')\"\n" .
"onMouseOut=\"user_out(this, '" . $i . "')\"\n" .
"onClick=\"user_click(this, '" . $i . "')\"\n" .
echo("<tr class=\"userlist\"\nonMouseOver=\"list_over(this, '" . $i . "', '" . $scope . "')\"\n" .
"onMouseOut=\"list_out(this, '" . $i . "', '" . $scope . "')\"\n" .
"onClick=\"list_click(this, '" . $i . "', '" . $scope . "')\"\n" .
"onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=user&amp;DN=" . $info[$i]['dn'] . "'\">\n");
// checkboxes if selectall = "yes"
if (isset($_GET['selectall'])) {
echo "<td height=22 align=\"center\">\n<input onClick=\"user_click(this, '" . $i . "')\" type=\"checkbox\" name=\"" .
echo "<td height=22 align=\"center\">\n<input onClick=\"list_click(this, '" . $i . "', '" . $scope . "')\" type=\"checkbox\" name=\"" .
$i . "\" checked>\n</td>\n";
}
else {
echo "<td height=22 align=\"center\">\n<input onClick=\"user_click(this, '" . $i . "')\" type=\"checkbox\" name=\"" .
echo "<td height=22 align=\"center\">\n<input onClick=\"list_click(this, '" . $i . "', '" . $scope . "')\" type=\"checkbox\" name=\"" .
$i . "\">\n</td>\n";
}
echo ("<td align='center'>\n<a href=\"../account/edit.php?type=user&amp;DN='" . $info[$i]['dn'] . "'\">" .
@ -270,30 +269,19 @@ if ($user_count != 0) {
echo ("</table>\n");
echo ("<br>");
if ($user_count != 0) {
listDrawNavigationBar($user_count, $max_page_entries, $page, $sort,
$searchFilter . "&amp;trans_primary=" . $trans_primary, "user", _("%s user(s) found"));
if (sizeof($info) != 0) {
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort,
$searchFilter . "&amp;trans_primary=" . $trans_primary, $scope, _("%s user(s) found"));
echo ("<br>");
}
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 ("<p align=\"left\">\n");
echo ("<b>" . _("Suffix") . ": </b>");
echo ("<select size=1 name=\"usr_suffix\">\n");
for ($i = 0; $i < sizeof($usr_units); $i++) {
if ($usr_suffix == $usr_units[$i]) echo ("<option selected>" . $usr_units[$i] . "</option>\n");
else echo("<option>" . $usr_units[$i] . "</option>\n");
}
echo ("</select>\n");
echo ("<input type=\"submit\" name=\"refresh\" value=\"" . _("Change Suffix") . "\">");
echo ("</p>\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 ("<p>&nbsp;</p>\n");
// new/delete/PDF buttons
echo ("<input type=\"submit\" name=\"new\" value=\"" . _("New user") . "\">\n");
if ($user_count != 0) {
if (sizeof($info) != 0) {
echo ("<input type=\"submit\" name=\"del\" value=\"" . _("Delete user(s)") . "\">\n");
echo ("<br><br><br>\n");
echo "<fieldset><legend><b>PDF</b></legend>\n";
echo ("<b>" . _('PDF structure') . ":</b>&nbsp;&nbsp;<select name=\"pdf_structure\">\n");
$pdf_structures = getAvailablePDFStructures('user');
$pdf_structures = getAvailablePDFStructures($scope);
foreach($pdf_structures as $pdf_structure) {
echo "<option value=\"" . $pdf_structure . "\"" . (($pdf_structure == 'default.xml') ? " selected" : "") . ">" . substr($pdf_structure,0,strlen($pdf_structure)-4) . "</option>";
}
@ -334,7 +322,7 @@ echo "</body></html>\n";
// save variables to session
$_SESSION['usr_units'] = $usr_units;
$_SESSION['usr_suffix'] = $usr_suffix;
$_SESSION[$scope . '_units'] = $units;
$_SESSION[$scope . '_suffix'] = $suffix;
?>