new configuration system for the account lists

This commit is contained in:
Roland Gruber 2007-11-11 14:01:16 +00:00
parent 19c08dc374
commit ce214c9885
5 changed files with 351 additions and 133 deletions

View File

@ -1,5 +1,6 @@
??? 2.2.0 ??? 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) - use suffix from account list as default for new accounts (patch 1823583)
- Security: passwords in configuration files are now saved as hash values - Security: passwords in configuration files are now saved as hash values
- Unix: allow to set host passwords (RFE 1754069) - Unix: allow to set host passwords (RFE 1754069)

View File

@ -1,19 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head> <html><head><title>Upgrade nores</title>
<title>Upgrade nores</title>
<link rel="stylesheet" type="text/css" href="style/layout.css">
</head>
<link rel="stylesheet" type="text/css" href="style/layout.css"></head>
<body> <body>
<div style="text-align: center;"> <div style="text-align: center;">
<h1>Upgrade notes</h1></div> <h1>Upgrade notes</h1></div>
<h2>2.1.0 -&gt; 2.2.0</h2> <h2>2.1.0 -&gt; 2.2.0</h2>
Account lists now support to define tools. These are displayed as linked images like the edit and delete links in the list.<br> Account lists now support to define tools. These are displayed as linked images like the edit and delete links in the list.<br>
Overwrite <span style="font-weight: bold;">lamList::getAdditionalTools()</span> to use this feature.<br>
<br> <br>
The definition of account list options changed. The function <span style="font-weight: bold;">lamList::getAdditionalTools()</span> is no longer available. Use these functions instead: <span style="font-weight: bold;">lamList::listGetAllConfigOptions()</span> and <span style="font-weight: bold;">lamList::listConfigurationChanged()</span>.<br>
All options are now saved in cookies for one year.<br>
<br> <br>
<h2>2.0.0 -&gt; 2.1.0</h2> <h2>2.0.0 -&gt; 2.1.0</h2>
<span style="font-weight: bold;">Style changes:</span><br> <span style="font-weight: bold;">Style changes:</span><br>
@ -34,8 +35,13 @@ LAM is now PHP5 only. Several variables are now private and need to be accessed
<h2>1.2.0 -&gt; 1.3.0</h2> <h2>1.2.0 -&gt; 1.3.0</h2>
<span style="font-weight: bold;">New lamList function:</span><br> <span style="font-weight: bold;">New lamList function:</span><br>
<ul> <ul>
<li><span style="font-weight: bold;">listPrintTableCellContent():</span> This function allows you to control how the LDAP attributes are displayed in the table. This can be used to display links or binary data.</li> <li><span style="font-weight: bold;">listPrintTableCellContent():</span>
<li><span style="font-weight: bold;">listPrintAdditionalOptions():</span> If you want to display additional conrols for a list please use this function. The controls will be placed under the account table.<br> This function allows you to control how the LDAP attributes are
displayed in the table. This can be used to display links or binary
data.</li>
<li><span style="font-weight: bold;">listPrintAdditionalOptions():</span>
If you want to display additional conrols for a list please use this
function. The controls will be placed under the account table.<br>
</li> </li>
</ul> </ul>
No more lamdaemon commands via delete_attributes() and save_attributes() in account modules.<br> No more lamdaemon commands via delete_attributes() and save_attributes() in account modules.<br>
@ -57,7 +63,10 @@ Please use these new functions to call lamdaemon directly:<br>
<span style="font-weight: bold;">API changes:</span><br> <span style="font-weight: bold;">API changes:</span><br>
<ul> <ul>
<li>removed $post parameters from module functions (delete_attributes(), process_...(), display_html_...()). Use $_POST instead.</li> <li>removed $post parameters from module functions (delete_attributes(), process_...(), display_html_...()). Use $_POST instead.</li>
<li>process_...() functions: returned messages are no longer grouped (e.g. return: array(array('INFO', 'headline', 'text'), array('INFO', 'headline2', 'text2')))</li> <li>process_...()
functions: returned messages are no longer grouped (e.g. return:
array(array('INFO', 'headline', 'text'), array('INFO', 'headline2',
'text2')))</li>
</ul> </ul>
<br> <br>
<h2>1.0.0 -&gt; 1.0.2</h2> <h2>1.0.0 -&gt; 1.0.2</h2>

