fixed list filtering
This commit is contained in:
parent
f29d7096bf
commit
ba8231dc09
|
@ -42,46 +42,46 @@ include_once("pdf.inc");
|
||||||
*
|
*
|
||||||
* @package lists
|
* @package lists
|
||||||
* @author Roland Gruber
|
* @author Roland Gruber
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class lamList {
|
class lamList {
|
||||||
|
|
||||||
/** Account type */
|
/** Account type */
|
||||||
var $type;
|
var $type;
|
||||||
|
|
||||||
/** current page number */
|
/** current page number */
|
||||||
var $page = 1;
|
var $page = 1;
|
||||||
|
|
||||||
/** list of LDAP attributes */
|
/** list of LDAP attributes */
|
||||||
var $attrArray = array();
|
var $attrArray = array();
|
||||||
|
|
||||||
/** list of attribute descriptions */
|
/** list of attribute descriptions */
|
||||||
var $descArray = array();
|
var $descArray = array();
|
||||||
|
|
||||||
/** maximum count of entries per page */
|
/** maximum count of entries per page */
|
||||||
var $maxPageEntries = 10;
|
var $maxPageEntries = 10;
|
||||||
|
|
||||||
/** sort column name */
|
/** sort column name */
|
||||||
var $sortColumn;
|
var $sortColumn;
|
||||||
|
|
||||||
/** LDAP suffix */
|
/** LDAP suffix */
|
||||||
var $suffix;
|
var $suffix;
|
||||||
|
|
||||||
/** refresh page switch */
|
/** refresh page switch */
|
||||||
var $refresh = true;
|
var $refresh = true;
|
||||||
|
|
||||||
/** LDAP entries */
|
/** LDAP entries */
|
||||||
var $entries;
|
var $entries;
|
||||||
|
|
||||||
/** filter string to include in URL */
|
/** filter string to include in URL */
|
||||||
var $filterText;
|
var $filterText;
|
||||||
|
|
||||||
/** list of possible LDAP suffixes(organizational units) */
|
/** list of possible LDAP suffixes(organizational units) */
|
||||||
var $possibleSuffixes;
|
var $possibleSuffixes;
|
||||||
|
|
||||||
/** list of account specific labels */
|
/** list of account specific labels */
|
||||||
var $labels;
|
var $labels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -98,7 +98,7 @@ class lamList {
|
||||||
'createPDF' => _("Create PDF for selected object(s)"),
|
'createPDF' => _("Create PDF for selected object(s)"),
|
||||||
'createPDFAll' => _("Create PDF for all objects"));
|
'createPDFAll' => _("Create PDF for all objects"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the HTML code to display the list view.
|
* Prints the HTML code to display the list view.
|
||||||
*/
|
*/
|
||||||
|
@ -159,9 +159,16 @@ class lamList {
|
||||||
$filter = array();
|
$filter = array();
|
||||||
// build filter array
|
// build filter array
|
||||||
for ($i = 0; $i < sizeof($this->attrArray); $i++) {
|
for ($i = 0; $i < sizeof($this->attrArray); $i++) {
|
||||||
if (isset($_POST["filter" . strtolower($this->attrArray[$i])]) && eregi('^([0-9a-z _\\*\\$-])+$', $_POST["filter" . strtolower($this->attrArray[$i])])) {
|
$foundFilter = null;
|
||||||
$filter[$this->attrArray[$i]]['original'] = $_POST["filter" . strtolower($this->attrArray[$i])];
|
if (isset($_GET["filter" . strtolower($this->attrArray[$i])])) {
|
||||||
$filter[$this->attrArray[$i]]['regex'] = $_POST["filter" . strtolower($this->attrArray[$i])];
|
$foundFilter = $_GET["filter" . strtolower($this->attrArray[$i])];
|
||||||
|
}
|
||||||
|
if (isset($_POST["filter" . strtolower($this->attrArray[$i])])) {
|
||||||
|
$foundFilter = $_POST["filter" . strtolower($this->attrArray[$i])];
|
||||||
|
}
|
||||||
|
if (isset($foundFilter) && eregi('^([0-9a-z _\\*\\$-])+$', $foundFilter)) {
|
||||||
|
$filter[$this->attrArray[$i]]['original'] = $foundFilter;
|
||||||
|
$filter[$this->attrArray[$i]]['regex'] = $foundFilter;
|
||||||
// replace special characters
|
// replace special characters
|
||||||
$filter[$this->attrArray[$i]]['regex'] = str_replace("*", "(.)*", $filter[$this->attrArray[$i]]['regex']);
|
$filter[$this->attrArray[$i]]['regex'] = str_replace("*", "(.)*", $filter[$this->attrArray[$i]]['regex']);
|
||||||
$filter[$this->attrArray[$i]]['regex'] = str_replace('$', '[$]', $filter[$this->attrArray[$i]]['regex']);
|
$filter[$this->attrArray[$i]]['regex'] = str_replace('$', '[$]', $filter[$this->attrArray[$i]]['regex']);
|
||||||
|
@ -184,8 +191,8 @@ class lamList {
|
||||||
$this->filterText = $searchFilter;
|
$this->filterText = $searchFilter;
|
||||||
return $filter;
|
return $filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all entries which do not fit to the filter.
|
* Removes all entries which do not fit to the filter.
|
||||||
*
|
*
|
||||||
|
@ -217,8 +224,8 @@ class lamList {
|
||||||
if (sizeof($entries) == 0) StatusMessage("WARN", $this->labels['error_noneFound']);
|
if (sizeof($entries) == 0) StatusMessage("WARN", $this->labels['error_noneFound']);
|
||||||
return $entries;
|
return $entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts an account list by a given attribute
|
* Sorts an account list by a given attribute
|
||||||
*
|
*
|
||||||
|
@ -232,8 +239,8 @@ class lamList {
|
||||||
usort($info, array($this, "cmp_array"));
|
usort($info, array($this, "cmp_array"));
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare function used for usort-method
|
* Compare function used for usort-method
|
||||||
*
|
*
|
||||||
|
@ -265,7 +272,7 @@ class lamList {
|
||||||
* @param integer $count number of account entries
|
* @param integer $count number of account entries
|
||||||
*/
|
*/
|
||||||
function listDrawNavigationBar($count) {
|
function listDrawNavigationBar($count) {
|
||||||
|
|
||||||
echo("<table class=\"" . $this->type . "nav\" width=\"100%\" border=\"0\">\n");
|
echo("<table class=\"" . $this->type . "nav\" width=\"100%\" border=\"0\">\n");
|
||||||
echo("<tr>\n");
|
echo("<tr>\n");
|
||||||
echo("<td><input type=\"submit\" name=\"refresh\" value=\"" . _("Refresh") . "\"> ");
|
echo("<td><input type=\"submit\" name=\"refresh\" value=\"" . _("Refresh") . "\"> ");
|
||||||
|
@ -276,19 +283,19 @@ class lamList {
|
||||||
echo("<=");
|
echo("<=");
|
||||||
}
|
}
|
||||||
echo(" ");
|
echo(" ");
|
||||||
|
|
||||||
if ($this->page < ($count / $this->maxPageEntries)) {
|
if ($this->page < ($count / $this->maxPageEntries)) {
|
||||||
echo("<a href=\"list.php?type=" . $this->type . "&norefresh=true&page=" . ($this->page + 1) . "&sort=" . $this->sortColumn . $this->filterText . "\">=></a>\n");
|
echo("<a href=\"list.php?type=" . $this->type . "&norefresh=true&page=" . ($this->page + 1) . "&sort=" . $this->sortColumn . $this->filterText . "\">=></a>\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo("=></td>");
|
echo("=></td>");
|
||||||
}
|
}
|
||||||
|
|
||||||
echo("<td class=\"" . $this->type . "nav-text\">");
|
echo("<td class=\"" . $this->type . "nav-text\">");
|
||||||
echo" ";
|
echo" ";
|
||||||
printf($this->labels['nav'], $count);
|
printf($this->labels['nav'], $count);
|
||||||
echo("</td>");
|
echo("</td>");
|
||||||
|
|
||||||
echo("<td class=\"" . $this->type . "nav-activepage\" align=\"right\">");
|
echo("<td class=\"" . $this->type . "nav-activepage\" align=\"right\">");
|
||||||
for ($i = 0; $i < ($count / $this->maxPageEntries); $i++) {
|
for ($i = 0; $i < ($count / $this->maxPageEntries); $i++) {
|
||||||
if ($i == $this->page - 1) {
|
if ($i == $this->page - 1) {
|
||||||
|
@ -300,7 +307,7 @@ class lamList {
|
||||||
}
|
}
|
||||||
echo("</td></tr></table>\n");
|
echo("</td></tr></table>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the attribute and filter row at the account table head
|
* Prints the attribute and filter row at the account table head
|
||||||
*/
|
*/
|
||||||
|
@ -318,7 +325,7 @@ class lamList {
|
||||||
"sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&norefresh=y" . "\">" . $this->descArray[$k] . "</a></th>\n";
|
"sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&norefresh=y" . "\">" . $this->descArray[$k] . "</a></th>\n";
|
||||||
}
|
}
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
|
|
||||||
// print filter row
|
// print filter row
|
||||||
echo "<tr align=\"center\" class=\"" . $this->type . "list\">\n";
|
echo "<tr align=\"center\" class=\"" . $this->type . "list\">\n";
|
||||||
echo "<td width=22 height=34>";
|
echo "<td width=22 height=34>";
|
||||||
|
@ -333,6 +340,9 @@ class lamList {
|
||||||
// print input boxes for filters
|
// print input boxes for filters
|
||||||
for ($k = 0; $k < sizeof ($this->descArray); $k++) {
|
for ($k = 0; $k < sizeof ($this->descArray); $k++) {
|
||||||
$value = "";
|
$value = "";
|
||||||
|
if (isset($_GET["filter" . strtolower($this->attrArray[$k])])) {
|
||||||
|
$value = " value=\"" . $_GET["filter" . strtolower($this->attrArray[$k])] . "\"";
|
||||||
|
}
|
||||||
if (isset($_POST["filter" . strtolower($this->attrArray[$k])])) {
|
if (isset($_POST["filter" . strtolower($this->attrArray[$k])])) {
|
||||||
$value = " value=\"" . $_POST["filter" . strtolower($this->attrArray[$k])] . "\"";
|
$value = " value=\"" . $_POST["filter" . strtolower($this->attrArray[$k])] . "\"";
|
||||||
}
|
}
|
||||||
|
@ -345,7 +355,7 @@ class lamList {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the entry list
|
* Prints the entry list
|
||||||
*
|
*
|
||||||
* @param array $info entries
|
* @param array $info entries
|
||||||
*/
|
*/
|
||||||
function listPrintTableBody($info) {
|
function listPrintTableBody($info) {
|
||||||
|
@ -390,15 +400,15 @@ class lamList {
|
||||||
$colspan = sizeof($this->attrArray) + 1;
|
$colspan = sizeof($this->attrArray) + 1;
|
||||||
echo "<tr class=\"" . $this->type . "list\">\n";
|
echo "<tr class=\"" . $this->type . "list\">\n";
|
||||||
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
|
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
|
||||||
echo "<td colspan=$colspan> <a href=\"list.php?type=" . $this->type . "&norefresh=y&page=" . $this->page .
|
echo "<td colspan=$colspan> <a href=\"list.php?type=" . $this->type . "&norefresh=y&page=" . $this->page .
|
||||||
"&sort=" . $this->sortColumn . $this->filterText . "&selectall=yes\">" .
|
"&sort=" . $this->sortColumn . $this->filterText . "&selectall=yes\">" .
|
||||||
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
|
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
echo ("</table>");
|
echo ("</table>");
|
||||||
|
|
||||||
echo ("<br>");
|
echo ("<br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages all POST actions (e.g. button pressed) for the account lists.
|
* Manages all POST actions (e.g. button pressed) for the account lists.
|
||||||
*/
|
*/
|
||||||
|
@ -465,7 +475,7 @@ class lamList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a combobox with possible sub-DNs.
|
* Prints a combobox with possible sub-DNs.
|
||||||
*/
|
*/
|
||||||
|
@ -485,7 +495,7 @@ class lamList {
|
||||||
echo ("</p>\n");
|
echo ("</p>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the create, delete and PDF buttons.
|
* Prints the create, delete and PDF buttons.
|
||||||
*
|
*
|
||||||
|
@ -510,7 +520,7 @@ class lamList {
|
||||||
echo "</fieldset>";
|
echo "</fieldset>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the HTML head.
|
* Prints the HTML head.
|
||||||
*/
|
*/
|
||||||
|
@ -522,7 +532,7 @@ class lamList {
|
||||||
echo "</head><body>\n";
|
echo "</head><body>\n";
|
||||||
$this->listPrintJavaScript();
|
$this->listPrintJavaScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints JavaScript code needed for mouse-over effects.
|
* Prints JavaScript code needed for mouse-over effects.
|
||||||
*/
|
*/
|
||||||
|
@ -534,13 +544,13 @@ class lamList {
|
||||||
echo "cbox = document.getElementsByName(box)[0];\n";
|
echo "cbox = document.getElementsByName(box)[0];\n";
|
||||||
echo "if (cbox.checked == false) list.setAttribute('class', scope + 'list-over', 0);\n";
|
echo "if (cbox.checked == false) list.setAttribute('class', scope + 'list-over', 0);\n";
|
||||||
echo "}";
|
echo "}";
|
||||||
|
|
||||||
// mouseOut function
|
// mouseOut function
|
||||||
echo "function list_out(list, box, scope) {\n";
|
echo "function list_out(list, box, scope) {\n";
|
||||||
echo "cbox = document.getElementsByName(box)[0];\n";
|
echo "cbox = document.getElementsByName(box)[0];\n";
|
||||||
echo "if (cbox.checked == false) list.setAttribute('class', scope + 'list', 0);\n";
|
echo "if (cbox.checked == false) list.setAttribute('class', scope + 'list', 0);\n";
|
||||||
echo "}\n";
|
echo "}\n";
|
||||||
|
|
||||||
// onClick function
|
// onClick function
|
||||||
echo "function list_click(list, box, scope) {\n";
|
echo "function list_click(list, box, scope) {\n";
|
||||||
echo "cbox = document.getElementsByName(box)[0];\n";
|
echo "cbox = document.getElementsByName(box)[0];\n";
|
||||||
|
@ -556,7 +566,7 @@ class lamList {
|
||||||
echo "//-->\n";
|
echo "//-->\n";
|
||||||
echo "</script>\n";
|
echo "</script>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an hash array containing with all attributes to be shown and their descriptions.
|
* Returns an hash array containing with all attributes to be shown and their descriptions.
|
||||||
* Format: array(attribute => description)
|
* Format: array(attribute => description)
|
||||||
|
@ -593,7 +603,7 @@ class lamList {
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets some internal parameters.
|
* Sets some internal parameters.
|
||||||
*/
|
*/
|
||||||
|
@ -621,7 +631,7 @@ class lamList {
|
||||||
if (isset($_GET['norefresh'])) $this->refresh = false;
|
if (isset($_GET['norefresh'])) $this->refresh = false;
|
||||||
if (isset($_POST['refresh'])) $this->refresh = true;
|
if (isset($_POST['refresh'])) $this->refresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rereads the entries from LDAP.
|
* Rereads the entries from LDAP.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue