Ignore:
Timestamp:
05/23/08 17:10:39 (16 years ago)
Author:
brunocosta
Message:

Correção dos problemas gerados no commit anterior, a funcionalidade citada no ticket #199 foram temporariamente desativadas.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/contactcenter/inc/class.bo_contactcenter.inc.php

    r284 r285  
    55  * Written by:                                                               * 
    66  *  - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net>         * 
    7   *  sponsored by Thyamad - http://www.thyamad.com                            * 
     7  *  sponsored by Thyamad - http://www.thyamad.com 
    88  * ------------------------------------------------------------------------- * 
    99  *  This program is free software; you can redistribute it and/or modify it  * 
     
    2525                */ 
    2626                var $catalog; 
    27  
     27                 
    2828                /*! 
    2929                        The Security Manager 
    3030                */ 
    3131                var $security; 
    32  
     32                 
    3333 
    3434                function bo_contactcenter($catalog=false) 
     
    3737                        $this->catalog_level = $GLOBALS['phpgw']->session->appsession('bo_contactcenter.catalog_level','contactcenter'); 
    3838                        $this->security = CreateObject('contactcenter.bo_security_manager'); 
    39  
     39                         
    4040                        if ($catalog) 
    4141                        { 
     
    5656                        } 
    5757                } 
    58  
     58                 
    5959                /* 
    6060                 * 
     
    108108 
    109109                /*! 
    110  
     110                 
    111111                        @function find 
    112112                        @abstract Performs a search in the DB based on the parameters 
    113113                        @author Raphael Derosso Pereira (algorithm and code) 
    114114                        @author Vinicius Cubas Brand (algorithm) 
    115  
     115                         
    116116                        @param array $what The list of fields to be returned. The format is: 
    117117                                $what = array( 
     
    119119                                        'contact.names_ordered' 
    120120                                ); 
    121  
     121                         
    122122                        @param array $rules The restrictions. 
    123  
     123                         
    124124                        The restrictions format is quite complicated, but is very complete. 
    125125                        As defined here, there is the possibility to do almost any type of 
    126126                        search (tell me if you can't do any). For example, imagine the 
    127127                        following search: 
    128  
     128                                         
    129129                                                and(a,or(d,e,and(f,g))) 
    130  
     130                         
    131131                        That is represented by the folloowing tree: 
    132  
     132                                 
    133133                                   and 
    134134                                    | 
     
    148148                        The rules that should be passed to the find function for this tree 
    149149                        is: 
    150  
     150                                 
    151151                                $rules = array( 
    152152                                        0 => array( 
     
    189189                                ); 
    190190 
    191  
    192                         The restriction type can be: =, !=, <=, <, >, >=, NULL, IN, LIKE, 
     191   
     192                        The restriction type can be: =, !=, <=, <, >, >=, NULL, IN, LIKE,  
    193193                        NOT NULL, NOT IN, NOT LIKE 
    194194                        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  
    197197                                $other = array( 
    198198                                        'offset'          => (int), 
     
    204204 
    205205                        @return array $array[<field_name>][<row_number>] 
    206  
     206                                 
    207207                */ 
    208208                function find($what, $rules=false, $other=false) 
     
    210210                        return $this->catalog->find($what, $rules, $other); 
    211211                } 
    212  
    213                 /*! 
    214  
     212                 
     213                /*! 
     214                 
    215215                        @function get_catalog_tree 
    216216                        @abstract Returns an array describing the available 
     
    223223                        @param (boolean) $recursive Retrive the whole tree from 
    224224                                the level specified until the leaves 
    225  
     225                         
    226226                        @return The format of the return is: 
    227227                                $return = array( 
     
    246246                                        1  => array(...),... 
    247247                                ); 
    248  
     248                                 
    249249                                <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  
    251251                                        handling the information for this catalog/view 
    252252                                <branch_class_args> is an array that holds the arguments to 
     
    254254                                <brach_find_args> is the string that should precede the search 
    255255                                        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                 
    260260                        TODO: This method is hard-coded, but it should grab the tree 
    261261                        from the DB using the View Manager... 
     
    269269                                        return $this->tree['branches']; 
    270270                                } 
    271  
     271                                 
    272272                                $lvl_vector = explode('.', $level); 
    273273                                $id = $lvl_vector[1]; 
     
    275275                                $branch =& $this->get_branch_by_level($level); 
    276276                                $info = $this->get_info_by_level($level); 
    277  
     277                                 
    278278                                if ($branch['type'] === 'unknown') 
    279279                                { 
     
    281281                                        { 
    282282                                                $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    283  
    284283                                                if ($this->tree['branches'][$id]['external']) 
    285284                                                { 
     
    292291                                                        $new_branch = $ldap->get_ldap_tree($info['src'], $branch['value'], $recursive); 
    293292                                                } 
    294  
    295293                                                if ($new_branch) 
    296294                                                { 
     
    304302                                                        $new_branch['external'] = $branch['external']; 
    305303                                                        $branch = $new_branch; 
    306  
    307304                                                } 
    308305                                                else 
     
    312309                                        } 
    313310                                        $GLOBALS['phpgw']->session->appsession('bo_contactcenter.tree','contactcenter',$this->tree); 
     311                                         
    314312                                        return $branch; 
    315313                                } 
     
    318316                                        return $branch; 
    319317                                } 
    320  
     318                                 
    321319                                return false; 
    322320                        } 
    323  
     321                         
    324322                        if ($level !== '0') 
    325323                        { 
    326324                                return false; 
    327325                        } 
    328  
     326                         
    329327                        $this->tree = array( 
    330328                                0 => array( 
     
    338336                                                'icon'       => 'people-mini.png', 
    339337                                                '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                                        ), 
    350339                                        1  => array( 
    351340                                                'name'       => lang('Groups'), 
     
    357346                                ) 
    358347                        ); 
    359  
     348                         
    360349                        $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    361350                        $ldap_srcs = $ldap->get_all_ldap_sources(); 
    362  
     351                         
    363352                        if ($ldap_srcs) 
    364353                        { 
     
    411400                                        // External catalogs are now identified as type unknown during initialization. An optimization change. 
    412401 
    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                                                         else 
    424                                                         { 
    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                                                 else 
    431                                                 { 
    432                                                 */ 
    433402                                                $tree['name'] = $ldap_srcs[$id]['name']; 
    434403                                                $tree['type'] = 'unknown'; 
    435404                                                $tree['value'] = $ldap_srcs[$id]['dn']; 
    436405                                                $tree['external'] = true; 
    437                                                 //$tree['sub_branch'] = false; 
    438406                                                array_push($this->tree['branches'], $tree); 
    439407                                                $this->tree[$i]['type'] = 'ldap'; 
    440408                                                $this->tree[$i]['src'] = $id; 
    441                                         //      } 
    442                                         //} 
    443409                                        $i++; 
    444410                                } 
    445411                        } 
    446  
     412                         
    447413                        $GLOBALS['phpgw']->session->appsession('bo_contactcenter.tree','contactcenter',$this->tree); 
    448414                        return $this->tree['branches']; 
    449                         //return null; 
    450                 } 
    451  
    452                 /*! 
    453  
     415                } 
     416 
     417                /*! 
     418                         
    454419                        @function get_branch_by_level 
    455420                        @abstract Returns the branch and it's informations given the level 
    456421                        @author Raphael Derosso Pereira 
    457  
     422                         
    458423                        @param (string) $level The level to be used 
    459  
     424                         
    460425                */ 
    461426                function & get_branch_by_level($level) 
     
    463428                        $path = @explode('.',$level); 
    464429                        $n_ways = count($path); 
    465  
     430                         
    466431                        if ($n_ways <= 1) 
    467432                        { 
    468433                                return false; 
    469434                        } 
    470  
     435                         
    471436                        $code = '$branch =& $this->tree[\'branches\']'; 
    472437                        for ($i = 1; $i < $n_ways-1; $i++) 
     
    478443                        //echo 'Codigo: '.$code.'<br>'; 
    479444                        eval($code); 
    480  
     445                         
    481446                        return $branch; 
    482447                } 
    483448 
    484449                /*! 
    485  
     450                  
    486451                 @function get_info_by_level 
    487452                 @abstract Returns the information about the catalog, given the level 
     
    495460                        $path = @explode('.',$level); 
    496461                        $n_ways = count($path); 
    497  
     462                         
    498463                        if ($n_ways <= 1) 
    499464                        { 
    500465                                return false; 
    501466                        } 
    502  
     467                         
    503468                        $info = $this->tree[$path[1]]; 
    504  
     469                         
    505470                        return $info; 
    506471                } 
     
    553518 
    554519                                        $search = $this->get_level_by_branch($catalog, $bcatalog['sub_branch'], (string) $level); 
    555  
     520                                         
    556521                                        if ($search !== false) 
    557522                                        { 
     
    567532                        return false; 
    568533                } 
    569  
    570                 /*! 
    571  
     534                 
     535                /*! 
     536                 
    572537                        @function get_actual_catalog 
    573                         @abstract Returns the information about the Catalog that is 
     538                        @abstract Returns the information about the Catalog that is  
    574539                                instantiated 
    575540 
    576541                        @author Raphael Derosso Pereira 
    577  
     542                 
    578543                */ 
    579544                function get_actual_catalog() 
     
    582547                        return $catalog; 
    583548                } 
    584  
    585                 /*! 
    586  
     549                 
     550                /*! 
     551                 
    587552                        @function set_catalog 
    588553                        @abstract Sets the actual catalog 
    589554                        @author Raphael Derosso Pereira 
    590  
     555                         
    591556                        @param array $to_catalog The catalog in the format returned by 
    592557                                get_available_tree or the level 
    593  
     558                 
    594559                */ 
    595560                function set_catalog(& $to_catalog ) 
     
    614579                        { 
    615580                                $catalog =& $to_catalog; 
    616                                 //echo "Daqui!<br>"; 
    617581                                $level = $this->get_level_by_branch($to_catalog, $this->tree['branches']); 
    618582                        } 
    619  
    620583                        $lvl_vector = explode('.', $level); 
    621584                        $id = $lvl_vector[1]; 
    622  
     585                         
    623586                        switch($catalog['type']) 
    624587                        { 
     
    642605                                                $call .= ','.implode(',',$args); 
    643606                                        } 
    644  
     607                                         
    645608                                        $call .= ');'; 
    646  
     609                                         
    647610//                                      print_r($catalog); 
    648611//                                      echo '<br><br><b>Setando Catalogo '.$catalog['name'].': </b>'.$call.'<br>'; 
    649612 
    650613                                        eval($call); 
    651  
     614                                                                 
    652615                                        return $catalog; 
    653  
     616                                         
    654617                                default: return false; 
    655618                        } 
    656619                } 
    657  
     620                 
    658621 
    659622 
     
    661624                 *                Methods to set general fields                      * 
    662625                \*********************************************************************/ 
    663  
    664                 /*! 
    665  
     626                 
     627                /*! 
     628                 
    666629                        @function add_vcard 
    667630                        @abstract Insert a VCard to the squema 
     
    669632                        @param string $uploaded_file The path to the file that were 
    670633                                uploaded. 
    671  
     634                 
    672635                */ 
    673636                function add_vcard ( $uploaded_file ) 
     
    676639 
    677640 
    678  
     641                 
    679642                /*********************************************************************\ 
    680643                 *                Methods to get general data                        * 
    681644                \*********************************************************************/ 
    682  
     645                 
    683646        } 
    684647?> 
Note: See TracChangeset for help on using the changeset viewer.