Horde_Config::_configLDAP PHP Метод

_configLDAP() защищенный Метод

Subnodes will be parsed and added to both the Horde defaults and the Custom configuration parts.
protected _configLDAP ( string $ctx, DomNode $node = null, string $switchname = 'driverconfig' ) : array
$ctx string The context of the tag.
$node DomNode The DomNode representation of the tag.
$switchname string If $node is not set, the value of the tag's switchname attribute.
Результат array An associative array with the LDAP configuration tree.
    protected function _configLDAP($ctx, $node = null, $switchname = 'driverconfig')
    {
        if ($node) {
            $xpath = new DOMXPath($node->ownerDocument);
        }
        $host = $node ? explode(',', $xpath->evaluate('string(configstring[@name="hostspec"])', $node) ?: '') : array();
        $host = $this->_default($ctx . '|hostspec', $host);
        $fields = array('hostspec' => array('_type' => 'stringlist', 'required' => true, 'desc' => 'LDAP server(s)/hostname(s)', 'default' => is_array($host) ? implode(',', $host) : $host), 'port' => array('_type' => 'int', 'required' => false, 'desc' => 'Port on which LDAP is listening, if non-standard', 'default' => $this->_default($ctx . '|port', $node ? $xpath->evaluate('string(configinteger[@name="port"])', $node) ?: null : null)), 'tls' => array('_type' => 'boolean', 'required' => false, 'desc' => 'Use TLS to connect to the server?', 'default' => $this->_default($ctx . '|tls', $node ? $xpath->evaluate('string(configboolean[@name="tls"])', $node) ?: false : false)), 'timeout' => array('_type' => 'int', 'required' => false, 'desc' => 'Connection timeout', 'default' => $this->_default($ctx . '|timeout', $node ? $xpath->evaluate('string(configinteger[@name="timeout"])', $node) ?: 5 : 5)), 'version' => array('_type' => 'int', 'required' => true, 'quote' => false, 'desc' => 'LDAP protocol version', 'default' => $this->_default($ctx . '|version', $node ? $xpath->evaluate('normalize-space(configswitch[@name="version"]/text())', $node) ?: 3 : 3), 'switch' => array('2' => array('desc' => '2 (deprecated)', 'fields' => array()), '3' => array('desc' => '3', 'fields' => array()))), 'bindas' => array('desc' => 'Bind to LDAP as which user?', 'default' => $this->_default($ctx . '|bindas', $node ? $xpath->evaluate('normalize-space(configswitch[@name="bindas"]/text())', $node) ?: 'admin' : 'admin'), 'switch' => array('anon' => array('desc' => 'Bind anonymously', 'fields' => $this->_configLDAPUser($ctx, $node)), 'user' => array('desc' => 'Bind as the currently logged-in user', 'fields' => $this->_configLDAPUser($ctx, $node)), 'admin' => array('desc' => 'Bind with administrative/system credentials', 'fields' => array_merge(array('binddn' => array('_type' => 'text', 'required' => true, 'desc' => 'DN used to bind to LDAP', 'default' => $this->_default($ctx . '|binddn', $node ? $xpath->evaluate('string(configsection/configstring[@name="binddn"])', $node) ?: '' : '')), 'bindpw' => array('_type' => 'text', 'required' => true, 'desc' => 'Password for bind DN', 'default' => $this->_default($ctx . '|bindpw', $node ? $xpath->evaluate('string(configsection/configstring[@name="bindpw"])', $node) ?: '' : ''))), $this->_configLDAPUser($ctx, $nod))))));
        if (isset($node) && $node->getAttribute('excludebind')) {
            $excludes = explode(',', $node->getAttribute('excludebind'));
            foreach ($excludes as $exclude) {
                unset($fields['bindas']['switch'][$exclude]);
            }
        }
        if (isset($node) && $node->getAttribute('baseconfig') == 'true') {
            return array('desc' => 'Use LDAP?', 'default' => $this->_default($ctx . '|' . $node->getAttribute('switchname'), $node ? $xpath->evaluate('normalize-space(text())', $node) ?: false : false), 'switch' => array('false' => array('desc' => 'No', 'fields' => array()), 'true' => array('desc' => 'Yes', 'fields' => $fields)));
        }
        $standardFields = array('basedn' => array('_type' => 'text', 'required' => true, 'desc' => 'Base DN', 'default' => $this->_default($ctx . '|basedn', $node ? $xpath->evaluate('string(configstring[@name="basedn"])', $node) ?: '' : '')), 'scope' => array('_type' => 'enum', 'required' => true, 'desc' => 'Search scope', 'default' => $this->_default($ctx . '|scope', $node ? $xpath->evaluate('normalize-space(configenum[@name="scope"]/text())', $node) ?: '' : ''), 'values' => array('sub' => 'Subtree search', 'one' => 'One level')));
        list($default, $isDefault) = $this->__default($ctx . '|' . (isset($node) ? $node->getAttribute('switchname') : $switchname), 'horde');
        $config = array('desc' => 'Driver configuration', 'default' => $default, 'is_default' => $isDefault, 'switch' => array('horde' => array('desc' => 'Horde defaults', 'fields' => $standardFields), 'custom' => array('desc' => 'Custom parameters', 'fields' => $fields + $standardFields)));
        if (isset($node) && $node->hasChildNodes()) {
            $cur = array();
            $this->_parseLevel($cur, $node->childNodes, $ctx);
            $config['switch']['horde']['fields'] = array_merge($config['switch']['horde']['fields'], $cur);
            $config['switch']['custom']['fields'] = array_merge($config['switch']['custom']['fields'], $cur);
        }
        return $config;
    }