roundcubemail/plugins/acl/acl.php
function acl_autocomplete()
    {
        $this->load_config();

        $search = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC, true);
        $reqid  = rcube_utils::get_input_value('_reqid', rcube_utils::INPUT_GPC);
        $users  = array();
        $keys   = array();

        if ($this->init_ldap()) {
            $max  = (int) $this->rc->config->get('autocomplete_max', 15);
            $mode = (int) $this->rc->config->get('addressbook_search_mode');

            $this->ldap->set_pagesize($max);
            $result = $this->ldap->search('*', $search, $mode);

            foreach ($result->records as $record) {
                $user = $record['uid'];

                if (is_array($user)) {
                    $user = array_filter($user);
                    $user = $user[0];
                }

                if ($user) {
                    $display = rcube_addressbook::compose_search_name($record);
                    $user    = array('name' => $user, 'display' => $display);
                    $users[] = $user;
                    $keys[]  = $display ?: $user['name'];
                }
            }

            if ($this->rc->config->get('acl_groups')) {
                $prefix      = $this->rc->config->get('acl_group_prefix');
                $group_field = $this->rc->config->get('acl_group_field', 'name');
                $result      = $this->ldap->list_groups($search, $mode);

                foreach ($result as $record) {
                    $group    = $record['name'];
                    $group_id = is_array($record[$group_field]) ? $record[$group_field][0] : $record[$group_field];

                    if ($group) {
                        $users[] = array('name' => ($prefix ?: '') . $group_id, 'display' => $group, 'type' => 'group');
                        $keys[]  = $group;
                    }
                }
            }
        }

        if (count($users)) {
            // sort users index
            asort($keys, SORT_LOCALE_STRING);
            // re-sort users according to index
            foreach ($keys as $idx => $val) {
                $keys[$idx] = $users[$idx];
            }
            $users = array_values($keys);
        }

        $this->rc->output->command('ksearch_query_results', $users, $search, $reqid);
        $this->rc->output->send();
    }
function acl_autocomplete()
    {
        $this->load_config();

        $search = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC, true);
        $reqid  = rcube_utils::get_input_value('_reqid', rcube_utils::INPUT_GPC);
        $users  = array();
        $keys   = array();

        if ($this->init_ldap()) {
            $max  = (int) $this->rc->config->get('autocomplete_max', 15);
            $mode = (int) $this->rc->config->get('addressbook_search_mode');

            $this->ldap->set_pagesize($max);
            $result = $this->ldap->search('*', $search, $mode);

            foreach ($result->records as $record) {
                $user = $record['uid'];

                if (is_array($user)) {
                    $user = array_filter($user);
                    $user = $user[0];
                }

                if ($user) {
                    $display = rcube_addressbook::compose_search_name($record);
                    $user    = array('name' => $user, 'display' => $display);
                    $users[] = $user;
                    $keys[]  = $display ?: $user['name'];
                }
            }

            if ($this->rc->config->get('acl_groups')) {
                $prefix      = $this->rc->config->get('acl_group_prefix');
                $group_field = $this->rc->config->get('acl_group_field', 'name');
                $result      = $this->ldap->list_groups($search, $mode);

                foreach ($result as $record) {
                    $group    = $record['name'];
                    $group_id = is_array($record[$group_field]) ? $record[$group_field][0] : $record[$group_field];

                    if ($group) {
                        $users[] = array('name' => ($prefix ?: '') . $group_id, 'display' => $group, 'type' => 'group');
                        $keys[]  = $group;
                    }
                }
            }
        }

        if (count($users)) {
            // sort users index
            asort($keys, SORT_LOCALE_STRING);
            // re-sort users according to index
            foreach ($keys as $idx => $val) {
                $keys[$idx] = $users[$idx];
            }
            $users = array_values($keys);
        }

        $this->rc->output->command('ksearch_query_results', $users, $search, $reqid);
        $this->rc->output->send();
    }
function acl_autocomplete ( ) { $ this -> load_config ( ) ; $ search = rcube_utils :: get_input_value ( '_search' , rcube_utils :: INPUT_GPC , true ) ; $ reqid = rcube_utils :: get_input_value ( '_reqid' , rcube_utils :: INPUT_GPC ) ; $ users = array ( ) ; $ keys = array ( ) ; if ( $ this -> init_ldap ( ) ) { $ max = ( int ) $ this -> rc -> config -> get ( 'autocomplete_max' , 15 ) ; $ mode = ( int ) $ this -> rc -> config -> get ( 'addressbook_search_mode' ) ; $ this -> ldap -> set_pagesize ( $ max ) ; $ result = $ this -> ldap -> search ( '*' , $ search , $ mode ) ; foreach ( $ result -> records as $ record ) { $ user = $ record [ 'uid' ] ; if ( is_array ( $ user ) ) { $ user = array_filter ( $ user ) ; $ user = $ user [ 0 ] ; } if ( $ user ) { $ display = rcube_addressbook :: compose_search_name ( $ record ) ; $ user = array ( 'name' => $ user , 'display' => $ display ) ; $ users [ ] = $ user ; $ keys [ ] = $ display ? : $ user [ 'name' ] ; } } if ( $ this -> rc -> config -> get ( 'acl_groups' ) ) { $ prefix = $ this -> rc -> config -> get ( 'acl_group_prefix' ) ; $ group_field = $ this -> rc -> config -> get ( 'acl_group_field' , 'name' ) ; $ result = $ this -> ldap -> list_groups ( $ search , $ mode ) ; foreach ( $ result as $ record ) { $ group = $ record [ 'name' ] ; $ group_id = is_array ( $ record [ $ group_field ] ) ? $ record [ $ group_field ] [ 0 ] : $ record [ $ group_field ] ; if ( $ group ) { $ users [ ] = array ( 'name' => ( $ prefix ? : '' ) . $ group_id , 'display' => $ group , 'type' => 'group' ) ; $ keys [ ] = $ group ; } } } } if ( count ( $ users ) ) { // sort users index asort ( $ keys , SORT_LOCALE_STRING ) ; // re-sort users according to index foreach ( $ keys as $ idx => $ val ) { $ keys [ $ idx ] = $ users [ $ idx ] ; } $ users = array_values ( $ keys ) ; } $ this -> rc -> output -> command ( 'ksearch_query_results' , $ users , $ search , $ reqid ) ; $ this -> rc -> output -> send ( ) ; }
Handler for user login autocomplete request
Handler for user login autocomplete request