Changeset 758


Ignore:
Timestamp:
04/22/09 14:12:10 (15 years ago)
Author:
niltonneto
Message:

Commit revertido para revisão [677].

Location:
tags/expressoMail1_2/1.233/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tags/expressoMail1_2/1.233/inc/class.db_functions.inc.php

    r752 r758  
    1010        var $db; 
    1111        var $user_id; 
    12         var $related_ids;  
    1312         
    1413        function db_functions(){ 
     
    3130                $result = array(); 
    3231                $stringDropDownContacts = '';            
    33                  
    34                 $query_related = $this->get_query_related('A.id_owner'); // field name for owner 
     32                // Traz primeiro os usuarios que compartilharam com o usuario logado: 
     33                $query = 'select id_related from phpgw_cc_contact_rels where id_contact='.$this -> user_id.' and id_typeof_contact_relation=1'; 
     34                // Somente do usuario logado 
     35                $query_related = 'A.id_owner ='.$this -> user_id; 
     36                if (!$this->db->query($query)) 
     37                return null;                     
     38                while($this->db->next_record()){ 
     39                        $row = $this->db->row(); 
     40                        $result[] = $row['id_related']; 
     41                } 
     42                $ids_related = implode(",",$result); 
     43 
     44                // Se houver contatos compartilhados então altera a query. 
     45                if($ids_related)                 
     46                        $query_related = '(A.id_owner ='.$this -> user_id.' or A.id_owner in ('.$ids_related.'))'; 
    3547                         
    3648                // Traz os contatos pessoais e compartilhados 
     
    3850                        'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
    3951                        'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
    40                         'and B.id_typeof_contact_connection = 1 and ('.$query_related.') group by '.  
    41                         'A.names_ordered,C.connection_value     order by lower(A.names_ordered)'; 
    42                  
     52                        'and B.id_typeof_contact_connection = 1 and '.$query_related.' group by '.  
     53                        'A.names_ordered,C.connection_value     order by A.names_ordered'; 
     54 
    4355        if (!$this->db->query($query)) 
    4456                return null; 
     
    5971                return $stringDropDownContacts; 
    6072        } 
    61         // Get Related Ids for sharing contacts or groups. 
    62         function get_query_related($field_name){                 
    63                 $query_related = $field_name .'='.$this -> user_id; 
    64                 // Only at first time, it gets all related ids... 
    65                 if(!$this->related_ids) { 
    66                         $query = 'select id_related from phpgw_cc_contact_rels where id_contact='.$this -> user_id.' and id_typeof_contact_relation=1';          
    67                         if (!$this->db->query($query)){ 
    68                 return $query_related; 
    69                         } 
    70                          
    71                         while($this->db->next_record()){ 
    72                                 $row = $this->db->row(); 
    73                                 $result[] = $row['id_related']; 
    74                         } 
    75                         if($result) 
    76                                 $this->related_ids = implode(",",$result); 
    77                 } 
    78                 if($this->related_ids) 
    79                         $query_related .= ' or '.$field_name.' in ('.$this->related_ids.')'; 
    80                  
    81                 return $query_related; 
    82         } 
     73         
    8374        function get_cc_groups()  
    8475        { 
     
    8677                $stringDropDownContacts = '';                    
    8778                $result = array(); 
    88                 $query_related = $this->get_query_related('owner'); // field name for 'owner'            
    89                 $query = 'select title, short_name, owner from phpgw_cc_groups where '.$query_related.' order by lower(title)'; 
    90  
     79                $query = 'select title, short_name from phpgw_cc_groups where owner ='.$this -> user_id.' order by title'; 
    9180                // Executa a query  
    9281                if (!$this->db->query($query)) 
     
    9584                while($this->db->next_record()) 
    9685                        $result[] = $this->db->row(); 
    97  
    98                 // Se houver grupos ....                                 
     86                // Se houver grupos .... 
    9987                if (count($result) != 0)  
    100                 { 
    101                         // Create Ldap Object, if exists related Ids for sharing groups. 
    102                         if($this->related_ids){ 
    103                                 $_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids']= array(); 
    104                                 include_once("class.ldap_functions.inc.php"); 
    105                                 $ldap = new ldap_functions(); 
    106                         } 
    107                         foreach($result as $group){ 
    108                                 // Searching uid (LDAP), if exists related Ids for sharing groups. 
    109                                 // Save into user session. It will used before send mail (verify permission). 
    110                                 if(!$_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'][$group['owner']] && $ldap){                                        
    111                                         $_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'][$group['owner']] = $ldap -> uidnumber2uid($group['owner']); 
    112                                 } 
    113                                 if($this->user_id != $group['owner']) 
    114                                         $owneruid = "::".$_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'][$group['owner']]; 
    115  
    116                                 $stringDropDownContacts .=  $group['title']. ';' . ($group['short_name'].$owneruid) . ','; 
    117                         } 
     88                {        
     89                        foreach($result as $group) 
     90                                $stringDropDownContacts .=  $group['title']. ';' . $group['short_name'] . ','; 
    11891                        //Retira ultima virgula. 
    11992                        $stringDropDownContacts = substr($stringDropDownContacts,0,(strlen($stringDropDownContacts) - 1)); 
    12093                } 
    12194                else 
    122                         return null;             
     95                        return null; 
     96                         
    12397                return $stringDropDownContacts; 
    12498        } 
     
    126100        function getContactsByGroupAlias($alias) 
    127101        { 
    128                 list($alias,$uid) = explode("::",$alias);                
    129                 $cc_related_ids = $_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'];             
    130                 // Explode personal group, If exists related ids (the user has permission to send email). 
    131                 if(is_array($cc_related_ids) && $uid){ 
    132                         $owner =  array_search($uid,$cc_related_ids);                    
    133                 } 
    134102                 
    135103                $query = "select C.id_connection, A.names_ordered, C.connection_value from phpgw_cc_contact A, ". 
     
    137105                "A.id_contact = B.id_contact and B.id_connection = C.id_connection ". 
    138106                "and B.id_typeof_contact_connection = 1 and ". 
    139                 "A.id_owner =".($owner ? $owner : $this->user_id)." and ".                       
     107                "A.id_owner =".$this -> user_id." and ".                         
    140108                "D.id_group = E.id_group and ". 
    141                 "D.id_connection = C.id_connection and E.short_name = '".$alias."'"; 
     109                "D.id_connection = C.id_connection and E.short_name = '".$alias. 
     110                "' order by A.names_ordered"; 
    142111 
    143112                if (!$this->db->query($query)) 
     
    167136 
    168137                                $alias = substr($array_addrs[$i], strpos($array_addrs[$i],'<'), strpos($array_addrs[$i],'>'));                           
    169                                 $alias = str_replace('<','', str_replace('>','',$alias)); 
    170                                                                                          
     138                                $alias = str_replace('<','', str_replace('>','',$alias));                                                                        
    171139                                $arrayContacts = $this -> getContactsByGroupAlias($alias); 
    172140 
  • tags/expressoMail1_2/1.233/inc/class.ldap_functions.inc.php

    r752 r758  
    612612                return false; 
    613613        } 
    614         function uidnumber2uid($uidnumber) 
    615         { 
    616                 // do not follow the referral 
    617                 $this->ldapRootConnect(false); 
    618                 if ($this->ds) 
    619                 { 
    620                         $filter="(&(phpgwAccountType=u)(uidnumber=$uidnumber))"; 
    621                         $justthese = array("uid"); 
    622                         $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese); 
    623                         if(!$sr) 
    624                                 return false; 
    625                         $info = ldap_get_entries($this->ds, $sr); 
    626                         return $info[0]["uid"][0]; 
    627                 } 
    628                 return false; 
    629         } 
    630614        function getSharedUsersFrom($params){ 
    631615                $filter = ''; 
Note: See TracChangeset for help on using the changeset viewer.