Changeset 285 for trunk/contactcenter/inc/class.bo_contactcenter.inc.php
- Timestamp:
- 05/23/08 17:10:39 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/contactcenter/inc/class.bo_contactcenter.inc.php
r284 r285 5 5 * Written by: * 6 6 * - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> * 7 * sponsored by Thyamad - http://www.thyamad.com *7 * sponsored by Thyamad - http://www.thyamad.com 8 8 * ------------------------------------------------------------------------- * 9 9 * This program is free software; you can redistribute it and/or modify it * … … 25 25 */ 26 26 var $catalog; 27 27 28 28 /*! 29 29 The Security Manager 30 30 */ 31 31 var $security; 32 32 33 33 34 34 function bo_contactcenter($catalog=false) … … 37 37 $this->catalog_level = $GLOBALS['phpgw']->session->appsession('bo_contactcenter.catalog_level','contactcenter'); 38 38 $this->security = CreateObject('contactcenter.bo_security_manager'); 39 39 40 40 if ($catalog) 41 41 { … … 56 56 } 57 57 } 58 58 59 59 /* 60 60 * … … 108 108 109 109 /*! 110 110 111 111 @function find 112 112 @abstract Performs a search in the DB based on the parameters 113 113 @author Raphael Derosso Pereira (algorithm and code) 114 114 @author Vinicius Cubas Brand (algorithm) 115 115 116 116 @param array $what The list of fields to be returned. The format is: 117 117 $what = array( … … 119 119 'contact.names_ordered' 120 120 ); 121 121 122 122 @param array $rules The restrictions. 123 123 124 124 The restrictions format is quite complicated, but is very complete. 125 125 As defined here, there is the possibility to do almost any type of 126 126 search (tell me if you can't do any). For example, imagine the 127 127 following search: 128 128 129 129 and(a,or(d,e,and(f,g))) 130 130 131 131 That is represented by the folloowing tree: 132 132 133 133 and 134 134 | … … 148 148 The rules that should be passed to the find function for this tree 149 149 is: 150 150 151 151 $rules = array( 152 152 0 => array( … … 189 189 ); 190 190 191 192 The restriction type can be: =, !=, <=, <, >, >=, NULL, IN, LIKE, 191 192 The restriction type can be: =, !=, <=, <, >, >=, NULL, IN, LIKE, 193 193 NOT NULL, NOT IN, NOT LIKE 194 194 Value of branch can be AND, OR, NOT 195 196 @param array $other Other parameter to the search 195 196 @param array $other Other parameter to the search 197 197 $other = array( 198 198 'offset' => (int), … … 204 204 205 205 @return array $array[<field_name>][<row_number>] 206 206 207 207 */ 208 208 function find($what, $rules=false, $other=false) … … 210 210 return $this->catalog->find($what, $rules, $other); 211 211 } 212 213 /*! 214 212 213 /*! 214 215 215 @function get_catalog_tree 216 216 @abstract Returns an array describing the available … … 223 223 @param (boolean) $recursive Retrive the whole tree from 224 224 the level specified until the leaves 225 225 226 226 @return The format of the return is: 227 227 $return = array( … … 246 246 1 => array(...),... 247 247 ); 248 248 249 249 <branch_type> can be 'catalog_group', 'catalog' or 'view'; 250 <branch_class> is the name of the class that is capable of 250 <branch_class> is the name of the class that is capable of 251 251 handling the information for this catalog/view 252 252 <branch_class_args> is an array that holds the arguments to … … 254 254 <brach_find_args> is the string that should precede the search 255 255 string 256 257 If the branch is actually a leaf, than 'sub_branch' is false; 258 259 256 257 If the branch is actually a leaf, than 'sub_branch' is false; 258 259 260 260 TODO: This method is hard-coded, but it should grab the tree 261 261 from the DB using the View Manager... … … 269 269 return $this->tree['branches']; 270 270 } 271 271 272 272 $lvl_vector = explode('.', $level); 273 273 $id = $lvl_vector[1]; … … 275 275 $branch =& $this->get_branch_by_level($level); 276 276 $info = $this->get_info_by_level($level); 277 277 278 278 if ($branch['type'] === 'unknown') 279 279 { … … 281 281 { 282 282 $ldap = CreateObject('contactcenter.bo_ldap_manager'); 283 284 283 if ($this->tree['branches'][$id]['external']) 285 284 { … … 292 291 $new_branch = $ldap->get_ldap_tree($info['src'], $branch['value'], $recursive); 293 292 } 294 295 293 if ($new_branch) 296 294 { … … 304 302 $new_branch['external'] = $branch['external']; 305 303 $branch = $new_branch; 306 307 304 } 308 305 else … … 312 309 } 313 310 $GLOBALS['phpgw']->session->appsession('bo_contactcenter.tree','contactcenter',$this->tree); 311 314 312 return $branch; 315 313 } … … 318 316 return $branch; 319 317 } 320 318 321 319 return false; 322 320 } 323 321 324 322 if ($level !== '0') 325 323 { 326 324 return false; 327 325 } 328 326 329 327 $this->tree = array( 330 328 0 => array( … … 338 336 'icon' => 'people-mini.png', 339 337 'sub_branch' => false 340 ),/* 341 1 => array( 342 'name' => lang('Companies'), 343 'type' => 'catalog', 344 'class' => 'bo_company_manager', 345 'find_args' => 'company', 346 'icon' => 'company-mini.png', 347 'sub_branch' => false 348 ),*/ 349 338 ), 350 339 1 => array( 351 340 'name' => lang('Groups'), … … 357 346 ) 358 347 ); 359 348 360 349 $ldap = CreateObject('contactcenter.bo_ldap_manager'); 361 350 $ldap_srcs = $ldap->get_all_ldap_sources(); 362 351 363 352 if ($ldap_srcs) 364 353 { … … 411 400 // External catalogs are now identified as type unknown during initialization. An optimization change. 412 401 413 /*414 if (($tree = $ldap->get_external_ldap_tree($id, $ldap_srcs[$id]['dn'], $recursive)))415 {416 if (array_key_exists('error_msg', $tree))417 {418 if (isset($this->tree['branches']['msg']))419 {420 $this->tree['branches']['msg'] .= "\n" . lang('Catalog %1 not showed due to error: ' .421 $tree['error_msg'], $ldap_srcs[$id]['name']);422 }423 else424 {425 $this->tree['branches']['msg'] = lang('Catalog %1 not showed due to error: ' .426 $tree['error_msg'], $ldap_srcs[$id]['name']);427 }428 }429 430 else431 {432 */433 402 $tree['name'] = $ldap_srcs[$id]['name']; 434 403 $tree['type'] = 'unknown'; 435 404 $tree['value'] = $ldap_srcs[$id]['dn']; 436 405 $tree['external'] = true; 437 //$tree['sub_branch'] = false;438 406 array_push($this->tree['branches'], $tree); 439 407 $this->tree[$i]['type'] = 'ldap'; 440 408 $this->tree[$i]['src'] = $id; 441 // }442 //}443 409 $i++; 444 410 } 445 411 } 446 412 447 413 $GLOBALS['phpgw']->session->appsession('bo_contactcenter.tree','contactcenter',$this->tree); 448 414 return $this->tree['branches']; 449 //return null; 450 } 451 452 /*! 453 415 } 416 417 /*! 418 454 419 @function get_branch_by_level 455 420 @abstract Returns the branch and it's informations given the level 456 421 @author Raphael Derosso Pereira 457 422 458 423 @param (string) $level The level to be used 459 424 460 425 */ 461 426 function & get_branch_by_level($level) … … 463 428 $path = @explode('.',$level); 464 429 $n_ways = count($path); 465 430 466 431 if ($n_ways <= 1) 467 432 { 468 433 return false; 469 434 } 470 435 471 436 $code = '$branch =& $this->tree[\'branches\']'; 472 437 for ($i = 1; $i < $n_ways-1; $i++) … … 478 443 //echo 'Codigo: '.$code.'<br>'; 479 444 eval($code); 480 445 481 446 return $branch; 482 447 } 483 448 484 449 /*! 485 450 486 451 @function get_info_by_level 487 452 @abstract Returns the information about the catalog, given the level … … 495 460 $path = @explode('.',$level); 496 461 $n_ways = count($path); 497 462 498 463 if ($n_ways <= 1) 499 464 { 500 465 return false; 501 466 } 502 467 503 468 $info = $this->tree[$path[1]]; 504 469 505 470 return $info; 506 471 } … … 553 518 554 519 $search = $this->get_level_by_branch($catalog, $bcatalog['sub_branch'], (string) $level); 555 520 556 521 if ($search !== false) 557 522 { … … 567 532 return false; 568 533 } 569 570 /*! 571 534 535 /*! 536 572 537 @function get_actual_catalog 573 @abstract Returns the information about the Catalog that is 538 @abstract Returns the information about the Catalog that is 574 539 instantiated 575 540 576 541 @author Raphael Derosso Pereira 577 542 578 543 */ 579 544 function get_actual_catalog() … … 582 547 return $catalog; 583 548 } 584 585 /*! 586 549 550 /*! 551 587 552 @function set_catalog 588 553 @abstract Sets the actual catalog 589 554 @author Raphael Derosso Pereira 590 555 591 556 @param array $to_catalog The catalog in the format returned by 592 557 get_available_tree or the level 593 558 594 559 */ 595 560 function set_catalog(& $to_catalog ) … … 614 579 { 615 580 $catalog =& $to_catalog; 616 //echo "Daqui!<br>";617 581 $level = $this->get_level_by_branch($to_catalog, $this->tree['branches']); 618 582 } 619 620 583 $lvl_vector = explode('.', $level); 621 584 $id = $lvl_vector[1]; 622 585 623 586 switch($catalog['type']) 624 587 { … … 642 605 $call .= ','.implode(',',$args); 643 606 } 644 607 645 608 $call .= ');'; 646 609 647 610 // print_r($catalog); 648 611 // echo '<br><br><b>Setando Catalogo '.$catalog['name'].': </b>'.$call.'<br>'; 649 612 650 613 eval($call); 651 614 652 615 return $catalog; 653 616 654 617 default: return false; 655 618 } 656 619 } 657 620 658 621 659 622 … … 661 624 * Methods to set general fields * 662 625 \*********************************************************************/ 663 664 /*! 665 626 627 /*! 628 666 629 @function add_vcard 667 630 @abstract Insert a VCard to the squema … … 669 632 @param string $uploaded_file The path to the file that were 670 633 uploaded. 671 634 672 635 */ 673 636 function add_vcard ( $uploaded_file ) … … 676 639 677 640 678 641 679 642 /*********************************************************************\ 680 643 * Methods to get general data * 681 644 \*********************************************************************/ 682 645 683 646 } 684 647 ?>
Note: See TracChangeset
for help on using the changeset viewer.