Changeset 37 for trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
- Timestamp:
- 06/29/07 15:19:52 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
r27 r37 13 13 $this->ds = ldap_connect($this->ldap_host); 14 14 ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); 15 ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); 15 ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); 16 16 ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']); 17 17 } … … 22 22 $this->ds = ldap_connect($this->ldap_host); 23 23 ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); 24 ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); 24 ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); 25 25 ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'],$_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); 26 26 … … 42 42 if ($this->ds) 43 43 { 44 $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(|(cn=*$search_for*)(sn=*$search_for*)(mail=$search_for*)))"; 45 $justthese = array("cn", "mail", "telephoneNumber", "phpgwAccountVisible"); 44 if (($field != 'null') && ($ID != 'null')) 45 { 46 $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(|(cn=*$search_for*)(sn=*$search_for*)(mail=$search_for*)))"; 47 $justthese = array("cn", "mail", "telephoneNumber", "phpgwAccountVisible", "uid"); 48 } 49 else 50 { 51 $filter="(&(phpgwAccountType=u)(|(cn=*$search_for*)(sn=*$search_for*)(mail=$search_for*)))"; 52 $justthese = array("cn", "mail", "telephoneNumber", "phpgwAccountVisible", "jpegPhoto", "uid"); 53 } 54 46 55 $sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese); 47 56 … … 53 62 return $return; 54 63 } 55 56 64 $info = ldap_get_entries($this->ds, $sr); 65 57 66 $tmp = array(); 58 67 for ($i=0; $i<$info["count"]; $i++) … … 60 69 if ($info[$i]["phpgwaccountvisible"][0] == '-1') 61 70 continue; 62 $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] ] = $info[$i]["cn"][0];71 $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count']] = $info[$i]["cn"][0]; 63 72 } 64 73 natcasesort($tmp); 65 74 66 75 $i = 0; 67 foreach ($tmp as $mail => $cn) 68 { 69 $contacts_result[$i] = array(); 70 $contacts_result[$i]["cn"] = $cn; 71 list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"]) = split ('%', $mail); 72 $i++; 76 if (($field != 'null') && ($ID != 'null')) 77 { 78 foreach ($tmp as $info => $cn) 79 { 80 $contacts_result[$i] = array(); 81 $contacts_result[$i]["cn"] = $cn; 82 list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"]) = split ('%', $info); 83 $i++; 84 } 85 } 86 else 87 { 88 $options = ''; 89 foreach ($tmp as $info => $cn) 90 { 91 $contacts_result[$i] = array(); 92 $contacts_result[$i]["cn"] = $cn; 93 list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"], $contacts_result[$i]["uid"], $contacts_result[$i]["jpegphoto"]) = split ('%', $info); 94 95 if ($contacts_result[$i]['jpegphoto']) 96 $photo_link = '<img src="./inc/show_user_photo.php?mail='.$contacts_result[$i]['mail'].'">'; 97 else 98 $photo_link = '<img src="./templates/default/images/photo.png">'; 99 100 // '<tr class="quicksearchcontacts_unselected" onClick="javascript:QuickSearchUser.select_cc(this)">' . 101 $options .= 102 '<tr class="quicksearchcontacts_unselected">' . 103 '<td class="cc" width="1%">' . 104 '<a onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result[$i]["cn"].'\', \''.$contacts_result[$i]["mail"].'\')">' . 105 $photo_link . 106 '</a>' . 107 '</td>' . 108 '<td class="cc">' . 109 '<span name="cn">' . $contacts_result[$i]['cn'] . '</span>' . '<br>' . 110 '<a onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result[$i]["cn"].'\', \''.$contacts_result[$i]["mail"].'\')">' . 111 '<font color=blue>' . 112 '<span name="mail">' . $contacts_result[$i]['mail'] . '</span>' . '<br>' . 113 '</font>' . 114 '</a>' . 115 $contacts_result[$i]['phone'] . 116 '</td>' . 117 '</tr>'; 118 $i++; 119 } 120 $contacts_result = $options; 73 121 } 74 122 } … … 198 246 //Busca usuários de um contexto e já retorna as options do select; 199 247 function get_available_users($params) 200 { 201 $this->ldapRootConnect(); 202 //Monta lista de Grupos e Usuários 203 $users = Array(); 204 $groups = Array(); 205 $user_context= $params['context']; 206 $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner']; 207 208 if ($this->ds) 209 { 210 $justthese = array("gidNumber","cn"); 211 $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese); 212 $info = ldap_get_entries($this->ds, $sr); 213 for ($i=0; $i<$info["count"]; $i++) 214 $groups[$uids=$info[$i]["gidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => g); 215 $justthese = array("phpgwaccountvisible","uidNumber","cn"); 216 $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese); 217 $info = ldap_get_entries($this->ds, $sr); 218 for ($i=0; $i<$info["count"]; $i++) 219 { 220 if ($info[$i]["phpgwaccountvisible"][0] == '-1') 221 continue; 222 $users[$uids=$info[$i]["uidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => u); 223 } 224 } 225 ldap_close($this->ds); 226 227 @asort($users); 228 @reset($users); 229 @asort($groups); 230 @reset($groups); 231 $user_options =''; 232 $group_options =''; 233 234 foreach($groups as $id => $user_array) { 235 $newId = $id.'U'; 236 $group_options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; 237 } 238 foreach($users as $id => $user_array) { 239 if($owner != $id){ 240 $newId = $id.'U'; 241 $user_options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; 242 } 243 } 244 return array("users" => $user_options, "groups" => $group_options); 245 } 248 { 249 $this->ldapRootConnect(); 250 //Monta lista de Grupos e Usuários 251 $users = Array(); 252 $groups = Array(); 253 $user_context= $params['context']; 254 $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner']; 255 256 if ($this->ds) 257 { 258 $justthese = array("gidNumber","cn"); 259 if ($params['type'] == 'search') 260 $sr=ldap_search($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese); 261 else 262 $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese); 263 $info = ldap_get_entries($this->ds, $sr); 264 for ($i=0; $i<$info["count"]; $i++) 265 $groups[$uids=$info[$i]["gidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => g); 266 $justthese = array("phpgwaccountvisible","uidNumber","cn"); 267 if ($params['type'] == 'search') 268 $sr=ldap_search($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese); 269 else 270 $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese); 271 272 $info = ldap_get_entries($this->ds, $sr); 273 for ($i=0; $i<$info["count"]; $i++) 274 { 275 if ($info[$i]["phpgwaccountvisible"][0] == '-1') 276 continue; 277 $users[$uids=$info[$i]["uidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => u); 278 } 279 } 280 ldap_close($this->ds); 281 282 @asort($users); 283 @reset($users); 284 @asort($groups); 285 @reset($groups); 286 $user_options =''; 287 $group_options =''; 288 289 foreach($groups as $id => $user_array) { 290 $newId = $id.'U'; 291 $group_options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; 292 } 293 foreach($users as $id => $user_array) { 294 if($owner != $id){ 295 $newId = $id.'U'; 296 $user_options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; 297 } 298 } 299 return array("users" => $user_options, "groups" => $group_options); 300 } 246 301 247 302 //Busca usuários de um contexto e já retorna as options do select; … … 331 386 { 332 387 $filter="(&(phpgwAccountType=u)(mail=$email))"; 333 $justthese = array("cn"," telephoneNumber","jpegPhoto");388 $justthese = array("cn","uid","telephoneNumber","jpegPhoto"); 334 389 $sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese); 335 390 $entry = ldap_first_entry($this->ds, $sr); … … 337 392 $obj = array("cn" => @ldap_get_values($this->ds, $entry, "cn"), 338 393 "email" => $email, 394 "uid" => @ldap_get_values($this->ds, $entry, "uid"), 339 395 "type" => "global", 340 396 "telefone" => @ldap_get_values($this->ds, $entry, "telephonenumber"));
Note: See TracChangeset
for help on using the changeset viewer.