Changeset 6664 for sandbox


Ignore:
Timestamp:
06/27/12 16:47:20 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Adicionada implementação para enviar email com anexo na versão 2.4

Location:
sandbox/webservice/api/rest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/rest/core/LoginResource.php

    r6239 r6664  
    44 
    55        private function getUserProfile(){ 
     6                if($this->getExpressoVersion() != "2.2") { 
     7                        $_SESSION['wallet']['user']['uidNumber'] = $GLOBALS['phpgw_info']['user']['account_id']; 
     8                } 
    69         
    710                return array( 
  • sandbox/webservice/api/rest/mail/SendResource.php

    r6619 r6664  
    2424                                $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder']; 
    2525 
     26                        if($this->getExpressoVersion() != "2.2" && count($_FILES)) 
     27                        { 
     28                                require_once (__DIR__.'/../../../prototype/api/controller.php'); 
     29                                $files = array(); 
     30                                foreach( $_FILES as $name => $file ) 
     31                                { 
     32                                        $files[$name] = array('name' => $file['name'], 
     33                                                        'type' => $file['type'], 
     34                                                        'source' => base64_encode(file_get_contents( $file['tmp_name'], $file['size'])), 
     35                                                        'size' => $file['size'], 
     36                                                        'error' => $file['error'] 
     37                                        ); 
     38                                } 
     39                                Controller::addFallbackHandler( 0, function($e){ 
     40                                        throw $e; 
     41                                } ); 
     42                                 
     43                                $result = array(); 
     44                                $attachments_ids = array(); 
     45                                         
     46                                foreach($files as $key => $value){ 
     47                                        $value['disposition']  = isset($value['disposition']) ? 
     48                                                $value['disposition'] : 'attachment'; 
     49                                        try{ 
     50                                                $attachment = Controller::put( array( 'concept' =>  "mailAttachment" ), $value ); 
     51                                                $attachments_ids[] = $attachment[0]['id']; 
     52                                                 
     53                                        }catch(Exception $e){ 
     54                                                $attachment['error'] = $e->getMessage(); 
     55                                        } 
     56                                } 
     57                                                                                 
     58                                $params['attDisposition1']      = 'attachment'; 
     59                                $params['attachments']          = json_encode($attachments_ids); 
     60                        } 
    2661                        $returncode = $this->getImap()->send_mail($params); 
    2762                        if (!$returncode || !(is_array($returncode) && $returncode['success'] == true)) 
Note: See TracChangeset for help on using the changeset viewer.