Changeset 4510 for sandbox


Ignore:
Timestamp:
05/25/11 16:25:53 (13 years ago)
Author:
wmerlotto
Message:

Ticket #1935 - Correcao na importacao de contatos de arquivos CSV do contactcenter

Location:
sandbox/2.2.0.2/contactcenter/inc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.2.0.2/contactcenter/inc/cc_updown.php

    r1679 r4510  
    33//      This script upload an CSV file to import contacts ....   
    44        if($ftmp = $_FILES['import_file']['tmp_name']){                                          
    5                 $fname = ini_get("session.save_path").'/'."contacts_".md5(microtime()).".swp";                                   
     5                // Foi necessário modificar o caminho onde se recuperava o diretório temporário. 
     6                // Esse caminho foi hardcodificado na string abaixo ( /tmp ) temporariamente, mas deve ser recuperada atraves 
     7                // da configuracao do Expresso. Ver ticket #385. 
     8                $fname = "/tmp/contacts_".md5(microtime()).".swp";                                       
    69                if(move_uploaded_file($ftmp, $fname))    
    710                        $_SESSION['contactcenter']['importCSV'] = $fname;                
    811        }                
    9 //      ... or download an CSV file to export contacts.  
     12//      ... or download an CSVfile to export contacts.   
    1013        else if($_GET['file_name']) {    
    1114                $file_name = $_GET['file_name'];         
     
    1619                header("Content-disposition: attachment; filename=".$file_name); 
    1720                readfile($file_path); 
     21                unlink($file_path); 
    1822        } 
    1923?> 
  • sandbox/2.2.0.2/contactcenter/inc/class.bo_group.inc.php

    r4502 r4510  
    4242                } 
    4343                 
    44                 function verify_contact($email){ 
     44                function verify_contact($email, $name, $phone){ 
    4545                 
    46                         $result = $this-> so -> verifyContact($email); 
     46                        $result = $this-> so -> verifyContact($email, $name, $phone); 
    4747                        return $result; 
    4848                } 
  • sandbox/2.2.0.2/contactcenter/inc/class.so_group.inc.php

    r4502 r4510  
    423423                } 
    424424 
    425                 function verifyContact($email) 
    426                 { 
    427                         $query = 'select A.names_ordered, C.id_connection from phpgw_cc_contact A,'. 
    428                         'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
    429                         'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
    430                         'and B.id_typeof_contact_connection = 1 and '. 
    431                         'A.id_owner ='.$this->owner.' and C.connection_value = \''.$email.'\''; 
    432                                                  
    433                         if (!$this->db->query($query)) 
    434                         { 
    435                                 exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
    436                         } 
     425                function verifyContact($email, $name, $phone) 
     426                { 
     427                        if ($email) { 
     428                         
     429                                $query = 'select A.names_ordered, C.id_connection from phpgw_cc_contact A,'. 
     430                                'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
     431                                'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
     432                                'and B.id_typeof_contact_connection = 1 and '. 
     433                                "A.id_owner ='" .$this->owner."' and C.connection_value = '".$email. "'"; 
     434 
     435                                if (!$this->db->query($query)) 
     436                                {        
     437                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
     438                                } 
    437439                          
    438                         $return = false; 
    439                          
    440                         while($this->db->next_record()) 
    441                         { 
    442                                 $row = $this->db->row(); 
    443                                 $return[] =  $row['names_ordered']; 
    444                                 $return[] =  $row['id_connection']; 
    445                         } 
    446                          
     440                                $return = false; 
     441                         
     442                                while($this->db->next_record()) 
     443                                { 
     444                                        $row = $this->db->row(); 
     445                                        $return[] =  $row['names_ordered'];  
     446                                } 
     447                        }  
     448                         
     449                        if (!$return && $phone) {  
     450 
     451                                $query = 'select A.names_ordered, C.id_connection from phpgw_cc_contact A,'. 
     452                                'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
     453                                'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
     454                                'and B.id_typeof_contact_connection = 2 and '. 
     455                                "A.id_owner ='" .$this->owner."' and C.connection_value = '".$phone. "'"; 
     456 
     457                                if (!$this->db->query($query)) 
     458                                {        
     459                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
     460                                } 
     461                          
     462                                $return = false; 
     463                         
     464                                while($this->db->next_record()) 
     465                                { 
     466                                        $row = $this->db->row(); 
     467                                        $return[] =  $row['names_ordered'];  
     468                                } 
     469 
     470                        } 
     471                         
     472                        if (!$return && $name) {  
     473 
     474                                $query = "select names_ordered, C.id_connection from phpgw_cc_contact where id_owner = '" . $this->owner . "' and RTRIM(names_ordered) = '". $name. "'"; 
     475 
     476                                if (!$this->db->query($query)) 
     477                                {        
     478                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
     479                                } 
     480                          
     481                                $return = false; 
     482                         
     483                                while($this->db->next_record()) 
     484                                { 
     485                                        $row = $this->db->row(); 
     486                                        $return[] =  $row['names_ordered'];  
     487                                } 
     488 
     489                        } 
     490                    $return[] =  $row['id_connection']; 
     491 
    447492                        return $return; 
    448493                }                
  • sandbox/2.2.0.2/contactcenter/inc/class.ui_data.inc.php

    r4509 r4510  
    41214121 
    41224122                        $file = "contacts_".md5(microtime()).".swp"; 
    4123                         $tempDir = ini_get("session.save_path"); 
     4123                        $tempDir = $GLOBALS['phpgw_info']['server']['temp_dir']; 
    41244124                        $f = fopen($tempDir.'/'.$file,"w"); 
    41254125                        if(!$f) 
     
    44704470                                        $sdata['connections']['default_phone']['connection_value'] = $phone; 
    44714471 
    4472                                         //      verifica se email já existe! 
     4472                                        //      verifica se email já existe! 
    44734473                                        $email = addslashes($email); 
    4474                                         $contact = $boGroup->verify_contact($email); 
     4474                                        // Foi modificado o método que fazia a verificação se um contato já existe. 
     4475                                        // Antes era verificado somente com base no email do contato. 
     4476                                        $contact = $boGroup->verify_contact($email, $full_name, $phone); 
    44754477 
    44764478                                        if(!$sdata['given_names'] && $email){ 
     
    44834485                                        if($contact){ 
    44844486                                                $return['_existing']++; 
    4485                                         } 
    4486                                         else if((!eregi("^[/_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) && $email) { 
     4487                                        }                                                                
     4488                                    // Modificada a expressão regular para aceitar endereços de email fora do padrão nome@provedor.com.br.  
     4489                                    // Aceita casos de domínios internos como c0000@mail.caixa.                                  
     4490                                        else if((!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[_a-z0-9-]+(\.[_a-z0-9-]+)+$", $email)) && $email) { 
    44874491                                                $return['_failure']++; 
    44884492                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>"; 
Note: See TracChangeset for help on using the changeset viewer.