Changeset 342
- Timestamp:
- 07/01/08 11:40:00 (16 years ago)
- Location:
- trunk/expressoMail1_2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
r325 r342 1 1 <?php 2 2 include_once("class.imap_functions.inc.php"); 3 include_once("class.functions.inc.php"); 3 4 4 5 function ldapRebind($ldap_connection, $ldap_url) … … 13 14 var $ldap_context; 14 15 var $imap; 15 16 // usa o host e context do contact center. 17 function ldapConnect($refer = false,$catalogo = 0){ 18 include("../contactcenter/setup/external_catalogs.inc.php"); 19 if ($catalogo == 0){ 16 var $external_srcs; 17 var $max_result; 18 var $functions; 19 function ldap_functions(){ 20 // todo: Page Configuration for External Catalogs. 21 @include("../contactcenter/setup/external_catalogs.inc.php"); 22 $this->external_srcs= $external_srcs; 23 $this->max_result = 200; 24 $this->functions = new functions(); 25 } 26 // Using ContactCenter configuration. 27 function ldapConnect($refer = false,$catalog = 0){ 28 if ($catalog > 0 && is_array($this->external_srcs)){ 29 $this->ldap_host = $this->external_srcs[$catalog]['host']; 30 $this->ldap_context = $this->external_srcs[$catalog]['dn']; 31 $this->bind_dn = $this->external_srcs[$catalog]['acc']; 32 $this->bind_dn_pw = $this->external_srcs[$catalog]['pw']; 33 $this->object_class = $this->external_srcs[$catalog]['obj']; 34 $this->base_dn = $this->external_srcs[$catalog]['dn']; 35 $this->branch = $this->external_srcs[$catalog]['branch']; 36 }else { 20 37 $this->ldap_host = $_SESSION['phpgw_info']['expressomail']['ldap_server']['host']; 21 38 $this->ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn']; 22 39 $this->bind_dn = $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc']; 23 40 $this->bind_dn_pw = $_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']; 24 $this->branch = 'ou'; 25 }else { 26 27 $this->ldap_host = $external_srcs[$catalogo]['host']; 28 $this->ldap_context = $external_srcs[$catalogo]['dn']; 29 $this->bind_dn = $external_srcs[$catalogo]['acc']; 30 $this->bind_dn_pw = $external_srcs[$catalogo]['pw']; 31 $this->object_class = $external_srcs[$catalogo]['obj']; 32 $this->base_dn = $external_srcs[$catalogo]['dn']; 33 $this->branch = $external_srcs[$catalogo]['branch']; 34 35 } 41 $this->branch = 'ou'; 42 } 43 36 44 $this->ds = ldap_connect($this->ldap_host); 37 45 ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); 38 46 ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); 39 if ($refer) {47 if ($refer) { 40 48 ldap_set_rebind_proc($this->ds, ldapRebind); 41 49 } 42 @ldap_bind($this->ds,$this->bind_dn,$this->bind_dn_pw ); 43 50 @ldap_bind($this->ds,$this->bind_dn,$this->bind_dn_pw ); 44 51 } 45 52 … … 74 81 function quicksearch($params) 75 82 { 76 include_once("../contactcenter/setup/external_catalogs.inc.php");77 83 include_once("class.functions.inc.php"); 78 84 $functions = new functions; … … 102 108 // follow the referral 103 109 $this->ldapConnect(true); 104 110 105 111 if ($this->ds) 106 112 { 107 113 if (($field != 'null') && ($ID != 'null')) 108 114 { 109 115 $filter="(& (|(phpgwAccountType=u)(phpgwAccountType=l)) (|(cn=*$search_for*)(mail=*$search_for*)) (!(phpgwaccountvisible=-1)) )"; 110 116 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid", "employeeNumber", "ou"); 111 117 } 112 118 else 113 119 { 114 120 $filter="(& (phpgwAccountType=u)(cn=*$search_for*) (!(phpgwaccountvisible=-1)) )"; 115 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "jpegPhoto", "uid", "employeeNumber", "ou"); 116 } 117 $sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, 201); 121 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible","jpegPhoto", "uid", "employeeNumber", "ou"); 122 } 123 $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result + 1); 124 if(!$sr) 125 return null; 118 126 $count_entries = ldap_count_entries($this->ds,$sr); 119 127 120 128 // Get user org dn. 121 129 $user_dn = $_SESSION['phpgw_info']['expressomail']['user']['account_dn']; … … 126 134 127 135 // New search only on user sector 128 if ($count_entries > 200)129 {136 if ($count_entries > $this->max_result) 137 { 130 138 // Close old ldap conection 131 139 ldap_close($this->ds); … … 134 142 $this->ldapRootConnect(true); 135 143 136 $sr=ldap_search($this->ds, $user_sector_dn, $filter, $justthese, 0, 201); 144 $sr= ldap_search($this->ds, $user_sector_dn, $filter, $justthese); 145 if(!$sr) 146 return null; 137 147 $count_entries = ldap_count_entries($this->ds,$sr); 138 148 139 if ($count_entries > 200){149 if ($count_entries > $this->max_result){ 140 150 $return = array(); 141 151 $return['status'] = false; … … 154 164 $tmp_users_from_user_org = array(); 155 165 156 if (!$quickSearch_only_in_userSector) 157 { 158 $catalogsNum=count($external_srcs); 159 for ($i=0; $i<=count($external_srcs); $i++) 160 { 161 if ($external_srcs[$i]["quicksearch"]) 162 { 166 if (!$quickSearch_only_in_userSector) { 167 $catalogsNum=count($this->external_srcs); 168 for ($i=0; $i<=count($this->external_srcs); $i++) { 169 if ($this->external_srcs[$i]["quicksearch"]) { 163 170 $this->ldapConnect(true,$i); 164 171 $filter="(|(cn=*$search_for*)(mail=*$search_for*))"; 165 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid", "employeeNumber", "ou"); 166 $sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, 201); 172 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid","employeeNumber", "ou"); 173 $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1); 174 if(!$sr) 175 return null; 167 176 $count_entries = ldap_count_entries($this->ds,$sr); 168 177 $search = ldap_get_entries($this->ds, $sr); 169 for ($i=0; $i<$search["count"]; $i++) 170 { 178 for ($i=0; $i<$search["count"]; $i++) { 171 179 $info[] = $search[$i]; 172 180 } 173 181 $info["count"] = count($info)-1; 174 }175 182 } 176 183 } 177 184 } 185 178 186 for ($i=0; $i<$info["count"]; $i++) 179 187 { 180 188 if ($quickSearch_only_in_userSector) 189 { 190 $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]); 191 } 192 else 193 { 194 if (preg_match("/$user_sector_dn/i", $info[$i]['dn'])) 181 195 { 182 $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]);196 $tmp_users_from_user_org[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]); 183 197 } 184 else198 else 185 199 { 186 if (preg_match("/$user_sector_dn/i", $info[$i]['dn']))187 {188 $tmp_users_from_user_org[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]);189 }190 else191 {192 200 $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]); 193 }194 201 } 195 202 } 203 } 196 204 natcasesort($tmp_users_from_user_org); 197 205 natcasesort($tmp); … … 242 250 '<tr class="quicksearchcontacts_unselected">' . 243 251 '<td colspan="2" width="100%" align="center">' . 244 $functions->getLang('More than 200 results were found') . '.<br>' .245 $ functions->getLang('Showing only the results found in your organization') . '.';252 str_replace("%1", $this->max_result,$this->functions->getLang('More than %1 results were found')) . '.<br>' . 253 $this->functions->getLang('Showing only the results found in your organization') . '.'; 246 254 '</td>' . 247 255 '</tr>'; … … 263 271 '<tr class="quicksearchcontacts_unselected">' . 264 272 '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . 265 $ functions->getLang('Users from your organization') . '.';266 '</ B></td>' .273 $this->functions->getLang('Users from your organization') . '</B> ['.count($tmp_users_from_user_org).']'; 274 '</td>' . 267 275 '</tr>'; 268 276 … … 270 278 '<tr class="quicksearchcontacts_unselected">' . 271 279 '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . 272 $ functions->getLang('Users from others organizations') . '.';273 '</ B></td>' .280 $this->functions->getLang('Users from others organizations') . '</B> ['.count($tmp).']'; 281 '</td>' . 274 282 '</tr>'; 275 283 } … … 299 307 300 308 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_enabled'] && $phoneUser) { 301 $phoneUser = '<a title="'.$ functions->getLang("Call to Comercial Number").'" href="#" onclick="InfoContact.connectVoip(\''.$phoneUser.'\',\'com\')">'.$phoneUser.'</a>';309 $phoneUser = '<a title="'.$this->functions->getLang("Call to Comercial Number").'" href="#" onclick="InfoContact.connectVoip(\''.$phoneUser.'\',\'com\')">'.$phoneUser.'</a>'; 302 310 if($contacts_result['mobile']){ 303 $phoneUser .= ' / <a title="'.$ functions->getLang("Call to Mobile Number").'" href="#" onclick="InfoContact.connectVoip(\''.$contacts_result['mobile'].'\',\'mob\')">'.$contacts_result['mobile'].'</a>';311 $phoneUser .= ' / <a title="'.$this->functions->getLang("Call to Mobile Number").'" href="#" onclick="InfoContact.connectVoip(\''.$contacts_result['mobile'].'\',\'mob\')">'.$contacts_result['mobile'].'</a>'; 304 312 } 305 313 } … … 307 315 '<tr class="quicksearchcontacts_unselected">' . 308 316 '<td class="cc" width="1%">' . 309 '<a title="'.$ functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\')">' .317 '<a title="'.$this->functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\')">' . 310 318 $photo_link . 311 319 '</a>' . … … 313 321 '<td class="cc">' . 314 322 '<span name="cn">' . $contacts_result['cn'] . '</span>' . '<br>' . 315 '<a title="'.$ functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\')">' .323 '<a title="'.$this->functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\')">' . 316 324 '<font color=blue>' . 317 325 '<span name="mail">' . $contacts_result['mail'] . '</span>' . '<br>' . … … 324 332 } 325 333 326 function get_catalogs(){ 327 include("../contactcenter/setup/external_catalogs.inc.php"); 334 function get_catalogs(){ 328 335 $catalogs = array(); 329 $catalogs[0] = "Catalogo geral"; 330 foreach ($external_srcs as $key => $valor ){ 336 $catalogs[0] = $this->functions->getLang("Global Catalog"); 337 if($this->external_srcs) 338 foreach ($this->external_srcs as $key => $valor ){ 331 339 $catalogs[$key] = $valor['name']; 332 340 } … … 334 342 } 335 343 function get_organizations($params){ 336 337 344 $organizations = array(); 338 345 $params['referral']?$referral = $params['referral']:$referral = false; … … 344 351 $filter=$this->branch."=*"; 345 352 $justthese = array("$this->branch"); 346 347 348 349 350 351 352 353 sort($organizations);354 353 $sr = ldap_list($this->ds, $this->ldap_context, $filter, $justthese); 354 $info = ldap_get_entries($this->ds, $sr); 355 356 for ($i=0; $i<$info["count"]; $i++) 357 $organizations[$i] = $info[$i]["ou"][0]; 358 359 ldap_close($this->ds); 360 sort($organizations); 361 return $organizations; 355 362 }else{ 356 363 return null; 357 364 } 358 365 } 359 366 function get_organizations2($params){ … … 381 388 function catalogsearch($params) 382 389 { 383 //$this->ldapConnect(true);384 include("../contactcenter/inc/external_catalogs.inc.php");385 390 $cn = $params['search_for'] ? "*".utf8_encode($params['search_for'])."*" : "*"; 386 $max_result = $params['max_result'] ? $params['max_result'] : '200';391 $max_result = $params['max_result'] ? $params['max_result'] : $this->max_result; 387 392 $catalog = $params['catalog']; 388 393 $error = False; 389 394 390 395 $this->ldapConnect(false,$catalog); 391 396 392 $params['organization'] == ' todos'?$user_context = $this->ldap_context :$user_context = $this->branch."=".$params['organization'].",".$this->ldap_context;397 $params['organization'] == 'all' ? $user_context = $this->ldap_context :$user_context = $this->branch."=".$params['organization'].",".$this->ldap_context; 393 398 394 399 if ($this->ds) { … … 405 410 } 406 411 407 $sr=ldap_search($this->ds, $user_context, $filter, $justthese,0,200); 412 $sr=@ldap_search($this->ds, $user_context, $filter, $justthese, 0, $this->max_result+1); 413 if(!$sr) 414 return null; 408 415 $count_entries = ldap_count_entries($this->ds,$sr); 409 if ($count_entries > $ max_result){416 if ($count_entries > $this->max_result){ 410 417 $info = null; 411 418 $error = True; … … 429 436 natcasesort($u_tmp); 430 437 natcasesort($g_tmp); 431 438 432 439 $i = 0; 433 $users = array(); 434 435 436 foreach ($u_tmp as $mail => $cn){ 440 $users = array(); 441 442 foreach ($u_tmp as $mail => $cn){ 437 443 438 444 $tmp = explode("%", $cn); //explode o cn pelo caracter "%" e joga em $tmp; … … 442 448 443 449 } 444 445 450 unset($u_tmp); 446 451 … … 479 484 } 480 485 481 //Busca usu ï¿œrios de um contexto e jï¿œretorna as options do select;486 //Busca usuarios de um contexto e ja retorna as options do select; 482 487 function get_available_users($params) 483 488 { 484 489 $this->ldapRootConnect(); 485 //Monta lista de Grupos e Usu ï¿œrios490 //Monta lista de Grupos e Usuarios 486 491 $users = Array(); 487 492 $groups = Array(); … … 535 540 } 536 541 537 //Busca usu ï¿œrios de um contexto e jï¿œretorna as options do select;542 //Busca usuarios de um contexto e ja retorna as options do select; 538 543 function get_available_users2($params) 539 544 { … … 626 631 if ($ds) 627 632 { 628 $sr= ldap_search($ds, $ldap_context, $filter, $justthese);633 $sr=@ldap_search($ds, $ldap_context, $filter, $justthese); 629 634 630 635 if (!$sr) -
trunk/expressoMail1_2/js/QuickCatalogSearch.js
r325 r342 139 139 Op.value = '"' + data[i].cn + '" ' + '<' + data[i].mail + '>'; 140 140 cmb.options.add(Op); 141 142 141 } 143 142 cmb.options[0].selected = true; … … 153 152 154 153 if(! this.arrayWin[div.id]) { 155 div.style.width = "700px"; //na comunidade valor eh 600px154 div.style.width = "700px"; 156 155 div.style.height = "230px"; 157 156 var title = get_lang('The results were found in the Global Catalog')+':'; … … 226 225 el.style.visibility = "hidden"; 227 226 el.style.position = "absolute"; 228 el.style.width = "700px"; // na comunidade valor eh 495px227 el.style.width = "700px"; 229 228 el.style.height = is_ie ? "360px" : "375px"; 230 229 el.style.left = "0px"; … … 239 238 '<tr><td><select style="width:150px" id="select_catalog" name="select_catalog" onchange="javascript:QuickCatalogSearch.update_organizations();"></select> '+ 240 239 '<select id="select_organization" style="width:100px" name="select_organization"></select> '+ 241 '<input type="text" id="search_for" name="search_for" value="" size=" 10" maxlength="15"/> <input type="button" onclick="QuickCatalogSearch.searchCatalogList(true)" class="button" value="'+get_lang('Search')+'"> <input style="display:none" type="button" onclick="QuickCatalogSearch.searchCatalogList(false)" class="button" value="'+get_lang('List All')+'"></td></tr>'+242 '<tr><td><input onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" id="type" type="radio" name="type" value="l"/>'+get_lang('Public Lists')+' <input type="radio" name="type" value="u" onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" checked/>'+get_lang('Users')+' '+240 '<input type="text" id="search_for" name="search_for" value="" size="30" maxlength="20"/> <input type="button" onclick="QuickCatalogSearch.searchCatalogList(true)" class="button" value="'+get_lang('Search')+'"> <input style="display:none" type="button" onclick="QuickCatalogSearch.searchCatalogList(false)" class="button" value="'+get_lang('List All')+'"></td></tr>'+ 241 //'<tr><td><input onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" id="type" type="radio" name="type" value="l"/>'+get_lang('Public Lists')+' <input type="radio" name="type" value="u" onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" checked/>'+get_lang('Users')+' '+ 243 242 '<span style="visibility:hidden;background:#cc4444" id=msg_search> <font face="Verdana" size="1" color="WHITE">'+get_lang('Search in Catalog')+'...</font> </span></td></tr>'+ 244 243 '<tr><td>'+ … … 298 297 var user_catalog = "Catalogo Geral"; 299 298 300 for(i = 0; i < data.length; i++) { 301 302 Element('select_catalog').options[i] = new Option(data[i],i); 303 if(user_catalog.toUpperCase() == data[i].toUpperCase()) 304 Element('select_catalog').options[i].selected = true; 299 if(data.length <= 1) 300 Element('select_catalog').style.display = 'none'; 301 else { 302 for(i = 0; i < data.length; i++) { 303 Element('select_catalog').options[i] = new Option(data[i],i); 304 if(user_catalog.toUpperCase() == data[i].toUpperCase()) 305 Element('select_catalog').options[i].selected = true; 306 } 305 307 } 306 308 } 307 309 cExecute ("$this.ldap_functions.get_catalogs", handler_catalogs); 308 310 309 311 this.update_organizations(); 310 312 … … 383 385 384 386 var handler_org = function(data){ 385 Element('select_organization').options[0] = new Option( 'todos','todos');387 Element('select_organization').options[0] = new Option(get_lang('all'),'all'); 386 388 if (data != null){ 387 389 388 390 for(x = 0; x < data.length; x++) { 389 Element('select_organization').options[x+1] = new Option(data[x] ,data[x]);391 Element('select_organization').options[x+1] = new Option(data[x].toUpperCase(),data[x]); 390 392 } 391 393 } … … 512 514 } 513 515 else{ 514 516 515 517 /*******************************************************************************************/ 516 518 /* O resultado pratico do bloco de codigo a seguir eh a exibicao dos valores em tela,
Note: See TracChangeset
for help on using the changeset viewer.