add(new htmlOutputText(_('Tree view'))); $suffix = empty($settings[self::TREE_SUFFIX_CONFIG]) ? '' : $settings[self::TREE_SUFFIX_CONFIG]; $row->add(new htmlResponsiveInputField(_('Tree suffix'), self::TREE_SUFFIX_CONFIG, $suffix, '203')); $row->addVerticalSpacer('1rem'); return $row; } /** * {@inheritDoc} */ public function checkConfigurationOptions(array $settings): array { $errors = []; $roots = self::getRootDns($settings); foreach ($roots as $root) { if (!get_preg($root, 'dn')) { $errors[] = ['ERROR', _('Tree suffix is invalid.'), htmlspecialchars($root)]; } } return $errors; } /** * Returns the list of configured root DNs. * * @param array|null $settings tool settings * @return string[] root DNs */ public static function getRootDns(?array $settings = null): array { $roots = []; $toolSettings = $settings; if ($toolSettings === null) { $toolSettings = $_SESSION['config']->getToolSettings(); } if (!empty($toolSettings[self::TREE_SUFFIX_CONFIG])) { $roots = explode(';', $toolSettings[self::TREE_SUFFIX_CONFIG]); } return $roots; } }