Changeset 285 for trunk/contactcenter


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.

Location:
trunk/contactcenter
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/contactcenter/doc/change_log.txt

    r284 r285  
    33Nilton Emilio Buhrer Neto. 
    44 
     5--------------------------- NOTA IMPORTANTE -------------------------- 
    56 
     7A partir de Agosto de 2007, todos os registros de bugs aqui relatados foram 
     8transferidos para o site do ExpressoLivre, no Wiki-Trac do módulo. 
     9Vide: http://www.expressolivre.org/dev/wiki/contactcenter/changelog 
     10 
     11---------------------------------------------------------------------- 
    61227/02/2007 - [1.0.005] 
    713- Excluído o diretorio contactcenter/templates/celepar e seus arquivos foram movidos para 
  • trunk/contactcenter/inc/class.bo_catalog_group_catalog.inc.php

    r284 r285  
    2020 
    2121        include_once('class.abo_catalog.inc.php'); 
    22  
     22         
    2323        class bo_catalog_group_catalog extends abo_catalog 
    2424        { 
    25  
    2625                var $external; 
    27  
    2826                var $fields = array( 
    2927                        'id_contact'    => true, 
     
    4038                        'pgp_key'       => true, 
    4139                        'notes'         => true, 
    42  
     40                         
    4341                        /* Array fields */ 
    4442                        'companies'     => true, 
     
    4745                        'connections'   => true 
    4846                ); 
    49  
    50                 /*! 
    51  
     47         
     48                /*! 
     49                 
    5250                 @function bo_people_catalog 
    5351                 @abstract Constructor 
    5452                 @author Raphael Derosso Pereira 
    55  
     53                  
    5654                */ 
    57                 function bo_catalog_group_catalog(& $bo_contactcenter, & $catalog, $external = 0) 
     55                function bo_catalog_group_catalog(& $bo_contactcenter, & $catalog, $external = 0 ) 
    5856                { 
    5957                        $this->bo_contactcenter = & $bo_contactcenter; 
     
    6159                        $this->external = $external; 
    6260                } 
    63  
     61                         
    6462 
    6563                /*! 
     
    7169 
    7270                 @param SEE class bo_contactcenter for usage 
    73  
     71                 
    7472                */ 
    7573                function find($what, $rules, $other) 
     
    7775                        if ($ldap_info = $this->catalog['ldap']) 
    7876                        { 
    79  
    8077                                $meta_catalog =& CreateObject('contactcenter.bo_global_ldap_catalog',$ldap_info['id_source'], $ldap_info['context'], $this->external); 
    8178                                return $meta_catalog->find($what, $rules, $other); 
    8279                        } 
    83  
     80                         
    8481                        $results = array(); 
    85  
     82                         
    8683                        reset($this->catalog); 
    8784                        while(list(, $new_catalog) = each($this->catalog['sub_branch'])) 
     
    9087                                //echo 'Setting catalog: <b>'.$new_catalog['name'].'</b><br>'; 
    9188                                $new_catalog = $this->bo_contactcenter->set_catalog($new_catalog); 
    92  
     89                                 
    9390                                //if($new_catalog) echo 'Setado corretamente!<br><br>'; else echo 'Erro ao setar<br><br>'; 
    94  
     91                                 
    9592                                if ($new_catalog['type'] === 'empty') 
    9693                                { 
    9794                                        continue; 
    9895                                } 
    99  
     96                                 
    10097                                $temp_res = $this->bo_contactcenter->catalog->find($what, $rules, $other); 
    10198                                if (is_array($temp_res) and count($temp_res)) 
     
    111108                        return $result; 
    112109                } 
    113  
    114                 /*! 
    115  
     110                 
     111                /*! 
     112                 
    116113                 @function get_single_entry 
    117114                 @abstract Returns all information requested about one contact 
    118115                 @author Raphael Derosso Pereira 
    119  
     116                      
    120117                 @param integer $id_contact The contact ID 
    121118                 @param array $fields The array returned by get_fields whith true 
    122119                        on the fields to be taken. 
    123  
     120                         
    124121                */ 
    125122                function get_single_entry ( $id_contact, $fields ) 
    126                 { 
    127                         if (!is_array($fields)) 
    128                         { 
    129                                 if (is_object($GLOBALS['phpgw']->log)) 
     123                {        
     124                        if (!is_array($fields))  
     125                        { 
     126                                if (is_object($GLOBALS['phpgw']->log))  
    130127                                { 
    131128                                        $GLOBALS['phpgw']->log->message(array( 
     
    133130                                                'line' => __LINE__, 
    134131                                                'file' => __FILE__)); 
    135  
     132                                         
    136133                                        $GLOBALS['phpgw']->log->commit(); 
    137134                                } 
    138                                 else 
     135                                else  
    139136                                { 
    140137                                        exit('Argument Error on: <br>File:'.__FILE__.'<br>Line:'.__LINE__.'<br>'); 
    141138                                } 
    142139                        } 
    143  
     140                         
    144141                        $contact_array = $this->get_multiple_entries(array($id_contact), $fields); 
    145  
     142                         
    146143                        if (!count($contact_array)) 
    147144                        { 
     
    153150                        else 
    154151                                $contact_data = $contact_array[$id_contact]; 
    155  
     152                         
    156153                        if (!is_array($contact_data)) 
    157154                        { 
    158155                                return false; 
    159156                        } 
    160  
     157                         
    161158                        return $contact_data; 
    162159                } 
    163  
    164                 /*! 
    165  
     160         
     161                /*! 
     162                  
    166163                 @function get_multiple_entries 
    167164                 @abstract Returns multiple Contacts data into one array 
     
    176173                                'sort'      => <sort>, 
    177174                                'order_by'  => <order by> 
    178                         ); 
    179  
     175                        );  
     176                 
    180177                */ 
    181178                function get_multiple_entries ( $id_contacts, $fields, $other_data = false ) 
     
    183180                        if (!is_array($id_contacts) or !is_array($fields) or ($other_data != false and !is_array($other_data))) 
    184181                        { 
    185                                 if (is_object($GLOBALS['phpgw']->log)) 
     182                                if (is_object($GLOBALS['phpgw']->log))  
    186183                                { 
    187184                                        $GLOBALS['phpgw']->log->message(array( 
     
    189186                                                'line' => __LINE__, 
    190187                                                'file' => __FILE__)); 
    191  
     188                                         
    192189                                        $GLOBALS['phpgw']->log->commit(); 
    193190                                } 
     
    196193                                } 
    197194                        } 
    198  
     195                         
    199196                        $contacts = array(); 
    200  
     197         
    201198                        if ($other_data) 
    202199                        { 
    203200                                //TODO 
    204201                        } 
    205  
    206                         //error_log("bo_ldap_catalog_group_catalog->get_multiple_entries \n", 3, '/var/www/teste.log'); 
    207  
     202         
    208203                        /* First check if this is a LDAP Catalog Group. In this case, just leave the 
    209204                         * subtree search for the LDAP server 
     
    214209                                return $meta_catalog->get_multiple_entries($id_contacts, $fields, $other_data); 
    215210                        } 
    216  
     211                         
    217212                        /* Search for the catalog of the first entry and try to get all ids from that 
    218213                         * catalog. Repeat to the ones not found until there's none missing or no more 
     
    226221                                $this->bo_contactcenter->set_catalog($branch); 
    227222                                $contacts += $this->bo_contactcenter->catalog->get_multiple_entries($id_contacts, $fields, $other_data); 
    228  
     223                                 
    229224                                reset($contacts); 
    230225                                while (list($id) = each($contacts)) 
     
    243238 
    244239                        $this->bo_contactcenter->set_catalog($this->catalog); 
    245  
     240                         
    246241                        return $contacts; 
    247242                } 
    248  
     243         
    249244                function get_all_entries_ids () 
    250245                { 
     
    252247                        return null; 
    253248                } 
    254  
     249                 
    255250                /*********************************************************************\ 
    256251                 *                Methods to get general fields                      * 
    257252                \*********************************************************************/ 
    258  
     253                 
    259254                /*********************************************************************\ 
    260255                 *                   Methods to Include Data                         * 
  • 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?> 
  • trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php

    r284 r285  
    1616        */ 
    1717        include_once('class.abo_catalog.inc.php'); 
    18  
     18         
    1919        class bo_global_ldap_catalog extends abo_catalog 
    2020        { 
    2121                var $ldap; 
    22  
     22         
    2323                var $src_info; 
    24  
     24                 
    2525                var $trans_table; 
    26  
    2726                // used to determine if a catalog is external 
    2827                var $external; 
    29  
    3028                var $fields = array( 
    3129                        'id_contact'    => true, 
     
    4341                        'pgp_key'       => true, 
    4442                        'notes'         => true, 
    45                         'department'    => true, 
    46  
    47                         'empNumber'     => true, 
    48  
     43                         
    4944                        /* Array fields */ 
    5045                        'companies'     => true, 
     
    5348                        'connections'   => true 
    5449                ); 
    55  
     50                 
    5651                /* 
    57  
     52                 
    5853                        @function global_ldap_catalog 
    5954                        @abstract Constructor 
     
    6459                        @param string $context Ldap bind DN 
    6560                        @param integer $external 0 = internal catalog, 1 = external catalog 
    66  
    6761                */ 
    6862                function bo_global_ldap_catalog ( $id_source, $context, $external = 0 ) 
    6963                { 
    70  
    7164                        $this->external = $external; 
    72  
    7365                        if (!function_exists('ldap_search')) 
    7466                        { 
    7567                                exit('PHP LDAP support Unavailable!'); 
    7668                        } 
    77  
     69                         
    7870                        $this->ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    79  
     71                         
    8072                        if ($this->external) 
    8173                        { 
     
    10092                        } 
    10193                        else 
    102                         { 
     94                        {        
    10395                                $this->trans_table = $this->ldap->get_ldap_fields_association($id_source); 
    10496                        } 
    10597                } 
    106  
     98                 
    10799                /* 
    108  
     100                 
    109101                        @function find 
    110102                        @abstract Searches the LDAP directory for the specified fields with 
     
    112104                                that matches the rules. 
    113105                        @author Raphael Derosso Pereira 
    114  
     106                         
    115107                        @param array $what The fields to be taken 
    116108                        @param array $rules The rules to be match. See class.abo_catalog.inc.php 
     
    121113                                        'offset' => (integer) [NOT IMPLEMENTED] 
    122114                                ) 
    123  
     115                 
    124116                */ 
    125117                function find($what, $rules=false, $other=false) 
    126118                { 
    127119                        $restric_fields = $this->get_restrictions_without_branch($rules); 
    128  
     120                         
    129121                        $trans_f = $this->translate_fields($what, $restric_fields); 
    130  
     122                         
    131123                        foreach($trans_f as $orig => $field_a) 
    132124                        { 
     
    136128                                } 
    137129                        } 
    138  
     130                         
    139131                        $fields = array_unique($fields); 
    140  
     132                         
    141133                        $filter = $this->process_restrictions($rules, $trans_f); 
    142134 
    143135                        if(strstr($this->src_info['context'], "ldap://")) { 
    144136                                $refer_context  = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $this->src_info['context'])); 
    145                                 $host   = preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $this->src_info['context']); 
     137                                $host   = preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $this->src_info['context']);                              
    146138                                $this->src_info['host'] = $host; 
    147                                 $this->src_info['acc'] = ''; 
    148                                 $this->src_info['pw']  = ''; 
    149                         } 
    150  
    151                         $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], true); 
    152  
    153                         if (!$ldap) 
    154                         { 
     139                        }                        
     140 
     141                        if($refer_context || "ou" === strtolower(substr($this->src_info['context'], 0, 2))) 
     142                        {                
     143                                $followReferral = false;                         
     144                        } 
     145                        elseif(trim($rules[4]['value']) != "inetOrgPerson")      
     146                        {                        
     147                                $followReferral = true; 
     148                        } 
     149                        else 
     150                        {                                
    155151                                return false; 
    156152                        } 
    157  
    158                         if (!$this->external) 
    159                         { 
    160                                 $fields[]  ='phpgwAccountVisible'; 
    161                         } 
    162  
    163                         $result_r = @ldap_search($ldap ,($refer_context  ? $refer_context  : $this->src_info['context']), $filter, $fields, 0); 
     153                         
     154                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], $followReferral); 
     155                        $result_r = ldap_search($ldap ,($refer_context  ? $refer_context  : $this->src_info['context']), $filter, $fields, 0); 
    164156 
    165157                        if (!$result_r) 
     
    167159                                return false; 
    168160                        } 
    169  
     161                         
    170162                        if ($other['order']) 
    171163                        { 
     
    181173                                } 
    182174                        } 
    183  
     175                         
    184176                        $result_u = ldap_get_entries($ldap, $result_r); 
    185  
     177                         
    186178                        $i = 0; 
    187179                        foreach ($result_u as $index => $result_p) 
     
    191183                                        continue; 
    192184                                } 
    193  
     185                                 
    194186                                foreach ($trans_f as $orig => $trans) 
    195187                                { 
     
    209201                                $i++; 
    210202                        } 
    211  
     203                         
    212204                        return $return; 
    213205                } 
    214  
     206                 
    215207                /* 
    216  
     208                 
    217209                        @function translate_fields 
    218210                        @abstract Return the LDAP objectClass fields that corresponds to the 
    219211                                specified parameter fields 
    220212                        @author Raphael Derosso Pereira 
    221  
     213                         
    222214                        @param array $fields The fields in the standard ContactCenter format 
    223215                        @param array $rules The rules 
    224  
     216                 
    225217                */ 
    226218                function translate_fields ( $fields, &$restric_fields ) 
    227219                { 
    228220                        $return = array(); 
    229  
     221                         
    230222                        $i = 0; 
    231223                        foreach ($fields as $field) 
     
    235227                                        continue; 
    236228                                } 
    237  
     229                                 
    238230                                if (!is_array($this->trans_table[$field])) 
    239231                                { 
    240232                                        $reference = $this->trans_table[$field]; 
    241  
     233                                         
    242234                                        reset($restric_fields); 
    243235                                        while(list(,$field_r) = each($restric_fields)) 
    244236                                        { 
    245  
    246237                                                if ($field_r['field'] === $reference and array_key_exists($field_r['value'], $this->trans_table[$reference])) 
    247238                                                { 
     
    252243                                else 
    253244                                { 
    254  
    255245                                        if (!is_array($return[$field])) 
    256246                                        { 
     
    263253                                } 
    264254                        } 
    265  
     255                         
    266256                        if (count($return)) 
    267257                        { 
    268258                                return $return; 
    269259                        } 
    270  
     260                         
    271261                        return false; 
    272262                } 
    273  
     263                 
    274264                /* 
    275  
     265                 
    276266                        @function process_restrictions 
    277267                        @abstract Returns a LDAP filter string that corresponds to the 
    278268                                specified restriction rules 
    279269                        @author Raphael Derosso Pereira 
    280  
     270                         
    281271                        @param string $rules The restriction rules 
    282  
     272                 
    283273                */ 
    284274                function process_restrictions( $rules, &$trans_table, $join_type='&' ) 
     
    288278                                return null; 
    289279                        } 
    290  
     280                         
    291281                        foreach($rules as $rule_i => $rule) 
    292282                        { 
     
    300290                                                                $join = '|'; 
    301291                                                                break; 
    302  
     292                                                                 
    303293                                                        case 'AND': 
    304294                                                                $join = '&'; 
    305295                                                                break; 
    306  
     296                                                                 
    307297                                                        case 'NOT': 
    308298                                                                $join = '!'; 
    309299                                                                break; 
    310  
     300                                                                 
    311301                                                        default: 
    312302                                                                $join = $join_type; 
     
    314304                                                $return_t[] = $this->process_restrictions($rule['sub_branch'], $trans_table, $join); 
    315305                                                break; 
    316  
     306                                                 
    317307                                        case '=': 
    318308                                                if (array_key_exists($rule['field'], $trans_table)) 
     
    325315                                                } 
    326316                                                break; 
    327  
    328                                         case '!=': 
     317                                         
     318                                        case '!=':       
    329319                                                if (array_key_exists($rule['field'], $trans_table)) 
    330320                                                { 
     
    336326                                                } 
    337327                                                break; 
    338  
     328                                         
    339329                                        case '<=': 
    340330                                        case '<': 
     
    348338                                                } 
    349339                                                break; 
    350  
     340                                         
    351341                                        case '>': 
    352342                                        case '>=': 
     
    360350                                                } 
    361351                                                break; 
    362  
     352                                                 
    363353                                        case 'NULL': 
    364354                                                if (array_key_exists($rule['field'], $trans_table)) 
     
    371361                                                } 
    372362                                                break; 
    373  
     363                                         
    374364                                        case 'IN': 
    375365                                                if (array_key_exists($rule['field'], $trans_table)) 
     
    391381                                                        $value_1 = strtoupper(str_replace('%', '*', $rule['value'])); 
    392382                                                        $value_2 = strtolower($value_1); 
    393  
     383                                                         
    394384                                                        foreach($trans_table[$rule['field']] as $field) 
    395385                                                        { 
     
    400390                                                } 
    401391                                                break; 
    402  
     392                                                 
    403393*/                                      case 'LIKE': 
    404394                                                if (array_key_exists($rule['field'], $trans_table)) 
    405395                                                { 
    406396                                                        $value = str_replace('%', '*', $rule['value']); 
    407  
     397                                                         
    408398                                                        foreach($trans_table[$rule['field']] as $field) 
    409399                                                        { 
     
    413403                                                } 
    414404                                                break; 
    415  
     405                                                 
    416406                                        case 'NOT NULL': 
    417407                                                if (array_key_exists($rule['field'], $trans_table)) 
     
    424414                                                } 
    425415                                                break; 
    426  
     416                                         
    427417                                        case 'NOT IN': 
    428418                                                if (array_key_exists($rule['field'], $trans_table)) 
     
    444434                                                        $value_1 = strtoupper(str_replace('%', '*', $rule['value'])); 
    445435                                                        $value_2 = strtolower($value_1); 
    446  
     436                                                         
    447437                                                        foreach($trans_table[$rule['field']] as $field) 
    448438                                                        { 
     
    458448                                                { 
    459449                                                        $value = str_replace('%', '*', $rule['value']); 
    460  
     450                                                         
    461451                                                        foreach($trans_table[$rule['field']] as $field) 
    462452                                                        { 
     
    468458                                } 
    469459                        } 
    470  
     460                         
    471461                        if (count($return_t)) 
    472462                        { 
     
    486476 
    487477                /*! 
    488  
     478                 
    489479                        @function get_restrictions_without_branch 
    490480                        @abstract Returns an array containing the restrictions ignoring the 
    491481                                branches 
    492482                        @author Raphael Derosso Pereira 
    493  
     483                         
    494484                        @param array $restrictions The restrictions 
    495  
     485                 
    496486                */ 
    497487                function get_restrictions_without_branch(&$restrictions) 
     
    501491                                return null; 
    502492                        } 
    503  
     493                         
    504494                        $fields = array(); 
    505  
     495                         
    506496                        foreach ($restrictions as $restrict_data) 
    507497                        { 
     
    511501                                                $fields = array_merge($fields, $this->get_restrictions_without_branch($restrict_data['sub_branch'])); 
    512502                                                break; 
    513  
     503                                                 
    514504                                        case '=': 
    515                                         case '!=': 
     505                                        case '!=':       
    516506                                        case '<=': 
    517507                                        case '<': 
     
    528518                                                array_push($fields, $restrict_data); 
    529519                                                break; 
    530  
     520                                                 
    531521                                        default: 
    532                                                 exit('Error in '.__FILE__.' on '.__LINE__.'<br>The restriction type passed was: '.$restrict_data['type']); 
    533                                 } 
    534                         } 
    535  
     522                                                exit('Error in '.__FILE__.' on '.__LINE__.'<br>The restriction type passed was: '.$restrict_data['type']);                                       
     523                                } 
     524                        } 
     525                         
    536526                        return $fields; 
    537527                } 
    538  
    539  
     528                 
     529                 
    540530                /*********************************************************************\ 
    541531                 *                        Methods to Get Data                        * 
    542532                \*********************************************************************/ 
    543  
    544  
     533                 
     534         
    545535                /*! 
    546  
     536                 
    547537                 @function get_single_entry 
    548538                 @abstract Returns all information requested about one contact 
    549539                 @author Raphael Derosso Pereira 
    550  
     540                      
    551541                 @param integer $id_contact The contact ID 
    552542                 @param array $fields The array returned by get_fields with true 
    553543                        on the fields to be taken. 
    554  
     544                         
    555545                */ 
    556546                function get_single_entry ( $id_contact, $fields ) 
    557547                { 
    558                         if (!is_array($fields)) 
    559                         { 
    560                                 if (is_object($GLOBALS['phpgw']->log)) 
     548                        if (!is_array($fields))  
     549                        { 
     550                                if (is_object($GLOBALS['phpgw']->log))  
    561551                                { 
    562552                                        $GLOBALS['phpgw']->log->message(array( 
     
    564554                                                'line' => __LINE__, 
    565555                                                'file' => __FILE__)); 
    566  
     556                                         
    567557                                        $GLOBALS['phpgw']->log->commit(); 
    568558                                } 
    569                                 else 
     559                                else  
    570560                                { 
    571561                                        exit('Argument Error on: <br>File:'.__FILE__.'<br>Line:'.__LINE__.'<br>'); 
    572562                                } 
    573563                        } 
    574  
     564                         
    575565                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'],$this->src_info['acc'],$this->src_info['pw'],true); 
    576  
     566                         
    577567                        if (!$ldap) 
    578568                        { 
    579569                                return false; 
    580570                        } 
    581  
     571                         
    582572                        $resource = ldap_read($ldap, $id_contact, 'objectClass='.$this->src_info['obj']); 
    583573                        $n_entries = ldap_count_entries($ldap, $resource); 
     
    586576                                return false; 
    587577                        } 
    588  
     578                         
    589579                        $first_entry = ldap_first_entry($ldap, $resource); 
    590580                        $contact = ldap_get_attributes($ldap,$first_entry); 
    591                         if($contact['jpegPhoto']){ 
    592                                 $contact['jpegPhoto'] = ldap_get_values_len ($ldap, $first_entry, "jpegPhoto"); 
     581                        if($contact['jpegPhoto']){       
     582                                $contact['jpegPhoto'] = ldap_get_values_len ($ldap, $first_entry, "jpegPhoto");  
    593583                        } 
    594584 
    595585//                      print_r($contact); 
    596  
     586                         
    597587                //      $contact_data = $this->fields; 
    598  
     588                         
    599589                        foreach($fields as $field => $trueness) 
    600590                        { 
     
    604594                                        continue; 
    605595                                } 
    606  
     596                                 
    607597                                switch ($field) 
    608598                                { 
     
    613603                                                $l_fields['department']    = $this->trans_table['contact.business_info.department']; 
    614604                                                $l_fields['company_notes'] = $this->trans_table['contact.company.company_notes']; 
    615  
     605                                                 
    616606                                                $contact_data['companies'] = array(); 
    617607                                                foreach($l_fields as $l_field => $l_value) 
     
    621611                                                                continue; 
    622612                                                        } 
    623  
     613                                                         
    624614                                                        $contact_data['companies']['company1'][$l_field] = utf8_decode($contact[$l_value[0]][0]); 
    625615                                                } 
    626  
     616                                                 
    627617                                                if (!(count($contact_data['companies']))) 
    628618                                                { 
     
    630620                                                } 
    631621                                                break; 
    632  
     622                                         
    633623                                        case 'relations': 
    634624                                                unset($l_fields); 
     
    637627                                                        unset($contact_data['relations']); 
    638628                                                } 
    639  
     629                                                 
    640630                                                $contact_data['relations'] = array(); 
    641631                                                if (!is_array($this->trans_table['contact.contact_related.names_ordered'])) 
     
    645635                                                                continue; 
    646636                                                        } 
    647  
     637                                                         
    648638                                                        $i = 1; 
    649639                                                        foreach($trans as $l_type => $l_type_fields) 
     
    653643                                                                        continue; 
    654644                                                                } 
    655  
     645                                                                 
    656646                                                                $contact_data['relations']['relation'.$i]['type'] = $l_type; 
    657647                                                                $contact_data['relations']['relation'.$i]['names_ordered'] = utf8_decode($contact[$l_type_fields[0]][0]); 
     
    659649                                                        } 
    660650                                                } 
    661  
     651                                                 
    662652                                                if (!(count($contact_data['relations']))) 
    663653                                                { 
     
    665655                                                } 
    666656                                                break; 
    667  
     657                                         
    668658                                        case 'addresses': 
    669659                                                unset($l_fields); 
     
    694684                                                                        continue; 
    695685                                                                } 
    696  
     686                                                                 
    697687                                                                $i = 1; 
    698688                                                                foreach($trans as $l_type => $l_type_fields) 
     
    702692                                                                                continue; 
    703693                                                                        } 
    704  
     694                                                                         
    705695                                                                        $contact_data['addresses']['address'.$i]['type'] = $l_type; 
    706696                                                                        $contact_data['addresses']['address'.$i][$l_field] = utf8_decode($contact[$l_type_fields[0]][0]); 
     
    713703                                                        } 
    714704                                                } 
    715  
     705                                                 
    716706                                                if (!(count($contact_data['addresses']))) 
    717707                                                { 
     
    719709                                                } 
    720710                                                break; 
    721  
     711                                         
    722712                                        case 'connections': 
    723713                            $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
     
    740730                                                                        continue; 
    741731                                                                } 
    742  
     732                                                                 
    743733                                                                $i = 1; 
    744734                                                                foreach($trans as $l_type => $l_type_fields) 
     
    748738                                                                                continue; 
    749739                                                                        } 
    750  
     740                                                                         
    751741                                                                        switch ($l_type) 
    752742                                                                        { 
     
    768758                                                        } 
    769759                                                } 
    770  
     760                                                 
    771761                                                if (!(count($contact_data['connections']))) 
    772762                                                { 
     
    774764                                                } 
    775765                                                break; 
    776  
     766                                         
    777767                                        case 'prefix': 
    778768                                                unset($l_fields); 
     
    783773                                                        continue; 
    784774                                                } 
    785  
     775                                                 
    786776                                                $contact_data['prefix'] = utf8_decode($contact[$l_fields[0]][0]); 
    787777                                                break; 
    788  
     778                                                 
    789779                                        case 'suffix': 
    790780                                                unset($l_fields); 
     
    795785                                                        continue; 
    796786                                                } 
    797  
     787                                                 
    798788                                                $contact_data['suffix'] = utf8_decode($contact[$l_fields[0]][0]); 
    799789                                                break; 
    800  
     790                                                 
    801791                                        case 'status': 
    802792                                                unset($l_fields); 
     
    807797                                                        continue; 
    808798                                                } 
    809  
     799                                                 
    810800                                                $contact_data['status'] = utf8_decode($contact[$l_fields[0]][0]); 
    811801                                                break; 
    812  
     802                                                 
    813803                                                case 'photo': 
    814804                                                unset($l_fields); 
     
    819809                                                        continue; 
    820810                                                } 
    821  
     811                                                 
    822812                                                $contact_data['photo'] = $contact[$l_fields[0]][0]; 
    823                                                 break; 
     813                                                break;                                                                                   
    824814 
    825815                                        default: 
     
    831821                                                        continue; 
    832822                                                } 
    833  
     823                                                 
    834824                                                if(count($contact[$l_fields[0]]) > 1) 
    835825                                                { 
     
    848838                                } 
    849839                        } 
    850  
     840                         
    851841                        if (!is_array($contact_data)) 
    852842                        { 
    853843                                return false; 
    854844                        } 
    855  
     845                         
    856846                        return $contact_data; 
    857847                } 
    858  
     848                //SERPRO 
    859849                /*! 
    860850 
     
    932922                                                        $l_fields['department']    = $this->trans_table['contact.business_info.department']; 
    933923                                                        $l_fields['company_notes'] = $this->trans_table['contact.company.company_notes']; 
    934  
    935                                                         ///Relaciona o array com o atributo 'employeeNumber' do RHDS 
    936                                                         $l_fields['empNumber']     = $this->trans_table['contact.business_info.empNumber']; 
    937924 
    938925                                                        $contact_data['companies'] = array(); 
     
    11811168                        return $contacts; 
    11821169                } 
    1183  
     1170                 
    11841171                function get_multiple_entries ( $id_contacts, $fields, $other_data = false ) 
    11851172                { 
    11861173                        if (!is_array($id_contacts) or !is_array($fields) or ($other_data != false and !is_array($other_data))) 
    11871174                        { 
    1188                                 if (is_object($GLOBALS['phpgw']->log)) 
     1175                                if (is_object($GLOBALS['phpgw']->log))  
    11891176                                { 
    11901177                                        $GLOBALS['phpgw']->log->message(array( 
     
    11921179                                                'line' => __LINE__, 
    11931180                                                'file' => __FILE__)); 
    1194  
     1181                                         
    11951182                                        $GLOBALS['phpgw']->log->commit(); 
    11961183                                } 
     
    11991186                                } 
    12001187                        } 
    1201  
    1202                         $contacts = array(); 
    1203  
     1188                          
     1189                        foreach ($id_contacts as $id) 
     1190                        { 
     1191                                $contacts[$id] = $this->get_single_entry($id,$fields); 
     1192                        } 
     1193                         
     1194                        return $contacts; 
     1195 
     1196                        // SERPRO 
     1197                                                 
     1198                        /*$contacts = array(); 
     1199         
    12041200                        if ($other_data) 
    12051201                        { 
     
    12111207                        //$teste = $this->get_all_entries($filter, $fields); 
    12121208 
    1213                         return $this->get_all_entries($filter, $fields); 
    1214                 } 
    1215  
     1209                        return $this->get_all_entries($filter, $fields);*/ 
     1210                         
     1211                } 
     1212 
     1213        // CELEPAR 
     1214                function generate_filter($id_contacts) 
     1215                { 
     1216                        if (($size = count($id_contacts))) 
     1217                        { 
     1218                                $contacts[$id] = $this->get_single_entry($id,$fields); 
     1219                        } 
     1220                         
     1221                        return $contacts; 
     1222                } 
     1223                 
     1224                // SERPRO 
     1225                /* 
    12161226                function generate_filter($id_contacts) 
    12171227                { 
     
    12221232                                { 
    12231233 
    1224                                         /* 
    1225                                          * Não utiliza mais a função ldap_explode, usa a expressão regular a seguir para pegar o primeiro 
    1226                                          * componente da dn 
    1227                                          */ 
     1234                                        //  
     1235                                        // Não utiliza mais a função ldap_explode, usa a expressão regular a seguir para pegar o primeiro 
     1236                                        // componente da dn 
     1237                                        //  
    12281238                                        preg_match('/^(\w*=[^,]*),.*$/', $id_contacts[$i], $cn); 
    12291239 
    1230                                 /* 
    1231                                  * Adicionados os str_replace para adicionar caracteres de escape em frente aos caracteres '(' e ')', 
    1232                                  * posteriormente poderá ser necessário substituir por uma expressão regular mais genérica. 
    1233                                  */ 
     1240                                // 
     1241                                // Adicionados os str_replace para adicionar caracteres de escape em frente aos caracteres '(' e ')', 
     1242                                // posteriormente poderá ser necessário substituir por uma expressão regular mais genérica. 
     1243                                // 
     1244 
    12341245                                        if ($cn[1]) 
    12351246                                        { 
    1236                                                 /* 
    1237                                                  * Esta operação resolve o problema causado pela conversão de caracteres acentuados realizada 
    1238                                                  * pela função ldap_explode_dn(). Talvez seja necessário utilizar esta tradução em outros lugares, 
    1239                                                  * neste caso é mais apropriado colocar dentro de uma função. 
    1240                                                  */ 
     1247                                                // 
     1248                                                // Esta operação resolve o problema causado pela conversão de caracteres acentuados realizada 
     1249                                                // pela função ldap_explode_dn(). Talvez seja necessário utilizar esta tradução em outros lugares, 
     1250                                                // neste caso é mais apropriado colocar dentro de uma função. 
     1251                                                // 
    12411252                                                //foreach($cn as $key=>$value){ 
    12421253                                        //      $cn[$key]=preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''", $value); 
     
    12521263 
    12531264                } 
     1265                */ 
    12541266 
    12551267                function get_all_entries_ids () 
     
    12801292                        return null; 
    12811293                } 
    1282  
     1294                 
    12831295                function get_relations ($id_contact,$extra=false) 
    12841296                { 
    12851297                } 
    1286  
     1298                 
    12871299                function get_addresses ( $id_contact,$extra=false ) 
    12881300                { 
    12891301                } 
    1290  
     1302                 
    12911303                function get_connections ( $id_contact,$extra=false ) 
    12921304                { 
    12931305                } 
    1294  
     1306                 
    12951307                function get_companies ( $id_contact, $extra=false ) 
    12961308                { 
    12971309                } 
    1298  
     1310                 
    12991311                function get_all_prefixes (  ) 
    13001312                { 
    13011313                } 
    1302  
     1314                 
    13031315                function get_all_suffixes (  ) 
    13041316                { 
    13051317                } 
    1306  
     1318                 
    13071319                function get_all_status (  ) 
    13081320                { 
    13091321                } 
    1310  
     1322                 
    13111323                function get_all_relations_types (  ) 
    13121324                { 
    13131325                } 
    1314  
     1326                 
    13151327                function get_all_addresses_types (  ) 
    13161328                { 
    13171329                } 
    1318  
     1330                 
    13191331                function get_all_connections_types (  ) 
    13201332                { 
    13211333                } 
    1322  
     1334                 
    13231335                function get_vcard ( $id_contact ) 
    13241336                { 
    13251337                } 
    1326  
    1327  
    1328  
    1329  
     1338                 
     1339                 
     1340                 
     1341                 
    13301342                function get_global_tree ( $root ) 
    13311343                { 
    13321344                } 
    1333  
     1345         
    13341346                function get_actual_brach (  ) 
    13351347                { 
    13361348                } 
    1337  
     1349         
    13381350                function set_actual_branch ( $branch ) 
    13391351                { 
  • trunk/contactcenter/inc/class.bo_ldap_manager.inc.php

    r284 r285  
    1212  \***************************************************************************/ 
    1313 
    14  
     14         
    1515        /* 
    1616                This class is responsible for the LDAP control/generic functions and for 
     
    1919        include_once('class.Thread.inc.php'); 
    2020 
    21         class bo_ldap_manager 
     21        class bo_ldap_manager  
    2222        { 
    23  
     23                 
    2424                var $srcs; 
    2525 
     26                 
    2627                function bo_ldap_manager () 
    2728                { 
    28  
    2929                        if (!($this->srcs = $GLOBALS['phpgw']->session->appsession('bo_ldap_manager.srcs','contactcenter'))) 
    3030                        { 
    3131                                $c = CreateObject('phpgwapi.config','contactcenter'); 
    3232                                $data = $c->read_repository(); 
    33  
     33                                 
    3434                                if (!$data or $data['cc_global_source0'] !== 'ldap') 
    3535                                { 
     
    3737                                        return; 
    3838                                } 
    39  
     39                                 
    4040                                $this->srcs = array( 
    4141                                        1 => array( 
     
    4646                                                'pw'     => $data['cc_ldap_pw0'], 
    4747                                                'obj'    => 'inetOrgPerson', 
    48                                                 'branch' => strtolower('ou') 
     48                                                'branch' => strtolower('ou'), 
     49                                                'visible' => $data['cc_ldap_query_automatic'] 
    4950                                        ) 
    50  
    5151                                ); 
    5252                        } 
     
    5656                { 
    5757                } 
    58  
     58         
    5959                /* 
    60  
     60                 
    6161                        @function get_all_ldap_sources 
    6262                        @abstract Returns an array containing all LDAP sources informations 
    6363                        @author Raphael Derosso Pereira 
    64  
     64                 
    6565                        @return array All LDAP information 
    6666                                $return = array( 
     
    6969                                                'dn'   => (string), 
    7070                                                'acc'  => (string), 
    71                                                 'pw'   => (string) 
     71                                                'pw'   => (string)    
    7272                                        ), 
    7373                                        ... 
    7474                                ) 
    75  
     75                                 
    7676                        TODO: Return multiple sources... 
    7777                */ 
     
    8080                        return $this->srcs; 
    8181                } 
    82  
     82                 
    8383                /* 
    8484                * @function get_external_ldap_sources 
     
    102102                function get_ldap_fields_association ( $id_source ) 
    103103                { 
    104  
     104                         
    105105                        $op_iop = array( 
    106106                                'contact.id_contact'               => array('dn'), 
     
    111111                                'contact.family_names'             => array('sn'), 
    112112                                'contact.names_ordered'            => array('cn'),//,'displayName'), 
    113  
    114113                                'contact.suffixes.suffix'          => false, 
    115114                                'contact.birthdate'                => false, 
     
    117116                                'contact.pgp_key'                  => false, 
    118117                                'contact.notes'                    => false, 
    119                                 'contact.mail_forwarding_address'  => array('mailForwardingAddress'), 
    120                                 'contact.account_type'             => array('phpgwAccountType'), 
    121                                 'contact.account_status'           => array('phpgwAccountStatus'), 
    122                                 'contact.account_visible'          => array('phpgwAccountVisible'), 
     118                                'contact.mail_forwarding_address' => array('mailForwardingAddress'), 
     119                                'contact.account_type' => array('phpgwAccountType'), 
     120                'contact.account_status'           => array('phpgwAccountStatus'), 
     121                'contact.account_visible'          => array('phpgwAccountVisible'), 
    123122                                'contact.object_class'             => array('objectClass'), 
    124123                                'contact.business_info.title'      => array('title'), 
    125                                 'contact.business_info.department' => array('ou'), // Setor do empregado... 
    126                                 'contact.business_info.empNumber'  => array('employeeNumber'), // Matricula do empregado 
     124                                'contact.business_info.department' => array('ou'), 
    127125                                'contact.company.company_name'     => array('o'), 
    128126                                'contact.company.company_notes'    => array('businessCategory'), 
    129  
     127                                 
    130128                                'contact.contact_related.names_ordered' => 'contact.contact_related.typeof_relation.contact_relation_name', 
    131129                                'contact.contact_related.typeof_relation.contact_relation_name' =>  array( 
     
    133131                                        'secretary' => array('secretary') 
    134132                                ), 
    135  
     133                                 
    136134                                'contact.address.address1'         => 'contact.address.typeof_address.contact_address_type_name', 
    137135                                'contact.address.typeof_address.contact_address_type_name' => array( 
    138136                                        'home' => array('street', 'st', 'postalAddress', 'homePostalAddress'), 
    139137                                ), 
    140  
     138                                 
    141139                                'contact.address.postal_code'      => 'contact.address.typeof_address.contact_address_type_name', 
    142140                                'contact.address.typeof_address.contact_address_type_name' => array( 
    143141                                        'home' => array('PostalCode'), 
    144142                                ), 
    145  
     143                                 
    146144                                'contact.address.city.city_name'   => 'contact.address.typeof_address.contact_address_type_name', 
    147145                                'contact.address.typeof_address.contact_address_type_name' => array( 
    148146                                        'home' => array('l'), 
    149147                                ), 
    150  
     148                                 
    151149                                'contact.address.city.state.state_name'       => 'contact.address.typeof_address.contact_address_type_name', 
    152150                                'contact.address.typeof_address.contact_address_type_name' => array( 
    153151                                        'home' => false, 
    154152                                ), 
    155  
     153                                 
    156154                                'contact.address.city.country.id_country'     => 'contact.address.typeof_address.contact_address_type_name', 
    157155                                'contact.address.typeof_address.contact_address_type_name' => array( 
    158156                                        'home' => array('c') 
    159157                                ), 
    160  
     158                                 
    161159                                'contact.connection.connection_value'         => 'contact.connection.typeof_connection.contact_connection_type_name', 
    162160                                'contact.connection.typeof_connection.contact_connection_type_name' => array ( 
     
    169167                                ), 
    170168                        ); 
    171  
     169                         
    172170                        return $op_iop; 
    173  
    174171                } 
    175172 
     
    232229 
    233230                /*! 
    234  
     231                 
    235232                        @function get_ldap_tree 
    236233                        @abstract Returns the LDAP tree corresponding to the specified level 
    237234                        @author Raphael Derosso Pereira 
    238  
     235                         
    239236                        @param (integer) $id_source The ID of the LDAP source 
    240  
     237                         
    241238                        @param (string)  $context The context to be used as root branch 
    242  
     239                                 
    243240                        @param (boolean) $recursive Make it a recursive construction. 
    244241                                CAUTION! This is EXTREMELY SLOW on large LDAP databases, 
    245242                                specially when they're not indexed 
    246                 */ 
    247                 function get_ldap_tree($id_source, $context = false, $recursive = false) 
     243                */               
     244                function get_ldap_tree($id_source, $context = false, $recursive = false)  
    248245                { 
    249246                        if (!$this->srcs[$id_source]) 
     
    251248                                return null; 
    252249                        } 
    253  
     250                         
    254251                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->srcs[$id_source]['host'], $this->srcs[$id_source]['acc'],$this->srcs[$id_source]['pw'], false); 
    255252                        if (!$ldap) 
     
    257254                                return false; 
    258255                        } 
    259  
     256                         
    260257                        if ($recursive) 
    261258                        { 
     
    265262                                return $tree; 
    266263                        } 
    267  
    268                         return $this->get_ldap_tree_level($id_source, $ldap, $context, $this->srcs[$id_source]['obj'],$this->srcs[$id_source]['branch'], 0); 
    269                 } 
     264                         
     265                        return $this->get_ldap_tree_level($id_source, $ldap, $context, $this->srcs[$id_source]['obj'],$this->srcs[$id_source]['branch']); 
     266                } 
     267                // SERPRO 
    270268 
    271269                /*! 
     
    336334                                return null; 
    337335                        } 
    338  
     336                         
    339337                        $count = ldap_count_entries($resource,$result_res); 
    340338                        if ( $count == 0 ) 
     
    353351                                } 
    354352                        } 
    355  
     353                         
    356354                        $entries = ldap_get_entries($resource, $result_res); 
    357  
     355                         
    358356                        for ($i = 0; $i < $entries['count']; $i++) 
    359357                        { 
    360358                                $subtree = $this->get_ldap_tree_recursive($resource, $entries[$i]['dn'], $objectClass); 
    361  
     359                                 
    362360                                $dn_parts=ldap_explode_dn($entries[$i]['dn'],1); 
    363  
    364  
    365  
    366                                 if ($subtree !== null and is_array($subtree)) 
     361                                 
     362                                if ($subtree !== null and is_array($subtree))  
    367363                                { 
    368364                                        $tree[$i]['name'] = $dn_parts[0]; 
     
    381377                                                'sub_branch' => false 
    382378                                        ); 
    383                                 } 
     379                                }  
    384380                        } 
    385381 
     
    393389                        } 
    394390                } 
    395  
     391                 
    396392                function get_ldap_referrals($ds, $dn, $filter) { 
    397  
     393                         
    398394                        ldap_set_option($ds, LDAP_OPT_REFERRALS, 0); 
    399395                        ldap_set_option($ds,LDAP_OPT_PROTOCOL_VERSION,3); 
    400  
     396                         
    401397                        if ($ds) { 
    402398                            ldap_bind($ds); 
    403                                 $sr=ldap_list($ds,$dn, $filter); 
     399                                $sr=ldap_list($ds,$dn, $filter);                     
    404400                                $ref = ldap_first_reference($ds, $sr); 
    405401                                $array_referral = array(); 
    406402                                $idx = 0; 
    407  
     403                                 
    408404                                 while ($ref) { 
    409405                                        $array_referral[$idx++] = ldap_get_dn($ds, $ref); 
     
    412408                                return $array_referral; 
    413409                        } 
    414                         else 
     410                        else  
    415411                                return false; 
    416412                } 
    417413 
    418414                function get_ldap_sub_branches_referrals($ds, $dn, $filter) { 
    419  
     415                         
    420416                        $referral = $this -> get_ldap_referrals($ds, $dn, $filter); 
    421417                        $sub_branches = array(); 
    422  
     418                         
    423419                        for($i = 0; $i <count($referral); $i++) { 
    424420                                $dn = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $referral[$i])); 
    425                                 $dn = explode(",",$dn); 
     421                                $dn = explode(",",$dn);                          
    426422                                $dn = strtoupper(str_replace("ou=", "",$dn[0])); 
    427423                                $dn = str_replace("DC=", "",$dn); 
    428  
     424                                                                                                                                                                                 
    429425                                $sub_branch = array( 
    430426                                                                                        'name' => $dn, 
    431427                                                                'type' => 'unknown', 
    432428                                                                'value' => $referral[$i], 
    433                                                                 'sub_branch' => false 
    434                                                                                 ); 
    435                                 $sub_branches[$i] = $sub_branch; 
     429                                                                'sub_branch' => false            
     430                                                                                );                                                                                                                       
     431                                $sub_branches[$i] = $sub_branch;                         
    436432                        } 
    437433                        return $sub_branches; 
    438434                } 
     435                 
    439436 
    440437                function translate_accentuation($text) 
     
    464461                        //$filter = '(!(objectClass='.$objectClass.'))'; 
    465462                        // Don't show OU's whith phpgwAccountVisible equal to '-1' 
    466  
    467463                        if ($external) 
    468464                        { 
     
    483479                        if ($result_res === false) 
    484480                        { 
    485                                 if (ldap_errno($resource) === 3) 
    486                                 { 
    487                                         return array('error_msg' => ldap_error($resource)); 
    488                                 } 
    489481                                return null; 
    490482                        } 
     
    591583                                $tree['ldap']       = array('id_source' => $id_source, 'context' => $context); 
    592584                        } 
     585                         
    593586                        usort($tree['sub_branch'], array($this, "compareTreeNodes")); 
    594587                        return $tree; 
     
    596589 
    597590                function compareTreeNodes($a, $b)       { 
    598  
     591                                                 
    599592                        return strnatcasecmp($a['name'], $b['name']); 
    600                 } 
     593                }        
    601594 
    602595        } 
  • trunk/contactcenter/inc/class.bo_people_catalog.inc.php

    r284 r285  
    14171417                        if ($altered) 
    14181418                        { 
     1419                                $contact->set_field("last_status", 'U'); 
     1420                                $contact->set_field("last_update",time()."000"); 
    14191421                                return $contact->commit(); 
    14201422                        } 
  • trunk/contactcenter/inc/class.so_contact.inc.php

    r284 r285  
    110110                                'is_global'             => array( 
    111111                                        'name'          => 'is_global', 
     112                                        'type'          => false, 
     113                                        'state'         => 'empty', 
     114                                        'value'         => false), 
     115                                'last_status'           => array( 
     116                                        'name'          => 'last_status', 
     117                                        'type'          => false, 
     118                                        'state'         => 'empty', 
     119                                        'value'         => false), 
     120                                'last_update'           => array( 
     121                                        'name'          => 'last_update', 
    112122                                        'type'          => false, 
    113123                                        'state'         => 'empty', 
  • trunk/contactcenter/inc/class.so_group.inc.php

    r284 r285  
    117117                        'A.id_contact = B.id_contact and B.id_connection = C.id_connection and '. 
    118118                        'C.connection_is_default = true and B.id_typeof_contact_connection = 1 and '. 
    119                         'A.id_owner ='.$this->owner.' order by A.names_ordered'; 
     119                        'A.id_owner ='.$this->owner.' order by A.names_ordered,C.connection_value'; 
    120120 
    121121                                         
  • trunk/contactcenter/inc/class.ui_api.inc.php

    r284 r285  
    1818         * 
    1919         */ 
    20  
     20   
    2121        class ui_api 
    2222        { 
    2323                var $commons; 
    2424                var $commons_loaded = false; 
    25  
     25                 
    2626                function ui_api() 
    2727                { 
    2828                        $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
    29  
     29                         
    3030                        if (!is_array($preferences)) 
    3131                        { 
     
    3333                                //$preferences['personCardPhone'] = 2; 
    3434                        } 
    35  
    36                         $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/'; 
    37                         $template = CreateObject('phpgwapi.Template',$template_dir); 
     35                         
     36                        //$template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/'; 
     37                        //$template = CreateObject('phpgwapi.Template',$template_dir); 
     38                        $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
    3839 
    3940                        $template->set_file(array('api' => 'api_common.tpl')); 
    40  
     41                         
    4142                        $template->set_var('cc_email_id_type', $preferences['personCardEmail']); 
    42  
     43                         
     44                         
    4345                        /* Messages */ 
    4446                        $template->set_var('cc_msg_err_invalid_catalog',lang('Unavailable or empty Catalog')); 
    45                         $template->set_var('cc_msg_err_contacting_server',lang('Couldn\'t contact server or server response is invalid.')); 
     47                        $template->set_var('cc_msg_err_contacting_server',lang('Couldn\'t contact server or server response is invalid. Contact Admin.')); 
    4648                        $template->set_var('cc_msg_err_timeout',lang('Operation Timed Out.')); 
    4749                        $template->set_var('cc_msg_err_serialize_data_unknown',lang('Data to be serialized is of unknown type!')); 
     
    7577                        $template->set_var('cc_js_djswin', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dJSWin/dJSWin.js'); 
    7678                        $template->set_var('cc_js_catalog_tree', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_tree.js'); 
    77  
     79                         
    7880                        $template->parse('out','api'); 
    7981 
     
    8183                        $this->commons_loaded = false; 
    8284                } 
    83  
     85                 
    8486                /* DEPRECTED! Use get_email_win() instead */ 
    8587                function ui_get_email_win() 
     
    9193                { 
    9294                        //$search = $this->ui_get_search_win(); 
    93  
     95                         
    9496                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/'; 
    9597                        $template = CreateObject('phpgwapi.Template', $template_dir); 
    9698 
    9799                        $template->set_file(array('email_win' => 'email_win.tpl')); 
    98  
     100                         
    99101                        if (!$this->commons_loaded) 
    100102                        { 
     
    106108                                $template->set_var('cc_api', ''); 
    107109                        } 
    108  
     110                         
    109111                        //$template->set_var('cc_search_win', $search); 
    110112                        $template->set_var('cc_js_search', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search.js'); 
    111  
     113                         
    112114                        $template->set_var('cc_email_id_type', $search); 
    113  
     115                         
    114116                        $template->set_var('cc_email_win_title',lang('Contact Center').' - '.lang('Catalog Entries Emails')); 
    115117                        $template->set_var('cc_email_status',lang('Status').':'); 
    116118                        $template->set_var('cc_email_search_text',lang('Search').'...'); 
    117  
     119                         
    118120                        $template->set_var('cc_choose_catalogue',lang('Choose a catalogue').'...'); 
    119121                        $template->set_var('cc_choose_ordinance',lang('Choose a ordinance').'...'); 
    120  
     122                         
    121123                        $template->set_var('cc_btn_to_add',lang('To').' >>'); 
    122124                        $template->set_var('cc_btn_to_del','<< '.lang('To')); 
     
    130132                        $template->set_var('cc_btn_ok',lang('Ok')); 
    131133                        $template->set_var('cc_btn_cancel',lang('Cancel')); 
    132  
     134                         
    133135                        $template->set_var('cc_label_to',lang('To').':'); 
    134136                        $template->set_var('cc_label_cc',lang('Cc').':'); 
     
    138140                        $template->set_var('cc_label_catalogue_type',lang('Type Of Catalogue').':'); 
    139141                        $template->set_var('cc_label_ordinance_type',lang('Type Of Ordinace').':'); 
    140  
     142                         
    141143                        $template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); 
    142  
     144                         
    143145                        $template->set_var('cc_js_email_win', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_email_win.js'); 
    144  
     146                         
    145147                        $template->parse('out','email_win'); 
    146148 
     
    159161 
    160162                        $template->set_file(array('search' => 'search_win.tpl')); 
    161  
     163                         
    162164                        if (!$this->commons_loaded) 
    163165                        { 
     
    169171                                $template->set_var('cc_api', ''); 
    170172                        } 
    171  
     173                         
    172174                        $template->set_var('cc_search_title',lang('Contact Center - Search for Catalog Entries')); 
    173175                        $template->set_var('cc_search_minimize',lang('Minimize')); 
     
    178180                        $template->set_var('cc_search_go',lang('Go')); 
    179181                        $template->set_var('cc_search_cancel',lang('Cancel')); 
    180  
     182                         
    181183                        $template->set_var('cc_js_search_win', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search_win.js'); 
    182  
     184                         
    183185                        $template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); 
    184  
     186                         
    185187                        $template->parse('out','search'); 
    186188 
     
    203205 
    204206                        $template->set_file(array('full_add' => 'full_add.tpl')); 
    205  
     207                         
    206208                        if (!$this->commons_loaded) 
    207209                        { 
     
    213215                                $template->set_var('cc_api', ''); 
    214216                        } 
    215  
     217                         
    216218                        $template->set_var('cc_contact_title',lang('Contact Center').' - '.lang('Contacts')); 
    217219 
     
    221223                        $template->set_var('cc_msg_type_city',lang('Type new city here').'...'); 
    222224                        /* End Messages */ 
    223  
     225                         
    224226                        /* Contact */ 
    225227                        $template->set_var('cc_contact_save',lang('Save')); 
     
    230232                        $template->set_var('cc_contact_addrs',lang('Addresses')); 
    231233                        $template->set_var('cc_contact_conns',lang('Connections')); 
     234                        $template->set_var('emails_telephones', lang("E-Mails and Telephones")); 
     235                        $template->set_var('cc_default', lang("Default")); 
     236 
    232237                        /* End Contact */ 
    233  
     238                         
    234239                        /* Contact - Personal Data */ 
    235240                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    236  
     241                 
    237242                        $j = 0; 
    238243                        for ($i = 0; $i < 5; $i+=2) 
     
    257262                                $j++; 
    258263                        } 
    259  
     264                         
    260265                        $template->set_var('cc_pd_birth_size_0', "{$date[0]['size']}"); 
    261266                        $template->set_var('cc_pd_birth_size_1', "{$date[1]['size']}"); 
    262267                        $template->set_var('cc_pd_birth_size_2', "{$date[2]['size']}"); 
    263  
     268                         
    264269                        $template->set_var('cc_pd_birthdate_0', "{$date[0]['name']}"); 
    265270                        $template->set_var('cc_pd_birthdate_1', "{$date[1]['name']}"); 
     
    268273                        $template->set_var('cc_pd_select_photo_b', lang('Browse').'...'); 
    269274                        $template->set_var('cc_form_photo_src', 'photo_form.html'); 
    270  
     275                         
    271276                        $template->set_var('cc_pd_select_photo',lang('Select Photo')); 
    272277                        $template->set_var('cc_pd_alias',lang('Alias')); 
     
    286291                        $template->set_var('cc_pd_female',lang('Female')); 
    287292                        /* End Contact - Personal Data */ 
    288  
     293                         
    289294                        /* Contact - Addresses */ 
    290295                        $template->set_var('cc_addr_types',lang('Type of Address')); 
     
    310315                        $template->set_var('cc_available',lang('Available')); 
    311316                        /* End Contact - Addresses */ 
    312  
     317                         
     318                         
    313319                        /* Contact - Connections */ 
    314320                        $template->set_var('cc_conn_type',lang('Type of Connection')); 
    315321                        $template->set_var('cc_conn_name',lang('Connection Name')); 
    316322                        $template->set_var('cc_conn_value',lang('Connection Value')); 
    317  
     323                         
    318324                        $template->set_var('cc_new_same_type',lang('New from the same Type').'...'); 
    319  
     325                         
    320326                        $template->set_var('cc_conn_type_none',lang('Choose Type of Connection').'...'); 
    321327                        /* End Contact - Connections */ 
    322328 
     329                        $template->set_var('email', lang("E-Mail")); 
     330                        $template->set_var('telephone', lang("Telephone")); 
     331                        $template->set_var('choose_email_telephone', lang("Choose 'E-Mail' or 'Telephone'")); 
     332 
    323333                        $template->parse('out_full', 'full_add'); 
    324334 
     
    332342 
    333343                        $template->set_file(array('quickAdd' => 'quickAddPlugin.tpl')); 
    334  
     344                         
    335345                        if (!$this->commons_loaded) 
    336346                        { 
     
    342352                                $template->set_var('cc_api', ''); 
    343353                        } 
    344  
     354                         
    345355                        $template->set_var('ccQAPluginFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccQuickAdd-plugin.js'); 
    346356 
     
    350360                        $nFields = 5; 
    351361                        $fields = array( 
    352                                 lang('Alias'), 
    353                                 lang('Given Names'), 
    354                                 lang('Family Names'), 
     362                                lang('Alias'),  
     363                                lang('Given Names'),  
     364                                lang('Family Names'),  
    355365                                lang('Phone'), 
    356366                                lang('Email') 
    357367                        ); 
    358  
     368                         
    359369                        $template->set_var('ccQAnFields', $nFields); 
    360  
     370                         
    361371                        $fieldsHTML = ''; 
    362372                        $fieldsTop = 10; 
     
    379389                        $template->set_var('ccQAWinHeight', ($i+1)*$fieldsSpace+$fieldsTop); 
    380390                        $template->set_var('ccQAFunctionsTop', ($fieldsTop+$i*$fieldsSpace).'px'); 
    381  
     391                         
    382392                        /* Images Dir */ 
    383393                        $template->set_var('ccQACardImgRoot', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/'); 
    384  
     394                         
    385395                        /* Texts */ 
    386396                        $template->set_var('ccQATitle', lang('Contact Center').' - '.lang('Quick Add')); 
     
    388398                        $template->set_var('ccQAClear', lang('Reset')); 
    389399                        $template->set_var('ccQACancel', lang('Cancel')); 
    390  
     400                         
    391401                        $template->parse('out_QA', 'quickAdd'); 
    392402 
    393403                        return $template->get_var('out_QA'); 
    394404                } 
    395  
     405                 
    396406                function get_add_group() 
    397407                { 
     
    400410 
    401411                        $template->set_file(array('addGroup' => 'addGroup.tpl')); 
    402  
     412                         
    403413                        if (!$this->commons_loaded) 
    404414                        { 
     
    408418                        else 
    409419                        { 
    410  
     420                                 
    411421                                $template->set_var('cc_api', ''); 
    412422                        } 
    413  
    414                         $template->set_var('ccAGFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccAddGroup.js'); 
    415                         $template->set_var('ccAGWinHeightIE', '285'); 
     423                         
     424                        $template->set_var('ccAGFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccAddGroup.js');                   
     425                        $template->set_var('ccAGWinHeightIE', '285');                    
    416426                        $template->set_var('ccAGWinHeightMO', '335'); 
    417  
     427                         
    418428                        /* Images Dir */ 
    419429                        $template->set_var('ccAGCardImgRoot', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/'); 
    420  
     430                         
    421431                        /* Texts */ 
    422432                        $template->set_var('ccAGTitle', lang('Contact Center').' - '.lang('Group Add')); 
     
    424434                        $template->set_var('ccAGClear', lang('Reset')); 
    425435                        $template->set_var('ccAGCancel', lang('Cancel')); 
    426                         $title = '<input type="text" id="title" name="title" value="'.$group['title'].'" size="50" maxlength="50"/>'; 
    427  
    428                         $template->set_var('title', $title); 
     436                        $title = '<input type="text" id="title" name="title" value="'.$group['title'].'" size="50" maxlength="50"/>';                    
     437                                 
     438                        $template->set_var('title', $title);                                                                                             
    429439                        // set content and label variables. 
    430440                        $template->set_var(array( 
    431                                                 'msg_text'      => lang($status), 
    432                                                 'txt_title'     => lang('Contact Group List'), 
     441                                                'msg_text'      => lang($status),                                                
     442                                                'txt_title'     => lang('Contact Group List'),                                           
    433443                                                'txt_cancel'=> lang('cancel'), 
    434                                                 'txt_add'=> lang('Add'), 
     444                                                'txt_add'=> lang('Add'),                                                 
    435445                                                'txt_rem'=> lang('Remove'), 
    436446                                                'txt_personal_contacts' => lang('Personal Contacts'), 
    437447                                                'txt_contacts_in_list' => lang("Participants"), 
    438448                                                'txt_name'      => lang('Full Name'))); 
    439  
     449                                                 
    440450                        $template->parse('out_AG', 'addGroup'); 
    441  
     451                         
    442452                        return $template->get_var('out_AG'); 
    443453                } 
  • trunk/contactcenter/inc/class.ui_data.inc.php

    r284 r285  
    1414  \***************************************************************************/ 
    1515 
    16  
     16         
    1717        class ui_data 
    1818        { 
     
    2020                        'data_manager' => true, 
    2121                ); 
    22  
     22                 
    2323                var $bo; 
    2424                var $typeContact; 
    25  
     25                 
    2626                var $page_info = array( 
    2727                        'n_cards'          => 20, 
     
    3434                        'actual_catalog'   => false 
    3535                ); 
    36  
     36                 
    3737                /*! 
    38  
     38                 
    3939                        @function ui_data 
    4040                        @abstract The constructor. Sets the initial parameters and loads 
    4141                                the data saved in the session 
    4242                        @author Raphael Derosso Pereira 
    43  
     43                         
    4444                */ 
    4545                function ui_data() 
     
    4747                        $temp = $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter'); 
    4848                        $temp2 = $GLOBALS['phpgw']->session->appsession('ui_data.all_entries','contactcenter'); 
    49  
    50                         //TODO: Achar um modo de descarregar este array da sessï¿œo quando o usuï¿œrio sair da tela do contactcenter. 
    51                         //TODO: Descarregar este array da memï¿œria toda vez que uma nova consulta por letras ou mudanï¿œa de catï¿œlogo for feita. 
    52                         $temp3 = $GLOBALS['phpgw']->session->appsession('ui_data.last_search_ids','contactcenter'); 
    53  
     49                         
    5450                        $this->bo = CreateObject('contactcenter.bo_contactcenter'); 
    55  
     51                         
    5652                        if ($temp) 
    5753                        { 
     
    6359                                $this->all_entries = $temp2; 
    6460                        } 
    65  
    66                         if ($temp3) 
    67                         { 
    68                                 $this->last_search_ids = $temp3; 
    69                         } 
    70  
     61                         
    7162                        if (!$this->page_info['actual_catalog']) 
    7263                        { 
     
    7465                                $this->page_info['actual_catalog'] = $catalogs[0]; 
    7566                        } 
    76  
    77                         $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']); 
    78  
     67                         
     68                        $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']);                        
     69                         
    7970                        if($this->page_info['actual_catalog']['class'] == 'bo_group_manager') 
    8071                                $this -> typeContact = 'groups'; 
     
    8475 
    8576                /*! 
    86  
     77                 
    8778                        @function index 
    8879                        @abstract Builds the Main Page 
    8980                        @author Raphael Derosso Pereira 
    9081                        @author Jonas Goes 
    91  
    92                 */ 
     82                         
     83                */               
    9384                function index() 
    94                 { 
     85                {        
    9586                        if(!@is_object($GLOBALS['phpgw']->js)) 
    9687                        { 
     
    10192                        $GLOBALS['phpgw']->js->validate_file('venus','jsStructUtil'); 
    10293                        $GLOBALS['phpgw']->js->validate_file('venus','cssUtil'); 
    103  
     94                         
    10495//                      $GLOBALS['phpgw']->js->set_onload('setTimeout(\'updateCards()\',1000)'); 
    10596                        $GLOBALS['phpgw']->common->phpgw_header(); 
    106  
     97                         
    10798                        $GLOBALS['phpgw']->template->set_file(array('index' => 'index.tpl')); 
    10899                        $GLOBALS['phpgw']->template->set_var('cc_root_dir', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/'); 
    109  
     100                         
    110101                        /* Quick Add */ 
    111102                        $GLOBALS['phpgw']->template->set_var('cc_qa_alias',lang('Alias').':'); 
     
    116107                        $GLOBALS['phpgw']->template->set_var('cc_qa_save',lang('Save')); 
    117108                        $GLOBALS['phpgw']->template->set_var('cc_qa_clear',lang('Clear')); 
     109                        $GLOBALS['phpgw']->template->set_var('cc_qa_close',lang('Close')); 
    118110                        /* End Quick Add */ 
    119  
     111                         
    120112                        $cc_css_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/styles/cc.css'; 
    121113                        $cc_card_image_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/card.png'; 
     
    123115                        $GLOBALS['phpgw']->template->set_var('cc_dtree_css', $cc_dtree_file); 
    124116                        $GLOBALS['phpgw']->template->set_var('cc_card_image',$cc_card_image_file); 
    125  
     117                         
    126118                        $GLOBALS['phpgw']->template->set_var('cc_personal',lang('Personal')); 
    127  
     119                         
    128120                        $GLOBALS['phpgw']->template->set_var('cc_full_add',lang('Full Add')); 
    129121                        $GLOBALS['phpgw']->template->set_var('cc_reset',lang('Reset')); 
    130  
     122                         
    131123                        $GLOBALS['phpgw']->template->set_var('cc_personal_data',lang('Personal Data')); 
    132124                        $GLOBALS['phpgw']->template->set_var('cc_addresses',lang('Addresses')); 
     
    137129                        $GLOBALS['phpgw']->template->set_var('cc_catalogs',lang('Catalogues')); 
    138130                        $GLOBALS['phpgw']->template->set_var('cc_group_add',lang('Group Add')); 
    139  
     131                         
    140132                        /* Panel */ 
    141133                        $GLOBALS['phpgw']->template->set_var('cc_panel_new',lang('New').'...'); 
     
    143135                        $GLOBALS['phpgw']->template->set_var('cc_panel_table',lang('Table View')); 
    144136                        $GLOBALS['phpgw']->template->set_var('cc_panel_cards',lang('Cards View')); 
    145  
     137                        $GLOBALS['phpgw']->template->set_var('cc_btn_import_export', lang('Import/Export')); 
     138                        $GLOBALS['phpgw']->template->set_var('cc_btn_new', lang("New...")); 
     139                         
    146140                        $GLOBALS['phpgw']->template->set_var('cc_panel_search_found',lang('Showing found entries')); 
    147141                        $GLOBALS['phpgw']->template->set_var('cc_panel_first_page',lang('First Page')); 
     
    151145                        $GLOBALS['phpgw']->template->set_var('cc_all',lang('all')); 
    152146                        /* End Panel */ 
    153  
     147                         
    154148                        /* Messages */ 
    155149                        $GLOBALS['phpgw']->template->set_var('cc_msg_no_cards',lang('No Cards')); 
     
    166160                        $GLOBALS['phpgw']->template->set_var('cc_empty',lang('Empty')); 
    167161                        /* End Messages */ 
    168  
     162                         
    169163                        $GLOBALS['phpgw']->template->set_var('cc_results',lang('Results')); 
    170164                        $GLOBALS['phpgw']->template->set_var('cc_is_my',lang('Is My')); 
     165                        $GLOBALS['phpgw']->template->set_var('cc_ie_personal',lang('Import/Export pesonal contacts')); 
    171166                        $GLOBALS['phpgw']->template->set_var('cc_btn_search',lang('Search')); 
    172167                        $GLOBALS['phpgw']->template->set_var('cc_add_relation',lang('Add Relation')); 
    173                         $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations')); 
     168                        $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations'));                       
    174169                        $GLOBALS['phpgw']->template->set_var('cc_msg_group',lang('Group')); 
    175170                        $GLOBALS['phpgw']->template->set_var('cc_msg_contact_full',lang('Contact [Full]')); 
     
    179174                        $GLOBALS['phpgw']->template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); 
    180175 
     176                        $GLOBALS['phpgw']->template->set_var('cc_msg_import_contacts', lang('Import Contacts')); 
     177                        $GLOBALS['phpgw']->template->set_var('cc_msg_export_contacts', lang('Export Contacts')); 
     178                        $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_info_csv', lang('The Expresso supports the contacts importation in the CSV file format.')); 
     179                        $GLOBALS['phpgw']->template->set_var('cc_msg_choose_file_type', lang('Select the file type')); 
     180                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express', lang('Outlook Express')); 
     181                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook2k', lang('Outlook 2000')); 
     182                        $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default', lang('Expresso (default)')); 
     183                        $GLOBALS['phpgw']->template->set_var('cc_msg_choose_contacts_file', lang('Select the file that contains the contacts to be imported:')); 
     184                        $GLOBALS['phpgw']->template->set_var('cc_msg_close_win', lang('Close')); 
     185                        $GLOBALS['phpgw']->template->set_var('cc_msg_close', lang('Close')); 
     186                        $GLOBALS['phpgw']->template->set_var('cc_msg_ie_personal', lang('Import / Export personal Contacts')); 
     187                        $GLOBALS['phpgw']->template->set_var('cc_msg_import_fail', lang('The importation has failed. Verify the file format.')); 
     188                        $GLOBALS['phpgw']->template->set_var('cc_msg_importing_contacts', lang('Importing Contacts...')); 
     189                        $GLOBALS['phpgw']->template->set_var('cc_msg_import_finished', lang('The importation has finished.')); 
     190                        $GLOBALS['phpgw']->template->set_var('cc_msg_new', lang(' new')); 
     191                        $GLOBALS['phpgw']->template->set_var('cc_msg_failure', lang(' failed')); 
     192                        $GLOBALS['phpgw']->template->set_var('cc_msg_exists', lang(' were existent')); 
     193                        $GLOBALS['phpgw']->template->set_var('cc_msg_show_more_info', lang('show more info')); 
     194                        $GLOBALS['phpgw']->template->set_var('cc_msg_clean', lang('Clean')); 
     195                        $GLOBALS['phpgw']->template->set_var('cc_msg_invalid_csv', lang('Select a valid CSV file to import your contacts')); 
     196                        $GLOBALS['phpgw']->template->set_var('cc_msg_export_csv', lang('Select the format type that you want to export your contacts')); 
     197                        $GLOBALS['phpgw']->template->set_var('cc_msg_automatic', lang('Automatic')); 
     198                        $GLOBALS['phpgw']->template->set_var('cc_msg_export_error', lang('An error has occurred while the exportation.')); 
     199                        $GLOBALS['phpgw']->template->set_var('cc_msg_new_email', lang('New Email')); 
     200                        $GLOBALS['phpgw']->template->set_var('cc_msg_main', lang('Main')); 
     201                        $GLOBALS['phpgw']->template->set_var('cc_msg_alternative', lang('Alternative')); 
     202                        $GLOBALS['phpgw']->template->set_var('cc_msg_select_email', lang('Select E-Mail')); 
     203                        $GLOBALS['phpgw']->template->set_var('cc_msg_new_phone', lang('New Telephone')); 
     204                        $GLOBALS['phpgw']->template->set_var('cc_msg_home', lang('Home')); 
     205                        $GLOBALS['phpgw']->template->set_var('cc_msg_cellphone', lang('Cellphone')); 
     206                        $GLOBALS['phpgw']->template->set_var('cc_msg_work', lang('Work')); 
     207                        $GLOBALS['phpgw']->template->set_var('cc_msg_fax', lang('Fax')); 
     208                        $GLOBALS['phpgw']->template->set_var('cc_msg_pager', lang('Pager')); 
     209                        $GLOBALS['phpgw']->template->set_var('cc_msg_choose_phone', lang('Select the telephone')); 
     210                        $GLOBALS['phpgw']->template->set_var('cc_msg_warn_firefox', lang('Warning: Too old version of Firefox')); 
     211                        $GLOBALS['phpgw']->template->set_var('cc_msg_firefox_half1', lang('For this application work correctly</u>')); 
     212                        $GLOBALS['phpgw']->template->set_var('cc_msg_firefox_half2', lang('it\'s necessary to update your Firefox Browser for a new version (version > 1.5) Install now clicking in the link bellow, or if you want to update it later')); 
     213                        $GLOBALS['phpgw']->template->set_var('cc_msg_click_close', lang('click Close')); 
     214                        $GLOBALS['phpgw']->template->set_var('cc_msg_install_now', lang('Install Now')); 
     215                        $GLOBALS['phpgw']->template->set_var('cc_msg_install_new_firefox', lang('Install a new Firefox version')); 
     216                        $GLOBALS['phpgw']->template->set_var('cc_msg_moz_thunderbird', lang('Export as Mozilla Thunderbird CSV.')); 
     217                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express_pt', lang('Export as Outlook Express (Portuguese) CSV.')); 
     218                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express_en', lang('Export as Outlook Express (English) CSV.')); 
     219                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_pt', lang('Export as Outlook 2000 (Portuguese) CSV.')); 
     220                        $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_en', lang('Export as Outlook 2000 (English) CSV.')); 
     221                        $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default_csv', lang('Export as Expresso (Default) CSV.')); 
     222                        $GLOBALS['phpgw']->template->set_var('cc_msg_copy_to_catalog', lang('Copy to personal catalog.')); 
     223                        $GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.')); 
     224                        $GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name')); 
     225                         
    181226                        $GLOBALS['phpgw']->template->parse('out','index'); 
    182  
     227                         
    183228                        $api = CreateObject('contactcenter.ui_api'); 
    184229                        $main = $api->get_full_add(); 
     
    191236                } 
    192237 
    193  
     238                 
    194239                /*! 
    195  
     240                 
    196241                        @function data_manager 
    197                         @abstract Calls the right method and passes to it the right 
     242                        @abstract Calls the right method and passes to it the right  
    198243                                parameters 
    199244                        @author Raphael Derosso Pereira 
    200  
     245                 
    201246                */ 
    202247                function data_manager() 
     
    207252                                case 'set_n_cards': 
    208253                                        return $this->set_n_cards((int)$_GET['ncards']); 
    209  
    210                                 case 'get_cards_data': 
    211  
     254                                         
     255                                case 'get_cards_data':                                   
    212256                                        $ids = false; 
    213257                                        // To support ldap catalogs using accentuation 
    214258                                        if ($_POST['letter'] == 'search' && isset($_POST['data'])) 
    215259                                        { 
    216                                                 //$ids = utf8_decode($this->search($_POST['data'])); 
    217                                                 $ids = $this->search($_POST['data']); 
     260                                                $ids = utf8_decode($this->search($_POST['data'])); 
    218261                                        } 
    219  
    220                                         //return $this->get_cards_data($_POST['letter'], $_POST['page'], unserialize(str_replace('\\"','"',$ids))); 
    221                                         return $this->get_cards_data($_POST['letter'], $_POST['page'], $ids); 
    222                                         //return $this->get_cards_data($_POST['letter'], $_POST['page'], unserialize(str_replace('\\"','"',$_POST['ids']))); 
    223  
     262                                         
     263                                        if(isset($_SESSION['ids'])) 
     264                                                $ids = $_SESSION['ids']; 
     265                                         
     266                                        return $this->get_cards_data($_POST['letter'], $_POST['page'], $ids);                                            
    224267                                case 'get_cards_data_get': 
    225268                                        return $this->get_cards_data($_GET['letter'], $_GET['page'], unserialize(str_replace('\\"','"',$_GET['ids']))); 
     
    229272                                        return $this->get_photo($_GET['id']); 
    230273 
    231  
     274                                case 'get_visible_all_ldap': 
     275                                        echo $this->get_visible_all_ldap(); 
     276                                        return; 
     277                                         
    232278                                /* Catalog Methods */ 
    233279                                case 'set_catalog': 
    234280                                        return $this->set_catalog($_GET['catalog']); 
    235  
     281                                         
    236282                                case 'get_catalog_tree': 
    237283                                        echo serialize($this->get_catalog_tree($_GET['level'])); 
     
    250296                                        echo serialize($this->get_catalog_add_contact(utf8_decode($_POST['id']))); 
    251297                                        return; 
    252  
     298                                         
    253299                                /* Full Add Methods */ 
    254300                                case 'get_full_data': 
    255301                                        return $this->get_full_data($_GET['id']); 
    256  
     302                                 
    257303                                case 'get_group': 
    258304                                        return $this->get_group_data($_GET['id']); 
    259  
     305                                         
    260306                                case 'get_contact_full_add_const': 
    261307                                        return $this->get_contact_full_add_const(); 
     
    269315                                case 'get_states': 
    270316                                        return $this->get_states($_GET['country']); 
    271  
     317                                         
    272318                                case 'get_cities': 
    273319                                        return $this->get_cities($_GET['country'], $_GET['state'] ? $_GET['state'] : null); 
    274  
    275  
     320                                         
     321                                         
    276322                                /* Other Methods */ 
    277                                 case 'quick_add': 
     323                                case 'quick_add':                                                                                                                        
    278324                                        return $this->quick_add($_POST['add']); 
    279  
    280                                 case 'add_group': 
     325                                 
     326                                case 'add_group':                                                                                                                        
    281327                                        return $this->add_group($_POST['add']); 
    282  
     328                                                                         
    283329                                case 'remove_entry': 
    284330                                        return $this->remove_entry((int)$_GET['remove']); 
    285  
     331                                 
    286332                                case 'remove_all_entries': 
    287333                                        return $this->remove_all_entries(); 
    288334 
    289335                                case 'remove_group': 
    290  
    291                                         return $this->remove_group((int)$_GET['remove']); 
     336                                                                                 
     337                                        return $this->remove_group((int)$_GET['remove']);                                        
    292338 
    293339                                case 'search': 
    294                                         return $this->search(str_replace('\\"', '"', $_GET['data'])); 
     340                                        $ids = false; 
     341                                        $ids = $this->search($_GET['data']); 
     342                                        return $this->get_cards_data('search', '1', $ids); 
    295343 
    296344                                case 'email_win': 
     
    326374 
    327375                /*! 
    328  
     376                 
    329377                        @function set_n_cards 
    330378                        @abstract Informs the class the number of cards the page can show 
    331379                        @author Raphael Derosso Pereira 
    332  
     380                         
    333381                        @param integer $n_cards The number of cards 
    334  
     382                         
    335383                */ 
    336384                function set_n_cards($n_cards) 
     
    341389                                echo 1; 
    342390                        } 
    343  
     391                         
    344392                        $this->save_session(); 
    345393                } 
    346  
     394                                 
    347395                /*! 
    348  
     396                 
    349397                        @function set_catalog 
    350398                        @abstract Sets the current catalog selected by the user 
    351399                        @author Raphael Derosso Pereira 
    352  
     400                         
    353401                        @param string $id_catalog The sequence of IDs to reach the catalog 
    354402                                separated by commas 
    355  
     403                 
    356404                */ 
    357405                function set_catalog($id_catalog) 
     
    359407                        $id_catalog = str_replace('\\"', '"', $id_catalog); 
    360408                        $temp =& $this->bo->set_catalog($id_catalog); 
    361  
     409                         
    362410                        if ($temp) 
    363411                        { 
     
    366414                                $this->page_info['actual_catalog'] =& $temp; 
    367415                                $this->save_session(); 
    368  
     416                                 
    369417                                $catalog_info = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 
    370  
     418                                 
    371419                                if ($catalog_info['class'] === 'bo_global_ldap_catalog' || 
    372420                                    $catalog_info['class'] === 'bo_catalog_group_catalog') 
     
    378426                                        $perms = 15; 
    379427                                } 
    380  
     428                                 
    381429                                echo serialize(array( 
    382430                                        'status' => 'ok', 
     
    386434                                return; 
    387435                        } 
    388  
     436                         
    389437                        echo serialize(array( 
    390438                                'status' => 'ok', 
     
    392440                        )); 
    393441                } 
    394  
    395  
     442                 
     443                 
    396444                /*! 
    397  
     445                 
    398446                        @function get_catalog_tree 
    399447                        @abstract Returns the JS serialized array to used as the tree 
    400448                                level 
    401449                        @author Raphael Derosso Pereira 
    402                         @author Mï¿œrio Cï¿œsar Kolling (error messages and timeout) 
    403  
    404                         @param (string) $level The level to be taken 
    405  
     450            @author Mário César Kolling (error messages and timeout) 
     451                         
     452                        @param (string) $level The level to be taken  
     453                 
    406454                */ 
    407455                function get_catalog_tree($level) 
     
    412460 
    413461                                $parent = '0'; 
    414  
     462                                 
    415463                                if (!($tree = $this->bo->get_catalog_tree($level))) 
    416464                                { 
     
    426474                                $parent = substr($level, 0, $last_dot); 
    427475                                $child = substr($level, $last_dot+1, strlen($level)); 
    428  
     476                         
    429477                                if (!($tree[$child] = $this->bo->get_catalog_tree($level))) 
    430478                                { 
     
    445493                                } 
    446494                        } 
    447  
     495                         
    448496                        $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); 
    449497                        $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); 
    450  
     498                         
    451499                        // Deals with error messages from the server and returns them to the browser 
    452500                        if ($tree['msg']) 
     
    474522                                        'status' => 'error' 
    475523                                ); 
    476  
    477524                        } 
    478525                } 
    479  
    480 /*              function get_catalog_tree($level, $name = 'tree') 
    481                 { 
    482                         if ($level === '0') 
    483                         { 
    484                                 $folderImageDir = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/dftree/images/'; 
    485                                 $tree_js =  $name." = new dFTree({'name': '".$name."'});\n"; 
    486  
    487                                 $parent = '0'; 
    488                                 $child  = '0'; 
    489  
    490                                 if (!($tree = $this->bo->get_catalog_tree($level))) 
    491                                 { 
    492                                         return '0'; 
    493                                 } 
    494                         } 
    495                         else 
    496                         { 
    497                                 $last_dot = strrpos($level,'.'); 
    498                                 $parent = substr($level, 0, $last_dot); 
    499                                 $child = substr($level, $last_dot+1, strlen($level)); 
    500  
    501                                 $tree_js = ''; 
    502  
    503                                 if (!($tree[$child] = $this->bo->get_catalog_tree($level))) 
    504                                 { 
    505                                         return '0'; 
    506                                 } 
    507                         } 
    508  
    509                         $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); 
    510                         $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); 
    511  
    512                         $tree_js .= $this->convert_tree($tree, $name, $folderImageDir, $parent); 
    513  
    514                         return $tree_js; 
    515                 } 
    516 */ 
    517  
     526                 
    518527                /*! 
    519  
     528                 
    520529                        @function get_actual_catalog 
    521530                        @abstract Returns the actual selected Catalog 
     
    524533                */ 
    525534                function get_actual_catalog() 
    526                 { 
     535                {                        
    527536                        $level = $this->bo->get_level_by_branch($this->bo->get_actual_catalog(), $this->bo->tree['branches'], '0'); 
    528  
     537                         
    529538                        if ($level) 
    530539                        { 
     
    540549                        ); 
    541550                } 
    542  
     551                 
    543552                /*! 
    544  
     553                 
    545554                        @function get_cards_data 
    546555                        @abstract Returns the information that is placed on the cards 
    547556                        @author Raphael Derosso Pereira 
    548  
     557                         
    549558                        @param string $letter The first letter to be searched 
    550                         @param (int)  $page The page to be taken 
     559                        @param (int)  $page The page to be taken  
    551560                        @param (str)  $ids The ids to be taken in case of search 
    552561 
     
    556565                function get_cards_data($letter, $page, $ids) 
    557566                { 
     567                        if( $ids ) 
     568                                $_SESSION['ids'] = $ids;                    
    558569 
    559570                        // It's an external catalog? 
    560571                        $external = $this->bo->is_external($this->page_info['actual_catalog']); 
    561  
    562572                        //echo $page."\n"; 
    563573                        if ($letter !== 'search' and ($letter != $this->page_info['actual_letter'] or 
    564                             ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or 
     574                            ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or  
    565575                            $this->page_info['changed'])) 
    566576                        { 
    567577                                unset($ids); 
    568578                                $this->page_info['changed'] = false; 
    569  
     579                                  
    570580                                switch ($this->page_info['actual_catalog']['class']) 
    571581                                { 
     
    654664                                                        ); 
    655665                                                } 
    656  
     666                                                 
    657667                                                $find_field[0] = array('contact.id_contact','contact.names_ordered'); 
    658  
     668                                                 
    659669                                                $find_other[0] = array( 
    660670                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    662672                                                        'order'  => 'contact.names_ordered' 
    663673                                                ); 
    664  
     674                                                 
    665675                                                break; 
    666  
    667                                         //case 'bo_external_ldap_catalog': 
    668  
    669                                         //      break; 
    670  
     676                                         
    671677                                        case 'bo_global_ldap_catalog': 
     678                                         
    672679                                                $field_name = 'id_contact'; 
    673680 
     
    718725                                                                                        'value' => 'u' 
    719726                                                                                        ), 
    720                                                                                         /*1 => array( 
    721                                                                                         'field' => 'contact.account_type', 
    722                                                                                         'type'  => '=', 
    723                                                                                         'value' => 'g' 
    724                                                                                         ),*/ 
    725                                                                                         2 => array( 
     727                                                                                        1 => array( 
    726728                                                                                        'field' => 'contact.account_type', 
    727729                                                                                        'type'  => '=', 
     
    834836                                                                                'value' => 'g' 
    835837                                                                                ),*/ 
    836                                                                                 2 => array( 
     838                                                                                1 => array( 
    837839                                                                                'field' => 'contact.account_type', 
    838840                                                                                'type'  => '=', 
     
    842844                                                                ); 
    843845                                                        } 
    844  
    845846                                                } 
    846847 
     
    858859                                                        $find_field[0] = array('contact.id_contact','contact.names_ordered'); 
    859860                                                } 
    860  
     861                                                 
    861862                                                $find_other[0] = array( 
    862863                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    864865                                                        'order'  => 'contact.names_ordered' 
    865866                                                ); 
    866  
     867                                                 
    867868                                                break; 
    868  
     869                                         
    869870                                        case 'bo_company_manager': 
    870871                                                $field_name = 'id_company'; 
    871  
     872         
    872873                                                $find_field[0] = array('company.id_company','company.company_name'); 
    873  
     874                                                 
    874875                                                $find_other[0] = array( 
    875876                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    877878                                                        'order'  => 'company.company_name' 
    878879                                                ); 
    879  
     880         
    880881                                                $find_restric[0] = array( 
    881882                                                        0 => array( 
     
    885886                                                        ) 
    886887                                                ); 
    887  
     888                                                         
    888889                                                break; 
    889890 
    890891                                        case 'bo_group_manager': 
    891  
     892                                         
    892893                                                $field_name = 'id_group'; 
    893  
     894                                                 
    894895                                                if ($letter !== 'number')       { 
    895  
     896                                                         
    896897                                                        $find_restric[0] = array( 
    897898                                                                0 => array( 
     
    903904                                                } 
    904905                                                 else { 
    905  
     906                                                         
    906907                                                        $find_restric[0] = array( 
    907908                                                                0 => array( 
    908909                                                                                        'field' => 'group.title', 
    909910                                                                                        'type'  => 'LIKE', 
    910                                                                                         'value' => '0%' 
     911                                                                                        'value' => '0%'                                                                          
    911912                                                                ) 
    912                                                         ); 
     913                                                        );                                               
    913914                                                } 
    914  
     915                                                 
    915916                                                array_push($find_restric[0],  array( 
    916917                                                                                        'field' => 'group.owner', 
    917918                                                                                        'type'  => '=', 
    918                                                                                         'value' => $GLOBALS['phpgw_info']['user']['account_id'] 
     919                                                                                        'value' => $GLOBALS['phpgw_info']['user']['account_id']                                                                          
    919920                                                                ) 
    920921                                                ); 
    921  
    922                                                 $find_field[0] = array('group.id_group','group.title','group.short_name'); 
     922                                                 
     923                                                $find_field[0] = array('group.id_group','group.title','group.short_name');                                               
    923924                                                $find_other[0] = array( 
    924925                                                        'order'  => 'group.title' 
    925926                                                ); 
    926  
     927                                                 
    927928                                                break; 
    928  
     929                                                 
    929930                                        case 'bo_catalog_group_catalog': 
    930931                                                $this->page_info['actual_entries'] = false; 
    931  
     932                                                 
    932933                                                $this->page_info['actual_letter'] = $letter; 
    933934                                                $this->page_info['actual_page'] = 0; 
    934  
     935                                                 
    935936                                                $this->save_session(); 
    936937                                                $final[0] = 0; 
    937                                                 $final[1] = $this -> typeContact; 
    938                                                 echo serialize($final); 
     938                                                $final[1] = $this->typeContact; 
     939                                                echo serialize($final);                                          
    939940                                                return; 
    940941 
    941942                                } 
    942  
     943                                 
    943944                                $result = $this->bo->find($find_field[0],$find_restric[0],$find_other[0]); 
    944945                                $n_entries = count($result); 
    945  
     946                                 
    946947                                if ($n_entries) 
    947948                                { 
     
    957958                                { 
    958959                                        $this->page_info['actual_entries'] = false; 
    959  
     960                                         
    960961                                        $this->page_info['actual_letter'] = $letter; 
    961962                                        $this->page_info['actual_page'] = 0; 
    962  
    963                                         $this->save_session(); 
     963                                         
     964                                        $this->save_session();                           
    964965                                        $final[0] = 0; 
    965                                         $final[1] = $this -> typeContact; 
    966                                         echo serialize($final); 
     966                                        $final[1] = $this->typeContact; 
     967                                        echo serialize($final);                                                                                  
    967968                                        return; 
    968969                                } 
     
    973974                                        { 
    974975                                                $this->page_info['actual_entries'][] = $value[$field_name]; 
    975                                         } 
    976                                 } 
    977                         } 
    978 //************************************************************************* 
     976                                        }  
     977                                        //print_r($this->page_info['actual_entries']); 
     978                                } 
     979                        } 
    979980                        else if ($letter === 'search') 
    980981                        { 
    981982                                //if (!$ids and $this->page_info['actual_letter'] !== 'search') 
    982                                 if (!$ids && !$this->last_search_ids) 
     983                                if (!$ids) 
    983984                                { 
    984985                                        error_log('!$ids e $this->page_info[\'actual_letter\'] != search'); 
    985986                                        $this->page_info['actual_entries'] = false; 
    986  
     987                                         
    987988                                        $this->page_info['actual_letter'] = $letter; 
    988989                                        $this->page_info['actual_page'] = 0; 
    989  
     990                                         
    990991                                        $this->save_session(); 
    991992                                        $final[0] = 0; 
    992993                                        $final[1] = $this -> typeContact; 
    993                                         echo serialize($final); 
     994                                        echo serialize($final);                                  
    994995                                        return; 
    995996                                } 
     
    10071008                                        return; 
    10081009                                } 
    1009                                 else if ($ids || $this->last_search_ids) 
    1010                                 { 
    1011  
    1012                                         if ($ids) 
    1013                                         { 
    1014  
    1015                                                 $this->last_search_ids = $ids; 
    1016  
    1017                                         } 
    1018                                         else { 
    1019  
    1020                                                 $ids = $this->last_search_ids; 
    1021  
    1022                                         } 
    1023  
     1010                                else if ($ids) 
     1011                                {                                
    10241012                                        $this->page_info['actual_letter']  = $letter; 
    10251013                                        $this->page_info['actual_entries'] = $ids; 
     
    10381026                                        $page = $this->page_info['n_pages']; 
    10391027                                } 
    1040  
     1028                                 
    10411029                                $final = array( 
    10421030                                        0 => (int)$this->page_info['n_pages'], 
     
    10501038                                                5 => 'cc_alias', 
    10511039                                                6 => 'cc_id', 
    1052                                                 7 => 'cc_forwarding_address', 
    1053                                                 8 => 'cc_empNumber', 
    1054                                                 9 => 'cc_department' 
     1040                                                7 => 'cc_forwarding_address' 
    10551041                                        ) 
    10561042                                ); 
    1057  
     1043                                 
    10581044                                //echo 'Page: '.$page.'<br>'; 
    10591045                                $id_i = (($page-1)*$this->page_info['n_cards']); 
    10601046                                $id_f = $id_i + $this->page_info['n_cards']; 
    10611047                                $n_entries = count($this->page_info['actual_entries']); 
    1062  
     1048                                 
    10631049                                //echo 'ID_I: '.$id_i.'<br>'; 
    10641050                                //echo 'ID_F: '.$id_f.'<br>'; 
    1065                                 ///---------------- Correᅵᅵo Temporï¿œria PHP5 -----------------------/// 
     1051                                ///---------------- Correção Temporária PHP5 -----------------------/// 
    10661052                                $ids = array(); 
    1067                                 $array_temp = array(); 
    1068  
     1053                                $array_temp = array();                   
     1054                                                                 
    10691055                                foreach($this->page_info['actual_entries'] as $key=>$tmp){ 
    1070                                         $array_temp[] = $tmp; 
    1071                                 } 
    1072  
     1056                                        $array_temp[] = $tmp;                            
     1057                                }        
     1058                                 
    10731059                                for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 
    10741060                                { 
    10751061                                        $ids[] = $array_temp[$i]; 
    10761062                                } 
    1077  
     1063                                 
    10781064                                /// Original 
    10791065                                //for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 
     
    10821068                                //} 
    10831069                                /// 
    1084  
     1070                                 
    10851071                                $fields = $this->bo->catalog->get_fields(false); 
    10861072 
    1087                                 if( $this -> typeContact == 'groups') { 
     1073                                if( $this->typeContact == 'groups') { 
    10881074                                        $final = array( 
    10891075                                                0 => (int)$this->page_info['n_pages'], 
     
    10941080                                                        2 => 'cc_id', 
    10951081                                                        3 => 'cc_contacts' 
    1096                                                 ) 
    1097                                         ); 
    1098  
     1082                                                )                                                
     1083                                        );                                       
     1084                                         
    10991085                                        $groups =& $this->bo->catalog->get_multiple_entries($ids,$fields); 
    1100  
     1086                                         
    11011087                                        $i = 0; 
    11021088                                        // contatos do grupo 
    1103                                         $boGroups = CreateObject('contactcenter.bo_group'); 
     1089                                        $boGroups = CreateObject('contactcenter.bo_group');                                      
    11041090                                        $contacts = array(); 
    11051091                                        foreach($groups as $group)              { 
    1106  
     1092                                                                                 
    11071093                                                $final[3][$i][0] = $group['title'] ? $group['title'] : 'none'; 
    1108                                                 $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none'; 
     1094                                                $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none';                                                 
    11091095                                                $final[3][$i][2] = $group['id_group'] ? $group['id_group'] : 'none'; 
    11101096                                                $contacts = $boGroups -> get_contacts_by_group($group['id_group']); 
    11111097                                                $final[3][$i][3] = $contacts; 
    1112                                                 $i++; 
     1098                                                $i++;                                                    
    11131099                                        } 
    1114  
     1100                                         
    11151101                                        $this->page_info['actual_letter'] = $letter; 
    1116                                         $this->page_info['actual_page'] = $page; 
    1117  
    1118  
     1102                                        $this->page_info['actual_page'] = $page;                                         
     1103                                         
     1104                                         
    11191105                                        $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 
    1120  
     1106                                         
    11211107                                        $final[5] = '<span class="link"  onclick="'.$lnk_compose; 
    1122                                         $final[10] = 'groups'; 
    1123                                         $this->save_session(); 
     1108                                        $final[10] = 'groups';                                                                                                                                                                                                                           
     1109                                        $this->save_session();                                   
    11241110                                        echo serialize($final); 
    1125                                         return; 
    1126                                 } 
    1127  
     1111                                        return;                                  
     1112                                } 
     1113                                 
    11281114                                $fields['photo'] = true; 
    11291115                                $fields['names_ordered'] = true; 
     
    11321118                                $fields['companies'] = 'default'; 
    11331119                                $fields['connections'] = 'default'; 
    1134  
    1135                                 // ?aqui alterar a chamada desse mï¿œtodo para receber o base dn? 
    1136                                 $contacts =& $this->bo->catalog->get_multiple_entries($ids,$fields); 
    1137  
     1120                                // ?aqui alterar a chamada desse método para receber o base dn? 
     1121                                $contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields); 
     1122                                 
     1123                                 
    11381124                                if (!is_array($contacts) or !count($contacts)) 
    11391125                                { 
     
    11431129                                        return; 
    11441130                                } 
    1145  
     1131                                 
    11461132                                $i = 0; 
    11471133                                foreach($contacts as $index => $contact) 
    11481134                                { 
    11491135                                        /* 
    1150                                          * TODO: Os timeouts de conexï¿œo foram retirados, ver se serï¿œ necessï¿œrio retornar essa funcionalidade, e, 
    1151                                          * neste caso, terminar a implementaᅵᅵo das mensagens de retorno. 
     1136                                         * TODO: Os timeouts de conexão foram retirados, ver se será necessário retornar essa funcionalidade, e, 
     1137                                         * neste caso, terminar a implementação das mensagens de retorno. 
    11521138                                         */ 
    11531139                                        if ($index !== 'error'){ 
     
    11561142                                                $final[3][$i][2] = $contact['companies']['company1']['title']?$contact['companies']['company1']['title']:'none'; 
    11571143 
    1158                                                 //Para exibir a matricula do empregado 
    1159                                                 $final[3][$i][8] = $contact['companies']['company1']['empNumber']?$contact['companies']['company1']['empNumber']:'none'; 
    1160                                                 //Para exibir o setor/lotaᅵᅵo do empregado 
    1161                                                 $final[3][$i][9] = $contact['companies']['company1']['department']?$contact['companies']['company1']['department']:'none'; 
    1162  
    11631144                                                /* Select the correct Email and Telephone to be shown */ 
    11641145                                                $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
     1146                                                 
    11651147                                                if (!is_array($preferences)) 
    11661148                                                { 
     
    11881170                                                                                $default_phone_found = true; 
    11891171                                                                        } 
    1190                                                                          
    1191                                                                         if (!($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['telephone_number'] == $conn_info['connection_value']) && $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && $conn_info['connection_value'] && preg_match('/^\([0-9]{2}\)[0-9]{4}\-[0-9]{4}$/',$conn_info['connection_value'])==1 && !$external) { 
     1172                                                                        if (!($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['telephone_number'] == $conn_info['connection_value']) && $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && $conn_info['connection_value'] && preg_match('/^\([0-9]{2}\)[0-9]{4}\-[0-9]{4}$/',$conn_info['connection_value'])==1 && !$external){ 
    11921173                                                                                $conn_info['connection_value'] = "<a title=\"".lang("Call Extension")."\" href=\"#\" onclick=\"connectVoip('".$conn_info['connection_value']."', 'com')\">".$conn_info['connection_value']."</a>"; 
    1193                                                                 } 
    1194                                                                          
     1174                                                                        } 
    11951175                                                                        $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 
    11961176                                                                } 
    11971177                                                        } 
    11981178                                                } 
    1199  
     1179                                                 
    12001180                                                if (!$final[3][$i][3]) 
    12011181                                                { 
     
    12171197                                                $final[4][$i] = $contact['photo'] ? 1  : 0; 
    12181198                                                $i++; 
    1219  
    12201199                                        } 
    12211200                                        else 
     
    12301209                                $this->page_info['actual_letter'] = $letter; 
    12311210                                $this->page_info['actual_page'] = $page; 
    1232  
    1233                                 $this->save_session(); 
    1234  
     1211                                 
     1212                                $this->save_session();                           
    12351213                                echo serialize($final); 
    12361214                                return; 
    12371215                        } 
    1238  
     1216                         
    12391217                        $this->page_info['actual_letter'] = $letter; 
    12401218                        $this->page_info['actual_page'] = $page; 
    1241  
     1219                         
    12421220                        $this->save_session(); 
    1243  
     1221                         
    12441222                        $final[0] = 0; 
    12451223                        $final[1] = $this -> typeContact; 
    12461224                        echo serialize($final); 
    12471225                } 
    1248  
     1226                 
     1227                function get_visible_all_ldap() 
     1228                { 
     1229                        $bo = CreateObject('contactcenter.bo_ldap_manager'); 
     1230                        $ldap_query = $bo->srcs; 
     1231                        return $ldap_query[1]['visible'];        
     1232                } 
     1233 
     1234  
    12491235                /*! 
    1250  
     1236                 
    12511237                        @function get_group_data 
    12521238                        @abstract Returns all the information of a given Group 
    12531239                        @author Nilton Emilio Buhrer Neto 
    1254  
     1240                         
    12551241                        @param (integer) $id The id to get information 
    1256  
    1257                 */ 
     1242                 
     1243                */               
    12581244                function get_group_data($id) 
    12591245                { 
     
    12611247                        $fields = $this->bo->catalog->get_fields(true); 
    12621248                        $data = $this->bo->catalog->get_single_entry($id,$fields); 
    1263  
    1264                         if($id) { 
     1249                         
     1250                        if($id) {                        
    12651251                                // get All Contacts by group. 
    1266                                 $data['contact_in_list'] = $this->bo->catalog->get_contacts_by_group($id); 
    1267                         } 
    1268  
     1252                                $data['contact_in_list'] = $this->bo->catalog->get_contacts_by_group($id);                                                               
     1253                        } 
     1254                         
    12691255                        $boGroup = CreateObject('contactcenter.bo_group'); 
    1270  
    1271                         $data['contact_list'] = $boGroup->get_all_contacts(); 
    1272  
    1273                         $data['result'] = 'ok'; 
    1274                         echo serialize($data); 
    1275                 } 
    1276  
     1256                                                 
     1257                        $all_contacts = $boGroup->get_all_contacts(); 
     1258                         
     1259                        $contact_options = ""; 
     1260                        if(count($all_contacts)) {                                       
     1261                                foreach($all_contacts as $idx => $contact) {                             
     1262                                        $contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered']." (".$contact['connection_value'].")</OPTION>"; 
     1263                                } 
     1264                        } 
     1265                        $data['contact_list'] = $contact_options; 
     1266                        $data['result'] = 'ok';                                                          
     1267                        echo serialize($data);                   
     1268                }                
     1269                 
    12771270                /*! 
    1278  
     1271                 
    12791272                        @function get_full_data 
    12801273                        @abstract Returns all the information of a given Entry 
    12811274                        @author Raphael Derosso Pereira 
    1282  
     1275                         
    12831276                        @param (integer) $id The id to get information 
    1284  
     1277                 
    12851278                */ 
    12861279                function get_full_data($id) 
    12871280                { 
    12881281                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    1289                         $this->bo->catalog = CreateObject('contactcenter.bo_people_catalog'); 
     1282                        $this->bo->catalog = CreateObject('contactcenter.bo_people_catalog');            
    12901283                        $fields = $this->bo->catalog->get_fields(true); 
    12911284                        $fields['photo'] = false; 
     
    13201313                        } 
    13211314                        $datecount = 0; 
    1322  
     1315                         
    13231316                        $data['result'] = 'ok'; 
    13241317                        $data['cc_full_add_contact_id'] = $id; 
     
    13621355 
    13631356                        /* Relations */ 
    1364  
     1357                         
    13651358                        echo serialize($data); 
    13661359                } 
     
    13991392                                return; 
    14001393                        } 
    1401  
     1394                         
    14021395                        echo 0; 
    14031396                } 
    1404  
     1397                 
    14051398                /*! 
    1406  
     1399                 
    14071400                        @function quick_add 
    14081401                        @abstract Adds a new Contact using the Quick Add interface 
    14091402                        @author Raphael Derosso Pereira 
    1410  
     1403                         
    14111404                        @param string $sdata Serialized data 
    14121405                */ 
    14131406                function quick_add($sdata) 
    14141407                { 
    1415  
     1408                         
    14161409                        $sdata = str_replace('\\"', '"', $sdata); 
    14171410                        $new_array = unserialize($sdata); 
    14181411                        $tdata = array(); 
    1419  
     1412                         
    14201413                        foreach($new_array as $tmp) 
    14211414                                $tdata[] = $tmp; 
    1422  
     1415                         
    14231416                        if (!$tdata) 
    14241417                        { 
     
    14271420                                        'status' => 'abort' 
    14281421                                )); 
    1429  
     1422                                 
    14301423                                return; 
    14311424                        } 
    1432  
    1433                         // verifica se email jï¿œ existe! 
     1425                         
     1426                        // verifica se email já existe! 
    14341427                        $boGroup = CreateObject('contactcenter.bo_group'); 
    14351428                        $contact = $boGroup->verify_contact($tdata[4]); 
    1436  
     1429                                                                                                 
    14371430                        if($contact) 
    1438                         { 
     1431                        {                                                        
    14391432                                $str_contact = "\r\n - ".implode("\r\n - ",$contact); 
    1440  
     1433                                 
    14411434                                echo serialize(array( 
    14421435                                        'msg'    => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact), 
    14431436                                        'status' => 'alreadyExists' 
    14441437                                )); 
    1445  
    1446                                 return; 
     1438                                 
     1439                                return;                  
    14471440                        } 
    14481441 
     
    14601453 
    14611454                        if ($boPeople ->quick_add($data)) 
    1462                         { 
     1455                        {                                
    14631456                                $this->page_info['changed'] = true; 
    1464  
     1457                                 
    14651458                                echo serialize(array( 
    14661459                                        'msg'    => lang('Entry added with success!'), 
     
    14761469                        } 
    14771470 
    1478                         $this->save_session(); 
    1479  
     1471                        $this->save_session();   
     1472                         
    14801473                } 
    14811474 
    14821475                /*! 
    1483  
     1476                 
    14841477                        @function add_group 
    14851478                        @abstract Adds a new Group using the Add Group interface 
    14861479                        @author Nilton Emilio Buhrer Neto 
    1487  
     1480                         
    14881481                        @param string $sdata Serialized data 
    14891482                */ 
     
    14931486                        $tdata = unserialize($sdata); 
    14941487                        $new_tdata = array(); 
    1495  
     1488                         
    14961489                        if (!$tdata) 
    14971490                        { 
     
    15001493                                        'status' => 'abort' 
    15011494                                )); 
    1502  
     1495                                 
    15031496                                return; 
    15041497                        } 
    1505  
     1498                         
    15061499                        foreach($tdata as $tmp) 
    15071500                                $new_tdata[] = $tmp; 
    1508  
    1509                         $data['title'] = $new_tdata[0]; 
     1501                         
     1502                        $data['title'] = $new_tdata[0];                  
    15101503                        $data['contact_in_list'] = $new_tdata[1]; 
    15111504                        $data['id_group'] = $new_tdata[2]; 
    1512  
     1505                                                 
    15131506                        $boGroup = CreateObject('contactcenter.bo_group_manager'); 
    15141507                        $id = $boGroup -> add_group($data); 
    1515  
     1508                         
    15161509                        if ($id) 
    15171510                        { 
    15181511                                $this->page_info['changed'] = true; 
    1519  
     1512                                 
    15201513                                echo serialize(array( 
    15211514                                        'msg'    => lang('Entry added with success!'), 
     
    15351528 
    15361529                /*! 
    1537  
     1530                 
    15381531                        @function remove_group 
    15391532                        @abstract Removes a group if the user has the right to do it 
    1540                         @author Nilton Emilio Buhrer Neto 
     1533                        @author Nilton Emilio Buhrer Neto                        
    15411534                        @param (integer) $id The id to be removed 
    1542  
     1535                                 
    15431536                */ 
    15441537                function remove_group($id) 
    1545                 { 
    1546                                 $soGroup = CreateObject('contactcenter.so_group'); 
     1538                {                                
     1539                                $soGroup = CreateObject('contactcenter.so_group');                               
    15471540                                $data = array ('id_group' => $id); 
    15481541                                if($soGroup -> delete($data)) { 
     
    15501543                                                'msg'    => lang('Removed Entry ID '.$id.'!'), 
    15511544                                                'status' => 'ok' 
    1552                                         )); 
     1545                                        ));                                                      
    15531546                                } 
    15541547                                else { 
     
    15591552                                } 
    15601553 
    1561                         $this->save_session(); 
     1554                        $this->save_session();                           
    15621555                } 
    15631556 
    15641557 
    15651558                function remove_all_entries (){ 
    1566  
     1559                 
    15671560                        $error = false; 
    15681561                        $this->all_entries = $this->bo->catalog->get_all_entries_ids(); 
     
    15721565                                if(!$result) { 
    15731566                                        $error = true; 
    1574                                         break; 
     1567                                        break;           
    15751568                                } 
    15761569                        } 
     
    15811574                                        'status' => 'ok' 
    15821575                                )); 
    1583                         } 
     1576                        }  
    15841577                        else { 
    15851578                                echo serialize(array( 
     
    15931586 
    15941587                /*! 
    1595  
     1588                 
    15961589                        @function remove_entry 
    15971590                        @abstract Removes an entry if the user has the right to do it 
    15981591                        @author Raphael Derosso Pereira 
    1599  
     1592                         
    16001593                        @param (integer) $id The id to be removed 
    1601  
     1594                                 
    16021595                */ 
    16031596                function remove_entry ($id) 
     
    16081601                                return; 
    16091602                        } 
    1610  
     1603                         
    16111604                        $this->page_info['changed'] = true; 
    16121605                        $result = $this->bo->catalog->remove_single_entry($id); 
    1613  
     1606                         
    16141607                        if ($result) 
    16151608                        { 
     
    16181611                                        unset($this->page_info['actual_entries'][$pos]); 
    16191612                                } 
    1620  
     1613                                 
    16211614                                $temp = false; 
    16221615                                reset($this->page_info['actual_entries']); 
     
    16251618                                        $temp[] = $t; 
    16261619                                } 
    1627  
     1620                                 
    16281621                                $this->page_info['actual_entries'] = $temp; 
    16291622 
     
    16401633                                )); 
    16411634                        } 
    1642  
     1635                         
    16431636                        $this->save_session(); 
    16441637                } 
    16451638 
    1646  
     1639                 
    16471640                /*! 
    1648  
     1641                 
    16491642                        @function post_full_add 
    16501643                        @abstract Saves all the information altered/entered in the Full Add 
     
    16551648                function post_full_add() 
    16561649                { 
    1657                         $data = unserialize(str_replace('\\"', '"', $_POST['data'])); 
     1650                        $data =  $_POST['data']; 
     1651                        // Exceptions!!! utf8 special chars.  
     1652                        $data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data); 
     1653                        $data = unserialize(str_replace('\\"', '"', $data)); 
    16581654                        $this -> bo -> catalog = CreateObject('contactcenter.bo_people_catalog'); 
    1659  
    1660 //                      echo str_replace('\\"', '"', $_POST['data']); 
    16611655 
    16621656                        if (!is_array($data)) 
     
    16821676                                        'status' => 'fatal' 
    16831677                                )); 
    1684  
     1678                                 
    16851679                                return; 
    16861680                        } 
     
    16961690                                $id_photo = '_new_'; 
    16971691                        } 
    1698  
    1699                         /* 
    1700                          * Process Photo, if available 
     1692                         
     1693                        /*  
     1694                         * Process Photo, if available  
    17011695                         */ 
    17021696                        $sleep_count = 0; 
     
    17151709                        } 
    17161710                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n')); 
    1717  
     1711                         
    17181712                        if (isset($this->page_info['photos'][$id_photo])) 
    17191713                        { 
     
    17321726                                $this->save_session(); 
    17331727                        } 
    1734  
     1728                         
    17351729                        /* 
    17361730                         * Arrange Date so it gets inserted correctly 
    17371731                         */ 
    1738  
     1732                          
    17391733                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    1740  
     1734                 
    17411735                        $j = 0; 
    17421736                        for ($i = 0; $i < 5; $i+=2) 
     
    17711765                                        continue; 
    17721766                                } 
    1773  
     1767                                 
    17741768                                switch($field) 
    17751769                                { 
     
    17831777                                                /* Do Nothing. This is just to make sure no invalid field is passed */ 
    17841778                                                break; 
    1785  
     1779                                         
    17861780                                        case 'id_status': 
    17871781                                        case 'id_prefix': 
     
    17921786                                                } 
    17931787                                                break; 
    1794  
     1788                                         
    17951789                                        case 'birthdate_0': 
    17961790                                        case 'birthdate_1': 
    17971791                                        case 'birthdate_2': 
    1798  
     1792                                         
    17991793                                                switch($date[$datecount]['digit']) 
    18001794                                                { 
     
    18181812                                                        break; 
    18191813                                                } 
    1820  
     1814                                                 
    18211815                                                if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2])) 
    18221816                                                { 
     
    18271821                                                        return; 
    18281822                                                } 
    1829  
     1823                                                 
    18301824                                                $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1]; 
    18311825                                                break; 
     
    18501844                                                        { 
    18511845                                                                $index = 'address'.$type; 
    1852  
     1846                                                                 
    18531847                                                                $id_state = $this->bo->catalog->add_state($state_info); 
    18541848                                                                $data['addresses'][$index]['id_state'] = $id_state; 
     
    18681862                                                        { 
    18691863                                                                $index = 'address'.$type; 
    1870  
     1864                                                                 
    18711865                                                                $id_city = $this->bo->catalog->add_city($city_info); 
    18721866                                                                $data['addresses'][$index]['id_city'] = $id_city; 
     
    19091903                                ); 
    19101904                        } 
    1911  
     1905                         
    19121906                        eval($code); 
    19131907 
     
    19251919 
    19261920                /*! 
    1927  
     1921                 
    19281922                        @function post_photo 
    19291923                        @abstract Wrapper to post a photo without reload a page. 
     
    19351929                        //print_r($_FILES); 
    19361930                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'y')); 
    1937  
     1931                         
    19381932                        if (!is_array($_FILES) and is_array(!$_FILES['cc_pd_photo'])) 
    19391933                        { 
    19401934                                $this->page_info['photos'][$id]['status'] = 'no_upload'; 
    19411935                                $this->page_info['photos'][$id]['msg'] = lang('No Photos uploaded to Server.'); 
    1942  
     1936                                 
    19431937                                $this->save_session(); 
    19441938                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
     
    19501944                                $this->page_info['photos'][$id]['status'] = 'no_GD_lib'; 
    19511945                                $this->page_info['photos'][$id]['msg'] = lang('Cannot manipulate Image. No Image added. Please, if you want to use images, ask the Administrator to install GD library.'); 
    1952  
     1946                                 
    19531947                                $this->save_session(); 
    19541948                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
     
    19761970                                return; 
    19771971                        } 
    1978  
     1972                         
    19791973                        switch($_FILES['cc_pd_photo']['type']) 
    19801974                        { 
     
    20062000 
    20072001                                default: 
    2008  
     2002                                         
    20092003                                        $this->page_info['photos'][$id]['status'] = 'invalid_image'; 
    20102004                                        $this->page_info['photos'][$id]['msg'] = lang('The file must be an JPEG, PNG or GIF Image.'); 
     
    20192013                                        $this->page_info['photos'][$id]['status'] = 'invalid_file'; 
    20202014                                        $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); 
    2021  
     2015                                         
    20222016                                        $this->save_session(); 
    20232017                                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    20242018                                        return; 
    20252019                        } 
    2026  
     2020                         
    20272021                        $img_size = getimagesize($_FILES['cc_pd_photo']['tmp_name']); 
    20282022                        $dst_img = imagecreatetruecolor(60, 80); 
    2029  
     2023                         
    20302024                        if (!imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, 60, 80, $img_size[0], $img_size[1])) 
    20312025                        { 
    20322026                                $this->page_info['photos'][$id]['status'] = 'invalid_file'; 
    20332027                                $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); 
    2034  
     2028                                 
    20352029                                $this->save_session(); 
    20362030                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    20372031                                return; 
    20382032                        } 
    2039  
     2033                         
    20402034                        ob_start(); 
    20412035                        imagepng($dst_img); 
     
    20472041 
    20482042                        $this->save_session(); 
    2049  
     2043                 
    20502044                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    20512045 
     
    20682062                        $fields = $this->bo->catalog->get_fields(false); 
    20692063                        $fields['photo'] = true; 
    2070  
     2064                         
    20712065                        $contact = $this->bo->catalog->get_single_entry($id, $fields); 
    20722066 
     
    20772071                                return; 
    20782072                        } 
    2079  
     2073                         
    20802074                        header('Content-type: image/jpeg'); 
    20812075                        $photo = imagecreatefromstring ($contact['photo']); 
     
    20892083                        return; 
    20902084                } 
    2091  
     2085                 
    20922086                /*! 
    2093  
     2087                 
    20942088                        @function get_states 
    20952089                        @abstract Echos a serialized array containing all the states for the given country 
     
    21132107                                return; 
    21142108                        } 
    2115  
     2109                         
    21162110                        $result = array( 
    21172111                                'msg'    => lang('States Successfully retrieved!'), 
    21182112                                'status' => 'ok' 
    21192113                        ); 
    2120  
     2114                         
    21212115                        foreach ($states as $state_info) 
    21222116                        { 
     
    21572151                                return; 
    21582152                        } 
    2159  
     2153                         
    21602154                        $result = array( 
    21612155                                'msg'    => lang('Cities Successfully retrieved!'), 
    21622156                                'status' => 'ok' 
    21632157                        ); 
    2164  
     2158                         
    21652159                        foreach ($cities as $city_info) 
    21662160                        { 
    21672161                                $result['data'][$city_info['id_city']] = $city_info['name']; 
    21682162                        } 
    2169  
     2163                         
    21702164                        echo serialize($result); 
    21712165                } 
     
    21732167 
    21742168                /*! 
    2175  
     2169                 
    21762170                        @function search 
    21772171                        @abstract Echos a serialized array containing the IDs 
    21782172                                of the entries that matches the search argument 
    21792173                        @author Raphael Derosso Pereira 
    2180                         @author Mï¿œrio Cï¿œsar Kolling (external catalogs) 
     2174                        @author Mário César Kolling (external catalogs) 
    21812175 
    21822176                        @param string $str_data A serialized array with two informations: 
     
    21872181 
    21882182                */ 
     2183                // SERPRO 
    21892184                function search($str_data) 
    21902185                { 
     
    21922187                        // It's an external catalog? 
    21932188                        $external = $this->bo->is_external($this->page_info['actual_catalog']); 
    2194  
    2195                         if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) 
    2196                         { 
    2197                                 //echo serialize(array( 
    2198                                 //      'msg'    => lang('Invalid parameters'), 
    2199                                 //      'status' => 'abort' 
    2200                                 //)); 
    2201  
    2202                                 return array('error' => lang('Invalid parameters')); 
    2203                         } 
    2204  
     2189                         
     2190            if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) 
     2191            { 
     2192                echo serialize(array(                                                                                                    
     2193                   'msg'    => lang('Invalid parameters'),                                                                              
     2194                    'status' => 'abort' 
     2195                )); 
     2196             
     2197                return array('error' => lang('Invalid parameters'));                                                                                                                  
     2198            }    
     2199 
     2200             
    22052201                        /* 
    22062202                         * TODO: look into the database to discover the database's encoding and convert the search_for field accordingly 
     
    22132209                                $data['search_for'] = utf8_encode($data['search_for']); 
    22142210                        } 
    2215  
    2216                         $rules  = array(); 
    2217  
    2218                         if ($data['search_for'] === '*') 
    2219                         { 
    2220                                 $rules = array( 
    2221                                         0 => array( 
    2222                                                 'field' => $data['fields']['search'], 
    2223                                                 'type'  => 'LIKE', 
    2224                                                 'value' => '%' 
    2225                                         ) 
    2226                                 ); 
    2227                         } 
    2228                         else 
    2229                         { 
    2230                                 $names = explode(' ', $data['search_for']); 
    2231  
    2232                                 if (!is_array($names)) 
    2233                                 { 
    2234                                         //echo serialize(array( 
    2235                                         //      'msg'    => lang('Invalid Search Parameter'), 
    2236                                         //      'status' => 'abort' 
    2237                                         //)); 
    2238  
    2239                                         return array('error' => lang('Invalid Search Parameter')); 
    2240                                 } 
     2211             
     2212            $rules  = array();                                                                                                           
     2213             
     2214             
     2215            if ($data['search_for'] === '*')                                                                                             
     2216            { 
     2217                $rules = array(                                                                                                          
     2218                    0 => array(                                                                                                          
     2219                        'field' => $data['fields']['search'],                                                                            
     2220                        'type'  => 'LIKE', 
     2221                        'value' => '%' 
     2222                    )    
     2223                );   
     2224            }    
     2225            else                                                                                                                         
     2226            { 
     2227                $names = explode(' ', $data['search_for']);                                                                              
     2228                 
     2229                if (!is_array($names))                                                                                                   
     2230                { 
     2231                    echo serialize(array(                                                                                                
     2232                        'msg'    => lang('Invalid Search Parameter'),                                                                    
     2233                        'status' => 'abort' 
     2234                    )); 
     2235  
     2236                } 
    22412237 
    22422238                                if (!$external && $this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && 
     
    22712267                                        ); 
    22722268                                } 
    2273  
    2274                                 foreach ($names as $name) 
    2275                                 { 
    2276                                         if ($name != '') 
    2277                                         { 
    2278                                                 array_push($rules, array( 
    2279                                                         'field' => $data['fields']['search'], 
    2280                                                         'type'  => 'iLIKE', 
    2281                                                         'value' => '%'.$name.'%' 
    2282                                                 )); 
    2283                                         } 
    2284                                 } 
    2285                         } 
     2269                 
     2270                foreach ($names as $name) 
     2271                { 
     2272                    if ($name != '') 
     2273                    { 
     2274                        array_push($rules, array( 
     2275                            'field' => $data['fields']['search'], 
     2276                            'type'  => 'iLIKE', 
     2277                            'value' => '%'.$name.'%' 
     2278                        )); 
     2279                    } 
     2280                } 
     2281            } 
    22862282 
    22872283                        if ($external || $this->page_info['actual_catalog']['class'] == 'bo_people_catalog' || 
     
    23052301                        } 
    23062302 
    2307                         if (!is_array($ids) || !count($ids)) 
    2308                         { 
    2309                                 //echo serialize(array( 
    2310                                 //      'msg'    => lang('No Entries Found!'), 
    2311                                 //      'status' => 'empty' 
    2312                                 //)); 
    2313  
     2303            if (!is_array($ids) || !count($ids)) 
     2304            { 
    23142305                                $this->last_search_ids = null; 
    23152306                                $this->save_session(); 
    23162307                                return null; 
    2317                         } 
    2318  
    2319                         $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1); 
    2320  
    2321                         $ids_f = array(); 
    2322                         foreach ($ids as $e_info) 
    2323                         { 
    2324                                 //$ids_f[] = "base64::" . base64_encode($e_info[$id_field]); 
    2325                                 $ids_f[] = $e_info[$id_field]; 
    2326                         } 
    2327  
    2328                         //error_log("ids_f serializados: " . serialize($ids_f) . "\n", 3, '/var/www/teste.log'); 
    2329  
    2330                         //return serialize($ids_f); 
     2308            } 
     2309 
     2310            $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1); 
     2311                         
     2312            $ids_f = array(); 
     2313 
     2314            foreach ($ids as $e_info) 
     2315            { 
     2316                $ids_f[] = $e_info[$id_field]; 
     2317            } 
     2318 
    23312319                        return $ids_f; 
    2332  
    2333                         //echo serialize(array( 
    2334                         //      'data'   => $ids_f, 
    2335                         //      'msg'    => lang('Found %1 Entries', count($ids)), 
    2336                         //      'status' => 'ok' 
    2337                         //)); 
    23382320                } 
    2339  
     2321                 
     2322                // CELEPAR 
     2323                /* 
     2324        function search($str_data) 
     2325        { 
     2326            $data = unserialize($str_data); 
     2327 
     2328            if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) 
     2329            { 
     2330                echo serialize(array( 
     2331                    'msg'    => lang('Invalid parameters'), 
     2332                    'status' => 'abort' 
     2333                )); 
     2334 
     2335                return; 
     2336            } 
     2337 
     2338            $rules  = array(); 
     2339 
     2340            if ($data['search_for'] === '*') 
     2341            { 
     2342                $rules = array( 
     2343                    0 => array( 
     2344                        'field' => $data['fields']['search'], 
     2345                        'type'  => 'LIKE', 
     2346                        'value' => '%' 
     2347                    ) 
     2348                ); 
     2349            } 
     2350            else 
     2351            { 
     2352                $names = explode(' ', $data['search_for']); 
     2353 
     2354                if (!is_array($names)) 
     2355                { 
     2356                    echo serialize(array( 
     2357                        'msg'    => lang('Invalid Search Parameter'), 
     2358                        'status' => 'abort' 
     2359                    )); 
     2360                     
     2361                    return; 
     2362                } 
     2363                 
     2364                foreach ($names as $name) 
     2365                { 
     2366                    if ($name != '') 
     2367                    { 
     2368                        array_push($rules, array( 
     2369                            'field' => $data['fields']['search'], 
     2370                            'type'  => 'iLIKE', 
     2371                            'value' => '%'.$name.'%' 
     2372                        )); 
     2373                    } 
     2374                } 
     2375            } 
     2376 
     2377             
     2378             
     2379            //$catalog = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 
     2380             
     2381            //if ($catalog['class'] === 'bo_people_catalog') 
     2382            //{ 
     2383            //    array_push($rules, array( 
     2384            //        'field' => 'contact.id_owner', 
     2385            //        'type'  => '=', 
     2386            //        'value' => $GLOBALS['phpgw_info']['user']['account_id'] 
     2387            //    )); 
     2388            //} 
     2389             
     2390             
     2391            $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); 
     2392 
     2393            if (!is_array($ids) || !count($ids)) 
     2394            { 
     2395                echo serialize(array( 
     2396                    'msg'    => lang('No Entries Found!'), 
     2397                    'status' => 'empty' 
     2398                )); 
     2399 
     2400                return; 
     2401            } 
     2402            $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1); 
     2403 
     2404            $ids_f = array(); 
     2405            foreach ($ids as $e_info) 
     2406            { 
     2407                $ids_f[] = $e_info[$id_field]; 
     2408            } 
     2409 
     2410            echo serialize(array( 
     2411                'data'   => $ids_f, 
     2412                'msg'    => lang('Found %1 Entries', count($ids)), 
     2413                'status' => 'ok' 
     2414            )); 
     2415                         
     2416                        return; 
     2417        }*/ 
    23402418                /*! 
    23412419 
     
    23452423                        @author Raphael Derosso Pereira 
    23462424 
    2347                         @param array str_data A serialized array containing the ID's of the entries 
     2425                        @param array str_data A serialized array containing the ID's of the entries  
    23482426                                to be taken, the fields to be taken and the rules to be used on the 
    23492427                                retrieval: 
     
    23582436                { 
    23592437                        $data = unserialize($str_data); 
    2360  
     2438                         
    23612439                        if (!is_array($data) or !count($data) or !count($data['fields']) or !count($data['ids'])) 
    23622440                        { 
     
    23682446 
    23692447                        $entries = $this->bo->catalog->get_multiple_entries($data['ids'], $data['fields']); 
    2370  
     2448                         
    23712449                        if (!is_array($entries) or !count($entries)) 
    23722450                        { 
     
    23872465 
    23882466                        @function get_all_entries 
    2389                         @abstract Returns the specified fields for all catalog's entries 
     2467                        @abstract Returns the specified fields for all catalog's entries  
    23902468                                in the default CC UI format 
    23912469                        @author Raphael Derosso Pereira 
    23922470 
    2393                         @params array str_data A serialized array containing the fields to 
     2471                        @params array str_data A serialized array containing the fields to  
    23942472                                be grabbed, the maximum number of entries to be returned and a 
    23952473                                boolean specifying if the calls refers to a new grab or to an 
     
    24002478                { 
    24012479                        $data = unserialize($str_data); 
    2402  
    2403                         if (!is_array($data) or 
    2404                             !count($data) or 
    2405                                 !count($data['fields']) or 
     2480                         
     2481                        if (!is_array($data) or  
     2482                            !count($data) or  
     2483                                !count($data['fields']) or  
    24062484                                !$data['maxlength'] or 
    24072485                                (!$data['new'] and !$data['offset'])) 
     
    24292507                                $data['offset'] = 0; 
    24302508                        } 
    2431  
     2509                         
    24322510                        if ($data['maxlength'] != -1) 
    24332511                        { 
     
    24402518 
    24412519                        $prefs = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
    2442  
     2520                         
    24432521                        $jsCode = array(); 
    24442522                        $count = 0; 
     
    24502528                                } 
    24512529 
    2452                                 if($this-> typeContact == 'groups') { 
    2453  
     2530                                if($this-> typeContact == 'groups') {                            
     2531                                         
    24542532                                        foreach ($each as $field => $value)     { 
    2455  
     2533                                                                                 
    24562534                                                if ($field === 'title') { 
    24572535                                                        $optionName = '\\"'.$value.'\\"'; 
    2458  
     2536                                                          
    24592537                                                } 
    24602538                                                else if ($field === 'short_name')       { 
    2461  
     2539                                                         
    24622540                                                        $jsCode[] = '_this.entries.options[_this.entries.options.length] = new Option("'.$optionName.' ('.$value.')", "'.$count.'");'; 
    2463                                                         $count++; 
    2464                                                 } 
     2541                                                        $count++;                                                                                                                                                                        
     2542                                                }                                        
    24652543                                        } 
    24662544                                } 
    2467  
    2468                                 else  { 
     2545                                 
     2546                                else  {  
    24692547                                        foreach ($each as $field => $value)     { 
    24702548                                                if ($field === 'names_ordered') { 
     
    24742552                                                } 
    24752553                                                else if ($field === 'connections')      { 
    2476  
     2554                                                         
    24772555                                                        foreach ($value as $connection)         { 
    24782556                                                                if ($connection['id_type'] == $prefs['personCardEmail'])        { 
     
    24872565 
    24882566                        $jsCodeFinal = implode("\n", $jsCode); 
    2489  
     2567                         
    24902568                        $nEntries = count($result); 
    2491  
     2569                         
    24922570                        if (!$nEntries) 
    24932571                        { 
     
    25072585                        ); 
    25082586                } 
    2509  
     2587                 
    25102588                /*********************************************************************\ 
    25112589                 *                      Auxiliar Methods                             * 
     
    25132591 
    25142592                /*! 
    2515  
     2593                 
    25162594                        @function save_session 
    25172595                        @abstract Saves the data on the session 
    25182596                        @author Raphael Derosso Pereira 
    2519  
     2597                 
    25202598                */ 
    25212599                function save_session() 
     
    25232601                        $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter',$this->page_info); 
    25242602                        $GLOBALS['phpgw']->session->appsession('ui_data.all_entries','contactcenter',$this->all_entries); 
    2525                         $GLOBALS['phpgw']->session->appsession('ui_data.last_search_ids','contactcenter',$this->last_search_ids); 
    25262603                } 
    25272604 
    25282605                /*! 
    2529  
     2606                 
    25302607                        @function convert_tree 
    25312608                        @abstract Converts the tree array in the BO format to a JS tree array compatible 
    25322609                                with the one available in eGW 
    25332610                        @author Raphael Derosso Pereira 
    2534  
     2611                 
    25352612                        @param (array)  $tree    The tree in the BO format 
    25362613                        @param (string) $name    The tree name 
     
    25662643                                        'caption' => $value['name'] 
    25672644                                ); 
    2568  
     2645                                 
    25692646                                switch($value['type']) 
    25702647                                { 
     
    25892666                                $this->bo->catalog->src_info = $ldap->srcs[1]; 
    25902667                        } 
    2591  
    2592                         $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); 
     2668                         
     2669                        $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);                               
    25932670                        $dn=$this->bo->catalog->src_info['dn']; 
    25942671                        $justThese = array("givenname","givenname","sn","telephonenumber","mail"); 
    2595                         $sr = ldap_read($ds,$id, "objectClass=*",$justThese); 
    2596                         $info = ldap_get_entries($ds, $sr); 
     2672                        $sr = ldap_read($ds,$id, "objectClass=*",$justThese);                                                    
     2673                        $info = ldap_get_entries($ds, $sr);                                                      
    25972674                        for($z = 0; $z < 5; $z++) { 
    2598                                 $participant = $info[0][$justThese[$z]]; 
     2675                                $participant = $info[0][$justThese[$z]];                                                                                                         
    25992676                                array_push($array_participants, $participant); 
    26002677                        } 
     
    26022679                        ldap_close($ds); 
    26032680                        echo serialize($array_participants); 
    2604                 } 
    2605  
    2606                 function get_catalog_participants_list($id) 
     2681                }        
     2682                 
     2683                function get_catalog_participants_list($id)  
    26072684                { 
    2608  
    2609                         $fields = $this->bo->catalog->get_fields(false); 
     2685                         
     2686                        $fields = $this->bo->catalog->get_fields(false);                         
    26102687                        $fields['names_ordered'] = true; 
    2611                         $fields['mail_forwarding_address'] = true; 
    2612                         $contact = $this->bo->catalog->get_single_entry($id,$fields); 
    2613  
     2688                        $fields['mail_forwarding_address'] = true;                       
     2689                        $contact = $this->bo->catalog->get_single_entry($id,$fields);                    
     2690                         
    26142691                        $array_participants = array(); 
    26152692                        $array_emails = array(); 
    2616  
     2693                         
    26172694                        $filter = null; 
    2618                         for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) { 
     2695                        for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) {                   
    26192696                                        if(strstr($contact['mail_forwarding_address'][$z],'@')) { 
    26202697                                                $filter.="(mail=".$contact['mail_forwarding_address'][$z].")"; 
    26212698                                                $array_emails[$contact['mail_forwarding_address'][$z]] = "<font color=black>".$contact['mail_forwarding_address'][$z]."</font>"; 
    2622                                         } 
    2623                                         else 
     2699                                        }                                                                                                                                
     2700                                        else  
    26242701                                                $array_participants[$z] = "<font color=red>".$contact['mail_forwarding_address'][$z]."</font>"; 
    2625                         } 
    2626  
     2702                        }                                        
     2703                         
    26272704                        if($filter) { 
    2628                                 $filter = "(|".$filter.")"; 
     2705                                $filter = "(|".$filter.")";                                                      
    26292706                                if(!$this->bo->catalog->src_info) { 
    26302707                                        $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    26312708                                        $this->bo->catalog->src_info = $ldap->srcs[1]; 
    26322709                                } 
    2633                                 $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); 
     2710                                $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);                               
    26342711                                $dn=$this->bo->catalog->src_info['dn']; 
    26352712                                $justThese = array("cn","mail"); 
    2636                                 $sr = ldap_search($ds,$dn, $filter,$justThese); 
    2637                                 $info = ldap_get_entries($ds, $sr); 
     2713                                $sr = ldap_search($ds,$dn, $filter,$justThese);                                                          
     2714                                $info = ldap_get_entries($ds, $sr);                                                      
    26382715                                for($z = 0; $z < $info['count']; $z++) { 
    26392716                                        $participant =  '<font color=\'DARKBLUE\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;'.$info[$z]['cn'][0].'&quot; &lt;'.$info[$z]['mail'][0].'&gt;</font><br>'; 
    2640                                         $array_emails[$info[$z]['mail'][0]] = null; 
    2641                                         array_push($array_participants, $participant); 
    2642                                 } 
    2643  
     2717                                        $array_emails[$info[$z]['mail'][0]] = null;                                                              
     2718                                        array_push($array_participants, $participant);                                   
     2719                                } 
     2720                                 
    26442721                                foreach($array_emails as $index => $email) 
    2645                                         if($email) 
    2646                                                 array_push($array_participants, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>"); 
    2647  
     2722                                        if($email)  
     2723                                                array_push($array_participants, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>");                           
     2724                                                                                                 
    26482725                                ldap_close($ds); 
    26492726                        } 
    26502727                        sort($array_participants); 
    2651                         $innerHTML = ''; 
     2728                        $innerHTML = '';                         
    26522729                        foreach($array_participants as $index => $participant){ 
    26532730                                $innerHTML .= $participant; 
    26542731                        } 
    2655                         $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML); 
     2732                        $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML);                   
    26562733                        echo serialize($return); 
    2657                 } 
    2658  
     2734                }        
     2735                 
    26592736                function export_contacts($typeExport){ 
    26602737 
     
    26672744 
    26682745 
    2669                         // Essa iteraᅵᅵo transforma uma esturuta com contatos redundantes e separados por email ou tel. 
     2746                        // Essa iteração transforma uma esturuta com contatos redundantes e separados por email ou tel. 
    26702747                        // em outra com apenas 1 elemento pra cada contato 
    26712748                        $i=0; 
     
    26782755                                        $all_contacts[$i]['phone']=$object['connection_value']; 
    26792756                        } 
    2680  
     2757                         
    26812758                        switch($typeExport) { 
    26822759 
    26832760                                case 'outlook_en': 
    26842761                                        $streamBuffer = "Name;E-mail Address;Notes;Mobile Phone;Pager;Company;". 
    2685                                                         "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n"; 
     2762                                                        "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n";                                                         
    26862763                                        foreach($all_contacts as $index => $object){ 
    26872764                                                $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;\r\n"; 
    26882765                                        } 
    26892766                                break; 
    2690  
     2767                                 
    26912768                                case 'outlook_pt-BR': 
    2692                                         $streamBuffer = "Nome;End. de email;Endereï¿œo residencial;". 
    2693                                         "Cidade do endereï¿œo residencial;CEP do endereï¿œo residencial;". 
    2694                                         "Estado;Paï¿œs/regiï¿œo do endereï¿œo residencial;Telefone residencial;". 
    2695                                         "Rua do endereï¿œo comercial;Cidade do endereï¿œo comercial;". 
    2696                                         "CEP do endereï¿œo comercial;Estado do endereï¿œo comercial;". 
    2697                                         "Paï¿œs/regiï¿œo do endereï¿œo comercial;Telefone comercial;Empresa;Cargo\r\n"; 
     2769                                        $streamBuffer = "Nome;End. de email;Endereço residencial;". 
     2770                                        "Cidade do endereço residencial;CEP do endereço residencial;". 
     2771                                        "Estado;País/região do endereço residencial;Telefone residencial;". 
     2772                                        "Rua do endereço comercial;Cidade do endereço comercial;". 
     2773                                        "CEP do endereço comercial;Estado do endereço comercial;". 
     2774                                        "País/região do endereço comercial;Telefone comercial;Empresa;Cargo\r\n";                                                        
    26982775                                        foreach($all_contacts as $index => $object){ 
    26992776                                                $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;;;;;;\r\n"; 
    27002777                                        } 
    27012778                                break; 
    2702  
     2779                                 
    27032780                                case 'outlook2000_pt-BR': 
    27042781                                        $streamBuffer = "\"Tratamento\",\"Nome\",\"Segundo Nome\",\"Sobrenome\",\"Sufixo\",". 
    2705                                         "\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endereï¿œo comercial\",\"Rua do endereï¿œo comercial 2\",". 
    2706                                         "\"Rua do endereï¿œo comercial 3\",\"Cidade do endereï¿œo comercial\",\"Estado do endereï¿œo comercial\",". 
    2707                                         "\"CEP do endereï¿œo comercial\",\"Paï¿œs do endereï¿œo comercial\",\"Endereï¿œo residencial\",\"Rua residencial 2\",". 
    2708                                         "\"Rua residencial 3\",\"Cidade do endereï¿œo residencial\",\"Estado\",\"CEP do endereï¿œo residencial\",\"Paï¿œs do endereï¿œo residencial\",". 
    2709                                         "\"Outro endereï¿œo\",\"Outro endereï¿œo 2\",\"Outro endereï¿œo 3\",\"Cidade\",\"Estado\",\"CEP\",\"Paï¿œs\",". 
     2782                                        "\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endereço comercial\",\"Rua do endereço comercial 2\",". 
     2783                                        "\"Rua do endereço comercial 3\",\"Cidade do endereço comercial\",\"Estado do endereço comercial\",". 
     2784                                        "\"CEP do endereço comercial\",\"País do endereço comercial\",\"Endereço residencial\",\"Rua residencial 2\",". 
     2785                                        "\"Rua residencial 3\",\"Cidade do endereço residencial\",\"Estado\",\"CEP do endereço residencial\",\"País do endereço residencial\",". 
     2786                                        "\"Outro endereço\",\"Outro endereço 2\",\"Outro endereço 3\",\"Cidade\",\"Estado\",\"CEP\",\"País\",". 
    27102787                                        "\"Telefone do assistente\",\"Fax comercial\",\"Telefone comercial\",\"Telefone comercial 2\",\"Retorno de chamada\",". 
    27112788                                        "\"Telefone do carro\",\"Telefone principal da empresa\",\"Fax residencial\",\"Telefone residencial\",". 
    27122789                                        "\"Telefone residencial 2\",\"ISDN\",\"Telefone celular\",\"Outro fax\",\"Outro telefone\",\"Pager\",\"Telefone principal\",". 
    2713                                         "\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Aniversï¿œrio\",\"Anotaᅵᅵes\",\"Caixa postal\",\"Categorias\",". 
    2714                                         "\"Cï¿œdigo da empresa\",\"Cï¿œdigo do governo\",\"Cï¿œnjuge\",\"Conta\",\"Endereï¿œo de correio eletrï¿œnico\",". 
    2715                                         "\"Nome de exibiᅵᅵo do correio eletr.\",\"Endereï¿œo de correio eletrï¿œnico 2\",". 
    2716                                         "\"Nome de exibiᅵᅵo do correio eletr.2\",\"Endereï¿œo de correio eletrï¿œnico 3\",". 
    2717                                         "\"Nome de exibiᅵᅵo do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",". 
    2718                                         "\"Filhos\",\"Hobby\",\"Idioma\",\"Indicaᅵᅵo\",\"Informaᅵᅵes para cobranï¿œa\",\"Iniciais\",\"Local\",". 
    2719                                         "\"Nome do assistente\",\"Nome do gerenciador\",\"Pï¿œgina da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",". 
    2720                                         "\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissï¿œo\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretï¿œrio\",". 
     2790                                        "\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Aniversário\",\"Anotações\",\"Caixa postal\",\"Categorias\",". 
     2791                                        "\"Código da empresa\",\"Código do governo\",\"Cônjuge\",\"Conta\",\"Endereço de correio eletrônico\",". 
     2792                                        "\"Nome de exibição do correio eletr.\",\"Endereço de correio eletrônico 2\",". 
     2793                                        "\"Nome de exibição do correio eletr.2\",\"Endereço de correio eletrônico 3\",". 
     2794                                        "\"Nome de exibição do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",". 
     2795                                        "\"Filhos\",\"Hobby\",\"Idioma\",\"Indicação\",\"Informações para cobrança\",\"Iniciais\",\"Local\",". 
     2796                                        "\"Nome do assistente\",\"Nome do gerenciador\",\"Página da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",". 
     2797                                        "\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissão\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretório\",". 
    27212798                                        "\"Sexo\"\r\n"; 
    27222799                                        foreach($all_contacts as $index => $object){ 
     
    27242801                                        } 
    27252802                                break; 
    2726  
     2803                                 
    27272804                                case 'outlook2000_en': 
    27282805                                        $streamBuffer = "Title,First Name,Middle Name,Last Name,Suffix,Company,Department,Job Title,". 
     
    27402817                                        } 
    27412818                                break; 
    2742  
     2819                                         
    27432820                                case 'thunderbird': 
    2744                                         $streamBuffer = "\n"; 
     2821                                        $streamBuffer = "\n";                                                    
    27452822                                        foreach($all_contacts as $index => $object){ 
    27462823                                                $streamBuffer.= ",,".$object['name'].",,".$object['email'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    27472824                                        } 
    27482825                                break; 
    2749  
    2750                                 default: 
     2826                                 
     2827                                case 'expresso': 
    27512828                                        $streamBuffer = "Nome,Email,Telefone\r\n"; 
    27522829                                        foreach($all_contacts as $index => $object){ 
     
    27542831                                        } 
    27552832                                break; 
    2756  
     2833                                 
    27572834                        } 
    27582835 
     
    27622839                        if(!$f) 
    27632840                                echo null; 
    2764  
     2841                 
    27652842                        fputs($f,$streamBuffer); 
    27662843                        fclose($f); 
     
    27692846                } 
    27702847 
     2848                // Get the csv field and put into array, from php.net 
     2849                function parse_line($input_text, $delimiter = ',', $text_qualifier = '"') { 
     2850                        $text = trim($input_text); 
     2851                          if(is_string($delimiter) && is_string($text_qualifier)) { 
     2852                         $re_d = '\x' . dechex(ord($delimiter));            //format for regexp 
     2853                        $re_tq = '\x' . dechex(ord($text_qualifier));    //format for regexp 
     2854                         
     2855                        $fields = array(); 
     2856                        $field_num = 0; 
     2857                        while(strlen($text) > 0) { 
     2858                        if($text{0} == $text_qualifier) { 
     2859                                preg_match('/^' . $re_tq . '((?:[^' . $re_tq . ']|(?<=\x5c)' . $re_tq . ')*)' . $re_tq . $re_d . '?(.*)$/', $text, $matches); 
     2860                                
     2861                                $value = str_replace('\\' . $text_qualifier, $text_qualifier, $matches[1]); 
     2862                                $text = trim($matches[2]); 
     2863                
     2864                                $fields[$field_num++] = $value; 
     2865                        } else { 
     2866                                preg_match('/^([^' . $re_d . ']*)' . $re_d . '?(.*)$/', $text, $matches); 
     2867                                
     2868                                $value = $matches[1]; 
     2869                                $text = trim($matches[2]); 
     2870                
     2871                                $fields[$field_num++] = $value; 
     2872                } 
     2873                } 
     2874                        return $fields; 
     2875                    } else 
     2876                        return false; 
     2877                } 
    27712878 
    27722879                function import_contacts($typeImport){ 
    27732880 
    2774                         $delim          = ($typeImport == 'outlook' ? ';' : ','); 
    2775  
    2776                         if($file = $_SESSION['contactcenter']['importCSV']) { 
    2777                                 unset($_SESSION['contactcenter']['importCSV']); 
     2881                        if($file = $_SESSION['contactcenter']['importCSV']) {                            
     2882                                unset($_SESSION['contactcenter']['importCSV']);                          
    27782883                                $len = filesize($file); 
    27792884                                $count = 0; 
    27802885                                $return = array('error' => false, '_new' => 0, '_existing' => 0, '_failure' => 0); 
    27812886                                $handle = @fopen($file, "r") or die(serialize($return['error'] = true)); 
     2887                                 
     2888                                $input_header = fgets($handle); 
     2889                                if ($typeImport == 'outlook') 
     2890                                        $delim = ';'; 
     2891                                else if ($typeImport == 'auto') 
     2892                                $delim = strstr($input_header,',') ? ',' : ';'; 
     2893                                else   
     2894                                        $delim = ','; 
     2895                                $csv_header = $this->parse_line($input_header,$delim); 
     2896                                $firstContact = fgets($handle); 
     2897                                preg_match("/\"(.+)\"[,;]/sU",$firstContact,$matches); // yahoo csv 
     2898                                rewind($handle);                                 
     2899 
    27822900                                $header = @fgetcsv($handle, $len, $delim) or die(serialize($return['error'] = true)); 
    27832901                                if(count($header)  < 2 || count($header) > 100) { 
     
    27872905                                        return; 
    27882906                                } 
    2789  
    2790                                 $boGroup = CreateObject('contactcenter.bo_group'); 
    2791                                 $boPeople = CreateObject('contactcenter.bo_people_catalog'); 
    2792  
     2907                                 
     2908                                if ($matches[0][strlen($matches[0])-1] == ';') 
     2909                                        $delim = ';'; 
     2910                                 
     2911                        $boGroup = CreateObject('contactcenter.bo_group'); 
     2912                        $boPeople = CreateObject('contactcenter.bo_people_catalog'); 
    27932913                                switch($typeImport){ 
    27942914                                        case 'outlook2000': 
     
    28072927                                                $phone_pos=7; 
    28082928                                                break; 
    2809                                         default: 
     2929                                        case 'expresso': 
    28102930                                                $name_pos=0; 
    28112931                                                $email_pos=1; 
    28122932                                                $phone_pos=2; 
    2813                                 } 
     2933                                                break; 
     2934                                        default: 
     2935                                                foreach($csv_header as $index => $fieldName) 
     2936                                                { 
     2937                                                        switch($fieldName){ 
     2938                                                        case 'Name': 
     2939                                                        case 'Nome': 
     2940                                                        case 'First Name': 
     2941                                                                $name_pos = $index; 
     2942                                                                break; 
     2943                                                        case 'E-mail': 
     2944                                                        case 'Email': 
     2945                                                        case 'E-mail Address': 
     2946                                                        case 'Endereço de correio eletrônico': 
     2947                                                        case 'End. de email': 
     2948                                                                $email_pos = $index; 
     2949                                                                break; 
     2950                                                        case 'Home Phone': 
     2951                                                        case 'Phone': 
     2952                                                        case 'Telefone': 
     2953                                                        case 'Telefone principal': 
     2954                                                        case 'Telefone comercial': 
     2955                                                                $phone_pos = $index; 
     2956                                                                break; 
     2957                                                        } 
     2958                                                }        
     2959                                                break; 
     2960                                } 
     2961                                 
    28142962 
    28152963                                while (($data = fgetcsv($handle, $len, $delim))) { 
    2816  
    28172964                                foreach ($header as $key=>$heading) 
    28182965                                $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; 
    2819  
     2966                                 
    28202967                                        $sdata = array(); 
    28212968                                        $full_name  = trim($row[$header[$name_pos]]); 
     
    28312978                                        $sdata['connections']['default_phone']['connection_name'] = lang('Main'); 
    28322979                                        $sdata['connections']['default_phone']['connection_value'] = $phone; 
    2833  
    2834                                         //      verifica se email jï¿œ existe! 
     2980                                         
     2981                                        //      verifica se email já existe! 
    28352982                                        $contact = $boGroup->verify_contact($email); 
    2836  
     2983                                                                                 
     2984                                        if(!$sdata['given_names'] && $email){ 
     2985                                                        $a_email = explode("@",$email); 
     2986                                                        $sdata['given_names'] = $a_email[0]; 
     2987                                        } 
     2988 
     2989                                        $line_iteration = $return['_failure'] + $return['_existing'] + $return['_new'];  
    28372990                                        if($contact){ 
    28382991                                                $return['_existing']++; 
    2839                                         } 
     2992                                        }                                                                                                                
    28402993                                        else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 
    28412994                                                $return['_failure']++; 
     2995                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>"; 
    28422996                                        } 
    28432997                                        else if (!$sdata['given_names'] || !$email || !$boPeople ->quick_add($sdata)){ 
    2844                                                 $return['_failure']++; 
     2998                                                $return['_failure']++;                                                   
     2999                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid Name: " . $sdata['given_names'] ."<br>"; 
    28453000                                        } 
    28463001                                        else 
    28473002                                                $return['_new']++; 
    2848                         } 
     3003                        }                                
    28493004                                fclose($handle); 
    28503005                                unlink($file); 
     
    28603015                        $new = null; 
    28613016                        $code = null; 
    2862  
     3017                         
    28633018                        if ($parent === '0') 
    28643019                        { 
     
    28663021                                $code .= $name.".add(new dNode({id:'0', caption: '".lang('Catalogues')."'}),'none');\n"; 
    28673022                        } 
    2868  
     3023                         
    28693024                        foreach ($tree as $id => $value) 
    28703025                        { 
     
    28723027 
    28733028                                switch ($value['type']) 
    2874                                 { 
     3029                                {                                        
    28753030                                        case 'unknown': 
    2876                                                 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption:'{$value['name']}', onFirstOpen: 'getCatalogTree(\\'{$parent}.{$id}\\');', onClick: 'getCatalogTree(\\'{$parent}.{$id}\\'); waitForTree(\\'{$parent}.{$id}\\', 0)'}),'$parent');\n"; 
     3031                                                $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption:'{$value['name']}', onFirstOpen: 'getCatalogTree(\\'{$parent}.{$id}\\');', onClick: 'getCatalogTree(\\'{$parent}.{$id}\\'); waitForTree(\\'{$parent}.{$id}\\', 0)'}),'$parent');\n";  
    28773032                                                break; 
    2878  
     3033                                         
    28793034                                        case 'catalog_group': 
    2880                                                 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}'}),'$parent');\n"; 
     3035                                                $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}'}),'$parent');\n";  
    28813036                                                $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 
    28823037                                                break; 
     
    28873042                                                $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 
    28883043                                                break; 
    2889  
     3044                                         
    28903045                                        case 'catalog': 
    28913046                                                $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}', onClick: 'setCatalog(\\'{$parent}.{$id}\\')'}),'$parent');\n"; 
    2892  
    2893                                 } 
    2894                         } 
    2895  
     3047                                                 
     3048                                } 
     3049                        } 
     3050                         
    28963051                        return $code; 
    28973052                } 
  • trunk/contactcenter/inc/class.ui_preferences.inc.php

    r2 r285  
    3535                        $pCatalog = CreateObject('contactcenter.bo_people_catalog'); 
    3636                        $types = $pCatalog->get_all_connections_types(); 
    37  
    38                         if (count($types)) 
     37                         
     38                        if (is_array($types)) 
    3939                        { 
    4040                                $options_email = ''; 
  • trunk/contactcenter/index.php

    r284 r285  
    2424        $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['telephone_number'] = $GLOBALS['phpgw_info']['user']['telephonenumber']; 
    2525        $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] = true; 
    26  
    2726        $obj = CreateObject('contactcenter.ui_data'); 
    2827        $obj->index(); 
    29          
    30  
    3128        $GLOBALS['phpgw']->common->phpgw_footer(); 
    3229?> 
  • trunk/contactcenter/js/cc.js

    r284 r285  
    5757var CC_full_add_const = false; 
    5858var CC_full_add_photo = false; 
    59  
     59         
    6060var CC_last_height = window.innerHeight; 
    6161var CC_last_width = window.innerWidth; 
     
    9090                 photo_input = photo_frame.contentDocument.createElement('input'); 
    9191        } 
    92  
     92         
    9393        photo_frame.id = 'cc_photo_frame'; 
    9494        photo_frame.style.position = 'absolute'; 
     
    9696        photo_frame.style.top = '600px'; 
    9797        photo_frame.style.left = '0px'; 
    98  
     98         
    9999        photo_form.id = 'cc_photo_form'; 
    100100        photo_form.method = 'POST'; 
    101101        photo_form.enctype = 'multipart/form-data'; 
    102  
     102         
    103103        photo_input.id = 'cc_photo_input'; 
    104104        photo_input.type = 'file'; 
    105  
     105         
    106106        if (is_ie) 
    107107        { 
     
    113113        } 
    114114        photo_form.appendChild(photo_input); 
    115  
     115         
    116116} 
    117117 
     
    121121        var obj = Element(id); 
    122122        var max = obj.options.length; 
    123  
     123         
    124124        if (option == undefined) 
    125125        { 
     
    161161function openFullAdd(){ 
    162162        // Build the FullAdd Window. 
    163         if(!fullAddWin && !is_ie) 
     163        if(!fullAddWin && !is_ie)  
    164164                __f(); 
    165165 
     
    168168        fullAddWin.open(); 
    169169        tabs._showTab('cc_contact_tab_0'); 
    170         Element("cc_conn_type_1").checked = false; 
     170        Element("cc_conn_type_1").checked = false;       
    171171        Element("cc_conn_type_2").checked = false; 
    172172        Element("cc_conn_type_sel").disabled = true; 
     
    189189function editGroup(id){ 
    190190        populateEditGroup(id); 
    191         ccAddGroup.window.open(); 
     191        ccAddGroup.window.open();                        
    192192} 
    193193/* 
     
    199199{ 
    200200        CC_full_add_const = false; 
    201  
     201         
    202202        setTimeout('populateFullAddConstAsync()', 10); 
    203203} 
     
    207207        var handler = function(responseText) 
    208208        { 
    209                 //Element('cc_debug').innerHTML = responseText; 
     209                //Element('cc_debug').innerHTML = responseText;          
    210210                var data = unserialize(responseText); 
    211211                var i = 1; 
    212212                var j; 
    213  
     213                 
    214214                if (typeof(data) != 'object') 
    215215                { 
     
    217217                        return; 
    218218                } 
    219  
     219                 
    220220                /* Populate Prefixes */ 
    221221                for (j in data[0]) 
     
    224224                        i++; 
    225225                } 
    226  
     226                 
    227227                /* Populate Suffixes */ 
    228228                i = 1; 
     
    246246                { 
    247247                        Element('cc_addr_countries').options[i] = new Option(data[3][j], j); 
    248  
     248                         
    249249                        if (j == 'BR' || j == 'br') 
    250250                        { 
    251251                                CC_br_index = i; 
    252252                        } 
    253  
     253                         
    254254                        i++; 
    255255                } 
    256  
     256                 
    257257                /* Populate Connection Types */ 
    258258                i = 1; 
     
    262262                        i++; 
    263263                } 
    264  
     264                 
    265265                /* Populate Relations Types */ 
    266266                i = 0; 
     
    270270                        i++; 
    271271                } 
    272  
     272                 
    273273                CC_full_add_const = true; 
    274274 
     
    305305{ 
    306306        var handler = function(responseText) 
    307         { 
    308                 var data = unserialize(responseText); 
    309                 Element('group_id').value = data['id_group']; 
    310  
    311                 if(data['contact_list']) { 
    312                         for(i = 0; i < data['contact_list'].length; i++) { 
    313                                 option = document.createElement('option'); 
    314                                 option.value = data['contact_list'][i]['id_connection']; 
    315                                 option.text = data['contact_list'][i]['names_ordered']+' ('+data['contact_list'][i]['connection_value']+')'; 
    316                                 Element('contact_list').options[Element('contact_list').options.length] = option; 
    317                         } 
     307        {                        
     308                var data = unserialize(responseText);                    
     309                Element('group_id').value = data['id_group'];                                                            
     310                var options_contact_list = Element('contact_list'); 
     311                if(data['contact_list']) {                                       
     312                        options_contact_list.innerHTML = data['contact_list']; 
    318313                } 
    319314 
    320315                if(data['id_group']) { 
    321  
    322                         if(data['contact_in_list']) { 
    323                                 for(i = 0; i < data['contact_in_list'].length; i++) { 
     316                 
     317                        if(data['contact_in_list']) {                                    
     318                                for(i = 0; i < data['contact_in_list'].length; i++) {                            
    324319                                        option = document.createElement('option'); 
    325320                                        option.value = data['contact_in_list'][i]['id_connection']; 
    326                                         option.text = data['contact_in_list'][i]['names_ordered']+' ('+data['contact_in_list'][i]['connection_value']+')'; 
     321                                        option.text = data['contact_in_list'][i]['names_ordered']+' ('+data['contact_in_list'][i]['connection_value']+')';                               
    327322                                        Element('contact_in_list').options[Element('contact_in_list').options.length] = option; 
    328323                                } 
    329                         } 
    330  
     324                        }                
     325                         
    331326                        Element('title').value =  data['title']; 
    332327                } 
    333  
     328                                 
    334329                if (typeof(data) != 'object' || data['result'] != 'ok') 
    335330                { 
     
    338333                } 
    339334        }; 
    340  
     335                 
    341336        id = typeof(id) == 'undefined' ? id = 0 :  id; 
    342  
    343         ccAddGroup.clear(true); 
     337         
     338        ccAddGroup.clear(true);                  
    344339        Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id, 'GET', handler); 
    345340} 
     
    376371                return false; 
    377372        } 
    378  
     373         
    379374        /* First thing: Send Photo */ 
    380375        if (Element('cc_pd_select_photo').value != '' && !is_ie) 
     
    394389                        frame = old_frame; 
    395390                } 
    396  
     391                 
    397392                frame.id = 'cc_photo_frame'; 
    398393                frame.style.visibility = 'hidden'; 
     
    403398 
    404399                form = frame.contentDocument.createElement('form'); 
    405  
     400                 
    406401                var id_contact = Element('cc_full_add_contact_id').value; 
    407402                form.id = 'cc_form_photo'; 
     
    409404                form.enctype = 'multipart/form-data'; 
    410405                form.action = 'http://'+ document.domain + Element('cc_root_dir').value+'../index.php?menuaction=contactcenter.ui_data.data_manager&method=post_photo&id='+(id_contact != '' && id_contact != 'null' ? id_contact : ''); 
    411  
     406                 
    412407                var input_clone = Element('cc_pd_select_photo').cloneNode(false); 
    413408                form.appendChild(input_clone); 
    414  
     409                 
    415410                frame.contentDocument.body.appendChild(form); 
    416411                form.submit(); 
     
    466461        var empty = true; 
    467462        var replacer = '__##AND##__'; 
    468  
     463         
    469464        data['commercialAnd'] = replacer; 
    470  
     465         
    471466        if (Element('cc_full_add_contact_id').value != '' && Element('cc_full_add_contact_id').value != 'null') 
    472467        { 
     
    477472        /* Status: Full Added */ 
    478473        data['id_status'] = CC_STATUS_FULL_ADD; 
    479  
     474         
    480475        /* Personal Data */ 
    481476        data['alias']         = replaceComAnd(Element('cc_pd_alias').value, replacer); 
     
    515510                                data['connections'] = new Array(); 
    516511                        } 
    517  
     512                         
    518513                        for (var i in CC_contact_full_info['connections'][type]) 
    519514                        { 
     
    527522                                        data['connections']['connection'+connNumber] = new Array(5); 
    528523                                } 
    529  
     524                                 
    530525                                data['connections']['connection'+connNumber]['id_connection'] = CC_contact_full_info['connections'][type][i]['id']; 
    531526                                data['connections']['connection'+connNumber]['id_typeof_connection'] = type; 
     
    536531                                                data['connections']['connection'+connNumber]['connection_is_default']  = 'TRUE'; 
    537532                                        } 
    538                                         else 
     533                                        else  
    539534                                                data['connections']['connection'+connNumber]['connection_is_default']  = 'FALSE'; 
    540535                                } 
    541536 
    542537//                              data['connections']['connection'+connNumber].length = 5; 
    543  
     538                                 
    544539                                empty = false; 
    545540                                connNumber++; 
     
    548543 
    549544                } 
    550  
     545                 
    551546                if (!empty) 
    552547                { 
     
    555550                } 
    556551        } 
    557  
     552         
    558553        if (CC_contact_full_info['removed_conns']) 
    559554        { 
    560555                empty = false; 
    561  
     556                 
    562557                if (typeof(data['connections']) != 'object') 
    563558                { 
     
    594589                        for (var i in CC_contact_full_info['connections'][type]){ 
    595590                                if((CC_contact_full_info['connections'][type][i]['value'].length < 4) || 
    596                                         (!comp.test(CC_contact_full_info['connections'][type][i]['value']))){ 
    597                                         showMessage('Endereï¿œo para conexï¿œo de ' + CC_contact_full_info['connections'][type][i]['name'] + ', nï¿œo ï¿œ vï¿œlido'); 
     591                                        (!comp.test(CC_contact_full_info['connections'][type][i]['value']))){  
     592                                        showMessage('Endereço para conexão de ' + CC_contact_full_info['connections'][type][i]['name'] + ', não é válido'); 
    598593                                        return false; 
    599594                                } 
     
    601596                        var _options_default = Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default"); 
    602597                        if(_options_default.value == '-1') { 
    603                                 alert("ï¿œ necessï¿œrio escolher um "+ (type == 1 ? 'E-mail' : 'Telefone')+" como padrï¿œo!"); 
     598                                alert("É necessário escolher um "+ (type == 1 ? 'E-mail' : 'Telefone')+" como padrão!"); 
    604599                                return false; 
    605600                        } 
    606601                } 
    607  
     602                 
    608603        } 
    609604 
     
    614609 
    615610/********* Personal Data Functions *********/ 
    616 /* 
     611/*  
    617612 * data[0] => cc_pd_select_photo 
    618613 * data[1] => cc_pd_alias 
     
    662657{ 
    663658        Element('cc_addr_types').selectedIndex = 0; 
    664  
     659         
    665660        Element('cc_addr_countries').selectedIndex = 0; 
    666661        Element('cc_addr_countries').disabled = true; 
    667  
     662         
    668663        Element('cc_addr_states').selectedIndex = 0; 
    669664        Element('cc_addr_states').disabled = true; 
     
    716711        var type = Element('cc_addr_types'); 
    717712        var oldSelected = type.value; 
    718  
     713         
    719714        saveAddressFields(); 
    720  
     715         
    721716        if (oldSelected == '_NONE_') 
    722717        { 
     
    724719                return true; 
    725720        } 
    726  
     721         
    727722        CC_addr_last_selected = type.selectedIndex; 
    728  
     723         
    729724        Element('cc_addr_countries').disabled = false; 
    730  
     725         
    731726        var data = CC_contact_full_info['addresses']; 
    732727        var addrIndex  = 'address'+Element('cc_addr_types').value; 
    733  
    734         if (typeof(data) != 'object' || typeof(data[addrIndex]) != 'object') 
     728         
     729        if (typeof(data) != 'object' || typeof(data[addrIndex]) != 'object')  
    735730        { 
    736731                resetAddressFields(); 
     
    741736                return true; 
    742737        } 
    743  
     738         
    744739        var addrTypeID = Element('cc_addr_types').value; 
    745  
     740         
    746741        data = CC_contact_full_info['addresses'][addrIndex]; 
    747  
     742         
    748743        Element('cc_addr_id').value                              = data['id_address']           ? data['id_address']                    : ''; 
    749744        Element('cc_addr_1').value                              = data['address1']                      ? data['address1']                              : ''; 
     
    767762                states.selectedIndex = 0; 
    768763                clearSelectBox(states, 4); 
    769                 updateAddrCities(); 
     764                updateAddrCities();      
    770765                return; 
    771766        } 
     
    782777        { 
    783778                var data = unserialize(responseText); 
    784  
     779                 
    785780                clearSelectBox(states, 1); 
    786  
     781                         
    787782                if (typeof(data) != 'object') 
    788783                { 
    789784                        showMessage(Element('cc_msg_err_contacting_server').value); 
    790  
     785         
    791786                        return; 
    792787                } 
     
    795790                { 
    796791                        states.disabled = true; 
    797                         cities.disabled = true; 
     792                        cities.disabled = true;                  
    798793                        states.selectedIndex = 0; 
    799794                        cities.selectedIndex = 0; 
     
    835830                } 
    836831        }; 
    837  
     832         
    838833        Connector.newRequest('populateStates', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_states&country='+Element('cc_addr_countries').value, 'GET', handler); 
    839834} 
     
    863858                        newState.disabled = false; 
    864859                        updateAddrNewStateOnMouseOut(); 
    865  
     860                         
    866861                        cities.disabled = false; 
    867862                        clearSelectBox(cities, 3); 
     
    874869                case '_NOSTATE_': 
    875870                        clearSelectBox(cities, 3); 
    876  
     871                         
    877872                        cities.disabled = false; 
    878873                        cities.selectedIndex = 0; 
    879  
     874                         
    880875                        requestStr = 'country='+Element('cc_addr_countries').value; 
    881876                        break; 
    882  
     877                 
    883878                default: 
    884879                        requestStr = 'country='+Element('cc_addr_countries').value+'&state='+states.value; 
     
    895890{ 
    896891        var cities = Element('cc_addr_cities'); 
    897  
     892         
    898893        var handler = function (responseText) 
    899894        { 
    900895                var data = unserialize(responseText); 
    901  
     896                 
    902897                clearSelectBox(cities, 1); 
    903  
     898                 
    904899                if (typeof(data) != 'object') 
    905900                { 
    906901                        showMessage(Element('cc_msg_err_contacting_server').value); 
    907  
     902                         
    908903                        return; 
    909904                } 
     
    950945                } 
    951946        }; 
    952  
     947         
    953948        Connector.newRequest('populateCities', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cities&'+requestStr, 'GET', handler); 
    954949} 
     
    956951function updateAddrNewStateOnMouseOver () 
    957952{ 
    958         if (Element('cc_addr_states_new').value == Element('cc_msg_type_state').value && Element('cc_addr_states').selectedIndex == 1) 
     953        if (Element('cc_addr_states_new').value == Element('cc_msg_type_state').value && Element('cc_addr_states').selectedIndex == 1)  
    959954        { 
    960955                Element('cc_addr_states_new').value = ''; 
     
    964959function updateAddrNewStateOnMouseOut () 
    965960{ 
    966         if (Element('cc_addr_states_new').value.length == 0 && Element('cc_addr_states').selectedIndex == 1) 
     961        if (Element('cc_addr_states_new').value.length == 0 && Element('cc_addr_states').selectedIndex == 1)  
    967962        { 
    968963                Element('cc_addr_states_new').value = Element('cc_msg_type_state').value; 
     
    984979                return; 
    985980        } 
    986  
     981         
    987982        Element('cc_addr_1').readonly = false; 
    988983        Element('cc_addr_1').disabled = false; 
     
    10141009 
    10151010                        //resetAddrFillingFields(); 
    1016  
     1011                         
    10171012                        return; 
    10181013 
     
    10221017                        newCity.disabled = false; 
    10231018                        updateAddrNewCityOnMouseOut(); 
    1024  
     1019                         
    10251020                        break; 
    10261021 
     
    10361031function updateAddrNewCityOnMouseOver () 
    10371032{ 
    1038         if (Element('cc_addr_cities_new').value == Element('cc_msg_type_city').value && Element('cc_addr_cities').selectedIndex == 1) 
     1033        if (Element('cc_addr_cities_new').value == Element('cc_msg_type_city').value && Element('cc_addr_cities').selectedIndex == 1)  
    10391034        { 
    10401035                Element('cc_addr_cities_new').value = ''; 
     
    10441039function updateAddrNewCityOnMouseOut () 
    10451040{ 
    1046         if (Element('cc_addr_cities_new').value.length == 0 && Element('cc_addr_cities').selectedIndex == 1) 
     1041        if (Element('cc_addr_cities_new').value.length == 0 && Element('cc_addr_cities').selectedIndex == 1)  
    10471042        { 
    10481043                Element('cc_addr_cities_new').value = Element('cc_msg_type_city').value; 
     
    10581053                return true; 
    10591054        } 
    1060  
    1061         var addrFields = new Array('cc_addr_1', 
    1062                                    'cc_addr_2', 
    1063                                                            'cc_addr_complement', 
     1055         
     1056        var addrFields = new Array('cc_addr_1',  
     1057                                   'cc_addr_2',  
     1058                                                           'cc_addr_complement',  
    10641059                                                           'cc_addr_other', 
    1065                                                            'cc_addr_postal_code', 
     1060                                                           'cc_addr_postal_code',  
    10661061                                                           'cc_addr_po_box', 
    10671062                                                           'cc_addr_countries', 
     
    10701065 
    10711066        var empty = true; 
    1072  
     1067         
    10731068        for (var i = 0; i < 8; i++) 
    10741069        { 
     
    10791074                } 
    10801075        } 
    1081  
     1076                                 
    10821077        if (empty) 
    10831078        { 
     
    11081103                default: 
    11091104                        addrInfo['id_country'] = Element('cc_addr_countries').value; 
    1110  
     1105                 
    11111106        } 
    11121107 
     
    11221117                default: 
    11231118                        addrInfo['id_state'] = Element('cc_addr_states').value; 
    1124  
     1119                 
    11251120        } 
    11261121 
     
    11351130                default: 
    11361131                        addrInfo['id_city'] = Element('cc_addr_cities').value; 
    1137  
    1138         } 
     1132                 
     1133        }        
    11391134 
    11401135        addrInfo['id_typeof_address']  = Element('cc_addr_types').options[lastIndex].value; 
     
    11491144        CC_contact_full_info['addresses']['address'+Element('cc_addr_types').options[lastIndex].value] = addrInfo; 
    11501145 
    1151         if (Element('cc_addr_cities').value == '_NEW_' && 
     1146        if (Element('cc_addr_cities').value == '_NEW_' &&  
    11521147            Element('cc_msg_type_city').value !=  Element('cc_addr_cities_new').value && 
    11531148                Element('cc_addr_cities_new').value != '') 
    11541149        { 
    11551150                var addrRootInfo = CC_contact_full_info['addresses']['new_cities']; 
    1156  
     1151                 
    11571152                if (!addrRootInfo) 
    11581153                { 
    11591154                        addrRootInfo = new Array(); 
    11601155                } 
    1161  
     1156                 
    11621157                var i = addrRootInfo.length; 
    11631158                addrRootInfo[addrInfo['id_typeof_address']] = new Array(); 
     
    11681163        } 
    11691164 
    1170         if (Element('cc_addr_states').value == '_NEW_' && 
    1171             Element('cc_msg_type_state').value !=  Element('cc_addr_states_new').value && 
     1165        if (Element('cc_addr_states').value == '_NEW_' &&  
     1166            Element('cc_msg_type_state').value !=  Element('cc_addr_states_new').value &&  
    11721167                Element('cc_addr_states_new').value != '') 
    11731168        { 
    11741169                var addrRootInfo = CC_contact_full_info['addresses']['new_states']; 
    1175  
     1170                 
    11761171                if (!addrRootInfo) 
    11771172                { 
    11781173                        addrRootInfo = new Array(); 
    11791174                } 
    1180  
     1175                 
    11811176                var i = addrRootInfo.length; 
    11821177                addrRootInfo[addrInfo['id_typeof_address']] = new Array(); 
     
    12081203        for(idx_conn; idx_conn < cc_conn_default.options.length; idx_conn++) 
    12091204                if(cc_conn_default.options[idx_conn].value == _label) 
    1210                         break; 
    1211  
     1205                        break;   
     1206         
    12121207        if(idx_conn == cc_conn_default.options.length) 
    12131208                cc_conn_default.options[idx_conn] = new Option (_label,_label, false,false); 
    1214  
     1209                         
    12151210        if (!document.all) 
    12161211        { 
    1217                 if (Element("cc_conn_type_1").checked) 
    1218                 { 
    1219                         return '<td style="position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden"><input id="cc_conn_id_' + CC_conn_count + '" type="hidden" value="_NEW_"><input id="cc_conn_is_default_' + CC_conn_count + '" type="hidden" value="false"></td>'+ 
    1220                         //'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+ 
    1221                         '<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px;" align="right"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+'</span></td>' + 
    1222                         '<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" style="width: 150px;" maxlength="100" type="text">&nbsp;' + 
    1223                         '<img align="top" alt="X" src="templates/default/images/x.png" style="width:18px; height:18px" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"></td>'; 
    1224                 } 
    1225                 else if (Element("cc_conn_type_2").checked) 
    1226                 { 
    1227                         return '<td style="position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden"><input id="cc_conn_id_' + CC_conn_count + '" type="hidden" value="_NEW_"><input id="cc_conn_is_default_' + CC_conn_count + '" type="hidden" value="false"></td>'+ 
    1228                         //'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+ 
    1229                         '<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px;" align="right"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+'</span></td>' + 
    1230                         '<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" style="width: 150px;" maxlength="50" type="text">&nbsp;' + 
    1231                         '<img align="top" alt="X" src="templates/default/images/x.png" style="width:18px; height:18px" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"></td>'; 
    1232                 } 
     1212                return '<td style="position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden"><input id="cc_conn_id_' + CC_conn_count + '" type="hidden" value="_NEW_"><input id="cc_conn_is_default_' + CC_conn_count + '" type="hidden" value="false"></td>'+ 
     1213                //'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+ 
     1214                '<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px;" align="right"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+'</span></td>' + 
     1215                '<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" style="width: 150px;" type="text">&nbsp;' + 
     1216                '<img align="top" alt="X" src="templates/default/images/x.png" style="width:18px; height:18px" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"></td>'; 
    12331217        } 
    12341218        else 
     
    12541238                img.align = 'top'; 
    12551239                img.onclick = function(e){ removeConnField(remove_id);}; 
    1256  
     1240                 
    12571241                for (var i = 0; i < 3; i++) 
    12581242                { 
     
    12651249 
    12661250                inputs[1].id = 'cc_conn_name_'+CC_conn_count; 
    1267                 inputs[1].type = 'hidden'; 
     1251                inputs[1].type = 'hidden';               
    12681252 
    12691253                inputs[2].id = 'cc_conn_value_'+CC_conn_count; 
     
    12941278                || typeof(CC_contact_full_info['connections'][CC_conn_last_selected]) == 'undefined' 
    12951279                || typeof(CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]) == 'undefined'); 
    1296  
    1297         if(_emptyLine) { 
    1298  
     1280         
     1281        if(_emptyLine) {         
     1282                 
    12991283                if(Element("cc_conn_type_sel").value == '-1'){ 
    1300                                 return false; 
    1301                 } 
    1302  
     1284                                return false;    
     1285                } 
     1286                 
    13031287                for(k = 0; k < CC_conn_count; k++) { 
    13041288                        if(Element("cc_conn_name_"+k) && Element("cc_conn_name_"+k).value != "" && Element("cc_conn_name_"+k).value == Element("cc_conn_type_sel").value) { 
    1305                                 alert('Vocï¿œ jï¿œ possui uma entrada para o tipo "'+Element("cc_conn_type_sel").value+'"!'); 
    1306                                 Element("cc_conn_type_sel").options.selectedIndex = 0; 
     1289                                alert('Você já possui uma entrada para o tipo "'+Element("cc_conn_type_sel").value+'"!'); 
     1290                                Element("cc_conn_type_sel").options.selectedIndex = 0;                           
    13071291                                return false; 
    13081292                        } 
    13091293                } 
    1310         } 
     1294        }        
    13111295        if (!document.all) 
    13121296        { 
     
    13351319 
    13361320function connRemoveLine(id) 
    1337 { 
     1321{        
    13381322        var p = Element(id).parentNode; 
    13391323        var cc_conn_default = Element("cc_phone_default").style.display == '' ? Element("cc_phone_default") : Element("cc_email_default"); 
     
    13741358                } 
    13751359        } 
    1376  
     1360         
    13771361        CC_conn_count = 0; 
    13781362} 
     
    13961380function updateConnFields() 
    13971381{ 
    1398  
     1382         
    13991383        var connID; 
    14001384        var i; 
     
    14051389        var cc_conn_is_default = ''; 
    14061390        var selected_index = ''; 
    1407  
     1391         
    14081392        cc_conn_type_sel.disabled = false; 
    14091393        div_cc_conn_is_default.style.display = ""; 
    1410  
     1394         
    14111395        for(var i = 0;i < cc_conn_type_sel.options.length; i++) 
    1412                 cc_conn_type_sel.options[i--] = null; 
    1413  
     1396                cc_conn_type_sel.options[i--] = null;    
     1397                 
    14141398        if(Element('cc_conn_type_1').checked) { 
    1415                 cc_conn_type_sel[0] = new Option('Novo Email...','-1'); 
    1416                 cc_conn_type_sel[1] = new Option('Principal','Principal'); 
    1417                 cc_conn_type_sel[2] = new Option('Alternativo','Alternativo'); 
     1399            var lang_new_email = Element('cc_msg_new_email').value; 
     1400            var lang_main = Element('cc_msg_main').value; 
     1401            var lang_alternative = Element('cc_msg_alternative').value;  
     1402            cc_conn_type_sel[0] = new Option(lang_new_email,'-1');       
     1403            cc_conn_type_sel[1] = new Option(lang_main,lang_main); 
     1404            cc_conn_type_sel[2] = new Option(lang_alternative,lang_alternative);         
    14181405                connID = 1; 
    14191406                selected_index = cc_email_default.options.selectedIndex; 
     
    14221409                } 
    14231410 
    1424                 cc_email_default.options[0] = new Option('Selecionar Email...','-1'); 
    1425  
     1411                var lang_select_email = Element('cc_msg_select_email').value; 
     1412                cc_email_default.options[0] = new Option(lang_select_email,'-1');                
    14261413                cc_phone_default.style.display = 'none'; 
    1427                 cc_email_default.style.display = ''; 
     1414                cc_email_default.style.display = '';                     
    14281415                cc_conn_is_default = cc_email_default; 
    14291416        } 
    14301417        else if(Element('cc_conn_type_2').checked) { 
    1431                 cc_conn_type_sel[0] = new Option('Novo Telefone...','-1'); 
    1432                 cc_conn_type_sel[1] = new Option('Residencial','Residencial'); 
    1433                 cc_conn_type_sel[2] = new Option('Celular','Celular'); 
    1434                 cc_conn_type_sel[3] = new Option('Comercial','Comercial'); 
    1435                 cc_conn_type_sel[4] = new Option('Fax','Fax'); 
    1436                 cc_conn_type_sel[5] = new Option('Pager','Pager'); 
     1418            var lang_new_telephone = Element('cc_msg_new_phone').value; 
     1419            var lang_home = Element('cc_msg_home').value; 
     1420            var lang_cellphone = Element('cc_msg_cellphone').value; 
     1421            var lang_work = Element('cc_msg_work').value; 
     1422            var lang_fax = Element('cc_msg_fax').value; 
     1423            var lang_pager = Element('cc_msg_pager').value; 
     1424            cc_conn_type_sel[0] = new Option(lang_new_telephone,'-1');   
     1425            cc_conn_type_sel[1] = new Option(lang_home,lang_home); 
     1426            cc_conn_type_sel[2] = new Option(lang_cellphone,lang_cellphone);     
     1427            cc_conn_type_sel[3] = new Option(lang_work,lang_work); 
     1428            cc_conn_type_sel[4] = new Option(lang_fax,lang_fax); 
     1429            cc_conn_type_sel[5] = new Option(lang_pager,lang_pager); 
     1430 
    14371431                connID = 2; 
    14381432                selected_index = cc_phone_default.options.selectedIndex; 
     
    14411435                } 
    14421436 
    1443                 cc_phone_default.options[0] = new Option('Selecionar Telefone...','-1'); 
     1437                var lang_choose_phone = Element('cc_msg_choose_phone').value;            
     1438                cc_phone_default.options[0] = new Option(lang_choose_phone,'-1'); 
    14441439                cc_email_default.style.display = 'none'; 
    14451440                cc_phone_default.style.display = ''; 
    14461441                cc_conn_is_default = cc_phone_default; 
    14471442        } 
    1448  
     1443                         
    14491444        Element("cc_conn_type_sel").options.selectedIndex = 0; 
    14501445        /* First save the data */ 
     
    14521447 
    14531448        CC_conn_last_selected = connID; 
    1454  
     1449         
    14551450        clearConn(); 
    1456  
     1451         
    14571452        if (connID == '_NONE_') 
    14581453        {       cc_conn_is_default.disabled = true; 
    14591454                return; 
    14601455        } 
    1461  
     1456         
    14621457        /* If no data already available, return */ 
    14631458        if (!CC_contact_full_info['connections']) 
     
    14831478                        } 
    14841479                } 
    1485         } 
     1480        }        
    14861481        if(cc_conn_is_default.options.length > selected_index) 
    14871482                cc_conn_is_default.options.selectedIndex = (selected_index == "-1" ? 0 : selected_index); 
     
    15041499                        CC_contact_full_info['connections'][CC_conn_last_selected] = new Array(); 
    15051500                } 
    1506                 else 
     1501                else  
    15071502                { 
    15081503                        delete CC_contact_full_info['connections'][CC_conn_last_selected]; 
     
    15161511                                var subNodes = nodes[i].childNodes; 
    15171512                                var found = false; 
    1518  
     1513                                 
    15191514                                for (var j = 0; j < subNodes.length; j++) 
    15201515                                { 
    1521                                         if (subNodes[j].childNodes.length > 0 && 
     1516                                        if (subNodes[j].childNodes.length > 0 &&  
    15221517                                            subNodes[j].childNodes[0].id) 
    15231518                                        { 
     
    15271522                                                        CC_contact_full_info['connections'][CC_conn_last_selected][k] = new Array(); 
    15281523                                                } 
    1529  
     1524                                                 
    15301525                                            if (subNodes[j].childNodes[0].id.indexOf('cc_conn_name') != -1) 
    15311526                                                { 
     
    15471542                                                        else 
    15481543                                                        { 
    1549                                                                 CC_contact_full_info['connections'][CC_conn_last_selected][k]['value'] = ''; 
     1544                                                                CC_contact_full_info['connections'][CC_conn_last_selected][k]['value'] = '';  
    15501545                                                        } 
    15511546                                                } 
     
    15581553                                        } 
    15591554                                } 
    1560  
     1555                                 
    15611556                                if (found) 
    15621557                                { 
     
    15751570                        delete CC_contact_full_info['connections'][CC_conn_last_selected]; 
    15761571                } 
    1577  
     1572                 
    15781573        } 
    15791574 
     
    16011596        var number = randomString().toLowerCase(); 
    16021597        var result = ''; 
    1603  
     1598         
    16041599        if(!is_ie) 
    1605                 result = prompt("Essa operaᅵᅵo removerï¿œ TODOS os seus \ncontatos pessoais,  e  Nï¿œO  PODERï¿œ  ser \ndesfeita. Digite o cï¿œdigo abaixo:\n\tCï¿œdigo de confirmaᅵᅵo: "+number); 
     1600                result = prompt("Essa operação removerá TODOS os seus \ncontatos pessoais,  e  NÃO  PODERÁ  ser \ndesfeita. Digite o código abaixo:\n\tCódigo de confirmação: "+number); 
    16061601        else 
    1607                 result = prompt("Essa operaᅵᅵo removerï¿œ TODOS os seus contatos pessoais,  e  Nï¿œO  PODERï¿œ  ser desfeita. Digite o seguinte cï¿œdigo de confirmaᅵᅵo: "+number,""); 
     1602                result = prompt("Essa operação removerá TODOS os seus contatos pessoais,  e  NÃO  PODERÁ  ser desfeita. Digite o seguinte código de confirmação: "+number,""); 
    16081603 
    16091604        if(result) { 
     
    16111606                        Connector.newRequest('removeAllEntries', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=remove_all_entries', 'GET', handler); 
    16121607                else 
    1613                         alert('Cï¿œdigo Incorreto'); 
    1614         } 
     1608                        alert('Código Incorreto'); 
     1609        }        
    16151610} 
    16161611 
     
    16231618                return; 
    16241619        } 
    1625  
     1620         
    16261621        var handler = function (responseText) 
    16271622        { 
     
    16331628                        return; 
    16341629                } 
    1635  
     1630                 
    16361631                if (data['status'] != 'ok') 
    16371632                { 
     
    16391634                        return; 
    16401635                } 
    1641  
     1636                 
    16421637                setTimeout('updateCards()',80);; 
    16431638        }; 
    1644  
     1639                 
    16451640        typeArg = (type == 'groups' ? 'group' : 'entry'); 
    1646  
     1641                 
    16471642        Connector.newRequest('removeEntry', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=remove_'+typeArg+'&remove=' + id, 'GET', handler); 
    16481643} 
     
    16671662        var w_height = 0; 
    16681663        var w_extra = 200; 
    1669  
     1664         
    16701665        if (document.body.clientHeight) 
    16711666        { 
     
    17061701        } 
    17071702} 
    1708  
    17091703function getActualPage () 
    17101704{ 
     
    17711765                                final_page = 1; 
    17721766                        } 
    1773  
     1767                         
    17741768                        html_pages += '<a href="javascript:setPages('+npages+', '+ actual_page +', '+ final_page +')">...</a> '; 
    17751769 
    17761770                        page = showing_page ? showing_page : actual_page; 
    17771771                } 
    1778  
     1772                 
    17791773                for (; page <= npages; page++) 
    17801774                { 
     
    18361830                Element('cc_panel_arrow_last').style.cursor = 'hand'; 
    18371831        } 
    1838  
     1832         
    18391833        Element('cc_panel_pages').innerHTML = html_pages; 
    18401834} 
     
    18421836function populateCards(data, type) 
    18431837{ 
    1844  
     1838        if (data[3].length >= 100 ) 
     1839        { 
     1840                alert("Critério de pesquisa muito abrangente, achados " + data[3].length + " resultados"); 
     1841                for (i = 0; i < (Math.sqrt(data[3].length)-1); i++) 
     1842                        for (j = 0; j < 3; j++) 
     1843                                document.getElementById("cc_card:"+j+":"+i).innerHTML = ''; 
     1844                return false; 
     1845        } 
     1846         
    18451847        if(type == 'groups') 
    18461848                return populateGroupsInCards(data); 
    1847  
     1849         
    18481850        var pos = 0; 
    18491851        var ncards = data[3].length; 
    1850  
     1852         
    18511853        if (typeof(data[3]) == 'object' && ncards > 0) 
    18521854        { 
     
    18561858                        { 
    18571859                                id = 'cc_card:'+j+':'+i; 
    1858  
     1860                         
    18591861                                for (var k = 0; k < data[2].length; k++) 
    18601862                                { 
    1861  
    1862                                         if(data[2][k] ==  'cc_mail' && data[3][pos][k] == 'none' && !(ccTree.catalog_perms & 2) ) { 
     1863                                        if(!(ccTree.catalog_perms & 2)) 
     1864                                        { 
     1865                                                switch(data[2][k]) 
     1866                                                { 
     1867                                                        case 'cc_mail' : 
     1868 
     1869                                                                if(data[3][pos][k] === 'none') 
     1870                                                                        data[3][pos][k] = '&nbsp'; 
     1871                                                                break; 
     1872                                                        case 'cc_phone' : 
     1873 
     1874                                                                if(data[3][pos][k] === 'none') 
     1875                                                                        data[3][pos][k] = '&nbsp'; 
     1876                                                                break; 
     1877                                                } 
     1878                                                 
     1879                                        } 
     1880                                         
     1881                                         
     1882                                        /*if(data[2][k] ==  'cc_mail' && data[3][pos][k] == 'none' && !(ccTree.catalog_perms & 2) ) { 
    18631883                                                Element(id).style.display = 'none'; 
    18641884                                                continue; 
    1865                                         } 
    1866  
     1885                                        }*/ 
     1886                                 
    18671887                                        if(data[3][pos][k] != 'none') 
    18681888                                        { 
     
    18801900                                                                } 
    18811901                                                                break; 
    1882  
     1902                                                         
    18831903                                                        case 'cc_mail': 
     1904                                                                 
    18841905                                                                if (data[3][pos][k].length > (CC_visual == 'table'  ? 50 : 20)) 
    18851906                                                                { 
     
    18891910                                                                else 
    18901911                                                                { 
    1891                                                                         Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>'; 
     1912                                                                        Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>';                                                                   
    18921913                                                                } 
    18931914                                                                break; 
    1894  
     1915                                                         
    18951916                                                        case 'cc_phone': 
    18961917                                                                if (data[3][pos][k].length > 20) 
     
    19231944                                                                Element(id+':cc_photo').src = '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_photo' + (data[4][pos] != 0 ? '&id='+data[3][pos][k] : ''); 
    19241945                                                                if(ccTree.catalog_perms == 1) 
    1925                                                                         Element(id+':cc_icon_data').innerHTML =  '<span title="Copiar para o Catï¿œlogo Pessoal" id="' + id + ':ccQuickAdd" onmouseout="window.status=\'\';" onclick="ccQuickAddContact.showList(\''+ Element(id+':cc_id').value + '\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img src="templates/default/images/address-conduit-16.png" align="center"></span>'; 
     1946                                                                        Element(id+':cc_icon_data').innerHTML =  '<span title="'+Element('cc_msg_copy_to_catalog').value+'" id="' + id + ':ccQuickAdd" onmouseout="window.status=\'\';" onclick="ccQuickAddContact.showList(\''+ Element(id+':cc_id').value + '\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img src="templates/default/images/address-conduit-16.png" align="center"></span>'; 
    19261947                                                                break; 
    19271948 
    19281949                                                        case 'cc_forwarding_address': 
    19291950                                                                var contacts = data[3][pos][k]; 
    1930  
     1951                                                                                                                                 
    19311952                                                                if( !contacts) 
    19321953                                                                        break; 
    1933  
     1954                                                                                                                                                                                                                                                                                                                                 
    19341955                                                                Element(id+':cc_icon_group').innerHTML =  '<span title="'+Element('cc_participants').value+'"  onmouseout="window.status=\'\';" onclick="ccListParticipants.showList(\''+ Element(id+':cc_id').value + '\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img src="templates/default/images/people-mini.png" align="center">&nbsp;&nbsp;</span>'; 
    1935                                                                 break; 
    1936  
    1937                                                         case 'cc_empNumber': 
    1938                                                                 if (data[3][pos][k].length > 20) 
    1939                                                                 { 
    1940                                                                         Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20); 
    1941                                                                         Element(id+':'+data[2][k]).title = data[3][pos][k]; 
    1942                                                                 } 
    1943                                                                 else 
    1944                                                                 { 
    1945                                                                         Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20); 
    1946                                                                 } 
    1947                                                                 Element(id+':cc_empNumber').innerHTML = data[3][pos][k]; 
    1948                                                                 break; 
    1949  
    1950                                                         //Para tratar tamanho do campo "departamento" do empregado 
    1951                                                         case 'cc_department': 
    1952                                                                 if (data[3][pos][k].length > 15) 
    1953                                                                 { 
    1954                                                                         Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15); 
    1955                                                                         Element(id+':'+data[2][k]).title = data[3][pos][k]; 
    1956                                                                 } 
    1957                                                                 else 
    1958                                                                 { 
    1959                                                                         Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15); 
    1960                                                                 } 
    1961                                                                 Element(id+':cc_department').innerHTML = data[3][pos][k]; 
    19621956                                                                break; 
    19631957 
     
    19701964                                                                else 
    19711965                                                                { 
    1972                                                                         if (Element(id+':'+data[2][k]) == null) alert('ï¿œ nulovgdfv'); 
    19731966                                                                        Element(id+':'+data[2][k]).innerHTML = data[3][pos][k]; 
    19741967                                                                } 
     
    19761969                                        } 
    19771970                                } 
    1978  
     1971         
    19791972                                if (--ncards == 0) 
    19801973                                { 
     
    19821975                                        i = CC_max_cards[1]; 
    19831976                                } 
    1984  
     1977         
    19851978                                pos++; 
    19861979                        } 
     
    19901983 
    19911984function populateGroupsInCards(data) 
    1992 { 
     1985{        
    19931986        var pos = 0; 
    1994         var contacts = data[5]; 
     1987        var contacts = data[5];          
    19951988        var ncards = data[3].length; 
    1996  
     1989         
    19971990        if (typeof(data[3]) == 'object' && ncards > 0) 
    19981991        { 
     
    20021995                        { 
    20031996                                id = 'cc_card:'+j+':'+i; 
    2004  
     1997                         
    20051998                                for (var k = 0; k < data[2].length; k++) 
    20061999                                { 
    2007  
     2000                                 
    20082001                                        if(data[3][pos][k] != 'none') 
    2009                                         { 
    2010  
     2002                                        {        
     2003                                                                                         
    20112004                                                switch (data[2][k]) 
    2012                                                 { 
     2005                                                {                                                        
    20132006                                                        case 'cc_title': 
    20142007                                                                if (data[3][pos][k].length > 50) 
     
    20222015                                                                } 
    20232016                                                                break; 
    2024  
     2017                                                         
    20252018                                                        case 'cc_short_name': 
    20262019                                                                if (data[3][pos][k].length > (CC_visual == 'table'  ? 50 : 20)) 
     
    20342027                                                                } 
    20352028                                                                break; 
    2036  
     2029                                                         
    20372030                                                        case 'cc_contacts': 
    20382031 
     
    20432036                                                                var email = ""; 
    20442037 
    2045                                                                 for (var d = 0; d < contacts.length; d++) { 
     2038                                                                for (var d = 0; d < contacts.length; d++) {                                                                                                                                                                                                                                                                                                      
    20462039                                                                        contact += contacts[d]['names_ordered']+ ","; 
    20472040                                                                        email += contacts[d]['connection_value']+","; 
    20482041                                                                } 
    2049  
     2042                                                                 
    20502043                                                                Element(id+':cc_participantes').innerHTML = '<span title="Ver Participantes" id="' + id + ':ccQuickAdd" onmouseout="window.status=\'\';" onclick="ccListParticipants.showList(\''+ Element(id+':cc_id').value+'value\', \''+contact+'\', \''+email+'\', \''+title+'\', \''+id_group+'\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img title="Ver participantes" align="center" src="templates/default/images/people-mini.png">&nbsp;&nbsp</span>'; 
    2051  
     2044                                                                                                                                                                         
    20522045                                                                break; 
    2053  
     2046                                                         
    20542047                                                        case 'cc_id': 
    20552048                                                                var id_contact = data[3][pos][k]; 
    20562049                                                                Element(id+':'+data[2][k]).value = data[3][pos][k]; 
    2057  
     2050                                                                                                                         
    20582051                                                                break; 
    2059  
     2052                                                                 
    20602053                                                } 
    20612054                                        } 
    20622055                                } 
    2063  
     2056         
    20642057                                if (--ncards == 0) 
    20652058                                { 
     
    20672060                                        i = CC_max_cards[1]; 
    20682061                                } 
    2069  
     2062         
    20702063                                pos++; 
    20712064                        } 
     
    20962089        }; 
    20972090 
    2098         Connector.newRequest('setMaxCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=set_n_cards&ncards=' + ncards, 'GET'); 
     2091        Connector.newRequest('setMaxCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=set_n_cards&ncards=' + ncards, 'GET');  
    20992092} 
    21002093 
     
    21022095{ 
    21032096        var coord = new Array(); 
    2104  
     2097         
    21052098        //Element('cc_card_space').innerHTML = ''; 
    21062099        //return; 
     
    21092102        //card_space_width = parseInt(is_ie ? document.body.offsetWidth : window.innerWidth) - parseInt(Element('cc_left').offsetWidth) - parseInt(CC_card_extra) - 40; 
    21102103        card_space_height = parseInt(Element('cc_card_space').offsetHeight) - parseInt(CC_card_extra); 
    2111  
     2104         
    21122105        card_width = CC_card_image_width + CC_card_extra; 
    21132106        card_height = CC_card_image_height + CC_card_extra; 
     
    21152108        ncols = parseInt(card_space_width / card_width); 
    21162109        nlines = parseInt(card_space_height / card_height); 
    2117  
     2110         
    21182111        coord[0] = ncols; 
    21192112        //coord[1] = nlines; 
     
    21292122{ 
    21302123                if(type != 'groups') { 
    2131  
     2124                 
    21322125                        html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' + 
    21332126                                '<div style="border: 0px solid #999; position: relative;">' + 
    2134                                         '<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' + 
     2127                                        '<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' +  
    21352128                                                ( ccTree.catalog_perms == 1 ? 
    21362129                                                '<span id="' + id + ':cc_icon_data" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1"></span>':'') + 
     
    21382131                                                '<img title="'+Element('cc_msg_card_edit').value+'" id="' + id + ':cc_card_edit" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1" onclick="editContact(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_edit\',0)" onmouseout="resizeIcon(\''+id+':cc_card_edit\',1)" src="templates/default/images/cc_card_edit.png">' + 
    21392132                                                '<img title="'+Element('cc_msg_card_remove').value+'" id="' + id + ':cc_card_remove" style="position: absolute; top: 78px; left: 223px; width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' : '') + 
    2140                                                 '<img id="' + id + ':cc_photo" style="position: absolute; top: 15px; left: 7px;" src="" border="0" ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' + 
     2133                                                '<img id="' + id + ':cc_photo" style="position: absolute; top: 15px; left: 7px;" src="" border="0" ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' +  
    21412134                                                '<span id="' + id + ':cc_company" style="position: absolute; top: 5px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 14px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_company_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_company_full\').style.visibility=\'hidden\'"></span>' + 
    2142                                                 '<span style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 100px; left: 35px"  valign="bottom" id="' + id + ':cc_icon_group">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>'+ 
    2143                                                 //Para exibir a matricula do empregado nos cartoes 
    2144                                                 '<span id="' + id + ':cc_empNumber" style="position: absolute; top: 15px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></span>' + 
    2145                                                 '<span id="' + id + ':cc_name" style="position: absolute; top: 30px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 10px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_name_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_name_full\').style.visibility=\'hidden\'"></span>' + 
    2146                                                 '<span id="' + id + ':cc_title" style="position: absolute; top: 60px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 12px; text-align: center; height: 10px;"></span>' + 
    2147                                                 //Para exibir o setor/lotacao do empregado nos cartoes 
    2148                                                 '<span id="' + id + ':cc_department" style="position: absolute; top: 70px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' + 
    2149                                                 '<span id="' + id + ':cc_phone" style="position: absolute; top: 90px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' + 
    2150                                                 '<span id="' + id + ':cc_mail" style="position: absolute; top: 105px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' + 
    2151                                                 '<span id="' + id + ':cc_alias" style="position: absolute; top: 95px; left: 10px; width: 60px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></span>' + 
     2135                                                '<span style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 100px; left: 35px"  valign="bottom" id="' + id + ':cc_icon_group">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>'+  
     2136                                                '<span id="' + id + ':cc_name" style="position: absolute; top: 30px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 10px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_name_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_name_full\').style.visibility=\'hidden\'"></span>' +  
     2137                                                '<span id="' + id + ':cc_title" style="position: absolute; top: 60px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 12px; text-align: center; height: 10px;"></span>' +  
     2138                                                '<span id="' + id + ':cc_phone" style="position: absolute; top: 90px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +  
     2139                                                '<span id="' + id + ':cc_mail" style="position: absolute; top: 105px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +  
     2140                                                '<span id="' + id + ':cc_alias" style="position: absolute; top: 95px; left: 10px; width: 60px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></span>' +  
    21522141                                        '<input id="' + id + ':cc_id" type="hidden">' + 
    21532142                                '</div>' + '</td>'; 
    2154  
     2143                 
    21552144                } else { 
    21562145                        html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' + 
    2157             '<div style="border: 0px solid #999; position: relative;">' + 
     2146            '<div style="border: 0px solid #999; position: relative;">' +  
    21582147                                '<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' + 
    21592148                                '<img title="'+Element('cc_msg_group_edit').value+'" id="' + id + ':cc_card_edit" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1" onclick="editGroup(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_edit\',0)" onmouseout="resizeIcon(\''+id+':cc_card_edit\',1)" src="templates/default/images/cc_card_edit.png">' + 
    2160                                 '<img title="'+Element('cc_msg_group_remove').value+'" id="' + id + ':cc_card_remove" style="position: absolute; top: 78px; left: 223px; width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value,\'groups\');" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' + 
     2149                                '<img title="'+Element('cc_msg_group_remove').value+'" id="' + id + ':cc_card_remove" style="position: absolute; top: 78px; left: 223px; width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value,\'groups\');" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' +  
    21612150                                '<span id="' + id + ':cc_title" style="position: absolute; top: 30px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 10px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_name_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_name_full\').style.visibility=\'hidden\'"></span>' + 
    21622151                                '<span id="' + id + ':cc_participantes" style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 15px; left: 15px"></span>' + 
     
    21652154                        '</div>' + '</td>'; 
    21662155                } 
    2167  
     2156         
    21682157 
    21692158        return html_card; 
     
    21772166                        else 
    21782167                                bg = "this.style.background=\'#EEEEEE\'"; 
    2179  
     2168                                                 
    21802169                        if(type != 'groups') { 
    2181  
    2182                                 html_card = '<tr  style="height:20px" id="' + id + '" onmouseout="'+bg+'" onmouseover="this.style.background=\'LIGHTYELLOW\'" bgcolor="EEEEEE">' + 
    2183                                         //Para exibir a matricula do empregado na tabela 
    2184                                         '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_empNumber"></span></td>' + 
    2185                                         '<td width="auto" style="font-weight: normal; font-size: 10px; text-align: left; height: 10px;"><span valign="bottom" id="' + id + ':cc_icon_group">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="' + id + ':cc_name"></span></td>' + 
     2170                         
     2171                                html_card = '<tr  style="height:20px" id="' + id + '" onmouseout="'+bg+'" onmouseover="this.style.background=\'LIGHTYELLOW\'" bgcolor="EEEEEE"><td width="auto" style="font-weight: normal; font-size: 10px; text-align: left; height: 10px;">' +                                        
     2172                                        '<span valign="bottom" id="' + id + ':cc_icon_group">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="' + id + ':cc_name"></span></td>' + 
    21862173                                        '<td style="solid #999; font-weight: normal; font-size: 10px; text-align: left; height: 10px"><span onMouseOver="this.title = \''+Element('cc_send_mail').value+' => '+'\'+document.getElementById(\''+id + ':cc_name\').innerHTML" id="' + id + ':cc_mail"></span></td>' + 
    2187                                         '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_phone"></span></td>' + 
    2188                                         //Para exibir o setor/lotacao do empregado na tabela 
    2189                                         '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_department"></span></td>' + 
    2190 //                                      '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_mobile"></span></td>' + 
    2191                                         '<td style="solid #999; font-weight: normal; font-size: 10px; text-align: left; height: 10px"><span onMouseOver="this.title = \''+Element('cc_send_mail').value+' => '+'\'+document.getElementById(\''+id + ':cc_name\').innerHTML" id="' + id + ':cc_mail"></span></td>' + 
     2174                                        '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_phone"></span></td>' +          
    21922175                                        ( ccTree.catalog_perms == 1 ? 
    21932176                                        '<td align="left"><span valign="bottom" id="' + id + ':cc_icon_data"></span></td>':'') + 
     
    22012184                                        '<span id="' + id + ':cc_title" style="display:none"></span>' + 
    22022185                                        '<span id="' + id + ':cc_alias" style="display:none"></span>' + 
    2203                                         // Esse campo ï¿œ necessï¿œrio se o contato possui dados no campo cc_company 
     2186                                        // Esse campo é necessário se o contato possui dados no campo cc_company 
    22042187                                        '<span id="' + id + ':cc_company" style="display:none"></span>' + 
    22052188                                        '</td></tr>'; 
     
    22142197                                        '&nbsp;&nbsp;|&nbsp;&nbsp;'+ 
    22152198                                        '<img  title="'+Element('cc_msg_group_remove').value+'" id="' + id + ':cc_card_remove" style="width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value,\'groups\');" src="templates/default/images/cc_x.png">'  + 
    2216                                         '<input id="' + id + ':cc_id" type="hidden">'+ 
     2199                                        '<input id="' + id + ':cc_id" type="hidden">'+                                                                           
    22172200                                        '</td></tr>'; 
    22182201                        } 
     
    22242207{ 
    22252208        var pos; 
    2226  
     2209         
    22272210        html_cards = '<div id="divScrollMain" style="overflow:auto;z-index:1"><table width="100%" border="0" cellpadding="0" cellspacing="3">'; 
    2228  
     2211         
    22292212        if (ncards > 0) 
    22302213        { 
     
    22462229                if((ccTree.catalog_perms & 2) && type != 'groups') 
    22472230                        html_cards += '<tr><td colspan=4 align="right"><button id="cc_button_tools" value="" type="button" onclick="javascript:removeAllEntries()">Remover Todos</button></td></tr>'; 
    2248         } 
     2231        }        
    22492232        else if (CC_max_cards != 0) 
    22502233        { 
     
    22662249        html_cards = '<div id="divScrollMain" style="overflow:auto;z-index:1">'; 
    22672250        html_cards += '<table  border="0" cellpadding="0" cellspacing="' + CC_card_extra + '">'; 
    2268  
     2251         
    22692252        if (ncards > 0) 
    22702253        { 
     
    22852268                if((ccTree.catalog_perms & 2) && type != 'groups') 
    22862269                        html_cards += '<tr><td colspan=3 align="right"><button id="cc_button_tools" value="" type="button" onclick="javascript:removeAllEntries()">Remover Todos</button></td></tr>'; 
    2287         } 
     2270        }        
    22882271        else if (CC_max_cards != 0) 
    22892272        { 
     
    23222305                else if(CC_visual == 'table') 
    23232306                        drawTable(0); 
    2324  
     2307                         
    23252308                setPages(0,0); 
    23262309                return; 
     
    23322315                data = unserialize(responseText); 
    23332316                if (data[0] == '0') 
    2334                 { 
    2335                         Element('cc_type_contact').value = data[1]; 
     2317                {                                
     2318                        Element('cc_type_contact').value = data[1];                      
    23362319                        CC_npages = 0; 
    23372320                        CC_actual_page = 1; 
     
    23452328                else 
    23462329                Element('cc_type_contact').value = data[10]; 
    2347  
    2348 //              Element('cc_debug').innerHTML = responseText; 
    2349  
     2330                 
     2331//              Element('cc_debug').innerHTML = responseText;                                            
     2332                 
    23502333                if (typeof(data) != 'object') 
    23512334                { 
     
    23532336                        return; 
    23542337                } 
    2355  
     2338                 
    23562339                if (typeof(data[3]) == 'object') 
    23572340                { 
    23582341                        CC_npages = parseInt(data[0]); 
    2359                         CC_actual_page = parseInt(data[1]); 
     2342                        CC_actual_page = parseInt(data[1]);                      
    23602343                        if(CC_visual == 'cards') 
    23612344                                drawCards(data[3].length, data[10]); 
     
    23652348                        populateCards(data, data[10]); 
    23662349                        setPages(data[0], data[1]); 
    2367  
    2368                 } 
    2369                 else if (data['error']) 
    2370                 { 
    2371                         showMessage(data['error']); 
     2350                         
    23722351                } 
    23732352                else 
     
    23812360        Connector.newRequest('showCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cards_data', 'POST', handler, info); 
    23822361} 
    2383  
    23842362 
    23852363function clearCards() 
     
    24062384        var table_h = Element('cc_panel_table'); 
    24072385        var cards_h = Element('cc_panel_cards'); 
    2408  
     2386         
    24092387        switch (type) 
    24102388        { 
     
    24192397                        break; 
    24202398        } 
    2421  
     2399         
    24222400        CC_visual = type; 
    24232401        showCards(getActualLetter(), getActualPage()); 
    24242402} 
    24252403 
    2426 /*function ccSearchUpdate(ids) 
     2404function ccSearchUpdate(ids) 
    24272405{ 
    24282406        Element('cc_panel_letters').style.display = 'none'; 
    24292407        Element('cc_panel_search').style.display  = 'inline'; 
    2430  
     2408         
    24312409        if(CC_visual == 'cards') 
    24322410                drawCards(0); 
     
    24362414        if (!ids) 
    24372415        { 
    2438                 //ccSearchHide(); 
     2416                ccSearchHide(); 
    24392417                return; 
    24402418        } 
    2441  
     2419         
    24422420        var sIds = serialize(ids); 
    24432421 
     
    24472425        } 
    24482426        showCards('search', '1', sIds); 
    2449 } 
    2450 */ 
    2451  
    2452 function ccSearchUpdate() 
    2453 { 
    2454         Element('cc_panel_letters').style.display = 'none'; 
    2455         Element('cc_panel_search').style.display  = 'inline'; 
    2456  
    2457         if(CC_visual == 'cards') 
    2458                 drawCards(0); 
    2459         else if(CC_visual == 'table') 
    2460                 drawTable(0); 
    2461  
    2462         if (CC_actual_letter != 'search') 
    2463         { 
    2464                 CC_last_letter = CC_actual_letter; 
    2465         } 
    2466         //showCards('search', '1', sIds); 
    24672427} 
    24682428 
     
    25072467        data[3] = Element('cc_qa_phone').value; 
    25082468        data[4] = Element('cc_qa_email').value; 
    2509  
     2469         
    25102470        return data; 
    25112471} 
     
    25142474{ 
    25152475        var data = getQuickAdd(); 
    2516  
     2476         
    25172477        var str = serialize(data); 
    25182478 
     
    25322492} 
    25332493 
    2534          
    25352494function connectVoip (phoneUser, typePhone){ 
    25362495        var handler_voip = function (responseText){ 
  • trunk/contactcenter/js/ccAddGroup.js

    r284 r285  
    158158                 
    159159                if(!this.title.value) { 
    160                         alert('Preencha o campo obrigatório "Nome Completo"'); 
     160                        alert(Element('cc_msg_fill_field_name').value); 
    161161                        this.title.focus(); 
    162162                        return false; 
     
    164164                                 
    165165                if(! contacts.length) { 
    166                         alert('Você não adicionou nenhum contato para esse grupo'); 
     166                        alert(Element('cc_msg_add_contact_to_group').value); 
    167167                        return false; 
    168168                } 
  • trunk/contactcenter/js/ccIEContacts.js

    r284 r285  
    33                this.el;                 
    44                this.wWidth = 395; 
    5                 this.wHeight = 240; 
     5                this.wHeight = 255; 
    66        } 
    77         
     
    1616                }        
    1717        } 
     18         
     19        cIEContacts.prototype.showFailures = function(data){ 
     20                if (data == 'undefined') 
     21                        return; 
     22                if (data){ 
     23                        var lang_clean = Element('cc_msg_clean').value; 
     24                        var info_box = document.getElementById('s_info2'); 
     25                        info_box.innerHTML = data; 
     26                        info_box.style.visibility = ''; 
     27                        var cleanButton = document.createElement('input'); 
     28                        cleanButton.type='button'; 
     29                        cleanButton.value=lang_clean; 
     30                        cleanButton.onclick= function() { ccIEContacts.cleanInfo() }; 
     31                        info_box.appendChild(cleanButton); 
     32                        } 
     33        } 
     34 
     35        cIEContacts.prototype.cleanInfo = function(){ 
     36        var info_box = document.getElementById('s_info2'); 
     37        info_box.innerHTML = ''; 
     38        }        
    1839         
    1940        cIEContacts.prototype.showList = function(){ 
     
    3758                        this.el.id = 'cc_rectIEContacts'; 
    3859                        document.body.appendChild(this.el); 
     60 
     61                        var lang_import_contacts = Element('cc_msg_import_contacts').value; 
     62            var lang_close_win = Element('cc_msg_close_win').value 
     63            var lang_export_contacts = Element('cc_msg_export_contacts').value; 
     64            var lang_expresso_info_csv = Element('cc_msg_expresso_info_csv').value; 
     65            var lang_expresso_default = Element('cc_msg_expresso_default').value; 
     66            var lang_choose_contacts_file       = Element('cc_msg_choose_contacts_file').value; 
     67            var lang_msg_choose_type            = Element('cc_msg_choose_file_type').value; 
     68                        var lang_msg_expresso_info_csv  = Element('cc_msg_expresso_info_csv').value; 
     69                        var lang_msg_export_csv                 = Element('cc_msg_export_csv').value; 
     70                        var lang_msg_automatic = Element('cc_msg_automatic').value; 
     71            var lang_close = Element('cc_msg_close').value; 
     72                        var lang_moz_tb = Element('cc_msg_moz_thunderbird').value; 
     73                        var lang_outl_pt = Element('cc_msg_outlook_express_pt').value; 
     74                        var lang_outl_en = Element('cc_msg_outlook_express_en').value; 
     75                        var lang_outl2k_pt = Element('cc_msg_outlook_2k_pt').value; 
     76                        var lang_outl2k_en = Element('cc_msg_outlook_2k_en').value; 
     77                        var lang_expresso_default_csv = Element('cc_msg_expresso_default_csv').value; 
     78 
     79                 
    3980                        this.el.innerHTML =  
    4081                        '<div align="left" id="divAppbox"><table width="100%" border=0>'+ 
    41                         '<tr><td style="border-bottom:1px solid black"><input onclick="javascript:ccIEContacts.changeOptions(this.value)" id="type" type="radio" name="type" value="i" style="border:0" checked>Importar Contatos'+ 
    42                         '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="javascript:ccIEContacts.changeOptions(this.value)" id="type" type="radio" name="type" style="border:0" value="e"/>Exportar Contatos<br></td></tr>'+ 
     82                        '<tr><td style="border-bottom:1px solid black"><input onclick="javascript:ccIEContacts.changeOptions(this.value)" id="type" type="radio" name="type" value="i" style="border:0" checked>'+lang_import_contacts+ 
     83                        '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="javascript:ccIEContacts.changeOptions(this.value)" id="type" type="radio" name="type" style="border:0" value="e"/>'+lang_export_contacts+' <br></td></tr>'+ 
    4384                        '</table>'+ 
    4485                        '<table border=0 height="208px"  width="100%" id="import_span">'+ 
    4586                        '<tr><td>'+ 
    46                         '<font color="DARKBLUE" size="2">O Expresso suporta a importação de contatos no formato de arquivo CSV.</font></td></tr>'+ 
     87                        '<font color="DARKBLUE" size="2">'+lang_expresso_info_csv+'</font></td></tr>'+ 
    4788                        '<tr><td height="75px" valign="top">'+ 
    48                         '<form name="formCSV" method="POST" enctype="multipart/form-data">'+                                                                             
    49                         'Selecione o tipo do arquivo:&nbsp;<select id="typeImport">'+ 
    50                         '<option value="outlook">Outlook Express</option>'+ 
    51                         '<option value="outlook2000">Outlook 2000</option>'+ 
    52                         '<option value="thunderbird">Mozilla Thunderbird</option>'+ 
    53                         '<option value="expresso" selected>Expresso (padrão)</option></select><br>'+ 
    54                         '<br>Selecione o arquivo que contém os contatos a serem importados:<br><br>'+                    
     89                        '<form name="formCSV" method="POST" enctype="multipart/form-data">'+ lang_msg_choose_type + 
     90                        ':&nbsp;<select id="typeImport"><option value="auto" selected>'+lang_msg_automatic+'</option>'+ 
     91                        '<option value="outlook">'+("Outlook Express")+'</option>'+ 
     92                        '<option value="outlook2000">'+("Outlook 2000")+'</option>'+ 
     93                        '<option value="thunderbird">'+("Mozilla Thunderbird")+'</option>'+ 
     94                        '<option value="expresso" selected>'+lang_expresso_default+'</option></select><br>'+ 
     95                        '<br>'+lang_choose_contacts_file+'<br><br>'+                     
    5596                        '<input id="import_file" type="file" name="import_file">'+ 
    5697                        '</form></td></tr>'+ 
    5798                        '<tr><td height="10px" align="center" nowrap><span style="visibility:hidden" id="s_info"></span></td></tr>'+ 
    5899                        '<tr><td height="10px" align="center"></td></tr>'+ 
    59                         '<tr><td nowrap><center><input id="import_button" type="button" value="Importar Contatos" onClick="javascript:ccIEContacts.importCSV(this)">&nbsp;&nbsp;&nbsp;&nbsp;'+ 
    60                         '<input type="button" value="Fechar" onClick="javascript:ccIEContacts.close()"></center></td></tr>'+ 
    61                         '</table>'+ 
     100                        '<tr><td nowrap><center><input id="import_button" type="button" value='+lang_import_contacts+' onClick="javascript:ccIEContacts.importCSV(this)">&nbsp;&nbsp;&nbsp;&nbsp;'+ 
     101                        '<input type="button" value='+lang_close_win+' onClick="javascript:ccIEContacts.close()"></center></td></tr>'+ 
     102                        '<tr><td height="10px" align="center" nowrap><span style="visibility:hidden" id="s_info2"></span></td></tr></table>'+ 
    62103                        '<table border=0  height="208px"  width="100%" style="display:none" id="export_span">'+ 
    63104                        '<tr><td>'+                                              
    64                         '<font color="DARKBLUE" size="2">O Expresso suporta a exportação de contatos no formato de arquivo CSV.</font></td></tr>'+ 
    65                         '<tr><td height="85px" valign="top">'+                                           
    66                         'Selecione o tipo do formato que deseja exportar seus contatos:<br><br>'+ 
    67                         '<input style="border:0" id="typeExport_0" name="radio" type="radio" value="expresso" checked/>Exportar como CSV do Expresso (padrão)<br>'+ 
    68                         '<input style="border:0" id="typeExport_1" name="radio" type="radio" value="outlook_pt-BR">Exportar como CSV do Outlook Express (Português)<br>'+ 
    69                         '<input style="border:0" id="typeExport_2" name="radio" type="radio" value="outlook_en">Exportar como CSV do Outlook Express (Inglês)<br>'+ 
    70                         '<input style="border:0" id="typeExport_3" name="radio" type="radio" value="outlook2000_pt-BR">Exportar como CSV do Outlook 2000 (Português)<br>'+ 
    71                         '<input style="border:0" id="typeExport_4" name="radio" type="radio" value="outlook2000_en">Exportar como CSV do Outlook 2000 (Inglês)<br>'+ 
    72                         '<input style="border:0" id="typeExport_5" name="radio" type="radio" value="thunderbird">Exportar como CSV do Mozilla Thunderbird<br>'+ 
     105                        '<font color="DARKBLUE" size="2">'+ lang_msg_expresso_info_csv+'</font></td></tr>'+ 
     106                        '<tr><td height="85px" valign="top">'+lang_msg_export_csv+'<br><br>'+ 
     107                        '<select id="typeExport">'+ 
     108                        '<option value="expresso" selected>'+lang_expresso_default_csv+'</option>'+ 
     109                        '<option value="outlook_pt-BR">'+lang_outl_pt+'</option>'+ 
     110                        '<option value="outlook_en">'+lang_outl_en+'</option>'+ 
     111                        '<option value="outlook2000_pt-BR">'+lang_outl2k_pt+'</option>'+ 
     112                        '<option value="outlook2000_en">'+lang_outl2k_en+'</option>'+ 
     113                        '<option value="thunderbird">'+lang_moz_tb+'</option>'+ 
     114                        '</select>'+                     
    73115                        '</td></tr>'+ 
    74116                        '<tr><td align="center">&nbsp;</td></tr>'+ 
    75                         '<tr><td nowrap><center><input id="export_button" type="button" value="Exportar Contatos" onClick="javascript:ccIEContacts.exportCSV(this)">&nbsp;&nbsp;&nbsp;&nbsp;'+ 
    76                         '<input type="button" value="Fechar" onClick="javascript:ccIEContacts.close()"></center></td></tr>'+ 
     117                        '<tr><td nowrap><center><input id="export_button" type="button" value='+lang_export_contacts+ ' onClick="javascript:ccIEContacts.exportCSV(this)">&nbsp;&nbsp;&nbsp;&nbsp;'+ 
     118                        '<input type="button" value='+lang_close_win+ ' onClick="javascript:ccIEContacts.close()"></center></td></tr>'+ 
    77119                        '</table></div>'; 
    78120                }                
    79121                this.showWindow(); 
    80122        } 
    81                  
     123         
    82124        cIEContacts.prototype.showWindow = function () 
    83125        {                                                
    84126                if(!this.win) { 
    85  
    86                         this.win = new dJSWin({                  
     127         
     128                                this.win = new dJSWin({                  
    87129                                id: 'ccIEContacts', 
    88130                                content_id: this.el.id, 
     
    91133                                title_color: '#3978d6', 
    92134                                bg_color: '#eee', 
    93                                 title: "Importar / Exportar Contatos Pessoais",                                          
     135                                title: Element('cc_msg_ie_personal').value,  
    94136                                title_text_color: 'white', 
    95137                                button_x_img: '../phpgwapi/images/winclose.gif', 
     
    112154                var status = ''; 
    113155 
    114                 var l_1         = '<font face="Verdana" size="1" color="GREEN">['+args[1]+' novos]</font>'; 
    115                 var l_2         = '<font face="Verdana" size="1" color="RED">['+args[2]+' falharam]</font>'; 
    116                 var l_3         = '<font face="Verdana" size="1" color="DARKBLUE">['+args[3]+' já existiam]</font>'; 
    117                 var l_error     = '<span style="height:15px;background:#cc4444">&nbsp;&nbsp;<font face="Verdana" size="1" color="WHITE">A importação falhou. Verifique o formato do arquivo.&nbsp;</font></span>'; 
    118                 var l_importing = '<span style="height:15px;background:rgb(250, 209, 99)">&nbsp;&nbsp;<font face="Verdana" size="1" color="DARKBLUE">Importando contatos ....&nbsp;</font></span>'; 
     156                var lang_import_fail = Element('cc_msg_import_fail').value; 
     157                var lang_importing = Element('cc_msg_importing_contacts').value; 
     158                var lang_import_finish = Element('cc_msg_import_finished').value; 
     159                var lang_new = Element('cc_msg_new').value; 
     160                var lang_failure = Element('cc_msg_failure').value; 
     161                var lang_exists = Element('cc_msg_exists').value; 
     162                var lang_show_more_info = Element('cc_msg_show_more_info').value; 
     163 
     164                var l_1         = '<font face="Verdana" size="1" color="GREEN">['+args[1]+lang_new+']</font>'; 
     165                var l_2         = '<font face="Verdana" size="1" color="RED">['+args[2]+lang_failure+']</font>'; 
     166                var l_3         = '<font face="Verdana" size="1" color="DARKBLUE">['+args[3]+lang_exists+']</font>'; 
     167                var l_4         = '<br><a font face="Verdana" size="1" href="javascript:ccIEContacts.showFailures(\''+args[4]+'\')">'+lang_show_more_info+'</a>'; 
     168                var l_error     = '<span style="height:15px;background:#cc4444">&nbsp;&nbsp;<font face="Verdana" size="1" color="WHITE">'+lang_import_fail+ '&nbsp;</font></span>'; 
     169                var l_importing = '<span style="height:15px;background:rgb(250, 209, 99)">&nbsp;&nbsp;<font face="Verdana" size="1" color="DARKBLUE">'+lang_importing + '&nbsp;</font></span>'; 
    119170 
    120171                if(args[0] == 'success') { 
    121172 
    122                         for(i = 1; i < 4; i++) { 
     173                        for(i = 1; i < 5; i++) { 
    123174                                status += "&nbsp;"+eval('l_'+i); 
    124175                        } 
    125                         Element('s_info').innerHTML = '&nbsp;&nbsp;<font face="Verdana" size="1" color="BLACK"><b>A importação foi concluída.</b></font><br>&nbsp;'+status; 
     176                        Element('s_info').innerHTML = '&nbsp;&nbsp;<font face="Verdana" size="1" color="BLACK"><b>'+lang_import_finish+'</b></font><br>&nbsp;'+status; 
    126177                } 
    127178                else  
     
    148199        cIEContacts.prototype.importCSV = function () 
    149200        {                
     201                var lang_msg_invalid_csv = Element('cc_msg_invalid_csv').value; 
    150202                var form = document.formCSV; 
    151                  
    152203                if ((form.import_file.value.length < 10) ||  
    153                 (form.import_file.value.substring(form.import_file.value.length - 4, form.import_file.value.length) != ".csv")){ 
    154                         alert('Selecione um arquivo CSV válido para importar seus contatos.'); 
     204                (form.import_file.value.substring(form.import_file.value.length - 4, form.import_file.value.length).toLowerCase() != ".csv")){ 
     205                        alert(lang_msg_invalid_csv); 
    155206                        return; 
    156207                } 
     
    170221                                args[2] = data._failure ? data._failure : 0; 
    171222                                args[3] = data._existing ? data._existing : 0; 
     223                                args[4] = data._failure_status 
     224 
    172225                        } 
    173226                        _this.importWriteStatus(args); 
     
    208261         
    209262        cIEContacts.prototype.exportCSV = function() { 
    210  
     263                var lang_export_error = Element('cc_msg_export_error'); 
    211264                var handler_export = function(data) { 
    212265                        if(!data){ 
    213                                 alert("Ocorreu um erro durante a exportação."); 
     266                                alert(lang_export_error ); 
    214267                                return; 
    215268                        }                                
     
    226279                }                
    227280                var typeExport = Element("typeExport"); 
    228  
    229                 for(var index = 0; index < 5; index++){ 
    230                         if(Element('typeExport_'+index).checked) 
    231                                 break; 
    232                 } 
    233  
    234281                Element('export_button').disabled = true; 
    235                 Connector.newRequest('export_contacts', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=export_contacts', 'POST', handler_export, 'typeExport='+Element('typeExport_'+index).value); 
     282                Connector.newRequest('export_contacts', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=export_contacts', 'POST', handler_export, 'typeExport='+typeExport.value); 
    236283        } 
    237284 
  • trunk/contactcenter/js/ccMain.js

    r284 r285  
    1 var last_id = 0; 
    2  
    3 function openwindow(url){ 
    4         var window_features =   "scrollbars=yes,resizable=yes,location=no,menubar=no," + 
    5                                                 "personalbar=no,status=no,titlebar=no,toolbar=no," + 
    6                                                 "screenX=0,screenY=0,top=0,left=0,width=" + 
    7                                                 screen.width + ",height=" + screen.height/5*3; 
    8  
    9         window.open(url,'', window_features); 
     1var last_id = 0;         
     2 
     3function openwindow(url){        
     4        var window_features =   "scrollbars=yes,resizable=yes,location=no,menubar=no," +  
     5                                                "personalbar=no,status=no,titlebar=no,toolbar=no," +  
     6                                                "screenX=0,screenY=0,top=0,left=0,width=" +  
     7                                                screen.width + ",height=" + screen.height/5*3;  
     8                         
     9        window.open(url,'', window_features);  
    1010} 
    1111 
    1212var Main_pre_load = document.body.onload; 
    1313var ccSearch, ccTree; 
    14 var Main_load = function () 
    15         { 
     14var Main_load = function ()  
     15        {        
    1616                Connector.setProgressBox(Element('cc_loading'), true); 
    17                 Connector.setProgressHolder(Element('cc_loading_inner')); 
     17                Connector.setProgressHolder(Element('cc_loading_inner'));                
    1818                /* Associate the Quick Add Button with the Plugin */ 
    19  
     19                                         
    2020 
    2121                /* Create the Search Object */ 
     
    3737                ccSearch.DOMresult.style.visibility = 'hidden'; 
    3838                ccSearch.onSearchFinish = ccSearchUpdate; 
    39  
     39                         
    4040                Connector.setProgressBox(Element('cc_loading'), true); 
    4141                Connector.setProgressHolder(Element('cc_loading_inner')); 
    4242 
    43                 /* Create the Tree Object */ 
     43                try 
     44                { 
     45                        function ViewLdap(data) 
     46                        { 
     47                                if( boolData = eval(data) ) 
     48                                { 
     49                                        ccTree = new ccCatalogTree({name: 'ccTree', id_destination: 'cc_tree', afterSetCatalog: 'ccSearchHidePanel(); updateCards()'}); 
     50                                        showCards('all',getActualPage()); 
     51                                        selectLetter('27'); 
     52                                }        
     53                                else 
     54                                { 
     55                                        ccTree = new ccCatalogTree({name: 'ccTree', id_destination: 'cc_tree', afterSetCatalog: 'ccSearchHidePanel(); clearCards();'}); 
     56                                } 
     57                        } 
     58 
     59                        Connector.newRequest('ViewLdap', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_visible_all_ldap', 'POST', ViewLdap);            
     60                         
     61                        ccTree.Connector = Connector;                                            
     62                } 
     63                catch(e){} 
     64 
     65                /* Create the Tree Object */                     
    4466                //ccTree = new ccCatalogTree({name: 'ccTree', id_destination: 'cc_tree', afterSetCatalog: 'ccSearchHidePanel(); updateCards()'}); 
    45                 ccTree = new ccCatalogTree({name: 'ccTree', id_destination: 'cc_tree', afterSetCatalog: 'ccSearchHidePanel(); clearCards();'}); 
    46  
    47                 ccTree.Connector = Connector; 
     67                //ccTree.Connector = Connector;                                          
    4868        } 
    4969        var menuStarted = false; 
     
    6585        var _timeout = ''; 
    6686        var menu = function () { 
    67  
     87                  
    6888         if(! this.menuStarted) 
    6989                this.menuStarted = true; 
    70  
     90                 
    7191                submenu = []; 
    7292                textmenu = []; 
    73  
     93                         
    7494                textmenu[0] = ["cc_msg_contact_qa","cc_msg_contact_full","cc_msg_group"] 
    75                 textmenu[1] = ["cc_quick_add", "cc_full_add", "cc_add_group"]; 
     95                textmenu[1] = ["cc_quick_add", "cc_full_add", "cc_add_group"];           
    7696                function show(){ 
    7797                        clearTimeout(_timeout); 
    7898                        button = document.getElementById("cc_button_new"); 
    79  
    80                         this.style.top = 19 + findPosY(button) + "px"; 
    81                         this.style.visibility='visible'; 
     99                                 
     100                        this.style.top = 19 + findPosY(button) + "px";  
     101                        this.style.visibility='visible';  
    82102                } 
    83103                function hide(){ _timeout = setTimeout("menu.style.visibility='hidden';",200); }; 
    84  
     104                         
    85105                if(document.getElementById) { 
    86106                        menu = document.getElementById("Layer1"); 
    87  
     107                                 
    88108                        for (i=0; i< textmenu[0].length; i++) { 
    89109                                textmenu[0][i] = "<span onclick= 'menu.onmouseout();'>" + document.getElementById(textmenu[0][i]).value + "</span><br>"; 
    90                                 submenu[i] = document.createElement("DIV"); 
     110                                submenu[i] = document.createElement("DIV");                              
    91111                                submenu[i].innerHTML = textmenu[0][i]; 
    92112                                submenu[i].id = textmenu[1][i]; 
    93113                                submenu[i].onmouseover = function () {this.style.backgroundColor = 'LIGHTYELLOW';this.style.color = 'DARKBLUE';}; 
    94                                 submenu[i].onmouseout   = function () {  this.style.backgroundColor = '#DCDCDC'; this.style.color = '#006699';}; 
     114                                submenu[i].onmouseout   = function () {  this.style.backgroundColor = '#DCDCDC'; this.style.color = '#006699';};                                         
    95115                                submenu[i].setAttribute("className", "special"); 
    96116                                submenu[i].setAttribute("class", "special"); 
    97                                 submenu[i].style.padding = "5px"; 
     117                                submenu[i].style.padding = "5px";                                          
    98118                                menu.appendChild(submenu[i]); 
    99                         } 
    100  
     119                        }                        
     120                                 
    101121                        menu.onmouseover = show; 
    102122                        menu.onmouseout = hide; 
    103123                } 
    104  
     124                         
    105125                ccQuickAdd.associateAsButton(Element('cc_quick_add')); 
    106126                ccAddGroup.associateAsButton(Element('cc_add_group')); 
    107127                document.getElementById("cc_full_add").onclick= newContact; 
    108  
    109  
     128                          
     129                         
    110130                ccQuickAdd.afterSave = function () 
    111131                { 
    112132                        updateCards(); 
    113                 } 
    114  
    115                 ccAddGroup.load = function () 
    116                 { 
    117                         editGroup(); 
    118                 } 
    119  
     133                }                        
     134                         
     135                ccAddGroup.load = function ()  
     136                {                                
     137                        editGroup();                     
     138                } 
     139                         
    120140                ccAddGroup.afterSave = function () 
    121141                { 
    122142                        updateCards(); 
    123143                } 
    124  
     144                         
    125145                return true; 
    126146        } 
     
    128148        if (is_ie) 
    129149        { 
    130  
     150                         
    131151                document.body.onload = function (e) 
    132                 { 
    133                         Main_pre_load(); 
    134                         Main_load(); 
    135  
     152                {                        
     153                        Main_pre_load();                                                                 
     154                        Main_load();                                     
     155                                                                 
    136156                } 
    137157        } 
    138158        else 
    139         { 
    140                 Main_load(); 
    141  
    142         } 
     159        {                
     160                Main_load();     
     161                         
     162        }        
    143163 
    144164// BEGIN: FUNCTION RESIZE WINDOW 
     
    157177showBar = __showBar; 
    158178hideBar = __hideBar; 
    159  
     179         
    160180var _onResize   = window.onresize; 
    161181window.onresize = resizeWindow; 
    162182var defaultHeight = 0; 
    163183function setDefaultHeight(){ 
    164  
     184         
    165185        var bar = Element("toolbar"); 
    166186        var offset = 0; 
    167         if(bar.style.visibility != 'hidden') 
    168                 offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight); 
     187        if(bar.style.visibility != 'hidden')  
     188                offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight);      
    169189 
    170190        var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight; 
    171         defaultHeight = screenHeight - offset; 
    172         Element("cc_tree").style.height                 = defaultHeight - 68; 
    173         Element("cc_left_main").style.height    = defaultHeight - 68; 
     191        defaultHeight = screenHeight - offset;   
     192        Element("cc_tree").style.height                 = defaultHeight - 68;    
     193        Element("cc_left_main").style.height    = defaultHeight - 68;    
    174194} 
    175195 
     
    177197        setDefaultHeight(); 
    178198        if(Element("divScrollMain")) 
    179                 Element("divScrollMain").style.height   = defaultHeight - 108; 
     199                Element("divScrollMain").style.height   = defaultHeight - 108;   
    180200        if (!is_ie) 
    181201                Element('tableDivAppbox').width = '100%'; 
     
    185205setDefaultHeight(); 
    186206Element('cc_main').style.height = defaultHeight; 
     207var lang_warn_firefox = Element('cc_msg_warn_firefox'); 
     208var lang_firefox_msg1 = Element('cc_msg_firefox_half1'); 
     209var lang_firefox_msg2 = Element('cc_msg_firefox_half2'); 
     210var lang_install_now = Element('cc_msg_install_now'); 
     211var lang_install_new_firefox = Element('cc_msg_install_new_firefox'); 
     212var lang_close = Element('cc_msg_close'); 
    187213function buildWarningMsg(_version) { 
    188214        var screenWidth = document.body.clientWidth ? document.body.clientWidth: document.body.offsetWidth; 
     
    191217        "border:1px solid black;left:"+(screenWidth - 330)+";top:10px;width:300px;padding:10px;"+ 
    192218        (document.body.clientWidth ? "-moz-border-radius: 9px 9px 9px 9px;'>" : "")+ 
    193         "<font color='RED' size='2'>Aviso: Versão muito antiga do Firefox ("+_version+")</font><BR>"+ 
    194         "<font color='black' size='2'><p style='text-align:justify'>&nbsp;Para que essa aplicação funcione <u>corretamente</u> "+ 
    195         "é necessário atualizar o seu navegador Firefox para uma versão mais nova (versão > 1.5). "+ 
    196         "Instale agora clicando no link abaixo ou caso queira atualizar mais tarde (não recomendável), clique em Fechar.</p></font><div style='width:100%' align='center'>"+ 
    197         "<a title='Instalar agora' href='http://br.mozdev.org/firefox/download.html' target='_blank'>Instalar nova versão do Firefox</a>"+ 
     219            "<font color='RED' size='2'>"+lang_warn_firefox +  "("+_version+")</font><BR>"+ 
     220            "<font color='black' size='2'><p style='text-align:justify'>&nbsp;"+lang_firefox_msg1+ 
     221            lang_firefox_msg2 + ".</p></font><div style='width:100%' align='center'>"+ 
     222            "<a title='"+lang_install_now+"' href='http://br.mozdev.org/firefox/download.html' target='_blank'>"+lang_install_new_firefox+ "</a>"+       
    198223        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ 
    199         "<a title='Fechar' href='javascript:void(0)' onclick='javascript:myOpacity.toggle()'>Fechar</a></div>"+ 
     224            "<a title='"+lang_close+"' href='javascript:void(0)' onclick='javascript:myOpacity.toggle()'>"+lang_close+"</a></div>"+ 
     225 
    200226        "</DIV>"; 
    201227 
     
    203229 
    204230        myOpacity = new fx.Opacity('warning_msg', {duration: 600}); 
    205         document.getElementById("warning_msg").style.visibility = 'hidden'; 
     231        document.getElementById("warning_msg").style.visibility = 'hidden';              
    206232        myOpacity.now = 0; 
    207233        setTimeout("myOpacity.toggle()",3000); 
  • trunk/contactcenter/js/ccQuickAddContact.js

    r284 r285  
    66        } 
    77 
    8  
     8         
    99        cQuickAddContact.prototype.showList = function(id){ 
    1010                _this = this; 
    1111                var handler = function (responseText) { 
    1212                        var contacts = unserialize(responseText); 
    13                         var title = contacts['names_ordered']; 
    14                         el = document.createElement("DIV"); 
    15                         el.style.visibility = "hidden"; 
     13                        var title = contacts['names_ordered'];                   
     14                        el = document.createElement("DIV");                                                                      
     15                        el.style.visibility = "hidden";                                                                  
    1616                        el.style.position = "absolute"; 
    1717                        el.style.left = "0px"; 
     
    2121                        el.style.height = wHeight + 'px'; 
    2222                        el.className = "div_cc_rectQuickAddContact"; 
    23                         el.id = id+':cc_rectQuickAddContact'; 
    24                         document.body.appendChild(el); 
    25                         el.innerHTML = ""; 
     23                        el.id = id+':cc_rectQuickAddContact';                                                                                                                                                                                    
     24                        document.body.appendChild(el);                                                                                                                           
     25                        el.innerHTML = "";                                                               
    2626 
    2727                        var fieldsTop = 10; 
    2828                        var fieldsSpace = 30; 
    2929                        fields = new Array(Element('cc_qa_alias').value, Element('cc_qa_given_names').value, Element('cc_qa_family_names').value, Element('cc_qa_phone').value, Element('cc_qa_email').value); 
    30  
     30                         
    3131                        for (i=0; i<fields.length; i++) { 
    3232                                var contact = contacts[i] != null ? contacts[i] : ''; 
     
    4343                                { 
    4444                                        el.innerHTML += '<input id="ccQuickAddCI' + i + id + '" type="text" value="' + contact + '" maxlength="50" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 110px; width: 135px;">'; 
    45                                 } 
     45                                }                                
    4646                        } 
    47  
     47                         
    4848                        el.innerHTML +='<div id="ccQAFuncitons" style="border: 0px solid black; width: 220px; height: 20px">' + 
    49                                 '<input title="ccQASave" type="button" onclick="ccQuickAddContact.send(\'' + id + '\');" value="' + Element('cc_qa_save').value + '" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 75px; width: 60px" />' + 
    50                                 '<input title="ccQAClear" type="button" onclick="ccQuickAddContact.fechar(\'' + id + '\');" value="' + Element('cc_qa_clear').value + '" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 140px; width: 60px" />' + 
     49                                '<input title="' + Element('cc_qa_save').value + '" type="button" onclick="ccQuickAddContact.send(\'' + id + '\');" value="' + Element('cc_qa_save').value + '" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 75px; width: 60px" />' + 
     50                                '<input title="' + Element('cc_qa_close').value + '" type="button" onclick="ccQuickAddContact.fechar(\'' + id + '\');" value="' + Element('cc_qa_close').value + '" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 140px; width: 60px" />' + 
    5151                                '</div>'; 
    5252                        el.innerHTML += "<br>"; 
    53  
     53                                                                 
    5454                        _this.showWindow(el); 
    5555                } 
    56  
     56                 
    5757                div = document.getElementById(id+':cc_rectQuickAddContact'); 
    58  
     58                                 
    5959                if(div) 
    6060                        this.showWindow(div); 
     
    6363                } 
    6464        } 
    65  
     65         
    6666        cQuickAddContact.prototype.showWindow = function (div) 
    67         { 
     67        {                                                
    6868                if(! this.arrayWin[div.id]) { 
    6969 
    70                         win = new dJSWin({ 
     70                        win = new dJSWin({                       
    7171                                id: 'ccQuickAddContact_'+div.id, 
    7272                                content_id: div.id, 
     
    7575                                title_color: '#3978d6', 
    7676                                bg_color: '#eee', 
    77                                 title: Element('ccQATitle').value, 
     77                                title: Element('ccQATitle').value,                                               
    7878                                title_text_color: 'white', 
    7979                                button_x_img: Element('cc_phpgw_img_dir').value+'/winclose.gif', 
    8080                                border: true }); 
    81  
     81                         
    8282                        this.arrayWin[div.id] = win; 
    83                         win.draw(); 
     83                        win.draw();                      
    8484                } 
    8585                else { 
    8686                        win = this.arrayWin[div.id]; 
    87                 } 
     87                }                        
    8888                win.open(); 
    8989        } 
    90  
     90         
    9191        cQuickAddContact.prototype.send = function (id) 
    9292        { 
     
    115115                                return; 
    116116                        } 
    117  
     117                         
    118118                        win.close(); 
    119119 
     
    132132                        } 
    133133                } 
    134  
     134         
    135135                var sdata = new Array(); 
    136  
     136                 
    137137                for (var f = 0; f < 5; f++){ 
    138138                        sdata[f] = document.getElementById('ccQuickAddCI' + f + id).value; 
    139139                } 
    140  
     140                 
    141141                //Utiliza expressão regular para validar email 
    142142                var reEmail = /^[A-Za-z\d_-]+(\.[A-Za-z\d_-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/; 
     
    147147                        return false; 
    148148                } 
    149  
     149                 
    150150                //Utiliza expressão regular para validar telefone 
    151151                var rePhone = /^[0-9|(-)| |-]{0,15}$/; 
    152  
     152                 
    153153                if (!rePhone.test(sdata[3])){ 
    154154                        alert("O número de telefone '" + sdata[3] + "' não é valido! Utilize apenas números.\n" + 
    155155                        "Parenteses, traços ou espaços em branco podem ser usados como carácter separador."); 
    156156                        return false; 
    157                 } 
    158  
     157                }  
     158                 
    159159                var sdata = 'add='+escape(serialize(sdata)); 
    160160 
    161161                Connector.newRequest('cQuickAdd.Send', CC_url+'quick_add', 'POST', handler, sdata); 
    162162        } 
    163  
     163         
    164164        cQuickAddContact.prototype.fechar = function(id) { 
    165  
     165         
    166166                div = document.getElementById(id+':cc_rectQuickAddContact'); 
    167167                win = this.arrayWin[div.id]; 
    168168                win.close(); 
    169169        } 
    170  
    171  
     170         
     171         
    172172/* Build the Object */ 
    173173        var ccQuickAddContact ; 
     
    175175 
    176176        if (is_ie) 
    177         { 
    178                 document.body.onload = function (e) 
    179                 { 
     177        {  
     178                document.body.onload = function (e)  
     179                {  
    180180                        cQuickAddContact_pre_load(); 
    181181                        ccQuickAddContact = new cQuickAddContact(); 
    182  
     182                         
    183183                }; 
    184184        } 
  • trunk/contactcenter/js/cc_search.js

    r284 r285  
    6060                this.DOMinput.value = params['value'] ? params['value'] : ''; 
    6161                this.DOMinput.style.width = params['input_width'] ? params['input_width'] : '200px'; 
    62                 this.DOMinput.onkeypress = function (e) { 
     62                this.DOMinput.onkeypress = function (e) {  
    6363                                if (is_ie) 
    6464                                { 
     
    8686                if (params['progress_color']) 
    8787                        this.DOMprogHold.style.color = params['progress_color']; 
    88  
     88                 
    8989                this.DOMresult.style.position = 'absolute'; 
    9090                this.DOMresult.style.top = params['progress_top'] ? params['progress_top'] : '0px'; 
     
    9696                        this.DOMresult.style.color = params['progress_color']; 
    9797 
    98                 this.DOMholder.appendChild(this.DOMdiv); 
     98                this.DOMholder.appendChild(this.DOMdiv);         
    9999                this.DOMdiv.appendChild(this.DOMfields); 
    100100                this.DOMdiv.appendChild(this.DOMinput); 
     
    104104                this.DOMdiv.appendChild(this.DOMresult); 
    105105        } 
    106  
     106         
    107107        ccSearchClass.prototype.go = function() 
    108108        { 
    109109                var data = new Array(); 
    110  
     110                 
    111111                this.DOMresult.innerHTML = ''; 
    112112 
    113113                //TODO: Make Generic! 
    114114                var type = Element('cc_type_contact').value; 
    115  
     115                 
    116116                data['fields']           = new Array(); 
    117  
     117                 
    118118                if (type == 'groups') { 
    119                         data['fields']['id']     = 'group.id_group'; 
     119                        data['fields']['id']     = 'group.id_group';                     
    120120                        data['fields']['search'] = 'group.title'; 
    121                 } 
    122                 else { 
    123                         data['fields']['id']     = 'contact.id_contact'; 
    124                         data['fields']['search'] = 'contact.names_ordered'; 
    125                 } 
    126  
     121                }                
     122                else {                   
     123                        data['fields']['id']     = 'contact.id_contact';                 
     124                        data['fields']['search'] = 'contact.names_ordered';                                      
     125                } 
     126                 
    127127                data['search_for']       = this.DOMinput.value; 
    128                 //data['recursive']        = this.recursive.checked ? true : false; 
    129                 // Exige que a consulta por nome seja feita com no mínimo 4 caracteres 
    130128                var search_for = data['search_for'].split(' '); 
    131129                var greaterThan4 = false; 
     
    145143 
    146144                var _this = this; 
    147  
    148         var handler = function (responseText) 
    149         { 
    150                 var data = new Array(); 
    151                 data = unserialize(responseText); 
    152  
    153                 ccSearchUpdate(); 
    154  
    155                 letter = 'search'; 
    156  
    157                 if ( letter != CC_actual_letter ) 
    158                 { 
    159                         CC_actual_page = '1'; 
    160                 } 
    161                 else 
    162                 { 
    163                         CC_actual_page = parseInt(data[1]); 
    164                 } 
    165  
    166                 CC_actual_letter = letter; 
    167  
    168                 if (CC_max_cards[0] == 0) 
    169                 { 
    170  
    171                         if(CC_visual == 'cards') 
    172                                 drawCards(0); 
    173                         else if(CC_visual == 'table') 
    174                                 drawTable(0); 
    175  
    176                         setPages(0,0); 
    177                         return; 
    178                 } 
    179  
    180                 if (data[0] == '0') 
    181                 { 
    182                         Element('cc_type_contact').value = data[1]; 
    183                         CC_npages = 0; 
    184                         CC_actual_page = 1; 
    185                         if(CC_visual == 'cards') 
    186                                 drawCards(0); 
    187                         else if(CC_visual == 'table') 
    188                                 drawTable(0); 
    189                         setPages(0,0); 
    190                         return; 
    191                 } 
    192                 else 
    193                 { 
    194                         Element('cc_type_contact').value = data[10]; 
    195                 } 
    196  
    197 //              Element('cc_debug').innerHTML = responseText; 
    198  
    199                 if (typeof(data) != 'object') 
    200                 { 
    201                         showMessage(Element('cc_msg_err_contacting_server').value); 
    202                         return; 
    203                 } 
    204  
    205                 if (typeof(data[3]) == 'object') 
    206                 { 
    207                         CC_npages = parseInt(data[0]); 
    208                         CC_actual_page = parseInt(data[1]); 
    209                         if(CC_visual == 'cards') 
    210                                 drawCards(data[3].length, data[10]); 
    211                         else if(CC_visual == 'table') 
    212                                 drawTable(data[3].length, data[10]); 
    213                         resizeWindow(); 
    214                         populateCards(data, data[10]); 
    215                         setPages(data[0], data[1]); 
    216                 } 
    217                 else if (data['error']) 
    218                 { 
    219                         showMessage(data['error']); 
    220                 } 
    221                 else 
    222                 { 
    223                         showMessage(Element('cc_msg_err_contacting_server').value); 
    224                         return; 
    225                 } 
    226  
    227  
    228         }; 
    229  
    230  
    231 /* 
     145                 
    232146                var handler = function (responseText) 
    233147                { 
    234                         Element('cc_debug').innerHTML = responseText; 
    235  
    236                         var data = unserialize(responseText); 
    237  
    238                         if (!data || !data['status']) 
     148                        var data = new Array(); 
     149                        data = unserialize(responseText); 
     150                         
     151                        if( !data ) 
     152                                return false; 
     153 
     154                        if( data[0] == 0 ) 
     155                        { 
     156                                if (_this.onSearchFinish) 
     157                                        _this.onSearchFinish(null); 
     158                                return false; 
     159                        } 
     160                         
     161                        if (data[3].length > 300) 
     162                        { 
     163                                alert("Mais de 300 resultados foram retornados! \n Favor refinar sua busca."); 
     164 
     165                                if (_this.onSearchFinish) 
     166                                        _this.onSearchFinish(null); 
     167 
     168                                return false; 
     169                        } 
     170                         
     171                        ccSearchUpdate(); 
     172         
     173                        letter = 'search'; 
     174 
     175                        if ( letter != CC_actual_letter ) 
     176                        { 
     177                                CC_actual_page = '1'; 
     178                        } 
     179                        else 
     180                        { 
     181                                CC_actual_page = parseInt(data[1]); 
     182                        } 
     183         
     184                        CC_actual_letter = letter; 
     185         
     186                        if (CC_max_cards[0] == 0) 
     187                        { 
     188                                if(CC_visual == 'cards') 
     189                                        drawCards(0); 
     190                                else if(CC_visual == 'table') 
     191                                        drawTable(0); 
     192         
     193                                setPages(0,0); 
     194                                return; 
     195                        } 
     196         
     197                        if (data[0] == '0') 
     198                        { 
     199                                Element('cc_type_contact').value = data[1]; 
     200                                CC_npages = 0; 
     201                                CC_actual_page = 1; 
     202                                if(CC_visual == 'cards') 
     203                                        drawCards(0); 
     204                                else if(CC_visual == 'table') 
     205                                        drawTable(0); 
     206                                setPages(0,0); 
     207                                return; 
     208                        } 
     209                        else 
     210                        { 
     211                                Element('cc_type_contact').value = data[10]; 
     212                        } 
     213         
     214                        if (typeof(data) != 'object') 
    239215                        { 
    240216                                showMessage(Element('cc_msg_err_contacting_server').value); 
    241                                 return false; 
    242                         } 
    243  
    244                         if (data['status'] == 'empty') 
    245                         { 
    246                                 //showMessage(data['msg']); 
    247                                 _this.DOMresult.innerHTML = data['msg']; 
    248                                 setTimeout(function(){_this.DOMresult.innerHTML = '';}, 1000); 
    249  
    250                                 if (_this.onSearchFinish) 
    251                                 { 
    252                                         _this.onSearchFinish(null); 
    253                                 } 
    254                                 return false; 
    255                         } 
    256  
    257                         if (data['status'] != 'ok') 
    258                         { 
    259                                 //showMessage(data['msg']); 
    260                                 _this.DOMresult.innerHTML = data['msg']; 
    261                                 setTimeout(function(){_this.DOMresult.innerHTML = '';}, 1000); 
    262                                 return false; 
    263                         } 
    264  
    265                         // Mostra a mensagem se a busca retornar mais de 300 resultados. 
    266                         if (data['data'].length > 300) 
    267                         { 
    268  
    269                                 TODO: Usar o esquema de tradução do expresso para este alert 
    270  
    271                                 alert("Mais de 300 resultados foram retornados!\n" + 
    272                                         "Favor refinar sua busca."); 
    273                         } 
    274  
    275                         if (_this.onSearchFinish) 
    276                         { 
    277                                 _this.onSearchFinish(data['data']); 
     217                                return; 
     218                        } 
     219         
     220                        if (typeof(data[3]) == 'object') 
     221                        { 
     222                                CC_npages = parseInt(data[0]); 
     223                                CC_actual_page = parseInt(data[1]); 
     224                                if(CC_visual == 'cards') 
     225                                        drawCards(data[3].length, data[10]); 
     226                                else if(CC_visual == 'table') 
     227                                        drawTable(data[3].length, data[10]); 
     228                                resizeWindow(); 
     229                                populateCards(data, data[10]); 
     230                                setPages(data[0], data[1]); 
     231                        } 
     232                        else if (data['error']) 
     233                        { 
     234                                showMessage(data['error']); 
     235                        } 
     236                        else 
     237                        { 
     238                                showMessage(Element('cc_msg_err_contacting_server').value); 
     239                                return; 
    278240                        } 
    279241                }; 
    280 */ 
    281                 var info = "letter="+'search'+"&page="+'1'+"&data="+serialize(data); 
    282                 this.Connector.newRequest('get_cards_data', CC_url+'get_cards_data', 'POST', handler, info); 
     242                 
     243                this.Connector.newRequest('search', CC_url+'search&data='+serialize(data), 'GET', handler); 
    283244        } 
  • trunk/contactcenter/js/cc_tree.js

    r284 r285  
    2020                throw('dFTree lib must be loaded!'); 
    2121        } 
    22  
     22         
    2323        function ccCatalogTree(params) 
    2424        { 
     
    2929 
    3030                var _tree = this; 
    31  
     31                 
    3232                /* This is the property that holds the Tree Object */ 
    3333                this.name = params['name']; 
     
    3939                this.Connector = params['connector']; 
    4040 
    41                 /* Build the Inicial Tree */ 
     41                /* Build the Inicial Tree */  
    4242                //this._getActualLevel(); 
    4343                setTimeout(function(){ _tree._updateTree('0', true);}, 100); 
     
    5757                                return; 
    5858                        } 
    59  
     59                         
    6060                        if (data['status'] != 'ok') 
    6161                        { 
     
    6666 
    6767                        _this.catalog_perms = parseInt(data['perms']); 
    68  
     68                         
    6969                        if (_this.afterSetCatalog) 
    7070                        { 
     
    7575                Connector.newRequest(this.name+'catalog', CC_url+'set_catalog&catalog='+catalog, 'GET', handler); 
    7676        } 
    77  
     77         
    7878        ccCatalogTree.prototype.setCatalogSearch = function (catalog) { 
    79  
     79         
    8080                var _this = this; 
    8181                var handler = function (responseText) 
     
    8989                                return; 
    9090                        } 
    91  
     91                         
    9292                        if (data['status'] != 'ok') 
    9393                        { 
     
    100100 
    101101                        this.afterSetCatalog = ccEmailWin.search.go(); 
    102  
     102                         
    103103                }; 
    104104 
    105105                Connector.newRequest(this.name+'catalog', CC_url+'set_catalog&catalog='+catalog, 'GET', handler); 
    106106        } 
    107  
    108  
     107                 
     108         
    109109        ccCatalogTree.prototype.select = function(level, search) 
    110110        { 
    111                 if (!search) { 
     111                if (!search) {  
    112112                        this.tree.openTo(level); 
    113113                        this.tree.getNodeById(level)._select(); 
    114  
     114                 
    115115                        if (level != this.actualLevel) 
    116116                        { 
     
    129129         *                    Methods For Internal Use                           * 
    130130        \*************************************************************************/ 
    131  
     131         
    132132        ccCatalogTree.prototype._waitForTree = function(level, rlevel) 
    133133        { 
     
    142142                        return; 
    143143                } 
    144  
     144                 
    145145                setTimeout(this.name+'._waitForTree(\''+level+'\', '+rlevel+')', 100); 
    146146        } 
     
    176176                                _this.tree.getNodeById(_this.actualLevel)._select(); 
    177177                                _this.setCatalog(_this.actualLevel); 
    178                         } 
    179                 }; 
    180  
     178                                _this.expandTree(); 
     179 
     180                        } 
     181                }; 
     182                 
    181183                Connector.newRequest(this.name+'actual', CC_url+'get_actual_catalog', 'GET', handler); 
    182184        } 
    183185 
     186        ccCatalogTree.prototype.expandTree = function() { 
     187                for (i=0; i < this.tree._aNodes.length; i++) 
     188                        this._expandSubTree(this.tree._aNodes[i]); 
     189        } 
     190 
     191        ccCatalogTree.prototype._expandSubTree = function(node) { 
     192                if ( node._children == '' ) { 
     193                        return; 
     194                } 
     195                if (node._children != '') { 
     196                        for (i = 0; i <= node._children.length; i++) { 
     197                                if ( node._io == false ) 
     198                                        node.changeState(); 
     199                                this._expandSubTree(node._children[i]); 
     200                        } 
     201                } 
     202        } 
     203 
     204 
    184205        ccCatalogTree.prototype._updateTree = function(level, open) 
    185206        { 
     
    201222                        { 
    202223                                showMessage(data['msg']); 
    203                                 if (data['status'] != 'error') 
    204                                 { 
    205                                         return; 
    206                                 } 
     224                                return; 
    207225                        } 
    208226 
    209227                        treeData = data['data']; 
    210  
     228                         
    211229                        var timeout = 10; 
    212230                        var limit = 0; 
     
    243261                                timeout += 5; 
    244262                        } 
    245  
     263                         
    246264                        _this.treeAvailable = true; 
    247265 
     
    253271                        } 
    254272                }; 
    255  
    256273                Connector.newRequest(this.name+'update', CC_url+'get_catalog_tree&level='+level, 'GET', handler); 
    257274        } 
  • trunk/contactcenter/setup/external_catalogs.inc.php

    r284 r285  
    4444 * 
    4545 */ 
    46  
    47   
     46?> 
  • trunk/contactcenter/setup/setup.inc.php

    r284 r285  
    3737        $setup_info['contactcenter']['hooks'][] = 'preferences'; 
    3838        $setup_info['contactcenter']['hooks'][] = 'config_validate'; 
    39  
     39         
    4040        /* ContactCenter Tables */ 
    4141        $setup_info['contactcenter']['tables'][] = 'phpgw_cc_status'; 
     
    6969        $setup_info['contactcenter']['tables'][] = 'phpgw_cc_contact_company'; 
    7070        $setup_info['contactcenter']['tables'][] = 'phpgw_cc_contact_grps'; 
    71  
     71         
    7272        $setup_info['contactcenter']['tables'][] = 'phpgw_cc_groups'; 
    73  
     73         
    7474        /* Dependencies for this app to work */ 
    7575        $setup_info['contactcenter']['depends'][] = array( 
  • trunk/contactcenter/setup/tables_update.inc.php

    r284 r285  
    5656                return $GLOBALS['setup_info']['contactcenter']['currentver']; 
    5757        } 
     58        $test[] = '1.0.005'; 
     59        function contactcenter_upgrade1_0_005() { 
     60                $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.14'; 
     61                return $GLOBALS['setup_info']['contactcenter']['currentver']; 
     62        } 
     63        $test[] = '1.14'; 
     64        function contactcenter_upgrade1_14() {                           
     65                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_connections ALTER COLUMN connection_value TYPE varchar(100)"); 
     66                $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.150'; 
     67                return $GLOBALS['setup_info']['contactcenter']['currentver']; 
     68        } 
     69        $test[] = '1.15'; 
     70        function contactcenter_upgrade1_15() { 
     71                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN last_status char(1) DEFAULT 'N'::bpchar"); 
     72                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN last_update int8 DEFAULT (date_part('epoch'::text, ('now'::text)::timestamp(3) with time zone) * (1000)::double precision)"); 
     73                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN category character varying(20)"); 
     74 
     75                $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.20'; 
     76                return $GLOBALS['setup_info']['contactcenter']['currentver']; 
     77        } 
     78 
    5879?> 
  • trunk/contactcenter/templates/default/config.tpl

    r2 r285  
    5050                <td>{lang_Password_for_the_account_above_(if_any)}:</td> 
    5151                <td><input name="newsettings[cc_ldap_pw0]" type="password" value="" size="40" /></td> 
     52        </tr> 
     53        <tr class="row_off"> 
     54                <td>Abrir Consulta Automática :</td> 
     55                <td> 
     56                        <select name="newsettings[cc_ldap_query_automatic]"> 
     57                                <option value="true" {selected_cc_ldap_query_automatic_true}>Sim</option>        
     58                                <option value="false" {selected_cc_ldap_query_automatic_false}>Não</option>                                                      
     59                        </select> 
     60                </td> 
    5261        </tr> 
    5362   
  • trunk/contactcenter/templates/default/full_add.tpl

    r284 r285  
    1313<input id="cc_contact_personal" type="hidden" value="{cc_contact_personal}"> 
    1414<input id="cc_contact_addrs" type="hidden" value="{cc_contact_addrs}"> 
    15 <input id="cc_contact_conns" type="hidden" value="E-mails e Telefones"> 
     15<input id="cc_contact_conns" type="hidden" value="{emails_telephones}"> 
    1616<input id="cc_pd_full_name" name="{cc_pd_full_name}" type="hidden"> 
    1717<input id="cc_pd_sex" name="{cc_pd_sex}" type="hidden"> 
     
    3636                <tr class="row_on"> 
    3737                        <td align="right">{cc_pd_alias}:</td> 
    38                         <td align="left" colspan="2"><input id="cc_pd_alias" name="{cc_pd_alias}" type="text" style="width:175px;z-index:-1" value="" maxlength="30"></td> 
     38                        <td align="left" colspan="2"><input id="cc_pd_alias" name="{cc_pd_alias}" type="text" style="width:175px;z-index:-1" value="" maxlength=""></td> 
    3939                </tr> 
    4040                <tr style="display:none" class="row_off"> 
     
    139139        <tbody> 
    140140                <tr class="th" width="100%" align="center" height="10px"> 
    141                         <td width="60px" noWrap><input type="radio"  name="cc_conn_type" id="cc_conn_type_1" value="Email" onclick="javascript:updateConnFields();">E-mail</td> 
    142                         <td width="60px" noWrap><input type="radio" name="cc_conn_type" id="cc_conn_type_2" value="Telefone" onclick="javascript:updateConnFields();">Telefone</td> 
    143                         <td width="*" align="left"><select style="width:160px" id="cc_conn_type_sel" onchange="javascript:connAddNewLine();"><option value="-1">Escolha 'Email' ou 'Telefone'</option></select></td> 
    144                 </tr> 
    145                 <tr class="row_off"> 
     141                        <td width="60px" noWrap><input type="radio"  name="cc_conn_type" id="cc_conn_type_1" value="Email" onclick="javascript:updateConnFields();">{email}</td> 
     142                        <td width="60px" noWrap><input type="radio" name="cc_conn_type" id="cc_conn_type_2" value="Telefone" onclick="javascript:updateConnFields();">{telephone}</td> 
     143                        <td width="*" align="left"><select style="width:160px" id="cc_conn_type_sel" onchange="javascript:connAddNewLine();"><option value="-1">{choose_email_telephone}</option></select></td> 
     144                </tr> 
     145                <tr class="row_off">                     
    146146                        <td valign="top" colspan="4" width="100%" style="border: 0px solid black" cellpadding="0" cellspacing="0"> 
    147147                                <table align="left" width="100%" style="border: 0px solid black"> 
    148148                                <tbody id="cc_conn">&nbsp; 
    149149                                        <!-- Code inside here is inserted dynamically --> 
    150                                 </tbody> 
     150                                </tbody>                                 
    151151                                </table> 
    152152                        </td> 
     
    159159        </tbody> 
    160160        </table> 
    161         <div style="z-index:10000;position: absolute;display:none; top: 170px; left: 78px;" id="div_cc_conn_is_default">É padrão:&nbsp;<select id="cc_email_default" name="cc_email_default" disabled style="display:none"></select><select id="cc_phone_default" name="cc_phone_default" disabled style="display:none"></select></div> 
     161        <div style="z-index:10000;position: absolute;display:none; top: 170px; left: 78px;" id="div_cc_conn_is_default"> {cc_default} &nbsp;<select id="cc_email_default" name="cc_email_default" disabled style="display:none"></select><select id="cc_phone_default" name="cc_phone_default" disabled style="display:none"></select></div> 
    162162</div> 
    163163<!-- _BOTTOM BUTTONS --> 
    164 <div align="center" id="cc_contact_tab_buttons" style="position: absolute; visibility: hidden; top: 250px; left: 0px; width: 498px; height: 32px; border: 0px solid black"> 
     164<div align="center" id="cc_contact_tab_buttons" style="position: absolute; visibility: hidden; top: 250px; left: 0px; width: 498px; height: 32px; border: 0px solid black">      
    165165        <table class="row_off" align="center" width="498px" cellpadding="2" cellspacing="0" border="0"> 
    166166                <tr> 
     
    177177<!-- 
    178178//      Overloading some methods for fix cursor problem in Firefox. 
    179         if(!is_ie) { 
    180                 dJSWin.prototype.close = function() { 
     179        if(!is_ie) {  
     180                dJSWin.prototype.close = function() {            
    181181                        dJSWin.state = 0; 
    182182                        dd.elements[this.title.id].hide(); 
    183                         Element("divScrollMain").style.overflow = 'auto'; 
     183                        if ( dd_div = document.getElementById('divScrollMain'))  
     184                                Element("divScrollMain").style.overflow = 'auto';        
    184185                } 
    185186                dJSWin.prototype.open = function() { 
     
    188189                        dd.elements[this.title.id].maximizeZ(); 
    189190                        dd.elements[this.title.id].show(); 
    190                         Element("divScrollMain").style.overflow = 'hidden'; 
    191                 } 
    192         } 
    193  
     191                        if ( dd_div = document.getElementById('divScrollMain')) 
     192                                dd_div.style.overflow = 'hidden'; 
     193                } 
     194        }        
     195                 
    194196        var fullAdd_onload = document.body.onload; 
    195197        var tabs; 
    196198        var fullAddWin; 
    197         var photo_frame, photo_form, photo_input; 
     199        var photo_frame, photo_form, photo_input;        
    198200 
    199201        __f = function(e) 
    200202        { 
    201  
     203                 
    202204                tabs = new dTabsManager({'id': 'cc_contact_tab', 'width': '500px'}); 
    203  
    204                 tabs.addTab({'id': 'cc_contact_tab_0', 
    205                                          'name': Element('cc_contact_personal').value, 
    206                                          'selectedClass': 'tab_box_active', 
     205                 
     206                tabs.addTab({'id': 'cc_contact_tab_0',  
     207                                         'name': Element('cc_contact_personal').value,  
     208                                         'selectedClass': 'tab_box_active',  
    207209                                         'unselectedClass': 'tab_box'}); 
    208  
    209                 tabs.addTab({'id': 'cc_contact_tab_2', 
    210                                          'name': Element('cc_contact_conns').value, 
    211                                          'selectedClass': 'tab_box_active', 
     210                                          
     211                tabs.addTab({'id': 'cc_contact_tab_2',  
     212                                         'name': Element('cc_contact_conns').value,  
     213                                         'selectedClass': 'tab_box_active',  
    212214                                         'unselectedClass': 'tab_box'}); 
    213215 
    214                 tabs.addTab({'id': 'cc_contact_tab_1', 
    215                                          'name': Element('cc_contact_addrs').value, 
    216                                          'selectedClass': 'tab_box_active', 
    217                                          'unselectedClass': 'tab_box'}); 
     216                tabs.addTab({'id': 'cc_contact_tab_1',  
     217                                         'name': Element('cc_contact_addrs').value,  
     218                                         'selectedClass': 'tab_box_active',  
     219                                         'unselectedClass': 'tab_box'});                                          
    218220 
    219221                fullAddWin = new dJSWin({'id': 'cc_full_add', 
     
    229231                                         'border': true}); 
    230232 
    231                 fullAddWin.draw(); 
    232  
     233                fullAddWin.draw();               
     234                                                 
    233235                if (is_ie) 
    234236                { 
     
    242244                { 
    243245                        Element('cc_pd_select_photo_t').style.display='none'; 
    244                         Element('cc_pd_select_photo_b').style.display='none'; 
    245                 } 
    246  
     246                        Element('cc_pd_select_photo_b').style.display='none';                    
     247                } 
     248                 
    247249        }; 
    248250 
    249251        if (is_ie) // || is_moz1_6) 
    250252        { 
    251  
     253                         
    252254                document.body.onload = function(e) { setTimeout('__f()', 10); fullAdd_onload ? setTimeout('fullAdd_onload()'): false;}; 
    253255        } 
     
    270272 
    271273 
    272 <!-- RELATIONS 
     274<!-- RELATIONS  
    273275<div id="cc_contact_tab_3" class="row_off div_cc_contact_tab"> 
    274276        <table align="center" width="500px" height="100%" cellpadding="2" cellspacing="0" border="0"> 
  • trunk/contactcenter/templates/default/index.tpl

    r284 r285  
    11<link rel="stylesheet" type="text/css" href="{cc_css}"> 
    2 <style> 
     2<style>  
    33        .special{ 
    44                cursor:pointer; 
    55                cursor:hand; 
    6                 position:relative; 
    7                 top:0px; 
     6                position:relative;  
     7                top:0px;  
    88                left:0px; 
    9                 color: #006699; 
     9                color: #006699;  
    1010                background-color:#DCDCDC; 
    1111        } 
     
    1515<input id="cc_msg_no_cards" type="hidden" value="{cc_msg_no_cards}"> 
    1616<input id="cc_msg_err_no_room" type="hidden" value="{cc_msg_err_no_room}"> 
    17  
    1817<input id="cc_root_dir" type="hidden" value="{cc_root_dir}"> 
    1918<input id="cc_msg_card_new" type="hidden" value="{cc_msg_card_new}"> 
     
    2524<input id="cc_msg_card_remove_confirm" type="hidden" value="{cc_msg_card_remove_confirm}"> 
    2625<input id="cc_send_mail" type="hidden" value="{cc_send_mail}"> 
    27 <input id="cc_msg_group_edit" type="hidden" value="{cc_msg_group_edit}"> 
     26<input id="cc_msg_group_edit" type="hidden" value="{cc_msg_group_edit}">         
    2827<input id="cc_msg_group_remove" type="hidden" value="{cc_msg_group_remove}"> 
    2928<input id="cc_msg_group_remove_confirm" type="hidden" value="{cc_msg_group_remove_confirm}"> 
    3029<input id="cc_panel_search_text" type="hidden" value="{cc_panel_search}" style="cursor: pointer; cursor: hand;" onclick="javascript:ccSearch()" /> 
     30<input id="cc_msg_close_win" type="hidden" value="{cc_msg_close_win}"> 
     31<input id="cc_msg_import_contacts" type="hidden" value="{cc_msg_import_contacts}"> 
     32<input id="cc_msg_export_contacts" type="hidden" value="{cc_msg_export_contacts}"> 
     33<input id="cc_msg_expresso_info_csv" type="hidden" value="{cc_msg_expresso_info_csv}"> 
     34<input id="cc_msg_choose_file_type" type="hidden" value="{cc_msg_choose_file_type}"> 
     35<input id="cc_msg_outlook_express" type="hidden" value="{cc_msg_outlook_express}"> 
     36<input id="cc_msg_outlook2k" type="hidden" value="{cc_msg_outlook2k}"> 
     37<input id="cc_msg_expresso_default" type="hidden" value="{cc_msg_expresso_default}"> 
     38<input id="cc_msg_choose_contacts_file" type="hidden" value="{cc_msg_choose_contacts_file}"> 
     39<input id="cc_msg_close" type="hidden" value="{cc_msg_close}"> 
     40<input id="cc_msg_ie_personal" type="hidden" value="{cc_msg_ie_personal}"> 
     41<input id="cc_msg_import_fail" type="hidden" value="{cc_msg_import_fail}"> 
     42<input id="cc_msg_export_csv" type="hidden" value="{cc_msg_export_csv}">                    
     43<input id="cc_msg_automatic" type="hidden" value="{cc_msg_automatic}"> 
     44<input id="cc_msg_importing_contacts" type="hidden" value="{cc_msg_importing_contacts}"> 
     45<input id="cc_msg_import_finished" type="hidden" value="{cc_msg_import_finished}"> 
     46<input id="cc_msg_invalid_csv" type="hidden" value="{cc_msg_invalid_csv}"> 
     47<input id="cc_msg_new" type="hidden" value="{cc_msg_new}"> 
     48<input id="cc_msg_failure" type="hidden" value="{cc_msg_failure}"> 
     49<input id="cc_msg_exists" type="hidden" value="{cc_msg_exists}"> 
     50<input id="cc_msg_show_more_info" type="hidden" value="{cc_msg_show_more_info}"> 
     51<input id="cc_msg_clean" type="hidden" value="{cc_msg_clean}"> 
     52<input id="cc_msg_choose_valid_csv" type="hidden" value="{cc_msg_choose_valid_csv}"> 
     53<input id="cc_msg_export_error" type="hidden" value="{cc_msg_export_error}"> 
     54<input id="cc_msg_new_email" type="hidden" value="{cc_msg_new_email}"> 
     55<input id="cc_msg_main" type="hidden" value="{cc_msg_main}"> 
     56<input id="cc_msg_alternative" type="hidden" value="{cc_msg_alternative}"> 
     57<input id="cc_msg_select_email" type="hidden" value="{cc_msg_select_email}"> 
     58<input id="cc_msg_new_phone" type="hidden" value="{cc_msg_new_phone}"> 
     59<input id="cc_msg_home" type="hidden" value="{cc_msg_home}"> 
     60<input id="cc_msg_cellphone" type="hidden" value="{cc_msg_cellphone}"> 
     61<input id="cc_msg_work" type="hidden" value="{cc_msg_work}"> 
     62<input id="cc_msg_fax" type="hidden" value="{cc_msg_fax}"> 
     63<input id="cc_msg_pager" type="hidden" value="{cc_msg_pager}"> 
     64<input id="cc_msg_choose_phone" type="hidden" value="{cc_msg_choose_phone}"> 
     65<input id="cc_msg_warn_firefox" type="hidden" value="{cc_msg_warn_firefox}"> 
     66<input id="cc_msg_firefox_half1" type="hidden" value="{cc_msg_firefox_half1}"> 
     67<input id="cc_msg_firefox_half2" type="hidden" value="{cc_msg_firefox_half2}"> 
     68<input id="cc_msg_click_close" type="hidden" value="{cc_msg_click_close}"> 
     69<input id="cc_msg_install_now" type="hidden" value="{cc_msg_install_now}"> 
     70<input id="cc_msg_install_new_firefox" type="hidden" value="{cc_msg_install_new_firefox}"> 
     71<input id="cc_msg_close" type="hidden" value="{cc_msg_close}"> 
     72<input id="cc_msg_outlook_express_pt" type="hidden" value="{cc_msg_outlook_express_pt}"> 
     73<input id="cc_msg_outlook_express_en" type="hidden" value="{cc_msg_outlook_express_en}"> 
     74<input id="cc_msg_outlook_2k_pt" type="hidden" value="{cc_msg_outlook_2k_pt}"> 
     75<input id="cc_msg_outlook_2k_en" type="hidden" value="{cc_msg_outlook_2k_en}"> 
     76<input id="cc_msg_moz_thunderbird" type="hidden" value="{cc_msg_moz_thunderbird}"> 
     77<input id="cc_msg_expresso_default_csv" type="hidden" value="{cc_msg_expresso_default_csv}"> 
     78<input id="cc_msg_copy_to_catalog" type="hidden" value="{cc_msg_copy_to_catalog}"> 
     79<input id="cc_msg_fill_field_name" type="hidden" value="{cc_msg_fill_field_name}"> 
     80<input id="cc_msg_add_contact_to_group" type="hidden" value="{cc_msg_add_contact_to_group}"> 
     81 
     82 
    3183 <!-- END JS MESSAGES --> 
    3284 <input id="cc_type_contact"    type="hidden"> 
    3385 <input id="cc_participants"    type="hidden"  value="{cc_participants}"> 
    34  
     86  
    3587 <input id="cc_qa_alias"                type="hidden" value="{cc_qa_alias}"> 
    3688 <input id="cc_qa_given_names"  type="hidden" value="{cc_qa_given_names}"> 
     
    3890 <input id="cc_qa_phone"                type="hidden" value="{cc_qa_phone}"> 
    3991 <input id="cc_qa_email"                type="hidden" value="{cc_qa_email}"> 
    40  
     92  
    4193 <input id="cc_qa_save"                 type="hidden" value="{cc_qa_save}"> 
    42  <input id="cc_qa_clear"                type="hidden" value="{cc_qa_clear}"> 
    43  
     94 <input id="cc_qa_close"                type="hidden" value="{cc_qa_close}"> 
     95  
    4496 <input id="cc_empty"                   type="hidden"  value="{cc_empty}"> 
    4597  <!-- VIEW CARDS --> 
     
    53105                                </tr> 
    54106                                <tr> 
    55                                         <td width="150px" height="100%" align="left" valign="top"> 
     107                                        <td width="150px" height="100%" align="left" valign="top">  
    56108                                                <div id="cc_tree" style="overflow:auto;position:relative; width: 150px;border: 0px solid #999;"></div> 
    57109                                        </td> 
     
    75127                                </tr>--> 
    76128                                <tr align="left"> 
    77                                         <td align="left"> 
    78                                         <input id="cc_button_new" onMouseOver="if(!menuStarted) menu();menu.onmouseover()" onMouseOut="menu.onmouseout()"  value="Novo ..." type="button"> 
     129                                        <td align="left">                                                                                                                        
     130                                        <input id="cc_button_new" onMouseOver="if(!menuStarted) menu();menu.onmouseover()" onMouseOut="menu.onmouseout()"  value="{cc_btn_new}" type="button">                                   
    79131                                        <div id="cc_panel_search_call" style="display: inline"></div> 
    80132                                        <div id="cc_panel_table" style="display: none; text-align: right"> 
     
    82134                                        </div> 
    83135                                        <div id="cc_panel_cards" style="display: inline; text-align: right"> 
    84                                         <input type="button" value="{cc_panel_cards}" class="tab_box" style="cursor: pointer; cursor: hand;" onclick="javascript: ccChangeVisualization('cards')" /> 
     136                                        <input type="button" value="{cc_panel_cards}" class="tab_box" style="cursor: pointer; cursor: hand;" onclick="javascript: ccChangeVisualization('cards')" />                                     
    85137                                        </div> 
    86138                                        </td> 
    87139                                        <td align="right"> 
    88                                         <input id="cc_button_tools" value="Importar | Exportar" type="button" onclick="javascript:ccIEContacts.showList()"> 
     140                                        <input id="cc_button_tools" value="{cc_btn_import_export}" type="button" onclick="javascript:ccIEContacts.showList()"> 
    89141                                        </td> 
    90142                                </tr> 
     
    172224                                                                                        <td align="left" valign="middle"><span id="cc_panel_arrow_last"><img src="templates/default/images/last-grey.png" border="0" alt="{cc_panel_last_page}" hspace="2" /></span></td> 
    173225                                                                                </tr> 
    174                                                                         </table> 
     226                                                                        </table>                         
    175227                                                                </td> 
    176228                                                        </tr> 
     
    179231                                </tr> 
    180232                                <!-- ___END PANEL --> 
    181                                 <!-- __CARDS --> 
     233                                <!-- __CARDS -->                                 
    182234                                <tr> 
    183235                                        <td style="border: 0px solid #666;" id="cc_card_space" width="100%" height="auto" valign="top" align="center" colspan="4"></td> 
    184                                 </tr> 
     236                                </tr>                                                                                            
    185237                                <!-- __END CARDS --> 
    186238                        </table> 
     
    197249<script type="text/javascript" src="js/ccIEContacts.js"></script> 
    198250<script type="text/javascript" src="js/ccMain.js"></script> 
    199 <!-- END BOTTOM DETAILS--> 
     251<!-- END BOTTOM DETAILS-->                                               
Note: See TracChangeset for help on using the changeset viewer.