View File

@ -47,19 +47,19 @@ include_once("pdf.inc");
class lamList { class lamList {
/** Account type */ /** Account type */
var $type; protected $type;
/** current page number */ /** current page number */
var $page = 1; protected $page = 1;
/** list of LDAP attributes */ /** list of LDAP attributes */
var $attrArray = array(); protected $attrArray = array();
/** list of attribute descriptions */ /** list of attribute descriptions */
var $descArray = array(); protected $descArray = array();
/** maximum count of entries per page */ /** maximum count of entries per page */
var $maxPageEntries = 10; protected $maxPageEntries = 10;
/** sort column name */ /** sort column name */
protected $sortColumn; protected $sortColumn;
@ -68,22 +68,25 @@ class lamList {
protected $sortDirection = 1; protected $sortDirection = 1;
/** LDAP suffix */ /** LDAP suffix */
var $suffix; protected $suffix;
/** refresh page switch */ /** refresh page switch */
var $refresh = true; protected $refresh = true;
/** LDAP entries */ /** LDAP entries */
var $entries; protected $entries;
/** filter string to include in URL */ /** filter string to include in URL */
var $filterText; protected $filterText;
/** list of possible LDAP suffixes(organizational units) */ /** list of possible LDAP suffixes(organizational units) */
var $possibleSuffixes; protected $possibleSuffixes;
/** list of account specific labels */ /** list of account specific labels */
var $labels; protected $labels;
/** configuration options */
private $configOptions;
/** /**
* Constructor * Constructor
@ -91,7 +94,7 @@ class lamList {
* @param string $type account type * @param string $type account type
* @return lamList list object * @return lamList list object
*/ */
function lamList($type) { public function lamList($type) {
$this->type = $type; $this->type = $type;
$this->labels = array( $this->labels = array(
'nav' => _("%s object(s) found"), 'nav' => _("%s object(s) found"),
@ -100,12 +103,44 @@ class lamList {
'deleteEntry' => _("Delete object"), 'deleteEntry' => _("Delete object"),
'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"));
$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. * Prints the HTML code to display the list view.
*/ */
function showPage() { public function showPage() {
if (isset($_GET['openConfig'])) {
$this->listPrintConfigurationPage();
return;
}
// do POST actions // do POST actions
$this->listDoPost(); $this->listDoPost();
// get some parameters // get some parameters
@ -142,8 +177,6 @@ class lamList {
// buttons // buttons
$this->listPrintButtons(false); $this->listPrintButtons(false);
echo ("<br>\n"); echo ("<br>\n");
// other options
$this->listPrintAdditionalOptions();
// PDF bar // PDF bar
$this->listPrintPDFButtons(); $this->listPrintPDFButtons();
} }
@ -157,11 +190,8 @@ class lamList {
// account table head // account table head
$this->listPrintTableHeader(); $this->listPrintTableHeader();
echo "</table><br>\n"; echo "</table><br>\n";
// other options
$this->listPrintAdditionalOptions();
} }
echo ("</form>\n"); $this->listPrintFooter();
echo "</body></html>\n";
} }
/** /**
@ -170,7 +200,7 @@ class lamList {
* @return array filter data array($attribute => array('regex' => $reg, 'original' => $orig)) * @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 * $reg is the regular expression to use, $orig the user's unmodified input string
*/ */
function listBuildFilter() { protected function listBuildFilter() {
$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++) {
@ -214,7 +244,7 @@ class lamList {
* *
* @return array filtered list of accounts * @return array filtered list of accounts
*/ */
function listFilterAccounts() { protected function listFilterAccounts() {
$entries = array(); $entries = array();
$filter = $this->listBuildFilter(); $filter = $this->listBuildFilter();
$attributes = array_keys($filter); $attributes = array_keys($filter);
@ -249,7 +279,7 @@ class lamList {
* @param array $info the account list * @param array $info the account list
* @return array sorted account list * @return array sorted account list
*/ */
function listSort(&$info) { protected function listSort(&$info) {
if (!is_array($this->attrArray)) return $info; if (!is_array($this->attrArray)) return $info;
if (!is_string($this->sortColumn)) return $info; if (!is_string($this->sortColumn)) return $info;
// sort and return account list // sort and return account list
@ -268,7 +298,7 @@ class lamList {
* @param array $b second 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 * @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 specifies the sort column
$sort = $this->sortColumn; $sort = $this->sortColumn;
// sort by first column if no attribute is given // sort by first column if no attribute is given
@ -287,7 +317,7 @@ class lamList {
* *
* @param integer $count number of account entries * @param integer $count number of account entries
*/ */
function listDrawNavigationBar($count) { protected 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");
@ -326,7 +356,7 @@ class lamList {
/** /**
* Prints the attribute and filter row at the account table head * Prints the attribute and filter row at the account table head
*/ */
function listPrintTableHeader() { protected function listPrintTableHeader() {
// print table header // print table header
echo "<table rules=\"all\" class=\"" . $this->type . "list\" width=\"100%\">\n"; 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"; echo "<tr class=\"" . $this->type . "list-head\">\n<th width=22 height=34></th>\n<th></th>\n";
@ -378,7 +408,7 @@ class lamList {
* *
* @param array $info entries * @param array $info entries
*/ */
function listPrintTableBody(&$info) { protected function listPrintTableBody(&$info) {
// calculate which rows to show // calculate which rows to show
$table_begin = ($this->page - 1) * $this->maxPageEntries; $table_begin = ($this->page - 1) * $this->maxPageEntries;
if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info); if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info);
@ -448,7 +478,7 @@ class lamList {
* @param array $entry LDAP attributes * @param array $entry LDAP attributes
* @param string $attribute attribute name * @param string $attribute attribute name
*/ */
function listPrintTableCellContent(&$entry, &$attribute) { protected function listPrintTableCellContent(&$entry, &$attribute) {
// print all attribute entries seperated by "; " // print all attribute entries seperated by "; "
if (isset($entry[$attribute]) && sizeof($entry[$attribute]) > 0) { if (isset($entry[$attribute]) && sizeof($entry[$attribute]) > 0) {
// delete "count" entry // delete "count" entry
@ -467,7 +497,7 @@ class lamList {
/** /**
* Manages all POST actions (e.g. button pressed) for the account lists. * 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 // 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'])){ if (isset($_POST['new']) || isset($_POST['del']) || isset($_POST['pdf']) || isset($_POST['pdf_all'])){
// add new account // 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. * Prints a combobox with possible sub-DNs.
*/ */
function listShowOUSelection() { protected function listShowOUSelection() {
if (sizeof($this->possibleSuffixes) > 1) { if (sizeof($this->possibleSuffixes) > 1) {
echo ("<b>" . _("Suffix") . ": </b>"); echo ("<b>" . _("Suffix") . ": </b>");
echo ("<select class=\"" . $this->type . "\" size=1 name=\"suffix\" onchange=\"listOUchanged()\">\n"); echo ("<select class=\"" . $this->type . "\" size=1 name=\"suffix\" onchange=\"listOUchanged()\">\n");
@ -557,7 +601,7 @@ class lamList {
* *
* @param boolean $createOnly true if only the create button should be displayed * @param boolean $createOnly true if only the create button should be displayed
*/ */
function listPrintButtons($createOnly) { protected function listPrintButtons($createOnly) {
echo "<table border=0 width=\"100%\">\n"; echo "<table border=0 width=\"100%\">\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td align=\"left\">\n"; echo "<td align=\"left\">\n";
@ -566,9 +610,14 @@ class lamList {
if (!$createOnly) { if (!$createOnly) {
echo ("<input class=\"" . $this->type . "\" type=\"submit\" name=\"del\" value=\"" . $this->labels['deleteEntry'] . "\">\n"); echo ("<input class=\"" . $this->type . "\" type=\"submit\" name=\"del\" value=\"" . $this->labels['deleteEntry'] . "\">\n");
} }
echo "&nbsp;&nbsp;&nbsp;";
$this->listShowOUSelection();
echo "</td>\n"; echo "</td>\n";
echo "<td align=\"right\">\n"; echo "<td align=\"right\">\n";
$this->listShowOUSelection(); echo '<a href="list.php?type=' . $this->type . '&amp;openConfig=1">';
echo '<img src="../../graphics/tools.png" alt="' . _('Change settings') . '" title="' . _('Change settings') . '">';
echo '&nbsp;' . _('Change settings');
echo '</a>';
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>\n"; echo "</table>\n";
@ -577,7 +626,7 @@ class lamList {
/** /**
* Prints the PDF button bar. * Prints the PDF button bar.
*/ */
function listPrintPDFButtons() { protected function listPrintPDFButtons() {
echo "<fieldset class=\"" . $this->type . "edit\"><legend><b>PDF</b></legend>\n"; echo "<fieldset class=\"" . $this->type . "edit\"><legend><b>PDF</b></legend>\n";
echo ("<b>" . _('PDF structure') . ":</b>&nbsp;&nbsp;<select name=\"pdf_structure\">\n"); echo ("<b>" . _('PDF structure') . ":</b>&nbsp;&nbsp;<select name=\"pdf_structure\">\n");
$pdf_structures = getPDFStructureDefinitions($this->type); $pdf_structures = getPDFStructureDefinitions($this->type);
@ -592,9 +641,9 @@ class lamList {
} }
/** /**
* Prints the HTML head. * Prints the HTML header.
*/ */
function listPrintHeader() { protected function listPrintHeader() {
echo $_SESSION['header']; echo $_SESSION['header'];
echo "<title>Account list</title>\n"; echo "<title>Account list</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
@ -603,10 +652,18 @@ class lamList {
$this->listPrintJavaScript(); $this->listPrintJavaScript();
} }
/**
* Prints the HTML footer.
*/
protected function listPrintFooter() {
echo ("</form>\n");
echo "</body></html>\n";
}
/** /**
* Prints JavaScript code needed for mouse-over effects. * Prints JavaScript code needed for mouse-over effects.
*/ */
function listPrintJavaScript() { protected function listPrintJavaScript() {
echo "<script type=\"text/javascript\" language=\"javascript\">\n"; echo "<script type=\"text/javascript\" language=\"javascript\">\n";
echo "<!--\n"; echo "<!--\n";
@ -651,7 +708,7 @@ class lamList {
* *
* @return array attribute list * @return array attribute list
*/ */
function listGetAttributeDescriptionList() { private function listGetAttributeDescriptionList() {
$ret = array(); $ret = array();
$attr_string = $_SESSION["config"]->get_listAttributes($this->type); $attr_string = $_SESSION["config"]->get_listAttributes($this->type);
$temp_array = explode(";", $attr_string); $temp_array = explode(";", $attr_string);
@ -685,7 +742,7 @@ class lamList {
/** /**
* Sets some internal parameters. * Sets some internal parameters.
*/ */
function listGetParams() { protected function listGetParams() {
// get current page // get current page
if (isset($_GET["page"])) $this->page = $_GET["page"]; if (isset($_GET["page"])) $this->page = $_GET["page"];
else $this->page = 1; else $this->page = 1;
@ -729,7 +786,7 @@ class lamList {
/** /**
* Rereads the entries from LDAP. * Rereads the entries from LDAP.
*/ */
function listRefreshData() { protected function listRefreshData() {
// configure search filter // configure search filter
$module_filter = get_ldap_filter($this->type); // basic filter is provided by modules $module_filter = get_ldap_filter($this->type); // basic filter is provided by modules
$filter = "(&" . $module_filter . ")"; $filter = "(&" . $module_filter . ")";
@ -759,13 +816,6 @@ class lamList {
$this->possibleSuffixes = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($this->type)); $this->possibleSuffixes = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($this->type));
} }
/**
* Prints additional option fields for specific object types.
*/
function listPrintAdditionalOptions() {
// may be used by subclasses
}
/** /**
* 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.
* *
@ -775,6 +825,63 @@ class lamList {
return array(); return array();
} }
/**
* Returns a list of possible configuration options.
*
* @return array list of lamListOption objects
*/
protected function listGetAllConfigOptions() {
return array();
}
/**
* 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 . "&amp;norefresh=true\" method=\"post\">\n";
echo "<table class=\"" . $this->type . "list\" width=\"100%\">\n";
echo "<tr class=\"" . $this->type . "list\"><td>\n";
$tabindex = 0;
$tabindexLink = 0;
for ($i = 0; $i < sizeof($this->configOptions); $i++) {
parseHtml('none', $this->configOptions[$i]->getMetaHTML(), array(), true, $tabindex, $tabindexLink, $this->type);
}
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";
echo "</form>\n";
$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() {
return;
}
} }
/** /**
@ -797,7 +904,7 @@ class lamListTool {
* @param String $target target page * @param String $target target page
* @return lamListTool tool object * @return lamListTool tool object
*/ */
function lamListTool($name, $image, $target) { public function lamListTool($name, $image, $target) {
$this->name = $name; $this->name = $name;
$this->image = $image; $this->image = $image;
$this->target = $target; $this->target = $target;
@ -809,7 +916,7 @@ class lamListTool {
* *
* @return String image name * @return String image name
*/ */
function getImage() { public function getImage() {
return $this->image; return $this->image;
} }
@ -819,7 +926,7 @@ class lamListTool {
* *
* @return String name * @return String name
*/ */
function getName() { public function getName() {
return $this->name; return $this->name;
} }
@ -829,10 +936,138 @@ class lamListTool {
* *
* @return String page file (e.g. 'mytool.php') * @return String page file (e.g. 'mytool.php')
*/ */
function getLinkTarget() { public function getLinkTarget() {
return $this->target; return $this->target;
} }
} }
/**
* Represents a list configuration option.
*
* @package lists
* @author Roland Gruber
*/
abstract class lamListOption {
private $ID;
private $value;
/**
* Creates a new config option.
*
* @param String $ID
* @return lamConfigOption config option
*/
public function lamConfigOption($ID) {
$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
* @return lamBooleanListOption config option
*/
public function lamBooleanListOption($name, $ID) {
parent::lamConfigOption($ID);
$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;
}
}
?> ?>

View File

@ -100,14 +100,13 @@ class group extends baseType {
class lamGroupList extends lamList { class lamGroupList extends lamList {
/** Controls if include primary group members into group memebers */ /** Controls if include primary group members into group memebers */
private $include_primary = ""; private $use_primary = false;
/** Primary group members hash */ /** Primary group members hash */
private $primary_hash = array(); private $primary_hash = array();
/** Controls if primary group members needs refresh */ /** Controls if primary group members needs refresh */
private $refresh_primary = false; private $refresh_primary = false;
/** Controls if primary group members are using */ /** ID for config option */
// This is here for future use with primary group members listing const TRANS_PRIMARY_OPTION_NAME = "LG_TP";
private $use_primary = false;
/** /**
* Constructor * Constructor
@ -126,21 +125,6 @@ class lamGroupList extends lamList {
'createPDFAll' => _("Create PDF for all groups")); 'createPDFAll' => _("Create PDF for all groups"));
} }
/**
* Manages all POST actions (e.g. button pressed) for the account lists.
*/
function listDoPost() {
parent::listDoPost();
// check if list primary group members
if (isset($_POST['apply_group_addopts'])) {
$use_primary = $this->use_primary;
$this->include_primary = $_POST['addopts_include_primary'];
$this->groupSetUsePrimary();
if (!$use_primary && $this->use_primary)
$this->refresh_primary = true;
}
}
/** /**
* Sets some internal parameters. * Sets some internal parameters.
*/ */
@ -148,27 +132,10 @@ class lamGroupList extends lamList {
parent::listGetParams(); parent::listGetParams();
// generate list primary group memebers // generate list primary group memebers
// after parent::listGetParams is $this->refresh set to correct value // after parent::listGetParams is $this->refresh set to correct value
if ($this->use_primary && !$this->refresh && ($this->refresh_primary || (sizeof($this->primary_hash) == 0))) if ($this->include_primary && !$this->refresh && ($this->refresh_primary || (sizeof($this->primary_hash) == 0)))
$this->groupRefreshPrimary(); $this->groupRefreshPrimary();
} }
/**
* Prints additional option field for primary member display.
*/
function listPrintAdditionalOptions() {
parent::listPrintAdditionalOptions();
// show primary group members option
if (in_array("memberuid", $this->attrArray)) {
echo "<b>" . _("Show primary group members as normal group members") . ": </b>";
echo "<input class=\"" . $this->type . "\" type=\"checkbox\" name=\"addopts_include_primary\"";
if ($this->include_primary == "on")
echo " checked";
echo ">";
echo ("&nbsp;&nbsp;<input class=\"" . $this->type . "\" type=\"submit\" name=\"apply_group_addopts\" value=\"" . _("Apply") . "\">");
echo "</p>\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.
* *
@ -244,7 +211,7 @@ class lamGroupList extends lamList {
*/ */
function listRefreshData() { function listRefreshData() {
parent::listRefreshData(); parent::listRefreshData();
if ($this->use_primary) { if ($this->include_primary) {
$this->groupRefreshPrimary(); $this->groupRefreshPrimary();
} }
} }
@ -285,10 +252,24 @@ class lamGroupList extends lamList {
} }
/** /**
* Checks if primary group members should be included. * Returns a list of possible configuration options.
*
* @return array list of lamListOption objects
*/ */
function groupSetUsePrimary() { protected function listGetAllConfigOptions() {
$this->use_primary = ($this->include_primary == "on"); return array(new lamBooleanListOption(_('Show primary group members as normal group members'), self::TRANS_PRIMARY_OPTION_NAME));
}
/**
* Called when the configuration options changed.
*/
protected function listConfigurationChanged() {
$tpOption = $this->listGetConfigOptionByID(self::TRANS_PRIMARY_OPTION_NAME);
$use_primary = $this->include_primary;
$this->include_primary = $tpOption->isSelected();
if (!$use_primary && $this->include_primary) {
$this->refresh_primary = true;
}
} }
} }

View File

@ -111,13 +111,16 @@ class lamUserList extends lamList {
/** translates GID to group name */ /** translates GID to group name */
private $trans_primary_hash = array(); private $trans_primary_hash = array();
/** ID for config option */
const TRANS_PRIMARY_OPTION_NAME = "LU_TP";
/** /**
* Constructor * Constructor
* *
* @param string $type account type * @param string $type account type
* @return lamList list object * @return lamList list object
*/ */
function lamUserList($type) { public function lamUserList($type) {
parent::lamList($type); parent::lamList($type);
$this->labels = array( $this->labels = array(
'nav' => _("%s user(s) found"), 'nav' => _("%s user(s) found"),
@ -128,21 +131,10 @@ class lamUserList extends lamList {
'createPDFAll' => _("Create PDF for all users")); 'createPDFAll' => _("Create PDF for all users"));
} }
/**
* Manages all POST actions (e.g. button pressed) for the account lists.
*/
function listDoPost() {
parent::listDoPost();
// check if primary group should be translated
if (isset($_POST['apply_trans_primary'])) {
$this->trans_primary = $_POST['trans_primary'];
}
}
/** /**
* Sets some internal parameters. * Sets some internal parameters.
*/ */
function listGetParams() { protected function listGetParams() {
parent::listGetParams(); parent::listGetParams();
// generate hash table for group translation // generate hash table for group translation
if ($this->trans_primary == "on" && !$this->refresh && (sizeof($this->trans_primary_hash) == 0)) { if ($this->trans_primary == "on" && !$this->refresh && (sizeof($this->trans_primary_hash) == 0)) {
@ -153,7 +145,7 @@ class lamUserList extends lamList {
/** /**
* Rereads the entries from LDAP. * Rereads the entries from LDAP.
*/ */
function listRefreshData() { protected function listRefreshData() {
parent::listRefreshData(); parent::listRefreshData();
if ($this->trans_primary == "on") { if ($this->trans_primary == "on") {
$this->refreshPrimaryGroupTranslation(); $this->refreshPrimaryGroupTranslation();
@ -163,7 +155,7 @@ class lamUserList extends lamList {
/** /**
* Refreshes the GID to group name cache. * Refreshes the GID to group name cache.
*/ */
function refreshPrimaryGroupTranslation() { protected function refreshPrimaryGroupTranslation() {
$this->trans_primary_hash = array(); $this->trans_primary_hash = array();
$grp_suffix = $_SESSION['config']->get_Suffix('group'); $grp_suffix = $_SESSION['config']->get_Suffix('group');
$filter = "objectClass=posixGroup"; $filter = "objectClass=posixGroup";
@ -184,7 +176,7 @@ class lamUserList extends lamList {
* @param array $entry LDAP attributes * @param array $entry LDAP attributes
* @param string $attribute attribute name * @param string $attribute attribute name
*/ */
function listPrintTableCellContent(&$entry, &$attribute) { protected function listPrintTableCellContent(&$entry, &$attribute) {
// check if there is something to display at all // check if there is something to display at all
if (!isset($entry[$attribute]) || !is_array($entry[$attribute]) || (sizeof($entry[$attribute]) < 1)) return; if (!isset($entry[$attribute]) || !is_array($entry[$attribute]) || (sizeof($entry[$attribute]) < 1)) return;
if (isset($entry[$attribute]['count'])) unset($entry[$attribute]['count']); if (isset($entry[$attribute]['count'])) unset($entry[$attribute]['count']);
@ -224,23 +216,6 @@ class lamUserList extends lamList {
} }
} }
/**
* Prints additional option fields for specific object types.
*/
function listPrintAdditionalOptions() {
// show translate GID to group name box if there is a column with gidnumber
if (in_array("gidnumber", $this->attrArray)) {
echo "<p align=\"left\">\n";
echo "<b>" . _("Translate GID number to group name") . ": </b>";
if ($this->trans_primary == "on") {
echo "<input class=\"" . $this->type . "\" type=\"checkbox\" name=\"trans_primary\" checked>";
}
else echo "<input class=\"" . $this->type . "\" type=\"checkbox\" name=\"trans_primary\">";
echo ("&nbsp;&nbsp;<input class=\"" . $this->type . "\" type=\"submit\" name=\"apply_trans_primary\" value=\"" . _("Apply") . "\">");
echo "</p>\n";
}
}
/** /**
* 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.
* *
@ -256,6 +231,23 @@ class lamUserList extends lamList {
} }
} }
/**
* Returns a list of possible configuration options.
*
* @return array list of lamListOption objects
*/
protected function listGetAllConfigOptions() {
return array(new lamBooleanListOption(_('Translate GID number to group name'), self::TRANS_PRIMARY_OPTION_NAME));
}
/**
* Called when the configuration options changed.
*/
protected function listConfigurationChanged() {
$tpOption = $this->listGetConfigOptionByID(self::TRANS_PRIMARY_OPTION_NAME);
$this->trans_primary = $tpOption->isSelected();
}
} }
?> ?>