allow ":" in filter

This commit is contained in:
Roland Gruber 2015-11-06 17:04:55 +00:00
parent 54a5672bc2
commit ed999af541
1 changed files with 72 additions and 72 deletions

View File

@ -63,7 +63,7 @@ class lamList {
/** sort column name */ /** sort column name */
protected $sortColumn; protected $sortColumn;
/** sort direction: 1 for ascending, -1 for descending */ /** sort direction: 1 for ascending, -1 for descending */
protected $sortDirection = 1; protected $sortDirection = 1;
@ -75,7 +75,7 @@ class lamList {
/** LDAP entries */ /** LDAP entries */
protected $entries; protected $entries;
/** sort mapping for entries array(original index => sorted index) */ /** sort mapping for entries array(original index => sorted index) */
protected $sortMapping; protected $sortMapping;
@ -87,19 +87,19 @@ class lamList {
/** list of account specific labels */ /** list of account specific labels */
protected $labels; protected $labels;
/** configuration options */ /** configuration options */
private $configOptions; private $configOptions;
/** tabindex for GUI elements */ /** tabindex for GUI elements */
protected $tabindex = 1; protected $tabindex = 1;
/** ID for list size config option */ /** ID for list size config option */
const LIST_SIZE_OPTION_NAME = "L_SIZE"; const LIST_SIZE_OPTION_NAME = "L_SIZE";
/** prefix for virtual (non-LDAP) attributes */ /** prefix for virtual (non-LDAP) attributes */
const VIRTUAL_ATTRIBUTE_PREFIX = 'lam_virtual_'; const VIRTUAL_ATTRIBUTE_PREFIX = 'lam_virtual_';
/** /**
* Constructor * Constructor
* *
@ -116,7 +116,7 @@ class lamList {
$this->configOptions = $this->listGetAllConfigOptions(); $this->configOptions = $this->listGetAllConfigOptions();
$this->listReadOptionsFromCookie(); $this->listReadOptionsFromCookie();
} }
/** /**
* Reads the list options from the cookie value. * Reads the list options from the cookie value.
*/ */
@ -222,7 +222,7 @@ class lamList {
$foundFilter = $_POST["filter" . strtolower($this->attrArray[$i])]; $foundFilter = $_POST["filter" . strtolower($this->attrArray[$i])];
} }
if (isset($foundFilter) && ($foundFilter != '')) { if (isset($foundFilter) && ($foundFilter != '')) {
if (preg_match('/^([\p{L}\p{N} _\\*\\$\\.@-])+$/iu', $foundFilter)) { // \p{L} matches any Unicode letter if (preg_match('/^([\p{L}\p{N} _\\*\\$\\.:@-])+$/iu', $foundFilter)) { // \p{L} matches any Unicode letter
$this->filters[strtolower($this->attrArray[$i])] = $foundFilter; $this->filters[strtolower($this->attrArray[$i])] = $foundFilter;
} }
else { else {
@ -232,7 +232,7 @@ class lamList {
} }
} }
} }
/** /**
* Determines the sort mapping and stores it in $this->sortMapping. * Determines the sort mapping and stores it in $this->sortMapping.
* The sort mapping is used to display the right rows when the account table is created. * The sort mapping is used to display the right rows when the account table is created.
@ -332,10 +332,10 @@ class lamList {
} }
echo "</tr></table>\n"; echo "</tr></table>\n";
} }
/** /**
* Returns the filter as text to be used as URL parameter. * Returns the filter as text to be used as URL parameter.
* *
* @return String filter text * @return String filter text
*/ */
protected function getFilterAsTextForURL() { protected function getFilterAsTextForURL() {
@ -401,10 +401,10 @@ class lamList {
} }
echo "</tr></thead>\n"; echo "</tr></thead>\n";
} }
/** /**
* Prints the content of a single attribute filter area. * Prints the content of a single attribute filter area.
* *
* @param String $attrName attribute name * @param String $attrName attribute name
* @param boolean $clearFilter true if filter value should be cleared * @param boolean $clearFilter true if filter value should be cleared
*/ */
@ -421,12 +421,12 @@ class lamList {
$filterInput->setOnKeyPress("SubmitForm('apply_filter', event);"); $filterInput->setOnKeyPress("SubmitForm('apply_filter', event);");
parseHtml(null, $filterInput, array(), false, $this->tabindex, $this->type); parseHtml(null, $filterInput, array(), false, $this->tabindex, $this->type);
} }
/** /**
* Returns if the given attribute can be filtered. * Returns if the given attribute can be filtered.
* If filtering is not possible then no filter box will be displayed. * If filtering is not possible then no filter box will be displayed.
* By default all attributes can be filtered. * By default all attributes can be filtered.
* *
* @param String $attr attribute name * @param String $attr attribute name
* @return boolean filtering possible * @return boolean filtering possible
*/ */
@ -488,10 +488,10 @@ class lamList {
echo "</tbody>\n"; echo "</tbody>\n";
echo "</table>\n"; echo "</table>\n";
} }
/** /**
* Prints the tool image links (e.g. edit and delete) for each account. * Prints the tool image links (e.g. edit and delete) for each account.
* *
* @param array $account LDAP attributes * @param array $account LDAP attributes
* @param String $id account ID * @param String $id account ID
*/ */
@ -528,7 +528,7 @@ class lamList {
parseHtml(null, $group, array(), false, $this->tabindex, $this->type); parseHtml(null, $group, array(), false, $this->tabindex, $this->type);
echo "</td>\n"; echo "</td>\n";
} }
/** /**
* Prints the content of a cell in the account list for a given LDAP entry and attribute. * Prints the content of a cell in the account list for a given LDAP entry and attribute.
* *
@ -546,12 +546,12 @@ class lamList {
else { else {
echo htmlspecialchars($entry[$attribute], ENT_QUOTES, "UTF-8"); echo htmlspecialchars($entry[$attribute], ENT_QUOTES, "UTF-8");
} }
} }
} }
/** /**
* Manages all POST actions (e.g. button pressed) for the account lists. * Manages all POST actions (e.g. button pressed) for the account lists.
* *
* @return String HTML fragment to insert into beginning of account list * @return String HTML fragment to insert into beginning of account list
*/ */
protected function listDoPost() { protected function listDoPost() {
@ -669,7 +669,7 @@ class lamList {
} }
return ''; return '';
} }
/** /**
* Shows the page where the user may select the PDF options. * Shows the page where the user may select the PDF options.
* *
@ -689,7 +689,7 @@ class lamList {
} }
// get possible PDF structures // get possible PDF structures
$pdf_structures = getPDFStructureDefinitions($this->type); $pdf_structures = getPDFStructureDefinitions($this->type);
$this->listPrintHeader(); $this->listPrintHeader();
echo "<div class=\"ui-tabs-nav " . $this->type . "-bright\">"; echo "<div class=\"ui-tabs-nav " . $this->type . "-bright\">";
@ -699,12 +699,12 @@ class lamList {
$refresh = '&amp;refresh=true'; $refresh = '&amp;refresh=true';
} }
echo "<form action=\"list.php?type=" . $this->type . $refresh . "\" method=\"post\">\n"; echo "<form action=\"list.php?type=" . $this->type . $refresh . "\" method=\"post\">\n";
$container = new htmlTable(); $container = new htmlTable();
$container->addElement(new htmlSubTitle(_('Create PDF file')), true); $container->addElement(new htmlSubTitle(_('Create PDF file')), true);
$container->addElement(new htmlTableExtendedSelect('pdf_structure', $pdf_structures, array('default'), _('PDF structure'), '405'), true); $container->addElement(new htmlTableExtendedSelect('pdf_structure', $pdf_structures, array('default'), _('PDF structure'), '405'), true);
$container->addElement(new htmlSpacer(null, '5px'), true); $container->addElement(new htmlSpacer(null, '5px'), true);
$container->addElement(new htmlOutputText(_('Create for'))); $container->addElement(new htmlOutputText(_('Create for')));
// check if account object is already in session // check if account object is already in session
@ -721,7 +721,7 @@ class lamList {
); );
$container->addElement(new htmlRadio('createFor', $radioOptions, 'DN'), true); $container->addElement(new htmlRadio('createFor', $radioOptions, 'DN'), true);
} }
$container->addElement(new htmlSpacer(null, '10px'), true); $container->addElement(new htmlSpacer(null, '10px'), true);
$buttonContainer = new htmlTable(); $buttonContainer = new htmlTable();
$buttonContainer->colspan = 3; $buttonContainer->colspan = 3;
@ -734,15 +734,15 @@ class lamList {
} }
$container->addElement(new htmlHiddenInput('clickedAccount', $id)); $container->addElement(new htmlHiddenInput('clickedAccount', $id));
addSecurityTokenToMetaHTML($container); addSecurityTokenToMetaHTML($container);
parseHtml(null, $container, array(), false, $this->tabindex, $this->type); parseHtml(null, $container, array(), false, $this->tabindex, $this->type);
$this->listPrintFooter(); $this->listPrintFooter();
} }
/** /**
* Prints a combobox with possible sub-DNs. * Prints a combobox with possible sub-DNs.
* *
* @return htmlGroup OU selection (may be empty) * @return htmlGroup OU selection (may be empty)
*/ */
protected function listShowOUSelection() { protected function listShowOUSelection() {
@ -798,7 +798,7 @@ class lamList {
$left->addElement($uploadButton); $left->addElement($uploadButton);
} }
} }
// OU selection and settings // OU selection and settings
$right = new htmlGroup(); $right = new htmlGroup();
$right->alignment = htmlElement::ALIGN_RIGHT; $right->alignment = htmlElement::ALIGN_RIGHT;
@ -811,30 +811,30 @@ class lamList {
$settingsLink->setOnClick('listShowSettingsDialog(\'' . _('Change list settings') . '\', \'' . _('Ok') . '\', \'' . _('Cancel') . '\');'); $settingsLink->setOnClick('listShowSettingsDialog(\'' . _('Change list settings') . '\', \'' . _('Ok') . '\', \'' . _('Cancel') . '\');');
$settingsLink->setTitle(_('Change settings')); $settingsLink->setTitle(_('Change settings'));
$right->addElement($settingsLink); $right->addElement($settingsLink);
$this->addExtraInputElementsToTopArea($left, $right); $this->addExtraInputElementsToTopArea($left, $right);
$table->addElement($left); $table->addElement($left);
$table->addElement($right); $table->addElement($right);
parseHtml(null, $table, array(), false, $this->tabindex, $this->type); parseHtml(null, $table, array(), false, $this->tabindex, $this->type);
} }
/** /**
* Can be used by subclasses to add e.g. additional buttons to the top area. * Can be used by subclasses to add e.g. additional buttons to the top area.
* *
* @param htmlGroup $left left part * @param htmlGroup $left left part
* @param htmlGroup $right right part * @param htmlGroup $right right part
*/ */
protected function addExtraInputElementsToTopArea(&$left, &$right) { protected function addExtraInputElementsToTopArea(&$left, &$right) {
// only used by subclasses // only used by subclasses
} }
/** /**
* Prints the HTML header. * Prints the HTML header.
*/ */
protected function listPrintHeader() { protected function listPrintHeader() {
include '../main_header.php'; include '../main_header.php';
} }
/** /**
* Prints the HTML footer. * Prints the HTML footer.
*/ */
@ -978,10 +978,10 @@ class lamList {
$typeObj = new $this->type(); $typeObj = new $this->type();
$this->possibleSuffixes = $typeObj->getSuffixList(); $this->possibleSuffixes = $typeObj->getSuffixList();
} }
/** /**
* Builds the LDAP filter based on the filter entries in the GUI. * Builds the LDAP filter based on the filter entries in the GUI.
* *
* @return String LDAP filter * @return String LDAP filter
*/ */
protected function buildLDAPAttributeFilter() { protected function buildLDAPAttributeFilter() {
@ -991,7 +991,7 @@ class lamList {
} }
return $text; return $text;
} }
/** /**
* Forces a refresh of the LDAP data. * 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). * Function must be called before $this->refresh option is checked to load new LDAP data (e.g. in listGetParams).
@ -1002,17 +1002,17 @@ class lamList {
unset($_GET['norefresh']); unset($_GET['norefresh']);
} }
} }
/** /**
* Returns a list of additional LDAP attributes that should be read. * Returns a list of additional LDAP attributes that should be read.
* This can be used to show additional data even if the user selected other attributes to show in the list. * This can be used to show additional data even if the user selected other attributes to show in the list.
* *
* @return array additional attribute names * @return array additional attribute names
*/ */
protected function getAdditionalLDAPAttributesToRead() { protected function getAdditionalLDAPAttributesToRead() {
return array(); return array();
} }
/** /**
* Returns a list of lamListTool objects to display next to the edit/delete buttons. * Returns a list of lamListTool objects to display next to the edit/delete buttons.
* *
@ -1021,7 +1021,7 @@ class lamList {
protected function getAdditionalTools() { protected function getAdditionalTools() {
return array(); return array();
} }
/** /**
* Returns a list of possible configuration options. * Returns a list of possible configuration options.
* *
@ -1041,21 +1041,21 @@ class lamList {
echo "<div id=\"settingsDialog\" class=\"hidden\">\n"; echo "<div id=\"settingsDialog\" class=\"hidden\">\n";
echo "<form id=\"settingsDialogForm\" action=\"list.php?type=" . $this->type . "&amp;norefresh=true\" method=\"post\">\n"; echo "<form id=\"settingsDialogForm\" action=\"list.php?type=" . $this->type . "&amp;norefresh=true\" method=\"post\">\n";
echo '<table width="100%"><tr><td>'; echo '<table width="100%"><tr><td>';
$configContainer = new htmlTable(); $configContainer = new htmlTable();
for ($i = 0; $i < sizeof($this->configOptions); $i++) { for ($i = 0; $i < sizeof($this->configOptions); $i++) {
$configContainer->mergeTableElements($this->configOptions[$i]->getMetaHTML()); $configContainer->mergeTableElements($this->configOptions[$i]->getMetaHTML());
} }
$configContainer->addElement(new htmlHiddenInput('saveConfigOptions', 'ok')); $configContainer->addElement(new htmlHiddenInput('saveConfigOptions', 'ok'));
addSecurityTokenToMetaHTML($configContainer); addSecurityTokenToMetaHTML($configContainer);
parseHtml('', $configContainer, array(), false, $this->tabindex, $this->type); parseHtml('', $configContainer, array(), false, $this->tabindex, $this->type);
echo "</td></tr></table>\n"; echo "</td></tr></table>\n";
echo '</form>'; echo '</form>';
echo "</div>\n"; echo "</div>\n";
} }
/** /**
* Returns the configuration option with the given ID. * Returns the configuration option with the given ID.
* *
@ -1069,7 +1069,7 @@ class lamList {
} }
return null; return null;
} }
/** /**
* Called when the configuration options changed. * Called when the configuration options changed.
*/ */
@ -1114,14 +1114,14 @@ class lamList {
* @author Roland Gruber * @author Roland Gruber
*/ */
class lamListTool { class lamListTool {
/** tool name */ /** tool name */
private $name; private $name;
/** tool image */ /** tool image */
private $image; private $image;
/** link target */ /** link target */
private $target; private $target;
/** /**
* Constructor * Constructor
* *
@ -1159,7 +1159,7 @@ class lamListTool {
/** /**
* Returns the PHP file (relative to 'templates/lists') which will be the target for this tool. * Returns the PHP file (relative to 'templates/lists') which will be the target for this tool.
* The target page will be opened with two GET parameters: DN and type (e.g. user) * The target page will be opened with two GET parameters: DN and type (e.g. user)
* *
* @return String page file (e.g. 'mytool.php') * @return String page file (e.g. 'mytool.php')
*/ */
public function getLinkTarget() { public function getLinkTarget() {
@ -1175,12 +1175,12 @@ class lamListTool {
* @author Roland Gruber * @author Roland Gruber
*/ */
abstract class lamListOption { abstract class lamListOption {
/** unique ID */ /** unique ID */
private $ID; private $ID;
/** option value */ /** option value */
private $value; private $value;
/** /**
* Creates a new config option. * Creates a new config option.
* *
@ -1190,7 +1190,7 @@ abstract class lamListOption {
public function __construct($ID) { public function __construct($ID) {
$this->ID = $ID; $this->ID = $ID;
} }
/** /**
* Returns the option ID. * Returns the option ID.
* *
@ -1199,14 +1199,14 @@ abstract class lamListOption {
public function getID() { public function getID() {
return $this->ID; return $this->ID;
} }
/** /**
* Fills the config option from POST data. * Fills the config option from POST data.
* *
* @return array list of StatusMessages (array(<type>, <head line>, <body>)) * @return array list of StatusMessages (array(<type>, <head line>, <body>))
*/ */
public abstract function fillFromPostData(); public abstract function fillFromPostData();
/** /**
* Returns the option value. The value must not contain "=" and ";". * Returns the option value. The value must not contain "=" and ";".
* *
@ -1215,7 +1215,7 @@ abstract class lamListOption {
public function getValue() { public function getValue() {
return $this->value; return $this->value;
} }
/** /**
* Sets the config option value. The value must not contain "=" and ";". * Sets the config option value. The value must not contain "=" and ";".
* *
@ -1227,14 +1227,14 @@ abstract class lamListOption {
} }
$this->value = $value; $this->value = $value;
} }
/** /**
* Returns the meta HTML data to display this option. * Returns the meta HTML data to display this option.
* *
* @return htmlTable meta HTML * @return htmlTable meta HTML
*/ */
public abstract function getMetaHTML(); public abstract function getMetaHTML();
} }
/** /**
@ -1244,10 +1244,10 @@ abstract class lamListOption {
* @author Roland Gruber * @author Roland Gruber
*/ */
class lamBooleanListOption extends lamListOption { class lamBooleanListOption extends lamListOption {
/** option name */ /** option name */
private $name; private $name;
/** /**
* Creates a new boolean option. * Creates a new boolean option.
* *
@ -1259,7 +1259,7 @@ class lamBooleanListOption extends lamListOption {
parent::__construct($ID); parent::__construct($ID);
$this->name = $name; $this->name = $name;
} }
/** /**
* Returns if this option is selected. * Returns if this option is selected.
* *
@ -1268,10 +1268,10 @@ class lamBooleanListOption extends lamListOption {
public function isSelected() { public function isSelected() {
return ($this->getValue() === "1"); return ($this->getValue() === "1");
} }
/** /**
* Fills the config option from POST data. * Fills the config option from POST data.
* *
* @return array list of StatusMessages (array(<type>, <head line>, <body>)) * @return array list of StatusMessages (array(<type>, <head line>, <body>))
*/ */
public function fillFromPostData() { public function fillFromPostData() {
@ -1285,7 +1285,7 @@ class lamBooleanListOption extends lamListOption {
/** /**
* Returns the meta HTML data to display this option. * Returns the meta HTML data to display this option.
* *
* @return htmlTable meta HTML * @return htmlTable meta HTML
*/ */
public function getMetaHTML() { public function getMetaHTML() {
@ -1303,14 +1303,14 @@ class lamBooleanListOption extends lamListOption {
* @author Roland Gruber * @author Roland Gruber
*/ */
class lamSelectListOption extends lamListOption { class lamSelectListOption extends lamListOption {
/** option name */ /** option name */
private $name; private $name;
/** possible select options */ /** possible select options */
private $options; private $options;
/** help ID */ /** help ID */
private $helpID; private $helpID;
/** /**
* Creates a new selection list option. * Creates a new selection list option.
* *
@ -1324,7 +1324,7 @@ class lamSelectListOption extends lamListOption {
$this->name = $name; $this->name = $name;
$this->options = $options; $this->options = $options;
} }
/** /**
* Sets the help ID. * Sets the help ID.
* *
@ -1333,10 +1333,10 @@ class lamSelectListOption extends lamListOption {
public function setHelpID($id) { public function setHelpID($id) {
$this->helpID = $id; $this->helpID = $id;
} }
/** /**
* Fills the config option from POST data. * Fills the config option from POST data.
* *
* @return array list of StatusMessages (array(<type>, <head line>, <body>)) * @return array list of StatusMessages (array(<type>, <head line>, <body>))
*/ */
public function fillFromPostData() { public function fillFromPostData() {
@ -1350,7 +1350,7 @@ class lamSelectListOption extends lamListOption {
/** /**
* Returns the meta HTML data to display this option. * Returns the meta HTML data to display this option.
* *
* @return htmlTable meta HTML * @return htmlTable meta HTML
*/ */
public function getMetaHTML() { public function getMetaHTML() {
@ -1358,7 +1358,7 @@ class lamSelectListOption extends lamListOption {
$return->addElement(new htmlTableExtendedSelect($this->getID(), $this->options, array($this->getValue()), $this->name, $this->helpID)); $return->addElement(new htmlTableExtendedSelect($this->getID(), $this->options, array($this->getValue()), $this->name, $this->helpID));
return $return; return $return;
} }
} }
?> ?>