type = $type; $this->labels = array( 'nav' => _("%s object(s) found"), 'error_noneFound' => _("No objects found!"), 'newEntry' => _("New object"), 'deleteEntry' => _("Delete object")); $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. */ public function showPage() { if (isset($_GET['openConfig'])) { $this->listPrintConfigurationPage(); return; } // do POST actions $this->listDoPost(); // get some parameters $this->listGetParams(); // print HTML head $this->listPrintHeader(); // refresh data if needed if ($this->refresh) { $this->listBuildFilter(); $this->listRefreshData(); } // sort rows by sort column if (isset($this->entries)) { $this->entries = $this->listSort($this->entries); } // show form echo "
"; echo "
\n"; echo ("
type . "&norefresh=true\" method=\"post\">\n"); // draw account list if accounts were found if (sizeof($this->entries) > 0) { // buttons $this->listPrintButtons(false); echo ("
\n"); // navigation bar $this->listDrawNavigationBar(sizeof($this->entries)); echo ("
\n"); echo "
"; // account table head $this->listPrintTableHeader(); // account table body $this->listPrintTableBody($this->entries); echo "
"; } else { // buttons $this->listPrintButtons(true); echo ("
\n"); // navigation bar $this->listDrawNavigationBar(sizeof($this->entries)); echo ("
\n"); // account table head $this->listPrintTableHeader(); echo "
\n"; } $this->listPrintFooter(); } /** * Builds the regular expressions from the filter values. */ protected function listBuildFilter() { $filter = array(); $filterParam = ""; $LDAPFilterPart = ""; // build filter array for ($i = 0; $i < sizeof($this->attrArray); $i++) { $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])]; } if (isset($foundFilter) && ($foundFilter != '')) { if (preg_match('/^([\p{L}\p{N} _\\*\\$\\.-])+$/iu', $foundFilter)) { // \p{L} matches any Unicode letter $filterParam .= "&filter" . $this->attrArray[$i] . '=' . $foundFilter; $LDAPFilterPart .= '(' . $this->attrArray[$i] . '=' . $foundFilter . ')'; } else { StatusMessage('ERROR', _('Please enter a valid filter. Only letters, numbers and " _*$.-" are allowed.'), htmlspecialchars($foundFilter)); } } } $this->filterText = $filterParam; $this->filterPart = $LDAPFilterPart; } /** * Sorts an account list by a given attribute * * @param array $info the account list * @return array sorted account list */ protected function listSort(&$info) { 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; } /** * 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 */ protected function cmp_array(&$a, &$b) { if ($this->sortColumn != "dn") { // sort by first attribute with name $sort return @strnatcasecmp($a[$this->sortColumn][0], $b[$this->sortColumn][0]) * $this->sortDirection; } else { return strnatcasecmp($a[$this->sortColumn], $b[$this->sortColumn]) * $this->sortDirection; } } /** * Draws a navigation bar to switch between pages * * @param integer $count number of account entries */ protected function listDrawNavigationBar($count) { echo("\n"); echo("\n"); echo(""); echo("
"); printf($this->labels['nav'], $count); echo("type . "nav-activepage\" align=\"right\">"); if ($this->page != 1) { echo("type . "&norefresh=true&page=1" . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $this->filterText . "\">" . "\"\"\n"); } if ($this->page > 10) { echo("type . "&norefresh=true&page=" . ($this->page - 10) . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $this->filterText . "\">" . "\"\"\n"); } for ($i = $this->page - 5; $i < ($this->page + 4); $i++) { if ($i >= ($count / $this->maxPageEntries)) { break; } elseif ($i < 0) { continue; } if ($i == $this->page - 1) { echo(" " . ($i + 1)); } else { echo(" type . "&norefresh=true&page=" . ($i + 1) . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $this->filterText . "\">" . ($i + 1) . "\n"); } } if ($this->page < (($count / $this->maxPageEntries) - 10)) { echo("type . "&norefresh=true&page=" . ($this->page + 10) . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $this->filterText . "\">" . "\"\"\n"); } if ($this->page < ($count / $this->maxPageEntries)) { echo("type . "&norefresh=true&page=" . round(($count / $this->maxPageEntries)) . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $this->filterText . "\">" . "\"\"\n"); } echo("
\n"); } /** * Prints the attribute and filter row at the account table head */ protected function listPrintTableHeader() { // print table header echo "type . "list\" width=\"100%\">\n"; echo "type . "list-dark\">\n\n\n"; // table header for ($k = 0; $k < sizeof($this->descArray); $k++) { if (strtolower($this->attrArray[$k]) == $this->sortColumn) { $sortImage = "sort_asc.png"; if ($this->sortDirection < 0) { $sortImage = "sort_desc.png"; } echo "\n"; } else echo "\n"; } echo "\n"; // print filter row echo "type . "list-bright\">\n"; echo "\n"; echo "\n"; // print input boxes for filters for ($k = 0; $k < sizeof ($this->descArray); $k++) { $value = ""; if (isset($_GET["filter" . strtolower($this->attrArray[$k])])) { $value = " value=\"" . $_GET["filter" . strtolower($this->attrArray[$k])] . "\""; } if (isset($_POST["filter" . strtolower($this->attrArray[$k])])) { $value = " value=\"" . $_POST["filter" . strtolower($this->attrArray[$k])] . "\""; } echo "\n"; } echo "\n"; } /** * Prints the entry list * * @param array $info entries */ protected function listPrintTableBody(&$info) { echo "\n"; // 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++) { $rowID = base64_encode($info[$i]['dn']); if ((($i - $table_begin) % 2) == 1) { $classes = ' ' . $this->type . 'list-bright'; } else { $classes = ' ' . $this->type . 'list-dark'; } echo("type . "')\"\n" . " onMouseOut=\"list_out(this, '" . $rowID . "', '" . $this->type . "')\"\n" . " onClick=\"list_click(this, '" . $rowID . "', '" . $this->type . "')\"\n" . " onDblClick=\"top.location.href='../account/edit.php?type=" . $this->type . "&DN=" . rawurlencode($info[$i]['dn']) . "'\">\n"); echo " \n"; $this->listPrintToolLinks($info[$i], $rowID); for ($k = 0; $k < sizeof($this->attrArray); $k++) { echo ("\n"); } echo("\n"); } // display select all link $colspan = sizeof($this->attrArray) + 1; echo "type . "list-bright\">\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
type . "list-sort\">type . "&". "sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&norefresh=y" . "\">" . $this->descArray[$k] . " \"sorttype . "&". "sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&norefresh=y" . "\">" . $this->descArray[$k] . "
"; printHelpLink(getHelp('', '250'), '250'); echo ""; echo ""; echo ""; echo ("attrArray[$k]) ."\"" . $value . " onkeypress=\"SubmitForm('apply_filter', event)\">"); echo "
type . "')\"" . " type=\"checkbox\" name=\"" . $rowID . "\">"); $attrName = strtolower($this->attrArray[$k]); $this->listPrintTableCellContent($info[$i], $attrName); echo ("
\"select " . "" . _("Select all") . "
\n"; } /** * Prints the tool image links (e.g. edit and delete) for each account. * * @param array $account LDAP attributes * @param String $id account ID */ private function listPrintToolLinks($account, $id) { $output = ''; $toolCount = 0; // edit image $output .= "type . "&DN='" . rawurlencode($account['dn']) . "'\">"; $output .= "\"""; $output .= "\n "; $toolCount++; // delete image if (checkIfWriteAccessIsAllowed()) { $output .= "type . "&DN='" . rawurlencode($account['dn']) . "'\">"; $output .= "\"""; $output .= "\n "; $toolCount++; } // pdf image $pdfButtonStyle = "background-image: url(../../graphics/pdf.png);background-position: -1px -1px;background-repeat: no-repeat;width:20px;height:20px;background-color:transparent;border-style:none;"; $output .= "\n "; $toolCount++; // additional tools $tools = $this->getAdditionalTools(); for ($i = 0; $i < sizeof($tools); $i++) { $output .= "getLinkTarget() . "?type=" . $this->type . "&DN='" . rawurlencode($account['dn']) . "'\">"; $output .= "getImage() . "\" alt=\"" . $tools[$i]->getName() . "\" title=\"" . $tools[$i]->getName() . "\">"; $output .= "\n "; $toolCount++; } $width = ($toolCount * 20) + 20; echo ""; echo $output; echo "\n"; } /** * 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 */ protected function listPrintTableCellContent(&$entry, &$attribute) { // print all attribute entries seperated by "; " if (isset($entry[$attribute]) && sizeof($entry[$attribute]) > 0) { if (is_array($entry[$attribute])) { // sort array sort($entry[$attribute]); echo htmlspecialchars(implode("; ", $entry[$attribute]), ENT_QUOTES, "UTF-8"); } else { echo htmlspecialchars($entry[$attribute], ENT_QUOTES, "UTF-8"); } } } /** * Manages all POST actions (e.g. button pressed) for the account lists. */ protected function listDoPost() { // check if button was pressed and if we have to add/delete an account or call file upload if (isset($_POST['new']) || isset($_POST['del']) || isset($_POST['fileUpload'])){ if (!checkIfWriteAccessIsAllowed()) { die(); } // add new account if (isset($_POST['new'])){ metaRefresh("../account/edit.php?type=" . $this->type . "&suffix=" . $this->suffix); exit; } // delete account(s) elseif (isset($_POST['del'])){ // search for checkboxes $accounts = array_keys($_POST, "on"); // build DN list $_SESSION['delete_dn'] = array(); for ($i = 0; $i < sizeof($accounts); $i++) { $_SESSION['delete_dn'][] = base64_decode($accounts[$i]); } if (sizeof($accounts) > 0) { metaRefresh("../delete.php?type=" . $this->type); exit; } } // file upload elseif (isset($_POST['fileUpload'])){ metaRefresh("../masscreate.php?type=" . $this->type); exit; } } // PDF button foreach ($_POST as $key => $value) { if (strpos($key, 'createPDF_') > -1) { $parts = explode("_", $key); if (sizeof($parts) == 2) { $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"); $_SESSION["accountPDF"]->load_account(base64_decode($_POST['clickedAccount'])); createModulePDF(array($_SESSION["accountPDF"]),$pdfStruct); unset($_SESSION["accountPDF"]); exit; } // create for all selected accounts elseif ($option == 'SELECTED') { // 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"); $_SESSION["accountPDF-$i"]->load_account(base64_decode($accounts[$i])); $list[$i] = $_SESSION["accountPDF-$i"]; } if (sizeof($list) > 0) { createModulePDF($list,$pdfStruct); for ($i = 0; $i < sizeof($accounts); $i++) { unset($_SESSION["accountPDF-$i"]); } exit; } } // create for all accounts elseif ($option == 'ALL') { $list = array(); for ($i = 0; $i < sizeof($this->entries); $i++) { $_SESSION["accountPDF-$i"] = new accountContainer($this->type, "accountPDF-$i"); $_SESSION["accountPDF-$i"]->load_account($this->entries[$i]['dn']); $list[$i] = $_SESSION["accountPDF-$i"]; } if (sizeof($list) > 0) { createModulePDF($list,$pdfStruct); for ($i = 0; $i < sizeof($this->entries); $i++) { // clean session unset($_SESSION["accountPDF-$i"]); } exit; } } elseif ($option == 'SESSION') { createModulePDF(array($_SESSION[$_POST['PDFSessionID']]),$pdfStruct); unset($_SESSION[$_GET['PDFSessionID']]); exit; } } // 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(); } } } /** * Shows the page where the user may select the PDF options. * * @param String $id account ID */ private function showPDFPage($id) { $sessionObject = null; $PDFSessionID = null; if (($id == null) && isset($_GET['PDFSessionID'])) { $PDFSessionID = $_GET['PDFSessionID']; $sessionObject = $_SESSION[$PDFSessionID]; } // search for checkboxes $selAccounts = array_keys($_POST, "on"); if (!in_array($id, $selAccounts)) { $selAccounts[] = $id; } $this->listPrintHeader(); echo "
\n"; echo "
"; echo "type . "&norefresh=true\" method=\"post\">\n"; echo '
' . _('Create PDF file') . '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo _('PDF structure') . " "; echo ''; echo "\n"; echo '
'; echo _('Create for') . " "; echo ''; // check if account object is already in session if ($sessionObject != null) { echo $sessionObject->finalDN; echo "\n"; echo "\n"; } else { echo ''; } echo '
 
'; echo ' '; echo ' ' . _('Cancel') . ''; echo '
'; echo '
'; // hiden inputs for selected accounts for ($i = 0; $i < sizeof($selAccounts); $i++) { echo ''; } echo ''; $this->listPrintFooter(); } /** * Prints a combobox with possible sub-DNs. */ protected function listShowOUSelection() { if (sizeof($this->possibleSuffixes) > 1) { echo ("   \n"); } } /** * Prints the create and delete buttons. * * @param boolean $createOnly true if only the create button should be displayed */ protected function listPrintButtons($createOnly) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; if (checkIfWriteAccessIsAllowed()) { // add/delete buttons echo "\n"; if (!$createOnly) { echo "\n"; } $type = new $this->type(); if ($type->supportsFileUpload()) { echo '      '; echo "\n"; } ?>     \n"; echo "\n"; $this->listShowOUSelection(); echo ""; echo ' '; echo '' . _('Change settings') . ''; echo ''; echo "
\n"; } /** * Prints the HTML header. */ protected function listPrintHeader() { include '../main_header.php'; } /** * Prints the HTML footer. */ protected function listPrintFooter() { ?>
description) * * @return array attribute list */ private function listGetAttributeDescriptionList() { $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; } } // if not predefined, the attribute is seperated by a ":" from description else { $attr = explode(":", $temp_array[$i]); if (isset($attr[1])) { $ret[$attr[0]] = $attr[1]; } else { $ret[$attr[0]] = $attr[0]; } } } return $ret; } /** * Sets some internal parameters. */ protected function listGetParams() { // check if only PDF should be shown if (isset($_GET['printPDF'])) { $this->showPDFPage(null); exit(); } // 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 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']; } // check search suffix if (isset($_POST['suffix'])) $this->suffix = $_POST['suffix']; // new suffix selected via combobox elseif (isset($_GET['suffix'])) $this->suffix = $_GET['suffix']; // new suffix selected via combobox 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']) || isset($_POST['apply_filter'])) { $this->refresh = true; } } /** * Rereads the entries from LDAP. */ protected function listRefreshData() { // configure search filter $module_filter = get_ldap_filter($this->type); // basic filter is provided by modules $filter = "(&" . $module_filter . $this->filterPart . ")"; $attrs = $this->attrArray; $entries = searchLDAP($this->suffix, $filter, $attrs); $lastError = getLastLDAPError(); if ($lastError != null) { call_user_func_array('StatusMessage', $lastError); } $this->entries = $entries; // generate list of possible suffixes $this->possibleSuffixes = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($this->type)); } /** * Returns a list of lamListTool objects to display next to the edit/delete buttons. * * @return lamListTool[] tools */ protected function getAdditionalTools() { return array(); } /** * Returns a list of possible configuration options. * * @return array list of lamListOption objects */ protected function listGetAllConfigOptions() { $listSizeOption = new lamSelectListOption(_("Maximum list entries"), array(10, 20, 30, 50, 75, 100), self::LIST_SIZE_OPTION_NAME); $listSizeOption->setHelpID('208'); return array($listSizeOption); } /** * Prints the list configuration page. */ protected function listPrintConfigurationPage() { $this->listPrintHeader(); echo "
\n"; echo "
\n"; echo "
type . "&norefresh=true\" method=\"post\">\n"; echo "type . "list-bright\" width=\"100%\">\n"; echo "type . "list-bright\">
\n"; $tabindex = 0; $configContainer = new htmlTable(); $configContainer->addElement(new htmlSubTitle(_('Change list settings')), true); for ($i = 0; $i < sizeof($this->configOptions); $i++) { $configContainer->mergeTableElements($this->configOptions[$i]->getMetaHTML()); } $configContainer->addElement(new htmlSpacer(null, '10px'), true); $buttonContainer = new htmlTable(); $buttonContainer->addElement(new htmlButton('saveConfigOptions', _('Ok'))); $buttonContainer->addElement(new htmlButton('cancelConfigOptions', _('Cancel'))); $buttonContainer->colspan = 2; $configContainer->addElement($buttonContainer); parseHtml('', $configContainer, array(), false, $tabindex, $this->type); echo "
\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() { $sizeOption = $this->listGetConfigOptionByID(self::LIST_SIZE_OPTION_NAME); if ($sizeOption->getValue() != null) { $this->maxPageEntries = $sizeOption->getValue(); } return; } } /** * 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 */ public function __construct($name, $image, $target) { $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 */ public function getImage() { return $this->image; } /** * Returns the tool name. * This is used for the tool tip. * * @return String name */ public function getName() { 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') */ public function getLinkTarget() { 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 unique ID * @return lamConfigOption config option */ public function __construct($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(, , )) */ 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 htmlTable 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 * @param String $ID unique ID * @return lamBooleanListOption config option */ public function __construct($name, $ID) { parent::__construct($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(, , )) */ 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 htmlTable meta HTML */ public function getMetaHTML() { $return = new htmlTable(); $return->addElement(new htmlTableExtendedInputCheckbox($this->getID(), $this->isSelected(), $this->name)); return $return; } } /** * 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 */ public function __construct($name, $options, $ID) { parent::__construct($ID); $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(, , )) */ 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 htmlTable meta HTML */ public function getMetaHTML() { $return = new htmlTable(); $return->addElement(new htmlTableExtendedSelect($this->getID(), $this->options, array($this->getValue()), $this->name, $this->helpID)); return $return; } } ?>