Changeset 3334


Ignore:
Timestamp:
10/06/10 16:14:29 (13 years ago)
Author:
eduardoalex
Message:

Ticket #1370 - Adicionada a opcao de escolha do grupo para os contatos importados

Location:
branches/2.2/contactcenter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/contactcenter/inc/class.so_group.inc.php

    r3322 r3334  
    105105                                                                         
    106106                        return True;             
     107                } 
     108                 
     109                function selectGroupsOwnerCanImportContacts($owner) { 
     110                        $query = "select id_group,title,short_name from phpgw_cc_groups where owner=$owner or owner in (select B.acl_location::bigint from phpgw_acl A, phpgw_acl B where  
     111                                                A.acl_location=B.acl_account and A.acl_account=B.acl_location 
     112                                                and A.acl_appname = 'contactcenter' and B.acl_appname = 'contactcenter' 
     113                                                and A.acl_rights & 4 <> 0 and B.acl_rights & 1 <> 0 
     114                                                and A.acl_location = $owner)"; //He can import contacts only to his groups, or shared groups that he gave read permission. 
     115                        $this->db->query($query); 
     116                         
     117                        $return = array(); 
     118                         
     119                        while($this->db->next_record()) 
     120                        { 
     121                                $return[] = $this->db->row();  
     122                        } 
     123                         
     124                        return $return; 
     125                         
    107126                } 
    108127                 
     
    492511                        return True;             
    493512                } 
     513                 
     514                function add_user_by_name($id_group){ 
     515                        $query = 'select C.id_connection, A.id_contact, A.names_ordered, C.connection_value, B.id_typeof_contact_connection'. 
     516                                 ' from phpgw_cc_contact A, phpgw_cc_contact_conns B, phpgw_cc_connections C'.  
     517                                         ' where A.id_contact = B.id_contact and B.id_connection = C.id_connection'. 
     518                                                ' and A.last_update = (select max(up.last_update) from phpgw_cc_contact up where up.id_owner ='.$this->owner.")". 
     519                                                ' and A.id_owner ='.$this->owner.' and C.connection_is_default = true'. 
     520                                         ' order by A.names_ordered,C.connection_value'; 
     521                         
     522                                                 
     523                        if (!$this->db->query($query)){ 
     524                                exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
     525                        } 
     526                          
     527                        $return = array();  
     528                         
     529                        $array_connections = array(); 
     530                        while($this->db->next_record()){ 
     531                                $return = $this->db->row(); 
     532                                array_push($array_connections, $return['id_connection']);                                
     533                        }                        
     534                        $this -> insertContactsByGroup($id_group, $array_connections); 
     535                                                                         
     536                } 
     537                 
    494538        } 
    495539?> 
  • branches/2.2/contactcenter/inc/class.ui_data.inc.php

    r3333 r3334  
    2222 
    2323                var $bo; 
     24                var $so_group; 
    2425                var $typeContact; 
    2526 
     
    259260                        $GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name')); 
    260261 
     262                        $select_groups = ''; 
     263                         
     264                        $this->so_group = CreateObject('contactcenter.so_group'); 
     265                         
     266                        $array_groups = $this->so_group->selectGroupsOwnerCanImportContacts($GLOBALS['phpgw_info']['user']['account_id']); 
     267                         
     268                        $select_groups = "<select id='id_group'>";//<option value=0>Selecione um grupo...</option></select>"; 
     269                        $select_groups .= "<option value=0 selected>Nenhum...</option>"; 
     270                        foreach ($array_groups as $group){ 
     271                                $select_groups .= "<option value='".$group['id_group']."'>".$group['title']."</option>";                                                 
     272                        }                                        
     273                        $select_groups .= "</select>"; 
     274                         
     275                        $GLOBALS['phpgw']->template->set_var('cc_select_groups',$select_groups); 
     276                         
    261277                        if($GLOBALS['phpgw_info']['server']['personal_contact_type']=='True'){ 
    262278                                $GLOBALS['phpgw']->template->set_var('cc_contact_type', 'advanced'); 
     
    417433 
    418434                                case 'import_contacts': 
    419                                         return $this->import_contacts($_GET['typeImport']); 
     435                                        return $this->import_contacts($_GET['typeImport'],$_GET['id_group']); 
    420436 
    421437                                case 'export_contacts': 
     
    519535                                level 
    520536                        @author Raphael Derosso Pereira 
    521             @author Mï¿œrio Cï¿œsar Kolling (error messages and timeout) 
     537            @author Mário César Kolling (error messages and timeout) 
    522538 
    523539                        @param (string) $level The level to be taken 
     
    12811297                                //echo 'ID_I: '.$id_i.'<br>'; 
    12821298                                //echo 'ID_F: '.$id_f.'<br>'; 
    1283                                 ///---------------- Correᅵᅵo Temporï¿œria PHP5 -----------------------/// 
    1284  
     1299                                ///---------------- Correção Temporária PHP5 -----------------------/// 
    12851300                                $ids = array(); 
    12861301/**rev 104**/ 
     
    14111426 
    14121427/**rev 104**/ 
    1413                                 // ?aqui alterar a chamada desse mï¿œtodo para receber o base dn? 
     1428                                // ?aqui alterar a chamada desse método para receber o base dn? 
    14141429                                //$contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields); 
    14151430 
     
    14371452                                { 
    14381453                                        /* 
    1439                                          * TODO: Os timeouts de conexï¿œo foram retirados, ver se serï¿œ necessï¿œrio retornar essa funcionalidade, e, 
    1440                                          * neste caso, terminar a implementaᅵᅵo das mensagens de retorno. 
     1454                                         * TODO: Os timeouts de conexão foram retirados, ver se será necessário retornar essa funcionalidade, e, 
     1455                                         * neste caso, terminar a implementação das mensagens de retorno. 
    14411456                                         */ 
    14421457                                        if ($index !== 'error'){ 
     
    17891804                        } 
    17901805 
    1791                         // verifica se email jï¿œ existe! 
     1806                        // verifica se email já existe! 
    17921807                        $boGroup = CreateObject('contactcenter.bo_group'); 
    17931808                        $contact = $boGroup->verify_contact($tdata[4]); 
     
    28482863                                of the entries that matches the search argument 
    28492864                        @author Raphael Derosso Pereira 
    2850                         @author Mï¿œrio Cï¿œsar Kolling (external catalogs) 
     2865                        @author Mário César Kolling (external catalogs) 
    28512866 
    28522867                        @param string $str_data A serialized array with two informations: 
     
    38523867                //em 19/06/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br); 
    38533868                function import_contacts($typeImport){ 
    3854  
     3869                        $this->so_group = CreateObject('contactcenter.so_group'); 
    38553870                        if($file = $_SESSION['contactcenter']['importCSV']) { 
    38563871                                unset($_SESSION['contactcenter']['importCSV']); 
     
    41444159                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid Name: " . $sdata['given_names'] ."<br>"; 
    41454160                                        } 
    4146                                         else 
    4147                                                 $return['_new']++; 
     4161                                        else{    
     4162                                                        if($id_group != 0){                                                              
     4163                                                                $this->so_group->add_user_by_name($id_group,$full_name); 
     4164                                                        }                                                
     4165                                                        $return['_new']++; 
     4166                                                } 
    41484167                        } 
    41494168                                fclose($handle); 
  • branches/2.2/contactcenter/js/ccIEContacts.js

    r285 r3334  
    22                this.win; 
    33                this.el;                 
    4                 this.wWidth = 395; 
     4                this.wWidth = 610; 
    55                this.wHeight = 255; 
    66        } 
     
    9393                        '<option value="thunderbird">'+("Mozilla Thunderbird")+'</option>'+ 
    9494                        '<option value="expresso" selected>'+lang_expresso_default+'</option></select><br>'+ 
    95                         '<br>'+lang_choose_contacts_file+'<br><br>'+                     
     95                        '<br> Selecione um grupo:&nbsp;' + Element('cc_select_groups').value + '<br>' + 
     96                        '<br>'+lang_choose_contacts_file+'<br><br>'+             
    9697                        '<input id="import_file" type="file" name="import_file">'+ 
    9798                        '</form></td></tr>'+ 
     
    237238                var _onload = function(){ 
    238239                        var typeImport = Element('typeImport').value; 
    239  
    240                         Connector.newRequest('import_contacts','../index.php?menuaction=contactcenter.ui_data.data_manager&method=import_contacts&typeImport='+typeImport,'GET',handler_import); 
     240                        var id_group = Element('id_group').value; 
     241                         
     242                        Connector.newRequest('import_contacts','../index.php?menuaction=contactcenter.ui_data.data_manager&method=import_contacts&typeImport='+typeImport+'&id_group='+id_group,'GET',handler_import); 
    241243                } 
    242244 
Note: See TracChangeset for help on using the changeset viewer.