2004-05-31 20:10:36 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
$Id$
|
|
|
|
|
2009-10-27 18:47:12 +00:00
|
|
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
2010-01-01 17:21:46 +00:00
|
|
|
Copyright (C) 2003 - 2010 Roland Gruber
|
2004-05-31 20:10:36 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file includes functions to manage the list views.
|
|
|
|
*
|
|
|
|
* @package lists
|
|
|
|
* @author Roland Gruber
|
|
|
|
*/
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** Used to get type information. */
|
|
|
|
include_once("types.inc");
|
|
|
|
/** Used to get PDF information. */
|
|
|
|
include_once("pdfstruct.inc");
|
2006-01-03 22:02:03 +00:00
|
|
|
/** Used to create PDF files. */
|
|
|
|
include_once("pdf.inc");
|
2006-01-01 16:30:05 +00:00
|
|
|
|
|
|
|
|
2005-01-23 17:54:13 +00:00
|
|
|
/**
|
2006-01-01 16:30:05 +00:00
|
|
|
* Generates the list view.
|
|
|
|
*
|
|
|
|
* @package lists
|
|
|
|
* @author Roland Gruber
|
2006-09-23 11:19:36 +00:00
|
|
|
*
|
2006-01-01 16:30:05 +00:00
|
|
|
*/
|
|
|
|
class lamList {
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** Account type */
|
2007-11-11 14:01:16 +00:00
|
|
|
protected $type;
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** current page number */
|
2007-11-11 14:01:16 +00:00
|
|
|
protected $page = 1;
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** list of LDAP attributes */
|
2007-11-11 14:01:16 +00:00
|
|
|
protected $attrArray = array();
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** list of attribute descriptions */
|
2007-11-11 14:01:16 +00:00
|
|
|
protected $descArray = array();
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** maximum count of entries per page */
|
2007-12-09 10:45:04 +00:00
|
|
|
protected $maxPageEntries = 30;
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** sort column name */
|
2007-11-05 18:14:38 +00:00
|
|
|
protected $sortColumn;
|
|
|
|
|
|
|
|
/** sort direction: 1 for ascending, -1 for descending */
|
|
|
|
protected $sortDirection = 1;
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** LDAP suffix */
|
2007-11-11 14:01:16 +00:00
|
|
|
protected $suffix;
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** refresh page switch */
|
2007-11-11 14:01:16 +00:00
|
|
|
protected $refresh = true;
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** LDAP entries */
|
2007-11-11 14:01:16 +00:00
|
|
|
protected $entries;
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** filter string to include in URL */
|
2007-11-11 14:01:16 +00:00
|
|
|
protected $filterText;
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** list of possible LDAP suffixes(organizational units) */
|
2007-11-11 14:01:16 +00:00
|
|
|
protected $possibleSuffixes;
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/** list of account specific labels */
|
2007-11-11 14:01:16 +00:00
|
|
|
protected $labels;
|
|
|
|
|
|
|
|
/** configuration options */
|
|
|
|
private $configOptions;
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2007-12-09 10:45:04 +00:00
|
|
|
/** ID for list size config option */
|
|
|
|
const LIST_SIZE_OPTION_NAME = "L_SIZE";
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param string $type account type
|
|
|
|
* @return lamList list object
|
|
|
|
*/
|
2007-12-28 16:08:56 +00:00
|
|
|
public function __construct($type) {
|
2006-01-01 16:30:05 +00:00
|
|
|
$this->type = $type;
|
|
|
|
$this->labels = array(
|
|
|
|
'nav' => _("%s object(s) found"),
|
|
|
|
'error_noneFound' => _("No objects found!"),
|
|
|
|
'newEntry' => _("New object"),
|
2008-08-05 19:11:37 +00:00
|
|
|
'deleteEntry' => _("Delete object"));
|
2007-11-11 14:01:16 +00:00
|
|
|
$this->configOptions = $this->listGetAllConfigOptions();
|
|
|
|
$this->listReadOptionsFromCookie();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads the list options from the cookie value.
|
|
|
|
*/
|
|
|
|
private function listReadOptionsFromCookie() {
|
|
|
|
if (sizeof($this->configOptions) > 0) {
|
|
|
|
if (isset($_COOKIE["ListOptions_" . $this->type])) {
|
|
|
|
$cookieValue = $_COOKIE["ListOptions_" . $this->type];
|
|
|
|
$valueParts = explode(";", $cookieValue);
|
|
|
|
$values = array();
|
|
|
|
for ($i = 0; $i < sizeof($valueParts); $i++) {
|
|
|
|
$key_value = explode('=', $valueParts[$i]);
|
|
|
|
if (sizeof($key_value) == 2) {
|
|
|
|
$values[$key_value[0]] = $key_value[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for ($i = 0; $i < sizeof($this->configOptions); $i++) {
|
|
|
|
if (isset($values[$this->configOptions[$i]->getID()])) {
|
|
|
|
$this->configOptions[$i]->setValue($values[$this->configOptions[$i]->getID()]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// notify subclasses
|
|
|
|
$this->listConfigurationChanged();
|
|
|
|
}
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Prints the HTML code to display the list view.
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
public function showPage() {
|
|
|
|
if (isset($_GET['openConfig'])) {
|
|
|
|
$this->listPrintConfigurationPage();
|
|
|
|
return;
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
// do POST actions
|
|
|
|
$this->listDoPost();
|
|
|
|
// get some parameters
|
|
|
|
$this->listGetParams();
|
|
|
|
// print HTML head
|
|
|
|
$this->listPrintHeader();
|
|
|
|
// refresh data if needed
|
|
|
|
if ($this->refresh) $this->listRefreshData();
|
|
|
|
// filter entries
|
|
|
|
$filteredEntries = $this->listFilterAccounts();
|
|
|
|
// sort rows by sort column
|
|
|
|
if ($filteredEntries) {
|
|
|
|
$filteredEntries = $this->listSort($filteredEntries);
|
|
|
|
}
|
|
|
|
// show form
|
|
|
|
echo ("<form action=\"list.php?type=" . $this->type . "&norefresh=true\" method=\"post\">\n");
|
|
|
|
// draw account list if accounts were found
|
|
|
|
if (sizeof($filteredEntries) > 0) {
|
2007-02-11 18:06:42 +00:00
|
|
|
// buttons
|
|
|
|
$this->listPrintButtons(false);
|
2010-01-01 17:21:46 +00:00
|
|
|
echo ("<br>\n");
|
2006-01-01 16:30:05 +00:00
|
|
|
// navigation bar
|
|
|
|
$this->listDrawNavigationBar(sizeof($filteredEntries));
|
|
|
|
echo ("<br>\n");
|
|
|
|
// account table head
|
|
|
|
$this->listPrintTableHeader();
|
|
|
|
// account table body
|
|
|
|
$this->listPrintTableBody($filteredEntries);
|
2007-02-11 18:06:42 +00:00
|
|
|
echo ("<br>\n");
|
2006-01-01 16:30:05 +00:00
|
|
|
// navigation bar
|
|
|
|
$this->listDrawNavigationBar(sizeof($filteredEntries));
|
|
|
|
echo ("<br>\n");
|
2007-07-03 15:51:50 +00:00
|
|
|
// buttons
|
|
|
|
$this->listPrintButtons(false);
|
|
|
|
echo ("<br>\n");
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-02-11 18:06:42 +00:00
|
|
|
// buttons
|
|
|
|
$this->listPrintButtons(true);
|
2007-11-06 17:42:37 +00:00
|
|
|
echo ("<hr style=\"background-color: #999999;\">\n");
|
|
|
|
// navigation bar
|
|
|
|
$this->listDrawNavigationBar(sizeof($filteredEntries));
|
|
|
|
echo ("<br>\n");
|
2006-01-01 16:30:05 +00:00
|
|
|
// account table head
|
|
|
|
$this->listPrintTableHeader();
|
|
|
|
echo "</table><br>\n";
|
2005-01-23 17:54:13 +00:00
|
|
|
}
|
2007-11-11 14:01:16 +00:00
|
|
|
$this->listPrintFooter();
|
2005-01-23 17:54:13 +00:00
|
|
|
}
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Builds the regular expressions from the filter values.
|
|
|
|
*
|
|
|
|
* @return array filter data array($attribute => array('regex' => $reg, 'original' => $orig))
|
|
|
|
* $reg is the regular expression to use, $orig the user's unmodified input string
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listBuildFilter() {
|
2006-01-01 16:30:05 +00:00
|
|
|
$filter = array();
|
|
|
|
// build filter array
|
|
|
|
for ($i = 0; $i < sizeof($this->attrArray); $i++) {
|
2006-09-23 11:19:36 +00:00
|
|
|
$foundFilter = null;
|
|
|
|
if (isset($_GET["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])];
|
|
|
|
}
|
2009-11-01 11:11:12 +00:00
|
|
|
if (isset($foundFilter) && preg_match('/^([\p{L}\p{N} _\\*\\$\\.-])+$/iu', $foundFilter)) { // \p{L} matches any Unicode letter
|
2006-09-23 11:19:36 +00:00
|
|
|
$filter[$this->attrArray[$i]]['original'] = $foundFilter;
|
|
|
|
$filter[$this->attrArray[$i]]['regex'] = $foundFilter;
|
2006-01-01 16:30:05 +00:00
|
|
|
// replace special characters
|
2007-03-05 16:40:10 +00:00
|
|
|
$filter[$this->attrArray[$i]]['regex'] = str_replace('.', '\\.', $filter[$this->attrArray[$i]]['regex']);
|
2006-01-01 16:30:05 +00:00
|
|
|
$filter[$this->attrArray[$i]]['regex'] = str_replace("*", "(.)*", $filter[$this->attrArray[$i]]['regex']);
|
|
|
|
$filter[$this->attrArray[$i]]['regex'] = str_replace('$', '[$]', $filter[$this->attrArray[$i]]['regex']);
|
|
|
|
// add string begin and end
|
|
|
|
$filter[$this->attrArray[$i]]['regex'] = "^" . $filter[$this->attrArray[$i]]['regex'] . "$";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// save filter string
|
|
|
|
$filterAttributes = array_keys($filter);
|
|
|
|
$searchFilter = array();
|
|
|
|
for ($i = 0; $i < sizeof($filterAttributes); $i++) {
|
|
|
|
$searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original'];
|
|
|
|
}
|
|
|
|
if (sizeof($searchFilter) > 0) {
|
|
|
|
$searchFilter = "&" . implode("&", $searchFilter);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$searchFilter = "";
|
|
|
|
}
|
|
|
|
$this->filterText = $searchFilter;
|
|
|
|
return $filter;
|
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Removes all entries which do not fit to the filter.
|
|
|
|
*
|
|
|
|
* @return array filtered list of accounts
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listFilterAccounts() {
|
2007-02-17 16:26:08 +00:00
|
|
|
$entries = array();
|
2006-01-01 16:30:05 +00:00
|
|
|
$filter = $this->listBuildFilter();
|
|
|
|
$attributes = array_keys($filter);
|
2009-11-27 19:06:05 +00:00
|
|
|
$attributeCount = sizeof($attributes);
|
|
|
|
$entryCount = sizeof($this->entries);
|
|
|
|
for ($r = 0; $r < $entryCount; $r++) {
|
2007-02-17 16:26:08 +00:00
|
|
|
$skip = false;
|
2009-11-27 19:06:05 +00:00
|
|
|
for ($a = 0; $a < $attributeCount; $a++) {
|
2006-01-01 16:30:05 +00:00
|
|
|
// check if filter fits
|
|
|
|
$found = false;
|
2007-02-17 16:26:08 +00:00
|
|
|
for ($i = 0; $i < sizeof($this->entries[$r][$attributes[$a]]); $i++) {
|
2009-08-13 18:57:26 +00:00
|
|
|
if (preg_match('/' . $filter[$attributes[$a]]['regex'] . '/i', $this->entries[$r][$attributes[$a]][$i])) {
|
2006-01-01 16:30:05 +00:00
|
|
|
$found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$found) {
|
2007-02-17 16:26:08 +00:00
|
|
|
$skip = true;
|
2005-01-23 17:54:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-02-17 16:26:08 +00:00
|
|
|
if (!$skip) {
|
|
|
|
$entries[] = &$this->entries[$r];
|
|
|
|
}
|
2005-01-23 17:54:13 +00:00
|
|
|
}
|
2006-05-21 19:50:08 +00:00
|
|
|
if (sizeof($entries) == 0) StatusMessage("WARN", $this->labels['error_noneFound']);
|
2006-01-01 16:30:05 +00:00
|
|
|
return $entries;
|
2005-01-23 17:54:13 +00:00
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Sorts an account list by a given attribute
|
|
|
|
*
|
|
|
|
* @param array $info the account list
|
|
|
|
* @return array sorted account list
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listSort(&$info) {
|
2006-01-01 16:30:05 +00:00
|
|
|
if (!is_array($this->attrArray)) return $info;
|
|
|
|
if (!is_string($this->sortColumn)) return $info;
|
|
|
|
// sort and return account list
|
|
|
|
usort($info, array($this, "cmp_array"));
|
|
|
|
return $info;
|
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
|
|
|
|
2004-05-31 20:10:36 +00:00
|
|
|
/**
|
|
|
|
* Compare function used for usort-method
|
|
|
|
*
|
|
|
|
* Rows are sorted with the first attribute entry of the sort column.
|
|
|
|
* If objects have attributes with multiple values only the first is used for sorting.
|
|
|
|
*
|
|
|
|
* @param array $a first row which is compared
|
|
|
|
* @param array $b second row which is compared
|
|
|
|
* @return integer 0 if both are equal, 1 if $a is greater, -1 if $b is greater
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function cmp_array(&$a, &$b) {
|
2009-11-27 14:25:58 +00:00
|
|
|
if ($this->sortColumn != "dn") {
|
2004-05-31 20:10:36 +00:00
|
|
|
// sort by first attribute with name $sort
|
2009-11-27 14:25:58 +00:00
|
|
|
return @strnatcasecmp($a[$this->sortColumn][0], $b[$this->sortColumn][0]) * $this->sortDirection;
|
2004-05-31 20:10:36 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-11-27 14:25:58 +00:00
|
|
|
return strnatcasecmp($a[$this->sortColumn], $b[$this->sortColumn]) * $this->sortDirection;
|
2004-05-31 20:10:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Draws a navigation bar to switch between pages
|
|
|
|
*
|
|
|
|
* @param integer $count number of account entries
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listDrawNavigationBar($count) {
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
echo("<table class=\"" . $this->type . "nav\" width=\"100%\" border=\"0\">\n");
|
|
|
|
echo("<tr>\n");
|
|
|
|
echo("<td><input type=\"submit\" name=\"refresh\" value=\"" . _("Refresh") . "\"> ");
|
|
|
|
if ($this->page != 1) {
|
2007-11-01 15:09:34 +00:00
|
|
|
echo("<a href=\"list.php?type=" . $this->type . "&norefresh=true&page=" . ($this->page - 1) .
|
2007-11-05 18:14:38 +00:00
|
|
|
"&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $this->filterText . "\">" .
|
|
|
|
"<img style=\"vertical-align: middle;\" src=\"../../graphics/back.gif\" alt=\"back\"></a>\n");
|
2004-06-01 11:32:00 +00:00
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
if ($this->page < ($count / $this->maxPageEntries)) {
|
2007-11-01 15:09:34 +00:00
|
|
|
echo("<a href=\"list.php?type=" . $this->type . "&norefresh=true&page=" . ($this->page + 1) .
|
2007-11-05 18:14:38 +00:00
|
|
|
"&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $this->filterText . "\">" .
|
|
|
|
"<img style=\"vertical-align: middle;\" src=\"../../graphics/forward.gif\" alt=\"forward\"></a>\n");
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2007-11-01 15:09:34 +00:00
|
|
|
echo("</td>");
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
echo("<td class=\"" . $this->type . "nav-text\">");
|
|
|
|
echo" ";
|
|
|
|
printf($this->labels['nav'], $count);
|
|
|
|
echo("</td>");
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
echo("<td class=\"" . $this->type . "nav-activepage\" align=\"right\">");
|
|
|
|
for ($i = 0; $i < ($count / $this->maxPageEntries); $i++) {
|
|
|
|
if ($i == $this->page - 1) {
|
|
|
|
echo(" " . ($i + 1));
|
|
|
|
}
|
|
|
|
else {
|
2007-11-05 18:14:38 +00:00
|
|
|
echo(" <a href=\"list.php?type=" . $this->type . "&norefresh=true&page=" . ($i + 1) .
|
|
|
|
"&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $this->filterText . "\">" . ($i + 1) . "</a>\n");
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
echo("</td></tr></table>\n");
|
2004-06-11 11:01:56 +00:00
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Prints the attribute and filter row at the account table head
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listPrintTableHeader() {
|
2006-01-01 16:30:05 +00:00
|
|
|
// print table header
|
|
|
|
echo "<table rules=\"all\" class=\"" . $this->type . "list\" width=\"100%\">\n";
|
|
|
|
echo "<tr class=\"" . $this->type . "list-head\">\n<th width=22 height=34></th>\n<th></th>\n";
|
|
|
|
// table header
|
|
|
|
for ($k = 0; $k < sizeof($this->descArray); $k++) {
|
|
|
|
if (strtolower($this->attrArray[$k]) == $this->sortColumn) {
|
2007-11-05 18:14:38 +00:00
|
|
|
$sortImage = "sort_asc.png";
|
|
|
|
if ($this->sortDirection < 0) {
|
|
|
|
$sortImage = "sort_desc.png";
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
echo "<th class=\"" . $this->type . "list-sort\"><a href=\"list.php?type=" . $this->type . "&".
|
2007-11-05 18:14:38 +00:00
|
|
|
"sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&norefresh=y" . "\">" . $this->descArray[$k] .
|
|
|
|
" <img style=\"vertical-align: middle;\" src=\"../../graphics/$sortImage\" alt=\"sort direction\"></a></th>\n";
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
else echo "<th><a href=\"list.php?type=" . $this->type . "&".
|
|
|
|
"sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&norefresh=y" . "\">" . $this->descArray[$k] . "</a></th>\n";
|
2005-02-22 20:20:47 +00:00
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
echo "</tr>\n";
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
// print filter row
|
|
|
|
echo "<tr align=\"center\" class=\"" . $this->type . "list\">\n";
|
|
|
|
echo "<td width=22 height=34>";
|
2009-02-07 20:37:06 +00:00
|
|
|
printHelpLink(getHelp('', '250'), '250');
|
2006-01-01 16:30:05 +00:00
|
|
|
echo "</td>\n";
|
2004-06-11 11:01:56 +00:00
|
|
|
echo "<td>";
|
2006-01-01 16:30:05 +00:00
|
|
|
echo "<input type=\"submit\" name=\"apply_filter\" value=\"" . _("Filter") . "\">";
|
2004-06-11 11:01:56 +00:00
|
|
|
echo "</td>\n";
|
2006-01-01 16:30:05 +00:00
|
|
|
// print input boxes for filters
|
|
|
|
for ($k = 0; $k < sizeof ($this->descArray); $k++) {
|
|
|
|
$value = "";
|
2006-09-23 11:19:36 +00:00
|
|
|
if (isset($_GET["filter" . strtolower($this->attrArray[$k])])) {
|
|
|
|
$value = " value=\"" . $_GET["filter" . strtolower($this->attrArray[$k])] . "\"";
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
if (isset($_POST["filter" . strtolower($this->attrArray[$k])])) {
|
|
|
|
$value = " value=\"" . $_POST["filter" . strtolower($this->attrArray[$k])] . "\"";
|
|
|
|
}
|
|
|
|
echo "<td>";
|
2008-03-21 15:33:25 +00:00
|
|
|
echo ("<input type=\"text\" size=15 name=\"filter" . strtolower ($this->attrArray[$k]) ."\"" . $value . " onkeypress=\"SubmitForm('apply_filter', event)\">");
|
2006-01-01 16:30:05 +00:00
|
|
|
echo "</td>\n";
|
|
|
|
}
|
|
|
|
echo "</tr>\n";
|
2004-06-11 11:01:56 +00:00
|
|
|
}
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Prints the entry list
|
2006-09-23 11:19:36 +00:00
|
|
|
*
|
2006-01-01 16:30:05 +00:00
|
|
|
* @param array $info entries
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listPrintTableBody(&$info) {
|
2006-01-01 16:30:05 +00:00
|
|
|
// calculate which rows to show
|
|
|
|
$table_begin = ($this->page - 1) * $this->maxPageEntries;
|
|
|
|
if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info);
|
|
|
|
else $table_end = ($this->page * $this->maxPageEntries);
|
|
|
|
// print account list
|
|
|
|
for ($i = $table_begin; $i < $table_end; $i++) {
|
2009-12-06 18:34:24 +00:00
|
|
|
$rowID = base64_encode($info[$i]['dn']);
|
|
|
|
echo("<tr class=\"" . $this->type . "list\" onMouseOver=\"list_over(this, '" . $rowID . "', '" . $this->type . "')\"\n" .
|
|
|
|
" onMouseOut=\"list_out(this, '" . $rowID . "', '" . $this->type . "')\"\n" .
|
|
|
|
" onClick=\"list_click(this, '" . $rowID . "', '" . $this->type . "')\"\n" .
|
2010-01-01 17:21:46 +00:00
|
|
|
" onDblClick=\"parent.location.href='../account/edit.php?type=" . $this->type . "&DN=" . $info[$i]['dn'] . "'\">\n");
|
2006-01-01 16:30:05 +00:00
|
|
|
if (isset($_GET['selectall'])) {
|
2009-12-06 18:34:24 +00:00
|
|
|
echo " <td align=\"center\"><input onClick=\"list_click(this, '" . $rowID . "', '" . $this->type . "')\"" .
|
|
|
|
" type=\"checkbox\" checked name=\"" . $rowID . "\"></td>\n";
|
2005-01-27 22:14:01 +00:00
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
else {
|
2009-12-06 18:34:24 +00:00
|
|
|
echo " <td align=\"center\"><input onClick=\"list_click(this, '" . $rowID . "', '" . $this->type . "')\"" .
|
|
|
|
" type=\"checkbox\" name=\"" . $rowID . "\"></td>\n";
|
2005-01-27 21:07:48 +00:00
|
|
|
}
|
2009-12-06 18:34:24 +00:00
|
|
|
echo " <td align='center' style=\"white-space: nowrap;\">";
|
|
|
|
$this->listPrintToolLinks($info[$i], $rowID);
|
|
|
|
echo "</td>\n";
|
2006-01-01 16:30:05 +00:00
|
|
|
for ($k = 0; $k < sizeof($this->attrArray); $k++) {
|
|
|
|
echo ("<td>");
|
|
|
|
$attrName = strtolower($this->attrArray[$k]);
|
2007-02-17 16:26:08 +00:00
|
|
|
$this->listPrintTableCellContent($info[$i], $attrName);
|
2006-01-01 16:30:05 +00:00
|
|
|
echo ("</td>\n");
|
2005-01-27 21:07:48 +00:00
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
echo("</tr>\n");
|
|
|
|
}
|
|
|
|
// display select all link
|
|
|
|
$colspan = sizeof($this->attrArray) + 1;
|
|
|
|
echo "<tr class=\"" . $this->type . "list\">\n";
|
|
|
|
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
|
2006-09-23 11:19:36 +00:00
|
|
|
echo "<td colspan=$colspan> <a href=\"list.php?type=" . $this->type . "&norefresh=y&page=" . $this->page .
|
2006-01-01 16:30:05 +00:00
|
|
|
"&sort=" . $this->sortColumn . $this->filterText . "&selectall=yes\">" .
|
|
|
|
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
|
|
|
|
echo "</tr>\n";
|
|
|
|
echo ("</table>");
|
|
|
|
}
|
2007-02-17 16:26:08 +00:00
|
|
|
|
2007-04-21 11:04:50 +00:00
|
|
|
/**
|
|
|
|
* Prints the tool image links (e.g. edit and delete) for each account.
|
|
|
|
*
|
2007-11-25 12:52:18 +00:00
|
|
|
* @param array $account LDAP attributes
|
|
|
|
* @param String $id account ID
|
2007-04-21 11:04:50 +00:00
|
|
|
*/
|
2007-11-25 12:52:18 +00:00
|
|
|
private function listPrintToolLinks($account, $id) {
|
2007-04-21 11:04:50 +00:00
|
|
|
// edit image
|
|
|
|
echo "<a href=\"../account/edit.php?type=" . $this->type . "&DN='" . $account['dn'] . "'\">";
|
|
|
|
echo "<img src=\"../../graphics/edit.png\" alt=\"" . _("Edit") . "\" title=\"" . _("Edit") . "\">";
|
2007-11-25 12:52:18 +00:00
|
|
|
echo "</a>\n ";
|
2007-04-21 11:04:50 +00:00
|
|
|
// delete image
|
2007-12-30 16:08:54 +00:00
|
|
|
if (checkIfWriteAccessIsAllowed()) {
|
|
|
|
echo "<a href=\"deletelink.php?type=" . $this->type . "&DN='" . $account['dn'] . "'\">";
|
|
|
|
echo "<img src=\"../../graphics/delete.png\" alt=\"" . _("Delete") . "\" title=\"" . _("Delete") . "\">";
|
|
|
|
echo "</a>\n ";
|
|
|
|
}
|
2007-11-25 12:52:18 +00:00
|
|
|
// pdf image
|
2008-01-02 20:20:53 +00:00
|
|
|
echo "<input type=\"image\" style=\"background:transparent;\" name=\"createPDF_" . $id . "\" src=\"../../graphics/pdf.png\" title=\"" . _('Create PDF file') . "\">\n ";
|
2007-11-05 18:14:38 +00:00
|
|
|
// additional tools
|
|
|
|
$tools = $this->getAdditionalTools();
|
|
|
|
for ($i = 0; $i < sizeof($tools); $i++) {
|
|
|
|
echo "<a href=\"" . $tools[$i]->getLinkTarget() . "?type=" . $this->type . "&DN='" . $account['dn'] . "'\">";
|
|
|
|
echo "<img src=\"../../graphics/" . $tools[$i]->getImage() . "\" alt=\"" . $tools[$i]->getName() . "\" title=\"" . $tools[$i]->getName() . "\">";
|
2007-11-25 12:52:18 +00:00
|
|
|
echo "</a>\n ";
|
2007-11-05 18:14:38 +00:00
|
|
|
}
|
2007-04-21 11:04:50 +00:00
|
|
|
}
|
|
|
|
|
2007-02-17 16:26:08 +00:00
|
|
|
/**
|
|
|
|
* Prints the content of a cell in the account list for a given LDAP entry and attribute.
|
|
|
|
*
|
|
|
|
* @param array $entry LDAP attributes
|
|
|
|
* @param string $attribute attribute name
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listPrintTableCellContent(&$entry, &$attribute) {
|
2007-02-17 16:26:08 +00:00
|
|
|
// print all attribute entries seperated by "; "
|
|
|
|
if (isset($entry[$attribute]) && sizeof($entry[$attribute]) > 0) {
|
|
|
|
if (is_array($entry[$attribute])) {
|
|
|
|
// sort array
|
|
|
|
sort($entry[$attribute]);
|
2007-03-21 13:36:09 +00:00
|
|
|
echo htmlspecialchars(implode("; ", $entry[$attribute]), ENT_QUOTES, "UTF-8");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo htmlspecialchars($entry[$attribute], ENT_QUOTES, "UTF-8");
|
2007-02-17 16:26:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Manages all POST actions (e.g. button pressed) for the account lists.
|
|
|
|
*/
|
2008-01-14 18:10:13 +00:00
|
|
|
protected function listDoPost() {
|
2006-01-01 16:30:05 +00:00
|
|
|
// check if button was pressed and if we have to add/delete an account
|
2007-11-25 12:52:18 +00:00
|
|
|
if (isset($_POST['new']) || isset($_POST['del'])){
|
2007-12-30 16:08:54 +00:00
|
|
|
if (!checkIfWriteAccessIsAllowed()) {
|
|
|
|
die();
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
// add new account
|
|
|
|
if (isset($_POST['new'])){
|
2007-11-06 17:42:37 +00:00
|
|
|
metaRefresh("../account/edit.php?type=" . $this->type . "&suffix=" . $this->suffix);
|
2005-01-27 21:07:48 +00:00
|
|
|
exit;
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
// delete account(s)
|
|
|
|
elseif (isset($_POST['del'])){
|
|
|
|
// search for checkboxes
|
|
|
|
$accounts = array_keys($_POST, "on");
|
2006-06-29 19:38:38 +00:00
|
|
|
// build DN list
|
2006-01-01 16:30:05 +00:00
|
|
|
$_SESSION['delete_dn'] = array();
|
|
|
|
for ($i = 0; $i < sizeof($accounts); $i++) {
|
2010-01-04 20:15:25 +00:00
|
|
|
$_SESSION['delete_dn'][] = base64_decode($accounts[$i]);
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
if (sizeof($accounts) > 0) {
|
|
|
|
metaRefresh("../delete.php?type=" . $this->type);
|
|
|
|
exit;
|
|
|
|
}
|
2005-01-27 21:07:48 +00:00
|
|
|
}
|
2007-11-25 12:52:18 +00:00
|
|
|
}
|
|
|
|
// PDF button
|
|
|
|
foreach ($_POST as $key => $value) {
|
|
|
|
if (strpos($key, 'createPDF_') > -1) {
|
|
|
|
$parts = explode("_", $key);
|
|
|
|
if (sizeof($parts) == 3) {
|
|
|
|
$this->showPDFPage($parts[1]);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// PDF creation Ok
|
|
|
|
if (isset($_POST['createPDFok'])) {
|
|
|
|
$pdfStruct = $_POST['pdf_structure'];
|
|
|
|
$option = $_POST['createFor'];
|
|
|
|
// create for clicked account
|
|
|
|
if ($option == 'DN') {
|
|
|
|
$_SESSION["accountPDF"] = new accountContainer($this->type, "accountPDF");
|
2009-12-06 18:34:24 +00:00
|
|
|
$_SESSION["accountPDF"]->load_account(base64_decode($_POST['clickedAccount']));
|
2007-11-25 12:52:18 +00:00
|
|
|
createModulePDF(array($_SESSION["accountPDF"]),$pdfStruct);
|
|
|
|
unset($_SESSION["accountPDF"]);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
// create for all selected accounts
|
|
|
|
elseif ($option == 'SELECTED') {
|
2006-01-01 16:30:05 +00:00
|
|
|
// search for checkboxes
|
|
|
|
$accounts = array_keys($_POST, "on");
|
|
|
|
$list = array();
|
|
|
|
// load accounts from LDAP
|
|
|
|
for ($i = 0; $i < sizeof($accounts); $i++) {
|
|
|
|
$_SESSION["accountPDF-$i"] = new accountContainer($this->type, "accountPDF-$i");
|
2009-12-06 18:34:24 +00:00
|
|
|
$_SESSION["accountPDF-$i"]->load_account(base64_decode($accounts[$i]));
|
2006-01-01 16:30:05 +00:00
|
|
|
$list[$i] = $_SESSION["accountPDF-$i"];
|
|
|
|
}
|
|
|
|
if (sizeof($list) > 0) {
|
2007-11-25 12:52:18 +00:00
|
|
|
createModulePDF($list,$pdfStruct);
|
|
|
|
for ($i = 0; $i < sizeof($accounts); $i++) {
|
|
|
|
unset($_SESSION["accountPDF-$i"]);
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
2007-11-25 12:52:18 +00:00
|
|
|
// create for all accounts
|
|
|
|
elseif ($option == 'ALL') {
|
2006-01-01 16:30:05 +00:00
|
|
|
$list = array();
|
2006-01-03 22:02:03 +00:00
|
|
|
for ($i = 0; $i < sizeof($this->entries); $i++) {
|
2006-01-01 16:30:05 +00:00
|
|
|
$_SESSION["accountPDF-$i"] = new accountContainer($this->type, "accountPDF-$i");
|
2006-01-03 22:02:03 +00:00
|
|
|
$_SESSION["accountPDF-$i"]->load_account($this->entries[$i]['dn']);
|
2006-01-01 16:30:05 +00:00
|
|
|
$list[$i] = $_SESSION["accountPDF-$i"];
|
|
|
|
}
|
|
|
|
if (sizeof($list) > 0) {
|
2007-11-25 12:52:18 +00:00
|
|
|
createModulePDF($list,$pdfStruct);
|
|
|
|
for ($i = 0; $i < sizeof($this->entries); $i++) {
|
|
|
|
// clean session
|
|
|
|
unset($_SESSION["accountPDF-$i"]);
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
exit;
|
|
|
|
}
|
2005-01-27 21:07:48 +00:00
|
|
|
}
|
|
|
|
}
|
2007-11-11 14:01:16 +00:00
|
|
|
// check if back from configuration page
|
|
|
|
if (sizeof($this->configOptions) > 0) {
|
|
|
|
if (isset($_POST['saveConfigOptions'])) {
|
|
|
|
$cookieValue = '';
|
|
|
|
for ($i = 0; $i < sizeof($this->configOptions); $i++) {
|
|
|
|
$this->configOptions[$i]->fillFromPostData();
|
|
|
|
$cookieValue .= $this->configOptions[$i]->getID() . "=" . $this->configOptions[$i]->getValue() . ';';
|
|
|
|
}
|
|
|
|
// save options as cookie for one year
|
|
|
|
setcookie("ListOptions_" . $this->type, $cookieValue, time()+60*60*24*365, "/");
|
|
|
|
// notify subclasses
|
|
|
|
$this->listConfigurationChanged();
|
|
|
|
}
|
|
|
|
}
|
2005-01-27 21:07:48 +00:00
|
|
|
}
|
2007-11-25 12:52:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the page where the user may select the PDF options.
|
|
|
|
*
|
|
|
|
* @param String $id account ID
|
|
|
|
*/
|
|
|
|
private function showPDFPage($id) {
|
|
|
|
// search for checkboxes
|
|
|
|
$selAccounts = array_keys($_POST, "on");
|
2007-12-03 09:18:20 +00:00
|
|
|
if (!in_array($id, $selAccounts)) {
|
|
|
|
$selAccounts[] = $id;
|
|
|
|
}
|
2007-11-25 12:52:18 +00:00
|
|
|
|
|
|
|
$this->listPrintHeader();
|
|
|
|
|
2009-12-06 18:34:24 +00:00
|
|
|
echo "<br>\n";
|
2010-01-04 20:50:39 +00:00
|
|
|
echo "<form target=\"_blank\" action=\"list.php?type=" . $this->type . "&norefresh=true\" method=\"post\">\n";
|
2007-11-25 12:52:18 +00:00
|
|
|
|
2009-12-06 18:34:24 +00:00
|
|
|
echo '<fieldset class="' . $this->type . 'edit"><legend>' . _('Create PDF file') . '</legend><br>';
|
2007-11-25 12:52:18 +00:00
|
|
|
echo '<table class="' . $this->type . 'edit">';
|
|
|
|
echo '<tr>';
|
|
|
|
echo '<td>';
|
|
|
|
echo _('PDF structure') . " ";
|
|
|
|
echo '</td>';
|
|
|
|
echo '<td>';
|
|
|
|
echo "<select name=\"pdf_structure\">\n";
|
|
|
|
$pdf_structures = getPDFStructureDefinitions($this->type);
|
|
|
|
foreach($pdf_structures as $pdf_structure) {
|
|
|
|
echo "<option " . (($pdf_structure == 'default') ? " selected" : "") . ">" . $pdf_structure . "</option>";
|
|
|
|
}
|
|
|
|
echo "</select>\n";
|
|
|
|
echo '</td>';
|
|
|
|
echo '</tr>';
|
|
|
|
echo '<tr>';
|
|
|
|
echo '<td>';
|
|
|
|
echo _('Create for') . " ";
|
|
|
|
echo '</td>';
|
|
|
|
echo '<td>';
|
|
|
|
echo '<select name="createFor">';
|
2009-12-06 18:34:24 +00:00
|
|
|
echo '<option value="DN">' . base64_decode($id) . '</option>';
|
2007-11-25 12:52:18 +00:00
|
|
|
echo '<option value="SELECTED">' . sprintf(_('All selected accounts (%s)'), sizeof($selAccounts)) . '</option>';
|
2007-12-03 09:18:20 +00:00
|
|
|
echo '<option value="ALL">' . sprintf(_('All accounts (%s)'), sizeof($this->entries)) . '</option>';
|
2007-11-25 12:52:18 +00:00
|
|
|
echo '</select>';
|
|
|
|
echo '</td>';
|
|
|
|
echo '</tr>';
|
|
|
|
echo '<tr>';
|
|
|
|
echo '<td colspan=2> </td>';
|
|
|
|
echo '</tr>';
|
|
|
|
echo '<tr>';
|
|
|
|
echo '<td colspan=2>';
|
|
|
|
echo '<input type="submit" name="createPDFok" value="' . _('Ok') . '"> ';
|
|
|
|
echo '<input type="submit" name="createPDFcancel" value="' . _('Cancel') . '">';
|
|
|
|
echo '</td>';
|
|
|
|
echo '</tr>';
|
|
|
|
echo '</table>';
|
|
|
|
echo '</fieldset>';
|
|
|
|
|
|
|
|
// hiden inputs for selected accounts
|
|
|
|
for ($i = 0; $i < sizeof($selAccounts); $i++) {
|
|
|
|
echo '<input type="hidden" name="' . $selAccounts[$i] . '" value="on">';
|
|
|
|
}
|
|
|
|
echo '<input type="hidden" name="clickedAccount" value="' . $id . '">';
|
|
|
|
|
|
|
|
$this->listPrintFooter();
|
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Prints a combobox with possible sub-DNs.
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listShowOUSelection() {
|
2006-01-01 16:30:05 +00:00
|
|
|
if (sizeof($this->possibleSuffixes) > 1) {
|
|
|
|
echo ("<b>" . _("Suffix") . ": </b>");
|
2007-11-25 12:52:18 +00:00
|
|
|
echo ("<select class=\"" . $this->type . "\" size=1 name=\"suffix\" onchange=\"listOUchanged('" . $this->type . "')\">\n");
|
2006-01-01 16:30:05 +00:00
|
|
|
for ($i = 0; $i < sizeof($this->possibleSuffixes); $i++) {
|
|
|
|
if ($this->suffix == $this->possibleSuffixes[$i]) {
|
|
|
|
echo ("<option selected>" . $this->possibleSuffixes[$i] . "</option>\n");
|
|
|
|
}
|
|
|
|
else echo("<option>" . $this->possibleSuffixes[$i] . "</option>\n");
|
|
|
|
}
|
|
|
|
echo ("</select>\n");
|
2007-02-11 14:23:44 +00:00
|
|
|
echo ("<input class=\"" . $this->type . "\" type=\"submit\" name=\"refresh\" value=\"" . _("Change suffix") . "\">");
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2005-04-14 17:42:15 +00:00
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
2007-11-25 12:52:18 +00:00
|
|
|
* Prints the create and delete buttons.
|
2006-01-01 16:30:05 +00:00
|
|
|
*
|
|
|
|
* @param boolean $createOnly true if only the create button should be displayed
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listPrintButtons($createOnly) {
|
2007-02-11 18:06:42 +00:00
|
|
|
echo "<table border=0 width=\"100%\">\n";
|
|
|
|
echo "<tr>\n";
|
|
|
|
echo "<td align=\"left\">\n";
|
2007-12-30 16:08:54 +00:00
|
|
|
if (checkIfWriteAccessIsAllowed()) {
|
|
|
|
// add/delete buttons
|
|
|
|
echo ("<input class=\"" . $this->type . "\" type=\"submit\" name=\"new\" value=\"" . $this->labels['newEntry'] . "\">\n");
|
|
|
|
if (!$createOnly) {
|
|
|
|
echo ("<input class=\"" . $this->type . "\" type=\"submit\" name=\"del\" value=\"" . $this->labels['deleteEntry'] . "\">\n");
|
|
|
|
}
|
|
|
|
echo " ";
|
2005-02-26 14:32:52 +00:00
|
|
|
}
|
2007-11-11 14:01:16 +00:00
|
|
|
$this->listShowOUSelection();
|
2007-02-11 18:06:42 +00:00
|
|
|
echo "</td>\n";
|
|
|
|
echo "<td align=\"right\">\n";
|
2007-11-11 14:01:16 +00:00
|
|
|
echo '<a href="list.php?type=' . $this->type . '&openConfig=1">';
|
|
|
|
echo '<img src="../../graphics/tools.png" alt="' . _('Change settings') . '" title="' . _('Change settings') . '">';
|
|
|
|
echo ' ' . _('Change settings');
|
|
|
|
echo '</a>';
|
2007-02-11 18:06:42 +00:00
|
|
|
echo "</td>\n";
|
|
|
|
echo "</tr>\n";
|
|
|
|
echo "</table>\n";
|
|
|
|
}
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
2007-11-11 14:01:16 +00:00
|
|
|
* Prints the HTML header.
|
2006-01-01 16:30:05 +00:00
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listPrintHeader() {
|
2010-01-01 17:21:46 +00:00
|
|
|
include '../main_header.php';
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2007-11-11 14:01:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints the HTML footer.
|
|
|
|
*/
|
|
|
|
protected function listPrintFooter() {
|
|
|
|
echo ("</form>\n");
|
|
|
|
echo "</body></html>\n";
|
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Returns an hash array containing with all attributes to be shown and their descriptions.
|
|
|
|
* Format: array(attribute => description)
|
|
|
|
*
|
|
|
|
* @return array attribute list
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
private function listGetAttributeDescriptionList() {
|
2006-01-01 16:30:05 +00:00
|
|
|
$ret = array();
|
|
|
|
$attr_string = $_SESSION["config"]->get_listAttributes($this->type);
|
|
|
|
$temp_array = explode(";", $attr_string);
|
|
|
|
$hash_table = getListAttributeDescriptions($this->type);
|
|
|
|
// generate column attributes and descriptions
|
|
|
|
for ($i = 0; $i < sizeof($temp_array); $i++) {
|
|
|
|
// if value is predifined, look up description in hash_table
|
|
|
|
if (substr($temp_array[$i],0,1) == "#") {
|
|
|
|
$attr = strtolower(substr($temp_array[$i],1));
|
|
|
|
if (isset($hash_table[$attr])) {
|
|
|
|
$ret[$attr] = $hash_table[$attr];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$ret[$attr] = $attr;
|
|
|
|
}
|
2005-04-14 17:42:15 +00:00
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
// if not predefined, the attribute is seperated by a ":" from description
|
2005-04-14 17:42:15 +00:00
|
|
|
else {
|
2006-01-01 16:30:05 +00:00
|
|
|
$attr = explode(":", $temp_array[$i]);
|
|
|
|
if (isset($attr[1])) {
|
|
|
|
$ret[$attr[0]] = $attr[1];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$ret[$attr[0]] = $attr[0];
|
|
|
|
}
|
2005-04-14 17:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
return $ret;
|
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Sets some internal parameters.
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listGetParams() {
|
2010-01-04 20:50:39 +00:00
|
|
|
// check if only PDF should be shown
|
|
|
|
if (isset($_GET['printPDF'])) {
|
|
|
|
$this->showPDFPage($_GET['dn']);
|
|
|
|
exit();
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
// get current page
|
|
|
|
if (isset($_GET["page"])) $this->page = $_GET["page"];
|
|
|
|
else $this->page = 1;
|
|
|
|
// generate attribute-description table
|
|
|
|
$temp_array = $this->listGetAttributeDescriptionList();
|
|
|
|
$this->attrArray = array_keys($temp_array); // list of LDAP attributes to show
|
|
|
|
$this->descArray = array_values($temp_array); // list of descriptions for the attributes
|
|
|
|
// get sorting column
|
2007-11-05 18:14:38 +00:00
|
|
|
if (isset($_GET["sort"])) {
|
|
|
|
if ($_GET["sort"] == $this->sortColumn) {
|
|
|
|
$this->sortDirection = -$this->sortDirection;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->sortColumn = $_GET["sort"];
|
|
|
|
$this->sortDirection = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->sortColumn = strtolower($this->attrArray[0]);
|
|
|
|
$this->sortDirection = 1;
|
|
|
|
}
|
|
|
|
// get sort order
|
|
|
|
if (isset($_GET['sortdirection'])) {
|
|
|
|
$this->sortDirection = $_GET['sortdirection'];
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
// check search suffix
|
2006-01-24 14:23:42 +00:00
|
|
|
if (isset($_POST['suffix'])) $this->suffix = $_POST['suffix']; // new suffix selected via combobox
|
2007-05-13 14:08:10 +00:00
|
|
|
elseif (isset($_GET['suffix'])) $this->suffix = $_GET['suffix']; // new suffix selected via combobox
|
2006-01-01 16:30:05 +00:00
|
|
|
elseif (!$this->suffix) $this->suffix = $_SESSION["config"]->get_Suffix($this->type); // default suffix
|
|
|
|
// check if LDAP data should be refreshed
|
|
|
|
$this->refresh = true;
|
|
|
|
if (isset($_GET['norefresh'])) $this->refresh = false;
|
|
|
|
if (isset($_POST['refresh'])) $this->refresh = true;
|
|
|
|
}
|
2006-09-23 11:19:36 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Rereads the entries from LDAP.
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listRefreshData() {
|
2006-01-01 16:30:05 +00:00
|
|
|
// configure search filter
|
|
|
|
$module_filter = get_ldap_filter($this->type); // basic filter is provided by modules
|
|
|
|
$filter = "(&" . $module_filter . ")";
|
|
|
|
$attrs = $this->attrArray;
|
2009-10-28 16:36:24 +00:00
|
|
|
$sr = @ldap_search($_SESSION["ldap"]->server(), escapeDN($this->suffix), $filter, $attrs, 0, 0, 0, LDAP_DEREF_NEVER);
|
2006-01-01 16:30:05 +00:00
|
|
|
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
|
2009-11-24 15:28:08 +00:00
|
|
|
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See the manual for instructions to solve this problem."));
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
if ($sr) {
|
2007-07-08 10:51:01 +00:00
|
|
|
$info = ldap_get_entries($_SESSION["ldap"]->server(), $sr);
|
2009-12-19 16:28:16 +00:00
|
|
|
$info = cleanLDAPResult($info);
|
2006-01-01 16:30:05 +00:00
|
|
|
ldap_free_result($sr);
|
|
|
|
// save results
|
|
|
|
$this->entries = $info;
|
|
|
|
}
|
2005-04-14 17:42:15 +00:00
|
|
|
else {
|
2006-01-01 16:30:05 +00:00
|
|
|
$this->entries = array();
|
2008-09-30 16:15:14 +00:00
|
|
|
StatusMessage("ERROR", _("LDAP search failed! Please check your preferences."));
|
2005-04-14 17:42:15 +00:00
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
// generate list of possible suffixes
|
|
|
|
$this->possibleSuffixes = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($this->type));
|
2005-04-14 17:42:15 +00:00
|
|
|
}
|
2007-02-11 18:06:42 +00:00
|
|
|
|
|
|
|
/**
|
2007-11-11 14:01:16 +00:00
|
|
|
* Returns a list of lamListTool objects to display next to the edit/delete buttons.
|
|
|
|
*
|
|
|
|
* @return lamListTool[] tools
|
2007-02-11 18:06:42 +00:00
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function getAdditionalTools() {
|
|
|
|
return array();
|
2007-02-11 18:06:42 +00:00
|
|
|
}
|
2007-11-05 18:14:38 +00:00
|
|
|
|
|
|
|
/**
|
2007-11-11 14:01:16 +00:00
|
|
|
* Returns a list of possible configuration options.
|
2007-11-05 18:14:38 +00:00
|
|
|
*
|
2007-11-11 14:01:16 +00:00
|
|
|
* @return array list of lamListOption objects
|
2007-11-05 18:14:38 +00:00
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listGetAllConfigOptions() {
|
2007-12-09 10:45:04 +00:00
|
|
|
$listSizeOption = new lamSelectListOption(_("Maximum list entries"), array(10, 20, 30, 50, 75, 100), self::LIST_SIZE_OPTION_NAME);
|
|
|
|
return array($listSizeOption);
|
2007-11-05 18:14:38 +00:00
|
|
|
}
|
|
|
|
|
2007-11-11 14:01:16 +00:00
|
|
|
/**
|
|
|
|
* Prints the list configuration page.
|
|
|
|
*/
|
|
|
|
protected function listPrintConfigurationPage() {
|
|
|
|
$this->listPrintHeader();
|
|
|
|
|
|
|
|
echo '<h1 align="center">' . _('Change list settings') . "</h1>\n";
|
|
|
|
|
|
|
|
echo "<form action=\"list.php?type=" . $this->type . "&norefresh=true\" method=\"post\">\n";
|
2008-01-03 19:33:56 +00:00
|
|
|
echo '<fieldset class="' . $this->type . 'edit"><br>';
|
2007-11-25 12:52:18 +00:00
|
|
|
echo "<table class=\"" . $this->type . "edit\" width=\"100%\">\n";
|
2007-11-11 14:01:16 +00:00
|
|
|
echo "<tr class=\"" . $this->type . "list\"><td>\n";
|
|
|
|
|
|
|
|
$tabindex = 0;
|
|
|
|
for ($i = 0; $i < sizeof($this->configOptions); $i++) {
|
2009-02-07 19:25:22 +00:00
|
|
|
parseHtml('', $this->configOptions[$i]->getMetaHTML(), array(), true, $tabindex, $this->type);
|
2007-11-11 14:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo "<br>";
|
|
|
|
echo "<input type=\"submit\" name=\"saveConfigOptions\" value=\"" . _('Ok') . "\">\n";
|
|
|
|
echo "<input type=\"submit\" name=\"cancelConfigOptions\" value=\"" . _('Cancel') . "\">\n";
|
|
|
|
echo "</td></tr></table>\n";
|
2007-11-25 12:52:18 +00:00
|
|
|
echo "</fieldset>\n";
|
2007-11-11 14:01:16 +00:00
|
|
|
|
|
|
|
$this->listPrintFooter();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the configuration option with the given ID.
|
|
|
|
*
|
|
|
|
* @param String $ID ID
|
|
|
|
*/
|
|
|
|
protected function listGetConfigOptionByID($ID) {
|
|
|
|
for ($i = 0; $i < sizeof($this->configOptions); $i++) {
|
|
|
|
if ($this->configOptions[$i]->getID() === $ID) {
|
|
|
|
return $this->configOptions[$i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the configuration options changed.
|
|
|
|
*/
|
|
|
|
protected function listConfigurationChanged() {
|
2007-12-09 10:45:04 +00:00
|
|
|
$sizeOption = $this->listGetConfigOptionByID(self::LIST_SIZE_OPTION_NAME);
|
|
|
|
if ($sizeOption->getValue() != null) {
|
|
|
|
$this->maxPageEntries = $sizeOption->getValue();
|
|
|
|
}
|
2007-11-11 14:01:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-05 18:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a tool which can be included in the account lists.
|
|
|
|
*
|
|
|
|
* @package lists
|
|
|
|
* @author Roland Gruber
|
|
|
|
*/
|
|
|
|
class lamListTool {
|
|
|
|
|
|
|
|
private $name;
|
|
|
|
private $image;
|
|
|
|
private $target;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param String $name tool name
|
|
|
|
* @param String $image image file
|
|
|
|
* @param String $target target page
|
|
|
|
* @return lamListTool tool object
|
|
|
|
*/
|
2007-12-28 16:08:56 +00:00
|
|
|
public function __construct($name, $image, $target) {
|
2007-11-05 18:14:38 +00:00
|
|
|
$this->name = $name;
|
|
|
|
$this->image = $image;
|
|
|
|
$this->target = $target;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name of the tool image.
|
|
|
|
* The image is returned without path (e.g. mytool.png). All images must reside in the graphics folder.
|
|
|
|
*
|
|
|
|
* @return String image name
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
public function getImage() {
|
2007-11-05 18:14:38 +00:00
|
|
|
return $this->image;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the tool name.
|
|
|
|
* This is used for the tool tip.
|
|
|
|
*
|
|
|
|
* @return String name
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
public function getName() {
|
2007-11-05 18:14:38 +00:00
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
*
|
|
|
|
* @return String page file (e.g. 'mytool.php')
|
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
public function getLinkTarget() {
|
2007-11-05 18:14:38 +00:00
|
|
|
return $this->target;
|
|
|
|
}
|
2005-04-14 17:42:15 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2005-04-14 17:42:15 +00:00
|
|
|
|
2007-11-11 14:01:16 +00:00
|
|
|
/**
|
|
|
|
* Represents a list configuration option.
|
|
|
|
*
|
|
|
|
* @package lists
|
|
|
|
* @author Roland Gruber
|
|
|
|
*/
|
|
|
|
abstract class lamListOption {
|
|
|
|
|
|
|
|
private $ID;
|
|
|
|
|
|
|
|
private $value;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new config option.
|
|
|
|
*
|
2007-12-09 10:45:04 +00:00
|
|
|
* @param String $ID unique ID
|
2007-11-11 14:01:16 +00:00
|
|
|
* @return lamConfigOption config option
|
|
|
|
*/
|
2007-12-28 16:08:56 +00:00
|
|
|
public function __construct($ID) {
|
2007-11-11 14:01:16 +00:00
|
|
|
$this->ID = $ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the option ID.
|
|
|
|
*
|
|
|
|
* @return String ID
|
|
|
|
*/
|
|
|
|
public function getID() {
|
|
|
|
return $this->ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fills the config option from POST data.
|
|
|
|
*
|
|
|
|
* @return array list of StatusMessages (array(<type>, <head line>, <body>))
|
|
|
|
*/
|
|
|
|
public abstract function fillFromPostData();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the option value. The value must not contain "=" and ";".
|
|
|
|
*
|
|
|
|
* @return String value
|
|
|
|
*/
|
|
|
|
public function getValue() {
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the config option value. The value must not contain "=" and ";".
|
|
|
|
*
|
|
|
|
* @param String $value
|
|
|
|
*/
|
|
|
|
public function setValue($value) {
|
|
|
|
if ((strpos($value, '=') > -1) || (strpos($value, ';') > -1)) {
|
|
|
|
user_error("Invalid value for list option: " . $value, E_ERROR);
|
|
|
|
}
|
|
|
|
$this->value = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the meta HTML data to display this option.
|
|
|
|
*
|
|
|
|
* @return array meta HTML
|
|
|
|
*/
|
|
|
|
public abstract function getMetaHTML();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Boolean option for list configuration.
|
|
|
|
*
|
|
|
|
* @package lists
|
|
|
|
* @author Roland Gruber
|
|
|
|
*/
|
|
|
|
class lamBooleanListOption extends lamListOption {
|
|
|
|
|
|
|
|
private $name;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new boolean option.
|
|
|
|
*
|
|
|
|
* @param String $name name to show on config page
|
2007-12-09 10:45:04 +00:00
|
|
|
* @param String $ID unique ID
|
2007-11-11 14:01:16 +00:00
|
|
|
* @return lamBooleanListOption config option
|
|
|
|
*/
|
2007-12-28 16:08:56 +00:00
|
|
|
public function __construct($name, $ID) {
|
|
|
|
parent::__construct($ID);
|
2007-11-11 14:01:16 +00:00
|
|
|
$this->name = $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if this option is selected.
|
|
|
|
*
|
|
|
|
* @return boolean true, if selected
|
|
|
|
*/
|
|
|
|
public function isSelected() {
|
|
|
|
return ($this->getValue() === "1");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fills the config option from POST data.
|
|
|
|
*
|
|
|
|
* @return array list of StatusMessages (array(<type>, <head line>, <body>))
|
|
|
|
*/
|
|
|
|
public function fillFromPostData() {
|
|
|
|
if (isset($_POST[$this->getID()])) {
|
|
|
|
$this->setValue("1");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->setValue("0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the meta HTML data to display this option.
|
|
|
|
*
|
|
|
|
* @return array meta HTML
|
|
|
|
*/
|
|
|
|
public function getMetaHTML() {
|
|
|
|
$return = array();
|
|
|
|
$return[] = array(
|
|
|
|
array('kind' => 'input', 'name' => $this->getID(), 'type' => 'checkbox', 'checked' => $this->isSelected()),
|
|
|
|
array('kind' => 'text', 'text' => $this->name)
|
|
|
|
);
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-12-09 10:45:04 +00:00
|
|
|
/**
|
|
|
|
* Boolean option for list configuration.
|
|
|
|
*
|
|
|
|
* @package lists
|
|
|
|
* @author Roland Gruber
|
|
|
|
*/
|
|
|
|
class lamSelectListOption extends lamListOption {
|
|
|
|
|
|
|
|
private $name;
|
|
|
|
private $options;
|
|
|
|
private $helpID;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new selection list option.
|
|
|
|
*
|
|
|
|
* @param String $name name to show on config page
|
|
|
|
* @param array $options list of possible values
|
|
|
|
* @param String $ID unique ID
|
|
|
|
* @return lamBooleanListOption config option
|
|
|
|
*/
|
2007-12-28 16:08:56 +00:00
|
|
|
public function __construct($name, $options, $ID) {
|
|
|
|
parent::__construct($ID);
|
2007-12-09 10:45:04 +00:00
|
|
|
$this->name = $name;
|
|
|
|
$this->options = $options;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the help ID.
|
|
|
|
*
|
|
|
|
* @param Strign $id help ID
|
|
|
|
*/
|
|
|
|
public function setHelpID($id) {
|
|
|
|
$this->helpID = $id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fills the config option from POST data.
|
|
|
|
*
|
|
|
|
* @return array list of StatusMessages (array(<type>, <head line>, <body>))
|
|
|
|
*/
|
|
|
|
public function fillFromPostData() {
|
|
|
|
if (isset($_POST[$this->getID()])) {
|
|
|
|
$this->setValue($_POST[$this->getID()]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->setValue(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the meta HTML data to display this option.
|
|
|
|
*
|
|
|
|
* @return array meta HTML
|
|
|
|
*/
|
|
|
|
public function getMetaHTML() {
|
|
|
|
$return = array();
|
|
|
|
$return[] = array(
|
|
|
|
array('kind' => 'text', 'text' => $this->name),
|
|
|
|
array('kind' => 'select', 'name' => $this->getID(), 'options' => $this->options, 'options_selected' => array($this->getValue())),
|
|
|
|
array('kind' => 'help', 'value' => '208')
|
|
|
|
);
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-05-31 20:10:36 +00:00
|
|
|
?>
|