Changeset 5075 for trunk/expressoMail1_2/inc
- Timestamp:
- 09/07/11 16:23:02 (13 years ago)
- Location:
- trunk/expressoMail1_2/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
r4929 r5075 285 285 } 286 286 287 288 /** 289 * Método que faz o roteamento entre os métodos de busca (Catálogo pessoal, global e todos) 290 * @license http://www.gnu.org/copyleft/gpl.html GPL 291 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 292 * @sponsor Caixa Econômica Federal 293 * @author Prognus Software Livre <airton@prognus.com.br | prognus@prognus.com.br> 294 * @param <array> <$param> <parametros vindos do cliente> 295 */ 296 function quicksearchcontact($params) 297 { 298 $modal = false; 299 if($params['catalog']) 300 $modal = true; 301 302 include_once $_SESSION['rootPath']. '/header.inc.php'; 303 304 305 if (stripos( $params['search_for'] , '@' ) !== false) 306 $params['search_for'] = substr($params['search_for'], 0 , stripos( $params['search_for'] , '@' ) ); 307 308 309 if($modal) 310 { 311 if($params['catalog'] == "global") 312 { 313 return $this->quickSearchGlobal($params); 314 } 315 else 316 { 317 if($params['catalog'] == "personal") 318 return $this->quickSearchPersonal($params); 319 else 320 return $this->quickSearchAll($params); 321 } 322 } 323 else 324 { 325 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['catalog_search'] == "global") 326 { 327 return $this->quickSearchGlobal($params); 328 } 329 else 330 { 331 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['catalog_search'] == "personal") 332 return $this->quickSearchPersonal($params); 333 else 334 //Veirifica se quem chamou foi o campo de pesquisa rápida Expresso_Mail 335 if(($params['field'] == 'null') && ($params['ID'] == 'null')) 336 return $this->quickSearch($params); 337 else 338 return $this->quickSearchAll($params); 339 } 340 } 341 } 342 343 344 345 /** 346 * Método que faz a busca de usuários em todos os catálogos 347 * @license http://www.gnu.org/copyleft/gpl.html GPL 348 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 349 * @sponsor Caixa Econômica Federal 350 * @author Prognus Software Livre <airton@prognus.com.br | prognus@prognus.com.br> 351 * @param <array> <$param> <parametros vindos do cliente> 352 * @return <array> <$retorno> <Array com os usuários de todos os catálogos, de acordo com o parâmetro> 353 */ 354 function quickSearchAll($params) 355 { 356 357 $retorno_personal = $this->quickSearchPersonal($params); 358 $retorno_global = $this->quickSearchGlobal($params); 359 //$retorno = $retorno_personal + $retorno_global; 360 $retorno = array_merge($retorno_personal, $retorno_global); 361 $retorno['search_for'] = $params['search_for']; 362 $retorno['type_catalog'] = "A"; 363 return $retorno; 364 } 365 366 367 /** 368 * Método que faz a busca de usuários no Catálogo Pessoal 369 * @license http://www.gnu.org/copyleft/gpl.html GPL 370 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 371 * @sponsor Caixa Econômica Federal 372 * @author Prognus Software Livre <airton@prognus.com.br | prognus@prognus.com.br> 373 * @param <array> <$param> <parametros vindos do cliente> 374 * @return <array> <$retorno> <Array com os usuários do Catálogo Pessoal, de acordo com o parâmetro> 375 */ 376 function quickSearchPersonal($params, $all=false) 377 { 378 $results = array(); 379 $DBService = ServiceLocator::getService('db'); 380 $results = $DBService->search_contacts($params['search_for']); 381 382 if(!$all) 383 $results['type_catalog'] = "P"; 384 $results['search_for'] = $params['search_for']; 385 return $results; 386 } 387 388 389 /** 390 * Método que faz a busca de usuários no Catálogo Geral 391 * @license http://www.gnu.org/copyleft/gpl.html GPL 392 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) 393 * @sponsor Caixa Econômica Federal 394 * @author Prognus Software Livre <airton@prognus.com.br | prognus@prognus.com.br> 395 * @param <array> <$param> <parametros vindos do cliente> 396 * @return <array> <$retorno> <Array com os usuários do Catálogo Global, de acordo com o parâmetro> 397 */ 398 function quickSearchGlobal($params, $all=false) 399 { 400 include_once $_SESSION['rootPath']. '/header.inc.php'; 401 $c = CreateObject('phpgwapi.config','contactcenter'); 402 $all_data = $c->read_repository(); 403 404 $searchable_fields = array(); 405 foreach($all_data as $index => $value) 406 { 407 $parts = explode('_', $index); 408 if (is_numeric($parts[3]) && $parts[1]=='attribute') 409 { 410 if($parts[2] == 'searchable' && $value == 'true') 411 $searchable_fields[$all_data['cc_attribute_ldapname_' . $parts[3]]] = $all_data['cc_attribute_name_' . $parts[3]]; 412 } 413 } 414 include_once("class.functions.inc.php"); 415 $functions = new functions; 416 $field = $params['field']; 417 $ID = $params['ID']; 418 $ldapService = ServiceLocator::getService('ldap'); 419 $filter = $ldapService->getSearchFilter($params['search_for']); 420 421 $contacts_result = array(); 422 $contacts_result['field'] = $field; 423 $contacts_result['ID'] = $ID; 424 $search_for = utf8_encode($params['search_for']); 425 426 $this->ldapConnect(true); 427 if ($this->ds) 428 { 429 $ldapService->connection = $this->ds; 430 $campos_extras = ''; 431 $justthese = array("cn", "mail", "telephonenumber", "mobile", "phpgwaccountvisible", "uid", "employeenumber", "ou"); 432 foreach($searchable_fields as $fields_ldap => $value_field) 433 { 434 $campos_extras .= $fields_ldap . "|" . $value_field . "#"; 435 array_push($justthese, $fields_ldap); 436 } 437 $types = false; 438 439 $campos_extras = substr($campos_extras,0,-1); 440 441 if($field == 'null' || $ID == 'null') 442 { 443 $justthese[] = "jpegphoto"; 444 $types = 'u'; 445 } 446 $filter = $ldapService->getSearchFilter($params['search_for'], $types); 447 // Retirei o this->max_results, que limitava a busca. Agora ta retornando tudo amigo. 448 $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0); 449 450 if(!$sr) 451 return null; 452 453 $count_entries = ldap_count_entries($this->ds,$sr); 454 $info = ldap_get_entries($this->ds, $sr); 455 $info_return = $info; 456 //if($campos_extras != '') 457 //array_push($info_return, $campos_extras); 458 } 459 ldap_close($this->ds); 460 461 //Busca em Catalagos externos 462 $catalogsNum=count($this->external_srcs); 463 for ($i=0; $i<=$catalogsNum; $i++) { 464 if ($this->external_srcs[$i]["quicksearch"]) 465 { 466 $this->ldapConnect(true,$i); 467 $filter="(|(cn=*$search_for*)(mail=*$search_for*))"; 468 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid","employeeNumber", "ou"); 469 $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1); 470 if(!$sr) 471 return null; 472 $count_entries = ldap_count_entries($this->ds,$sr); 473 $search = ldap_get_entries($this->ds, $sr); 474 for ($j=0; $j<$search["count"]; $j++) { 475 $info_return[] = $search[$j]; 476 } 477 $info_return["count"] = count($info_return)-1; 478 } 479 } 480 //---------------------------------------------------------------// 481 482 if($all == false) 483 $info_return['type_catalog'] = "G"; 484 485 $info_return['search_for'] = $params['search_for']; 486 $info_return['extra_ldap_fields'] = $campos_extras; 487 return $info_return; 488 } 489 490 491 492 493 494 495 287 496 function make_quicksearch_card($info, $cn) 288 497 { -
trunk/expressoMail1_2/inc/hook_settings.inc.php
r4885 r5075 411 411 create_select_box('What is the maximum size of embedded images?','image_size',$default,'When user send an email with image in body message, it changes the size'); 412 412 413 $default = array( 414 'global' => lang("Global catalog"), 415 'personal' => lang("Personal catalog"), 416 'all' => lang("All catalogs") 417 ); 418 419 create_select_box('The dynamic search will use the catalog','catalog_search',$default,'Seleciona o catálogo que será usado para fazer a busca'); 420 421 422 413 423 if($GLOBALS['phpgw_info']['server']['use_assinar_criptografar']) 414 424 { … … 439 449 $vars = $GLOBALS['phpgw']->preferences->user['expressoMail']; 440 450 441 create_html_code("signature","<script src='../library/jquery/jquery -1.6.1.min.js' language='javascript'></script><script src='../library/tiny_mce/jquery.tinymce.js' language='javascript'></script><script src='../library/tiny_mce/tiny_mce.js' language='javascript'></script>451 create_html_code("signature","<script src='../library/jquery/jquery.js' language='javascript'></script><script src='../library/tiny_mce/jquery.tinymce.js' language='javascript'></script><script src='../library/tiny_mce/tiny_mce.js' language='javascript'></script> 442 452 <input type='hidden' id='counter' value='0'> 443 453 <input type='hidden' id='signatures' name='user[signatures]' value='". $vars['signatures']."'>
Note: See TracChangeset
for help on using the changeset viewer.