[2] | 1 | <?php |
---|
[176] | 2 | include_once("class.imap_functions.inc.php"); |
---|
| 3 | |
---|
| 4 | function ldapRebind($ldap_connection, $ldap_url) |
---|
| 5 | { |
---|
| 6 | @ldap_bind($ldap_connection, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']); |
---|
| 7 | } |
---|
| 8 | |
---|
[2] | 9 | class ldap_functions |
---|
| 10 | { |
---|
| 11 | var $ds; |
---|
| 12 | var $ldap_host; |
---|
| 13 | var $ldap_context; |
---|
| 14 | var $imap; |
---|
| 15 | |
---|
[108] | 16 | // usa o host e context do contact center. |
---|
[2] | 17 | function ldapConnect($refer = false){ |
---|
| 18 | $this->ldap_host = $_SESSION['phpgw_info']['expressomail']['ldap_server']['host']; |
---|
| 19 | $this->ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn']; |
---|
| 20 | $this->ds = ldap_connect($this->ldap_host); |
---|
| 21 | ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
[37] | 22 | ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); |
---|
[176] | 23 | if ($refer) |
---|
| 24 | { |
---|
| 25 | ldap_set_rebind_proc($this->ds, ldapRebind); |
---|
| 26 | } |
---|
| 27 | @ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']); |
---|
[2] | 28 | } |
---|
| 29 | |
---|
[108] | 30 | // usa o host e context do setup. |
---|
[2] | 31 | function ldapRootConnect($refer = false){ |
---|
| 32 | $this->ldap_host = $_SESSION['phpgw_info']['expressomail']['server']['ldap_host']; |
---|
| 33 | $this->ldap_context = $_SESSION['phpgw_info']['expressomail']['server']['ldap_context']; |
---|
| 34 | $this->ds = ldap_connect($this->ldap_host); |
---|
| 35 | ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
[37] | 36 | ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); |
---|
[2] | 37 | ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'],$_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); |
---|
| 38 | |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | function quicksearch($params) |
---|
| 42 | { |
---|
[95] | 43 | include_once("class.functions.inc.php"); |
---|
| 44 | $functions = new functions; |
---|
[108] | 45 | |
---|
[2] | 46 | $search_for = $params['search_for']; |
---|
| 47 | $field = $params['field']; |
---|
| 48 | $ID = $params['ID']; |
---|
| 49 | |
---|
| 50 | $contacts_result = array(); |
---|
| 51 | $contacts_result['field'] = $field; |
---|
| 52 | $contacts_result['ID'] = $ID; |
---|
| 53 | |
---|
| 54 | // follow the referral |
---|
| 55 | $this->ldapConnect(true); |
---|
[108] | 56 | |
---|
[2] | 57 | if ($this->ds) |
---|
| 58 | { |
---|
[37] | 59 | if (($field != 'null') && ($ID != 'null')) |
---|
| 60 | { |
---|
[114] | 61 | $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(|(cn=*$search_for*)(mail=$search_for*)))"; |
---|
[72] | 62 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid"); |
---|
[37] | 63 | } |
---|
| 64 | else |
---|
| 65 | { |
---|
[114] | 66 | $filter="(& (phpgwAccountType=u)(cn=*$search_for*) )"; |
---|
[72] | 67 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "jpegPhoto", "uid"); |
---|
[37] | 68 | } |
---|
| 69 | |
---|
[2] | 70 | $sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
[95] | 71 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
[2] | 72 | |
---|
[95] | 73 | if ($count_entries > 200) |
---|
| 74 | { |
---|
[108] | 75 | // Close old ldap conection |
---|
| 76 | ldap_close($this->ds); |
---|
| 77 | |
---|
| 78 | // Reopen a local ldap connection, following referral |
---|
| 79 | $this->ldapRootConnect(true); |
---|
| 80 | |
---|
[95] | 81 | $user_dn = $_SESSION['phpgw_info']['expressomail']['user']['account_dn']; |
---|
| 82 | $user_sector_dn = ldap_explode_dn ( $user_dn, false ); |
---|
| 83 | array_shift($user_sector_dn); |
---|
| 84 | array_shift($user_sector_dn); |
---|
| 85 | $user_sector_dn = implode(",", $user_sector_dn); |
---|
| 86 | |
---|
| 87 | // New search only on user sector |
---|
| 88 | $sr=ldap_search($this->ds, $user_sector_dn, $filter, $justthese); |
---|
[108] | 89 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
| 90 | |
---|
| 91 | if ($count_entries > 200){ |
---|
| 92 | $return = array(); |
---|
| 93 | $return['status'] = false; |
---|
| 94 | $return['error'] = "many results"; |
---|
| 95 | return $return; |
---|
| 96 | } |
---|
[95] | 97 | else |
---|
| 98 | { |
---|
| 99 | $quickSearch_only_in_userSector = true; |
---|
| 100 | } |
---|
| 101 | } |
---|
[37] | 102 | $info = ldap_get_entries($this->ds, $sr); |
---|
[176] | 103 | |
---|
[2] | 104 | $tmp = array(); |
---|
| 105 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 106 | { |
---|
| 107 | if ($info[$i]["phpgwaccountvisible"][0] == '-1') |
---|
| 108 | continue; |
---|
[72] | 109 | $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count']] = $info[$i]["cn"][0]; |
---|
[2] | 110 | } |
---|
| 111 | natcasesort($tmp); |
---|
| 112 | |
---|
| 113 | $i = 0; |
---|
[37] | 114 | if (($field != 'null') && ($ID != 'null')) |
---|
[2] | 115 | { |
---|
[37] | 116 | foreach ($tmp as $info => $cn) |
---|
| 117 | { |
---|
| 118 | $contacts_result[$i] = array(); |
---|
| 119 | $contacts_result[$i]["cn"] = $cn; |
---|
[72] | 120 | list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"], $contacts_result[$i]["mobile"]) = split ('%', $info); |
---|
[37] | 121 | $i++; |
---|
| 122 | } |
---|
[95] | 123 | $contacts_result['quickSearch_only_in_userSector'] = $quickSearch_only_in_userSector; |
---|
[2] | 124 | } |
---|
[37] | 125 | else |
---|
| 126 | { |
---|
| 127 | $options = ''; |
---|
[72] | 128 | |
---|
[37] | 129 | foreach ($tmp as $info => $cn) |
---|
| 130 | { |
---|
| 131 | $contacts_result[$i] = array(); |
---|
| 132 | $contacts_result[$i]["cn"] = $cn; |
---|
[72] | 133 | list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"], $contacts_result[$i]["mobile"], $contacts_result[$i]["uid"], $contacts_result[$i]["jpegphoto"]) = split ('%', $info); |
---|
[37] | 134 | |
---|
| 135 | if ($contacts_result[$i]['jpegphoto']) |
---|
| 136 | $photo_link = '<img src="./inc/show_user_photo.php?mail='.$contacts_result[$i]['mail'].'">'; |
---|
| 137 | else |
---|
| 138 | $photo_link = '<img src="./templates/default/images/photo.png">'; |
---|
| 139 | |
---|
| 140 | // '<tr class="quicksearchcontacts_unselected" onClick="javascript:QuickSearchUser.select_cc(this)">' . |
---|
[72] | 141 | $phoneUser = $contacts_result[$i]['phone']; |
---|
| 142 | |
---|
| 143 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_enabled'] && $phoneUser) { |
---|
| 144 | $phoneUser = '<a title="'.$functions->getLang("Call to Comercial Number").'" href="#" onclick="InfoContact.connectVoip(\''.$phoneUser.'\',\'com\')">'.$phoneUser.'</a>'; |
---|
| 145 | if($contacts_result[$i]['mobile']){ |
---|
| 146 | $phoneUser .= ' / <a title="'.$functions->getLang("Call to Mobile Number").'" href="#" onclick="InfoContact.connectVoip(\''.$contacts_result[$i]['mobile'].'\',\'mob\')">'.$contacts_result[$i]['mobile'].'</a>'; |
---|
| 147 | } |
---|
| 148 | } |
---|
[37] | 149 | $options .= |
---|
| 150 | '<tr class="quicksearchcontacts_unselected">' . |
---|
| 151 | '<td class="cc" width="1%">' . |
---|
[72] | 152 | '<a title="'.$functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result[$i]["cn"].'\', \''.$contacts_result[$i]["mail"].'\')">' . |
---|
[37] | 153 | $photo_link . |
---|
| 154 | '</a>' . |
---|
| 155 | '</td>' . |
---|
| 156 | '<td class="cc">' . |
---|
| 157 | '<span name="cn">' . $contacts_result[$i]['cn'] . '</span>' . '<br>' . |
---|
[72] | 158 | '<a title="'.$functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result[$i]["cn"].'\', \''.$contacts_result[$i]["mail"].'\')">' . |
---|
| 159 | '<font color=blue>' . |
---|
| 160 | '<span name="mail">' . $contacts_result[$i]['mail'] . '</span>' . '<br>' . |
---|
| 161 | '</font>' . |
---|
| 162 | '</a>' . |
---|
| 163 | $phoneUser . |
---|
[37] | 164 | '</td>' . |
---|
| 165 | '</tr>'; |
---|
| 166 | $i++; |
---|
| 167 | } |
---|
| 168 | $contacts_result = $options; |
---|
[95] | 169 | |
---|
| 170 | if ($quickSearch_only_in_userSector) |
---|
| 171 | { |
---|
| 172 | $head_option = |
---|
| 173 | '<tr class="quicksearchcontacts_unselected">' . |
---|
| 174 | '<td colspan="2" width="100%" align="center">' . |
---|
| 175 | $functions->getLang('More than 200 results were found') . '.<br>' . |
---|
| 176 | $functions->getLang('Showing only the results found in your organization') . '.'; |
---|
| 177 | '</td>' . |
---|
| 178 | '</tr>'; |
---|
| 179 | $contacts_result = $head_option . $contacts_result; |
---|
[108] | 180 | } |
---|
[37] | 181 | } |
---|
[2] | 182 | } |
---|
| 183 | ldap_close($this->ds); |
---|
| 184 | return $contacts_result; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | function get_organizations($params){ |
---|
| 188 | $organizations = array(); |
---|
| 189 | $referral = $params['referral']; |
---|
| 190 | $this->ldapConnect($referral); |
---|
| 191 | if ($this->ds) { |
---|
| 192 | $filter="ou=*"; |
---|
| 193 | $justthese = array("ou"); |
---|
| 194 | $sr = ldap_list($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 195 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 196 | |
---|
| 197 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 198 | $organizations[$i] = $info[$i]["ou"][0]; |
---|
| 199 | |
---|
| 200 | ldap_close($this->ds); |
---|
| 201 | sort($organizations); |
---|
| 202 | } |
---|
| 203 | return $organizations; |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | function get_organizations2($params){ |
---|
| 207 | $organizations = array(); |
---|
| 208 | $referral = $params['referral']; |
---|
| 209 | $this->ldapRootConnect($referral); |
---|
| 210 | if ($this->ds) { |
---|
| 211 | $filter="ou=*"; |
---|
| 212 | $justthese = array("ou"); |
---|
| 213 | $sr = ldap_list($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 214 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 215 | |
---|
| 216 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 217 | { |
---|
| 218 | $organizations[$i]['ou'] = $info[$i]["ou"][0]; |
---|
| 219 | $organizations[$i]['dn'] = $info[$i]["dn"]; |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | ldap_close($this->ds); |
---|
| 223 | sort($organizations); |
---|
| 224 | } |
---|
| 225 | return $organizations; |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | function catalogsearch($params) |
---|
| 229 | { |
---|
| 230 | $this->ldapConnect(true); |
---|
| 231 | $cn = $params['search_for'] ? "*".$params['search_for']."*" : "*"; |
---|
| 232 | $user_context = "ou=".$params['organization'].",".$this->ldap_context; |
---|
| 233 | $max_result = $params['max_result'] ? $params['max_result'] : '200'; |
---|
| 234 | $error = False; |
---|
| 235 | |
---|
| 236 | if ($this->ds) { |
---|
| 237 | $justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible"); |
---|
| 238 | $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(cn=".$cn."))"; |
---|
| 239 | $sr=ldap_search($this->ds, $user_context, $filter, $justthese); |
---|
| 240 | |
---|
| 241 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
| 242 | if ($count_entries > $max_result){ |
---|
| 243 | $info = null; |
---|
| 244 | $error = True; |
---|
| 245 | } |
---|
| 246 | else |
---|
| 247 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 248 | |
---|
| 249 | ldap_close($this->ds); |
---|
| 250 | |
---|
| 251 | $u_tmp = array(); |
---|
| 252 | $g_tmp = array(); |
---|
| 253 | |
---|
| 254 | for ($i=0; $i<$info["count"]; $i++){ |
---|
| 255 | if((strtoupper($info[$i]["phpgwaccounttype"][0]) == 'U') && ($info[$i]["phpgwaccountvisible"][0] != '-1')) |
---|
| 256 | $u_tmp[$info[$i]["mail"][0]] = $info[$i]["cn"][0]; |
---|
| 257 | else |
---|
| 258 | $g_tmp[$info[$i]["mail"][0]] = $info[$i]["cn"][0]; |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | natcasesort($u_tmp); |
---|
| 262 | natcasesort($g_tmp); |
---|
| 263 | |
---|
| 264 | $i = 0; |
---|
| 265 | $users = array(); |
---|
| 266 | |
---|
| 267 | foreach ($u_tmp as $mail => $cn){ |
---|
| 268 | $users[$i++] = array("name" => $cn, "email" => $mail); |
---|
| 269 | } |
---|
| 270 | unset($u_tmp); |
---|
| 271 | |
---|
| 272 | $i = 0; |
---|
| 273 | $groups = array(); |
---|
| 274 | |
---|
| 275 | foreach ($g_tmp as $mail => $cn){ |
---|
| 276 | $groups[$i++] = array("name" => $cn, "email" => $mail); |
---|
| 277 | } |
---|
| 278 | unset($g_tmp); |
---|
| 279 | |
---|
| 280 | return array('users' => $users, 'groups' => $groups, 'error' => $error); |
---|
| 281 | } |
---|
| 282 | return null; |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | function get_emails_ldap(){ |
---|
| 286 | |
---|
| 287 | $result['mail']= array(); |
---|
| 288 | $result['mailalter']= array(); |
---|
| 289 | $user = $_SESSION['phpgw_info']['expressomail']['user']['account_lid']; |
---|
| 290 | $this->ldapRootConnect(false); |
---|
| 291 | if ($this->ds) { |
---|
| 292 | $filter="uid=".$user; |
---|
| 293 | $justthese = array("mail","mailAlternateAddress"); |
---|
| 294 | $sr = ldap_search($this->ds,$this->ldap_context, $filter, $justthese); |
---|
| 295 | $ent = ldap_get_entries($this->ds, $sr); |
---|
| 296 | ldap_close($this->ds); |
---|
| 297 | |
---|
| 298 | for ($i=0; $i<$ent["count"]; $i++){ |
---|
| 299 | $result['mail'][] = $ent[$i]["mail"][0]; |
---|
| 300 | $result['mailalter'][] = $ent[$i]["mailalternateaddress"][0]; |
---|
| 301 | } |
---|
| 302 | } |
---|
| 303 | return $result; |
---|
| 304 | } |
---|
| 305 | |
---|
| 306 | //Busca usuários de um contexto e já retorna as options do select; |
---|
| 307 | function get_available_users($params) |
---|
[37] | 308 | { |
---|
| 309 | $this->ldapRootConnect(); |
---|
| 310 | //Monta lista de Grupos e Usuários |
---|
| 311 | $users = Array(); |
---|
| 312 | $groups = Array(); |
---|
| 313 | $user_context= $params['context']; |
---|
| 314 | $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner']; |
---|
[2] | 315 | |
---|
[37] | 316 | if ($this->ds) |
---|
| 317 | { |
---|
| 318 | $justthese = array("gidNumber","cn"); |
---|
| 319 | if ($params['type'] == 'search') |
---|
| 320 | $sr=ldap_search($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
| 321 | else |
---|
| 322 | $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
| 323 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 324 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 325 | $groups[$uids=$info[$i]["gidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => g); |
---|
| 326 | $justthese = array("phpgwaccountvisible","uidNumber","cn"); |
---|
| 327 | if ($params['type'] == 'search') |
---|
| 328 | $sr=ldap_search($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
| 329 | else |
---|
| 330 | $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
[2] | 331 | |
---|
[37] | 332 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 333 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 334 | { |
---|
| 335 | if ($info[$i]["phpgwaccountvisible"][0] == '-1') |
---|
| 336 | continue; |
---|
| 337 | $users[$uids=$info[$i]["uidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => u); |
---|
| 338 | } |
---|
| 339 | } |
---|
| 340 | ldap_close($this->ds); |
---|
| 341 | |
---|
| 342 | @asort($users); |
---|
| 343 | @reset($users); |
---|
| 344 | @asort($groups); |
---|
| 345 | @reset($groups); |
---|
| 346 | $user_options =''; |
---|
| 347 | $group_options =''; |
---|
[2] | 348 | |
---|
[37] | 349 | foreach($groups as $id => $user_array) { |
---|
| 350 | $newId = $id.'U'; |
---|
| 351 | $group_options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; |
---|
| 352 | } |
---|
| 353 | foreach($users as $id => $user_array) { |
---|
| 354 | if($owner != $id){ |
---|
| 355 | $newId = $id.'U'; |
---|
| 356 | $user_options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; |
---|
| 357 | } |
---|
| 358 | } |
---|
| 359 | return array("users" => $user_options, "groups" => $group_options); |
---|
| 360 | } |
---|
| 361 | |
---|
[2] | 362 | //Busca usuários de um contexto e já retorna as options do select; |
---|
| 363 | function get_available_users2($params) |
---|
| 364 | { |
---|
| 365 | $this->ldapRootConnect(); |
---|
| 366 | |
---|
| 367 | $context= $params['context']; |
---|
| 368 | $justthese = array("cn", "uid", "cn"); |
---|
[21] | 369 | $filter = "(&(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"; |
---|
[2] | 370 | |
---|
| 371 | if ($this->ds) |
---|
| 372 | { |
---|
| 373 | $sr=ldap_search($this->ds, $context, $filter, $justthese); |
---|
| 374 | $entries = ldap_get_entries($this->ds, $sr); |
---|
| 375 | |
---|
| 376 | for ($i=0; $i<$entries["count"]; $i++){ |
---|
| 377 | if($_SESSION['phpgw_info']['expressomail']['user']['account_lid'] != $entries[$i]["uid"][0]){ |
---|
| 378 | $u_tmp[$entries[$i]["uid"][0]] = $entries[$i]["cn"][0]; |
---|
| 379 | } |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | natcasesort($u_tmp); |
---|
| 383 | |
---|
| 384 | $i = 0; |
---|
| 385 | $users = array(); |
---|
| 386 | |
---|
| 387 | if (count($u_tmp)) |
---|
| 388 | { |
---|
| 389 | foreach ($u_tmp as $uidnumber => $cn) |
---|
| 390 | { |
---|
| 391 | $options .= "<option value=$uidnumber>$cn</option>"; |
---|
| 392 | } |
---|
| 393 | unset($u_tmp); |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | ldap_close($this->ds); |
---|
| 397 | return $options; |
---|
| 398 | } |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | function uid2cn($uid) |
---|
| 402 | { |
---|
| 403 | // do not follow the referral |
---|
| 404 | $this->ldapRootConnect(false); |
---|
| 405 | if ($this->ds) |
---|
| 406 | { |
---|
| 407 | $filter="(&(phpgwAccountType=u)(uid=$uid))"; |
---|
| 408 | $justthese = array("cn"); |
---|
| 409 | $sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 410 | |
---|
| 411 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 412 | return $info[0]["cn"][0]; |
---|
| 413 | } |
---|
| 414 | return false; |
---|
| 415 | } |
---|
| 416 | function getSharedUsersFrom($params){ |
---|
| 417 | $uids = explode(";",$params['uids']); |
---|
| 418 | |
---|
| 419 | $this->imap = new imap_functions(); |
---|
| 420 | $filter = ''; |
---|
| 421 | |
---|
| 422 | foreach($uids as $index => $uid){ |
---|
| 423 | $params = array(); |
---|
| 424 | $acl = $this->imap->getacltouser($uid); |
---|
| 425 | if(preg_match("/a/",$acl)) |
---|
| 426 | $filter .= "(uid=$uid)"; |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | $this->ldapRootConnect(false); |
---|
| 430 | $filter="(&(phpgwAccountType=u)(|$filter))"; |
---|
| 431 | if ($this->ds) { |
---|
| 432 | $justthese = array("cn","mail"); |
---|
| 433 | $sr = ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 434 | ldap_sort($this->ds,$sr,"cn"); |
---|
| 435 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 436 | $info['myname'] = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; |
---|
| 437 | return $info; |
---|
| 438 | } |
---|
| 439 | } |
---|
[27] | 440 | |
---|
| 441 | function getUserByEmail($params){ |
---|
| 442 | // Follow the referral |
---|
| 443 | $email = $params['email']; |
---|
| 444 | $this->ldapConnect(true); |
---|
| 445 | if ($this->ds) |
---|
| 446 | { |
---|
| 447 | $filter="(&(phpgwAccountType=u)(mail=$email))"; |
---|
[72] | 448 | $justthese = array("cn","uid","telephoneNumber","jpegPhoto","mobile"); |
---|
[27] | 449 | $sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 450 | $entry = ldap_first_entry($this->ds, $sr); |
---|
| 451 | if($entry) { |
---|
| 452 | $obj = array("cn" => @ldap_get_values($this->ds, $entry, "cn"), |
---|
| 453 | "email" => $email, |
---|
[37] | 454 | "uid" => @ldap_get_values($this->ds, $entry, "uid"), |
---|
[27] | 455 | "type" => "global", |
---|
[72] | 456 | "mobile" => @ldap_get_values($this->ds, $entry, "mobile"), |
---|
[27] | 457 | "telefone" => @ldap_get_values($this->ds, $entry, "telephonenumber")); |
---|
| 458 | |
---|
| 459 | $_SESSION['phpgw_info']['expressomail']['contact_photo'] = @ldap_get_values_len($this->ds, $entry, "jpegphoto"); |
---|
| 460 | ldap_close($this->ds); |
---|
| 461 | return $obj; |
---|
| 462 | } |
---|
| 463 | } |
---|
| 464 | return null; |
---|
| 465 | } |
---|
[2] | 466 | } |
---|
[108] | 467 | ?> |
---|