Ignore:
Timestamp:
08/06/07 08:54:16 (17 years ago)
Author:
niltonneto
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoAdmin1_2/inc/class.functions.inc.php

    r33 r46  
    103103                                                return true; 
    104104                                        break; 
     105                                case edit_email_groups: 
     106                                        if ($array_acl[edit_email_groups]) 
     107                                                return true; 
     108                                        break; 
    105109                                 
    106110                                case list_maillists: 
     
    175179                function read_acl($account_lid) 
    176180                {  
    177                         /* 
    178                         $query = "SELECT * FROM phpgw_expressoadmin WHERE manager_lid = '" . $account_lid . "'";  
    179                         $GLOBALS['phpgw']->db->query($query); 
    180                         while($GLOBALS['phpgw']->db->next_record()) 
    181                         { 
    182                                 $result[] = $GLOBALS['phpgw']->db->row(); 
    183                         } 
    184                         */ 
    185181                        $result = $this->db_functions->read_acl($account_lid); 
    186182                        $context_array = ldap_explode_dn($result[0]['context'], 1); 
    187                         $tmp = array_shift($context_array); 
    188                         $result[0]['context_display'] = implode(".", $context_array); 
     183                        $result[0]['context_display'] = ldap_dn2ufn ( $result[0]['context'] ); 
    189184                        return $result; 
    190185                } 
    191186                 
    192187                // Make a array read humam 
    193                 // Last acl:    33.554.432 
     188                // Last acl:    33.554.432, 67.108.864 
    194189                function make_array_acl($acl) 
    195190                { 
     
    202197                        $array_acl['edit_groups'] = $acl & 32; 
    203198                        $array_acl['delete_groups'] = $acl & 64; 
     199                        $array_acl['edit_email_groups'] = $acl & 67108864; 
    204200                        $array_acl['change_users_password'] = $acl & 128; 
    205201                        $array_acl['change_users_quote'] = $acl & 262144; 
     
    234230                                 
    235231                                $justthese = array("uidnumber", "uid", "cn", "mail"); 
    236                                 $filter="(&(phpgwAccountType=u)(|(uid=*".$query."*)(sn=*".$query."*)(cn=*".$query."*)(givenName=*".$query."*)(mail=$query*)))"; 
     232                                $filter="(&(phpgwAccountType=u)(|(uid~=".$query.")(sn~=".$query.")(cn~=".$query.")(givenName~=".$query.")(mail~=$query)(mailAlternateAddress~=$query)))"; 
    237233                                $search=ldap_search($ldap_conn, $context, $filter, $justthese); 
    238234                                ldap_sort($ldap_conn, $search, "uid"); 
     
    470466                 
    471467                // Get list of all levels, this function is used for sectors module. 
     468                /* 
    472469                function get_sectors_list($context) 
    473470                { 
     
    477474         
    478475                        if ($connection) 
    479                         { 
     476                        {                                
    480477                                $bind=ldap_bind($connection); 
    481478                                $filter="ou=*"; 
    482479                                $justthese = array("ou"); 
    483480                                $search=ldap_list($connection, $context, $filter, $justthese); 
    484                                 ldap_sort($connection ,$search, "ou"); 
     481                                ldap_sort($connection, $search, "ou"); 
    485482                                $info = ldap_get_entries($connection, $search); 
    486483                                for ($i=0; $i<$info["count"]; $i++) 
     
    496493                        $this->level--; 
    497494                        return $this->sectors_list; 
     495                } 
     496                */ 
     497                 
     498                // Get list of all levels, this function is used for sectors module. 
     499                function get_sectors_list($context, $selected='', $referral=false ,$show_invisible_ou=false) 
     500                { 
     501                        $dn                     = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 
     502                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 
     503                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 
     504                         
     505                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 
     506                         
     507                        if ($referral) 
     508                                ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); 
     509                        else 
     510                                ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 
     511                         
     512                        ldap_bind($ldap_conn,$dn,$passwd); 
     513                         
     514                        $justthese = array("dn"); 
     515                        $filter = "(ou=*)"; 
     516                        $search=ldap_search($ldap_conn, $context, $filter, $justthese); 
     517                 
     518                ldap_sort($ldap_conn, $search, "ou"); 
     519                $info = ldap_get_entries($ldap_conn, $search); 
     520                        ldap_close($ldap_conn); 
     521 
     522                        // Retiro o count do array info e inverto o array para ordenação. 
     523                for ($i=0; $i<$info["count"]; $i++) 
     524            { 
     525                                $dn = $info[$i]["dn"]; 
     526                                 
     527                                // Necessário, pq em uma busca com ldapsearch ou=*, traz tb o próprio ou.  
     528                                if (strtolower($dn) == $context) 
     529                                        continue; 
     530 
     531                                $array_dn = ldap_explode_dn ( $dn, 1 ); 
     532 
     533                $array_dn_reverse  = array_reverse ( $array_dn, true ); 
     534 
     535                                // Retirar o indice count do array. 
     536                                array_pop ( $array_dn_reverse ); 
     537 
     538                                $inverted_dn[$dn] = implode ( "#", $array_dn_reverse ); 
     539                        } 
     540 
     541                        // Ordenação 
     542                        natcasesort($inverted_dn); 
     543                         
     544                        // Construção do select 
     545                        $level = 0; 
     546                        $options = array(); 
     547                        foreach ($inverted_dn as $dn=>$invert_ufn) 
     548                        { 
     549                $display = ''; 
     550 
     551                $array_dn_reverse = explode ( "#", $invert_ufn ); 
     552                $array_dn  = array_reverse ( $array_dn_reverse, true ); 
     553 
     554                $level = count( $array_dn ) - (int)(count(explode(",", $GLOBALS['phpgw_info']['server']['ldap_context'])) + 1); 
     555 
     556                if ($level == 0) 
     557                        $display .= '+'; 
     558                else  
     559                { 
     560                                        for ($i=0; $i<$level; $i++) 
     561                                                $display .= '---'; 
     562                } 
     563 
     564                reset ( $array_dn ); 
     565                $display .= ' ' . (current ( $array_dn ) ); 
     566                                 
     567                                $dn = trim(strtolower($dn)); 
     568                                $options[$dn] = $display; 
     569                } 
     570            return $options; 
    498571                } 
    499572                 
Note: See TracChangeset for help on using the changeset viewer.