Ignore:
Timestamp:
06/27/12 17:55:11 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Implementado verificação do limite de anexo conforme configurado.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/rest/mail/SendResource.php

    r6664 r6666  
    2424                                $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder']; 
    2525 
    26                         if($this->getExpressoVersion() != "2.2" && count($_FILES)) 
     26                        if(count($_FILES)) 
    2727                        { 
    28                                 require_once (__DIR__.'/../../../prototype/api/controller.php'); 
    2928                                $files = array(); 
     29                                $totalSize = 0; 
    3030                                foreach( $_FILES as $name => $file ) 
    3131                                { 
     
    3636                                                        'error' => $file['error'] 
    3737                                        ); 
     38                                        $totalSize += $file['size']; 
    3839                                } 
    39                                 Controller::addFallbackHandler( 0, function($e){ 
    40                                         throw $e; 
    41                                 } ); 
    4240                                 
    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']; 
     41                                $uploadMaxFileSize = str_replace("M","",$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size']) * 1024 * 1024; 
     42                                if($totalSize > $uploadMaxFileSize){ 
     43                                        Errors::runException("MAIL_NOT_SENT_LIMIT_EXCEEDED", $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size']); 
     44                                } 
     45 
     46                                if($this->getExpressoVersion() != "2.2") 
     47                                { 
     48                                        require_once (__DIR__.'/../../../prototype/api/controller.php'); 
     49                                        Controller::addFallbackHandler( 0, function($e){ 
     50                                                throw $e; 
     51                                        } ); 
     52                                 
     53                                        $result = array(); 
     54                                        $attachments_ids = array(); 
    5255                                                 
    53                                         }catch(Exception $e){ 
    54                                                 $attachment['error'] = $e->getMessage(); 
     56                                        foreach($files as $key => $value){ 
     57                                                $value['disposition']  = isset($value['disposition']) ? 
     58                                                        $value['disposition'] : 'attachment'; 
     59                                                try{ 
     60                                                        $attachment = Controller::put( array( 'concept' =>  "mailAttachment" ), $value ); 
     61                                                        $attachments_ids[] = $attachment[0]['id']; 
     62                                                }catch(Exception $e){ 
     63                                                        Errors::runException($e->getMessage()); 
     64                                                } 
    5565                                        } 
     66                                        $params['attDisposition1']      = 'attachment'; 
     67                                        $params['attachments']          = json_encode($attachments_ids); 
    5668                                } 
    57                                                                                  
    58                                 $params['attDisposition1']      = 'attachment'; 
    59                                 $params['attachments']          = json_encode($attachments_ids); 
    6069                        } 
    6170                        $returncode = $this->getImap()->send_mail($params); 
Note: See TracChangeset for help on using the changeset viewer.