Ignore:
Timestamp:
11/06/09 09:50:22 (14 years ago)
Author:
rafaelraymundo
Message:

Ticket #704 - Incluido outro campo para busca utilizando atributo do LDAP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php

    r1419 r1598  
    4141                        'pgp_key'       => true, 
    4242                        'notes'         => true, 
    43                          
    44                         /* Array fields */ 
    4543                        'companies'     => true, 
    4644                        'relations'     => true, 
     
    115113                 
    116114                */ 
    117                 function find($what, $rules=false, $other=false) 
     115                function find($what, $rules=false, $other=false, $area=false) 
    118116                { 
    119117                        $restric_fields = $this->get_restrictions_without_branch($rules); 
     
    128126                                } 
    129127                        } 
    130                          
     128 
    131129                        $fields = array_unique($fields); 
    132                          
    133                         $filter = $this->process_restrictions($rules, $trans_f); 
    134                         // Find objects where 'mail' attribute is not null. 
     130                         
     131            //Testa se a busca foi realizada com aspas 
     132            $rules_search = $rules[3]['value']; 
     133            $rules_len = (strlen($rules_search)) -1; 
     134 
     135            if((($rules_search{1}) == "\"") && (($rules_search{$rules_len -1}) == "\"")){ 
     136                                $rules_search = substr($rules_search,2,$rules_len-3); 
     137                                $filter = "(&(|(objectClass=phpgwAccount))(&(!(phpgwAccountVisible=-1)))(|(cn=* $rules_search *)(cn=$rules_search *)(cn=* $rules_search)))"; 
     138            } 
     139            else{ 
     140                                $filter = $this->process_restrictions($rules, $trans_f); 
     141            } 
     142                         
     143            if ($area) 
     144            { 
     145                 $obj = CreateObject('phpgwapi.config','contactcenter'); 
     146                 $opts = $obj->read_repository(); 
     147                 $filter = substr($filter,0,-1) .'(' . $opts['cc_ldap_atrib'] . '=*' . $area . '*))'; 
     148                 $opts = null; 
     149                 $obj = null; 
     150            } 
     151            // Find objects where 'mail' attribute is not null. 
    135152                        $filter = "(&".$filter."(mail=*))"; 
    136                         if("ou" === strtolower(substr($this->src_info['context'], 0, 2)) || 
    137                                 (trim($rules[0]['value']) == "phpgwAccount"))    
    138                         {                        
    139                                 $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], true); 
    140                                 $result_r = ldap_search($ldap , $this->src_info['context'], $filter, $fields, 0, $this->src_info['max_results']); 
    141                         } 
     153 
     154                        if(strstr($this->src_info['context'], "ldap://")) { 
     155                                $refer_context  = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $this->src_info['context'])); 
     156                                $host   = preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $this->src_info['context']); 
     157                                $this->src_info['host'] = $host; 
     158                        } 
     159                        if($refer_context || "ou" === strtolower(substr($this->src_info['context'], 0, 2))) 
     160                        { 
     161                                $followReferral = false; 
     162                        } 
     163                        elseif(trim($rules[4]['value']) != "inetOrgPerson") 
     164                        { 
     165                                $followReferral = true; 
     166                        } 
    142167                        else 
    143168                        {                                
     
    145170                        } 
    146171                         
     172                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], $followReferral); 
     173                        $result_r = ldap_search($ldap ,($refer_context  ? $refer_context  : $this->src_info['context']), $filter, $fields, 0, $this->src_info['max_results']); 
    147174 
    148175                        if (!$result_r) 
     
    192219                                $i++; 
    193220                        } 
    194                         usort($return, array($this, "compareObjects"));                                                  
     221                        usort($return, array($this, "compareObjects")); 
    195222                        return $return; 
    196223                } 
    197224                // Compare function for usort. 
    198                 function compareObjects($a, $b) {                                                
     225                function compareObjects($a, $b) { 
    199226                        return strnatcasecmp($a['names_ordered'], $b['names_ordered']); 
    200227                } 
     
    580607                        } 
    581608 
    582                          
     609//                      print_r($contact); 
    583610                         
    584611                //      $contact_data = $this->fields; 
     
    598625                                                $l_fields['company_name']  = $this->trans_table['contact.company.company_name']; 
    599626                                                $l_fields['title']         = $this->trans_table['contact.business_info.title']; 
    600                                                 $l_fields['department']    = $this->trans_table['contact.business_info.department']; 
     627                                                //$l_fields['department']    = $this->trans_table['contact.business_info.department']; 
    601628                                                $l_fields['company_notes'] = $this->trans_table['contact.company.company_notes']; 
    602                                                  
     629 
     630                                                //Relaciona o array com o atributo 'ou' do RHDS; tambem verifica se a 
     631                                                //preferencia esta configurada para exibir o campo 
     632                                                if(isset($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['departmentShow']) && $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['departmentShow']) 
     633                                                { 
     634                                                        $l_fields['department']    = $this->trans_table['contact.business_info.department']; 
     635                                                } 
     636                                                //Relaciona o array com o atributo 'employeeNumber' do RHDS; tambem verifica se a 
     637                                                //preferencia esta configurada para exibir o campo 
     638                                                if(isset($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['empNumShow']) && $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['empNumShow']) 
     639                                                { 
     640                                                        $l_fields['empNumber']     = $this->trans_table['contact.business_info.empNumber']; 
     641                                                } 
     642                                                //Relaciona o array com o atributo 'mobile' do RHDS; tambem verifica se a 
     643                                                //preferencia esta configurada para exibir o campo 
     644                                                if(isset($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['cellShow']) && $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['cellShow']) 
     645                                                { 
     646                                                        $l_fields['celPhone']     = $this->trans_table['contact.business_info.celPhone']; 
     647                                                } 
     648 
    603649                                                $contact_data['companies'] = array(); 
    604650                                                foreach($l_fields as $l_field => $l_value) 
     
    920966                                                        $l_fields['company_notes'] = $this->trans_table['contact.company.company_notes']; 
    921967 
     968                                                        //Relaciona o array com o atributo 'employeeNumber' do RHDS 
     969                                                        if(isset($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['empNumberShow']) && $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['empNumberShow']) 
     970                                                        { 
     971                                                                $l_fields['empNumber']     = $this->trans_table['contact.business_info.empNumber']; 
     972                                                        } 
     973                                                        //Relaciona o array com o atributo 'mobile' do RHDS 
     974                                                        $l_fields['celPhone']     = $this->trans_table['contact.business_info.celPhone']; 
     975 
     976                                                        //Relaciona o array com o atributo 'mobile' do RHDS 
     977                                                        $l_fields['celPhone']     = $this->trans_table['contact.business_info.celPhone']; 
     978 
    922979                                                        $contact_data['companies'] = array(); 
    923980                                                        foreach($l_fields as $l_field => $l_value) 
Note: See TracChangeset for help on using the changeset viewer.