Changeset 284


Ignore:
Timestamp:
05/21/08 16:56:17 (16 years ago)
Author:
rafaelraymundo
Message:

Vide Trac - #197, #166, #198, #199

  1. Correção de problema na leitura do arquivo configuração.
  2. Permissão do click2dial também no contactcenter.
  3. Visualização de matricula, e nro celular no resultado da pesquisa(se estiverem populados)
  4. Adicionada a leitura a Catálogos Externos
Location:
trunk/contactcenter
Files:
7 added
25 edited

Legend:

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

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

    r2 r284  
    2020 
    2121        include_once('class.abo_catalog.inc.php'); 
    22          
     22 
    2323        class bo_catalog_group_catalog extends abo_catalog 
    2424        { 
    25                          
     25 
     26                var $external; 
     27 
    2628                var $fields = array( 
    2729                        'id_contact'    => true, 
     
    3840                        'pgp_key'       => true, 
    3941                        'notes'         => true, 
    40                          
     42 
    4143                        /* Array fields */ 
    4244                        'companies'     => true, 
     
    4547                        'connections'   => true 
    4648                ); 
    47          
    48                 /*! 
    49                  
     49 
     50                /*! 
     51 
    5052                 @function bo_people_catalog 
    5153                 @abstract Constructor 
    5254                 @author Raphael Derosso Pereira 
    53                   
     55 
    5456                */ 
    55                 function bo_catalog_group_catalog(& $bo_contactcenter, & $catalog) 
     57                function bo_catalog_group_catalog(& $bo_contactcenter, & $catalog, $external = 0) 
    5658                { 
    5759                        $this->bo_contactcenter = & $bo_contactcenter; 
    5860                        $this->catalog = & $catalog; 
    59                 } 
    60                          
     61                        $this->external = $external; 
     62                } 
     63 
    6164 
    6265                /*! 
     
    6871 
    6972                 @param SEE class bo_contactcenter for usage 
    70                  
     73 
    7174                */ 
    7275                function find($what, $rules, $other) 
     
    7477                        if ($ldap_info = $this->catalog['ldap']) 
    7578                        { 
    76                                 $meta_catalog =& CreateObject('contactcenter.bo_global_ldap_catalog',$ldap_info['id_source'], $ldap_info['context']); 
     79 
     80                                $meta_catalog =& CreateObject('contactcenter.bo_global_ldap_catalog',$ldap_info['id_source'], $ldap_info['context'], $this->external); 
    7781                                return $meta_catalog->find($what, $rules, $other); 
    7882                        } 
    79                          
     83 
    8084                        $results = array(); 
    81                          
     85 
    8286                        reset($this->catalog); 
    8387                        while(list(, $new_catalog) = each($this->catalog['sub_branch'])) 
     
    8690                                //echo 'Setting catalog: <b>'.$new_catalog['name'].'</b><br>'; 
    8791                                $new_catalog = $this->bo_contactcenter->set_catalog($new_catalog); 
    88                                  
     92 
    8993                                //if($new_catalog) echo 'Setado corretamente!<br><br>'; else echo 'Erro ao setar<br><br>'; 
    90                                  
     94 
    9195                                if ($new_catalog['type'] === 'empty') 
    9296                                { 
    9397                                        continue; 
    9498                                } 
    95                                  
     99 
    96100                                $temp_res = $this->bo_contactcenter->catalog->find($what, $rules, $other); 
    97101                                if (is_array($temp_res) and count($temp_res)) 
     
    107111                        return $result; 
    108112                } 
    109                  
    110                 /*! 
    111                  
     113 
     114                /*! 
     115 
    112116                 @function get_single_entry 
    113117                 @abstract Returns all information requested about one contact 
    114118                 @author Raphael Derosso Pereira 
    115                       
     119 
    116120                 @param integer $id_contact The contact ID 
    117121                 @param array $fields The array returned by get_fields whith true 
    118122                        on the fields to be taken. 
    119                          
     123 
    120124                */ 
    121125                function get_single_entry ( $id_contact, $fields ) 
    122                 {        
    123                         if (!is_array($fields))  
    124                         { 
    125                                 if (is_object($GLOBALS['phpgw']->log))  
     126                { 
     127                        if (!is_array($fields)) 
     128                        { 
     129                                if (is_object($GLOBALS['phpgw']->log)) 
    126130                                { 
    127131                                        $GLOBALS['phpgw']->log->message(array( 
     
    129133                                                'line' => __LINE__, 
    130134                                                'file' => __FILE__)); 
    131                                          
     135 
    132136                                        $GLOBALS['phpgw']->log->commit(); 
    133137                                } 
    134                                 else  
     138                                else 
    135139                                { 
    136140                                        exit('Argument Error on: <br>File:'.__FILE__.'<br>Line:'.__LINE__.'<br>'); 
    137141                                } 
    138142                        } 
    139                          
     143 
    140144                        $contact_array = $this->get_multiple_entries(array($id_contact), $fields); 
    141                          
     145 
    142146                        if (!count($contact_array)) 
    143147                        { 
     
    149153                        else 
    150154                                $contact_data = $contact_array[$id_contact]; 
    151                          
     155 
    152156                        if (!is_array($contact_data)) 
    153157                        { 
    154158                                return false; 
    155159                        } 
    156                          
     160 
    157161                        return $contact_data; 
    158162                } 
    159          
    160                 /*! 
    161                   
     163 
     164                /*! 
     165 
    162166                 @function get_multiple_entries 
    163167                 @abstract Returns multiple Contacts data into one array 
     
    172176                                'sort'      => <sort>, 
    173177                                'order_by'  => <order by> 
    174                         );  
    175                  
     178                        ); 
     179 
    176180                */ 
    177181                function get_multiple_entries ( $id_contacts, $fields, $other_data = false ) 
     
    179183                        if (!is_array($id_contacts) or !is_array($fields) or ($other_data != false and !is_array($other_data))) 
    180184                        { 
    181                                 if (is_object($GLOBALS['phpgw']->log))  
     185                                if (is_object($GLOBALS['phpgw']->log)) 
    182186                                { 
    183187                                        $GLOBALS['phpgw']->log->message(array( 
     
    185189                                                'line' => __LINE__, 
    186190                                                'file' => __FILE__)); 
    187                                          
     191 
    188192                                        $GLOBALS['phpgw']->log->commit(); 
    189193                                } 
     
    192196                                } 
    193197                        } 
    194                          
     198 
    195199                        $contacts = array(); 
    196          
     200 
    197201                        if ($other_data) 
    198202                        { 
    199203                                //TODO 
    200204                        } 
    201          
     205 
     206                        //error_log("bo_ldap_catalog_group_catalog->get_multiple_entries \n", 3, '/var/www/teste.log'); 
     207 
    202208                        /* First check if this is a LDAP Catalog Group. In this case, just leave the 
    203209                         * subtree search for the LDAP server 
     
    205211                        if ($ldap_info = $this->catalog['ldap']) 
    206212                        { 
    207                                 $meta_catalog = CreateObject('contactcenter.bo_global_ldap_catalog', $ldap_info['id_source'], $ldap_info['context']); 
     213                                $meta_catalog = CreateObject('contactcenter.bo_global_ldap_catalog', $ldap_info['id_source'], $ldap_info['context'], $this->external); 
    208214                                return $meta_catalog->get_multiple_entries($id_contacts, $fields, $other_data); 
    209215                        } 
    210                          
     216 
    211217                        /* Search for the catalog of the first entry and try to get all ids from that 
    212218                         * catalog. Repeat to the ones not found until there's none missing or no more 
     
    220226                                $this->bo_contactcenter->set_catalog($branch); 
    221227                                $contacts += $this->bo_contactcenter->catalog->get_multiple_entries($id_contacts, $fields, $other_data); 
    222                                  
     228 
    223229                                reset($contacts); 
    224230                                while (list($id) = each($contacts)) 
     
    237243 
    238244                        $this->bo_contactcenter->set_catalog($this->catalog); 
    239                          
     245 
    240246                        return $contacts; 
    241247                } 
    242          
     248 
    243249                function get_all_entries_ids () 
    244250                { 
     
    246252                        return null; 
    247253                } 
    248                  
     254 
    249255                /*********************************************************************\ 
    250256                 *                Methods to get general fields                      * 
    251257                \*********************************************************************/ 
    252                  
     258 
    253259                /*********************************************************************\ 
    254260                 *                   Methods to Include Data                         * 
  • trunk/contactcenter/inc/class.bo_contactcenter.inc.php

    r2 r284  
    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                  
    59                 /*! 
    60                  
     58 
     59                /* 
     60                 * 
     61                 * @function is_external 
     62                 * @author Mário César Kolling <mario.kolling@serpro.gov.br> 
     63                 * @abstract Verify if a catalog is external 
     64                 * @param (mixed) an catalog array or a catalog tree level, a string in the form 0.sublevel.subsublevel 
     65                 * @return (boolean) true if it is an external catalog false otherwise 
     66                 * 
     67                 */ 
     68 
     69                function is_external($catalog) 
     70                { 
     71                        if (is_array($catalog)) 
     72                        { 
     73                                $level = $this->get_level_by_branch($catalog, $this->tree['branches']); 
     74                        } 
     75                        else 
     76                        { 
     77                                $level = $catalog; 
     78                        } 
     79 
     80                        $lvl_vector = explode('.', $level); 
     81                        $id = $lvl_vector[1]; 
     82 
     83                        if ($this->tree['branches'][$id]['external']) 
     84                        { 
     85                                return true; 
     86                        } 
     87 
     88                        return false; 
     89 
     90                } 
     91 
     92                /* 
     93                 function get_letters_filter($catalog) 
     94                { 
     95 
     96                } 
     97 
     98                function get_numbers_filter($catalog) 
     99                { 
     100 
     101                } 
     102 
     103                function get_search_filter($catalog) 
     104                { 
     105 
     106                } 
     107                */ 
     108 
     109                /*! 
     110 
    61111                        @function find 
    62112                        @abstract Performs a search in the DB based on the parameters 
    63113                        @author Raphael Derosso Pereira (algorithm and code) 
    64114                        @author Vinicius Cubas Brand (algorithm) 
    65                          
     115 
    66116                        @param array $what The list of fields to be returned. The format is: 
    67117                                $what = array( 
     
    69119                                        'contact.names_ordered' 
    70120                                ); 
    71                          
     121 
    72122                        @param array $rules The restrictions. 
    73                          
     123 
    74124                        The restrictions format is quite complicated, but is very complete. 
    75125                        As defined here, there is the possibility to do almost any type of 
    76126                        search (tell me if you can't do any). For example, imagine the 
    77127                        following search: 
    78                                          
     128 
    79129                                                and(a,or(d,e,and(f,g))) 
    80                          
     130 
    81131                        That is represented by the folloowing tree: 
    82                                  
     132 
    83133                                   and 
    84134                                    | 
     
    98148                        The rules that should be passed to the find function for this tree 
    99149                        is: 
    100                                  
     150 
    101151                                $rules = array( 
    102152                                        0 => array( 
     
    139189                                ); 
    140190 
    141    
    142                         The restriction type can be: =, !=, <=, <, >, >=, NULL, IN, LIKE,  
     191 
     192                        The restriction type can be: =, !=, <=, <, >, >=, NULL, IN, LIKE, 
    143193                        NOT NULL, NOT IN, NOT LIKE 
    144194                        Value of branch can be AND, OR, NOT 
    145                          
    146                         @param array $other Other parameter to the search  
     195 
     196                        @param array $other Other parameter to the search 
    147197                                $other = array( 
    148198                                        'offset'          => (int), 
     
    154204 
    155205                        @return array $array[<field_name>][<row_number>] 
    156                                  
     206 
    157207                */ 
    158208                function find($what, $rules=false, $other=false) 
     
    160210                        return $this->catalog->find($what, $rules, $other); 
    161211                } 
    162                  
    163                 /*! 
    164                  
     212 
     213                /*! 
     214 
    165215                        @function get_catalog_tree 
    166216                        @abstract Returns an array describing the available 
     
    168218                                values and types 
    169219                        @author Raphael Derosso Pereira 
     220                        @author Mário César Kolling (external catalogs and optimizations) 
    170221 
    171222                        @param (string)  $level The level to be taken 
    172223                        @param (boolean) $recursive Retrive the whole tree from 
    173224                                the level specified until the leaves 
    174                          
     225 
    175226                        @return The format of the return is: 
    176227                                $return = array( 
     
    195246                                        1  => array(...),... 
    196247                                ); 
    197                                  
     248 
    198249                                <branch_type> can be 'catalog_group', 'catalog' or 'view'; 
    199                                 <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 
    200251                                        handling the information for this catalog/view 
    201252                                <branch_class_args> is an array that holds the arguments to 
     
    203254                                <brach_find_args> is the string that should precede the search 
    204255                                        string 
    205                                                  
    206                                 If the branch is actually a leaf, than 'sub_branch' is false;  
    207                  
    208                  
     256 
     257                                If the branch is actually a leaf, than 'sub_branch' is false; 
     258 
     259 
    209260                        TODO: This method is hard-coded, but it should grab the tree 
    210261                        from the DB using the View Manager... 
     
    218269                                        return $this->tree['branches']; 
    219270                                } 
    220                                  
     271 
     272                                $lvl_vector = explode('.', $level); 
     273                                $id = $lvl_vector[1]; 
     274 
    221275                                $branch =& $this->get_branch_by_level($level); 
    222276                                $info = $this->get_info_by_level($level); 
    223                                  
     277 
    224278                                if ($branch['type'] === 'unknown') 
    225279                                { 
     
    227281                                        { 
    228282                                                $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    229                                                 $new_branch = $ldap->get_ldap_tree($info['src'], $branch['value'], $recursive); 
    230                                                  
     283 
     284                                                if ($this->tree['branches'][$id]['external']) 
     285                                                { 
     286                                                        // if it's an external catalog 
     287                                                        $new_branch = $ldap->get_external_ldap_tree($info['src'], $branch['value'], $recursive); 
     288                                                } 
     289                                                else 
     290                                                { 
     291                                                        // if it's not an external catalog 
     292                                                        $new_branch = $ldap->get_ldap_tree($info['src'], $branch['value'], $recursive); 
     293                                                } 
     294 
    231295                                                if ($new_branch) 
    232296                                                { 
     297                                                        if (!empty($new_branch['timeout']) && !empty($new_branch['msg'])) 
     298                                                        { 
     299                                                                return $new_branch; 
     300                                                        } 
     301 
     302                                                        // Necessary for the new way the catalog tree is built at initialization 
     303                                                        $new_branch['name'] = $branch['name']; 
     304                                                        $new_branch['external'] = $branch['external']; 
    233305                                                        $branch = $new_branch; 
     306 
    234307                                                } 
    235308                                                else 
     
    239312                                        } 
    240313                                        $GLOBALS['phpgw']->session->appsession('bo_contactcenter.tree','contactcenter',$this->tree); 
    241                                          
    242314                                        return $branch; 
    243315                                } 
     
    246318                                        return $branch; 
    247319                                } 
    248                                  
     320 
    249321                                return false; 
    250322                        } 
    251                          
     323 
    252324                        if ($level !== '0') 
    253325                        { 
    254326                                return false; 
    255327                        } 
    256                          
     328 
    257329                        $this->tree = array( 
    258330                                0 => array( 
     
    275347                                                'sub_branch' => false 
    276348                                        ),*/ 
    277                                          
     349 
    278350                                        1  => array( 
    279351                                                'name'       => lang('Groups'), 
     
    281353                                                'class'      => 'bo_group_manager', 
    282354                                                'icon'       => 'people-mini.png', 
    283                                                 'sub_branch' => False    
     355                                                'sub_branch' => False 
    284356                                        ) 
    285357                                ) 
    286358                        ); 
    287                          
     359 
    288360                        $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    289361                        $ldap_srcs = $ldap->get_all_ldap_sources(); 
    290                          
     362 
    291363                        if ($ldap_srcs) 
    292364                        { 
     
    297369                                        if (($tree = $ldap->get_ldap_tree($id, $ldap_srcs[$id]['dn'], $recursive))) 
    298370                                        { 
     371                                                // It isn't used anymore, but does no harm! 
     372                                                // It may be usefull later for use with search timeouts, or another ldap error 
     373                                                if (array_key_exists('error_msg', $tree)) 
     374                                                { 
     375                                                        if (isset($this->tree['branches']['msg'])) 
     376                                                        { 
     377                                                                $this->tree['branches']['msg'] .= "\n" . lang('Catalog %1 not showed due to error: ' . 
     378                                                                                                         $tree['error_msg'], $ldap_srcs[$id]['name']); 
     379                                                        } 
     380                                                        else 
     381                                                        { 
     382                                                                $this->tree['branches']['msg'] = lang('Catalog %1 not showed due to error: ' . 
     383                                                                                                         $tree['error_msg'], $ldap_srcs[$id]['name']); 
     384                                                        } 
     385                                                } 
     386                                                else 
     387                                                { 
     388                                                        $tree['name'] = $ldap_srcs[$id]['name']; 
     389                                                        $tree['external'] = false; 
     390                                                        array_push($this->tree['branches'], $tree); 
     391                                                        $this->tree[$i]['type'] = 'ldap'; 
     392                                                        $this->tree[$i]['src'] = $id; 
     393                                                } 
     394 
     395                                        } 
     396                                        $i++; 
     397                                } 
     398                        } 
     399 
     400                        // external LDAP sources 
     401                        $ldap_srcs = $ldap->get_external_ldap_sources(); 
     402 
     403                        if ($ldap_srcs) 
     404                        { 
     405                                $i = count($this->tree); 
     406 
     407                                reset($ldap_srcs); 
     408 
     409                                while (list($id,) = each($ldap_srcs)) 
     410                                { 
     411                                        // External catalogs are now identified as type unknown during initialization. An optimization change. 
     412 
     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                                                */ 
    299433                                                $tree['name'] = $ldap_srcs[$id]['name']; 
     434                                                $tree['type'] = 'unknown'; 
     435                                                $tree['value'] = $ldap_srcs[$id]['dn']; 
     436                                                $tree['external'] = true; 
     437                                                //$tree['sub_branch'] = false; 
    300438                                                array_push($this->tree['branches'], $tree); 
    301439                                                $this->tree[$i]['type'] = 'ldap'; 
    302440                                                $this->tree[$i]['src'] = $id; 
    303                                         } 
     441                                        //      } 
     442                                        //} 
    304443                                        $i++; 
    305444                                } 
    306445                        } 
    307                          
     446 
    308447                        $GLOBALS['phpgw']->session->appsession('bo_contactcenter.tree','contactcenter',$this->tree); 
    309448                        return $this->tree['branches']; 
    310                 } 
    311  
    312                 /*! 
    313                          
     449                        //return null; 
     450                } 
     451 
     452                /*! 
     453 
    314454                        @function get_branch_by_level 
    315455                        @abstract Returns the branch and it's informations given the level 
    316456                        @author Raphael Derosso Pereira 
    317                          
     457 
    318458                        @param (string) $level The level to be used 
    319                          
     459 
    320460                */ 
    321461                function & get_branch_by_level($level) 
     
    323463                        $path = @explode('.',$level); 
    324464                        $n_ways = count($path); 
    325                          
     465 
    326466                        if ($n_ways <= 1) 
    327467                        { 
    328468                                return false; 
    329469                        } 
    330                          
     470 
    331471                        $code = '$branch =& $this->tree[\'branches\']'; 
    332472                        for ($i = 1; $i < $n_ways-1; $i++) 
     
    338478                        //echo 'Codigo: '.$code.'<br>'; 
    339479                        eval($code); 
    340                          
     480 
    341481                        return $branch; 
    342482                } 
    343483 
    344484                /*! 
    345                   
     485 
    346486                 @function get_info_by_level 
    347487                 @abstract Returns the information about the catalog, given the level 
     
    355495                        $path = @explode('.',$level); 
    356496                        $n_ways = count($path); 
    357                          
     497 
    358498                        if ($n_ways <= 1) 
    359499                        { 
    360500                                return false; 
    361501                        } 
    362                          
     502 
    363503                        $info = $this->tree[$path[1]]; 
    364                          
     504 
    365505                        return $info; 
    366506                } 
     
    413553 
    414554                                        $search = $this->get_level_by_branch($catalog, $bcatalog['sub_branch'], (string) $level); 
    415                                          
     555 
    416556                                        if ($search !== false) 
    417557                                        { 
     
    427567                        return false; 
    428568                } 
    429                  
    430                 /*! 
    431                  
     569 
     570                /*! 
     571 
    432572                        @function get_actual_catalog 
    433                         @abstract Returns the information about the Catalog that is  
     573                        @abstract Returns the information about the Catalog that is 
    434574                                instantiated 
    435575 
    436576                        @author Raphael Derosso Pereira 
    437                  
     577 
    438578                */ 
    439579                function get_actual_catalog() 
     
    442582                        return $catalog; 
    443583                } 
    444                  
    445                 /*! 
    446                  
     584 
     585                /*! 
     586 
    447587                        @function set_catalog 
    448588                        @abstract Sets the actual catalog 
    449589                        @author Raphael Derosso Pereira 
    450                          
     590 
    451591                        @param array $to_catalog The catalog in the format returned by 
    452592                                get_available_tree or the level 
    453                  
     593 
    454594                */ 
    455595                function set_catalog(& $to_catalog ) 
     
    477617                                $level = $this->get_level_by_branch($to_catalog, $this->tree['branches']); 
    478618                        } 
    479                          
     619 
     620                        $lvl_vector = explode('.', $level); 
     621                        $id = $lvl_vector[1]; 
     622 
    480623                        switch($catalog['type']) 
    481624                        { 
     
    499642                                                $call .= ','.implode(',',$args); 
    500643                                        } 
    501                                          
     644 
    502645                                        $call .= ');'; 
    503                                          
     646 
    504647//                                      print_r($catalog); 
    505648//                                      echo '<br><br><b>Setando Catalogo '.$catalog['name'].': </b>'.$call.'<br>'; 
    506649 
    507650                                        eval($call); 
    508                                                                  
     651 
    509652                                        return $catalog; 
    510                                          
     653 
    511654                                default: return false; 
    512655                        } 
    513656                } 
    514                  
     657 
    515658 
    516659 
     
    518661                 *                Methods to set general fields                      * 
    519662                \*********************************************************************/ 
    520                  
    521                 /*! 
    522                  
     663 
     664                /*! 
     665 
    523666                        @function add_vcard 
    524667                        @abstract Insert a VCard to the squema 
     
    526669                        @param string $uploaded_file The path to the file that were 
    527670                                uploaded. 
    528                  
     671 
    529672                */ 
    530673                function add_vcard ( $uploaded_file ) 
     
    533676 
    534677 
    535                  
     678 
    536679                /*********************************************************************\ 
    537680                 *                Methods to get general data                        * 
    538681                \*********************************************************************/ 
    539                  
     682 
    540683        } 
    541684?> 
  • trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php

    r167 r284  
    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                  
     26 
     27                // used to determine if a catalog is external 
     28                var $external; 
     29 
    2730                var $fields = array( 
    2831                        'id_contact'    => true, 
     
    4043                        'pgp_key'       => true, 
    4144                        'notes'         => true, 
    42                          
     45                        'department'    => true, 
     46 
     47                        'empNumber'     => true, 
     48 
    4349                        /* Array fields */ 
    4450                        'companies'     => true, 
     
    4753                        'connections'   => true 
    4854                ); 
    49                  
     55 
    5056                /* 
    51                  
     57 
    5258                        @function global_ldap_catalog 
    5359                        @abstract Constructor 
    5460                        @author Raphael Derosso Pereira 
    55                          
     61                        @author Mário César Kolling (external catalogs) 
     62 
    5663                        @param integer $id_source The ID of the LDAP source 
    57                          
     64                        @param string $context Ldap bind DN 
     65                        @param integer $external 0 = internal catalog, 1 = external catalog 
     66 
    5867                */ 
    59                 function bo_global_ldap_catalog ( $id_source, $context ) 
    60                 { 
     68                function bo_global_ldap_catalog ( $id_source, $context, $external = 0 ) 
     69                { 
     70 
     71                        $this->external = $external; 
     72 
    6173                        if (!function_exists('ldap_search')) 
    6274                        { 
    6375                                exit('PHP LDAP support Unavailable!'); 
    6476                        } 
    65                          
     77 
    6678                        $this->ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    67                          
    68                         $all_src = $this->ldap->get_all_ldap_sources(); 
     79 
     80                        if ($this->external) 
     81                        { 
     82                                $all_src = $this->ldap->get_external_ldap_sources(); 
     83                        } 
     84                        else 
     85                        { 
     86                                $all_src = $this->ldap->get_all_ldap_sources(); 
     87                        } 
    6988 
    7089                        if (!$all_src[$id_source] or !$context) 
     
    7594                        $this->src_info = $all_src[$id_source]; 
    7695                        $this->src_info['context'] = $context; 
    77                         $this->trans_table = $this->ldap->get_ldap_fields_association($id_source); 
    78                 } 
    79                  
     96 
     97                        if ($this->external) 
     98                        { 
     99                                $this->trans_table = $this->ldap->get_external_ldap_fields_association($id_source); 
     100                        } 
     101                        else 
     102                        { 
     103                                $this->trans_table = $this->ldap->get_ldap_fields_association($id_source); 
     104                        } 
     105                } 
     106 
    80107                /* 
    81                  
     108 
    82109                        @function find 
    83110                        @abstract Searches the LDAP directory for the specified fields with 
     
    85112                                that matches the rules. 
    86113                        @author Raphael Derosso Pereira 
    87                          
     114 
    88115                        @param array $what The fields to be taken 
    89116                        @param array $rules The rules to be match. See class.abo_catalog.inc.php 
     
    94121                                        'offset' => (integer) [NOT IMPLEMENTED] 
    95122                                ) 
    96                  
     123 
    97124                */ 
    98125                function find($what, $rules=false, $other=false) 
    99126                { 
    100127                        $restric_fields = $this->get_restrictions_without_branch($rules); 
    101                          
     128 
    102129                        $trans_f = $this->translate_fields($what, $restric_fields); 
    103                          
     130 
    104131                        foreach($trans_f as $orig => $field_a) 
    105132                        { 
     
    109136                                } 
    110137                        } 
    111                          
     138 
    112139                        $fields = array_unique($fields); 
    113                          
     140 
    114141                        $filter = $this->process_restrictions($rules, $trans_f); 
    115142 
    116143                        if(strstr($this->src_info['context'], "ldap://")) { 
    117144                                $refer_context  = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $this->src_info['context'])); 
    118                                 $host   = preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $this->src_info['context']);                              
     145                                $host   = preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $this->src_info['context']); 
    119146                                $this->src_info['host'] = $host; 
    120                                 //$this->src_info['acc'] = ''; 
    121                                 //$this->src_info['pw']  = '';                           
    122                         }                        
     147                                $this->src_info['acc'] = ''; 
     148                                $this->src_info['pw']  = ''; 
     149                        } 
    123150 
    124151                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], true); 
    125                          
     152 
    126153                        if (!$ldap) 
    127154                        { 
    128155                                return false; 
    129156                        } 
    130                          
    131                         $fields[]  ='phpgwAccountVisible'; 
    132                         $result_r = @ldap_search($ldap ,($refer_context  ? $refer_context  : $this->src_info['context']), $filter, $fields); 
     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); 
    133164 
    134165                        if (!$result_r) 
     
    136167                                return false; 
    137168                        } 
    138                          
     169 
    139170                        if ($other['order']) 
    140171                        { 
     
    150181                                } 
    151182                        } 
    152                          
     183 
    153184                        $result_u = ldap_get_entries($ldap, $result_r); 
    154                          
     185 
    155186                        $i = 0; 
    156187                        foreach ($result_u as $index => $result_p) 
    157188                        { 
    158                                 if ($index === 'count' or $index === 'dn' or $result_p['phpgwaccountvisible'][0] == '-1') 
     189                                if ($index === 'count' or $index === 'dn' or (!$this->external and $result_p['phpgwaccountvisible'][0] == '-1')) 
    159190                                { 
    160191                                        continue; 
    161192                                } 
    162                                  
     193 
    163194                                foreach ($trans_f as $orig => $trans) 
    164195                                { 
     
    178209                                $i++; 
    179210                        } 
    180                          
     211 
    181212                        return $return; 
    182213                } 
    183                  
     214 
    184215                /* 
    185                  
     216 
    186217                        @function translate_fields 
    187218                        @abstract Return the LDAP objectClass fields that corresponds to the 
    188219                                specified parameter fields 
    189220                        @author Raphael Derosso Pereira 
    190                          
     221 
    191222                        @param array $fields The fields in the standard ContactCenter format 
    192223                        @param array $rules The rules 
    193                  
     224 
    194225                */ 
    195226                function translate_fields ( $fields, &$restric_fields ) 
    196227                { 
    197228                        $return = array(); 
    198                          
     229 
    199230                        $i = 0; 
    200231                        foreach ($fields as $field) 
     
    204235                                        continue; 
    205236                                } 
    206                                  
     237 
    207238                                if (!is_array($this->trans_table[$field])) 
    208239                                { 
    209240                                        $reference = $this->trans_table[$field]; 
    210                                          
     241 
    211242                                        reset($restric_fields); 
    212243                                        while(list(,$field_r) = each($restric_fields)) 
    213244                                        { 
     245 
    214246                                                if ($field_r['field'] === $reference and array_key_exists($field_r['value'], $this->trans_table[$reference])) 
    215247                                                { 
     
    220252                                else 
    221253                                { 
     254 
    222255                                        if (!is_array($return[$field])) 
    223256                                        { 
     
    230263                                } 
    231264                        } 
    232                          
     265 
    233266                        if (count($return)) 
    234267                        { 
    235268                                return $return; 
    236269                        } 
    237                          
     270 
    238271                        return false; 
    239272                } 
    240                  
     273 
    241274                /* 
    242                  
     275 
    243276                        @function process_restrictions 
    244277                        @abstract Returns a LDAP filter string that corresponds to the 
    245278                                specified restriction rules 
    246279                        @author Raphael Derosso Pereira 
    247                          
     280 
    248281                        @param string $rules The restriction rules 
    249                  
     282 
    250283                */ 
    251284                function process_restrictions( $rules, &$trans_table, $join_type='&' ) 
     
    255288                                return null; 
    256289                        } 
    257                          
     290 
    258291                        foreach($rules as $rule_i => $rule) 
    259292                        { 
     
    267300                                                                $join = '|'; 
    268301                                                                break; 
    269                                                                  
     302 
    270303                                                        case 'AND': 
    271304                                                                $join = '&'; 
    272305                                                                break; 
    273                                                                  
     306 
    274307                                                        case 'NOT': 
    275308                                                                $join = '!'; 
    276309                                                                break; 
    277                                                                  
     310 
    278311                                                        default: 
    279312                                                                $join = $join_type; 
     
    281314                                                $return_t[] = $this->process_restrictions($rule['sub_branch'], $trans_table, $join); 
    282315                                                break; 
    283                                                  
     316 
    284317                                        case '=': 
    285318                                                if (array_key_exists($rule['field'], $trans_table)) 
     
    292325                                                } 
    293326                                                break; 
    294                                          
    295                                         case '!=':       
     327 
     328                                        case '!=': 
    296329                                                if (array_key_exists($rule['field'], $trans_table)) 
    297330                                                { 
     
    303336                                                } 
    304337                                                break; 
    305                                          
     338 
    306339                                        case '<=': 
    307340                                        case '<': 
     
    315348                                                } 
    316349                                                break; 
    317                                          
     350 
    318351                                        case '>': 
    319352                                        case '>=': 
     
    327360                                                } 
    328361                                                break; 
    329                                                  
     362 
    330363                                        case 'NULL': 
    331364                                                if (array_key_exists($rule['field'], $trans_table)) 
     
    338371                                                } 
    339372                                                break; 
    340                                          
     373 
    341374                                        case 'IN': 
    342375                                                if (array_key_exists($rule['field'], $trans_table)) 
     
    358391                                                        $value_1 = strtoupper(str_replace('%', '*', $rule['value'])); 
    359392                                                        $value_2 = strtolower($value_1); 
    360                                                          
     393 
    361394                                                        foreach($trans_table[$rule['field']] as $field) 
    362395                                                        { 
     
    367400                                                } 
    368401                                                break; 
    369                                                  
     402 
    370403*/                                      case 'LIKE': 
    371404                                                if (array_key_exists($rule['field'], $trans_table)) 
    372405                                                { 
    373406                                                        $value = str_replace('%', '*', $rule['value']); 
    374                                                          
     407 
    375408                                                        foreach($trans_table[$rule['field']] as $field) 
    376409                                                        { 
     
    380413                                                } 
    381414                                                break; 
    382                                                  
     415 
    383416                                        case 'NOT NULL': 
    384417                                                if (array_key_exists($rule['field'], $trans_table)) 
     
    391424                                                } 
    392425                                                break; 
    393                                          
     426 
    394427                                        case 'NOT IN': 
    395428                                                if (array_key_exists($rule['field'], $trans_table)) 
     
    411444                                                        $value_1 = strtoupper(str_replace('%', '*', $rule['value'])); 
    412445                                                        $value_2 = strtolower($value_1); 
    413                                                          
     446 
    414447                                                        foreach($trans_table[$rule['field']] as $field) 
    415448                                                        { 
     
    425458                                                { 
    426459                                                        $value = str_replace('%', '*', $rule['value']); 
    427                                                          
     460 
    428461                                                        foreach($trans_table[$rule['field']] as $field) 
    429462                                                        { 
     
    435468                                } 
    436469                        } 
    437                          
     470 
    438471                        if (count($return_t)) 
    439472                        { 
     
    453486 
    454487                /*! 
    455                  
     488 
    456489                        @function get_restrictions_without_branch 
    457490                        @abstract Returns an array containing the restrictions ignoring the 
    458491                                branches 
    459492                        @author Raphael Derosso Pereira 
    460                          
     493 
    461494                        @param array $restrictions The restrictions 
    462                  
     495 
    463496                */ 
    464497                function get_restrictions_without_branch(&$restrictions) 
     
    468501                                return null; 
    469502                        } 
    470                          
     503 
    471504                        $fields = array(); 
    472                          
     505 
    473506                        foreach ($restrictions as $restrict_data) 
    474507                        { 
     
    478511                                                $fields = array_merge($fields, $this->get_restrictions_without_branch($restrict_data['sub_branch'])); 
    479512                                                break; 
    480                                                  
     513 
    481514                                        case '=': 
    482                                         case '!=':       
     515                                        case '!=': 
    483516                                        case '<=': 
    484517                                        case '<': 
     
    495528                                                array_push($fields, $restrict_data); 
    496529                                                break; 
    497                                                  
     530 
    498531                                        default: 
    499                                                 exit('Error in '.__FILE__.' on '.__LINE__.'<br>The restriction type passed was: '.$restrict_data['type']);                                       
    500                                 } 
    501                         } 
    502                          
     532                                                exit('Error in '.__FILE__.' on '.__LINE__.'<br>The restriction type passed was: '.$restrict_data['type']); 
     533                                } 
     534                        } 
     535 
    503536                        return $fields; 
    504537                } 
    505                  
    506                  
     538 
     539 
    507540                /*********************************************************************\ 
    508541                 *                        Methods to Get Data                        * 
    509542                \*********************************************************************/ 
    510                  
    511          
     543 
     544 
    512545                /*! 
    513                  
     546 
    514547                 @function get_single_entry 
    515548                 @abstract Returns all information requested about one contact 
    516549                 @author Raphael Derosso Pereira 
    517                       
     550 
    518551                 @param integer $id_contact The contact ID 
    519552                 @param array $fields The array returned by get_fields with true 
    520553                        on the fields to be taken. 
    521                          
     554 
    522555                */ 
    523556                function get_single_entry ( $id_contact, $fields ) 
    524557                { 
    525                         if (!is_array($fields))  
    526                         { 
    527                                 if (is_object($GLOBALS['phpgw']->log))  
     558                        if (!is_array($fields)) 
     559                        { 
     560                                if (is_object($GLOBALS['phpgw']->log)) 
    528561                                { 
    529562                                        $GLOBALS['phpgw']->log->message(array( 
     
    531564                                                'line' => __LINE__, 
    532565                                                'file' => __FILE__)); 
    533                                          
     566 
    534567                                        $GLOBALS['phpgw']->log->commit(); 
    535568                                } 
    536                                 else  
     569                                else 
    537570                                { 
    538571                                        exit('Argument Error on: <br>File:'.__FILE__.'<br>Line:'.__LINE__.'<br>'); 
    539572                                } 
    540573                        } 
    541                          
     574 
    542575                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'],$this->src_info['acc'],$this->src_info['pw'],true); 
    543                          
     576 
    544577                        if (!$ldap) 
    545578                        { 
    546579                                return false; 
    547580                        } 
    548                          
     581 
    549582                        $resource = ldap_read($ldap, $id_contact, 'objectClass='.$this->src_info['obj']); 
    550583                        $n_entries = ldap_count_entries($ldap, $resource); 
     
    553586                                return false; 
    554587                        } 
    555                          
     588 
    556589                        $first_entry = ldap_first_entry($ldap, $resource); 
    557590                        $contact = ldap_get_attributes($ldap,$first_entry); 
    558                         if($contact['jpegPhoto']){       
    559                                 $contact['jpegPhoto'] = ldap_get_values_len ($ldap, $first_entry, "jpegPhoto");  
     591                        if($contact['jpegPhoto']){ 
     592                                $contact['jpegPhoto'] = ldap_get_values_len ($ldap, $first_entry, "jpegPhoto"); 
    560593                        } 
    561594 
    562595//                      print_r($contact); 
    563                          
     596 
    564597                //      $contact_data = $this->fields; 
    565                          
     598 
    566599                        foreach($fields as $field => $trueness) 
    567600                        { 
     
    571604                                        continue; 
    572605                                } 
    573                                  
     606 
    574607                                switch ($field) 
    575608                                { 
     
    580613                                                $l_fields['department']    = $this->trans_table['contact.business_info.department']; 
    581614                                                $l_fields['company_notes'] = $this->trans_table['contact.company.company_notes']; 
    582                                                  
     615 
    583616                                                $contact_data['companies'] = array(); 
    584617                                                foreach($l_fields as $l_field => $l_value) 
     
    588621                                                                continue; 
    589622                                                        } 
    590                                                          
    591                                                         $contact_data['companies']['company1'][$l_field] = $contact[$l_value[0]][0]; 
    592                                                 } 
    593                                                  
     623 
     624                                                        $contact_data['companies']['company1'][$l_field] = utf8_decode($contact[$l_value[0]][0]); 
     625                                                } 
     626 
    594627                                                if (!(count($contact_data['companies']))) 
    595628                                                { 
     
    597630                                                } 
    598631                                                break; 
    599                                          
     632 
    600633                                        case 'relations': 
    601634                                                unset($l_fields); 
     
    604637                                                        unset($contact_data['relations']); 
    605638                                                } 
    606                                                  
     639 
    607640                                                $contact_data['relations'] = array(); 
    608641                                                if (!is_array($this->trans_table['contact.contact_related.names_ordered'])) 
     
    612645                                                                continue; 
    613646                                                        } 
    614                                                          
     647 
    615648                                                        $i = 1; 
    616649                                                        foreach($trans as $l_type => $l_type_fields) 
     
    620653                                                                        continue; 
    621654                                                                } 
    622                                                                  
     655 
    623656                                                                $contact_data['relations']['relation'.$i]['type'] = $l_type; 
    624                                                                 $contact_data['relations']['relation'.$i]['names_ordered'] = $contact[$l_type_fields[0]][0]; 
     657                                                                $contact_data['relations']['relation'.$i]['names_ordered'] = utf8_decode($contact[$l_type_fields[0]][0]); 
    625658                                                                $i++; 
    626659                                                        } 
    627660                                                } 
    628                                                  
     661 
    629662                                                if (!(count($contact_data['relations']))) 
    630663                                                { 
     
    632665                                                } 
    633666                                                break; 
    634                                          
     667 
    635668                                        case 'addresses': 
    636669                                                unset($l_fields); 
     
    661694                                                                        continue; 
    662695                                                                } 
    663                                                                  
     696 
    664697                                                                $i = 1; 
    665698                                                                foreach($trans as $l_type => $l_type_fields) 
     
    669702                                                                                continue; 
    670703                                                                        } 
    671                                                                          
     704 
    672705                                                                        $contact_data['addresses']['address'.$i]['type'] = $l_type; 
    673                                                                         $contact_data['addresses']['address'.$i][$l_field] = $contact[$l_type_fields[0]][0]; 
     706                                                                        $contact_data['addresses']['address'.$i][$l_field] = utf8_decode($contact[$l_type_fields[0]][0]); 
    674707                                                                        $i++; 
    675708                                                                } 
     
    677710                                                        else 
    678711                                                        { 
    679                                                                 $contact_data['addresses']['address1'][$l_field] = $contact[$l_value[0]][0]; 
    680                                                         } 
    681                                                 } 
    682                                                  
     712                                                                $contact_data['addresses']['address1'][$l_field] = utf8_decode($contact[$l_value[0]][0]); 
     713                                                        } 
     714                                                } 
     715 
    683716                                                if (!(count($contact_data['addresses']))) 
    684717                                                { 
     
    686719                                                } 
    687720                                                break; 
    688                                          
     721 
    689722                                        case 'connections': 
    690723                            $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
     
    707740                                                                        continue; 
    708741                                                                } 
    709                                                                  
     742 
    710743                                                                $i = 1; 
    711744                                                                foreach($trans as $l_type => $l_type_fields) 
     
    715748                                                                                continue; 
    716749                                                                        } 
    717                                                                          
     750 
    718751                                                                        switch ($l_type) 
    719752                                                                        { 
     
    726759                                                                        } 
    727760                                                                        $contact_data['connections']['connection'.$i]['type'] = $l_type; 
    728                                                                         $contact_data['connections']['connection'.$i][$l_field] = $contact[$l_type_fields[0]][0]; 
     761                                                                        $contact_data['connections']['connection'.$i][$l_field] = utf8_decode($contact[$l_type_fields[0]][0]); 
    729762                                                                        $i++; 
    730763                                                                } 
     
    732765                                                        else 
    733766                                                        { 
    734                                                                 $contact_data['connections']['connection1'][$l_field] = $contact[$l_value[0]][0]; 
    735                                                         } 
    736                                                 } 
    737                                                  
     767                                                                $contact_data['connections']['connection1'][$l_field] = utf8_decode($contact[$l_value[0]][0]); 
     768                                                        } 
     769                                                } 
     770 
    738771                                                if (!(count($contact_data['connections']))) 
    739772                                                { 
     
    741774                                                } 
    742775                                                break; 
    743                                          
     776 
    744777                                        case 'prefix': 
    745778                                                unset($l_fields); 
     
    750783                                                        continue; 
    751784                                                } 
    752                                                  
    753                                                 $contact_data['prefix'] = $contact[$l_fields[0]][0]; 
    754                                                 break; 
    755                                                  
     785 
     786                                                $contact_data['prefix'] = utf8_decode($contact[$l_fields[0]][0]); 
     787                                                break; 
     788 
    756789                                        case 'suffix': 
    757790                                                unset($l_fields); 
     
    762795                                                        continue; 
    763796                                                } 
    764                                                  
    765                                                 $contact_data['suffix'] = $contact[$l_fields[0]][0]; 
    766                                                 break; 
    767                                                  
     797 
     798                                                $contact_data['suffix'] = utf8_decode($contact[$l_fields[0]][0]); 
     799                                                break; 
     800 
    768801                                        case 'status': 
    769802                                                unset($l_fields); 
     
    774807                                                        continue; 
    775808                                                } 
    776                                                  
    777                                                 $contact_data['status'] = $contact[$l_fields[0]][0]; 
    778                                                 break; 
    779                                                  
     809 
     810                                                $contact_data['status'] = utf8_decode($contact[$l_fields[0]][0]); 
     811                                                break; 
     812 
    780813                                                case 'photo': 
    781814                                                unset($l_fields); 
     
    786819                                                        continue; 
    787820                                                } 
    788                                                  
     821 
    789822                                                $contact_data['photo'] = $contact[$l_fields[0]][0]; 
    790                                                 break;                                                                                   
     823                                                break; 
    791824 
    792825                                        default: 
     
    798831                                                        continue; 
    799832                                                } 
    800                                                  
     833 
    801834                                                if(count($contact[$l_fields[0]]) > 1) 
    802                                                         $contact_data[$field] = $contact[$l_fields[0]]; 
     835                                                { 
     836                                                        $tmp = array(); 
     837                                                        foreach ($contact[$l_fields[0]] as $i => $j) 
     838                                                        { 
     839                                                                $tmp["$i"] = utf8_decode($j); 
     840                                                        } 
     841                                                        //$contact_data[$field] = $contact[$l_fields[0]]; 
     842                                                        $contact_data[$field] = $tmp; 
     843                                                } 
    803844                                                else 
    804                                                         $contact_data[$field] = $contact[$l_fields[0]][0]; 
    805  
    806                                                 break; 
    807                                 } 
    808                         } 
    809                          
     845                                                        $contact_data[$field] = utf8_decode($contact[$l_fields[0]][0]); 
     846 
     847                                                break; 
     848                                } 
     849                        } 
     850 
    810851                        if (!is_array($contact_data)) 
    811852                        { 
    812853                                return false; 
    813854                        } 
    814                          
     855 
    815856                        return $contact_data; 
    816857                } 
    817                  
     858 
     859                /*! 
     860 
     861                 @function get_all_entries 
     862                 @abstract Returns all information requested about a bunch of contacts, usually a page 
     863                 @author Raphael Derosso Pereira 
     864                 @author Mário César Kolling 
     865 
     866                 @param string $filter Filter (returned by generate_filter). 
     867                 @param array $fields The array returned by get_fields with true 
     868                        on the fields to be taken. 
     869 
     870                */ 
     871                function get_all_entries($filter, $fields) 
     872                { 
     873                        if (!is_array($fields)) 
     874                        { 
     875                                if (is_object($GLOBALS['phpgw']->log)) 
     876                                { 
     877                                        $GLOBALS['phpgw']->log->message(array( 
     878                                                'text' => 'F-BadcontactcenterParam, wrong get_single_entry parameters type.', 
     879                                                'line' => __LINE__, 
     880                                                'file' => __FILE__)); 
     881 
     882                                        $GLOBALS['phpgw']->log->commit(); 
     883                                } 
     884                                else 
     885                                { 
     886                                        exit('Argument Error on: <br>File:'.__FILE__.'<br>Line:'.__LINE__.'<br>'); 
     887                                } 
     888                        } 
     889 
     890                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'],$this->src_info['acc'],$this->src_info['pw'],true); 
     891 
     892                        if (!$ldap) 
     893                        { 
     894                                return false; 
     895                        } 
     896 
     897                        $resource = @ldap_search($ldap, $this->src_info['dn'], $filter); 
     898                        $n_entries = @ldap_count_entries($ldap, $resource); 
     899 
     900                        ldap_sort($ldap, $resource, 'cn'); 
     901 
     902                        if ( $n_entries < 1) 
     903                        { 
     904                                return false; 
     905                        } 
     906 
     907                        $contacts = array(); 
     908 
     909                        for ($entry = ldap_first_entry($ldap, $resource); 
     910                                 $entry != false; 
     911                                 $entry = ldap_next_entry($ldap, $entry)) 
     912                        { 
     913                                $contact = ldap_get_attributes($ldap,$entry); 
     914                                if($contact['jpegPhoto']){ 
     915                                        $contact['jpegPhoto'] = ldap_get_values_len ($ldap, $entry, "jpegPhoto"); 
     916                                } 
     917 
     918                                foreach($fields as $field => $trueness) 
     919                                { 
     920                                        if (!$trueness) 
     921                                        { 
     922                                                //unset($contact_data[$field]); 
     923                                                continue; 
     924                                        } 
     925 
     926                                        switch ($field) 
     927                                        { 
     928                                                case 'companies': 
     929                                                        unset($l_fields); 
     930                                                        $l_fields['company_name']  = $this->trans_table['contact.company.company_name']; 
     931                                                        $l_fields['title']         = $this->trans_table['contact.business_info.title']; 
     932                                                        $l_fields['department']    = $this->trans_table['contact.business_info.department']; 
     933                                                        $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']; 
     937 
     938                                                        $contact_data['companies'] = array(); 
     939                                                        foreach($l_fields as $l_field => $l_value) 
     940                                                        { 
     941                                                                if (!( $contact[$l_value[0]][0])) 
     942                                                                { 
     943                                                                        continue; 
     944                                                                } 
     945 
     946                                                                $contact_data['companies']['company1'][$l_field] = utf8_decode($contact[$l_value[0]][0]); 
     947                                                        } 
     948 
     949                                                        if (!(count($contact_data['companies']))) 
     950                                                        { 
     951                                                                unset($contact_data['companies']); 
     952                                                        } 
     953                                                        break; 
     954 
     955                                                case 'relations': 
     956                                                        unset($l_fields); 
     957                                                        if (!$this->trans_table['contact.contact_related.names_ordered']) 
     958                                                        { 
     959                                                                unset($contact_data['relations']); 
     960                                                        } 
     961 
     962                                                        $contact_data['relations'] = array(); 
     963                                                        if (!is_array($this->trans_table['contact.contact_related.names_ordered'])) 
     964                                                        { 
     965                                                                if (!($trans = $this->trans_table[$this->trans_table['contact.contact_related.names_ordered']])) 
     966                                                                { 
     967                                                                        continue; 
     968                                                                } 
     969 
     970                                                                $i = 1; 
     971                                                                foreach($trans as $l_type => $l_type_fields) 
     972                                                                { 
     973                                                                        if (!($contact[$l_type_fields[0]][0])) 
     974                                                                        { 
     975                                                                                continue; 
     976                                                                        } 
     977 
     978                                                                        $contact_data['relations']['relation'.$i]['type'] = $l_type; 
     979                                                                        $contact_data['relations']['relation'.$i]['names_ordered'] = utf8_decode($contact[$l_type_fields[0]][0]); 
     980                                                                        $i++; 
     981                                                                } 
     982                                                        } 
     983 
     984                                                        if (!(count($contact_data['relations']))) 
     985                                                        { 
     986                                                                unset($contact_data['relations']); 
     987                                                        } 
     988                                                        break; 
     989 
     990                                                case 'addresses': 
     991                                                        unset($l_fields); 
     992                                                        $l_fields['address1'] = $this->trans_table['contact.address.address1']; 
     993                                                        $l_fields['address2'] = $this->trans_table['contact.address.address2']; 
     994                                                        $l_fields['complement'] = $this->trans_table['contact.address.complement']; 
     995                                                        $l_fields['address_other'] = $this->trans_table['contact.address.address_other']; 
     996                                                        $l_fields['postal_code'] = $this->trans_table['contact.address.postal_code']; 
     997                                                        $l_fields['po_box'] = $this->trans_table['contact.address.po_box']; 
     998                                                        $l_fields['id_city'] = $this->trans_table['contact.address.city.id_city']; 
     999                                                        $l_fields['city_name'] = $this->trans_table['contact.address.city.city_name']; 
     1000                                                        $l_fields['city_timezone'] = $this->trans_table['contact.address.city.city_timezone']; 
     1001                                                        $l_fields['city_geo_location'] = $this->trans_table['contact.address.city.city_geo_location']; 
     1002                                                        $l_fields['id_state'] = $this->trans_table['contact.address.city.state.id_state']; 
     1003                                                        $l_fields['state_name'] = $this->trans_table['contact.address.city.state.state_name']; 
     1004                                                        $l_fields['state_symbol'] = $this->trans_table['contact.address.city.state.state_symbol']; 
     1005                                                        $l_fields['id_country'] = $this->trans_table['contact.address.city.country.id_country']; 
     1006                                                        $l_fields['country_name'] = $this->trans_table['contact.address.city.country.country_name']; 
     1007                                                        $l_fields['address_is_default'] = $this->trans_table['contact.address.address_is_default']; 
     1008 
     1009                                                        $contact_data['addresses'] = array(); 
     1010                                                        foreach($l_fields as $l_field => $l_value) 
     1011                                                        { 
     1012                                                                if (!is_array($l_value)) 
     1013                                                                { 
     1014                                                                        if (!($trans = $this->trans_table[$l_value])) 
     1015                                                                        { 
     1016                                                                                continue; 
     1017                                                                        } 
     1018 
     1019                                                                        $i = 1; 
     1020                                                                        foreach($trans as $l_type => $l_type_fields) 
     1021                                                                        { 
     1022                                                                                if (!($contact[$l_type_fields[0]][0])) 
     1023                                                                                { 
     1024                                                                                        continue; 
     1025                                                                                } 
     1026 
     1027                                                                                $contact_data['addresses']['address'.$i]['type'] = $l_type; 
     1028                                                                                $contact_data['addresses']['address'.$i][$l_field] = utf8_decode($contact[$l_type_fields[0]][0]); 
     1029                                                                                $i++; 
     1030                                                                        } 
     1031                                                                } 
     1032                                                                else 
     1033                                                                { 
     1034                                                                        $contact_data['addresses']['address1'][$l_field] = utf8_decode($contact[$l_value[0]][0]); 
     1035                                                                } 
     1036                                                        } 
     1037 
     1038                                                        if (!(count($contact_data['addresses']))) 
     1039                                                        { 
     1040                                                                unset($contact_data['addresses']); 
     1041                                                        } 
     1042                                                        break; 
     1043 
     1044                                                case 'connections': 
     1045                                    $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
     1046                                    if (!is_array($preferences)) 
     1047                                    { 
     1048                                                                $preferences['personCardEmail'] = 1; 
     1049                                                                $preferences['personCardPhone'] = 2; 
     1050                                                        } 
     1051                                                        unset($l_fields); 
     1052                                                        $l_fields['connection_name'] = $this->trans_table['contact.connection.connection_name']; 
     1053                                                        $l_fields['connection_value'] = $this->trans_table['contact.connection.connection_value']; 
     1054 
     1055                                                        $contact_data['connections'] = array(); 
     1056                                                        foreach($l_fields as $l_field => $l_value) 
     1057                                                        { 
     1058                                                                if (!is_array($l_value)) 
     1059                                                                { 
     1060                                                                        if (!($trans = $this->trans_table[$l_value])) 
     1061                                                                        { 
     1062                                                                                continue; 
     1063                                                                        } 
     1064 
     1065                                                                        $i = 1; 
     1066                                                                        foreach($trans as $l_type => $l_type_fields) 
     1067                                                                        { 
     1068                                                                                if (!($contact[$l_type_fields[0]][0])) 
     1069                                                                                { 
     1070                                                                                        continue; 
     1071                                                                                } 
     1072 
     1073                                                                                switch ($l_type) 
     1074                                                                                { 
     1075                                                                                        case 'email': 
     1076                                                                                        $contact_data['connections']['connection'.$i]['id_type'] = $preferences['personCardEmail']; 
     1077                                                                                        break; 
     1078 
     1079                                                                                        default: 
     1080                                                                                        $contact_data['connections']['connection'.$i]['id_type'] = $preferences['personCardPhone']; 
     1081                                                                                } 
     1082                                                                                $contact_data['connections']['connection'.$i]['type'] = $l_type; 
     1083                                                                                $contact_data['connections']['connection'.$i][$l_field] = utf8_decode($contact[$l_type_fields[0]][0]); 
     1084                                                                                $i++; 
     1085                                                                        } 
     1086                                                                } 
     1087                                                                else 
     1088                                                                { 
     1089                                                                        $contact_data['connections']['connection1'][$l_field] = utf8_decode($contact[$l_value[0]][0]); 
     1090                                                                } 
     1091                                                        } 
     1092 
     1093                                                        if (!(count($contact_data['connections']))) 
     1094                                                        { 
     1095                                                                unset($contact_data['connections']); 
     1096                                                        } 
     1097                                                        break; 
     1098 
     1099                                                case 'prefix': 
     1100                                                        unset($l_fields); 
     1101                                                        $l_fields = $this->trans_table['contact.prefixes.prefix']; 
     1102                                                        if (!$l_fields or !$contact[$l_fields[0]][0]) 
     1103                                                        { 
     1104                                                                unset($contact_data['prefix']); 
     1105                                                                continue; 
     1106                                                        } 
     1107 
     1108                                                        $contact_data['prefix'] = utf8_decode($contact[$l_fields[0]][0]); 
     1109                                                        break; 
     1110 
     1111                                                case 'suffix': 
     1112                                                        unset($l_fields); 
     1113                                                        $l_fields = $this->trans_table['contact.suffixes.suffix']; 
     1114                                                        if (!$l_fields or !$contact[$l_fields[0]][0]) 
     1115                                                        { 
     1116                                                                unset($contact_data['suffix']); 
     1117                                                                continue; 
     1118                                                        } 
     1119 
     1120                                                        $contact_data['suffix'] = utf8_decode($contact[$l_fields[0]][0]); 
     1121                                                        break; 
     1122 
     1123                                                case 'status': 
     1124                                                        unset($l_fields); 
     1125                                                        $l_fields = $this->trans_table['contact.status.status_name']; 
     1126                                                        if (!$l_fields or !$contact[$l_fields[0]][0]) 
     1127                                                        { 
     1128                                                                unset($contact_data['status']); 
     1129                                                                continue; 
     1130                                                        } 
     1131 
     1132                                                        $contact_data['status'] = utf8_decode($contact[$l_fields[0]][0]); 
     1133                                                        break; 
     1134 
     1135                                                        case 'photo': 
     1136                                                        unset($l_fields); 
     1137                                                        $l_fields = $this->trans_table['contact.photo']; 
     1138                                                        if (!$l_fields or !$contact[$l_fields[0]][0]) 
     1139                                                        { 
     1140                                                                unset($contact_data['photo']); 
     1141                                                                continue; 
     1142                                                        } 
     1143 
     1144                                                        $contact_data['photo'] = $contact[$l_fields[0]][0]; 
     1145                                                        break; 
     1146 
     1147                                                default: 
     1148                                                        unset($l_fields); 
     1149                                                        $l_fields = $this->trans_table['contact.'.$field]; 
     1150                                                        if (!$l_fields or !$contact[$l_fields[0]][0]) 
     1151                                                        { 
     1152                                                                unset($contact_data[$field]); 
     1153                                                                continue; 
     1154                                                        } 
     1155 
     1156                                                        if(count($contact[$l_fields[0]]) > 1) 
     1157                                                        { 
     1158                                                                $tmp = array(); 
     1159                                                                foreach ($contact[$l_fields[0]] as $i => $j) 
     1160                                                                { 
     1161                                                                        $tmp["$i"] = utf8_decode($j); 
     1162                                                                } 
     1163                                                                //$contact_data[$field] = $contact[$l_fields[0]]; 
     1164                                                                $contact_data[$field] = $tmp; 
     1165                                                        } 
     1166                                                        else 
     1167                                                                $contact_data[$field] = utf8_decode($contact[$l_fields[0]][0]); 
     1168 
     1169                                                        break; 
     1170 
     1171                                        } 
     1172                                } 
     1173 
     1174                                if (is_array($contact_data)) 
     1175                                { 
     1176                                        $contacts[ldap_get_dn($ldap, $entry)] = $contact_data; 
     1177                                } 
     1178 
     1179                        } 
     1180 
     1181                        return $contacts; 
     1182                } 
     1183 
    8181184                function get_multiple_entries ( $id_contacts, $fields, $other_data = false ) 
    8191185                { 
    8201186                        if (!is_array($id_contacts) or !is_array($fields) or ($other_data != false and !is_array($other_data))) 
    8211187                        { 
    822                                 if (is_object($GLOBALS['phpgw']->log))  
     1188                                if (is_object($GLOBALS['phpgw']->log)) 
    8231189                                { 
    8241190                                        $GLOBALS['phpgw']->log->message(array( 
     
    8261192                                                'line' => __LINE__, 
    8271193                                                'file' => __FILE__)); 
    828                                          
     1194 
    8291195                                        $GLOBALS['phpgw']->log->commit(); 
    8301196                                } 
     
    8331199                                } 
    8341200                        } 
    835                          
     1201 
    8361202                        $contacts = array(); 
    837          
     1203 
    8381204                        if ($other_data) 
    8391205                        { 
    8401206                                //TODO 
    8411207                        } 
    842          
    843                         foreach ($id_contacts as $id) 
    844                         { 
    845                                 $contacts[$id] = $this->get_single_entry($id,$fields); 
    846                         } 
    847                          
    848                         return $contacts; 
     1208 
     1209                        $filter = $this->generate_filter($id_contacts); 
     1210 
     1211                        //$teste = $this->get_all_entries($filter, $fields); 
     1212 
     1213                        return $this->get_all_entries($filter, $fields); 
     1214                } 
     1215 
     1216                function generate_filter($id_contacts) 
     1217                { 
     1218                        if (($size = count($id_contacts))) 
     1219                        { 
     1220                                $filter = '(&(objectClass='.$this->src_info['obj'] .  ')(|'; 
     1221                                for ($i = 0; $i < $size; $i++) 
     1222                                { 
     1223 
     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                                         */ 
     1228                                        preg_match('/^(\w*=[^,]*),.*$/', $id_contacts[$i], $cn); 
     1229 
     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                                 */ 
     1234                                        if ($cn[1]) 
     1235                                        { 
     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                                                 */ 
     1241                                                //foreach($cn as $key=>$value){ 
     1242                                        //      $cn[$key]=preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''", $value); 
     1243                                        //} 
     1244 
     1245                                                $filter .= '(' . str_replace(')', '\)', str_replace('(','\(',$cn[1])) . ')'; 
     1246                                        } 
     1247                                } 
     1248                                $filter .= '))'; 
     1249                        } 
     1250 
     1251                        return $filter; 
     1252 
    8491253                } 
    8501254 
     
    8761280                        return null; 
    8771281                } 
    878                  
     1282 
    8791283                function get_relations ($id_contact,$extra=false) 
    8801284                { 
    8811285                } 
    882                  
     1286 
    8831287                function get_addresses ( $id_contact,$extra=false ) 
    8841288                { 
    8851289                } 
    886                  
     1290 
    8871291                function get_connections ( $id_contact,$extra=false ) 
    8881292                { 
    8891293                } 
    890                  
     1294 
    8911295                function get_companies ( $id_contact, $extra=false ) 
    8921296                { 
    8931297                } 
    894                  
     1298 
    8951299                function get_all_prefixes (  ) 
    8961300                { 
    8971301                } 
    898                  
     1302 
    8991303                function get_all_suffixes (  ) 
    9001304                { 
    9011305                } 
    902                  
     1306 
    9031307                function get_all_status (  ) 
    9041308                { 
    9051309                } 
    906                  
     1310 
    9071311                function get_all_relations_types (  ) 
    9081312                { 
    9091313                } 
    910                  
     1314 
    9111315                function get_all_addresses_types (  ) 
    9121316                { 
    9131317                } 
    914                  
     1318 
    9151319                function get_all_connections_types (  ) 
    9161320                { 
    9171321                } 
    918                  
     1322 
    9191323                function get_vcard ( $id_contact ) 
    9201324                { 
    9211325                } 
    922                  
    923                  
    924                  
    925                  
     1326 
     1327 
     1328 
     1329 
    9261330                function get_global_tree ( $root ) 
    9271331                { 
    9281332                } 
    929          
     1333 
    9301334                function get_actual_brach (  ) 
    9311335                { 
    9321336                } 
    933          
     1337 
    9341338                function set_actual_branch ( $branch ) 
    9351339                { 
  • trunk/contactcenter/inc/class.bo_ldap_manager.inc.php

    r23 r284  
    1212  \***************************************************************************/ 
    1313 
    14          
     14 
    1515        /* 
    1616                This class is responsible for the LDAP control/generic functions and for 
    1717                configuration gathering 
    1818        */ 
    19  
    20         class bo_ldap_manager  
     19        include_once('class.Thread.inc.php'); 
     20 
     21        class bo_ldap_manager 
    2122        { 
    22                  
     23 
    2324                var $srcs; 
    2425 
    25                  
    2626                function bo_ldap_manager () 
    2727                { 
     28 
    2829                        if (!($this->srcs = $GLOBALS['phpgw']->session->appsession('bo_ldap_manager.srcs','contactcenter'))) 
    2930                        { 
    3031                                $c = CreateObject('phpgwapi.config','contactcenter'); 
    3132                                $data = $c->read_repository(); 
    32                                  
     33 
    3334                                if (!$data or $data['cc_global_source0'] !== 'ldap') 
    3435                                { 
     
    3637                                        return; 
    3738                                } 
    38                                  
     39 
    3940                                $this->srcs = array( 
    4041                                        1 => array( 
     
    4748                                                'branch' => strtolower('ou') 
    4849                                        ) 
     50 
    4951                                ); 
    5052                        } 
     
    5456                { 
    5557                } 
    56          
     58 
    5759                /* 
    58                  
     60 
    5961                        @function get_all_ldap_sources 
    6062                        @abstract Returns an array containing all LDAP sources informations 
    6163                        @author Raphael Derosso Pereira 
    62                  
     64 
    6365                        @return array All LDAP information 
    6466                                $return = array( 
     
    6769                                                'dn'   => (string), 
    6870                                                'acc'  => (string), 
    69                                                 'pw'   => (string)    
     71                                                'pw'   => (string) 
    7072                                        ), 
    7173                                        ... 
    7274                                ) 
    73                                  
     75 
    7476                        TODO: Return multiple sources... 
    7577                */ 
     
    7880                        return $this->srcs; 
    7981                } 
    80                  
     82 
     83                /* 
     84                * @function get_external_ldap_sources 
     85                * @author Mário César Kolling <mario.kolling@serpro.gov.br> 
     86                * @abstract returns an array with the external sources 
     87                * @return (array) the external sources 
     88                */ 
     89 
     90                function get_external_ldap_sources() 
     91                { 
     92                        include(PHPGW_INCLUDE_ROOT . '/contactcenter/setup/external_catalogs.inc.php' ); 
     93                        //include('external_catalogs.inc.php' ); 
     94                        return $external_srcs; 
     95                } 
     96 
     97                /* 
     98                 * @function get_ldap_fields_association 
     99                 * @abstract get the fields associantion for ldap source 
     100                 * @return an array with attribute mappings 
     101                 */ 
    81102                function get_ldap_fields_association ( $id_source ) 
    82103                { 
    83                          
     104 
    84105                        $op_iop = array( 
    85106                                'contact.id_contact'               => array('dn'), 
     
    90111                                'contact.family_names'             => array('sn'), 
    91112                                'contact.names_ordered'            => array('cn'),//,'displayName'), 
     113 
    92114                                'contact.suffixes.suffix'          => false, 
    93115                                'contact.birthdate'                => false, 
     
    95117                                'contact.pgp_key'                  => false, 
    96118                                'contact.notes'                    => false, 
    97                                 'contact.mail_forwarding_address' => array('mailForwardingAddress'), 
    98                                 'contact.account_type' => array('phpgwAccountType'), 
     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'), 
     123                                'contact.object_class'             => array('objectClass'), 
    99124                                'contact.business_info.title'      => array('title'), 
    100                                 'contact.business_info.department' => array('ou'), 
     125                                'contact.business_info.department' => array('ou'), // Setor do empregado... 
     126                                'contact.business_info.empNumber'  => array('employeeNumber'), // Matricula do empregado 
    101127                                'contact.company.company_name'     => array('o'), 
    102128                                'contact.company.company_notes'    => array('businessCategory'), 
    103                                  
     129 
    104130                                'contact.contact_related.names_ordered' => 'contact.contact_related.typeof_relation.contact_relation_name', 
    105131                                'contact.contact_related.typeof_relation.contact_relation_name' =>  array( 
     
    107133                                        'secretary' => array('secretary') 
    108134                                ), 
    109                                  
     135 
    110136                                'contact.address.address1'         => 'contact.address.typeof_address.contact_address_type_name', 
    111137                                'contact.address.typeof_address.contact_address_type_name' => array( 
    112138                                        'home' => array('street', 'st', 'postalAddress', 'homePostalAddress'), 
    113139                                ), 
    114                                  
     140 
    115141                                'contact.address.postal_code'      => 'contact.address.typeof_address.contact_address_type_name', 
    116142                                'contact.address.typeof_address.contact_address_type_name' => array( 
    117143                                        'home' => array('PostalCode'), 
    118144                                ), 
    119                                  
     145 
    120146                                'contact.address.city.city_name'   => 'contact.address.typeof_address.contact_address_type_name', 
    121147                                'contact.address.typeof_address.contact_address_type_name' => array( 
    122148                                        'home' => array('l'), 
    123149                                ), 
    124                                  
     150 
    125151                                'contact.address.city.state.state_name'       => 'contact.address.typeof_address.contact_address_type_name', 
    126152                                'contact.address.typeof_address.contact_address_type_name' => array( 
    127153                                        'home' => false, 
    128154                                ), 
    129                                  
     155 
    130156                                'contact.address.city.country.id_country'     => 'contact.address.typeof_address.contact_address_type_name', 
    131157                                'contact.address.typeof_address.contact_address_type_name' => array( 
    132158                                        'home' => array('c') 
    133159                                ), 
    134                                  
     160 
    135161                                'contact.connection.connection_value'         => 'contact.connection.typeof_connection.contact_connection_type_name', 
    136162                                'contact.connection.typeof_connection.contact_connection_type_name' => array ( 
     
    143169                                ), 
    144170                        ); 
    145                          
     171 
    146172                        return $op_iop; 
     173 
     174                } 
     175 
     176                /* 
     177                 * @function get_external_ldap_fields_association 
     178                 * @author Mário César Kolling <mario.kolling@serpro.gov.br> 
     179                 * @abstract get the fields association for an external ldap_source 
     180                 * @return an array with attribute mappings 
     181                 */ 
     182                function get_external_ldap_fields_association ( $id_source ) 
     183                { 
     184                        include(PHPGW_INCLUDE_ROOT . '/contactcenter/setup/external_catalogs.inc.php' ); 
     185                        //include('external_catalogs.inc.php' ); 
     186                        return $external_mappings[$id_source]; 
     187                } 
     188 
     189                /* 
     190                 * @function test_connection 
     191                 * @author Mário César Kolling <mario.kolling@serpro.gov.br> 
     192                 * @abstract Test if we can bind to a ldap server in a reasonable time 
     193                 * @param (string) $host ldap server's hostname 
     194                 * @param (string) $account ldap bind dn 
     195                 * @param (string) $password a bind dn's password 
     196                 * @return (array) an array with the answer from the subprocess, null otherwise 
     197                 */ 
     198                function test_connection($host, $account, $password, $timeout = 5) 
     199                { 
     200                        //opens a subprocess for nonblocking bind 
     201                        $tsearch = Thread::Create('class.ldap_assync.inc.php', array('host'     => $host, 
     202                                                                                                                                'account'       => $account, 
     203                                                                                                                                'password'      => $password 
     204                                                                                                                                ) 
     205                        ); 
     206 
     207                        // It's problably more efficient to let method readResponse control the timeout through 
     208                        // stream_select native timeout. 
     209                        $response = NULL; 
     210                        for ($i = 0; $i < $timeout; $i++) 
     211                        { 
     212                                if ($tsearch->isActive()) 
     213                                { 
     214                                        sleep(1); 
     215                                        if (($response = $tsearch->readResponse()) !== NULL) 
     216                                        { 
     217                                                $tsearch->close(); 
     218                                                return $response; 
     219                                        } 
     220 
     221                                } 
     222                                else 
     223                                { 
     224                                        $response = $tsearch->readResponse(); 
     225                                        break; 
     226                                } 
     227                        } 
     228 
     229                        $tsearch->close(); 
     230                        return null; 
    147231                } 
    148232 
    149233                /*! 
    150                  
     234 
    151235                        @function get_ldap_tree 
    152236                        @abstract Returns the LDAP tree corresponding to the specified level 
    153237                        @author Raphael Derosso Pereira 
    154                          
     238 
    155239                        @param (integer) $id_source The ID of the LDAP source 
    156                          
     240 
    157241                        @param (string)  $context The context to be used as root branch 
    158                                  
     242 
    159243                        @param (boolean) $recursive Make it a recursive construction. 
    160244                                CAUTION! This is EXTREMELY SLOW on large LDAP databases, 
    161245                                specially when they're not indexed 
    162                 */               
    163                 function get_ldap_tree($id_source, $context = false, $recursive = false)  
     246                */ 
     247                function get_ldap_tree($id_source, $context = false, $recursive = false) 
    164248                { 
    165249                        if (!$this->srcs[$id_source]) 
     
    167251                                return null; 
    168252                        } 
    169                          
     253 
    170254                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->srcs[$id_source]['host'], $this->srcs[$id_source]['acc'],$this->srcs[$id_source]['pw'], false); 
    171255                        if (!$ldap) 
     
    173257                                return false; 
    174258                        } 
    175                          
     259 
    176260                        if ($recursive) 
    177261                        { 
     
    181265                                return $tree; 
    182266                        } 
    183                          
    184                         return $this->get_ldap_tree_level($id_source, $ldap, $context, $this->srcs[$id_source]['obj'],$this->srcs[$id_source]['branch']); 
    185                 } 
    186  
     267 
     268                        return $this->get_ldap_tree_level($id_source, $ldap, $context, $this->srcs[$id_source]['obj'],$this->srcs[$id_source]['branch'], 0); 
     269                } 
     270 
     271                /*! 
     272 
     273                        @function get_external_ldap_tree 
     274                        @abstract Returns the LDAP external tree corresponding to the specified level 
     275                        @author Mário César Kolling <mario.kolling@serpro.gov.br> 
     276                        @param (integer) $id_source The ID of the external LDAP source 
     277                        @param (string)  $context The context to be used as root branch 
     278                        @param (boolean) $recursive Make it a recursive construction. 
     279                                CAUTION! This is EXTREMELY SLOW on large LDAP databases, 
     280                                specially when they're not indexed 
     281                */ 
     282                function get_external_ldap_tree($id_source, $context = false, $recursive = false) 
     283                { 
     284 
     285 
     286                        include(PHPGW_INCLUDE_ROOT . '/contactcenter/setup/external_catalogs.inc.php' ); 
     287                        //include('external_catalogs.inc.php' ); 
     288 
     289                        if (!$external_srcs[$id_source]) 
     290                        { 
     291                                return null; 
     292                        } 
     293 
     294                        // calls test_connection first. If succeeded continue, return error message otherwise. 
     295                        if (!($response = $this->test_connection($external_srcs[$id_source]['host'], $external_srcs[$id_source]['acc'], $external_srcs[$id_source]['pw'], 10))) 
     296                        { 
     297                                return array( 
     298                                        'msg'           =>      lang("Catalog %1 temporarily unavailable. Please try again later!", $external_srcs[$id_source]['name']), 
     299                                        'timeout'       =>      'true' 
     300                                ); 
     301                        } 
     302 
     303                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($external_srcs[$id_source]['host'], $external_srcs[$id_source]['acc'],$external_srcs[$id_source]['pw'], false); 
     304                        if (!$ldap) 
     305                        { 
     306                                return false; 
     307                        } 
     308 
     309                        // Option recursive commented out 
     310                        /* 
     311                        if ($recursive) 
     312                        { 
     313                                $tree = $this->get_ldap_tree_recursive($ldap, $context, $this->srcs[$id_source]['obj'],$this->srcs[$id_source]['branch']); 
     314                                $tree['recursive'] = true; 
     315 
     316                                return $tree; 
     317                        } 
     318                        */ 
     319 
     320                        return $this->get_ldap_tree_level($id_source, $ldap, $context, $external_srcs[$id_source]['obj'],$external_srcs[$id_source]['branch'], 1); 
     321                } 
    187322 
    188323                /*! 
     
    201336                                return null; 
    202337                        } 
    203                          
     338 
    204339                        $count = ldap_count_entries($resource,$result_res); 
    205340                        if ( $count == 0 ) 
     
    218353                                } 
    219354                        } 
    220                          
     355 
    221356                        $entries = ldap_get_entries($resource, $result_res); 
    222                          
     357 
    223358                        for ($i = 0; $i < $entries['count']; $i++) 
    224359                        { 
    225360                                $subtree = $this->get_ldap_tree_recursive($resource, $entries[$i]['dn'], $objectClass); 
    226                                  
     361 
    227362                                $dn_parts=ldap_explode_dn($entries[$i]['dn'],1); 
    228                                  
    229                                 if ($subtree !== null and is_array($subtree))  
     363 
     364 
     365 
     366                                if ($subtree !== null and is_array($subtree)) 
    230367                                { 
    231368                                        $tree[$i]['name'] = $dn_parts[0]; 
     
    244381                                                'sub_branch' => false 
    245382                                        ); 
    246                                 }  
     383                                } 
    247384                        } 
    248385 
     
    256393                        } 
    257394                } 
    258                  
     395 
    259396                function get_ldap_referrals($ds, $dn, $filter) { 
    260                          
     397 
    261398                        ldap_set_option($ds, LDAP_OPT_REFERRALS, 0); 
    262399                        ldap_set_option($ds,LDAP_OPT_PROTOCOL_VERSION,3); 
    263                          
     400 
    264401                        if ($ds) { 
    265402                            ldap_bind($ds); 
    266                                 $sr=ldap_list($ds,$dn, $filter);                     
     403                                $sr=ldap_list($ds,$dn, $filter); 
    267404                                $ref = ldap_first_reference($ds, $sr); 
    268405                                $array_referral = array(); 
    269406                                $idx = 0; 
    270                                  
     407 
    271408                                 while ($ref) { 
    272409                                        $array_referral[$idx++] = ldap_get_dn($ds, $ref); 
     
    275412                                return $array_referral; 
    276413                        } 
    277                         else  
     414                        else 
    278415                                return false; 
    279416                } 
    280417 
    281418                function get_ldap_sub_branches_referrals($ds, $dn, $filter) { 
    282                          
     419 
    283420                        $referral = $this -> get_ldap_referrals($ds, $dn, $filter); 
    284421                        $sub_branches = array(); 
    285                          
     422 
    286423                        for($i = 0; $i <count($referral); $i++) { 
    287424                                $dn = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $referral[$i])); 
    288                                 $dn = explode(",",$dn);                          
     425                                $dn = explode(",",$dn); 
    289426                                $dn = strtoupper(str_replace("ou=", "",$dn[0])); 
    290427                                $dn = str_replace("DC=", "",$dn); 
    291                                                                                                                                                                                  
     428 
    292429                                $sub_branch = array( 
    293430                                                                                        'name' => $dn, 
    294431                                                                'type' => 'unknown', 
    295432                                                                'value' => $referral[$i], 
    296                                                                 'sub_branch' => false            
    297                                                                                 );                                                                                                                       
    298                                 $sub_branches[$i] = $sub_branch;                         
     433                                                                'sub_branch' => false 
     434                                                                                ); 
     435                                $sub_branches[$i] = $sub_branch; 
    299436                        } 
    300437                        return $sub_branches; 
    301438                } 
    302                  
    303  
    304                 function get_ldap_tree_level($id_source, $resource, $context, $objectClass, $branch_dn) 
     439 
     440                function translate_accentuation($text) 
     441                { 
     442                        /* 
     443                         * Esta operação resolve o problema causado pela conversão de caracteres acentuados realizada 
     444                         * pela função ldap_explode_dn(). 
     445                         */ 
     446 
     447                        return utf8_decode(preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''", $text)); 
     448                } 
     449 
     450                function get_ldap_tree_level($id_source, $resource, $context, $objectClass, $branch_dn, $external = 0) 
    305451                { 
    306452                        if(strstr($context, "ldap://")){ 
    307                                 $refer_context = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $context));                                                                                              
    308                                 $host   = preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $context);                                                                                                                                
     453                                $refer_context = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $context)); 
     454                                $host   = preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $context); 
    309455                                $resource = ldap_connect($host); 
    310                                 ldap_bind($resource);    
    311                         } 
    312                         $dn_parts = ldap_explode_dn(($refer_context ? $refer_context : $context),1);                     
     456                                ldap_bind($resource); 
     457                        } 
     458 
     459                        /* 
     460                         * TODO: Search timeouts 
     461                         */ 
     462 
     463                        $dn_parts = ldap_explode_dn(($refer_context ? $refer_context : $context),1); 
    313464                        //$filter = '(!(objectClass='.$objectClass.'))'; 
    314465                        // Don't show OU's whith phpgwAccountVisible equal to '-1' 
    315                         $filter = '(&(!(objectClass='.$objectClass.')) (!(phpgwAccountVisible=-1)))'; 
    316                         $result_res = @ldap_list($resource,  ($refer_context ? $refer_context : $context), $filter); 
     466 
     467                        if ($external) 
     468                        { 
     469                                // external source: get all organizationalUnits 
     470                                $filter = '(objectClass=organizationalUnit)'; 
     471                        } 
     472                        else 
     473                        { 
     474                                // get any objectClass except the objectClass used for the source 
     475                                // and whose attribute phpgwAccountVisible value is different from -1 
     476                                $filter = '(&(!(objectClass='.$objectClass.')) (!(phpgwAccountVisible=-1)))'; 
     477                        } 
     478                        $result_res = @ldap_list($resource,  ($refer_context ? $refer_context : $context), $filter, array(), 0, 0); 
    317479                        @ldap_sort($resource, $result_res, 'ou'); 
    318480 
     481                        // Timeouts commented out 
     482                        /* 
    319483                        if ($result_res === false) 
    320484                        { 
     485                                if (ldap_errno($resource) === 3) 
     486                                { 
     487                                        return array('error_msg' => ldap_error($resource)); 
     488                                } 
    321489                                return null; 
    322490                        } 
     491                        */ 
    323492 
    324493                        $count = ldap_count_entries($resource,$result_res); 
     
    326495                        if ( $count == 0 ) 
    327496                        { 
    328                                 $filter = 'objectClass='.$objectClass; 
    329                                 $result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter); 
     497                                $filter = '(objectClass='.$objectClass.')'; 
     498                                // Get only one attribute of the source's objectClass 
     499                                $result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, Array('cn'), 0, 1); 
    330500                                $entries_count = ldap_count_entries($resource, $result_res2); 
    331501 
     
    333503                                { 
    334504                                        return array( 
    335                                                 'name'       => $dn_parts[0], 
     505                                                'name'       => $this->translate_accentuation($dn_parts[0]), 
    336506                                                'type'       => 'catalog', 
    337507                                                'class'      => 'bo_global_ldap_catalog', 
    338                                                 'class_args' => array($id_source, $context), 
     508                                                // Pass the variable $external as a parameter to the constructor 
     509                                                'class_args' => array($id_source, $context, $external), 
    339510                                                'icon'       => 'globalcatalog-mini.png', 
    340511                                                'value'      => $context, 
     
    345516                                { 
    346517                                        return array( 
    347                                                 'name' => $dn_parts[0], 
     518                                                'name' => $this->translate_accentuation($dn_parts[0]), 
    348519                                                'type' => 'empty' 
    349520                                        ); 
     
    361532                                $dn_parts_full = ldap_explode_dn($dn,0); 
    362533                                list($group) = explode('=',$dn_parts_full[0]); 
    363                                  
    364                                 if ($group == $branch_dn or $branch_dn === 'all') 
     534 
     535                                //Faz a comparação do branch como case insensitive 
     536                                if (strtolower($group) == strtolower($branch_dn) or $branch_dn === 'all') 
    365537                                { 
    366538                                        $tree['sub_branch'][$i] = array( 
    367                                                 'name'  => $dn_parts_1[0], 
     539                                                'name'  => $this->translate_accentuation($dn_parts_1[0]), 
    368540                                                'type'  => 'unknown', 
    369541                                                'value' =>  ($refer_context ? $host."/" : "").$dn, 
    370                                                 'sub_branch' => false                                    
     542                                                'sub_branch' => false 
    371543                                        ); 
    372544                                        $sub_branch_found = true; 
     
    374546                                $i++; 
    375547                        } 
    376                          
     548 
    377549                        if(! $refer_context) { 
    378550                                $array_referral = $this -> get_ldap_sub_branches_referrals($resource, $context,'(objectClass=organizationalUnit)'); 
     
    383555 
    384556                        $filter = 'objectClass='.$objectClass; 
    385                         $result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter); 
     557                        $result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, Array('cn'), 0, 1); 
    386558                        $entries_count = ldap_count_entries($resource, $result_res2); 
    387559 
    388560                        if ($result_res2 !== false && $entries_count > 0 && $sub_branch_found) 
    389561                        { 
    390                                 $tree['name']       = $dn_parts[0]; 
     562                                $tree['name']       = $this->translate_accentuation($dn_parts[0]); 
    391563                                $tree['type']       = 'mixed_catalog_group'; 
    392564                                $tree['class']      = 'bo_global_ldap_catalog'; 
    393                                 $tree['class_args'] = array($id_source,$context); 
     565                                // Pass the variable $external as a parameter to the constructor 
     566                                $tree['class_args'] = array($id_source,$context,$external); 
    394567                                $tree['icon']       = 'globalcatalog-mini.png'; 
    395568                                $tree['value']      = $context; 
     
    398571                        { 
    399572                                return array( 
    400                                         'name'       => $dn_parts[0], 
     573                                        'name'       => $this->translate_accentuation($dn_parts[0]), 
    401574                                        'type'       => 'catalog', 
    402575                                        'class'      => 'bo_global_ldap_catalog', 
    403                                         'class_args' => array($id_source, $context), 
     576                                        // Pass the variable $external as a parameter to the constructor 
     577                                        'class_args' => array($id_source, $context,$external), 
    404578                                        'icon'       => 'globalcatalog-mini.png', 
    405579                                        'value'      => $context, 
     
    409583                        else 
    410584                        { 
    411                                 $tree['name']       = $dn_parts[0]; 
     585                                $tree['name']       = $this->translate_accentuation($dn_parts[0]); 
    412586                                $tree['type']       = 'catalog_group'; 
    413587                                $tree['class']      = 'bo_catalog_group_catalog'; 
    414                                 $tree['class_args'] = array('$this', '$this->get_branch_by_level($this->catalog_level[0])'); 
     588                                // Pass the variable $external as a parameter to the constructor 
     589                                $tree['class_args'] = array('$this', '$this->get_branch_by_level($this->catalog_level[0])', $external); 
    415590                                $tree['value']      = $context; 
    416591                                $tree['ldap']       = array('id_source' => $id_source, 'context' => $context); 
    417592                        } 
    418                          
    419593                        usort($tree['sub_branch'], array($this, "compareTreeNodes")); 
    420594                        return $tree; 
     
    422596 
    423597                function compareTreeNodes($a, $b)       { 
    424                                                  
     598 
    425599                        return strnatcasecmp($a['name'], $b['name']); 
    426                 }        
     600                } 
    427601 
    428602        } 
  • trunk/contactcenter/inc/class.bo_people_catalog.inc.php

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

    r203 r284  
    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', 
    122112                                        'type'          => false, 
    123113                                        'state'         => 'empty', 
  • trunk/contactcenter/inc/class.so_group.inc.php

    r258 r284  
    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,C.connection_value'; 
     119                        'A.id_owner ='.$this->owner.' order by A.names_ordered'; 
    120120 
    121121                                         
  • trunk/contactcenter/inc/class.ui_api.inc.php

    r203 r284  
    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); 
    38                         $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
     35 
     36                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/'; 
     37                        $template = CreateObject('phpgwapi.Template',$template_dir); 
    3938 
    4039                        $template->set_file(array('api' => 'api_common.tpl')); 
    41                          
     40 
    4241                        $template->set_var('cc_email_id_type', $preferences['personCardEmail']); 
    43                          
    44                          
     42 
    4543                        /* Messages */ 
    4644                        $template->set_var('cc_msg_err_invalid_catalog',lang('Unavailable or empty Catalog')); 
    47                         $template->set_var('cc_msg_err_contacting_server',lang('Couldn\'t contact server or server response is invalid. Contact Admin.')); 
     45                        $template->set_var('cc_msg_err_contacting_server',lang('Couldn\'t contact server or server response is invalid.')); 
    4846                        $template->set_var('cc_msg_err_timeout',lang('Operation Timed Out.')); 
    4947                        $template->set_var('cc_msg_err_serialize_data_unknown',lang('Data to be serialized is of unknown type!')); 
     
    7775                        $template->set_var('cc_js_djswin', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dJSWin/dJSWin.js'); 
    7876                        $template->set_var('cc_js_catalog_tree', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_tree.js'); 
    79                          
     77 
    8078                        $template->parse('out','api'); 
    8179 
     
    8381                        $this->commons_loaded = false; 
    8482                } 
    85                  
     83 
    8684                /* DEPRECTED! Use get_email_win() instead */ 
    8785                function ui_get_email_win() 
     
    9391                { 
    9492                        //$search = $this->ui_get_search_win(); 
    95                          
     93 
    9694                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/'; 
    9795                        $template = CreateObject('phpgwapi.Template', $template_dir); 
    9896 
    9997                        $template->set_file(array('email_win' => 'email_win.tpl')); 
    100                          
     98 
    10199                        if (!$this->commons_loaded) 
    102100                        { 
     
    108106                                $template->set_var('cc_api', ''); 
    109107                        } 
    110                          
     108 
    111109                        //$template->set_var('cc_search_win', $search); 
    112110                        $template->set_var('cc_js_search', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search.js'); 
    113                          
     111 
    114112                        $template->set_var('cc_email_id_type', $search); 
    115                          
     113 
    116114                        $template->set_var('cc_email_win_title',lang('Contact Center').' - '.lang('Catalog Entries Emails')); 
    117115                        $template->set_var('cc_email_status',lang('Status').':'); 
    118116                        $template->set_var('cc_email_search_text',lang('Search').'...'); 
    119                          
     117 
    120118                        $template->set_var('cc_choose_catalogue',lang('Choose a catalogue').'...'); 
    121119                        $template->set_var('cc_choose_ordinance',lang('Choose a ordinance').'...'); 
    122                          
     120 
    123121                        $template->set_var('cc_btn_to_add',lang('To').' >>'); 
    124122                        $template->set_var('cc_btn_to_del','<< '.lang('To')); 
     
    132130                        $template->set_var('cc_btn_ok',lang('Ok')); 
    133131                        $template->set_var('cc_btn_cancel',lang('Cancel')); 
    134                          
     132 
    135133                        $template->set_var('cc_label_to',lang('To').':'); 
    136134                        $template->set_var('cc_label_cc',lang('Cc').':'); 
     
    140138                        $template->set_var('cc_label_catalogue_type',lang('Type Of Catalogue').':'); 
    141139                        $template->set_var('cc_label_ordinance_type',lang('Type Of Ordinace').':'); 
    142                          
     140 
    143141                        $template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); 
    144                          
     142 
    145143                        $template->set_var('cc_js_email_win', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_email_win.js'); 
    146                          
     144 
    147145                        $template->parse('out','email_win'); 
    148146 
     
    161159 
    162160                        $template->set_file(array('search' => 'search_win.tpl')); 
    163                          
     161 
    164162                        if (!$this->commons_loaded) 
    165163                        { 
     
    171169                                $template->set_var('cc_api', ''); 
    172170                        } 
    173                          
     171 
    174172                        $template->set_var('cc_search_title',lang('Contact Center - Search for Catalog Entries')); 
    175173                        $template->set_var('cc_search_minimize',lang('Minimize')); 
     
    180178                        $template->set_var('cc_search_go',lang('Go')); 
    181179                        $template->set_var('cc_search_cancel',lang('Cancel')); 
    182                          
     180 
    183181                        $template->set_var('cc_js_search_win', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search_win.js'); 
    184                          
     182 
    185183                        $template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); 
    186                          
     184 
    187185                        $template->parse('out','search'); 
    188186 
     
    205203 
    206204                        $template->set_file(array('full_add' => 'full_add.tpl')); 
    207                          
     205 
    208206                        if (!$this->commons_loaded) 
    209207                        { 
     
    215213                                $template->set_var('cc_api', ''); 
    216214                        } 
    217                          
     215 
    218216                        $template->set_var('cc_contact_title',lang('Contact Center').' - '.lang('Contacts')); 
    219217 
     
    223221                        $template->set_var('cc_msg_type_city',lang('Type new city here').'...'); 
    224222                        /* End Messages */ 
    225                          
     223 
    226224                        /* Contact */ 
    227225                        $template->set_var('cc_contact_save',lang('Save')); 
     
    232230                        $template->set_var('cc_contact_addrs',lang('Addresses')); 
    233231                        $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  
    237232                        /* End Contact */ 
    238                          
     233 
    239234                        /* Contact - Personal Data */ 
    240235                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    241                  
     236 
    242237                        $j = 0; 
    243238                        for ($i = 0; $i < 5; $i+=2) 
     
    262257                                $j++; 
    263258                        } 
    264                          
     259 
    265260                        $template->set_var('cc_pd_birth_size_0', "{$date[0]['size']}"); 
    266261                        $template->set_var('cc_pd_birth_size_1', "{$date[1]['size']}"); 
    267262                        $template->set_var('cc_pd_birth_size_2', "{$date[2]['size']}"); 
    268                          
     263 
    269264                        $template->set_var('cc_pd_birthdate_0', "{$date[0]['name']}"); 
    270265                        $template->set_var('cc_pd_birthdate_1', "{$date[1]['name']}"); 
     
    273268                        $template->set_var('cc_pd_select_photo_b', lang('Browse').'...'); 
    274269                        $template->set_var('cc_form_photo_src', 'photo_form.html'); 
    275                          
     270 
    276271                        $template->set_var('cc_pd_select_photo',lang('Select Photo')); 
    277272                        $template->set_var('cc_pd_alias',lang('Alias')); 
     
    291286                        $template->set_var('cc_pd_female',lang('Female')); 
    292287                        /* End Contact - Personal Data */ 
    293                          
     288 
    294289                        /* Contact - Addresses */ 
    295290                        $template->set_var('cc_addr_types',lang('Type of Address')); 
     
    315310                        $template->set_var('cc_available',lang('Available')); 
    316311                        /* End Contact - Addresses */ 
    317                          
    318                          
     312 
    319313                        /* Contact - Connections */ 
    320314                        $template->set_var('cc_conn_type',lang('Type of Connection')); 
    321315                        $template->set_var('cc_conn_name',lang('Connection Name')); 
    322316                        $template->set_var('cc_conn_value',lang('Connection Value')); 
    323                          
     317 
    324318                        $template->set_var('cc_new_same_type',lang('New from the same Type').'...'); 
    325                          
     319 
    326320                        $template->set_var('cc_conn_type_none',lang('Choose Type of Connection').'...'); 
    327321                        /* End Contact - Connections */ 
    328322 
    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  
    333323                        $template->parse('out_full', 'full_add'); 
    334324 
     
    342332 
    343333                        $template->set_file(array('quickAdd' => 'quickAddPlugin.tpl')); 
    344                          
     334 
    345335                        if (!$this->commons_loaded) 
    346336                        { 
     
    352342                                $template->set_var('cc_api', ''); 
    353343                        } 
    354                          
     344 
    355345                        $template->set_var('ccQAPluginFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccQuickAdd-plugin.js'); 
    356346 
     
    360350                        $nFields = 5; 
    361351                        $fields = array( 
    362                                 lang('Alias'),  
    363                                 lang('Given Names'),  
    364                                 lang('Family Names'),  
     352                                lang('Alias'), 
     353                                lang('Given Names'), 
     354                                lang('Family Names'), 
    365355                                lang('Phone'), 
    366356                                lang('Email') 
    367357                        ); 
    368                          
     358 
    369359                        $template->set_var('ccQAnFields', $nFields); 
    370                          
     360 
    371361                        $fieldsHTML = ''; 
    372362                        $fieldsTop = 10; 
     
    375365                        { 
    376366                                $fieldsHTML .= '<span id="ccQuickAddT'.$i.'" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 5px; width: 100px; text-align: right; border: 0px solid #999;">'.$fields[$i].':</span>'."\n"; 
    377                                 $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="50" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n"; 
     367                                if ($i == 0){ 
     368                                        $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="30" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n"; 
     369                                } 
     370                                else if ($i == 4){ 
     371                                        $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="100" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n"; 
     372                                } 
     373                                else { 
     374                                        $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="50" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n"; 
     375                                } 
    378376                        } 
    379377 
     
    381379                        $template->set_var('ccQAWinHeight', ($i+1)*$fieldsSpace+$fieldsTop); 
    382380                        $template->set_var('ccQAFunctionsTop', ($fieldsTop+$i*$fieldsSpace).'px'); 
    383                          
     381 
    384382                        /* Images Dir */ 
    385383                        $template->set_var('ccQACardImgRoot', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/'); 
    386                          
     384 
    387385                        /* Texts */ 
    388386                        $template->set_var('ccQATitle', lang('Contact Center').' - '.lang('Quick Add')); 
     
    390388                        $template->set_var('ccQAClear', lang('Reset')); 
    391389                        $template->set_var('ccQACancel', lang('Cancel')); 
    392                          
     390 
    393391                        $template->parse('out_QA', 'quickAdd'); 
    394392 
    395393                        return $template->get_var('out_QA'); 
    396394                } 
    397                  
     395 
    398396                function get_add_group() 
    399397                { 
     
    402400 
    403401                        $template->set_file(array('addGroup' => 'addGroup.tpl')); 
    404                          
     402 
    405403                        if (!$this->commons_loaded) 
    406404                        { 
     
    410408                        else 
    411409                        { 
    412                                  
     410 
    413411                                $template->set_var('cc_api', ''); 
    414412                        } 
    415                          
    416                         $template->set_var('ccAGFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccAddGroup.js');                   
    417                         $template->set_var('ccAGWinHeightIE', '285');                    
     413 
     414                        $template->set_var('ccAGFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccAddGroup.js'); 
     415                        $template->set_var('ccAGWinHeightIE', '285'); 
    418416                        $template->set_var('ccAGWinHeightMO', '335'); 
    419                          
     417 
    420418                        /* Images Dir */ 
    421419                        $template->set_var('ccAGCardImgRoot', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/'); 
    422                          
     420 
    423421                        /* Texts */ 
    424422                        $template->set_var('ccAGTitle', lang('Contact Center').' - '.lang('Group Add')); 
     
    426424                        $template->set_var('ccAGClear', lang('Reset')); 
    427425                        $template->set_var('ccAGCancel', lang('Cancel')); 
    428                         $title = '<input type="text" id="title" name="title" value="'.$group['title'].'" size="50" maxlength="50"/>';                    
    429                                  
    430                         $template->set_var('title', $title);                                                                                             
     426                        $title = '<input type="text" id="title" name="title" value="'.$group['title'].'" size="50" maxlength="50"/>'; 
     427 
     428                        $template->set_var('title', $title); 
    431429                        // set content and label variables. 
    432430                        $template->set_var(array( 
    433                                                 'msg_text'      => lang($status),                                                
    434                                                 'txt_title'     => lang('Contact Group List'),                                           
     431                                                'msg_text'      => lang($status), 
     432                                                'txt_title'     => lang('Contact Group List'), 
    435433                                                'txt_cancel'=> lang('cancel'), 
    436                                                 'txt_add'=> lang('Add'),                                                 
     434                                                'txt_add'=> lang('Add'), 
    437435                                                'txt_rem'=> lang('Remove'), 
    438436                                                'txt_personal_contacts' => lang('Personal Contacts'), 
    439437                                                'txt_contacts_in_list' => lang("Participants"), 
    440438                                                'txt_name'      => lang('Full Name'))); 
    441                                                  
     439 
    442440                        $template->parse('out_AG', 'addGroup'); 
    443                          
     441 
    444442                        return $template->get_var('out_AG'); 
    445443                } 
  • trunk/contactcenter/inc/class.ui_data.inc.php

    r276 r284  
    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                          
     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 
    5054                        $this->bo = CreateObject('contactcenter.bo_contactcenter'); 
    51                          
     55 
    5256                        if ($temp) 
    5357                        { 
     
    5963                                $this->all_entries = $temp2; 
    6064                        } 
    61                          
     65 
     66                        if ($temp3) 
     67                        { 
     68                                $this->last_search_ids = $temp3; 
     69                        } 
     70 
    6271                        if (!$this->page_info['actual_catalog']) 
    6372                        { 
     
    6574                                $this->page_info['actual_catalog'] = $catalogs[0]; 
    6675                        } 
    67                          
    68                         $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']);                        
    69                          
     76 
     77                        $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']); 
     78 
    7079                        if($this->page_info['actual_catalog']['class'] == 'bo_group_manager') 
    7180                                $this -> typeContact = 'groups'; 
     
    7584 
    7685                /*! 
    77                  
     86 
    7887                        @function index 
    7988                        @abstract Builds the Main Page 
    8089                        @author Raphael Derosso Pereira 
    8190                        @author Jonas Goes 
    82                          
    83                 */               
     91 
     92                */ 
    8493                function index() 
    85                 {        
     94                { 
    8695                        if(!@is_object($GLOBALS['phpgw']->js)) 
    8796                        { 
     
    92101                        $GLOBALS['phpgw']->js->validate_file('venus','jsStructUtil'); 
    93102                        $GLOBALS['phpgw']->js->validate_file('venus','cssUtil'); 
    94                          
     103 
    95104//                      $GLOBALS['phpgw']->js->set_onload('setTimeout(\'updateCards()\',1000)'); 
    96105                        $GLOBALS['phpgw']->common->phpgw_header(); 
    97                          
     106 
    98107                        $GLOBALS['phpgw']->template->set_file(array('index' => 'index.tpl')); 
    99108                        $GLOBALS['phpgw']->template->set_var('cc_root_dir', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/'); 
    100                          
     109 
    101110                        /* Quick Add */ 
    102111                        $GLOBALS['phpgw']->template->set_var('cc_qa_alias',lang('Alias').':'); 
     
    107116                        $GLOBALS['phpgw']->template->set_var('cc_qa_save',lang('Save')); 
    108117                        $GLOBALS['phpgw']->template->set_var('cc_qa_clear',lang('Clear')); 
    109                         $GLOBALS['phpgw']->template->set_var('cc_qa_close',lang('Close')); 
    110118                        /* End Quick Add */ 
    111                          
     119 
    112120                        $cc_css_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/styles/cc.css'; 
    113121                        $cc_card_image_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/card.png'; 
     
    115123                        $GLOBALS['phpgw']->template->set_var('cc_dtree_css', $cc_dtree_file); 
    116124                        $GLOBALS['phpgw']->template->set_var('cc_card_image',$cc_card_image_file); 
    117                          
     125 
    118126                        $GLOBALS['phpgw']->template->set_var('cc_personal',lang('Personal')); 
    119                          
     127 
    120128                        $GLOBALS['phpgw']->template->set_var('cc_full_add',lang('Full Add')); 
    121129                        $GLOBALS['phpgw']->template->set_var('cc_reset',lang('Reset')); 
    122                          
     130 
    123131                        $GLOBALS['phpgw']->template->set_var('cc_personal_data',lang('Personal Data')); 
    124132                        $GLOBALS['phpgw']->template->set_var('cc_addresses',lang('Addresses')); 
     
    129137                        $GLOBALS['phpgw']->template->set_var('cc_catalogs',lang('Catalogues')); 
    130138                        $GLOBALS['phpgw']->template->set_var('cc_group_add',lang('Group Add')); 
    131                          
     139 
    132140                        /* Panel */ 
    133141                        $GLOBALS['phpgw']->template->set_var('cc_panel_new',lang('New').'...'); 
     
    135143                        $GLOBALS['phpgw']->template->set_var('cc_panel_table',lang('Table View')); 
    136144                        $GLOBALS['phpgw']->template->set_var('cc_panel_cards',lang('Cards View')); 
    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                          
     145 
    140146                        $GLOBALS['phpgw']->template->set_var('cc_panel_search_found',lang('Showing found entries')); 
    141147                        $GLOBALS['phpgw']->template->set_var('cc_panel_first_page',lang('First Page')); 
     
    145151                        $GLOBALS['phpgw']->template->set_var('cc_all',lang('all')); 
    146152                        /* End Panel */ 
    147                          
     153 
    148154                        /* Messages */ 
    149155                        $GLOBALS['phpgw']->template->set_var('cc_msg_no_cards',lang('No Cards')); 
     
    160166                        $GLOBALS['phpgw']->template->set_var('cc_empty',lang('Empty')); 
    161167                        /* End Messages */ 
    162                          
     168 
    163169                        $GLOBALS['phpgw']->template->set_var('cc_results',lang('Results')); 
    164170                        $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')); 
    166171                        $GLOBALS['phpgw']->template->set_var('cc_btn_search',lang('Search')); 
    167172                        $GLOBALS['phpgw']->template->set_var('cc_add_relation',lang('Add Relation')); 
    168                         $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations'));                       
     173                        $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations')); 
    169174                        $GLOBALS['phpgw']->template->set_var('cc_msg_group',lang('Group')); 
    170175                        $GLOBALS['phpgw']->template->set_var('cc_msg_contact_full',lang('Contact [Full]')); 
     
    174179                        $GLOBALS['phpgw']->template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); 
    175180 
    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_ie_personal', lang('Import / Export personal Contacts')); 
    186                         $GLOBALS['phpgw']->template->set_var('cc_msg_import_fail', lang('The importation has failed. Verify the file format.')); 
    187                         $GLOBALS['phpgw']->template->set_var('cc_msg_importing_contacts', lang('Importing Contacts...')); 
    188                         $GLOBALS['phpgw']->template->set_var('cc_msg_import_finished', lang('The importation has finished.')); 
    189                         $GLOBALS['phpgw']->template->set_var('cc_msg_new', lang(' new')); 
    190                         $GLOBALS['phpgw']->template->set_var('cc_msg_failure', lang(' failed')); 
    191                         $GLOBALS['phpgw']->template->set_var('cc_msg_exists', lang(' were existent')); 
    192                         $GLOBALS['phpgw']->template->set_var('cc_msg_show_more_info', lang('show more info')); 
    193                         $GLOBALS['phpgw']->template->set_var('cc_msg_clean', lang('Clean')); 
    194                         $GLOBALS['phpgw']->template->set_var('cc_msg_invalid_csv', lang('Select a valid CSV file to import your contacts')); 
    195                         $GLOBALS['phpgw']->template->set_var('cc_msg_export_csv', lang('Select the format type that you want to export your contacts')); 
    196                         $GLOBALS['phpgw']->template->set_var('cc_msg_automatic', lang('Automatic')); 
    197                         $GLOBALS['phpgw']->template->set_var('cc_msg_export_error', lang('An error has occurred while the exportation.')); 
    198                         $GLOBALS['phpgw']->template->set_var('cc_msg_new_email', lang('New Email')); 
    199                         $GLOBALS['phpgw']->template->set_var('cc_msg_main', lang('Main')); 
    200                         $GLOBALS['phpgw']->template->set_var('cc_msg_alternative', lang('Alternative')); 
    201                         $GLOBALS['phpgw']->template->set_var('cc_msg_select_email', lang('Select E-Mail')); 
    202                         $GLOBALS['phpgw']->template->set_var('cc_msg_new_phone', lang('New Telephone')); 
    203                         $GLOBALS['phpgw']->template->set_var('cc_msg_home', lang('Home')); 
    204                         $GLOBALS['phpgw']->template->set_var('cc_msg_cellphone', lang('Cellphone')); 
    205                         $GLOBALS['phpgw']->template->set_var('cc_msg_work', lang('Work')); 
    206                         $GLOBALS['phpgw']->template->set_var('cc_msg_fax', lang('Fax')); 
    207                         $GLOBALS['phpgw']->template->set_var('cc_msg_pager', lang('Pager')); 
    208                         $GLOBALS['phpgw']->template->set_var('cc_msg_choose_phone', lang('Select the telephone')); 
    209                         $GLOBALS['phpgw']->template->set_var('cc_msg_warn_firefox', lang('Warning: Too old version of Firefox')); 
    210                         $GLOBALS['phpgw']->template->set_var('cc_msg_firefox_half1', lang('For this application work correctly</u>')); 
    211                         $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')); 
    212                         $GLOBALS['phpgw']->template->set_var('cc_msg_click_close', lang('click Close')); 
    213                         $GLOBALS['phpgw']->template->set_var('cc_msg_install_now', lang('Install Now')); 
    214                         $GLOBALS['phpgw']->template->set_var('cc_msg_install_new_firefox', lang('Install a new Firefox version')); 
    215                         $GLOBALS['phpgw']->template->set_var('cc_msg_moz_thunderbird', lang('Export as Mozilla Thunderbird CSV.')); 
    216                         $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express_pt', lang('Export as Outlook Express (Portuguese) CSV.')); 
    217                         $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express_en', lang('Export as Outlook Express (English) CSV.')); 
    218                         $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_pt', lang('Export as Outlook 2000 (Portuguese) CSV.')); 
    219                         $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_en', lang('Export as Outlook 2000 (English) CSV.')); 
    220                         $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default_csv', lang('Export as Expresso (Default) CSV.')); 
    221                         $GLOBALS['phpgw']->template->set_var('cc_msg_copy_to_catalog', lang('Copy to personal catalog.')); 
    222                         $GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.')); 
    223                         $GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name')); 
    224                          
    225181                        $GLOBALS['phpgw']->template->parse('out','index'); 
    226                          
     182 
    227183                        $api = CreateObject('contactcenter.ui_api'); 
    228184                        $main = $api->get_full_add(); 
     
    235191                } 
    236192 
    237                  
     193 
    238194                /*! 
    239                  
     195 
    240196                        @function data_manager 
    241                         @abstract Calls the right method and passes to it the right  
     197                        @abstract Calls the right method and passes to it the right 
    242198                                parameters 
    243199                        @author Raphael Derosso Pereira 
    244                  
     200 
    245201                */ 
    246202                function data_manager() 
     
    251207                                case 'set_n_cards': 
    252208                                        return $this->set_n_cards((int)$_GET['ncards']); 
    253                                          
     209 
    254210                                case 'get_cards_data': 
    255                                         return $this->get_cards_data($_POST['letter'], $_POST['page'], unserialize(str_replace('\\"','"',$_POST['ids']))); 
     211 
     212                                        $ids = false; 
     213                                        // To support ldap catalogs using accentuation 
     214                                        if ($_POST['letter'] == 'search' && isset($_POST['data'])) 
     215                                        { 
     216                                                //$ids = utf8_decode($this->search($_POST['data'])); 
     217                                                $ids = $this->search($_POST['data']); 
     218                                        } 
     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 
    256224                                case 'get_cards_data_get': 
    257225                                        return $this->get_cards_data($_GET['letter'], $_GET['page'], unserialize(str_replace('\\"','"',$_GET['ids']))); 
     
    261229                                        return $this->get_photo($_GET['id']); 
    262230 
    263                                          
     231 
    264232                                /* Catalog Methods */ 
    265233                                case 'set_catalog': 
    266234                                        return $this->set_catalog($_GET['catalog']); 
    267                                          
     235 
    268236                                case 'get_catalog_tree': 
    269237                                        echo serialize($this->get_catalog_tree($_GET['level'])); 
     
    279247 
    280248                                case 'get_catalog_add_contact': 
    281                                         echo serialize($this->get_catalog_add_contact($_POST['id'])); 
     249                                        // To support ldap catalogs with accentuation 
     250                                        echo serialize($this->get_catalog_add_contact(utf8_decode($_POST['id']))); 
    282251                                        return; 
    283                                          
     252 
    284253                                /* Full Add Methods */ 
    285254                                case 'get_full_data': 
    286255                                        return $this->get_full_data($_GET['id']); 
    287                                  
     256 
    288257                                case 'get_group': 
    289258                                        return $this->get_group_data($_GET['id']); 
    290                                          
     259 
    291260                                case 'get_contact_full_add_const': 
    292261                                        return $this->get_contact_full_add_const(); 
     
    300269                                case 'get_states': 
    301270                                        return $this->get_states($_GET['country']); 
    302                                          
     271 
    303272                                case 'get_cities': 
    304273                                        return $this->get_cities($_GET['country'], $_GET['state'] ? $_GET['state'] : null); 
    305                                          
    306                                          
     274 
     275 
    307276                                /* Other Methods */ 
    308                                 case 'quick_add':                                                                                                                        
     277                                case 'quick_add': 
    309278                                        return $this->quick_add($_POST['add']); 
    310                                  
    311                                 case 'add_group':                                                                                                                        
     279 
     280                                case 'add_group': 
    312281                                        return $this->add_group($_POST['add']); 
    313                                                                          
     282 
    314283                                case 'remove_entry': 
    315284                                        return $this->remove_entry((int)$_GET['remove']); 
    316                                  
     285 
    317286                                case 'remove_all_entries': 
    318287                                        return $this->remove_all_entries(); 
    319288 
    320289                                case 'remove_group': 
    321                                                                                  
    322                                         return $this->remove_group((int)$_GET['remove']);                                        
     290 
     291                                        return $this->remove_group((int)$_GET['remove']); 
    323292 
    324293                                case 'search': 
     
    357326 
    358327                /*! 
    359                  
     328 
    360329                        @function set_n_cards 
    361330                        @abstract Informs the class the number of cards the page can show 
    362331                        @author Raphael Derosso Pereira 
    363                          
     332 
    364333                        @param integer $n_cards The number of cards 
    365                          
     334 
    366335                */ 
    367336                function set_n_cards($n_cards) 
     
    372341                                echo 1; 
    373342                        } 
    374                          
     343 
    375344                        $this->save_session(); 
    376345                } 
    377                                  
     346 
    378347                /*! 
    379                  
     348 
    380349                        @function set_catalog 
    381350                        @abstract Sets the current catalog selected by the user 
    382351                        @author Raphael Derosso Pereira 
    383                          
     352 
    384353                        @param string $id_catalog The sequence of IDs to reach the catalog 
    385354                                separated by commas 
    386                  
     355 
    387356                */ 
    388357                function set_catalog($id_catalog) 
     
    390359                        $id_catalog = str_replace('\\"', '"', $id_catalog); 
    391360                        $temp =& $this->bo->set_catalog($id_catalog); 
    392                          
     361 
    393362                        if ($temp) 
    394363                        { 
     
    397366                                $this->page_info['actual_catalog'] =& $temp; 
    398367                                $this->save_session(); 
    399                                  
     368 
    400369                                $catalog_info = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 
    401                                  
     370 
    402371                                if ($catalog_info['class'] === 'bo_global_ldap_catalog' || 
    403372                                    $catalog_info['class'] === 'bo_catalog_group_catalog') 
     
    409378                                        $perms = 15; 
    410379                                } 
    411                                  
     380 
    412381                                echo serialize(array( 
    413382                                        'status' => 'ok', 
     
    417386                                return; 
    418387                        } 
    419                          
     388 
    420389                        echo serialize(array( 
    421390                                'status' => 'ok', 
     
    423392                        )); 
    424393                } 
    425                  
    426                  
     394 
     395 
    427396                /*! 
    428                  
     397 
    429398                        @function get_catalog_tree 
    430399                        @abstract Returns the JS serialized array to used as the tree 
    431400                                level 
    432401                        @author Raphael Derosso Pereira 
    433                          
    434                         @param (string) $level The level to be taken  
    435                  
     402                        @author Mï¿œrio Cï¿œsar Kolling (error messages and timeout) 
     403 
     404                        @param (string) $level The level to be taken 
     405 
    436406                */ 
    437407                function get_catalog_tree($level) 
     
    442412 
    443413                                $parent = '0'; 
    444                                  
     414 
    445415                                if (!($tree = $this->bo->get_catalog_tree($level))) 
    446416                                { 
     
    456426                                $parent = substr($level, 0, $last_dot); 
    457427                                $child = substr($level, $last_dot+1, strlen($level)); 
    458                          
     428 
    459429                                if (!($tree[$child] = $this->bo->get_catalog_tree($level))) 
    460430                                { 
     
    464434                                        ); 
    465435                                } 
    466                         } 
    467                          
     436                                // Deals with timeout and returns the generated message to the browser 
     437                                else if (!empty($tree[$child]['timeout']) && !empty($tree[$child]['msg'])) 
     438                                { 
     439                                        $tmp = array( 
     440                                                'msg'    => $tree[$child]['msg'], 
     441                                                'status' => 'fatal' 
     442                                        ); 
     443                                        unset($tree[$child]); 
     444                                        return $tmp; 
     445                                } 
     446                        } 
     447 
    468448                        $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); 
    469449                        $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); 
    470                          
     450 
     451                        // Deals with error messages from the server and returns them to the browser 
     452                        if ($tree['msg']) 
     453                        { 
     454                                $msg = $tree['msg']; 
     455                                unset($tree['msg']); 
     456                        } 
     457 
    471458                        $tree_js = $this->convert_tree($tree, $folderImageDir, $parent); 
    472                          
    473                         return array( 
    474                                 'data' => $tree_js, 
    475                                 'msg'  => lang('Catalog Tree Successfully taken!'), 
    476                                 'status' => 'ok' 
    477                         ); 
    478                 } 
    479                  
     459 
     460                        // Return status = ok, or else return generated message to the browser 
     461                        if (!$msg) 
     462                        { 
     463                                return array( 
     464                                        'data' => $tree_js, 
     465                                        'msg'  => lang('Catalog Tree Successfully taken!'), 
     466                                        'status' => 'ok' 
     467                                ); 
     468                        } 
     469                        else 
     470                        { 
     471                                return array( 
     472                                        'data' => $tree_js, 
     473                                        'msg'  => $msg, 
     474                                        'status' => 'error' 
     475                                ); 
     476 
     477                        } 
     478                } 
     479 
    480480/*              function get_catalog_tree($level, $name = 'tree') 
    481481                { 
     
    487487                                $parent = '0'; 
    488488                                $child  = '0'; 
    489                                  
     489 
    490490                                if (!($tree = $this->bo->get_catalog_tree($level))) 
    491491                                { 
     
    498498                                $parent = substr($level, 0, $last_dot); 
    499499                                $child = substr($level, $last_dot+1, strlen($level)); 
    500                          
     500 
    501501                                $tree_js = ''; 
    502                                  
     502 
    503503                                if (!($tree[$child] = $this->bo->get_catalog_tree($level))) 
    504504                                { 
     
    506506                                } 
    507507                        } 
    508                          
     508 
    509509                        $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); 
    510510                        $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); 
    511                          
     511 
    512512                        $tree_js .= $this->convert_tree($tree, $name, $folderImageDir, $parent); 
    513                          
     513 
    514514                        return $tree_js; 
    515515                } 
    516 */               
    517                  
     516*/ 
     517 
    518518                /*! 
    519                  
     519 
    520520                        @function get_actual_catalog 
    521521                        @abstract Returns the actual selected Catalog 
     
    524524                */ 
    525525                function get_actual_catalog() 
    526                 {                        
     526                { 
    527527                        $level = $this->bo->get_level_by_branch($this->bo->get_actual_catalog(), $this->bo->tree['branches'], '0'); 
    528                          
     528 
    529529                        if ($level) 
    530530                        { 
     
    540540                        ); 
    541541                } 
    542                  
     542 
    543543                /*! 
    544                  
     544 
    545545                        @function get_cards_data 
    546546                        @abstract Returns the information that is placed on the cards 
    547547                        @author Raphael Derosso Pereira 
    548                          
     548 
    549549                        @param string $letter The first letter to be searched 
    550                         @param (int)  $page The page to be taken  
     550                        @param (int)  $page The page to be taken 
    551551                        @param (str)  $ids The ids to be taken in case of search 
    552552 
     
    556556                function get_cards_data($letter, $page, $ids) 
    557557                { 
     558 
     559                        // It's an external catalog? 
     560                        $external = $this->bo->is_external($this->page_info['actual_catalog']); 
     561 
    558562                        //echo $page."\n"; 
    559563                        if ($letter !== 'search' and ($letter != $this->page_info['actual_letter'] or 
    560                             ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or  
     564                            ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or 
    561565                            $this->page_info['changed'])) 
    562566                        { 
    563567                                unset($ids); 
    564568                                $this->page_info['changed'] = false; 
    565                                   
     569 
    566570                                switch ($this->page_info['actual_catalog']['class']) 
    567571                                { 
     
    650654                                                        ); 
    651655                                                } 
    652                                                  
     656 
    653657                                                $find_field[0] = array('contact.id_contact','contact.names_ordered'); 
    654                                                  
     658 
    655659                                                $find_other[0] = array( 
    656660                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    658662                                                        'order'  => 'contact.names_ordered' 
    659663                                                ); 
    660                                                  
     664 
    661665                                                break; 
    662                                          
     666 
     667                                        //case 'bo_external_ldap_catalog': 
     668 
     669                                        //      break; 
     670 
    663671                                        case 'bo_global_ldap_catalog': 
    664672                                                $field_name = 'id_contact'; 
     
    671679                                                                        'type'  => 'iLIKE', 
    672680                                                                        'value' => $letter !== 'all' ? $letter.'%' : '%' 
    673                                                                 ) 
     681                                                                ), 
     682                                                                /* 
     683                                                                 * Restrict the returned contacts in a "first letter" search 
     684                                                                 * to objectClass = phpgwAccount, must have attibute phpgwAccountStatus, 
     685                                                                 * phpgwAccountVisible != -1 and objectClass = inetOrgPerson 
     686                                                                 */ 
     687                                                                1 => array( 
     688                                                                        'field' => 'contact.object_class', 
     689                                                                        'type'  => '=', 
     690                                                                        'value' => 'phpgwAccount' 
     691                                                                ), 
     692                                                                2 => array( 
     693                                                                        'field' => 'contact.account_status', 
     694                                                                        'type'  => 'iLIKE', 
     695                                                                        'value' => '%' 
     696                                                                ), 
     697                                                                3 => array( 
     698                                                                        'field' => 'contact.account_visible', 
     699                                                                        'type'  => '!=', 
     700                                                                        'value' => '-1' 
     701                                                                ), 
     702                                                                4 => array( 
     703                                                                        'field' => 'contact.object_class', 
     704                                                                        'type'  => '=', 
     705                                                                        'value' => 'inetOrgPerson' 
     706                                                                ), 
    674707                                                        ); 
    675                                                         $find_restric[0][1] =  array( 
    676                                                                         'type'  => 'branch', 
    677                                                                         'value' => 'OR', 
    678                                                                         'sub_branch' => array( 
    679                                                                                 0 => array( 
    680                                                                                 'field' => 'contact.account_type', 
    681                                                                                 'type'  => '=', 
    682                                                                                 'value' => 'u' 
    683                                                                                 ), 
    684                                                                                 /*1 => array( 
    685                                                                                 'field' => 'contact.account_type', 
    686                                                                                 'type'  => '=', 
    687                                                                                 'value' => 'g' 
    688                                                                                 ),*/ 
    689                                                                                 2 => array( 
    690                                                                                 'field' => 'contact.account_type', 
    691                                                                                 'type'  => '=', 
    692                                                                                 'value' => 'l' 
     708                                                        // If not external catalog get only phpgwAccountType = u ou l 
     709                                                        if (!$external) 
     710                                                        { 
     711                                                                $find_restric[0][5] =  array( 
     712                                                                                'type'  => 'branch', 
     713                                                                                'value' => 'OR', 
     714                                                                                'sub_branch' => array( 
     715                                                                                        0 => array( 
     716                                                                                        'field' => 'contact.account_type', 
     717                                                                                        'type'  => '=', 
     718                                                                                        'value' => 'u' 
     719                                                                                        ), 
     720                                                                                        /*1 => array( 
     721                                                                                        'field' => 'contact.account_type', 
     722                                                                                        'type'  => '=', 
     723                                                                                        'value' => 'g' 
     724                                                                                        ),*/ 
     725                                                                                        2 => array( 
     726                                                                                        'field' => 'contact.account_type', 
     727                                                                                        'type'  => '=', 
     728                                                                                        'value' => 'l' 
     729                                                                                        ) 
    693730                                                                                ) 
    694                                                                         ) 
    695                                                         ); 
     731                                                                ); 
     732                                                        } 
    696733                                                } 
    697734                                                else 
    698735                                                { 
    699736                                                        $find_restric[0] = array( 
     737                                                                /* 
     738                                                                 * Restrict the returned contacts in a "first number" search 
     739                                                                 * to objectClass = phpgwAccount, must have attibute phpgwAccountStatus, 
     740                                                                 * phpgwAccountVisible != -1 and objectClass = inetOrgPerson 
     741                                                                 */ 
    700742                                                                0 => array( 
     743                                                                        'field' => 'contact.object_class', 
     744                                                                        'type'  => '=', 
     745                                                                        'value' => 'phpgwAccount' 
     746                                                                ), 
     747                                                                1 => array( 
     748                                                                        'field' => 'contact.account_status', 
     749                                                                        'type'  => 'iLIKE', 
     750                                                                        'value' => '%' 
     751                                                                ), 
     752                                                                2 => array( 
     753                                                                        'field' => 'contact.account_visible', 
     754                                                                        'type'  => '!=', 
     755                                                                        'value' => '-1' 
     756                                                                ), 
     757                                                                3 => array( 
     758                                                                        'field' => 'contact.object_class', 
     759                                                                        'type'  => '=', 
     760                                                                        'value' => 'inetOrgPerson' 
     761                                                                ), 
     762                                                                4 => array( 
    701763                                                                        'type'  => 'branch', 
    702764                                                                        'value' => 'OR', 
     
    755817                                                                ), 
    756818                                                        ); 
    757                                                         $find_restric[0][1] =  array( 
    758                                                                 'type'  => 'branch', 
    759                                                                 'value' => 'OR', 
    760                                                                 'sub_branch' => array( 
    761                                                                         0 => array( 
    762                                                                         'field' => 'contact.account_type', 
    763                                                                         'type'  => '=', 
    764                                                                         'value' => 'u' 
    765                                                                         ), 
    766                                                                         /*1 => array( 
    767                                                                         'field' => 'contact.account_type', 
    768                                                                         'type'  => '=', 
    769                                                                         'value' => 'g' 
    770                                                                         ),*/ 
    771                                                                         2 => array( 
    772                                                                         'field' => 'contact.account_type', 
    773                                                                         'type'  => '=', 
    774                                                                         'value' => 'l' 
     819                                                        // If not external catalog get only phpgwAccountType = u ou l 
     820                                                        if (!$external) 
     821                                                        { 
     822                                                                $find_restric[0][5] =  array( 
     823                                                                        'type'  => 'branch', 
     824                                                                        'value' => 'OR', 
     825                                                                        'sub_branch' => array( 
     826                                                                                0 => array( 
     827                                                                                'field' => 'contact.account_type', 
     828                                                                                'type'  => '=', 
     829                                                                                'value' => 'u' 
     830                                                                                ), 
     831                                                                                /*1 => array( 
     832                                                                                'field' => 'contact.account_type', 
     833                                                                                'type'  => '=', 
     834                                                                                'value' => 'g' 
     835                                                                                ),*/ 
     836                                                                                2 => array( 
     837                                                                                'field' => 'contact.account_type', 
     838                                                                                'type'  => '=', 
     839                                                                                'value' => 'l' 
     840                                                                                ) 
    775841                                                                        ) 
    776                                                                 ) 
    777                                                         ); 
     842                                                                ); 
     843                                                        } 
     844 
    778845                                                } 
    779                                                  
    780                                                 $find_field[0] = array('contact.id_contact','contact.names_ordered','contact.account_type'); 
    781                                                  
     846 
     847                                                if (!$external) 
     848                                                { 
     849                                                        // Get only this attributes: dn, cn, phpgwAccountType, objectClass, phpgwAccountStatus, phpghAccountVisible 
     850                                                        // for non-external catalogs, used to restrict the attributes used in filters 
     851                                                        $find_field[0] = array('contact.id_contact','contact.names_ordered','contact.account_type', 
     852                                                                'contact.object_class','contact.account_status','contact.account_visible'); 
     853                                                } 
     854                                                else 
     855                                                { 
     856                                                        // Get only this attributes: dn, cn for external catalogs, 
     857                                                        // used to restrict the attributes used in filters 
     858                                                        $find_field[0] = array('contact.id_contact','contact.names_ordered'); 
     859                                                } 
     860 
    782861                                                $find_other[0] = array( 
    783862                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    785864                                                        'order'  => 'contact.names_ordered' 
    786865                                                ); 
    787                                                  
     866 
    788867                                                break; 
    789                                          
     868 
    790869                                        case 'bo_company_manager': 
    791870                                                $field_name = 'id_company'; 
    792          
     871 
    793872                                                $find_field[0] = array('company.id_company','company.company_name'); 
    794                                                  
     873 
    795874                                                $find_other[0] = array( 
    796875                                                        //'offset' => (($page-1)*$this->page_info['n_cards']), 
     
    798877                                                        'order'  => 'company.company_name' 
    799878                                                ); 
    800          
     879 
    801880                                                $find_restric[0] = array( 
    802881                                                        0 => array( 
     
    806885                                                        ) 
    807886                                                ); 
    808                                                          
     887 
    809888                                                break; 
    810889 
    811890                                        case 'bo_group_manager': 
    812                                          
     891 
    813892                                                $field_name = 'id_group'; 
    814                                                  
     893 
    815894                                                if ($letter !== 'number')       { 
    816                                                          
     895 
    817896                                                        $find_restric[0] = array( 
    818897                                                                0 => array( 
     
    824903                                                } 
    825904                                                 else { 
    826                                                          
     905 
    827906                                                        $find_restric[0] = array( 
    828907                                                                0 => array( 
    829908                                                                                        'field' => 'group.title', 
    830909                                                                                        'type'  => 'LIKE', 
    831                                                                                         'value' => '0%'                                                                          
     910                                                                                        'value' => '0%' 
    832911                                                                ) 
    833                                                         );                                               
     912                                                        ); 
    834913                                                } 
    835                                                  
     914 
    836915                                                array_push($find_restric[0],  array( 
    837916                                                                                        'field' => 'group.owner', 
    838917                                                                                        'type'  => '=', 
    839                                                                                         'value' => $GLOBALS['phpgw_info']['user']['account_id']                                                                          
     918                                                                                        'value' => $GLOBALS['phpgw_info']['user']['account_id'] 
    840919                                                                ) 
    841920                                                ); 
    842                                                  
    843                                                 $find_field[0] = array('group.id_group','group.title','group.short_name');                                               
     921 
     922                                                $find_field[0] = array('group.id_group','group.title','group.short_name'); 
    844923                                                $find_other[0] = array( 
    845924                                                        'order'  => 'group.title' 
    846925                                                ); 
    847                                                  
     926 
    848927                                                break; 
    849                                                  
     928 
    850929                                        case 'bo_catalog_group_catalog': 
    851930                                                $this->page_info['actual_entries'] = false; 
    852                                                  
     931 
    853932                                                $this->page_info['actual_letter'] = $letter; 
    854933                                                $this->page_info['actual_page'] = 0; 
    855                                                  
     934 
    856935                                                $this->save_session(); 
    857936                                                $final[0] = 0; 
    858937                                                $final[1] = $this -> typeContact; 
    859                                                 echo serialize($final);                                          
     938                                                echo serialize($final); 
    860939                                                return; 
    861940 
    862941                                } 
    863                                  
     942 
    864943                                $result = $this->bo->find($find_field[0],$find_restric[0],$find_other[0]); 
    865944                                $n_entries = count($result); 
    866                                  
     945 
    867946                                if ($n_entries) 
    868947                                { 
     
    878957                                { 
    879958                                        $this->page_info['actual_entries'] = false; 
    880                                          
     959 
    881960                                        $this->page_info['actual_letter'] = $letter; 
    882961                                        $this->page_info['actual_page'] = 0; 
    883                                          
    884                                         $this->save_session();                           
     962 
     963                                        $this->save_session(); 
    885964                                        $final[0] = 0; 
    886965                                        $final[1] = $this -> typeContact; 
    887                                         echo serialize($final);                                                                                  
     966                                        echo serialize($final); 
    888967                                        return; 
    889968                                } 
     
    894973                                        { 
    895974                                                $this->page_info['actual_entries'][] = $value[$field_name]; 
    896                                         }  
    897                                         //print_r($this->page_info['actual_entries']); 
    898                                 } 
    899                         } 
     975                                        } 
     976                                } 
     977                        } 
     978//************************************************************************* 
    900979                        else if ($letter === 'search') 
    901980                        { 
    902                                 if (!$ids and $this->page_info['actual_letter'] !== 'search') 
    903                                 { 
     981                                //if (!$ids and $this->page_info['actual_letter'] !== 'search') 
     982                                if (!$ids && !$this->last_search_ids) 
     983                                { 
     984                                        error_log('!$ids e $this->page_info[\'actual_letter\'] != search'); 
    904985                                        $this->page_info['actual_entries'] = false; 
    905                                          
     986 
    906987                                        $this->page_info['actual_letter'] = $letter; 
    907988                                        $this->page_info['actual_page'] = 0; 
    908                                          
     989 
    909990                                        $this->save_session(); 
    910991                                        $final[0] = 0; 
    911992                                        $final[1] = $this -> typeContact; 
    912                                         echo serialize($final);                                  
     993                                        echo serialize($final); 
    913994                                        return; 
    914995                                } 
    915                                 else if ($ids) 
    916                                 {                                
     996                                else if ($ids['error']) 
     997                                { 
     998                                        $this->page_info['actual_entries'] = false; 
     999                                        $this->page_info['actual_letter'] = $letter; 
     1000                                        $this->page_info['actual_page'] = 0; 
     1001 
     1002                                        $this->save_session(); 
     1003                                        $final[0] = 0; 
     1004                                        $final[1] = $this -> typeContact; 
     1005                                        $final['error'] = $ids['error']; 
     1006                                        echo serialize($final); 
     1007                                        return; 
     1008                                } 
     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 
    9171024                                        $this->page_info['actual_letter']  = $letter; 
    9181025                                        $this->page_info['actual_entries'] = $ids; 
     
    9311038                                        $page = $this->page_info['n_pages']; 
    9321039                                } 
    933                                  
     1040 
    9341041                                $final = array( 
    9351042                                        0 => (int)$this->page_info['n_pages'], 
     
    9431050                                                5 => 'cc_alias', 
    9441051                                                6 => 'cc_id', 
    945                                                 7 => 'cc_forwarding_address' 
     1052                                                7 => 'cc_forwarding_address', 
     1053                                                8 => 'cc_empNumber', 
     1054                                                9 => 'cc_department' 
    9461055                                        ) 
    9471056                                ); 
    948                                  
     1057 
    9491058                                //echo 'Page: '.$page.'<br>'; 
    9501059                                $id_i = (($page-1)*$this->page_info['n_cards']); 
    9511060                                $id_f = $id_i + $this->page_info['n_cards']; 
    9521061                                $n_entries = count($this->page_info['actual_entries']); 
    953                                  
     1062 
    9541063                                //echo 'ID_I: '.$id_i.'<br>'; 
    9551064                                //echo 'ID_F: '.$id_f.'<br>'; 
    956                                 ///---------------- Correção Temporária PHP5 -----------------------/// 
     1065                                ///---------------- Correᅵᅵo Temporï¿œria PHP5 -----------------------/// 
    9571066                                $ids = array(); 
    958                                 $array_temp = array();                   
    959                                                                  
     1067                                $array_temp = array(); 
     1068 
    9601069                                foreach($this->page_info['actual_entries'] as $key=>$tmp){ 
    961                                         $array_temp[] = $tmp;                            
    962                                 }        
    963                                  
     1070                                        $array_temp[] = $tmp; 
     1071                                } 
     1072 
    9641073                                for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 
    9651074                                { 
    9661075                                        $ids[] = $array_temp[$i]; 
    9671076                                } 
    968                                  
     1077 
    9691078                                /// Original 
    9701079                                //for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 
     
    9731082                                //} 
    9741083                                /// 
    975                                  
     1084 
    9761085                                $fields = $this->bo->catalog->get_fields(false); 
    9771086 
     
    9851094                                                        2 => 'cc_id', 
    9861095                                                        3 => 'cc_contacts' 
    987                                                 )                                                
    988                                         );                                       
    989                                          
     1096                                                ) 
     1097                                        ); 
     1098 
    9901099                                        $groups =& $this->bo->catalog->get_multiple_entries($ids,$fields); 
    991                                          
     1100 
    9921101                                        $i = 0; 
    9931102                                        // contatos do grupo 
    994                                         $boGroups = CreateObject('contactcenter.bo_group');                                      
     1103                                        $boGroups = CreateObject('contactcenter.bo_group'); 
    9951104                                        $contacts = array(); 
    9961105                                        foreach($groups as $group)              { 
    997                                                                                  
     1106 
    9981107                                                $final[3][$i][0] = $group['title'] ? $group['title'] : 'none'; 
    999                                                 $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none';                                                 
     1108                                                $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none'; 
    10001109                                                $final[3][$i][2] = $group['id_group'] ? $group['id_group'] : 'none'; 
    10011110                                                $contacts = $boGroups -> get_contacts_by_group($group['id_group']); 
    10021111                                                $final[3][$i][3] = $contacts; 
    1003                                                 $i++;                                                    
     1112                                                $i++; 
    10041113                                        } 
    1005                                          
     1114 
    10061115                                        $this->page_info['actual_letter'] = $letter; 
    1007                                         $this->page_info['actual_page'] = $page;                                         
    1008                                          
    1009                                          
     1116                                        $this->page_info['actual_page'] = $page; 
     1117 
     1118 
    10101119                                        $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 
    1011                                          
     1120 
    10121121                                        $final[5] = '<span class="link"  onclick="'.$lnk_compose; 
    1013                                         $final[10] = 'groups';                                                                                                                                                                                                                           
    1014                                         $this->save_session();                                   
     1122                                        $final[10] = 'groups'; 
     1123                                        $this->save_session(); 
    10151124                                        echo serialize($final); 
    1016                                         return;                                  
    1017                                 } 
    1018                                  
     1125                                        return; 
     1126                                } 
     1127 
    10191128                                $fields['photo'] = true; 
    10201129                                $fields['names_ordered'] = true; 
     
    10231132                                $fields['companies'] = 'default'; 
    10241133                                $fields['connections'] = 'default'; 
     1134 
     1135                                // ?aqui alterar a chamada desse mï¿œtodo para receber o base dn? 
    10251136                                $contacts =& $this->bo->catalog->get_multiple_entries($ids,$fields); 
    1026                                  
    1027                                  
     1137 
    10281138                                if (!is_array($contacts) or !count($contacts)) 
    10291139                                { 
     
    10331143                                        return; 
    10341144                                } 
    1035                                  
     1145 
    10361146                                $i = 0; 
    1037                                 foreach($contacts as $contact) 
    1038                                 { 
    1039                                         $final[3][$i][0] = $contact['companies']['company1']['company_name']?$contact['companies']['company1']['company_name']:'none'; 
    1040                                         $final[3][$i][1] = $contact['names_ordered'] ? $contact['names_ordered'] : 'none'; 
    1041                                         $final[3][$i][2] = $contact['companies']['company1']['title']?$contact['companies']['company1']['title']:'none'; 
    1042  
    1043                                         /* Select the correct Email and Telephone to be shown */ 
    1044                                         $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
    1045                                         if (!is_array($preferences)) 
    1046                                         { 
    1047                                                 $preferences['personCardEmail'] = 1; 
    1048                                                 $preferences['personCardPhone'] = 2; 
    1049                                         } 
    1050                                         if ($contact['connections']) 
    1051                                         { 
    1052                                                 $default_email_found = false; 
    1053                                                 $default_phone_found = false; 
    1054                                                 foreach($contact['connections'] as $conn_info) 
     1147                                foreach($contacts as $index => $contact) 
     1148                                { 
     1149                                        /* 
     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. 
     1152                                         */ 
     1153                                        if ($index !== 'error'){ 
     1154                                                $final[3][$i][0] = $contact['companies']['company1']['company_name']?$contact['companies']['company1']['company_name']:'none'; 
     1155                                                $final[3][$i][1] = $contact['names_ordered'] ? $contact['names_ordered'] : 'none'; 
     1156                                                $final[3][$i][2] = $contact['companies']['company1']['title']?$contact['companies']['company1']['title']:'none'; 
     1157 
     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 
     1163                                                /* Select the correct Email and Telephone to be shown */ 
     1164                                                $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
     1165                                                if (!is_array($preferences)) 
    10551166                                                { 
    1056                                                         if ($conn_info['id_type'] == $preferences['personCardEmail'] and !$default_email_found) 
     1167                                                        $preferences['personCardEmail'] = 1; 
     1168                                                        $preferences['personCardPhone'] = 2; 
     1169                                                } 
     1170                                                if ($contact['connections']) 
     1171                                                { 
     1172                                                        $default_email_found = false; 
     1173                                                        $default_phone_found = false; 
     1174                                                        foreach($contact['connections'] as $conn_info) 
    10571175                                                        { 
    1058                                                                 if ($conn_info['connection_is_default']) 
     1176                                                                if ($conn_info['id_type'] == $preferences['personCardEmail'] and !$default_email_found) 
    10591177                                                                { 
    1060                                                                         $default_email_found = true; 
     1178                                                                        if ($conn_info['connection_is_default']) 
     1179                                                                        { 
     1180                                                                                $default_email_found = true; 
     1181                                                                        } 
     1182                                                                        $final[3][$i][4] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 
    10611183                                                                } 
    1062                                                                 $final[3][$i][4] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 
    1063                                                         } 
    1064                                                         else if ($conn_info['id_type'] == $preferences['personCardPhone'] and !$default_phone_found) 
    1065                                                         { 
    1066                                                                 if ($conn_info['connection_is_default']) 
     1184                                                                else if ($conn_info['id_type'] == $preferences['personCardPhone'] and !$default_phone_found) 
    10671185                                                                { 
    1068                                                                         $default_phone_found = true; 
     1186                                                                        if ($conn_info['connection_is_default']) 
     1187                                                                        { 
     1188                                                                                $default_phone_found = true; 
     1189                                                                        } 
     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) { 
     1192                                                                                $conn_info['connection_value'] = "<a title=\"".lang("Call Extension")."\" href=\"#\" onclick=\"connectVoip('".$conn_info['connection_value']."', 'com')\">".$conn_info['connection_value']."</a>"; 
    10691193                                                                } 
    1070                                                                 $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 
     1194                                                                         
     1195                                                                        $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; 
     1196                                                                } 
    10711197                                                        } 
    10721198                                                } 
     1199 
     1200                                                if (!$final[3][$i][3]) 
     1201                                                { 
     1202                                                        $final[3][$i][3] = 'none'; 
     1203                                                } 
     1204 
     1205                                                if (!$final[3][$i][4]) 
     1206                                                { 
     1207                                                        $final[3][$i][4] = 'none'; 
     1208                                                } 
     1209 
     1210                                                $final[3][$i][5] = $contact['alias']?$contact['alias']:'none'; 
     1211                                                $final[3][$i][6] = $ids[$i]; 
     1212 
     1213                                        //      If contact is a public list, then load the forwarding addresses. 
     1214                                                if($contact['account_type'][0] == 'l') 
     1215                                                        $final[3][$i][7] = array(); 
     1216 
     1217                                                $final[4][$i] = $contact['photo'] ? 1  : 0; 
     1218                                                $i++; 
     1219 
    10731220                                        } 
    1074                                          
    1075                                         if (!$final[3][$i][3]) 
     1221                                        else 
    10761222                                        { 
    1077                                                 $final[3][$i][3] = 'none'; 
     1223                                                // coloca mensagem de erro no vetor que retorna para o browser 
    10781224                                        } 
    1079                                          
    1080                                         if (!$final[3][$i][4]) 
    1081                                         { 
    1082                                                 $final[3][$i][4] = 'none'; 
    1083                                         } 
    1084  
    1085                                         $final[3][$i][5] = $contact['alias']?$contact['alias']:'none'; 
    1086                                         $final[3][$i][6] = $ids[$i]; 
    1087  
    1088                                 //      If contact is a public list, then load the forwarding addresses. 
    1089                                         if($contact['account_type'][0] == 'l') 
    1090                                                 $final[3][$i][7] = array(); 
    1091  
    1092                                         $final[4][$i] = $contact['photo'] ? 1  : 0; 
    1093                                         $i++; 
    1094                                 } 
    1095                                 $lnk_compose = "location.href=('../expressoMail1_2/index.php?to=";                               
     1225                                } 
     1226                                $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 
    10961227                                $final[5] = '<span class="link" onclick="'.$lnk_compose; 
    1097                                  
    1098                                  
     1228 
     1229 
    10991230                                $this->page_info['actual_letter'] = $letter; 
    11001231                                $this->page_info['actual_page'] = $page; 
    1101                                  
    1102                                 $this->save_session();                           
     1232 
     1233                                $this->save_session(); 
     1234 
    11031235                                echo serialize($final); 
    11041236                                return; 
    11051237                        } 
    1106                          
     1238 
    11071239                        $this->page_info['actual_letter'] = $letter; 
    11081240                        $this->page_info['actual_page'] = $page; 
    1109                          
     1241 
    11101242                        $this->save_session(); 
    1111                          
     1243 
    11121244                        $final[0] = 0; 
    11131245                        $final[1] = $this -> typeContact; 
    11141246                        echo serialize($final); 
    11151247                } 
    1116                  
     1248 
    11171249                /*! 
    1118                  
     1250 
    11191251                        @function get_group_data 
    11201252                        @abstract Returns all the information of a given Group 
    11211253                        @author Nilton Emilio Buhrer Neto 
    1122                          
     1254 
    11231255                        @param (integer) $id The id to get information 
    1124                  
    1125                 */               
     1256 
     1257                */ 
    11261258                function get_group_data($id) 
    11271259                { 
     
    11291261                        $fields = $this->bo->catalog->get_fields(true); 
    11301262                        $data = $this->bo->catalog->get_single_entry($id,$fields); 
    1131                          
    1132                         if($id) {                        
     1263 
     1264                        if($id) { 
    11331265                                // get All Contacts by group. 
    1134                                 $data['contact_in_list'] = $this->bo->catalog->get_contacts_by_group($id);                                                               
    1135                         } 
    1136                          
     1266                                $data['contact_in_list'] = $this->bo->catalog->get_contacts_by_group($id); 
     1267                        } 
     1268 
    11371269                        $boGroup = CreateObject('contactcenter.bo_group'); 
    1138                                                  
    1139                         $all_contacts = $boGroup->get_all_contacts(); 
    1140                          
    1141                         $contact_options = ""; 
    1142                         if(count($all_contacts)) {                                       
    1143                                 foreach($all_contacts as $idx => $contact) {                             
    1144                                         $contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered']." (".$contact['connection_value'].")</OPTION>"; 
    1145                                 } 
    1146                         } 
    1147                         $data['contact_list'] = $contact_options; 
    1148                         $data['result'] = 'ok';                                                          
    1149                         echo serialize($data);                   
    1150                 }                
    1151                  
     1270 
     1271                        $data['contact_list'] = $boGroup->get_all_contacts(); 
     1272 
     1273                        $data['result'] = 'ok'; 
     1274                        echo serialize($data); 
     1275                } 
     1276 
    11521277                /*! 
    1153                  
     1278 
    11541279                        @function get_full_data 
    11551280                        @abstract Returns all the information of a given Entry 
    11561281                        @author Raphael Derosso Pereira 
    1157                          
     1282 
    11581283                        @param (integer) $id The id to get information 
    1159                  
     1284 
    11601285                */ 
    11611286                function get_full_data($id) 
    11621287                { 
    11631288                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    1164                         $this->bo->catalog = CreateObject('contactcenter.bo_people_catalog');            
     1289                        $this->bo->catalog = CreateObject('contactcenter.bo_people_catalog'); 
    11651290                        $fields = $this->bo->catalog->get_fields(true); 
    11661291                        $fields['photo'] = false; 
     
    11951320                        } 
    11961321                        $datecount = 0; 
    1197                          
     1322 
    11981323                        $data['result'] = 'ok'; 
    11991324                        $data['cc_full_add_contact_id'] = $id; 
     
    12371362 
    12381363                        /* Relations */ 
    1239                          
     1364 
    12401365                        echo serialize($data); 
    12411366                } 
     
    12741399                                return; 
    12751400                        } 
    1276                          
     1401 
    12771402                        echo 0; 
    12781403                } 
    1279                  
     1404 
    12801405                /*! 
    1281                  
     1406 
    12821407                        @function quick_add 
    12831408                        @abstract Adds a new Contact using the Quick Add interface 
    12841409                        @author Raphael Derosso Pereira 
    1285                          
     1410 
    12861411                        @param string $sdata Serialized data 
    12871412                */ 
    12881413                function quick_add($sdata) 
    12891414                { 
    1290                          
     1415 
    12911416                        $sdata = str_replace('\\"', '"', $sdata); 
    12921417                        $new_array = unserialize($sdata); 
    12931418                        $tdata = array(); 
    1294                          
     1419 
    12951420                        foreach($new_array as $tmp) 
    12961421                                $tdata[] = $tmp; 
    1297                          
     1422 
    12981423                        if (!$tdata) 
    12991424                        { 
     
    13021427                                        'status' => 'abort' 
    13031428                                )); 
    1304                                  
     1429 
    13051430                                return; 
    13061431                        } 
    1307                          
    1308                         // verifica se email já existe! 
     1432 
     1433                        // verifica se email jï¿œ existe! 
    13091434                        $boGroup = CreateObject('contactcenter.bo_group'); 
    13101435                        $contact = $boGroup->verify_contact($tdata[4]); 
    1311                                                                                                  
     1436 
    13121437                        if($contact) 
    1313                         {                                                        
     1438                        { 
    13141439                                $str_contact = "\r\n - ".implode("\r\n - ",$contact); 
    1315                                  
     1440 
    13161441                                echo serialize(array( 
    13171442                                        'msg'    => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact), 
    13181443                                        'status' => 'alreadyExists' 
    13191444                                )); 
    1320                                  
    1321                                 return;                  
     1445 
     1446                                return; 
    13221447                        } 
    13231448 
     
    13351460 
    13361461                        if ($boPeople ->quick_add($data)) 
    1337                         {                                
     1462                        { 
    13381463                                $this->page_info['changed'] = true; 
    1339                                  
     1464 
    13401465                                echo serialize(array( 
    13411466                                        'msg'    => lang('Entry added with success!'), 
     
    13511476                        } 
    13521477 
    1353                         $this->save_session();   
    1354                          
     1478                        $this->save_session(); 
     1479 
    13551480                } 
    13561481 
    13571482                /*! 
    1358                  
     1483 
    13591484                        @function add_group 
    13601485                        @abstract Adds a new Group using the Add Group interface 
    13611486                        @author Nilton Emilio Buhrer Neto 
    1362                          
     1487 
    13631488                        @param string $sdata Serialized data 
    13641489                */ 
     
    13681493                        $tdata = unserialize($sdata); 
    13691494                        $new_tdata = array(); 
    1370                          
     1495 
    13711496                        if (!$tdata) 
    13721497                        { 
     
    13751500                                        'status' => 'abort' 
    13761501                                )); 
    1377                                  
     1502 
    13781503                                return; 
    13791504                        } 
    1380                          
     1505 
    13811506                        foreach($tdata as $tmp) 
    13821507                                $new_tdata[] = $tmp; 
    1383                          
    1384                         $data['title'] = $new_tdata[0];                  
     1508 
     1509                        $data['title'] = $new_tdata[0]; 
    13851510                        $data['contact_in_list'] = $new_tdata[1]; 
    13861511                        $data['id_group'] = $new_tdata[2]; 
    1387                                                  
     1512 
    13881513                        $boGroup = CreateObject('contactcenter.bo_group_manager'); 
    13891514                        $id = $boGroup -> add_group($data); 
    1390                          
     1515 
    13911516                        if ($id) 
    13921517                        { 
    13931518                                $this->page_info['changed'] = true; 
    1394                                  
     1519 
    13951520                                echo serialize(array( 
    13961521                                        'msg'    => lang('Entry added with success!'), 
     
    14101535 
    14111536                /*! 
    1412                  
     1537 
    14131538                        @function remove_group 
    14141539                        @abstract Removes a group if the user has the right to do it 
    1415                         @author Nilton Emilio Buhrer Neto                        
     1540                        @author Nilton Emilio Buhrer Neto 
    14161541                        @param (integer) $id The id to be removed 
    1417                                  
     1542 
    14181543                */ 
    14191544                function remove_group($id) 
    1420                 {                                
    1421                                 $soGroup = CreateObject('contactcenter.so_group');                               
     1545                { 
     1546                                $soGroup = CreateObject('contactcenter.so_group'); 
    14221547                                $data = array ('id_group' => $id); 
    14231548                                if($soGroup -> delete($data)) { 
     
    14251550                                                'msg'    => lang('Removed Entry ID '.$id.'!'), 
    14261551                                                'status' => 'ok' 
    1427                                         ));                                                      
     1552                                        )); 
    14281553                                } 
    14291554                                else { 
     
    14341559                                } 
    14351560 
    1436                         $this->save_session();                           
     1561                        $this->save_session(); 
    14371562                } 
    14381563 
    14391564 
    14401565                function remove_all_entries (){ 
    1441                  
     1566 
    14421567                        $error = false; 
    14431568                        $this->all_entries = $this->bo->catalog->get_all_entries_ids(); 
     
    14471572                                if(!$result) { 
    14481573                                        $error = true; 
    1449                                         break;           
     1574                                        break; 
    14501575                                } 
    14511576                        } 
     
    14561581                                        'status' => 'ok' 
    14571582                                )); 
    1458                         }  
     1583                        } 
    14591584                        else { 
    14601585                                echo serialize(array( 
     
    14681593 
    14691594                /*! 
    1470                  
     1595 
    14711596                        @function remove_entry 
    14721597                        @abstract Removes an entry if the user has the right to do it 
    14731598                        @author Raphael Derosso Pereira 
    1474                          
     1599 
    14751600                        @param (integer) $id The id to be removed 
    1476                                  
     1601 
    14771602                */ 
    14781603                function remove_entry ($id) 
     
    14831608                                return; 
    14841609                        } 
    1485                          
     1610 
    14861611                        $this->page_info['changed'] = true; 
    14871612                        $result = $this->bo->catalog->remove_single_entry($id); 
    1488                          
     1613 
    14891614                        if ($result) 
    14901615                        { 
     
    14931618                                        unset($this->page_info['actual_entries'][$pos]); 
    14941619                                } 
    1495                                  
     1620 
    14961621                                $temp = false; 
    14971622                                reset($this->page_info['actual_entries']); 
     
    15001625                                        $temp[] = $t; 
    15011626                                } 
    1502                                  
     1627 
    15031628                                $this->page_info['actual_entries'] = $temp; 
    15041629 
     
    15151640                                )); 
    15161641                        } 
    1517                          
     1642 
    15181643                        $this->save_session(); 
    15191644                } 
    15201645 
    1521                  
     1646 
    15221647                /*! 
    1523                  
     1648 
    15241649                        @function post_full_add 
    15251650                        @abstract Saves all the information altered/entered in the Full Add 
     
    15301655                function post_full_add() 
    15311656                { 
    1532                         $data =  $_POST['data']; 
    1533                         // Exceptions!!! utf8 special chars.  
    1534                         $data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data); 
    1535                         $data = unserialize(str_replace('\\"', '"', $data)); 
     1657                        $data = unserialize(str_replace('\\"', '"', $_POST['data'])); 
    15361658                        $this -> bo -> catalog = CreateObject('contactcenter.bo_people_catalog'); 
     1659 
     1660//                      echo str_replace('\\"', '"', $_POST['data']); 
    15371661 
    15381662                        if (!is_array($data)) 
     
    15581682                                        'status' => 'fatal' 
    15591683                                )); 
    1560                                  
     1684 
    15611685                                return; 
    15621686                        } 
     
    15721696                                $id_photo = '_new_'; 
    15731697                        } 
    1574                          
    1575                         /*  
    1576                          * Process Photo, if available  
     1698 
     1699                        /* 
     1700                         * Process Photo, if available 
    15771701                         */ 
    15781702                        $sleep_count = 0; 
     
    15911715                        } 
    15921716                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n')); 
    1593                          
     1717 
    15941718                        if (isset($this->page_info['photos'][$id_photo])) 
    15951719                        { 
     
    16081732                                $this->save_session(); 
    16091733                        } 
    1610                          
     1734 
    16111735                        /* 
    16121736                         * Arrange Date so it gets inserted correctly 
    16131737                         */ 
    1614                           
     1738 
    16151739                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 
    1616                  
     1740 
    16171741                        $j = 0; 
    16181742                        for ($i = 0; $i < 5; $i+=2) 
     
    16471771                                        continue; 
    16481772                                } 
    1649                                  
     1773 
    16501774                                switch($field) 
    16511775                                { 
     
    16591783                                                /* Do Nothing. This is just to make sure no invalid field is passed */ 
    16601784                                                break; 
    1661                                          
     1785 
    16621786                                        case 'id_status': 
    16631787                                        case 'id_prefix': 
     
    16681792                                                } 
    16691793                                                break; 
    1670                                          
     1794 
    16711795                                        case 'birthdate_0': 
    16721796                                        case 'birthdate_1': 
    16731797                                        case 'birthdate_2': 
    1674                                          
     1798 
    16751799                                                switch($date[$datecount]['digit']) 
    16761800                                                { 
     
    16941818                                                        break; 
    16951819                                                } 
    1696                                                  
     1820 
    16971821                                                if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2])) 
    16981822                                                { 
     
    17031827                                                        return; 
    17041828                                                } 
    1705                                                  
     1829 
    17061830                                                $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1]; 
    17071831                                                break; 
     
    17261850                                                        { 
    17271851                                                                $index = 'address'.$type; 
    1728                                                                  
     1852 
    17291853                                                                $id_state = $this->bo->catalog->add_state($state_info); 
    17301854                                                                $data['addresses'][$index]['id_state'] = $id_state; 
     
    17441868                                                        { 
    17451869                                                                $index = 'address'.$type; 
    1746                                                                  
     1870 
    17471871                                                                $id_city = $this->bo->catalog->add_city($city_info); 
    17481872                                                                $data['addresses'][$index]['id_city'] = $id_city; 
     
    17851909                                ); 
    17861910                        } 
    1787                          
     1911 
    17881912                        eval($code); 
    17891913 
     
    18011925 
    18021926                /*! 
    1803                  
     1927 
    18041928                        @function post_photo 
    18051929                        @abstract Wrapper to post a photo without reload a page. 
     
    18111935                        //print_r($_FILES); 
    18121936                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'y')); 
    1813                          
     1937 
    18141938                        if (!is_array($_FILES) and is_array(!$_FILES['cc_pd_photo'])) 
    18151939                        { 
    18161940                                $this->page_info['photos'][$id]['status'] = 'no_upload'; 
    18171941                                $this->page_info['photos'][$id]['msg'] = lang('No Photos uploaded to Server.'); 
    1818                                  
     1942 
    18191943                                $this->save_session(); 
    18201944                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
     
    18261950                                $this->page_info['photos'][$id]['status'] = 'no_GD_lib'; 
    18271951                                $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.'); 
    1828                                  
     1952 
    18291953                                $this->save_session(); 
    18301954                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
     
    18521976                                return; 
    18531977                        } 
    1854                          
     1978 
    18551979                        switch($_FILES['cc_pd_photo']['type']) 
    18561980                        { 
     
    18822006 
    18832007                                default: 
    1884                                          
     2008 
    18852009                                        $this->page_info['photos'][$id]['status'] = 'invalid_image'; 
    18862010                                        $this->page_info['photos'][$id]['msg'] = lang('The file must be an JPEG, PNG or GIF Image.'); 
     
    18952019                                        $this->page_info['photos'][$id]['status'] = 'invalid_file'; 
    18962020                                        $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); 
    1897                                          
     2021 
    18982022                                        $this->save_session(); 
    18992023                                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    19002024                                        return; 
    19012025                        } 
    1902                          
     2026 
    19032027                        $img_size = getimagesize($_FILES['cc_pd_photo']['tmp_name']); 
    19042028                        $dst_img = imagecreatetruecolor(60, 80); 
    1905                          
     2029 
    19062030                        if (!imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, 60, 80, $img_size[0], $img_size[1])) 
    19072031                        { 
    19082032                                $this->page_info['photos'][$id]['status'] = 'invalid_file'; 
    19092033                                $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); 
    1910                                  
     2034 
    19112035                                $this->save_session(); 
    19122036                                $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    19132037                                return; 
    19142038                        } 
    1915                          
     2039 
    19162040                        ob_start(); 
    19172041                        imagepng($dst_img); 
     
    19232047 
    19242048                        $this->save_session(); 
    1925                  
     2049 
    19262050                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); 
    19272051 
     
    19442068                        $fields = $this->bo->catalog->get_fields(false); 
    19452069                        $fields['photo'] = true; 
    1946                          
     2070 
    19472071                        $contact = $this->bo->catalog->get_single_entry($id, $fields); 
    19482072 
     
    19532077                                return; 
    19542078                        } 
    1955                          
     2079 
    19562080                        header('Content-type: image/jpeg'); 
    19572081                        $photo = imagecreatefromstring ($contact['photo']); 
     
    19652089                        return; 
    19662090                } 
    1967                  
     2091 
    19682092                /*! 
    1969                  
     2093 
    19702094                        @function get_states 
    19712095                        @abstract Echos a serialized array containing all the states for the given country 
     
    19892113                                return; 
    19902114                        } 
    1991                          
     2115 
    19922116                        $result = array( 
    19932117                                'msg'    => lang('States Successfully retrieved!'), 
    19942118                                'status' => 'ok' 
    19952119                        ); 
    1996                          
     2120 
    19972121                        foreach ($states as $state_info) 
    19982122                        { 
     
    20332157                                return; 
    20342158                        } 
    2035                          
     2159 
    20362160                        $result = array( 
    20372161                                'msg'    => lang('Cities Successfully retrieved!'), 
    20382162                                'status' => 'ok' 
    20392163                        ); 
    2040                          
     2164 
    20412165                        foreach ($cities as $city_info) 
    20422166                        { 
    20432167                                $result['data'][$city_info['id_city']] = $city_info['name']; 
    20442168                        } 
    2045                          
     2169 
    20462170                        echo serialize($result); 
    20472171                } 
     
    20492173 
    20502174                /*! 
    2051                  
     2175 
    20522176                        @function search 
    20532177                        @abstract Echos a serialized array containing the IDs 
    20542178                                of the entries that matches the search argument 
    20552179                        @author Raphael Derosso Pereira 
     2180                        @author Mï¿œrio Cï¿œsar Kolling (external catalogs) 
    20562181 
    20572182                        @param string $str_data A serialized array with two informations: 
     
    20652190                { 
    20662191                        $data = unserialize($str_data); 
     2192                        // It's an external catalog? 
     2193                        $external = $this->bo->is_external($this->page_info['actual_catalog']); 
    20672194 
    20682195                        if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) 
    20692196                        { 
    2070                                 echo serialize(array( 
    2071                                         'msg'    => lang('Invalid parameters'), 
    2072                                         'status' => 'abort' 
    2073                                 )); 
    2074  
    2075                                 return; 
     2197                                //echo serialize(array( 
     2198                                //      'msg'    => lang('Invalid parameters'), 
     2199                                //      'status' => 'abort' 
     2200                                //)); 
     2201 
     2202                                return array('error' => lang('Invalid parameters')); 
     2203                        } 
     2204 
     2205                        /* 
     2206                         * TODO: look into the database to discover the database's encoding and convert the search_for field accordingly 
     2207                         */ 
     2208                        // Support search parameters with accentuation 
     2209                        if ($this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && 
     2210                                $this->page_info['actual_catalog']['class'] != 'bo_group_manager') 
     2211                        { 
     2212 
     2213                                $data['search_for'] = utf8_encode($data['search_for']); 
    20762214                        } 
    20772215 
     
    20942232                                if (!is_array($names)) 
    20952233                                { 
    2096                                         echo serialize(array( 
    2097                                                 'msg'    => lang('Invalid Search Parameter'), 
    2098                                                 'status' => 'abort' 
    2099                                         )); 
    2100                                          
    2101                                         return; 
    2102                                 } 
    2103                                  
     2234                                        //echo serialize(array( 
     2235                                        //      'msg'    => lang('Invalid Search Parameter'), 
     2236                                        //      'status' => 'abort' 
     2237                                        //)); 
     2238 
     2239                                        return array('error' => lang('Invalid Search Parameter')); 
     2240                                } 
     2241 
     2242                                if (!$external && $this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && 
     2243                                        $this->page_info['actual_catalog']['class'] != 'bo_group_manager') 
     2244                                { 
     2245                                        /* 
     2246                                         * Restrict the returned contacts search to objectClass = phpgwAccount, 
     2247                                         * must have attibute phpgwAccountStatus, phpgwAccountVisible != -1 and 
     2248                                         * objectClass = inetOrgPerson 
     2249                                         */ 
     2250                                        $rules = array( 
     2251                                                0 => array( 
     2252                                                        'field' => 'contact.object_class', 
     2253                                                        'type'  => '=', 
     2254                                                        'value' => 'phpgwAccount' 
     2255                                                ), 
     2256                                                1 => array( 
     2257                                                        'field' => 'contact.account_status', 
     2258                                                        'type'  => 'iLIKE', 
     2259                                                        'value' => '%' 
     2260                                                ), 
     2261                                                2 => array( 
     2262                                                        'field' => 'contact.account_visible', 
     2263                                                        'type'  => '!=', 
     2264                                                        'value' => '-1' 
     2265                                                ), 
     2266                                                3 => array( 
     2267                                                        'field' => 'contact.object_class', 
     2268                                                        'type'  => '=', 
     2269                                                        'value' => 'inetOrgPerson' 
     2270                                                ) 
     2271                                        ); 
     2272                                } 
     2273 
    21042274                                foreach ($names as $name) 
    21052275                                { 
     
    21142284                                } 
    21152285                        } 
    2116                          
    2117                         /* 
    2118                         $catalog = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); 
    2119                          
    2120                         if ($catalog['class'] === 'bo_people_catalog') 
    2121                         { 
    2122                                 array_push($rules, array( 
    2123                                         'field' => 'contact.id_owner', 
    2124                                         'type'  => '=', 
    2125                                         'value' => $GLOBALS['phpgw_info']['user']['account_id'] 
    2126                                 )); 
    2127                         } 
    2128                         */ 
    2129                          
    2130                         $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); 
     2286 
     2287                        if ($external || $this->page_info['actual_catalog']['class'] == 'bo_people_catalog' || 
     2288                                $this->page_info['actual_catalog']['class'] == 'bo_group_manager') 
     2289                        { 
     2290                                // Get only this attributes: dn, cn for external catalogs, 
     2291                                // used to restrict the attributes used in filters 
     2292                                $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); 
     2293                        } 
     2294                        else 
     2295                        { 
     2296                                // Get only this attributes: dn, cn, phpgwAccountType, objectClass, phpgwAccountStatus, phpghAccountVisible 
     2297                                // for non-external catalogs, used to restrict the attributes used in filters 
     2298                                $ids = $this->bo->find(array( 
     2299                                        $data['fields']['id'], 
     2300                                        $data['fields']['search'], 
     2301                                        'contact.object_class', 
     2302                                        'contact.account_status', 
     2303                                        'contact.account_visible' 
     2304                                        ), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); 
     2305                        } 
    21312306 
    21322307                        if (!is_array($ids) || !count($ids)) 
    21332308                        { 
    2134                                 echo serialize(array( 
    2135                                         'msg'    => lang('No Entries Found!'), 
    2136                                         'status' => 'empty' 
    2137                                 )); 
    2138  
    2139                                 return; 
     2309                                //echo serialize(array( 
     2310                                //      'msg'    => lang('No Entries Found!'), 
     2311                                //      'status' => 'empty' 
     2312                                //)); 
     2313 
     2314                                $this->last_search_ids = null; 
     2315                                $this->save_session(); 
     2316                                return null; 
    21402317                        } 
    21412318 
     
    21452322                        foreach ($ids as $e_info) 
    21462323                        { 
     2324                                //$ids_f[] = "base64::" . base64_encode($e_info[$id_field]); 
    21472325                                $ids_f[] = $e_info[$id_field]; 
    21482326                        } 
    2149                          
    2150                         echo serialize(array( 
    2151                                 'data'   => $ids_f, 
    2152                                 'msg'    => lang('Found %1 Entries', count($ids)), 
    2153                                 'status' => 'ok' 
    2154                         )); 
     2327 
     2328                        //error_log("ids_f serializados: " . serialize($ids_f) . "\n", 3, '/var/www/teste.log'); 
     2329 
     2330                        //return serialize($ids_f); 
     2331                        return $ids_f; 
     2332 
     2333                        //echo serialize(array( 
     2334                        //      'data'   => $ids_f, 
     2335                        //      'msg'    => lang('Found %1 Entries', count($ids)), 
     2336                        //      'status' => 'ok' 
     2337                        //)); 
    21552338                } 
    21562339 
     
    21622345                        @author Raphael Derosso Pereira 
    21632346 
    2164                         @param array str_data A serialized array containing the ID's of the entries  
     2347                        @param array str_data A serialized array containing the ID's of the entries 
    21652348                                to be taken, the fields to be taken and the rules to be used on the 
    21662349                                retrieval: 
     
    21752358                { 
    21762359                        $data = unserialize($str_data); 
    2177                          
     2360 
    21782361                        if (!is_array($data) or !count($data) or !count($data['fields']) or !count($data['ids'])) 
    21792362                        { 
     
    21852368 
    21862369                        $entries = $this->bo->catalog->get_multiple_entries($data['ids'], $data['fields']); 
    2187                          
     2370 
    21882371                        if (!is_array($entries) or !count($entries)) 
    21892372                        { 
     
    22042387 
    22052388                        @function get_all_entries 
    2206                         @abstract Returns the specified fields for all catalog's entries  
     2389                        @abstract Returns the specified fields for all catalog's entries 
    22072390                                in the default CC UI format 
    22082391                        @author Raphael Derosso Pereira 
    22092392 
    2210                         @params array str_data A serialized array containing the fields to  
     2393                        @params array str_data A serialized array containing the fields to 
    22112394                                be grabbed, the maximum number of entries to be returned and a 
    22122395                                boolean specifying if the calls refers to a new grab or to an 
     
    22172400                { 
    22182401                        $data = unserialize($str_data); 
    2219                          
    2220                         if (!is_array($data) or  
    2221                             !count($data) or  
    2222                                 !count($data['fields']) or  
     2402 
     2403                        if (!is_array($data) or 
     2404                            !count($data) or 
     2405                                !count($data['fields']) or 
    22232406                                !$data['maxlength'] or 
    22242407                                (!$data['new'] and !$data['offset'])) 
     
    22462429                                $data['offset'] = 0; 
    22472430                        } 
    2248                          
     2431 
    22492432                        if ($data['maxlength'] != -1) 
    22502433                        { 
     
    22572440 
    22582441                        $prefs = ExecMethod('contactcenter.ui_preferences.get_preferences'); 
    2259                          
     2442 
    22602443                        $jsCode = array(); 
    22612444                        $count = 0; 
     
    22672450                                } 
    22682451 
    2269                                 if($this-> typeContact == 'groups') {                            
    2270                                          
     2452                                if($this-> typeContact == 'groups') { 
     2453 
    22712454                                        foreach ($each as $field => $value)     { 
    2272                                                                                  
     2455 
    22732456                                                if ($field === 'title') { 
    22742457                                                        $optionName = '\\"'.$value.'\\"'; 
    2275                                                           
     2458 
    22762459                                                } 
    22772460                                                else if ($field === 'short_name')       { 
    2278                                                          
     2461 
    22792462                                                        $jsCode[] = '_this.entries.options[_this.entries.options.length] = new Option("'.$optionName.' ('.$value.')", "'.$count.'");'; 
    2280                                                         $count++;                                                                                                                                                                        
    2281                                                 }                                        
     2463                                                        $count++; 
     2464                                                } 
    22822465                                        } 
    22832466                                } 
    2284                                  
    2285                                 else  {  
     2467 
     2468                                else  { 
    22862469                                        foreach ($each as $field => $value)     { 
    22872470                                                if ($field === 'names_ordered') { 
     
    22912474                                                } 
    22922475                                                else if ($field === 'connections')      { 
    2293                                                          
     2476 
    22942477                                                        foreach ($value as $connection)         { 
    22952478                                                                if ($connection['id_type'] == $prefs['personCardEmail'])        { 
     
    23042487 
    23052488                        $jsCodeFinal = implode("\n", $jsCode); 
    2306                          
     2489 
    23072490                        $nEntries = count($result); 
    2308                          
     2491 
    23092492                        if (!$nEntries) 
    23102493                        { 
     
    23242507                        ); 
    23252508                } 
    2326                  
     2509 
    23272510                /*********************************************************************\ 
    23282511                 *                      Auxiliar Methods                             * 
     
    23302513 
    23312514                /*! 
    2332                  
     2515 
    23332516                        @function save_session 
    23342517                        @abstract Saves the data on the session 
    23352518                        @author Raphael Derosso Pereira 
    2336                  
     2519 
    23372520                */ 
    23382521                function save_session() 
     
    23402523                        $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter',$this->page_info); 
    23412524                        $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); 
    23422526                } 
    23432527 
    23442528                /*! 
    2345                  
     2529 
    23462530                        @function convert_tree 
    23472531                        @abstract Converts the tree array in the BO format to a JS tree array compatible 
    23482532                                with the one available in eGW 
    23492533                        @author Raphael Derosso Pereira 
    2350                  
     2534 
    23512535                        @param (array)  $tree    The tree in the BO format 
    23522536                        @param (string) $name    The tree name 
     
    23822566                                        'caption' => $value['name'] 
    23832567                                ); 
    2384                                  
     2568 
    23852569                                switch($value['type']) 
    23862570                                { 
     
    24052589                                $this->bo->catalog->src_info = $ldap->srcs[1]; 
    24062590                        } 
    2407                          
    2408                         $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);                               
     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); 
    24092593                        $dn=$this->bo->catalog->src_info['dn']; 
    24102594                        $justThese = array("givenname","givenname","sn","telephonenumber","mail"); 
    2411                         $sr = ldap_read($ds,$id, "objectClass=*",$justThese);                                                    
    2412                         $info = ldap_get_entries($ds, $sr);                                                      
     2595                        $sr = ldap_read($ds,$id, "objectClass=*",$justThese); 
     2596                        $info = ldap_get_entries($ds, $sr); 
    24132597                        for($z = 0; $z < 5; $z++) { 
    2414                                 $participant = $info[0][$justThese[$z]];                                                                                                         
     2598                                $participant = $info[0][$justThese[$z]]; 
    24152599                                array_push($array_participants, $participant); 
    24162600                        } 
     
    24182602                        ldap_close($ds); 
    24192603                        echo serialize($array_participants); 
    2420                 }        
    2421                  
    2422                 function get_catalog_participants_list($id)  
     2604                } 
     2605 
     2606                function get_catalog_participants_list($id) 
    24232607                { 
    2424                          
    2425                         $fields = $this->bo->catalog->get_fields(false);                         
     2608 
     2609                        $fields = $this->bo->catalog->get_fields(false); 
    24262610                        $fields['names_ordered'] = true; 
    2427                         $fields['mail_forwarding_address'] = true;                       
    2428                         $contact = $this->bo->catalog->get_single_entry($id,$fields);                    
    2429                          
     2611                        $fields['mail_forwarding_address'] = true; 
     2612                        $contact = $this->bo->catalog->get_single_entry($id,$fields); 
     2613 
    24302614                        $array_participants = array(); 
    24312615                        $array_emails = array(); 
    2432                          
     2616 
    24332617                        $filter = null; 
    2434                         for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) {                   
     2618                        for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) { 
    24352619                                        if(strstr($contact['mail_forwarding_address'][$z],'@')) { 
    24362620                                                $filter.="(mail=".$contact['mail_forwarding_address'][$z].")"; 
    24372621                                                $array_emails[$contact['mail_forwarding_address'][$z]] = "<font color=black>".$contact['mail_forwarding_address'][$z]."</font>"; 
    2438                                         }                                                                                                                                
    2439                                         else  
     2622                                        } 
     2623                                        else 
    24402624                                                $array_participants[$z] = "<font color=red>".$contact['mail_forwarding_address'][$z]."</font>"; 
    2441                         }                                        
    2442                          
     2625                        } 
     2626 
    24432627                        if($filter) { 
    2444                                 $filter = "(|".$filter.")";                                                      
     2628                                $filter = "(|".$filter.")"; 
    24452629                                if(!$this->bo->catalog->src_info) { 
    24462630                                        $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    24472631                                        $this->bo->catalog->src_info = $ldap->srcs[1]; 
    24482632                                } 
    2449                                 $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);                               
     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); 
    24502634                                $dn=$this->bo->catalog->src_info['dn']; 
    24512635                                $justThese = array("cn","mail"); 
    2452                                 $sr = ldap_search($ds,$dn, $filter,$justThese);                                                          
    2453                                 $info = ldap_get_entries($ds, $sr);                                                      
     2636                                $sr = ldap_search($ds,$dn, $filter,$justThese); 
     2637                                $info = ldap_get_entries($ds, $sr); 
    24542638                                for($z = 0; $z < $info['count']; $z++) { 
    24552639                                        $participant =  '<font color=\'DARKBLUE\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;'.$info[$z]['cn'][0].'&quot; &lt;'.$info[$z]['mail'][0].'&gt;</font><br>'; 
    2456                                         $array_emails[$info[$z]['mail'][0]] = null;                                                              
    2457                                         array_push($array_participants, $participant);                                   
    2458                                 } 
    2459                                  
     2640                                        $array_emails[$info[$z]['mail'][0]] = null; 
     2641                                        array_push($array_participants, $participant); 
     2642                                } 
     2643 
    24602644                                foreach($array_emails as $index => $email) 
    2461                                         if($email)  
    2462                                                 array_push($array_participants, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>");                           
    2463                                                                                                  
     2645                                        if($email) 
     2646                                                array_push($array_participants, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>"); 
     2647 
    24642648                                ldap_close($ds); 
    24652649                        } 
    24662650                        sort($array_participants); 
    2467                         $innerHTML = '';                         
     2651                        $innerHTML = ''; 
    24682652                        foreach($array_participants as $index => $participant){ 
    24692653                                $innerHTML .= $participant; 
    24702654                        } 
    2471                         $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML);                   
     2655                        $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML); 
    24722656                        echo serialize($return); 
    2473                 }        
    2474                  
     2657                } 
     2658 
    24752659                function export_contacts($typeExport){ 
    24762660 
     
    24832667 
    24842668 
    2485                         // Essa iteração transforma uma esturuta com contatos redundantes e separados por email ou tel. 
     2669                        // Essa iteraᅵᅵo transforma uma esturuta com contatos redundantes e separados por email ou tel. 
    24862670                        // em outra com apenas 1 elemento pra cada contato 
    24872671                        $i=0; 
     
    24942678                                        $all_contacts[$i]['phone']=$object['connection_value']; 
    24952679                        } 
    2496                          
     2680 
    24972681                        switch($typeExport) { 
    24982682 
    24992683                                case 'outlook_en': 
    25002684                                        $streamBuffer = "Name;E-mail Address;Notes;Mobile Phone;Pager;Company;". 
    2501                                                         "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n";                                                         
     2685                                                        "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n"; 
    25022686                                        foreach($all_contacts as $index => $object){ 
    25032687                                                $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;\r\n"; 
    25042688                                        } 
    25052689                                break; 
    2506                                  
     2690 
    25072691                                case 'outlook_pt-BR': 
    2508                                         $streamBuffer = "Nome;End. de email;Endereço residencial;". 
    2509                                         "Cidade do endereço residencial;CEP do endereço residencial;". 
    2510                                         "Estado;País/região do endereço residencial;Telefone residencial;". 
    2511                                         "Rua do endereço comercial;Cidade do endereço comercial;". 
    2512                                         "CEP do endereço comercial;Estado do endereço comercial;". 
    2513                                         "País/região do endereço comercial;Telefone comercial;Empresa;Cargo\r\n";                                                        
     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"; 
    25142698                                        foreach($all_contacts as $index => $object){ 
    25152699                                                $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;;;;;;\r\n"; 
    25162700                                        } 
    25172701                                break; 
    2518                                  
     2702 
    25192703                                case 'outlook2000_pt-BR': 
    25202704                                        $streamBuffer = "\"Tratamento\",\"Nome\",\"Segundo Nome\",\"Sobrenome\",\"Sufixo\",". 
    2521                                         "\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endereço comercial\",\"Rua do endereço comercial 2\",". 
    2522                                         "\"Rua do endereço comercial 3\",\"Cidade do endereço comercial\",\"Estado do endereço comercial\",". 
    2523                                         "\"CEP do endereço comercial\",\"País do endereço comercial\",\"Endereço residencial\",\"Rua residencial 2\",". 
    2524                                         "\"Rua residencial 3\",\"Cidade do endereço residencial\",\"Estado\",\"CEP do endereço residencial\",\"País do endereço residencial\",". 
    2525                                         "\"Outro endereço\",\"Outro endereço 2\",\"Outro endereço 3\",\"Cidade\",\"Estado\",\"CEP\",\"País\",". 
     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\",". 
    25262710                                        "\"Telefone do assistente\",\"Fax comercial\",\"Telefone comercial\",\"Telefone comercial 2\",\"Retorno de chamada\",". 
    25272711                                        "\"Telefone do carro\",\"Telefone principal da empresa\",\"Fax residencial\",\"Telefone residencial\",". 
    25282712                                        "\"Telefone residencial 2\",\"ISDN\",\"Telefone celular\",\"Outro fax\",\"Outro telefone\",\"Pager\",\"Telefone principal\",". 
    2529                                         "\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Aniversário\",\"Anotações\",\"Caixa postal\",\"Categorias\",". 
    2530                                         "\"Código da empresa\",\"Código do governo\",\"Cônjuge\",\"Conta\",\"Endereço de correio eletrônico\",". 
    2531                                         "\"Nome de exibição do correio eletr.\",\"Endereço de correio eletrônico 2\",". 
    2532                                         "\"Nome de exibição do correio eletr.2\",\"Endereço de correio eletrônico 3\",". 
    2533                                         "\"Nome de exibição do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",". 
    2534                                         "\"Filhos\",\"Hobby\",\"Idioma\",\"Indicação\",\"Informações para cobrança\",\"Iniciais\",\"Local\",". 
    2535                                         "\"Nome do assistente\",\"Nome do gerenciador\",\"Página da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",". 
    2536                                         "\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissão\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretório\",". 
     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\",". 
    25372721                                        "\"Sexo\"\r\n"; 
    25382722                                        foreach($all_contacts as $index => $object){ 
     
    25402724                                        } 
    25412725                                break; 
    2542                                  
     2726 
    25432727                                case 'outlook2000_en': 
    25442728                                        $streamBuffer = "Title,First Name,Middle Name,Last Name,Suffix,Company,Department,Job Title,". 
     
    25562740                                        } 
    25572741                                break; 
    2558                                          
     2742 
    25592743                                case 'thunderbird': 
    2560                                         $streamBuffer = "\n";                                                    
     2744                                        $streamBuffer = "\n"; 
    25612745                                        foreach($all_contacts as $index => $object){ 
    25622746                                                $streamBuffer.= ",,".$object['name'].",,".$object['email'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    25632747                                        } 
    25642748                                break; 
    2565                                  
    2566                                 case 'expresso': 
     2749 
     2750                                default: 
    25672751                                        $streamBuffer = "Nome,Email,Telefone\r\n"; 
    25682752                                        foreach($all_contacts as $index => $object){ 
     
    25702754                                        } 
    25712755                                break; 
    2572                                  
     2756 
    25732757                        } 
    25742758 
     
    25782762                        if(!$f) 
    25792763                                echo null; 
    2580                  
     2764 
    25812765                        fputs($f,$streamBuffer); 
    25822766                        fclose($f); 
     
    25852769                } 
    25862770 
    2587                 // Get the csv field and put into array, from php.net 
    2588                 function parse_line($input_text, $delimiter = ',', $text_qualifier = '"') { 
    2589                         $text = trim($input_text); 
    2590                           if(is_string($delimiter) && is_string($text_qualifier)) { 
    2591                          $re_d = '\x' . dechex(ord($delimiter));            //format for regexp 
    2592                         $re_tq = '\x' . dechex(ord($text_qualifier));    //format for regexp 
    2593                          
    2594                         $fields = array(); 
    2595                         $field_num = 0; 
    2596                         while(strlen($text) > 0) { 
    2597                         if($text{0} == $text_qualifier) { 
    2598                                 preg_match('/^' . $re_tq . '((?:[^' . $re_tq . ']|(?<=\x5c)' . $re_tq . ')*)' . $re_tq . $re_d . '?(.*)$/', $text, $matches); 
    2599                                 
    2600                                 $value = str_replace('\\' . $text_qualifier, $text_qualifier, $matches[1]); 
    2601                                 $text = trim($matches[2]); 
    2602                 
    2603                                 $fields[$field_num++] = $value; 
    2604                         } else { 
    2605                                 preg_match('/^([^' . $re_d . ']*)' . $re_d . '?(.*)$/', $text, $matches); 
    2606                                 
    2607                                 $value = $matches[1]; 
    2608                                 $text = trim($matches[2]); 
    2609                 
    2610                                 $fields[$field_num++] = $value; 
    2611                 } 
    2612                 } 
    2613                         return $fields; 
    2614                     } else 
    2615                         return false; 
    2616                 } 
    26172771 
    26182772                function import_contacts($typeImport){ 
    26192773 
    2620                         if($file = $_SESSION['contactcenter']['importCSV']) {                            
    2621                                 unset($_SESSION['contactcenter']['importCSV']);                          
     2774                        $delim          = ($typeImport == 'outlook' ? ';' : ','); 
     2775 
     2776                        if($file = $_SESSION['contactcenter']['importCSV']) { 
     2777                                unset($_SESSION['contactcenter']['importCSV']); 
    26222778                                $len = filesize($file); 
    26232779                                $count = 0; 
    26242780                                $return = array('error' => false, '_new' => 0, '_existing' => 0, '_failure' => 0); 
    26252781                                $handle = @fopen($file, "r") or die(serialize($return['error'] = true)); 
    2626                                  
    2627                                 $input_header = fgets($handle); 
    2628                                 if ($typeImport == 'outlook') 
    2629                                         $delim = ';'; 
    2630                                 else if ($typeImport == 'auto') 
    2631                                 $delim = strstr($input_header,',') ? ',' : ';'; 
    2632                                 else   
    2633                                         $delim = ','; 
    2634                                 $csv_header = $this->parse_line($input_header,$delim); 
    2635                                 $firstContact = fgets($handle); 
    2636                                 preg_match("/\"(.+)\"[,;]/sU",$firstContact,$matches); // yahoo csv 
    2637                                 rewind($handle);                                 
    2638  
    26392782                                $header = @fgetcsv($handle, $len, $delim) or die(serialize($return['error'] = true)); 
    26402783                                if(count($header)  < 2 || count($header) > 100) { 
     
    26442787                                        return; 
    26452788                                } 
    2646                                  
    2647                                 if ($matches[0][strlen($matches[0])-1] == ';') 
    2648                                         $delim = ';'; 
    2649                                  
    2650                         $boGroup = CreateObject('contactcenter.bo_group'); 
    2651                         $boPeople = CreateObject('contactcenter.bo_people_catalog'); 
     2789 
     2790                                $boGroup = CreateObject('contactcenter.bo_group'); 
     2791                                $boPeople = CreateObject('contactcenter.bo_people_catalog'); 
     2792 
    26522793                                switch($typeImport){ 
    26532794                                        case 'outlook2000': 
     
    26662807                                                $phone_pos=7; 
    26672808                                                break; 
    2668                                         case 'expresso': 
     2809                                        default: 
    26692810                                                $name_pos=0; 
    26702811                                                $email_pos=1; 
    26712812                                                $phone_pos=2; 
    2672                                                 break; 
    2673                                         default: 
    2674                                                 foreach($csv_header as $index => $fieldName) 
    2675                                                 { 
    2676                                                         switch($fieldName){ 
    2677                                                         case 'Name': 
    2678                                                         case 'Nome': 
    2679                                                         case 'First Name': 
    2680                                                                 $name_pos = $index; 
    2681                                                                 break; 
    2682                                                         case 'E-mail': 
    2683                                                         case 'Email': 
    2684                                                         case 'E-mail Address': 
    2685                                                         case 'Endereço de correio eletrônico': 
    2686                                                         case 'End. de email': 
    2687                                                                 $email_pos = $index; 
    2688                                                                 break; 
    2689                                                         case 'Home Phone': 
    2690                                                         case 'Phone': 
    2691                                                         case 'Telefone': 
    2692                                                         case 'Telefone principal': 
    2693                                                         case 'Telefone comercial': 
    2694                                                                 $phone_pos = $index; 
    2695                                                                 break; 
    2696                                                         } 
    2697                                                 }        
    2698                                                 break; 
    2699                                 } 
    2700                                  
     2813                                } 
    27012814 
    27022815                                while (($data = fgetcsv($handle, $len, $delim))) { 
     2816 
    27032817                                foreach ($header as $key=>$heading) 
    27042818                                $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; 
    2705                                  
     2819 
    27062820                                        $sdata = array(); 
    27072821                                        $full_name  = trim($row[$header[$name_pos]]); 
     
    27172831                                        $sdata['connections']['default_phone']['connection_name'] = lang('Main'); 
    27182832                                        $sdata['connections']['default_phone']['connection_value'] = $phone; 
    2719                                          
    2720                                         //      verifica se email já existe! 
     2833 
     2834                                        //      verifica se email jï¿œ existe! 
    27212835                                        $contact = $boGroup->verify_contact($email); 
    27222836 
    2723                                         $line_iteration = $return['_failure'] + $return['_existing'] + $return['_new'];  
    27242837                                        if($contact){ 
    27252838                                                $return['_existing']++; 
    2726                                         }                                                                                                                
     2839                                        } 
    27272840                                        else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 
    27282841                                                $return['_failure']++; 
    2729                                                 $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>"; 
    27302842                                        } 
    2731                                         else if (!$sdata['given_names'] || !$email || !$boPeople ->quick_add($sdata)){                                           
    2732                                                 $return['_failure']++;                                                   
    2733                                                 $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid Name: " . $sdata['given_names'] ."<br>"; 
     2843                                        else if (!$sdata['given_names'] || !$email || !$boPeople ->quick_add($sdata)){ 
     2844                                                $return['_failure']++; 
    27342845                                        } 
    27352846                                        else 
    27362847                                                $return['_new']++; 
    2737                         }                                
     2848                        } 
    27382849                                fclose($handle); 
    27392850                                unlink($file); 
     
    27492860                        $new = null; 
    27502861                        $code = null; 
    2751                          
     2862 
    27522863                        if ($parent === '0') 
    27532864                        { 
     
    27552866                                $code .= $name.".add(new dNode({id:'0', caption: '".lang('Catalogues')."'}),'none');\n"; 
    27562867                        } 
    2757                          
     2868 
    27582869                        foreach ($tree as $id => $value) 
    27592870                        { 
     
    27612872 
    27622873                                switch ($value['type']) 
    2763                                 {                                        
     2874                                { 
    27642875                                        case 'unknown': 
    2765                                                 $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";  
     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"; 
    27662877                                                break; 
    2767                                          
     2878 
    27682879                                        case 'catalog_group': 
    2769                                                 $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}'}),'$parent');\n";  
     2880                                                $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}'}),'$parent');\n"; 
    27702881                                                $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 
    27712882                                                break; 
     
    27762887                                                $code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id); 
    27772888                                                break; 
    2778                                          
     2889 
    27792890                                        case 'catalog': 
    27802891                                                $code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}', onClick: 'setCatalog(\\'{$parent}.{$id}\\')'}),'$parent');\n"; 
    2781                                                  
    2782                                 } 
    2783                         } 
    2784                          
     2892 
     2893                                } 
     2894                        } 
     2895 
    27852896                        return $code; 
    27862897                } 
  • trunk/contactcenter/index.php

    r2 r284  
    2222        ); 
    2323        include('../header.inc.php'); 
     24        $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['telephone_number'] = $GLOBALS['phpgw_info']['user']['telephonenumber']; 
     25        $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] = true; 
    2426 
    2527        $obj = CreateObject('contactcenter.ui_data'); 
    2628        $obj->index(); 
     29         
    2730 
    2831        $GLOBALS['phpgw']->common->phpgw_footer(); 
  • trunk/contactcenter/js/cc.js

    r258 r284  
    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                 var options_contact_list = Element('contact_list'); 
    311                 if(data['contact_list']) {                                       
    312                         options_contact_list.innerHTML = data['contact_list']; 
     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                        } 
    313318                } 
    314319 
    315320                if(data['id_group']) { 
    316                  
    317                         if(data['contact_in_list']) {                                    
    318                                 for(i = 0; i < data['contact_in_list'].length; i++) {                            
     321 
     322                        if(data['contact_in_list']) { 
     323                                for(i = 0; i < data['contact_in_list'].length; i++) { 
    319324                                        option = document.createElement('option'); 
    320325                                        option.value = data['contact_in_list'][i]['id_connection']; 
    321                                         option.text = data['contact_in_list'][i]['names_ordered']+' ('+data['contact_in_list'][i]['connection_value']+')';                               
     326                                        option.text = data['contact_in_list'][i]['names_ordered']+' ('+data['contact_in_list'][i]['connection_value']+')'; 
    322327                                        Element('contact_in_list').options[Element('contact_in_list').options.length] = option; 
    323328                                } 
    324                         }                
    325                          
     329                        } 
     330 
    326331                        Element('title').value =  data['title']; 
    327332                } 
    328                                  
     333 
    329334                if (typeof(data) != 'object' || data['result'] != 'ok') 
    330335                { 
     
    333338                } 
    334339        }; 
    335                  
     340 
    336341        id = typeof(id) == 'undefined' ? id = 0 :  id; 
    337          
    338         ccAddGroup.clear(true);                  
     342 
     343        ccAddGroup.clear(true); 
    339344        Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id, 'GET', handler); 
    340345} 
     
    371376                return false; 
    372377        } 
    373          
     378 
    374379        /* First thing: Send Photo */ 
    375380        if (Element('cc_pd_select_photo').value != '' && !is_ie) 
     
    389394                        frame = old_frame; 
    390395                } 
    391                  
     396 
    392397                frame.id = 'cc_photo_frame'; 
    393398                frame.style.visibility = 'hidden'; 
     
    398403 
    399404                form = frame.contentDocument.createElement('form'); 
    400                  
     405 
    401406                var id_contact = Element('cc_full_add_contact_id').value; 
    402407                form.id = 'cc_form_photo'; 
     
    404409                form.enctype = 'multipart/form-data'; 
    405410                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 : ''); 
    406                  
     411 
    407412                var input_clone = Element('cc_pd_select_photo').cloneNode(false); 
    408413                form.appendChild(input_clone); 
    409                  
     414 
    410415                frame.contentDocument.body.appendChild(form); 
    411416                form.submit(); 
     
    461466        var empty = true; 
    462467        var replacer = '__##AND##__'; 
    463          
     468 
    464469        data['commercialAnd'] = replacer; 
    465          
     470 
    466471        if (Element('cc_full_add_contact_id').value != '' && Element('cc_full_add_contact_id').value != 'null') 
    467472        { 
     
    472477        /* Status: Full Added */ 
    473478        data['id_status'] = CC_STATUS_FULL_ADD; 
    474          
     479 
    475480        /* Personal Data */ 
    476481        data['alias']         = replaceComAnd(Element('cc_pd_alias').value, replacer); 
     
    510515                                data['connections'] = new Array(); 
    511516                        } 
    512                          
     517 
    513518                        for (var i in CC_contact_full_info['connections'][type]) 
    514519                        { 
     
    522527                                        data['connections']['connection'+connNumber] = new Array(5); 
    523528                                } 
    524                                  
     529 
    525530                                data['connections']['connection'+connNumber]['id_connection'] = CC_contact_full_info['connections'][type][i]['id']; 
    526531                                data['connections']['connection'+connNumber]['id_typeof_connection'] = type; 
     
    531536                                                data['connections']['connection'+connNumber]['connection_is_default']  = 'TRUE'; 
    532537                                        } 
    533                                         else  
     538                                        else 
    534539                                                data['connections']['connection'+connNumber]['connection_is_default']  = 'FALSE'; 
    535540                                } 
    536541 
    537542//                              data['connections']['connection'+connNumber].length = 5; 
    538                                  
     543 
    539544                                empty = false; 
    540545                                connNumber++; 
     
    543548 
    544549                } 
    545                  
     550 
    546551                if (!empty) 
    547552                { 
     
    550555                } 
    551556        } 
    552          
     557 
    553558        if (CC_contact_full_info['removed_conns']) 
    554559        { 
    555560                empty = false; 
    556                  
     561 
    557562                if (typeof(data['connections']) != 'object') 
    558563                { 
     
    589594                        for (var i in CC_contact_full_info['connections'][type]){ 
    590595                                if((CC_contact_full_info['connections'][type][i]['value'].length < 4) || 
    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'); 
     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'); 
    593598                                        return false; 
    594599                                } 
     
    596601                        var _options_default = Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default"); 
    597602                        if(_options_default.value == '-1') { 
    598                                 alert("É necessário escolher um "+ (type == 1 ? 'E-mail' : 'Telefone')+" como padrão!"); 
     603                                alert("ï¿œ necessï¿œrio escolher um "+ (type == 1 ? 'E-mail' : 'Telefone')+" como padrï¿œo!"); 
    599604                                return false; 
    600605                        } 
    601606                } 
    602                  
     607 
    603608        } 
    604609 
     
    609614 
    610615/********* Personal Data Functions *********/ 
    611 /*  
     616/* 
    612617 * data[0] => cc_pd_select_photo 
    613618 * data[1] => cc_pd_alias 
     
    657662{ 
    658663        Element('cc_addr_types').selectedIndex = 0; 
    659          
     664 
    660665        Element('cc_addr_countries').selectedIndex = 0; 
    661666        Element('cc_addr_countries').disabled = true; 
    662          
     667 
    663668        Element('cc_addr_states').selectedIndex = 0; 
    664669        Element('cc_addr_states').disabled = true; 
     
    711716        var type = Element('cc_addr_types'); 
    712717        var oldSelected = type.value; 
    713          
     718 
    714719        saveAddressFields(); 
    715          
     720 
    716721        if (oldSelected == '_NONE_') 
    717722        { 
     
    719724                return true; 
    720725        } 
    721          
     726 
    722727        CC_addr_last_selected = type.selectedIndex; 
    723          
     728 
    724729        Element('cc_addr_countries').disabled = false; 
    725          
     730 
    726731        var data = CC_contact_full_info['addresses']; 
    727732        var addrIndex  = 'address'+Element('cc_addr_types').value; 
    728          
    729         if (typeof(data) != 'object' || typeof(data[addrIndex]) != 'object')  
     733 
     734        if (typeof(data) != 'object' || typeof(data[addrIndex]) != 'object') 
    730735        { 
    731736                resetAddressFields(); 
     
    736741                return true; 
    737742        } 
    738          
     743 
    739744        var addrTypeID = Element('cc_addr_types').value; 
    740          
     745 
    741746        data = CC_contact_full_info['addresses'][addrIndex]; 
    742          
     747 
    743748        Element('cc_addr_id').value                              = data['id_address']           ? data['id_address']                    : ''; 
    744749        Element('cc_addr_1').value                              = data['address1']                      ? data['address1']                              : ''; 
     
    762767                states.selectedIndex = 0; 
    763768                clearSelectBox(states, 4); 
    764                 updateAddrCities();      
     769                updateAddrCities(); 
    765770                return; 
    766771        } 
     
    777782        { 
    778783                var data = unserialize(responseText); 
    779                  
     784 
    780785                clearSelectBox(states, 1); 
    781                          
     786 
    782787                if (typeof(data) != 'object') 
    783788                { 
    784789                        showMessage(Element('cc_msg_err_contacting_server').value); 
    785          
     790 
    786791                        return; 
    787792                } 
     
    790795                { 
    791796                        states.disabled = true; 
    792                         cities.disabled = true;                  
     797                        cities.disabled = true; 
    793798                        states.selectedIndex = 0; 
    794799                        cities.selectedIndex = 0; 
     
    830835                } 
    831836        }; 
    832          
     837 
    833838        Connector.newRequest('populateStates', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_states&country='+Element('cc_addr_countries').value, 'GET', handler); 
    834839} 
     
    858863                        newState.disabled = false; 
    859864                        updateAddrNewStateOnMouseOut(); 
    860                          
     865 
    861866                        cities.disabled = false; 
    862867                        clearSelectBox(cities, 3); 
     
    869874                case '_NOSTATE_': 
    870875                        clearSelectBox(cities, 3); 
    871                          
     876 
    872877                        cities.disabled = false; 
    873878                        cities.selectedIndex = 0; 
    874                          
     879 
    875880                        requestStr = 'country='+Element('cc_addr_countries').value; 
    876881                        break; 
    877                  
     882 
    878883                default: 
    879884                        requestStr = 'country='+Element('cc_addr_countries').value+'&state='+states.value; 
     
    890895{ 
    891896        var cities = Element('cc_addr_cities'); 
    892          
     897 
    893898        var handler = function (responseText) 
    894899        { 
    895900                var data = unserialize(responseText); 
    896                  
     901 
    897902                clearSelectBox(cities, 1); 
    898                  
     903 
    899904                if (typeof(data) != 'object') 
    900905                { 
    901906                        showMessage(Element('cc_msg_err_contacting_server').value); 
    902                          
     907 
    903908                        return; 
    904909                } 
     
    945950                } 
    946951        }; 
    947          
     952 
    948953        Connector.newRequest('populateCities', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cities&'+requestStr, 'GET', handler); 
    949954} 
     
    951956function updateAddrNewStateOnMouseOver () 
    952957{ 
    953         if (Element('cc_addr_states_new').value == Element('cc_msg_type_state').value && Element('cc_addr_states').selectedIndex == 1)  
     958        if (Element('cc_addr_states_new').value == Element('cc_msg_type_state').value && Element('cc_addr_states').selectedIndex == 1) 
    954959        { 
    955960                Element('cc_addr_states_new').value = ''; 
     
    959964function updateAddrNewStateOnMouseOut () 
    960965{ 
    961         if (Element('cc_addr_states_new').value.length == 0 && Element('cc_addr_states').selectedIndex == 1)  
     966        if (Element('cc_addr_states_new').value.length == 0 && Element('cc_addr_states').selectedIndex == 1) 
    962967        { 
    963968                Element('cc_addr_states_new').value = Element('cc_msg_type_state').value; 
     
    979984                return; 
    980985        } 
    981          
     986 
    982987        Element('cc_addr_1').readonly = false; 
    983988        Element('cc_addr_1').disabled = false; 
     
    10091014 
    10101015                        //resetAddrFillingFields(); 
    1011                          
     1016 
    10121017                        return; 
    10131018 
     
    10171022                        newCity.disabled = false; 
    10181023                        updateAddrNewCityOnMouseOut(); 
    1019                          
     1024 
    10201025                        break; 
    10211026 
     
    10311036function updateAddrNewCityOnMouseOver () 
    10321037{ 
    1033         if (Element('cc_addr_cities_new').value == Element('cc_msg_type_city').value && Element('cc_addr_cities').selectedIndex == 1)  
     1038        if (Element('cc_addr_cities_new').value == Element('cc_msg_type_city').value && Element('cc_addr_cities').selectedIndex == 1) 
    10341039        { 
    10351040                Element('cc_addr_cities_new').value = ''; 
     
    10391044function updateAddrNewCityOnMouseOut () 
    10401045{ 
    1041         if (Element('cc_addr_cities_new').value.length == 0 && Element('cc_addr_cities').selectedIndex == 1)  
     1046        if (Element('cc_addr_cities_new').value.length == 0 && Element('cc_addr_cities').selectedIndex == 1) 
    10421047        { 
    10431048                Element('cc_addr_cities_new').value = Element('cc_msg_type_city').value; 
     
    10531058                return true; 
    10541059        } 
    1055          
    1056         var addrFields = new Array('cc_addr_1',  
    1057                                    'cc_addr_2',  
    1058                                                            'cc_addr_complement',  
     1060 
     1061        var addrFields = new Array('cc_addr_1', 
     1062                                   'cc_addr_2', 
     1063                                                           'cc_addr_complement', 
    10591064                                                           'cc_addr_other', 
    1060                                                            'cc_addr_postal_code',  
     1065                                                           'cc_addr_postal_code', 
    10611066                                                           'cc_addr_po_box', 
    10621067                                                           'cc_addr_countries', 
     
    10651070 
    10661071        var empty = true; 
    1067          
     1072 
    10681073        for (var i = 0; i < 8; i++) 
    10691074        { 
     
    10741079                } 
    10751080        } 
    1076                                  
     1081 
    10771082        if (empty) 
    10781083        { 
     
    11031108                default: 
    11041109                        addrInfo['id_country'] = Element('cc_addr_countries').value; 
    1105                  
     1110 
    11061111        } 
    11071112 
     
    11171122                default: 
    11181123                        addrInfo['id_state'] = Element('cc_addr_states').value; 
    1119                  
     1124 
    11201125        } 
    11211126 
     
    11301135                default: 
    11311136                        addrInfo['id_city'] = Element('cc_addr_cities').value; 
    1132                  
    1133         }        
     1137 
     1138        } 
    11341139 
    11351140        addrInfo['id_typeof_address']  = Element('cc_addr_types').options[lastIndex].value; 
     
    11441149        CC_contact_full_info['addresses']['address'+Element('cc_addr_types').options[lastIndex].value] = addrInfo; 
    11451150 
    1146         if (Element('cc_addr_cities').value == '_NEW_' &&  
     1151        if (Element('cc_addr_cities').value == '_NEW_' && 
    11471152            Element('cc_msg_type_city').value !=  Element('cc_addr_cities_new').value && 
    11481153                Element('cc_addr_cities_new').value != '') 
    11491154        { 
    11501155                var addrRootInfo = CC_contact_full_info['addresses']['new_cities']; 
    1151                  
     1156 
    11521157                if (!addrRootInfo) 
    11531158                { 
    11541159                        addrRootInfo = new Array(); 
    11551160                } 
    1156                  
     1161 
    11571162                var i = addrRootInfo.length; 
    11581163                addrRootInfo[addrInfo['id_typeof_address']] = new Array(); 
     
    11631168        } 
    11641169 
    1165         if (Element('cc_addr_states').value == '_NEW_' &&  
    1166             Element('cc_msg_type_state').value !=  Element('cc_addr_states_new').value &&  
     1170        if (Element('cc_addr_states').value == '_NEW_' && 
     1171            Element('cc_msg_type_state').value !=  Element('cc_addr_states_new').value && 
    11671172                Element('cc_addr_states_new').value != '') 
    11681173        { 
    11691174                var addrRootInfo = CC_contact_full_info['addresses']['new_states']; 
    1170                  
     1175 
    11711176                if (!addrRootInfo) 
    11721177                { 
    11731178                        addrRootInfo = new Array(); 
    11741179                } 
    1175                  
     1180 
    11761181                var i = addrRootInfo.length; 
    11771182                addrRootInfo[addrInfo['id_typeof_address']] = new Array(); 
     
    12031208        for(idx_conn; idx_conn < cc_conn_default.options.length; idx_conn++) 
    12041209                if(cc_conn_default.options[idx_conn].value == _label) 
    1205                         break;   
    1206          
     1210                        break; 
     1211 
    12071212        if(idx_conn == cc_conn_default.options.length) 
    12081213                cc_conn_default.options[idx_conn] = new Option (_label,_label, false,false); 
    1209                          
     1214 
    12101215        if (!document.all) 
    12111216        { 
    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>'; 
     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                } 
    12171233        } 
    12181234        else 
     
    12381254                img.align = 'top'; 
    12391255                img.onclick = function(e){ removeConnField(remove_id);}; 
    1240                  
     1256 
    12411257                for (var i = 0; i < 3; i++) 
    12421258                { 
     
    12491265 
    12501266                inputs[1].id = 'cc_conn_name_'+CC_conn_count; 
    1251                 inputs[1].type = 'hidden';               
     1267                inputs[1].type = 'hidden'; 
    12521268 
    12531269                inputs[2].id = 'cc_conn_value_'+CC_conn_count; 
     
    12781294                || typeof(CC_contact_full_info['connections'][CC_conn_last_selected]) == 'undefined' 
    12791295                || typeof(CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]) == 'undefined'); 
    1280          
    1281         if(_emptyLine) {         
    1282                  
     1296 
     1297        if(_emptyLine) { 
     1298 
    12831299                if(Element("cc_conn_type_sel").value == '-1'){ 
    1284                                 return false;    
    1285                 } 
    1286                  
     1300                                return false; 
     1301                } 
     1302 
    12871303                for(k = 0; k < CC_conn_count; k++) { 
    12881304                        if(Element("cc_conn_name_"+k) && Element("cc_conn_name_"+k).value != "" && Element("cc_conn_name_"+k).value == Element("cc_conn_type_sel").value) { 
    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;                           
     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; 
    12911307                                return false; 
    12921308                        } 
    12931309                } 
    1294         }        
     1310        } 
    12951311        if (!document.all) 
    12961312        { 
     
    13191335 
    13201336function connRemoveLine(id) 
    1321 {        
     1337{ 
    13221338        var p = Element(id).parentNode; 
    13231339        var cc_conn_default = Element("cc_phone_default").style.display == '' ? Element("cc_phone_default") : Element("cc_email_default"); 
     
    13581374                } 
    13591375        } 
    1360          
     1376 
    13611377        CC_conn_count = 0; 
    13621378} 
     
    13801396function updateConnFields() 
    13811397{ 
    1382          
     1398 
    13831399        var connID; 
    13841400        var i; 
     
    13891405        var cc_conn_is_default = ''; 
    13901406        var selected_index = ''; 
    1391          
     1407 
    13921408        cc_conn_type_sel.disabled = false; 
    13931409        div_cc_conn_is_default.style.display = ""; 
    1394          
     1410 
    13951411        for(var i = 0;i < cc_conn_type_sel.options.length; i++) 
    1396                 cc_conn_type_sel.options[i--] = null;    
    1397                  
     1412                cc_conn_type_sel.options[i--] = null; 
     1413 
    13981414        if(Element('cc_conn_type_1').checked) { 
    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);         
     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'); 
    14051418                connID = 1; 
    14061419                selected_index = cc_email_default.options.selectedIndex; 
     
    14091422                } 
    14101423 
    1411                 var lang_select_email = Element('cc_msg_select_email').value; 
    1412                 cc_email_default.options[0] = new Option(lang_select_email,'-1');                
     1424                cc_email_default.options[0] = new Option('Selecionar Email...','-1'); 
     1425 
    14131426                cc_phone_default.style.display = 'none'; 
    1414                 cc_email_default.style.display = '';                     
     1427                cc_email_default.style.display = ''; 
    14151428                cc_conn_is_default = cc_email_default; 
    14161429        } 
    14171430        else if(Element('cc_conn_type_2').checked) { 
    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  
     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'); 
    14311437                connID = 2; 
    14321438                selected_index = cc_phone_default.options.selectedIndex; 
     
    14351441                } 
    14361442 
    1437                 var lang_choose_phone = Element('cc_msg_choose_phone').value;            
    1438                 cc_phone_default.options[0] = new Option(lang_choose_phone,'-1'); 
     1443                cc_phone_default.options[0] = new Option('Selecionar Telefone...','-1'); 
    14391444                cc_email_default.style.display = 'none'; 
    14401445                cc_phone_default.style.display = ''; 
    14411446                cc_conn_is_default = cc_phone_default; 
    14421447        } 
    1443                          
     1448 
    14441449        Element("cc_conn_type_sel").options.selectedIndex = 0; 
    14451450        /* First save the data */ 
     
    14471452 
    14481453        CC_conn_last_selected = connID; 
    1449          
     1454 
    14501455        clearConn(); 
    1451          
     1456 
    14521457        if (connID == '_NONE_') 
    14531458        {       cc_conn_is_default.disabled = true; 
    14541459                return; 
    14551460        } 
    1456          
     1461 
    14571462        /* If no data already available, return */ 
    14581463        if (!CC_contact_full_info['connections']) 
     
    14781483                        } 
    14791484                } 
    1480         }        
     1485        } 
    14811486        if(cc_conn_is_default.options.length > selected_index) 
    14821487                cc_conn_is_default.options.selectedIndex = (selected_index == "-1" ? 0 : selected_index); 
     
    14991504                        CC_contact_full_info['connections'][CC_conn_last_selected] = new Array(); 
    15001505                } 
    1501                 else  
     1506                else 
    15021507                { 
    15031508                        delete CC_contact_full_info['connections'][CC_conn_last_selected]; 
     
    15111516                                var subNodes = nodes[i].childNodes; 
    15121517                                var found = false; 
    1513                                  
     1518 
    15141519                                for (var j = 0; j < subNodes.length; j++) 
    15151520                                { 
    1516                                         if (subNodes[j].childNodes.length > 0 &&  
     1521                                        if (subNodes[j].childNodes.length > 0 && 
    15171522                                            subNodes[j].childNodes[0].id) 
    15181523                                        { 
     
    15221527                                                        CC_contact_full_info['connections'][CC_conn_last_selected][k] = new Array(); 
    15231528                                                } 
    1524                                                  
     1529 
    15251530                                            if (subNodes[j].childNodes[0].id.indexOf('cc_conn_name') != -1) 
    15261531                                                { 
     
    15421547                                                        else 
    15431548                                                        { 
    1544                                                                 CC_contact_full_info['connections'][CC_conn_last_selected][k]['value'] = '';  
     1549                                                                CC_contact_full_info['connections'][CC_conn_last_selected][k]['value'] = ''; 
    15451550                                                        } 
    15461551                                                } 
     
    15531558                                        } 
    15541559                                } 
    1555                                  
     1560 
    15561561                                if (found) 
    15571562                                { 
     
    15701575                        delete CC_contact_full_info['connections'][CC_conn_last_selected]; 
    15711576                } 
    1572                  
     1577 
    15731578        } 
    15741579 
     
    15961601        var number = randomString().toLowerCase(); 
    15971602        var result = ''; 
    1598          
     1603 
    15991604        if(!is_ie) 
    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); 
     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); 
    16011606        else 
    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,""); 
     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,""); 
    16031608 
    16041609        if(result) { 
     
    16061611                        Connector.newRequest('removeAllEntries', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=remove_all_entries', 'GET', handler); 
    16071612                else 
    1608                         alert('Código Incorreto'); 
    1609         }        
     1613                        alert('Cï¿œdigo Incorreto'); 
     1614        } 
    16101615} 
    16111616 
     
    16181623                return; 
    16191624        } 
    1620          
     1625 
    16211626        var handler = function (responseText) 
    16221627        { 
     
    16281633                        return; 
    16291634                } 
    1630                  
     1635 
    16311636                if (data['status'] != 'ok') 
    16321637                { 
     
    16341639                        return; 
    16351640                } 
    1636                  
     1641 
    16371642                setTimeout('updateCards()',80);; 
    16381643        }; 
    1639                  
     1644 
    16401645        typeArg = (type == 'groups' ? 'group' : 'entry'); 
    1641                  
     1646 
    16421647        Connector.newRequest('removeEntry', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=remove_'+typeArg+'&remove=' + id, 'GET', handler); 
    16431648} 
     
    16621667        var w_height = 0; 
    16631668        var w_extra = 200; 
    1664          
     1669 
    16651670        if (document.body.clientHeight) 
    16661671        { 
     
    16911696                        Element('cc_letter_' + i).className = 'letter_box'; 
    16921697                } 
     1698        } 
     1699} 
     1700 
     1701function clearLetterSelection() 
     1702{ 
     1703        for (var i = 0; i < 28; i++) 
     1704        { 
     1705                Element('cc_letter_' + i).className = 'letter_box'; 
    16931706        } 
    16941707} 
     
    17581771                                final_page = 1; 
    17591772                        } 
    1760                          
     1773 
    17611774                        html_pages += '<a href="javascript:setPages('+npages+', '+ actual_page +', '+ final_page +')">...</a> '; 
    17621775 
    17631776                        page = showing_page ? showing_page : actual_page; 
    17641777                } 
    1765                  
     1778 
    17661779                for (; page <= npages; page++) 
    17671780                { 
     
    18231836                Element('cc_panel_arrow_last').style.cursor = 'hand'; 
    18241837        } 
    1825          
     1838 
    18261839        Element('cc_panel_pages').innerHTML = html_pages; 
    18271840} 
     
    18291842function populateCards(data, type) 
    18301843{ 
    1831         if (data[3].length >= 100 ) 
    1832         { 
    1833                 alert("Critério de pesquisa muito abrangente, achados " + data[3].length + " resultados"); 
    1834                 for (i = 0; i < (Math.sqrt(data[3].length)-1); i++) 
    1835                         for (j = 0; j < 3; j++) 
    1836                                 document.getElementById("cc_card:"+j+":"+i).innerHTML = ''; 
    1837                 return false; 
    1838         } 
    1839          
     1844 
    18401845        if(type == 'groups') 
    18411846                return populateGroupsInCards(data); 
    1842          
     1847 
    18431848        var pos = 0; 
    18441849        var ncards = data[3].length; 
    1845          
     1850 
    18461851        if (typeof(data[3]) == 'object' && ncards > 0) 
    18471852        { 
     
    18511856                        { 
    18521857                                id = 'cc_card:'+j+':'+i; 
    1853                          
     1858 
    18541859                                for (var k = 0; k < data[2].length; k++) 
    18551860                                { 
     
    18581863                                                Element(id).style.display = 'none'; 
    18591864                                                continue; 
    1860                                         }                                        
    1861                                  
     1865                                        } 
     1866 
    18621867                                        if(data[3][pos][k] != 'none') 
    18631868                                        { 
     
    18751880                                                                } 
    18761881                                                                break; 
    1877                                                          
     1882 
    18781883                                                        case 'cc_mail': 
    1879                                                                  
    18801884                                                                if (data[3][pos][k].length > (CC_visual == 'table'  ? 50 : 20)) 
    18811885                                                                { 
     
    18851889                                                                else 
    18861890                                                                { 
    1887                                                                         Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>';                                                                   
     1891                                                                        Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>'; 
    18881892                                                                } 
    18891893                                                                break; 
    1890                                                          
     1894 
    18911895                                                        case 'cc_phone': 
    18921896                                                                if (data[3][pos][k].length > 20) 
     
    19191923                                                                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] : ''); 
    19201924                                                                if(ccTree.catalog_perms == 1) 
    1921                                                                         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>'; 
     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>'; 
    19221926                                                                break; 
    19231927 
    19241928                                                        case 'cc_forwarding_address': 
    19251929                                                                var contacts = data[3][pos][k]; 
    1926                                                                                                                                  
     1930 
    19271931                                                                if( !contacts) 
    19281932                                                                        break; 
    1929                                                                                                                                                                                                                                                                                                                                  
     1933 
    19301934                                                                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]; 
    19311962                                                                break; 
    19321963 
     
    19391970                                                                else 
    19401971                                                                { 
     1972                                                                        if (Element(id+':'+data[2][k]) == null) alert('ï¿œ nulovgdfv'); 
    19411973                                                                        Element(id+':'+data[2][k]).innerHTML = data[3][pos][k]; 
    19421974                                                                } 
     
    19441976                                        } 
    19451977                                } 
    1946          
     1978 
    19471979                                if (--ncards == 0) 
    19481980                                { 
     
    19501982                                        i = CC_max_cards[1]; 
    19511983                                } 
    1952          
     1984 
    19531985                                pos++; 
    19541986                        } 
     
    19581990 
    19591991function populateGroupsInCards(data) 
    1960 {        
     1992{ 
    19611993        var pos = 0; 
    1962         var contacts = data[5];          
     1994        var contacts = data[5]; 
    19631995        var ncards = data[3].length; 
    1964          
     1996 
    19651997        if (typeof(data[3]) == 'object' && ncards > 0) 
    19661998        { 
     
    19702002                        { 
    19712003                                id = 'cc_card:'+j+':'+i; 
    1972                          
     2004 
    19732005                                for (var k = 0; k < data[2].length; k++) 
    19742006                                { 
    1975                                  
     2007 
    19762008                                        if(data[3][pos][k] != 'none') 
    1977                                         {        
    1978                                                                                          
     2009                                        { 
     2010 
    19792011                                                switch (data[2][k]) 
    1980                                                 {                                                        
     2012                                                { 
    19812013                                                        case 'cc_title': 
    19822014                                                                if (data[3][pos][k].length > 50) 
     
    19902022                                                                } 
    19912023                                                                break; 
    1992                                                          
     2024 
    19932025                                                        case 'cc_short_name': 
    19942026                                                                if (data[3][pos][k].length > (CC_visual == 'table'  ? 50 : 20)) 
     
    20022034                                                                } 
    20032035                                                                break; 
    2004                                                          
     2036 
    20052037                                                        case 'cc_contacts': 
    20062038 
     
    20112043                                                                var email = ""; 
    20122044 
    2013                                                                 for (var d = 0; d < contacts.length; d++) {                                                                                                                                                                                                                                                                                                      
     2045                                                                for (var d = 0; d < contacts.length; d++) { 
    20142046                                                                        contact += contacts[d]['names_ordered']+ ","; 
    20152047                                                                        email += contacts[d]['connection_value']+","; 
    20162048                                                                } 
    2017                                                                  
     2049 
    20182050                                                                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>'; 
    2019                                                                                                                                                                          
     2051 
    20202052                                                                break; 
    2021                                                          
     2053 
    20222054                                                        case 'cc_id': 
    20232055                                                                var id_contact = data[3][pos][k]; 
    20242056                                                                Element(id+':'+data[2][k]).value = data[3][pos][k]; 
    2025                                                                                                                          
     2057 
    20262058                                                                break; 
    2027                                                                  
     2059 
    20282060                                                } 
    20292061                                        } 
    20302062                                } 
    2031          
     2063 
    20322064                                if (--ncards == 0) 
    20332065                                { 
     
    20352067                                        i = CC_max_cards[1]; 
    20362068                                } 
    2037          
     2069 
    20382070                                pos++; 
    20392071                        } 
     
    20642096        }; 
    20652097 
    2066         Connector.newRequest('setMaxCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=set_n_cards&ncards=' + ncards, 'GET');  
     2098        Connector.newRequest('setMaxCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=set_n_cards&ncards=' + ncards, 'GET'); 
    20672099} 
    20682100 
     
    20702102{ 
    20712103        var coord = new Array(); 
    2072          
     2104 
    20732105        //Element('cc_card_space').innerHTML = ''; 
    20742106        //return; 
     
    20772109        //card_space_width = parseInt(is_ie ? document.body.offsetWidth : window.innerWidth) - parseInt(Element('cc_left').offsetWidth) - parseInt(CC_card_extra) - 40; 
    20782110        card_space_height = parseInt(Element('cc_card_space').offsetHeight) - parseInt(CC_card_extra); 
    2079          
     2111 
    20802112        card_width = CC_card_image_width + CC_card_extra; 
    20812113        card_height = CC_card_image_height + CC_card_extra; 
     
    20832115        ncols = parseInt(card_space_width / card_width); 
    20842116        nlines = parseInt(card_space_height / card_height); 
    2085          
     2117 
    20862118        coord[0] = ncols; 
    20872119        //coord[1] = nlines; 
     
    20972129{ 
    20982130                if(type != 'groups') { 
    2099                  
     2131 
    21002132                        html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' + 
    21012133                                '<div style="border: 0px solid #999; position: relative;">' + 
    2102                                         '<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);">' +  
     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);">' + 
    21032135                                                ( ccTree.catalog_perms == 1 ? 
    21042136                                                '<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>':'') + 
     
    21062138                                                '<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">' + 
    21072139                                                '<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">' : '') + 
    2108                                                 '<img id="' + id + ':cc_photo" style="position: absolute; top: 15px; left: 7px;" src="" border="0" ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' +  
     2140                                                '<img id="' + id + ':cc_photo" style="position: absolute; top: 15px; left: 7px;" src="" border="0" ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' + 
    21092141                                                '<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>' + 
    2110                                                 '<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>'+  
    2111                                                 '<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>' +  
    2112                                                 '<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>' +  
    2113                                                 '<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>' +  
    2114                                                 '<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>' +  
    2115                                                 '<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>' +  
     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>' + 
    21162152                                        '<input id="' + id + ':cc_id" type="hidden">' + 
    21172153                                '</div>' + '</td>'; 
    2118                  
     2154 
    21192155                } else { 
    21202156                        html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' + 
    2121             '<div style="border: 0px solid #999; position: relative;">' +  
     2157            '<div style="border: 0px solid #999; position: relative;">' + 
    21222158                                '<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);">' + 
    21232159                                '<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">' + 
    2124                                 '<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">' +  
     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">' + 
    21252161                                '<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>' + 
    21262162                                '<span id="' + id + ':cc_participantes" style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 15px; left: 15px"></span>' + 
     
    21292165                        '</div>' + '</td>'; 
    21302166                } 
    2131          
     2167 
    21322168 
    21332169        return html_card; 
     
    21412177                        else 
    21422178                                bg = "this.style.background=\'#EEEEEE\'"; 
    2143                                                  
     2179 
    21442180                        if(type != 'groups') { 
    2145                          
    2146                                 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;">' +                                        
    2147                                         '<span valign="bottom" id="' + id + ':cc_icon_group">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="' + id + ':cc_name"></span></td>' + 
     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>' + 
    21482186                                        '<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>' + 
    2149                                         '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_phone"></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>' + 
    21502192                                        ( ccTree.catalog_perms == 1 ? 
    21512193                                        '<td align="left"><span valign="bottom" id="' + id + ':cc_icon_data"></span></td>':'') + 
     
    21562198                                        '<img title="'+Element('cc_msg_card_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);" src="templates/default/images/cc_x.png">' : '') + 
    21572199                                        '<input id="' + id + ':cc_id" type="hidden">'+ 
    2158                                         '<input type="hidden" id="' + id + ':cc_photo">' +  
    2159                                         '<span id="' + id + ':cc_title" style="display:none"></span>' +  
    2160                                         '<span id="' + id + ':cc_alias" style="display:none"></span>' +  
     2200                                        '<input type="hidden" id="' + id + ':cc_photo">' + 
     2201                                        '<span id="' + id + ':cc_title" style="display:none"></span>' + 
     2202                                        '<span id="' + id + ':cc_alias" style="display:none"></span>' + 
     2203                                        // Esse campo ï¿œ necessï¿œrio se o contato possui dados no campo cc_company 
     2204                                        '<span id="' + id + ':cc_company" style="display:none"></span>' + 
    21612205                                        '</td></tr>'; 
    21622206                        } 
     
    21702214                                        '&nbsp;&nbsp;|&nbsp;&nbsp;'+ 
    21712215                                        '<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">'  + 
    2172                                         '<input id="' + id + ':cc_id" type="hidden">'+                                                                           
     2216                                        '<input id="' + id + ':cc_id" type="hidden">'+ 
    21732217                                        '</td></tr>'; 
    21742218                        } 
     
    21802224{ 
    21812225        var pos; 
    2182          
     2226 
    21832227        html_cards = '<div id="divScrollMain" style="overflow:auto;z-index:1"><table width="100%" border="0" cellpadding="0" cellspacing="3">'; 
    2184          
     2228 
    21852229        if (ncards > 0) 
    21862230        { 
     
    22022246                if((ccTree.catalog_perms & 2) && type != 'groups') 
    22032247                        html_cards += '<tr><td colspan=4 align="right"><button id="cc_button_tools" value="" type="button" onclick="javascript:removeAllEntries()">Remover Todos</button></td></tr>'; 
    2204         }        
     2248        } 
    22052249        else if (CC_max_cards != 0) 
    22062250        { 
     
    22222266        html_cards = '<div id="divScrollMain" style="overflow:auto;z-index:1">'; 
    22232267        html_cards += '<table  border="0" cellpadding="0" cellspacing="' + CC_card_extra + '">'; 
    2224          
     2268 
    22252269        if (ncards > 0) 
    22262270        { 
     
    22412285                if((ccTree.catalog_perms & 2) && type != 'groups') 
    22422286                        html_cards += '<tr><td colspan=3 align="right"><button id="cc_button_tools" value="" type="button" onclick="javascript:removeAllEntries()">Remover Todos</button></td></tr>'; 
    2243         }        
     2287        } 
    22442288        else if (CC_max_cards != 0) 
    22452289        { 
     
    22782322                else if(CC_visual == 'table') 
    22792323                        drawTable(0); 
    2280                          
     2324 
    22812325                setPages(0,0); 
    22822326                return; 
     
    22882332                data = unserialize(responseText); 
    22892333                if (data[0] == '0') 
    2290                 {                                
    2291                         Element('cc_type_contact').value = data[1];                      
     2334                { 
     2335                        Element('cc_type_contact').value = data[1]; 
    22922336                        CC_npages = 0; 
    22932337                        CC_actual_page = 1; 
     
    23012345                else 
    23022346                Element('cc_type_contact').value = data[10]; 
    2303                  
    2304 //              Element('cc_debug').innerHTML = responseText;                                            
    2305                  
     2347 
     2348//              Element('cc_debug').innerHTML = responseText; 
     2349 
    23062350                if (typeof(data) != 'object') 
    23072351                { 
     
    23092353                        return; 
    23102354                } 
    2311                  
     2355 
    23122356                if (typeof(data[3]) == 'object') 
    23132357                { 
    23142358                        CC_npages = parseInt(data[0]); 
    2315                         CC_actual_page = parseInt(data[1]);                      
     2359                        CC_actual_page = parseInt(data[1]); 
    23162360                        if(CC_visual == 'cards') 
    23172361                                drawCards(data[3].length, data[10]); 
     
    23212365                        populateCards(data, data[10]); 
    23222366                        setPages(data[0], data[1]); 
    2323                          
     2367 
     2368                } 
     2369                else if (data['error']) 
     2370                { 
     2371                        showMessage(data['error']); 
    23242372                } 
    23252373                else 
     
    23322380        var info = "letter="+letter+"&page="+CC_actual_page+"&ids="+ids; 
    23332381        Connector.newRequest('showCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cards_data', 'POST', handler, info); 
     2382} 
     2383 
     2384 
     2385function clearCards() 
     2386{ 
     2387        clearLetterSelection(); 
     2388        setHeightSpace(); 
     2389        setMaxCards(getMaxCards()); 
     2390 
     2391        if(CC_visual == 'cards') 
     2392                drawCards(0); 
     2393        else if(CC_visual == 'table') 
     2394                drawTable(0); 
     2395 
     2396        setPages(0,0); 
     2397        return; 
    23342398} 
    23352399 
     
    23422406        var table_h = Element('cc_panel_table'); 
    23432407        var cards_h = Element('cc_panel_cards'); 
    2344          
     2408 
    23452409        switch (type) 
    23462410        { 
     
    23552419                        break; 
    23562420        } 
    2357          
     2421 
    23582422        CC_visual = type; 
    23592423        showCards(getActualLetter(), getActualPage()); 
    23602424} 
    23612425 
    2362 function ccSearchUpdate(ids) 
     2426/*function ccSearchUpdate(ids) 
    23632427{ 
    23642428        Element('cc_panel_letters').style.display = 'none'; 
    23652429        Element('cc_panel_search').style.display  = 'inline'; 
    2366          
     2430 
    23672431        if(CC_visual == 'cards') 
    23682432                drawCards(0); 
     
    23752439                return; 
    23762440        } 
    2377          
     2441 
    23782442        var sIds = serialize(ids); 
    23792443 
     
    23832447        } 
    23842448        showCards('search', '1', sIds); 
     2449} 
     2450*/ 
     2451 
     2452function 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); 
    23852467} 
    23862468 
     
    23992481        Element('cc_panel_search').style.display  = 'none'; 
    24002482        Element('cc_panel_letters').style.display = 'inline'; 
    2401         showCards(CC_last_letter, '1'); 
     2483        clearCards(); 
     2484        //showCards(CC_last_letter, '1'); 
    24022485} 
    24032486 
     
    24242507        data[3] = Element('cc_qa_phone').value; 
    24252508        data[4] = Element('cc_qa_email').value; 
     2509 
     2510        return data; 
     2511} 
     2512 
     2513function sendQuickAdd () 
     2514{ 
     2515        var data = getQuickAdd(); 
     2516 
     2517        var str = serialize(data); 
     2518 
     2519        if (!str) 
     2520        { 
     2521                return false; 
     2522        } 
     2523 
     2524        var handler = function (responseText) 
     2525        { 
     2526                setTimeout('updateCards()',100);; 
     2527        } 
     2528 
     2529        resetQuickAdd(); 
     2530 
     2531        Connector.newRequest('quickAdd', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=quick_add', 'POST', handler, 'add='+escape(str)); 
     2532} 
     2533 
    24262534         
    2427         return data; 
    2428 } 
    2429  
    2430 function sendQuickAdd () 
    2431 { 
    2432         var data = getQuickAdd(); 
    2433          
    2434         var str = serialize(data); 
    2435  
    2436         if (!str) 
    2437         { 
    2438                 return false; 
    2439         } 
    2440  
    2441         var handler = function (responseText) 
    2442         { 
    2443                 setTimeout('updateCards()',100);; 
    2444         } 
    2445  
    2446         resetQuickAdd(); 
    2447  
    2448         Connector.newRequest('quickAdd', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=quick_add', 'POST', handler, 'add='+escape(str)); 
    2449 } 
     2535function connectVoip (phoneUser, typePhone){ 
     2536        var handler_voip = function (responseText){ 
     2537                if(!responseText) { 
     2538                        alert("Erro conectando servidor VoIP."); 
     2539                } 
     2540                else{ 
     2541                        data = unserialize(responseText); 
     2542                        alert("Requisitando chamada para o ramal: "+data); 
     2543                } 
     2544        } 
     2545        Connector.newRequest('voip', "../../expressoMail1_2/controller.php?action=expressoMail1_2.functions.callVoipconnect&to="+phoneUser+"&typePhone="+typePhone, 'POST', handler_voip); 
     2546        } 
  • trunk/contactcenter/js/ccAddGroup.js

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

    r270 r284  
    33                this.el;                 
    44                this.wWidth = 395; 
    5                 this.wHeight = 255; 
     5                this.wHeight = 240; 
    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         }        
    3918         
    4019        cIEContacts.prototype.showList = function(){ 
     
    5837                        this.el.id = 'cc_rectIEContacts'; 
    5938                        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_moz_tb = Element('cc_msg_moz_thunderbird').value; 
    72                         var lang_outl_pt = Element('cc_msg_outlook_express_pt').value; 
    73                         var lang_outl_en = Element('cc_msg_outlook_express_en').value; 
    74                         var lang_outl2k_pt = Element('cc_msg_outlook_2k_pt').value; 
    75                         var lang_outl2k_en = Element('cc_msg_outlook_2k_en').value; 
    76                         var lang_expresso_default_csv = Element('cc_msg_expresso_default_csv').value; 
    77  
    78                  
    7939                        this.el.innerHTML =  
    8040                        '<div align="left" id="divAppbox"><table width="100%" border=0>'+ 
    81                         '<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+ 
    82                         '&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>'+ 
     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>'+ 
    8343                        '</table>'+ 
    8444                        '<table border=0 height="208px"  width="100%" id="import_span">'+ 
    8545                        '<tr><td>'+ 
    86                         '<font color="DARKBLUE" size="2">'+lang_expresso_info_csv+'</font></td></tr>'+ 
     46                        '<font color="DARKBLUE" size="2">O Expresso suporta a importação de contatos no formato de arquivo CSV.</font></td></tr>'+ 
    8747                        '<tr><td height="75px" valign="top">'+ 
    88                         '<form name="formCSV" method="POST" enctype="multipart/form-data">'+ lang_msg_choose_type + 
    89                         ':&nbsp;<select id="typeImport"><option value="auto" selected>'+lang_msg_automatic+'</option>'+ 
    90                         '<option value="outlook">'+("Outlook Express")+'</option>'+ 
    91                         '<option value="outlook2000">'+("Outlook 2000")+'</option>'+ 
    92                         '<option value="thunderbird">'+("Mozilla Thunderbird")+'</option>'+ 
    93                         '<option value="expresso">'+lang_expresso_default+'</option></select><br>'+ 
    94                         '<br>'+lang_choose_contacts_file+'<br><br>'+                     
     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>'+                    
    9555                        '<input id="import_file" type="file" name="import_file">'+ 
    9656                        '</form></td></tr>'+ 
    9757                        '<tr><td height="10px" align="center" nowrap><span style="visibility:hidden" id="s_info"></span></td></tr>'+ 
    9858                        '<tr><td height="10px" align="center"></td></tr>'+ 
    99                         '<tr><td nowrap><center><input id="import_button" type="button" value='+lang_import_contacts+' onClick="javascript:ccIEContacts.importCSV(this)">&nbsp;&nbsp;&nbsp;&nbsp;'+ 
    100                         '<input type="button" value='+lang_close_win+' onClick="javascript:ccIEContacts.close()"></center></td></tr>'+ 
    101                         '<tr><td height="10px" align="center" nowrap><span style="visibility:hidden" id="s_info2"></span></td></tr></table>'+ 
     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>'+ 
    10262                        '<table border=0  height="208px"  width="100%" style="display:none" id="export_span">'+ 
    10363                        '<tr><td>'+                                              
    104                         '<font color="DARKBLUE" size="2">'+ lang_msg_expresso_info_csv+'</font></td></tr>'+ 
    105                         '<tr><td height="85px" valign="top">'+lang_msg_export_csv+'<br><br>'+ 
    106                         '<input style="border:0" id="typeExport_0" name="radio" type="radio" value="expresso" checked/>'+lang_expresso_default_csv+'<br>'+ 
    107                         '<input style="border:0" id="typeExport_1" name="radio" type="radio" value="outlook_pt-BR">'+lang_outl_pt+ '<br>'+ 
    108                         '<input style="border:0" id="typeExport_2" name="radio" type="radio" value="outlook_en">'+lang_outl_en+ '<br>'+ 
    109                         '<input style="border:0" id="typeExport_3" name="radio" type="radio" value="outlook2000_pt-BR">'+lang_outl2k_pt + '<br>'+ 
    110                         '<input style="border:0" id="typeExport_4" name="radio" type="radio" value="outlook2000_en">'+lang_outl2k_en + '<br>'+ 
    111                         '<input style="border:0" id="typeExport_5" name="radio" type="radio" value="thunderbird">'+lang_moz_tb + '<br>'+ 
     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>'+ 
    11273                        '</td></tr>'+ 
    11374                        '<tr><td align="center">&nbsp;</td></tr>'+ 
    114                         '<tr><td nowrap><center><input id="export_button" type="button" value='+lang_export_contacts+ ' onClick="javascript:ccIEContacts.exportCSV(this)">&nbsp;&nbsp;&nbsp;&nbsp;'+ 
    115                         '<input type="button" value='+lang_close_win+ ' onClick="javascript:ccIEContacts.close()"></center></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>'+ 
    11677                        '</table></div>'; 
    11778                }                
    11879                this.showWindow(); 
    11980        } 
    120          
     81                 
    12182        cIEContacts.prototype.showWindow = function () 
    12283        {                                                
    12384                if(!this.win) { 
    124          
    125                                 this.win = new dJSWin({                  
     85 
     86                        this.win = new dJSWin({                  
    12687                                id: 'ccIEContacts', 
    12788                                content_id: this.el.id, 
     
    13091                                title_color: '#3978d6', 
    13192                                bg_color: '#eee', 
    132                                 title: Element('cc_msg_ie_personal').value,  
     93                                title: "Importar / Exportar Contatos Pessoais",                                          
    13394                                title_text_color: 'white', 
    13495                                button_x_img: '../phpgwapi/images/winclose.gif', 
     
    151112                var status = ''; 
    152113 
    153                 var lang_import_fail = Element('cc_msg_import_fail').value; 
    154                 var lang_importing = Element('cc_msg_importing_contacts').value; 
    155                 var lang_import_finish = Element('cc_msg_import_finished').value; 
    156                 var lang_new = Element('cc_msg_new').value; 
    157                 var lang_failure = Element('cc_msg_failure').value; 
    158                 var lang_exists = Element('cc_msg_exists').value; 
    159                 var lang_show_more_info = Element('cc_msg_show_more_info').value; 
    160  
    161                 var l_1         = '<font face="Verdana" size="1" color="GREEN">['+args[1]+lang_new+']</font>'; 
    162                 var l_2         = '<font face="Verdana" size="1" color="RED">['+args[2]+lang_failure+']</font>'; 
    163                 var l_3         = '<font face="Verdana" size="1" color="DARKBLUE">['+args[3]+lang_exists+']</font>'; 
    164                 var l_4         = '<br><a font face="Verdana" size="1" href="javascript:ccIEContacts.showFailures(\''+args[4]+'\')">'+lang_show_more_info+'</a>'; 
    165                 var l_error     = '<span style="height:15px;background:#cc4444">&nbsp;&nbsp;<font face="Verdana" size="1" color="WHITE">'+lang_import_fail+ '&nbsp;</font></span>'; 
    166                 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>'; 
     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>'; 
    167119 
    168120                if(args[0] == 'success') { 
    169121 
    170                         for(i = 1; i < 5; i++) { 
     122                        for(i = 1; i < 4; i++) { 
    171123                                status += "&nbsp;"+eval('l_'+i); 
    172124                        } 
    173                         Element('s_info').innerHTML = '&nbsp;&nbsp;<font face="Verdana" size="1" color="BLACK"><b>'+lang_import_finish+'</b></font><br>&nbsp;'+status; 
     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; 
    174126                } 
    175127                else  
     
    196148        cIEContacts.prototype.importCSV = function () 
    197149        {                
    198                 var lang_msg_invalid_csv = Element('cc_msg_invalid_csv').value; 
    199150                var form = document.formCSV; 
     151                 
    200152                if ((form.import_file.value.length < 10) ||  
    201                 (form.import_file.value.substring(form.import_file.value.length - 4, form.import_file.value.length).toLowerCase() != ".csv")){ 
    202                         alert(lang_msg_invalid_csv); 
     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.'); 
    203155                        return; 
    204156                } 
     
    218170                                args[2] = data._failure ? data._failure : 0; 
    219171                                args[3] = data._existing ? data._existing : 0; 
    220                                 args[4] = data._failure_status 
    221  
    222172                        } 
    223173                        _this.importWriteStatus(args); 
     
    258208         
    259209        cIEContacts.prototype.exportCSV = function() { 
    260                 var lang_export_error = Element('cc_msg_export_error'); 
     210 
    261211                var handler_export = function(data) { 
    262212                        if(!data){ 
    263                                 alert(lang_export_error ); 
     213                                alert("Ocorreu um erro durante a exportação."); 
    264214                                return; 
    265215                        }                                
  • trunk/contactcenter/js/ccMain.js

    r119 r284  
    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')); 
    42                          
     42 
    4343                /* Create the Tree Object */ 
    44                 ccTree = new ccCatalogTree({name: 'ccTree', id_destination: 'cc_tree', afterSetCatalog: 'ccSearchHidePanel(); updateCards()'}); 
     44                //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();'}); 
    4546 
    4647                ccTree.Connector = Connector; 
     
    6465        var _timeout = ''; 
    6566        var menu = function () { 
    66                   
     67 
    6768         if(! this.menuStarted) 
    6869                this.menuStarted = true; 
    69                  
     70 
    7071                submenu = []; 
    7172                textmenu = []; 
    72                          
     73 
    7374                textmenu[0] = ["cc_msg_contact_qa","cc_msg_contact_full","cc_msg_group"] 
    74                 textmenu[1] = ["cc_quick_add", "cc_full_add", "cc_add_group"];           
     75                textmenu[1] = ["cc_quick_add", "cc_full_add", "cc_add_group"]; 
    7576                function show(){ 
    7677                        clearTimeout(_timeout); 
    7778                        button = document.getElementById("cc_button_new"); 
    78                                  
    79                         this.style.top = 19 + findPosY(button) + "px";  
    80                         this.style.visibility='visible';  
     79 
     80                        this.style.top = 19 + findPosY(button) + "px"; 
     81                        this.style.visibility='visible'; 
    8182                } 
    8283                function hide(){ _timeout = setTimeout("menu.style.visibility='hidden';",200); }; 
    83                          
     84 
    8485                if(document.getElementById) { 
    8586                        menu = document.getElementById("Layer1"); 
    86                                  
     87 
    8788                        for (i=0; i< textmenu[0].length; i++) { 
    8889                                textmenu[0][i] = "<span onclick= 'menu.onmouseout();'>" + document.getElementById(textmenu[0][i]).value + "</span><br>"; 
    89                                 submenu[i] = document.createElement("DIV");                              
     90                                submenu[i] = document.createElement("DIV"); 
    9091                                submenu[i].innerHTML = textmenu[0][i]; 
    9192                                submenu[i].id = textmenu[1][i]; 
    9293                                submenu[i].onmouseover = function () {this.style.backgroundColor = 'LIGHTYELLOW';this.style.color = 'DARKBLUE';}; 
    93                                 submenu[i].onmouseout   = function () {  this.style.backgroundColor = '#DCDCDC'; this.style.color = '#006699';};                                         
     94                                submenu[i].onmouseout   = function () {  this.style.backgroundColor = '#DCDCDC'; this.style.color = '#006699';}; 
    9495                                submenu[i].setAttribute("className", "special"); 
    9596                                submenu[i].setAttribute("class", "special"); 
    96                                 submenu[i].style.padding = "5px";                                          
     97                                submenu[i].style.padding = "5px"; 
    9798                                menu.appendChild(submenu[i]); 
    98                         }                        
    99                                  
     99                        } 
     100 
    100101                        menu.onmouseover = show; 
    101102                        menu.onmouseout = hide; 
    102103                } 
    103                          
     104 
    104105                ccQuickAdd.associateAsButton(Element('cc_quick_add')); 
    105106                ccAddGroup.associateAsButton(Element('cc_add_group')); 
    106107                document.getElementById("cc_full_add").onclick= newContact; 
    107                           
    108                          
     108 
     109 
    109110                ccQuickAdd.afterSave = function () 
    110111                { 
    111112                        updateCards(); 
    112                 }                        
    113                          
    114                 ccAddGroup.load = function ()  
    115                 {                                
    116                         editGroup();                     
    117                 } 
    118                          
     113                } 
     114 
     115                ccAddGroup.load = function () 
     116                { 
     117                        editGroup(); 
     118                } 
     119 
    119120                ccAddGroup.afterSave = function () 
    120121                { 
    121122                        updateCards(); 
    122123                } 
    123                          
     124 
    124125                return true; 
    125126        } 
     
    127128        if (is_ie) 
    128129        { 
    129                          
     130 
    130131                document.body.onload = function (e) 
    131                 {                        
    132                         Main_pre_load();                                                                 
    133                         Main_load();                                     
    134                                                                  
     132                { 
     133                        Main_pre_load(); 
     134                        Main_load(); 
     135 
    135136                } 
    136137        } 
    137138        else 
    138         {                
    139                 Main_load();     
    140                          
    141         }        
     139        { 
     140                Main_load(); 
     141 
     142        } 
    142143 
    143144// BEGIN: FUNCTION RESIZE WINDOW 
     
    156157showBar = __showBar; 
    157158hideBar = __hideBar; 
    158          
     159 
    159160var _onResize   = window.onresize; 
    160161window.onresize = resizeWindow; 
    161162var defaultHeight = 0; 
    162163function setDefaultHeight(){ 
    163          
     164 
    164165        var bar = Element("toolbar"); 
    165166        var offset = 0; 
    166         if(bar.style.visibility != 'hidden')  
    167                 offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight);      
     167        if(bar.style.visibility != 'hidden') 
     168                offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight); 
    168169 
    169170        var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight; 
    170         defaultHeight = screenHeight - offset;   
    171         Element("cc_tree").style.height                 = defaultHeight - 68;    
    172         Element("cc_left_main").style.height    = defaultHeight - 68;    
     171        defaultHeight = screenHeight - offset; 
     172        Element("cc_tree").style.height                 = defaultHeight - 68; 
     173        Element("cc_left_main").style.height    = defaultHeight - 68; 
    173174} 
    174175 
     
    176177        setDefaultHeight(); 
    177178        if(Element("divScrollMain")) 
    178                 Element("divScrollMain").style.height   = defaultHeight - 108;   
     179                Element("divScrollMain").style.height   = defaultHeight - 108; 
    179180        if (!is_ie) 
    180181                Element('tableDivAppbox').width = '100%'; 
     
    184185setDefaultHeight(); 
    185186Element('cc_main').style.height = defaultHeight; 
    186 var lang_warn_firefox = Element('cc_msg_warn_firefox'); 
    187 var lang_firefox_msg1 = Element('cc_msg_firefox_half1'); 
    188 var lang_firefox_msg2 = Element('cc_msg_firefox_half2'); 
    189 var lang_install_now = Element('cc_msg_install_now'); 
    190 var lang_install_new_firefox = Element('cc_msg_install_new_firefox'); 
    191 var lang_close = Element('cc_msg_close'); 
    192187function buildWarningMsg(_version) { 
    193188        var screenWidth = document.body.clientWidth ? document.body.clientWidth: document.body.offsetWidth; 
     
    196191        "border:1px solid black;left:"+(screenWidth - 330)+";top:10px;width:300px;padding:10px;"+ 
    197192        (document.body.clientWidth ? "-moz-border-radius: 9px 9px 9px 9px;'>" : "")+ 
    198             "<font color='RED' size='2'>"+lang_warn_firefox +  "("+_version+")</font><BR>"+ 
    199             "<font color='black' size='2'><p style='text-align:justify'>&nbsp;"+lang_firefox_msg1+ 
    200             lang_firefox_msg2 + ".</p></font><div style='width:100%' align='center'>"+ 
    201             "<a title='"+lang_install_now+"' href='http://br.mozdev.org/firefox/download.html' target='_blank'>"+lang_install_new_firefox+ "</a>"+       
     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>"+ 
    202198        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ 
    203             "<a title='"+lang_close+"' href='javascript:void(0)' onclick='javascript:myOpacity.toggle()'>"+lang_close+"</a></div>"+ 
    204  
     199        "<a title='Fechar' href='javascript:void(0)' onclick='javascript:myOpacity.toggle()'>Fechar</a></div>"+ 
    205200        "</DIV>"; 
    206201 
     
    208203 
    209204        myOpacity = new fx.Opacity('warning_msg', {duration: 600}); 
    210         document.getElementById("warning_msg").style.visibility = 'hidden';              
     205        document.getElementById("warning_msg").style.visibility = 'hidden'; 
    211206        myOpacity.now = 0; 
    212207        setTimeout("myOpacity.toggle()",3000); 
  • trunk/contactcenter/js/ccQuickAddContact.js

    r118 r284  
    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] : ''; 
    3333                                el.innerHTML += '<span id="ccQuickAddCT' + i + id + '" style="position: absolute; top: ' +  (fieldsTop+i*fieldsSpace) + 'px; left: 5px; width: 100px; text-align: right; border: 0px solid #999;">' + fields[i] + '</span>'; 
    34                                 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;">'; 
     34                                if (i == 0) 
     35                                { 
     36                                        el.innerHTML += '<input id="ccQuickAddCI' + i + id + '" type="text" value="' + contact + '" maxlength="30" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 110px; width: 135px;">'; 
     37                                } 
     38                                else if (i == 4) 
     39                                { 
     40                                        el.innerHTML += '<input id="ccQuickAddCI' + i + id + '" type="text" value="' + contact + '" maxlength="100" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 110px; width: 135px;">'; 
     41                                } 
     42                                else 
     43                                { 
     44                                        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                                } 
    3546                        } 
    36                          
     47 
    3748                        el.innerHTML +='<div id="ccQAFuncitons" style="border: 0px solid black; width: 220px; height: 20px">' + 
    38                                 '<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" />' + 
    39                                 '<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" />' + 
     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" />' + 
    4051                                '</div>'; 
    4152                        el.innerHTML += "<br>"; 
    42                                                                  
     53 
    4354                        _this.showWindow(el); 
    4455                } 
    45                  
     56 
    4657                div = document.getElementById(id+':cc_rectQuickAddContact'); 
    47                                  
     58 
    4859                if(div) 
    4960                        this.showWindow(div); 
     
    5263                } 
    5364        } 
    54          
     65 
    5566        cQuickAddContact.prototype.showWindow = function (div) 
    56         {                                                
     67        { 
    5768                if(! this.arrayWin[div.id]) { 
    5869 
    59                         win = new dJSWin({                       
     70                        win = new dJSWin({ 
    6071                                id: 'ccQuickAddContact_'+div.id, 
    6172                                content_id: div.id, 
     
    6475                                title_color: '#3978d6', 
    6576                                bg_color: '#eee', 
    66                                 title: Element('ccQATitle').value,                                               
     77                                title: Element('ccQATitle').value, 
    6778                                title_text_color: 'white', 
    6879                                button_x_img: Element('cc_phpgw_img_dir').value+'/winclose.gif', 
    6980                                border: true }); 
    70                          
     81 
    7182                        this.arrayWin[div.id] = win; 
    72                         win.draw();                      
     83                        win.draw(); 
    7384                } 
    7485                else { 
    7586                        win = this.arrayWin[div.id]; 
    76                 }                        
     87                } 
    7788                win.open(); 
    7889        } 
    79          
     90 
    8091        cQuickAddContact.prototype.send = function (id) 
    8192        { 
     
    104115                                return; 
    105116                        } 
    106                          
     117 
    107118                        win.close(); 
    108119 
     
    121132                        } 
    122133                } 
    123          
     134 
    124135                var sdata = new Array(); 
    125                  
     136 
    126137                for (var f = 0; f < 5; f++){ 
    127138                        sdata[f] = document.getElementById('ccQuickAddCI' + f + id).value; 
    128139                } 
    129                  
     140 
    130141                //Utiliza expressão regular para validar email 
    131142                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}\])$/; 
     
    136147                        return false; 
    137148                } 
    138                  
     149 
    139150                //Utiliza expressão regular para validar telefone 
    140151                var rePhone = /^[0-9|(-)| |-]{0,15}$/; 
    141                  
     152 
    142153                if (!rePhone.test(sdata[3])){ 
    143154                        alert("O número de telefone '" + sdata[3] + "' não é valido! Utilize apenas números.\n" + 
    144155                        "Parenteses, traços ou espaços em branco podem ser usados como carácter separador."); 
    145156                        return false; 
    146                 }  
    147                  
     157                } 
     158 
    148159                var sdata = 'add='+escape(serialize(sdata)); 
    149160 
    150161                Connector.newRequest('cQuickAdd.Send', CC_url+'quick_add', 'POST', handler, sdata); 
    151162        } 
    152          
     163 
    153164        cQuickAddContact.prototype.fechar = function(id) { 
    154          
     165 
    155166                div = document.getElementById(id+':cc_rectQuickAddContact'); 
    156167                win = this.arrayWin[div.id]; 
    157168                win.close(); 
    158169        } 
    159          
    160          
     170 
     171 
    161172/* Build the Object */ 
    162173        var ccQuickAddContact ; 
     
    164175 
    165176        if (is_ie) 
    166         {  
    167                 document.body.onload = function (e)  
    168                 {  
     177        { 
     178                document.body.onload = function (e) 
     179                { 
    169180                        cQuickAddContact_pre_load(); 
    170181                        ccQuickAddContact = new cQuickAddContact(); 
    171                          
     182 
    172183                }; 
    173184        } 
  • trunk/contactcenter/js/cc_search.js

    r2 r284  
    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; 
    128128                //data['recursive']        = this.recursive.checked ? true : false; 
    129                  
     129                // Exige que a consulta por nome seja feita com no mínimo 4 caracteres 
     130                var search_for = data['search_for'].split(' '); 
     131                var greaterThan4 = false; 
     132 
     133                for (i = 0; i < search_for.length; i++) 
     134                { 
     135                        if (search_for[i].length >= 4) 
     136                        { 
     137                                greaterThan4 = true; 
     138                        } 
     139                } 
     140 
     141                if (!greaterThan4){ 
     142                        alert("Favor fazer a consulta com pelo menos 4 caracteres!"); 
     143                        return; 
     144                } 
     145 
    130146                var _this = this; 
    131147 
     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/* 
    132232                var handler = function (responseText) 
    133233                { 
    134234                        Element('cc_debug').innerHTML = responseText; 
    135                          
     235 
    136236                        var data = unserialize(responseText); 
    137                          
     237 
    138238                        if (!data || !data['status']) 
    139239                        { 
     
    147247                                _this.DOMresult.innerHTML = data['msg']; 
    148248                                setTimeout(function(){_this.DOMresult.innerHTML = '';}, 1000); 
    149                                  
     249 
    150250                                if (_this.onSearchFinish) 
    151251                                { 
     
    163263                        } 
    164264 
    165                         //showMessage(data['msg']); 
     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                        } 
    166274 
    167275                        if (_this.onSearchFinish) 
     
    170278                        } 
    171279                }; 
    172                  
    173                 this.Connector.newRequest('search', CC_url+'search&data='+serialize(data), 'GET', handler); 
     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); 
    174283        } 
  • trunk/contactcenter/js/cc_tree.js

    r56 r284  
    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                                 _this.expandTree(); 
    179  
    180                         } 
    181                 }; 
    182                  
     178                        } 
     179                }; 
     180 
    183181                Connector.newRequest(this.name+'actual', CC_url+'get_actual_catalog', 'GET', handler); 
    184182        } 
    185183 
    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  
    205184        ccCatalogTree.prototype._updateTree = function(level, open) 
    206185        { 
     
    222201                        { 
    223202                                showMessage(data['msg']); 
    224                                 return; 
     203                                if (data['status'] != 'error') 
     204                                { 
     205                                        return; 
     206                                } 
    225207                        } 
    226208 
    227209                        treeData = data['data']; 
    228                          
     210 
    229211                        var timeout = 10; 
    230212                        var limit = 0; 
     
    261243                                timeout += 5; 
    262244                        } 
    263                          
     245 
    264246                        _this.treeAvailable = true; 
    265247 
     
    271253                        } 
    272254                }; 
     255 
    273256                Connector.newRequest(this.name+'update', CC_url+'get_catalog_tree&level='+level, 'GET', handler); 
    274257        } 
  • trunk/contactcenter/setup/setup.inc.php

    r203 r284  
    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

    r203 r284  
    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  
    7958?> 
  • trunk/contactcenter/templates/default/full_add.tpl

    r118 r284  
    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="{emails_telephones}"> 
     15<input id="cc_contact_conns" type="hidden" value="E-mails e Telefones"> 
    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=""></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> 
    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();">{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">                     
     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"> 
    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"> {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> 
     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> 
    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                        Element("divScrollMain").style.overflow = 'auto'; 
    184184                } 
    185185                dJSWin.prototype.open = function() { 
     
    190190                        Element("divScrollMain").style.overflow = 'hidden'; 
    191191                } 
    192         }        
    193                  
     192        } 
     193 
    194194        var fullAdd_onload = document.body.onload; 
    195195        var tabs; 
    196196        var fullAddWin; 
    197         var photo_frame, photo_form, photo_input;        
     197        var photo_frame, photo_form, photo_input; 
    198198 
    199199        __f = function(e) 
    200200        { 
    201                  
     201 
    202202                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',  
     203 
     204                tabs.addTab({'id': 'cc_contact_tab_0', 
     205                                         'name': Element('cc_contact_personal').value, 
     206                                         'selectedClass': 'tab_box_active', 
    207207                                         'unselectedClass': 'tab_box'}); 
    208                                           
    209                 tabs.addTab({'id': 'cc_contact_tab_2',  
    210                                          'name': Element('cc_contact_conns').value,  
    211                                          'selectedClass': 'tab_box_active',  
     208 
     209                tabs.addTab({'id': 'cc_contact_tab_2', 
     210                                         'name': Element('cc_contact_conns').value, 
     211                                         'selectedClass': 'tab_box_active', 
    212212                                         'unselectedClass': 'tab_box'}); 
    213213 
    214                 tabs.addTab({'id': 'cc_contact_tab_1',  
    215                                          'name': Element('cc_contact_addrs').value,  
    216                                          'selectedClass': 'tab_box_active',  
    217                                          'unselectedClass': 'tab_box'});                                          
     214                tabs.addTab({'id': 'cc_contact_tab_1', 
     215                                         'name': Element('cc_contact_addrs').value, 
     216                                         'selectedClass': 'tab_box_active', 
     217                                         'unselectedClass': 'tab_box'}); 
    218218 
    219219                fullAddWin = new dJSWin({'id': 'cc_full_add', 
     
    229229                                         'border': true}); 
    230230 
    231                 fullAddWin.draw();               
    232                                                  
     231                fullAddWin.draw(); 
     232 
    233233                if (is_ie) 
    234234                { 
     
    242242                { 
    243243                        Element('cc_pd_select_photo_t').style.display='none'; 
    244                         Element('cc_pd_select_photo_b').style.display='none';                    
    245                 } 
    246                  
     244                        Element('cc_pd_select_photo_b').style.display='none'; 
     245                } 
     246 
    247247        }; 
    248248 
    249249        if (is_ie) // || is_moz1_6) 
    250250        { 
    251                          
     251 
    252252                document.body.onload = function(e) { setTimeout('__f()', 10); fullAdd_onload ? setTimeout('fullAdd_onload()'): false;}; 
    253253        } 
     
    270270 
    271271 
    272 <!-- RELATIONS  
     272<!-- RELATIONS 
    273273<div id="cc_contact_tab_3" class="row_off div_cc_contact_tab"> 
    274274        <table align="center" width="500px" height="100%" cellpadding="2" cellspacing="0" border="0"> 
  • trunk/contactcenter/templates/default/index.tpl

    r270 r284  
    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 
    1718<input id="cc_root_dir" type="hidden" value="{cc_root_dir}"> 
    1819<input id="cc_msg_card_new" type="hidden" value="{cc_msg_card_new}"> 
     
    2425<input id="cc_msg_card_remove_confirm" type="hidden" value="{cc_msg_card_remove_confirm}"> 
    2526<input id="cc_send_mail" type="hidden" value="{cc_send_mail}"> 
    26 <input id="cc_msg_group_edit" type="hidden" value="{cc_msg_group_edit}">         
     27<input id="cc_msg_group_edit" type="hidden" value="{cc_msg_group_edit}"> 
    2728<input id="cc_msg_group_remove" type="hidden" value="{cc_msg_group_remove}"> 
    2829<input id="cc_msg_group_remove_confirm" type="hidden" value="{cc_msg_group_remove_confirm}"> 
    2930<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_outlook_express_pt" type="hidden" value="{cc_msg_outlook_express_pt}"> 
    72 <input id="cc_msg_outlook_express_en" type="hidden" value="{cc_msg_outlook_express_en}"> 
    73 <input id="cc_msg_outlook_2k_pt" type="hidden" value="{cc_msg_outlook_2k_pt}"> 
    74 <input id="cc_msg_outlook_2k_en" type="hidden" value="{cc_msg_outlook_2k_en}"> 
    75 <input id="cc_msg_moz_thunderbird" type="hidden" value="{cc_msg_moz_thunderbird}"> 
    76 <input id="cc_msg_expresso_default_csv" type="hidden" value="{cc_msg_expresso_default_csv}"> 
    77 <input id="cc_msg_copy_to_catalog" type="hidden" value="{cc_msg_copy_to_catalog}"> 
    78 <input id="cc_msg_fill_field_name" type="hidden" value="{cc_msg_fill_field_name}"> 
    79 <input id="cc_msg_add_contact_to_group" type="hidden" value="{cc_msg_add_contact_to_group}"> 
    80  
    81  
    8231 <!-- END JS MESSAGES --> 
    8332 <input id="cc_type_contact"    type="hidden"> 
    8433 <input id="cc_participants"    type="hidden"  value="{cc_participants}"> 
    85   
     34 
    8635 <input id="cc_qa_alias"                type="hidden" value="{cc_qa_alias}"> 
    8736 <input id="cc_qa_given_names"  type="hidden" value="{cc_qa_given_names}"> 
     
    8938 <input id="cc_qa_phone"                type="hidden" value="{cc_qa_phone}"> 
    9039 <input id="cc_qa_email"                type="hidden" value="{cc_qa_email}"> 
    91   
     40 
    9241 <input id="cc_qa_save"                 type="hidden" value="{cc_qa_save}"> 
    93  <input id="cc_qa_close"                type="hidden" value="{cc_qa_close}"> 
    94   
     42 <input id="cc_qa_clear"                type="hidden" value="{cc_qa_clear}"> 
     43 
    9544 <input id="cc_empty"                   type="hidden"  value="{cc_empty}"> 
    9645  <!-- VIEW CARDS --> 
     
    10453                                </tr> 
    10554                                <tr> 
    106                                         <td width="150px" height="100%" align="left" valign="top">  
     55                                        <td width="150px" height="100%" align="left" valign="top"> 
    10756                                                <div id="cc_tree" style="overflow:auto;position:relative; width: 150px;border: 0px solid #999;"></div> 
    10857                                        </td> 
     
    12675                                </tr>--> 
    12776                                <tr align="left"> 
    128                                         <td align="left">                                                                                                                        
    129                                         <input id="cc_button_new" onMouseOver="if(!menuStarted) menu();menu.onmouseover()" onMouseOut="menu.onmouseout()"  value="{cc_btn_new}" type="button">                                   
     77                                        <td align="left"> 
     78                                        <input id="cc_button_new" onMouseOver="if(!menuStarted) menu();menu.onmouseover()" onMouseOut="menu.onmouseout()"  value="Novo ..." type="button"> 
    13079                                        <div id="cc_panel_search_call" style="display: inline"></div> 
    13180                                        <div id="cc_panel_table" style="display: none; text-align: right"> 
     
    13382                                        </div> 
    13483                                        <div id="cc_panel_cards" style="display: inline; text-align: right"> 
    135                                         <input type="button" value="{cc_panel_cards}" class="tab_box" style="cursor: pointer; cursor: hand;" onclick="javascript: ccChangeVisualization('cards')" />                                     
     84                                        <input type="button" value="{cc_panel_cards}" class="tab_box" style="cursor: pointer; cursor: hand;" onclick="javascript: ccChangeVisualization('cards')" /> 
    13685                                        </div> 
    13786                                        </td> 
    13887                                        <td align="right"> 
    139                                         <input id="cc_button_tools" value="{cc_btn_import_export}" type="button" onclick="javascript:ccIEContacts.showList()"> 
     88                                        <input id="cc_button_tools" value="Importar | Exportar" type="button" onclick="javascript:ccIEContacts.showList()"> 
    14089                                        </td> 
    14190                                </tr> 
     
    223172                                                                                        <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> 
    224173                                                                                </tr> 
    225                                                                         </table>                         
     174                                                                        </table> 
    226175                                                                </td> 
    227176                                                        </tr> 
     
    230179                                </tr> 
    231180                                <!-- ___END PANEL --> 
    232                                 <!-- __CARDS -->                                 
     181                                <!-- __CARDS --> 
    233182                                <tr> 
    234183                                        <td style="border: 0px solid #666;" id="cc_card_space" width="100%" height="auto" valign="top" align="center" colspan="4"></td> 
    235                                 </tr>                                                                                            
     184                                </tr> 
    236185                                <!-- __END CARDS --> 
    237186                        </table> 
     
    248197<script type="text/javascript" src="js/ccIEContacts.js"></script> 
    249198<script type="text/javascript" src="js/ccMain.js"></script> 
    250 <!-- END BOTTOM DETAILS-->                                               
     199<!-- END BOTTOM DETAILS--> 
Note: See TracChangeset for help on using the changeset viewer.