diff --git a/lam/HISTORY b/lam/HISTORY index 42c92dbf..4054bbf1 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,5 +1,6 @@ ??? 2.2.0 - - allow to switch sorting in the account lists + - account lists: allow to switch sorting + - account lists: added separate configuration page and store settings in cookies - use suffix from account list as default for new accounts (patch 1823583) - Security: passwords in configuration files are now saved as hash values - Unix: allow to set host passwords (RFE 1754069) diff --git a/lam/docs/devel/upgrade.htm b/lam/docs/devel/upgrade.htm index 5f6b0fc3..b081999a 100644 --- a/lam/docs/devel/upgrade.htm +++ b/lam/docs/devel/upgrade.htm @@ -1,19 +1,20 @@ - - Upgrade nores +Upgrade nores + - - - +

Upgrade notes

2.1.0 -> 2.2.0

Account lists now support to define tools. These are displayed as linked images like the edit and delete links in the list.
+Overwrite lamList::getAdditionalTools() to use this feature.

+The definition of account list options changed. The function lamList::getAdditionalTools() is no longer available. Use these functions instead: lamList::listGetAllConfigOptions() and lamList::listConfigurationChanged().
+All options are now saved in cookies for one year.

2.0.0 -> 2.1.0

Style changes:
@@ -34,8 +35,13 @@ LAM is now PHP5 only. Several variables are now private and need to be accessed

1.2.0 -> 1.3.0

New lamList function:
No more lamdaemon commands via delete_attributes() and save_attributes() in account modules.
@@ -57,7 +63,10 @@ Please use these new functions to call lamdaemon directly:
API changes:

1.0.0 -> 1.0.2

diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index dafd0ab5..0cdcdbca 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -47,19 +47,19 @@ include_once("pdf.inc"); class lamList { /** Account type */ - var $type; + protected $type; /** current page number */ - var $page = 1; + protected $page = 1; /** list of LDAP attributes */ - var $attrArray = array(); + protected $attrArray = array(); /** list of attribute descriptions */ - var $descArray = array(); + protected $descArray = array(); /** maximum count of entries per page */ - var $maxPageEntries = 10; + protected $maxPageEntries = 10; /** sort column name */ protected $sortColumn; @@ -68,22 +68,25 @@ class lamList { protected $sortDirection = 1; /** LDAP suffix */ - var $suffix; + protected $suffix; /** refresh page switch */ - var $refresh = true; + protected $refresh = true; /** LDAP entries */ - var $entries; + protected $entries; /** filter string to include in URL */ - var $filterText; + protected $filterText; /** list of possible LDAP suffixes(organizational units) */ - var $possibleSuffixes; + protected $possibleSuffixes; /** list of account specific labels */ - var $labels; + protected $labels; + + /** configuration options */ + private $configOptions; /** * Constructor @@ -91,7 +94,7 @@ class lamList { * @param string $type account type * @return lamList list object */ - function lamList($type) { + public function lamList($type) { $this->type = $type; $this->labels = array( 'nav' => _("%s object(s) found"), @@ -100,12 +103,44 @@ class lamList { 'deleteEntry' => _("Delete object"), 'createPDF' => _("Create PDF for selected object(s)"), 'createPDFAll' => _("Create PDF for all objects")); + $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(); + } + } } /** * Prints the HTML code to display the list view. */ - function showPage() { + public function showPage() { + if (isset($_GET['openConfig'])) { + $this->listPrintConfigurationPage(); + return; + } // do POST actions $this->listDoPost(); // get some parameters @@ -142,8 +177,6 @@ class lamList { // buttons $this->listPrintButtons(false); echo ("
\n"); - // other options - $this->listPrintAdditionalOptions(); // PDF bar $this->listPrintPDFButtons(); } @@ -157,11 +190,8 @@ class lamList { // account table head $this->listPrintTableHeader(); echo "
\n"; - // other options - $this->listPrintAdditionalOptions(); } - echo ("\n"); - echo "\n"; + $this->listPrintFooter(); } /** @@ -170,7 +200,7 @@ class lamList { * @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 */ - function listBuildFilter() { + protected function listBuildFilter() { $filter = array(); // build filter array for ($i = 0; $i < sizeof($this->attrArray); $i++) { @@ -214,7 +244,7 @@ class lamList { * * @return array filtered list of accounts */ - function listFilterAccounts() { + protected function listFilterAccounts() { $entries = array(); $filter = $this->listBuildFilter(); $attributes = array_keys($filter); @@ -249,7 +279,7 @@ class lamList { * @param array $info the account list * @return array sorted account list */ - function listSort(&$info) { + protected function listSort(&$info) { if (!is_array($this->attrArray)) return $info; if (!is_string($this->sortColumn)) return $info; // sort and return account list @@ -268,7 +298,7 @@ class lamList { * @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 */ - function cmp_array(&$a, &$b) { + protected function cmp_array(&$a, &$b) { // sort specifies the sort column $sort = $this->sortColumn; // sort by first column if no attribute is given @@ -287,7 +317,7 @@ class lamList { * * @param integer $count number of account entries */ - function listDrawNavigationBar($count) { + protected function listDrawNavigationBar($count) { echo("type . "nav\" width=\"100%\" border=\"0\">\n"); echo("\n"); @@ -326,7 +356,7 @@ class lamList { /** * Prints the attribute and filter row at the account table head */ - function listPrintTableHeader() { + protected function listPrintTableHeader() { // print table header echo "
type . "list\" width=\"100%\">\n"; echo "type . "list-head\">\n\n\n"; @@ -378,7 +408,7 @@ class lamList { * * @param array $info entries */ - function listPrintTableBody(&$info) { + protected function listPrintTableBody(&$info) { // calculate which rows to show $table_begin = ($this->page - 1) * $this->maxPageEntries; if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info); @@ -448,7 +478,7 @@ class lamList { * @param array $entry LDAP attributes * @param string $attribute attribute name */ - function listPrintTableCellContent(&$entry, &$attribute) { + protected function listPrintTableCellContent(&$entry, &$attribute) { // print all attribute entries seperated by "; " if (isset($entry[$attribute]) && sizeof($entry[$attribute]) > 0) { // delete "count" entry @@ -467,7 +497,7 @@ class lamList { /** * Manages all POST actions (e.g. button pressed) for the account lists. */ - function listDoPost() { + private function listDoPost() { // check if button was pressed and if we have to add/delete an account if (isset($_POST['new']) || isset($_POST['del']) || isset($_POST['pdf']) || isset($_POST['pdf_all'])){ // add new account @@ -532,12 +562,26 @@ class lamList { } } } + // 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(); + } + } } /** * Prints a combobox with possible sub-DNs. */ - function listShowOUSelection() { + protected function listShowOUSelection() { if (sizeof($this->possibleSuffixes) > 1) { echo ("" . _("Suffix") . ": "); echo ("
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; @@ -566,9 +610,14 @@ class lamList { if (!$createOnly) { echo ("type . "\" type=\"submit\" name=\"del\" value=\"" . $this->labels['deleteEntry'] . "\">\n"); } + echo "   "; + $this->listShowOUSelection(); echo "\n"; - $this->listShowOUSelection(); + echo ''; + echo '' . _('Change settings') . ''; + echo ' ' . _('Change settings'); + echo ''; echo "
\n"; @@ -577,7 +626,7 @@ class lamList { /** * Prints the PDF button bar. */ - function listPrintPDFButtons() { + protected function listPrintPDFButtons() { echo "
type . "edit\">PDF\n"; echo ("" . _('PDF structure') . ":