Changeset 16 for trunk/expressoAdmin1_2/inc/class.functions.inc.php
- Timestamp:
- 04/24/07 17:30:15 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoAdmin1_2/inc/class.functions.inc.php
r13 r16 341 341 } 342 342 343 function get_organizations2($context, $selected='') 344 { 345 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 346 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 347 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 348 349 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 350 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 351 ldap_bind($ldap_conn,$dn,$passwd); 352 353 $justthese = array("dn"); 354 $search=ldap_search($ldap_conn, $context, "ou=*", $justthese); 355 356 ldap_sort($ldap_conn, $search, "ou"); 357 $info = ldap_get_entries($ldap_conn, $search); 358 ldap_close($ldap_conn); 359 360 // Retiro o count do array info e inverto o array para ordenação. 361 for ($i=0; $i<$info["count"]; $i++) 362 { 363 $dn = $info[$i]["dn"]; 364 365 // Necessário, pq em uma busca com ldapsearch ou=*, traz tb o próprio ou. 366 if (strtolower($dn) == $context) 367 continue; 368 369 $array_dn = ldap_explode_dn ( $dn, 1 ); 370 371 $array_dn_reverse = array_reverse ( $array_dn, true ); 372 373 array_pop ( $array_dn_reverse ); 374 375 $inverted_dn[$dn] = implode ( ".", $array_dn_reverse ); 376 } 377 378 // Ordenação 379 natcasesort($inverted_dn); 380 381 // Construção do select 382 $level = 0; 383 foreach ($inverted_dn as $dn=>$invert_ufn) 384 { 385 $display = ''; 386 387 $array_dn_reverse = explode ( ".", $invert_ufn ); 388 $array_dn = array_reverse ( $array_dn_reverse, true ); 389 390 $level = count( $array_dn ) - 4; 391 392 if ($level == 0) 393 $display .= '+'; 394 else { 395 for ($i=0; $i<$level; $i++) 396 $display .= '---'; 397 } 398 399 reset ( $array_dn ); 400 $display .= ' ' . (current ( $array_dn ) ); 401 402 $dn = trim(strtolower($dn)); 403 if ( $dn == $selected ) 404 $select = ' selected'; 405 else 406 $select = ''; 407 $options .= "<option value='$dn'$select>$display</option>"; 408 } 409 410 // Cria a primeira entrada na combo 411 $first_sector_ufn = ldap_dn2ufn($context); 412 $first_sector_string = split(",", $first_sector_ufn); 413 $options = "<option value='$context'>" . strtoupper($first_sector_string[0]) . "</option>" . $options; 414 415 return $options; 416 } 417 343 418 function get_sectors($context, $selected='') 344 419 {
Note: See TracChangeset
for help on using the changeset viewer.