diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc
index 02e44ee0..ebe11098 100644
--- a/lam/lib/lists.inc
+++ b/lam/lib/lists.inc
@@ -76,11 +76,8 @@ class lamList {
/** LDAP entries */
protected $entries;
- /** filter string to include in URL */
- protected $filterText;
-
- /** LDAP filter part which was entered by user via filter boxes */
- protected $filterPart = '';
+ /** list of filters (attribute name => filter input) */
+ protected $filters = array();
/** list of possible LDAP suffixes(organizational units) */
protected $possibleSuffixes;
@@ -206,9 +203,11 @@ class lamList {
* Builds the regular expressions from the filter values.
*/
protected function listBuildFilter() {
+ if (isset($_GET['accountEditBack'])) {
+ return;
+ }
$filter = array();
- $filterParam = "";
- $LDAPFilterPart = "";
+ $this->filters = array();
if (!isset($_POST['clear_filter'])) {
// build filter array
for ($i = 0; $i < sizeof($this->attrArray); $i++) {
@@ -221,8 +220,7 @@ class lamList {
}
if (isset($foundFilter) && ($foundFilter != '')) {
if (preg_match('/^([\p{L}\p{N} _\\*\\$\\.@-])+$/iu', $foundFilter)) { // \p{L} matches any Unicode letter
- $filterParam .= "&filter" . $this->attrArray[$i] . '=' . $foundFilter;
- $LDAPFilterPart .= '(' . $this->attrArray[$i] . '=' . $foundFilter . ')';
+ $this->filters[strtolower($this->attrArray[$i])] = $foundFilter;
}
else {
StatusMessage('ERROR', _('Please enter a valid filter. Only letters, numbers and " _*$.@-" are allowed.'), htmlspecialchars($foundFilter));
@@ -230,8 +228,6 @@ class lamList {
}
}
}
- $this->filterText = $filterParam;
- $this->filterPart = $LDAPFilterPart;
}
/**
@@ -273,6 +269,7 @@ class lamList {
* @param integer $count number of account entries
*/
protected function listDrawNavigationBar($count) {
+ $filter = $this->getFilterAsTextForURL();
echo("
\n";
}
+
+ /**
+ * Returns the filter as text to be used as URL parameter.
+ *
+ * @return String filter text
+ */
+ protected function getFilterAsTextForURL() {
+ $text = '';
+ foreach ($this->filters as $attr => $filter) {
+ $text .= "&filter" . strtolower($attr) . '=' . $filter;
+ }
+ return $text;
+ }
/**
* Prints the attribute and filter row at the account table head
*/
protected function listPrintTableHeader() {
+ $filter = $this->getFilterAsTextForURL();
// print table header
echo "type . "-border collapse accountlist ui-corner-all\" width=\"100%\">\n";
echo "type . "-dark\">\n | \n | \n";
@@ -336,11 +347,11 @@ class lamList {
$sortImage = "sort_desc.png";
}
echo "type . "&".
- "sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&norefresh=y" . "\">" . $this->descArray[$k] .
+ "sort=" . strtolower($this->attrArray[$k]) . $filter . "&norefresh=y" . "\">" . $this->descArray[$k] .
" | \n";
}
else echo "type . "&".
- "sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&norefresh=y" . "\">" . $this->descArray[$k] . " | \n";
+ "sort=" . strtolower($this->attrArray[$k]) . $filter . "&norefresh=y" . "\">" . $this->descArray[$k] . "\n";
}
echo "
\n";
@@ -354,7 +365,7 @@ class lamList {
$filterButton = new htmlButton('apply_filter', 'filter.png', true);
$filterButton->setTitle(_("Filter"));
$filterGroup->addElement($filterButton);
- if (isset($this->filterPart) && ($this->filterPart != '')) {
+ if (sizeof($this->filters) > 0) {
$filterGroup->addElement(new htmlSpacer('1px', null));
$clearFilterButton = new htmlButton('clear_filter', 'clearFilter.png', true);
$clearFilterButton->setTitle(_('Clear filter'));
@@ -368,11 +379,8 @@ class lamList {
if ($this->canBeFiltered($this->attrArray[$k])) {
$value = "";
if (!isset($_POST['clear_filter'])) {
- if (isset($_GET["filter" . strtolower($this->attrArray[$k])])) {
- $value = $_GET["filter" . strtolower($this->attrArray[$k])];
- }
- if (isset($_POST["filter" . strtolower($this->attrArray[$k])])) {
- $value = $_POST["filter" . strtolower($this->attrArray[$k])];
+ if (isset($this->filters[strtolower($this->attrArray[$k])])) {
+ $value = $this->filters[strtolower($this->attrArray[$k])];
}
}
$filterInput = new htmlInputField('filter' . strtolower($this->attrArray[$k]), $value);
@@ -836,6 +844,10 @@ class lamList {
* Sets some internal parameters.
*/
protected function listGetParams() {
+ if (isset($_GET['accountEditBack'])) {
+ $this->refresh = true;
+ return;
+ }
// check if only PDF should be shown
if (isset($_GET['printPDF'])) {
$this->showPDFPage(null);
@@ -888,7 +900,7 @@ class lamList {
}
// configure search filter
$module_filter = get_ldap_filter($this->type); // basic filter is provided by modules
- $filter = "(&" . $module_filter . $this->filterPart . ")";
+ $filter = "(&" . $module_filter . $this->buildLDAPAttributeFilter() . ")";
$attrs = $this->attrArray;
// remove virtual attributes from list
for ($i = 0; $i < sizeof($attrs); $i++) {
@@ -914,6 +926,19 @@ class lamList {
$this->possibleSuffixes = $typeObj->getSuffixList();
}
+ /**
+ * Builds the LDAP filter based on the filter entries in the GUI.
+ *
+ * @return String LDAP filter
+ */
+ protected function buildLDAPAttributeFilter() {
+ $text = '';
+ foreach ($this->filters as $attr => $filter) {
+ $text .= '(' . $attr . '=' . $filter . ')';
+ }
+ return $text;
+ }
+
/**
* Forces a refresh of the LDAP data.
* Function must be called before $this->refresh option is checked to load new LDAP data (e.g. in listGetParams).
diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc
index 811d7747..7f39bcb0 100644
--- a/lam/lib/modules.inc
+++ b/lam/lib/modules.inc
@@ -3,7 +3,7 @@
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2003 - 2012 Roland Gruber
+ Copyright (C) 2003 - 2013 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -826,7 +826,7 @@ class accountContainer {
if (isset($_POST['accountContainerBackToList'])) {
// Return to account list
unset($_SESSION[$this->base]);
- metaRefresh("../lists/list.php?type=" . $this->type);
+ metaRefresh("../lists/list.php?type=" . $this->type . '&accountEditBack=true');
exit;
}
// create PDF file
diff --git a/lam/lib/types/asteriskExt.inc b/lam/lib/types/asteriskExt.inc
index 4f93593d..b2a51add 100644
--- a/lam/lib/types/asteriskExt.inc
+++ b/lam/lib/types/asteriskExt.inc
@@ -5,7 +5,7 @@
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2009 - 2012 Pozdnyak Pavel
- 2010 - 2012 Roland Gruber
+ 2010 - 2013 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -168,7 +168,7 @@ class lamAsteriskExtList extends lamList {
parent::listRefreshData();
// configure search filter
$module_filter = get_ldap_filter($this->type); // basic filter is provided by modules
- $filter = "(&" . $module_filter . $this->filterPart . ")";
+ $filter = "(&" . $module_filter . $this->buildLDAPAttributeFilter() . ")";
$attrs = $this->attrArray;
$attrs[] = "astpriority";
$entries = searchLDAP($this->suffix, $filter, $attrs);