Changeset 757
- Timestamp:
- 04/22/09 13:59:35 (14 years ago)
- Location:
- trunk/expressoMail1_2/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.db_functions.inc.php
r673 r757 10 10 var $db; 11 11 var $user_id; 12 var $related_ids; 12 13 13 14 function db_functions(){ … … 30 31 $result = array(); 31 32 $stringDropDownContacts = ''; 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.'))'; 33 34 $query_related = $this->get_query_related('A.id_owner'); // field name for owner 47 35 48 36 // Traz os contatos pessoais e compartilhados … … 50 38 'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 51 39 'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 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 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 55 43 if (!$this->db->query($query)) 56 44 return null; … … 71 59 return $stringDropDownContacts; 72 60 } 73 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 } 74 83 function get_cc_groups() 75 84 { … … 77 86 $stringDropDownContacts = ''; 78 87 $result = array(); 79 $query = 'select title, short_name from phpgw_cc_groups where owner ='.$this -> user_id.' order by title'; 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 80 91 // Executa a query 81 92 if (!$this->db->query($query)) … … 84 95 while($this->db->next_record()) 85 96 $result[] = $this->db->row(); 86 // Se houver grupos .... 97 98 // Se houver grupos .... 87 99 if (count($result) != 0) 88 { 89 foreach($result as $group) 90 $stringDropDownContacts .= $group['title']. ';' . $group['short_name'] . ','; 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 } 91 118 //Retira ultima virgula. 92 119 $stringDropDownContacts = substr($stringDropDownContacts,0,(strlen($stringDropDownContacts) - 1)); 93 120 } 94 121 else 95 return null; 96 122 return null; 97 123 return $stringDropDownContacts; 98 124 } … … 100 126 function getContactsByGroupAlias($alias) 101 127 { 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 } 102 134 103 135 $query = "select C.id_connection, A.names_ordered, C.connection_value from phpgw_cc_contact A, ". … … 105 137 "A.id_contact = B.id_contact and B.id_connection = C.id_connection ". 106 138 "and B.id_typeof_contact_connection = 1 and ". 107 "A.id_owner =". $this -> user_id." and ".139 "A.id_owner =".($owner ? $owner : $this->user_id)." and ". 108 140 "D.id_group = E.id_group and ". 109 "D.id_connection = C.id_connection and E.short_name = '".$alias. 110 "' order by A.names_ordered"; 141 "D.id_connection = C.id_connection and E.short_name = '".$alias."'"; 111 142 112 143 if (!$this->db->query($query)) … … 136 167 137 168 $alias = substr($array_addrs[$i], strpos($array_addrs[$i],'<'), strpos($array_addrs[$i],'>')); 138 $alias = str_replace('<','', str_replace('>','',$alias)); 169 $alias = str_replace('<','', str_replace('>','',$alias)); 170 139 171 $arrayContacts = $this -> getContactsByGroupAlias($alias); 140 172 -
trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
r657 r757 612 612 return false; 613 613 } 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 } 614 630 function getSharedUsersFrom($params){ 615 631 $filter = '';
Note: See TracChangeset
for help on using the changeset viewer.