Changeset 4753


Ignore:
Timestamp:
07/14/11 17:12:23 (13 years ago)
Author:
roberto.santosjunior
Message:

Ticket #1820 - Mensagem incorreta ao adicionar grupo duplicado. r4598

Location:
trunk/contactcenter
Files:
3 edited

Legend:

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

    r4717 r4753  
    1919                var $public_functions = array( 
    2020                        'data_manager' => true, 
    21                         'advanced_searh_fields' => true 
    2221                ); 
    2322 
     
    8382                                $this -> typeContact = 'contacts'; 
    8483                        $this->preferences = $_SESSION['phpgw_info']['user']['preferences']['contactcenter']; 
    85                 } 
    86                  
    87                 function lg( $message, $path = '/tmp/natan.log' ) 
    88                 { 
    89                     ob_start(); 
    90                     print_r( $message ); 
    91                     echo( "\n" ); 
    92                     $output = ob_get_clean(); 
    93                     file_put_contents( $path, file_get_contents( $path ) . $output ); 
    9484                } 
    9585 
     
    269259                        $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default_csv', lang('Export as Expresso (Default) CSV.')); 
    270260                        $GLOBALS['phpgw']->template->set_var('cc_msg_copy_to_catalog', lang('Copy to personal catalog.')); 
    271                         $GLOBALS['phpgw']->template->set_var('cc_msg_show_extra_detail', lang("Show extra contact's details.")); 
    272261                        $GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.')); 
    273262                        $GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name')); 
    274  
    275                         /* 
    276                             * Monta Contactcenter Busca Avancada 
    277                             */ 
    278                         $c = CreateObject('phpgwapi.config','contactcenter'); 
    279                         $c->read_repository(); 
    280                         $current_config = $c->config_data; 
    281                         $this->lg( $current_config ); 
    282  
    283                         $arraySearch = array(); 
    284                         foreach ($current_config as $index => $value) 
    285                         { 
    286  
    287                             if(substr($index, 0, 24) == 'cc_attribute_searchable_') 
    288                             { 
    289                                 if($value == 'true') 
    290                                     $arraySearch[] = substr($index, 24, strlen($index)); 
    291                             } 
    292                         } 
    293                         $advanceSearchArray = array(); 
    294                         foreach ($arraySearch as $value) 
    295                         { 
    296                             foreach ($current_config as $index => $value2) 
    297                             { 
    298                                 if($value == substr($index, 22, strlen($index)) && substr($index, 0, 22) == 'cc_attribute_ldapname_') 
    299                                 { 
    300                                     foreach ($current_config as $index2 => $value3) 
    301                                     { 
    302                                         if($value == substr($index2, 18, strlen($index2)) && substr($index2, 0, 18) == 'cc_attribute_name_') 
    303                                                 $advanceSearchArray[$value2] =  $value3; 
    304                                     } 
    305                                 } 
    306  
    307                             } 
    308                         } 
    309  
    310                         $advanceSearch = array(); 
    311                         foreach ($advanceSearchArray as $index => $value) 
    312                             $advanceSearch[] ='"'.$index.'":"'.$value.'"'; 
    313  
    314                         $advancedFields =  "{".implode(',',$advanceSearch)."}"; 
    315                          
    316                         $this->lg( $advancedFields ); 
    317  
    318  
    319                         $GLOBALS['phpgw']->template->set_var('cc_config_advanced_search', $advancedFields); 
    320263 
    321264                        $select_groups = ''; 
     
    339282                                $GLOBALS['phpgw']->template->set_var('cc_contact_type', 'default'); 
    340283                        } 
    341  
    342284                        $GLOBALS['phpgw']->template->parse('out','index'); 
    343285 
     
    347289                        $main .= $api->get_quick_add_plugin(); 
    348290                        $main .= $api->get_add_group(); 
    349                         $main .= $api->get_contact_details(); 
    350291                        $main .= $GLOBALS['phpgw']->template->get_var('out'); 
    351292 
     
    504445                                        return $this->export_contacts($_POST['typeExport']); 
    505446                                 
    506                                 case 'get_contact_details': 
    507                                         return $this->get_contact_details($_GET['id']); 
    508  
    509447                                case 'get_qtds_compartilhado': 
    510448                                        return $this->get_qtds_compartilhado(); 
    511  
    512449                                case 'get_list_owners_perms_add': 
    513450                                        echo $this->get_list_owners_perms_add(); 
     
    13861323                                        ) 
    13871324                                ); 
    1388                                 //verifica se esta habilitado a opcao de exibir os detalhes extras 
    1389                                 $objconfig = CreateObject('phpgwapi.config', 'contactcenter'); 
    1390                                 $config = $objconfig->read_repository(); 
    1391                                 $final[12] = isset($config['cc_allow_details'])? $config['cc_allow_details'] : false; 
     1325 
    13921326                                //echo 'Page: '.$page.'<br>'; 
    13931327                                $n_entries = count($this->page_info['actual_entries']); 
     
    17481682                         
    17491683                        $boGroup = CreateObject('contactcenter.bo_group'); 
    1750                          
    1751                         $all_contacts = $boGroup->get_all_contacts(false,$shared_from); 
    1752                          
     1684 
     1685                        $all_contacts = $boGroup->get_all_contacts('only_email',$shared_from); 
    17531686                         
    17541687                        $contact_options = ""; 
    17551688                        if(count($all_contacts)) {                                       
    17561689                                foreach($all_contacts as $idx => $contact) {                             
    1757                                         $contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered']; 
    1758                                         if (isset($contact['connection_value'])) 
    1759                                                 $contact_options .= " (".$contact['connection_value'].")</OPTION>"; 
    1760                                         else 
    1761                                                 $contact_options .= " (". $contact['phone'].")</OPTION>"; 
     1690                                        $contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered']." (".$contact['connection_value'].")</OPTION>"; 
    17621691                                } 
    17631692                        } 
     
    18691798 
    18701799                        /* Relations */ 
    1871                          
    1872                         /* Groups */ 
    1873                         /* 
    1874                          * Criado uma estrutura no data que conterá os grupos do 
    1875                          * contato. O formato é: 
    1876                          * data['groups'] = array( 
    1877                          *                                              'id_group' => array( 
    1878                          *                                                                              'id_group', 'title', 'short_name' 
    1879                          *                                                                              ) 
    1880                          *                                              ); 
    1881                          */ 
    1882                         $boGroup = CreateObject('contactcenter.bo_group'); 
    1883                         $groups = $boGroup->get_contact_groups($id); 
    1884                          
    1885                         $i = 0; 
    1886                         $data['groups'] = array(); 
    1887                         foreach($groups as $group) 
    1888                         { 
    1889                                 $idGroup = $group['id_group']; 
    1890                                 $data['groups'][$idGroup] = array( 
    1891                                         'title'                 => $group['title'], 
    1892                                         'id_group'              => $idGroup, 
    1893                                         'short_name'    => $group['short_name'] 
    1894                                 ); 
    1895                                 $i++; 
    1896                         } 
    1897                                  
     1800 
    18981801                        echo serialize($data); 
    18991802                } 
     
    19141817                        $predata[] = $boPeopleCatalog -> get_all_countries(); 
    19151818                        $predata[] = $boPeopleCatalog -> get_all_connections_types(); 
    1916                         $boGroup = CreateObject('contactcenter.bo_group'); 
    1917                         if ($this->typeContact == 'shared_contacts') {  
    1918                                 $so_contact = CreateObject('contactcenter.so_contact',  $GLOBALS['phpgw_info']['user']['account_id']); 
    1919                 $relacionados = $so_contact->get_relations(); 
    1920                          
    1921                 foreach($relacionados as $uid_relacionado => $tipo_relacionamento) {     
    1922                                         $predata[] = $boGroup->get_groups_by_user($uid_relacionado);                                             
    1923                                 }        
    1924                         } else { 
    1925                                                 $predata[] = $boGroup->get_groups_by_user(); 
    1926                                         } 
     1819                        //$predata[] = $this->bo->catalog->get_all_relations_types(); 
    19271820 
    19281821                        $i = 0; 
     
    20941987                        $data['contact_in_list'] = $new_tdata[1]; 
    20951988                        $data['id_group'] = $new_tdata[2]; 
    2096                         $data['old_contacts_in_list'] = $new_tdata[3]; 
    2097                          
    2098                         foreach ($data['old_contacts_in_list'] as $id_connection) 
    2099                         { 
    2100                                 $boConn = CreateObject('contactcenter.bo_connection'); 
    2101  
    2102                                 $id_contact = $boConn->get_contact_id_by_connection($id_connection); 
    2103                                 $contact = CreateObject('contactcenter.so_contact', $id_contact); 
    2104                                 $contact->set_field("last_status", 'U'); 
    2105                                 $contact->set_field("last_update",time()."000"); 
    2106                                 $contact->commit(); 
    2107                         } 
    2108                                                  
    2109                         $contactWOemail = false; 
    2110  
    2111                         foreach ($data['contact_in_list'] as $id_connection) 
    2112                         { 
    2113                                 $boConn = CreateObject('contactcenter.bo_connection'); 
    2114                                  
    2115                                 $id_contact = $boConn->get_contact_id_by_connection($id_connection); 
    2116                                 $contact = CreateObject('contactcenter.so_contact', $id_contact); 
    2117                                 $contact->set_field("last_status", 'U'); 
    2118                                 $contact->set_field("last_update",time()."000"); 
    2119                                 $contact->commit(); 
    2120                                  
    2121                                 if (!$contactWOemail) 
    2122                                 { 
    2123                                         $type = $boConn->get_connection_type_by_conn_id($id_connection); 
    2124                                         if ($type != 1) 
    2125                                         { 
    2126                                                 $contactWOemail = true; 
    2127                                         } 
    2128                                 } 
    2129                         } 
    2130  
    2131   
    21321989                        $acumulatedErrors = ''; 
    21331990 
     
    21812038                        { 
    21822039                                $this->page_info['changed'] = true; 
    2183                                  
    2184                                 if (!$contactWOemail) 
    2185                                         echo serialize(array( 
    2186                                                 'msg'    => lang('Entry added with success!'), 
    2187                                                 'status' => 'ok' 
    2188                                                 )); 
    2189                                 else 
    2190                                         echo serialize(array( 
    2191                                                 'msg'    => lang('Entry added with success. But some contacts will not receive or send messages.'), 
    2192                                                 'status' => 'warning' 
    2193                                                 )); 
     2040 
     2041                                echo serialize(array( 
     2042                                        'msg'    => lang('Entry added with success!'), 
     2043                                        'status' => 'ok' 
     2044                                )); 
    21942045                        } 
    21952046                        else 
    21962047                        { 
    21972048                                echo serialize(array( 
    2198                                         'msg'    => lang('Problems on adding your Contact. No Contact added!'), 
     2049                                        'msg'    => lang("Problems on adding your Group. Be sure that a group with this name do not exists"). 
     2050                                            "\n".$acumulatedErrors, 
    21992051                                        'status' => 'error' 
    22002052                                )); 
     
    22242076                                else { 
    22252077                                        echo serialize(array( 
    2226                                                 'msg'    => lang('Problems on adding your Contact. No Contact added!'), 
     2078                                                'msg'    => lang("Could\'nt remove group with id: %1", $id), 
    22272079                                                'status' => 'error' 
    22282080                                        )); 
     
    25672419                                                /* Does nothing... */ 
    25682420                                                break; 
    2569                                         case 'groups': 
    2570                                                 $groups = $data['groups']; 
    2571                                                 unset($data['groups']); 
    2572                                                 break; 
    25732421 
    25742422                                        default: 
     
    25832431                        if (!is_null($id) and $id !== '') 
    25842432                        { 
    2585                                 $old_connections = $this->bo->catalog->get_connections($id); 
    2586                                 $id = $this->bo->catalog->update_single_info($id, $data); 
     2433                                $id = $this->bo->catalog->update_single_info($id, $data);  
    25872434                                $result = array( 
    25882435                                        'msg' => lang('Updated Successfully!'), 
     
    26062453                                        'status' => 'fail' 
    26072454                                ); 
    2608                         } 
    2609                         else 
    2610                         { 
    2611                                 if (isset($old_connections)) 
    2612                                         $this->bo->catalog->update_contact_groups($id, $groups, $old_connections); 
    2613                                 else 
    2614                                         $this->bo->catalog->update_contact_groups($id, $groups); 
    26152455                        } 
    26162456 
     
    30582898 
    30592899                        header('Content-type: image/jpeg'); 
    3060  
    3061                         $tmpDir = $GLOBALS['phpgw_info']['server']['temp_dir']; 
    3062                         $imagem_temp = fopen("$tmpDir/img_tmp","wb+"); 
    3063                         fwrite($imagem_temp,$contact['photo']); 
    3064                         fclose($imagem_temp);                    
    3065                         $exif = exif_read_data("$tmpDir/img_tmp","IDF0"); 
    3066                         $ort = 1; 
    3067                         if ($exif['Orientation'] != '') { 
    3068                                 $ort = $exif['Orientation']; 
    3069                         } 
    3070                         unlink("$tmpDir/img_tmp");                       
    3071  
    30722900                        $photo = imagecreatefromstring ($contact['photo']); 
    30732901                        $width = imagesx($photo); 
     
    30772905                        $small_photo = imagecreatetruecolor ($twidth, $theight); 
    30782906                        imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height); 
    3079                          
    3080                         if ($ort != 1){ 
    3081                                 switch($ort) 
    3082                                 { 
    3083                                         case 3:  
    3084                                                 $rotate = imagerotate($small_photo, 180, 0); 
    3085                                                 break; 
    3086                                         case 6: 
    3087                                                 $rotate = imagerotate($small_photo, 270, 0); 
    3088                                                 break; 
    3089                                         case 8: 
    3090                                                 $rotate = imagerotate($small_photo, 90, 0); 
    3091                                                 break; 
    3092                                 } 
    3093                         } else $rotate = imagerotate($small_photo, 0, 0); 
    3094          
    3095                         imagejpeg($rotate,"",100); 
    3096                         ImageDestroy($rotate); 
    3097                         ImageDestroy($small_photo); 
    3098  
     2907                        imagejpeg($small_photo,"",100); 
    30992908                        return; 
    31002909                } 
     
    32333042                        if (!is_array($data) || (!$data['search_for'] && !$full_search) || !is_array($data['fields'])) 
    32343043                        { 
    3235                             echo serialize(array( 
    3236                                     'msg'    => lang('Invalid parameters'), 
    3237                                     'status' => 'abort' 
    3238                             )); 
    3239  
    3240                             return array('error' => lang('Invalid parameters')); 
     3044                                echo serialize(array( 
     3045                                        'msg'    => lang('Invalid parameters'), 
     3046                                        'status' => 'abort' 
     3047                                )); 
     3048 
     3049                                return array('error' => lang('Invalid parameters')); 
    32413050                        } 
    32423051 
     
    32553064                        { 
    32563065 
    3257                                 $data['search_for'] = ($data['search_for']); 
     3066                                $data['search_for'] = utf8_encode($data['search_for']); 
    32583067                        } 
    32593068 
     
    32723081                        else 
    32733082                        { 
    3274                             $names = explode(' ', $data['search_for']); 
    3275  
    3276                             if (!is_array($names)) 
    3277                             { 
    3278                                     if(!$full_search) { 
    3279                                             echo serialize(array( 
    3280                                                     'msg'    => lang('Invalid Search Parameter'), 
    3281                                                     'status' => 'abort' 
    3282                                             )); 
    3283                                             exit; 
    3284                                     } 
    3285                                     else  
    3286                                             $names = array(); 
    3287  
    3288                             } 
     3083                                $names = explode(' ', $data['search_for']); 
     3084 
     3085                                if (!is_array($names)) 
     3086                                { 
     3087                                        if(!$full_search) { 
     3088                                                echo serialize(array( 
     3089                                                        'msg'    => lang('Invalid Search Parameter'), 
     3090                                                        'status' => 'abort' 
     3091                                                )); 
     3092                                                exit; 
     3093                                        } 
     3094                                        else  
     3095                                                $names = array(); 
     3096 
     3097                                } 
    32893098 
    32903099                                if (!$external && $this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && 
     
    33303139                                        ); 
    33313140 
    3332                                         if($full_search) { 
    3333                                                 foreach($full_search as $field => $value) { 
    3334                                                         if(trim($value)!='') 
    3335                                                                 array_push($rules,array( 
    3336                                                                                                 'field' => $this->aux_full_search($field,true), 
    3337                                                                                                 'type' => 'LIKE', 
    3338                                                                                                 'value' => '*'.$value.'*' 
    3339                                                                                                 )); 
    3340                                                 } 
    3341                                         } 
     3141                                        if($full_search) { 
     3142                                            foreach($full_search as $field => $value) { 
     3143                                                    if(trim($value)!='') 
     3144                                                            array_push($rules,array( 
     3145                                                                                            'field' => $this->aux_full_search($field,true), 
     3146                                                                                            'type' => 'LIKE', 
     3147                                                                                            'value' => '*'.$value.'*' 
     3148                                                                                            )); 
     3149                                            } 
     3150                                        } 
    33423151 
    33433152                                } 
     
    33483157                                                        array_push($rules,array( 
    33493158                                                                                        'field' => $this->aux_full_search($field,false), 
    3350                                                                                         'type'  => 'LIKE and ~=', 
    3351                                                                                         'value' => $name 
     3159                                                                                        'type' => 'iLIKE', 
     3160                                                                                        'value' => '%'.$value.'%' 
    33523161                                                                                        )); 
    3353                                                 } 
     3162                                        } 
    33543163                                 
    33553164                                } 
     
    33613170                                                array_push($rules, array( 
    33623171                                                        'field' => $data['fields']['search'], 
    3363                                                         'type'  => 'LIKE and ~=', 
    3364                                                         'value' => $name 
     3172                                                        'type'  => 'iLIKE', 
     3173                                                        'value' => '%'.$name.'%' 
    33653174                                                )); 
    33663175                                        } 
     
    33803189                                // Get only this attributes: dn, cn for external catalogs, 
    33813190                                // used to restrict the attributes used in filters 
    3382                                 $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC', 'customFilter' => $data['custom_filter'], 'CN' => $data['CN'], 'exact' => $data['exact']), $data['search_for'] != null); 
     3191                                $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'), $data['search_for'] != null); 
    33833192                        } 
    33843193                        else 
     
    33943203                                        'contact.connection.mail', 
    33953204                                        'contact.connection.phone' 
    3396                                         ), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC', 'customFilter' => $data['custom_filter'], 'CN' => $data['CN'], 'exact' => $data['exact']), $data['search_for_area'], $data['search_for'] != null ); 
     3205                                        ), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'), $data['search_for_area'], $data['search_for'] != null ); 
    33973206                        } 
    33983207 
     
    37763585                        for($z = 0; $z < 5; $z++) { 
    37773586                                $participant = $info[0][$justThese[$z]]; 
    3778                                 $participant[0] = utf8_decode($participant[0]); 
    37793587                                array_push($array_participants, $participant); 
    37803588                        } 
     
    40363844                                        "Office Location,Organizational ID Number,PO Box,Priority,Private,Profession,Referred By,Sensitivity,Spouse,User 1,User 2,User 3,User 4,Web Page\r\n"; 
    40373845 
    4038                                         foreach($contacts as $index => $object){ 
    4039                                                 if( array_key_exists("phone", $object) ) 
    4040                                                         $phone = $object['phone']; 
    4041                                                 else 
    4042                             $phone = $object['business-phone']; 
    4043                                          
     3846                                foreach($contacts as $index => $object) 
     3847                                { 
     3848                                        if( array_key_exists("phone", $object) ) 
     3849                                           $phone = $object['phone']; 
     3850                                        else 
     3851                                           $phone = $object['business-phone']; 
     3852 
    40443853                                                $streamBuffer.= "\"".$object[ 'alias' ] . "\"," 
    40453854                                                        . "\"".$object[ 'names_ordered'] . "\"," 
     
    40643873                                                        .",,,,,,,," 
    40653874                                                        . "\"".$object[ 'business-fax' ] . "\"," 
    4066                                                         . "\"".$phone . "\"," 
     3875                                                        . "\"".$phone . "\"," 
    40673876                                                        . "\"".$object[ 'business-mobile' ] . "\"," 
    40683877                                                        .",,," 
     
    41033912                                                        . "\"".$object[ 'alternative-mail' ] . "\"," 
    41043913                                                        ."," 
    4105                                                         . "\"".$phone . "\"," 
     3914                                                        . "\"".$phone . "\"," 
    41063915                                                        . "\"".$object[ 'home-phone' ] . "\"," 
    41073916                                                        . "\"".$object[ 'business-fax' ] . "\"," 
     
    41823991 
    41833992                        $file = "contacts_".md5(microtime()).".swp"; 
    4184                         $tempDir = $GLOBALS['phpgw_info']['server']['temp_dir']; 
     3993                        $tempDir = ini_get("session.save_path"); 
    41853994                        $f = fopen($tempDir.'/'.$file,"w"); 
    41863995                        if(!$f) 
     
    42304039                //sobrenome, notas e e-mail; 
    42314040                //em 19/06/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br); 
    4232                 function import_contacts($typeImport, $id_group=false){  
     4041                function import_contacts($typeImport, $id_group=false){ 
    42334042                        $this->so_group = CreateObject('contactcenter.so_group'); 
    42344043                        if($file = $_SESSION['contactcenter']['importCSV']) { 
     
    43874196                                                                case 'Telefone principal': 
    43884197                                                                case 'Telefone comercial': 
    4389                                                                 case 'Telefone Comercial': 
     4198                                                                case 'Telefone Comercial':                                                                     
    43904199                                                                        $phone_pos = $index; 
    43914200                                                                        break; 
     
    44514260 
    44524261                                                $sdata['connections']['default_phone']['connection_name'] = lang('Main'); 
    4453                                          
    4454                                                 $sdata['connections']['default_phone']['connection_value'] = $phone; 
    4455  
    4456                                                 if( trim($row[$header[$home_phone_pos]]) != "" ) 
     4262                                                $sdata['connections']['default_phone']['connection_value'] = $phone; 
     4263 
     4264                                                if( trim($row[$header[$home_phone_pos]]) != "" ) 
    44574265                                                { 
    44584266                                                    $sdata['connections']['aditional_phone']['home_phone']['connection_name'] = 'Casa'; 
     
    45044312                                                    } 
    45054313                                                } 
    4506                                          
     4314 
    45074315                                                $sdata['addresses']['address_corporative']['address1'] = trim($row[$header[$corporate_street_pos]]); 
    45084316                                                $sdata['addresses']['address_corporative']['address2'] = trim($row[$header[$corporate_street_2_pos]]); 
    45094317                                                $sdata['addresses']['address_corporative']['complement'] = trim($row[$header[$corporate_comp_pos]]); 
    4510                                                 $sdata['addresses']['address_corporative']['postal_code'] = trim($row[$header[$corporate_cep_pos]]);                                             
     4318                                                $sdata['addresses']['address_corporative']['postal_code'] = trim($row[$header[$corporate_cep_pos]]); 
    45114319                                                $sdata['addresses']['address_corporative']['id_country'] = "BR"; 
    4512                                                 $sdata['addresses']['address_corporative']['id_state'] = trim($row[$header[$corporate_state_pos]]);      
     4320                                                $sdata['addresses']['address_corporative']['id_state'] = trim($row[$header[$corporate_state_pos]]); 
    45134321                                                $sdata['addresses']['address_corporative']['id_city'] = trim($row[$header[$corporate_city_pos]]); 
    4514                                                  
    4515                                                                                                          
     4322 
     4323 
    45164324                                                $sdata['addresses']['address_personal']['address1'] = trim($row[$header[$street_pos]]); 
    45174325                                                $sdata['addresses']['address_personal']['address2'] = trim($row[$header[$street_2_pos]]); 
    45184326                                                $sdata['addresses']['address_personal']['complement'] = trim($row[$header[$comp_pos]]); 
    45194327                                                $sdata['addresses']['address_personal']['postal_code'] = trim($row[$header[$cep_pos]]); 
    4520                                                 $sdata['addresses']['address_personal']['id_country'] = "BR";                                                    
    4521                                                 $sdata['addresses']['address_personal']['id_state'] = trim($row[$header[$state_pos]]);   
     4328                                                $sdata['addresses']['address_personal']['id_country'] = "BR"; 
     4329                                                $sdata['addresses']['address_personal']['id_state'] = trim($row[$header[$state_pos]]); 
    45224330                                                $sdata['addresses']['address_personal']['id_city'] =  trim($row[$header[$city_pos]]); 
    45234331 
     
    45314339                                        $sdata['connections']['default_phone']['connection_value'] = $phone; 
    45324340 
    4533                                         //      verifica se email já existe! 
     4341                                        //      verifica se email já existe! 
    45344342                                        $email = addslashes($email); 
    4535                                         // Foi modificado o método que fazia a verificação se um contato já existe. 
    4536                                         // Antes era verificado somente com base no email do contato. 
    4537                                         $contact = $boGroup->verify_contact($email, $full_name, $phone); 
     4343                                        $contact = $boGroup->verify_contact($email); 
    45384344 
    45394345                                        if(!$sdata['given_names'] && $email){ 
     
    45464352                                        if($contact){ 
    45474353                                                $return['_existing']++; 
    4548                                         }                                                                
    4549                                     // Modificada a expressão regular para aceitar endereços de email fora do padrão nome@provedor.com.br.  
    4550                                     // Aceita casos de domínios internos como c0000@mail.caixa.                                  
    4551                                         else if((!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[_a-z0-9-]+(\.[_a-z0-9-]+)+$", $email)) && $email) { 
     4354                                        } 
     4355                                        else if((!eregi("^[/_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) && $email) { 
    45524356                                                $return['_failure']++; 
    45534357                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>"; 
     
    45574361                                                $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid Name: " . $sdata['given_names'] ."<br>"; 
    45584362                                        } 
    4559                                         else{    
    4560                                                         if($id_group != 0){                                                              
     4363                                        else{ 
     4364                                                        if($id_group != 0){ 
    45614365                                                                $this->so_group->add_user_by_name($id_group,$full_name); 
    4562                                                         }                                                
     4366                                                        } 
    45634367                                                        $return['_new']++; 
    45644368                                                } 
     
    45724376                        echo serialize($return); 
    45734377                } 
    4574          
    4575                 /*! 
    4576                  * @function get_contact_details 
    4577                  * @abstract Retorna os detalhes extras de um contato 
    4578                  * @author Luiz Carlos Viana Melo - Prognus 
    4579                  * @param (string) O ID do usuário do LDAP 
    4580                  */ 
    4581                 function get_contact_details($id) 
    4582                 { 
    4583                         $data = array(); 
    4584                          
    4585                         if(!$this->bo->catalog->src_info) { 
    4586                                 $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
    4587                                 $this->bo->catalog->src_info = $ldap->srcs[1]; 
    4588                         } 
    4589                          
    4590                         $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);                               
    4591                         $dn=$this->bo->catalog->src_info['dn']; 
    4592                          
    4593                         //buscar os atributos do ldap 
    4594                         $configobj = CreateObject('phpgwapi.config', 'contactcenter'); 
    4595                         $prefs = $configobj->read_repository(); 
    4596                         $attr_names = array(); 
    4597                         $attr_types = array(); 
    4598                         $justThese = array(); 
    4599                         foreach ($prefs as $pref_key => $pref_value) 
    4600                         { 
    4601                                 if (stripos($pref_key, "cc_attribute_name_") !== false) 
    4602                                 { 
    4603                                         $num = substr($pref_key, strlen("cc_attribute_name_")); 
    4604                                         $attr_names[] = $prefs["cc_attribute_name_$num"]; 
    4605                                         $attr_types[] = $prefs["cc_attribute_type_$num"]; 
    4606                                         $justThese[] = strtolower($prefs["cc_attribute_ldapname_$num"]); 
    4607                                 } 
    4608                         } 
    4609                         $sr = ldap_read($ds,$id, "objectClass=*",$justThese);                                                    
    4610                         $info = ldap_get_entries($ds, $sr); 
    4611                         if ($info) 
    4612                         { 
    4613                                 for ($i = 0; $i < count($justThese); $i++) 
    4614                                 { 
    4615                                         $attr = array(); 
    4616                                         $attr['name'] = $attr_names[$i]; 
    4617                                         if ($attr_types[$i] == 'multivalues') 
    4618                                         { 
    4619                                                 $attr['type'] = 'multivalues'; 
    4620                                                 $attr['value'] = array(); 
    4621                                                 for ($j = 0; $j < $info[0][$justThese[$i]]['count']; $j++) 
    4622                                                         $attr['value'][] = utf8_decode($info[0][$justThese[$i]][$j]); 
    4623                                         } 
    4624                                         else 
    4625                                         { 
    4626                                                 $attr['type'] = 'text'; 
    4627                                                 $attr['value'] = utf8_decode($info[0][$justThese[$i]][0]); 
    4628                                         } 
    4629                                         $data[] = $attr; 
    4630                                 } 
    4631                         } 
    4632                         else 
    4633                                 $data = 'error'; 
    4634                         ldap_close($ds); 
    4635                          
    4636                         echo serialize($data); 
    4637                 } 
    46384378        } 
    46394379 
Note: See TracChangeset for help on using the changeset viewer.