Changeset 758
- Timestamp:
- 04/22/09 14:12:10 (14 years ago)
- 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 10 10 var $db; 11 11 var $user_id; 12 var $related_ids;13 12 14 13 function db_functions(){ … … 31 30 $result = array(); 32 31 $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.'))'; 35 47 36 48 // Traz os contatos pessoais e compartilhados … … 38 50 'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 39 51 '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 43 55 if (!$this->db->query($query)) 44 56 return null; … … 59 71 return $stringDropDownContacts; 60 72 } 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 83 74 function get_cc_groups() 84 75 { … … 86 77 $stringDropDownContacts = ''; 87 78 $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'; 91 80 // Executa a query 92 81 if (!$this->db->query($query)) … … 95 84 while($this->db->next_record()) 96 85 $result[] = $this->db->row(); 97 98 // Se houver grupos .... 86 // Se houver grupos .... 99 87 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'] . ','; 118 91 //Retira ultima virgula. 119 92 $stringDropDownContacts = substr($stringDropDownContacts,0,(strlen($stringDropDownContacts) - 1)); 120 93 } 121 94 else 122 return null; 95 return null; 96 123 97 return $stringDropDownContacts; 124 98 } … … 126 100 function getContactsByGroupAlias($alias) 127 101 { 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 }134 102 135 103 $query = "select C.id_connection, A.names_ordered, C.connection_value from phpgw_cc_contact A, ". … … 137 105 "A.id_contact = B.id_contact and B.id_connection = C.id_connection ". 138 106 "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 ". 140 108 "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"; 142 111 143 112 if (!$this->db->query($query)) … … 167 136 168 137 $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)); 171 139 $arrayContacts = $this -> getContactsByGroupAlias($alias); 172 140 -
tags/expressoMail1_2/1.233/inc/class.ldap_functions.inc.php
r752 r758 612 612 return false; 613 613 } 614 function uidnumber2uid($uidnumber)615 {616 // do not follow the referral617 $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 }630 614 function getSharedUsersFrom($params){ 631 615 $filter = '';
Note: See TracChangeset
for help on using the changeset viewer.