type->getScope() . "-bright\">";
echo "
\n";
$refreshParam = '&norefresh=true';
if (isset($_GET['refresh']) && ($_GET['refresh'] == 'true')) {
$refreshParam = '&refresh=true';
}
echo "
description)
*
* @return array attribute list
*/
protected function listGetAttributeDescriptionList() {
$attrs = $this->type->getAttributes();
$ret = array();
foreach ($attrs as $attr) {
$ret[$attr->getAttributeName()] = $attr->getAlias();
}
return $ret;
}
/**
* Sets some internal parameters.
*/
protected function listGetParams() {
if (isset($_GET['accountEditBack'])) {
$this->refresh = true;
return;
}
// check if only PDF should be shown
if (isset($_GET['printPDF'])) {
$this->showPDFPage(null);
exit();
}
// get current page
if (!empty($_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 = htmlspecialchars($_GET['sortdirection']);
}
// check search suffix
if (isset($_POST['suffix'])) {
// new suffix selected via combobox
$this->suffix = $_POST['suffix'];
}
elseif (isset($_GET['suffix'])) {
// new suffix selected via combobox
$this->suffix = $_GET['suffix'];
}
elseif (!$this->suffix) {
// default suffix
$this->suffix = $this->type->getSuffix();
}
// check if LDAP data should be refreshed
$this->refresh = true;
if (isset($_GET['norefresh'])) {
$this->refresh = false;
}
if (isset($_POST['refresh'])) {
$this->refresh = true;
}
if ((isset($_POST['apply_filter']) || isset($_POST['clear_filter']))
&& $this->serverSideFilterChanged) {
$this->refresh = true;
}
}
/**
* Rereads the entries from LDAP.
*/
protected function listRefreshData() {
// check suffix
if (!$this->suffix) {
$this->suffix = $this->type->getSuffix(); // default suffix
}
// configure search filter
$module_filter = get_ldap_filter($this->type->getId()); // basic filter is provided by modules
$filter = "(&" . $module_filter . $this->buildLDAPAttributeFilter() . ")";
$attrs = $this->attrArray;
// remove virtual attributes from list
for ($i = 0; $i < sizeof($attrs); $i++) {
if (strpos($attrs[$i], self::VIRTUAL_ATTRIBUTE_PREFIX) === 0) {
unset($attrs[$i]);
}
}
$attrs = array_values($attrs);
// include additional attributes
$additionalAttrs = $this->getAdditionalLDAPAttributesToRead();
for ($i = 0; $i < sizeof($additionalAttrs); $i++) {
if (!in_array_ignore_case($additionalAttrs[$i], $attrs)) {
$attrs[] = $additionalAttrs[$i];
}
}
$this->ldapEntries = searchLDAP($this->suffix, $filter, $attrs);
$this->entries = array();
foreach ($this->ldapEntries as $index => &$attrs) {
$this->entries[$index] = &$attrs;
}
$lastError = getLastLDAPError();
if ($lastError != null) {
call_user_func_array('StatusMessage', $lastError);
}
// generate list of possible suffixes
$this->possibleSuffixes = $this->type->getSuffixList();
}
/**
* Builds the LDAP filter based on the filter entries in the GUI.
*
* @return String LDAP filter
*/
protected function buildLDAPAttributeFilter() {
$text = '';
foreach ($this->filters as $attr => $filter) {
if (!$this->isAttributeFilteredByServer($attr)) {
continue;
}
$filterExpression = $filter;
if (strpos($filter, '^') === 0) {
$filterExpression = substr($filterExpression, 1);
}
elseif (strpos($filter, '*') !== 0) {
$filterExpression = '*' . $filterExpression;
}
if (strrpos($filter, '$') === (strlen($filter) - 1)) {
$filterExpression = substr($filterExpression, 0, -1);
}
elseif (strrpos($filter, '*') !== (strlen($filter) - 1)) {
$filterExpression = $filterExpression . '*';
}
$text .= '(' . $attr . '=' . $filterExpression . ')';
}
return $text;
}
/**
* Specifies if the given attribute name is used for server side filtering (LDAP filter string).
*
* @param string $attrName attribute name
* @return bool filter server side
*/
protected function isAttributeFilteredByServer($attrName) {
return in_array(strtolower($attrName), $this->serverSideFilterAttributes);
}
/**
* Applies any local filters for attributes that cannot be filtered server side.
*/
protected function applyLocalFilters() {
$this->entries = array();
foreach ($this->ldapEntries as $index => &$data) {
$this->entries[$index] = &$data;
}
$toFilter = array();
foreach ($this->filters as $filterAttribute => $filterValue) {
if ($this->isAttributeFilteredByServer($filterAttribute) || ($filterValue === '')) {
continue;
}
foreach ($this->entries as $index => &$data) {
if (in_array($index, $toFilter)) {
continue;
}
$regex = str_replace(array('*'), array('.*'), $filterValue);
$regex = '/' . $regex . '/i';
if (!$this->isFilterMatching($data, $filterAttribute, $regex)) {
$toFilter[] = $index;
}
}
}
foreach ($toFilter as $index) {
unset($this->entries[$index]);
}
$this->entries = array_values($this->entries);
}
/**
* Checks if the given LDAP data matches the filter.
*
* @param array $data LDAP attributes
* @param string $filterAttribute filter attribute name
* @param string $regex filter attribute regex
*/
protected function isFilterMatching(&$data, $filterAttribute, $regex) {
if (!isset($data[$filterAttribute])) {
return false;
}
foreach ($data[$filterAttribute] as $value) {
if (preg_match($regex, $value)) {
return true;
}
}
return false;
}
/**
* Forces a refresh of the LDAP data.
* Function must be called before $this->refresh option is checked to load new LDAP data (e.g. in listGetParams).
*/
protected function forceRefresh() {
$this->refresh = true;
if (isset($_GET['norefresh'])) {
unset($_GET['norefresh']);
}
}
/**
* Returns a list of additional LDAP attributes that should be read.
* This can be used to show additional data even if the user selected other attributes to show in the list.
*
* @return array additional attribute names
*/
protected function getAdditionalLDAPAttributesToRead() {
return array();
}
/**
* 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, 500, 1000), self::LIST_SIZE_OPTION_NAME);
$listSizeOption->setHelpID('208');
$listSizeOption->setValue($this->maxPageEntries);
return array($listSizeOption);
}
/**
* Prints the list configuration page.
*/
protected function listPrintConfigurationPage() {
echo "