Changeset 3966


Ignore:
Timestamp:
04/11/11 09:44:40 (13 years ago)
Author:
rafaelraymundo
Message:

Ticket #189 - Funcionalidade de envio de anexos nas notificações de agendamento.

Location:
branches/2.2.0.1
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.0.1/calendar/inc/class.bocalendar.inc.php

    r3910 r3966  
    10141014                                $GLOBALS['phpgw']->datetime = createobject('phpgwapi.date_time'); 
    10151015                        } 
     1016 
    10161017                        $l_cal = (@isset($params['cal']) && $params['cal']?$params['cal']:$_POST['cal']); 
     1018 
     1019                        $post_max_size = ini_get('post_max_size'); 
     1020                        $mul = substr($post_max_size, -1); 
     1021                        $mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); 
     1022                        if ($_SERVER['CONTENT_LENGTH'] > $mul*(int)$post_max_size && $post_max_size) 
     1023                             $l_cal['attachment'] = 'ERROR'; 
     1024 
     1025                        if(count($_FILES['cal']) > 0){ 
     1026 
     1027                            if($l_cal['attachment'] != '') 
     1028                               $attachments = unserialize($l_cal['attachment']); 
     1029                            else 
     1030                               $attachments = Array(); 
     1031 
     1032                            foreach ($_FILES['cal']['error']['attachment'] as $key => $error) { 
     1033 
     1034                                if ($error == UPLOAD_ERR_OK) { 
     1035 
     1036                                    $new_file= $GLOBALS['phpgw_info']['server']['temp_dir'].'/'.$_SESSION[ 'phpgw_session' ][ 'session_id' ].md5($attachment['name'].microtime()); 
     1037                                    move_uploaded_file($_FILES['cal']['tmp_name']['attachment'][$key], $new_file); 
     1038                                    $attach = Array('tmp_name' => $new_file, 'name' => $_FILES['cal']['name']['attachment'][$key], 'type' =>  $_FILES['cal']['type']['attachment'][$key]); 
     1039 
     1040                                    $attachments[] = $attach; 
     1041 
     1042                                }elseif($error == UPLOAD_ERR_INI_SIZE){ 
     1043                                    $attachments = 'ERROR'; 
     1044                                    break; 
     1045 
     1046                                } 
     1047                            } 
     1048                            $l_cal['attachment'] = $attachments; 
     1049 
     1050                        } 
    10171051                        $l_participants = (@$params['participants']?$params['participants']:$_POST['participants']); 
    10181052                        $this->ex_participants = (@$params['ex_participants']?$params['ex_participants']:$_POST['ex_participants']); 
     
    11531187                                $this->so->set_title($l_cal['title']); 
    11541188                                $this->so->set_description($l_cal['description']); 
     1189                                $this->so->set_attachment($l_cal['attachment']); 
    11551190                                $this->so->set_ex_participants($l_cal['ex_participants']); 
    11561191                                $this->so->set_start($l_start['year'],$l_start['month'],$l_start['mday'],$l_start['hour'],$l_start['min'],0); 
     
    17221757                                } 
    17231758                        } 
     1759                        if($event['attachment'] == 'ERROR') 
     1760                            $error = 99; 
     1761                         
    17241762                        return $error; 
    17251763                } 
     
    35023540                                        fclose($attach_fd); 
    35033541                                } 
     3542 
     3543                                if(isset($new_event['attachment'])){ 
     3544                                    foreach($new_event['attachment'] as $attach){ 
     3545                                        $mail->AddAttachment($attach['tmp_name'], $attach['name'], "base64", $attach['type']); 
     3546                                    } 
     3547                                } 
     3548                                 
    35043549                                $mail->From = $sender; 
    35053550                                $mail->FromName = $GLOBALS['phpgw_info']['user']['fullname']; 
     
    39113956                                'data'  => $GLOBALS['phpgw']->common->show_date($this->maketime($event['modtime']) - $GLOBALS['phpgw']->datetime->tz_offset) 
    39123957                        ); 
     3958 
     3959                        $var['attachment'] = Array( 
     3960                                'field' => $this->translate('Attachment'), 
     3961                                'data'  => $event['attachment'] 
     3962                        ); 
    39133963 
    39143964                        $var['access'] = Array( 
  • branches/2.2.0.1/calendar/inc/class.bocustom_fields.inc.php

    r2 r3966  
    3131                        'updated'     => 'Updated', 
    3232                        'alarm'       => 'Alarm', 
    33                         'recure_type' => 'Repetition' 
     33                        'recure_type' => 'Repetition', 
     34                        'attachment' => 'attachment' 
    3435                ); 
    3536 
  • branches/2.2.0.1/calendar/inc/class.socalendar.inc.php

    r1729 r3966  
    369369                        $this->cal->set_description($description); 
    370370                } 
     371                function set_attachment($attachment='') 
     372                { 
     373                        $this->cal->set_attachment($attachment); 
     374                } 
    371375                function set_ex_participants($ex_participants='') 
    372376                { 
  • branches/2.2.0.1/calendar/inc/class.socalendar__.inc.php

    r2 r3966  
    102102                } 
    103103 
     104                function set_attachment($attachment='') 
     105                { 
     106                        $this->add_attribute('attachment',$attachment); 
     107                } 
     108 
    104109                function set_ex_participants($ex_participants='') 
    105110                { 
  • branches/2.2.0.1/calendar/inc/class.socalendar_sql.inc.php

    r3608 r3966  
    569569                                $this->set_title(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('title')))); 
    570570                                $this->set_description(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('description')))); 
     571                                $this->set_attachment(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('attachment')))); 
    571572                                $this->set_ex_participants(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('ex_participants')))); 
    572573                                $this->add_attribute('uid',$GLOBALS['phpgw']->strip_html($this->stream->f('uid'))); 
     
    976977                                        . "title='".$this->stream->db_addslashes($event['title'])."', " 
    977978                                        . "description='".$this->stream->db_addslashes($event['description'])."', " 
     979                                        . "attachment='".$this->stream->db_addslashes(serialize($event['attachment']))."', " 
    978980                                        . "ex_participants='".$this->stream->db_addslashes($event['ex_participants'])."', " 
    979981                                        . "location='".$this->stream->db_addslashes($event['location'])."', " 
  • branches/2.2.0.1/calendar/inc/class.uicalendar.inc.php

    r3914 r3966  
    35613561                        } 
    35623562 
     3563                        if($event['attachment'] != '') 
     3564                                { 
     3565                                        $picture[] = Array( 
     3566                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','clip'), 
     3567                                                'width' => 9, 
     3568                                                'height'=> 9, 
     3569                                                'title' => lang('Notification with attachments sent.') 
     3570                                        ); 
     3571                                } 
     3572 
    35633573                        $description = $this->bo->get_short_field($event,$is_private,'description'); 
    35643574                        for($i=0;$i<count($picture);$i++) 
     
    44874497                        $vars = $this->bo->event2array($event); 
    44884498 
     4499                        if($vars['attachment']['data'] == "") 
     4500                            $vars['attachment']['data'] = lang('No Attachment'); 
     4501                        else{ 
     4502                            $vars['attachment']['data'] = lang('Has attachment(s)'); 
     4503                        } 
     4504                         
    44894505                        $vars['title']['tr_color'] = $this->theme['th_bg']; 
    44904506 
     
    54065422//                      $this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>')); 
    54075423 
     5424                        if ($event['attachment'] == '' || $event['attachment'] == 'ERROR' || is_array($event['attachment'])) 
     5425                            $data =  '<a onClick="javascript:addAttach()" href="#divFiles" >Anexos: adicionar+</a><div id="divFiles"</div>'; 
     5426                        else 
     5427                            $data = '<input type="hidden" name="cal[attachment]" value='.$event["attachment"].'>'.lang('Notification with attachments sent.').'<br><a onClick="javascript:addAttach()" href="#divFiles" >Anexos: adicionar+</a><div id="divFiles"</div>'; 
     5428 
     5429                        $var['attachment'] = Array( 
     5430                                'field' => lang('Attachment'), 
     5431                                //'data' => '<input  type="file" name="cal[attachment]" />' 
     5432                                'data' => $data 
     5433                        ); 
     5434 
    54085435                        if (!isset($this->fields)) 
    54095436                        { 
  • branches/2.2.0.1/calendar/inc/class.uipublicview.inc.php

    r3201 r3966  
    466466                                        ); 
    467467                                } 
     468                                if($event['attachment'] != '') 
     469                                { 
     470                                        $picture[] = Array( 
     471                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','circle'), 
     472                                                'width' => 9, 
     473                                                'height'=> 9, 
     474                                                'title' => lang('Has Attachment') 
     475                                        ); 
     476                                } 
    468477                                else 
    469478                                { 
     
    520529                        } 
    521530 
     531                        if($event['attachment'] != '') 
     532                        { 
     533                            $picture[] = Array( 
     534                                    'pict'      => $GLOBALS['phpgw']->common->image('calendar','circle'), 
     535                                    'width'     => 9, 
     536                                    'height'=> 9, 
     537                                    'title' => lang('Has Attachment') 
     538                            ); 
     539                        } 
    522540                        $description = $this->bo->get_short_field($event,$is_private,'description'); 
    523541                        for($i=0;$i<count($picture);$i++) 
  • branches/2.2.0.1/calendar/setup/tables_current.inc.php

    r2 r3966  
    2727                                'title' => array('type' => 'varchar','precision' => '80','nullable' => False,'default' => '1'), 
    2828                                'description' => array('type' => 'text','nullable' => True), 
     29                                'attachment' => array('type' => 'text','nullable' => True), 
    2930                                'location' => array('type' => 'varchar','precision' => '255','nullable' => True), 
    3031                                'reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), 
  • branches/2.2.0.1/calendar/setup/tables_update.inc.php

    r3765 r3966  
    8080                return $GLOBALS['setup_info']['calendar']['currentver']; 
    8181        } 
     82        $test[] = '2.2.001'; 
     83        function calendar_upgrade2_2_001() 
     84        { 
     85            $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cal ADD COLUMN attachment text"); 
     86        } 
    8287?> 
  • branches/2.2.0.1/calendar/templates/default/edit.tpl

    r3254 r3966  
    1010</style> 
    1111<script language="JavaScript"> 
     12 
     13        function addAttach(){ 
     14            divFiles = document.getElementById("divFiles"); 
     15            if (! divFiles) 
     16                    return false; 
     17 
     18            if (divFiles.lastChild) 
     19                    var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[1]) + 1; 
     20 
     21            if (! countDivFiles) 
     22                    var countDivFiles = 1; 
     23 
     24            divFile = document.createElement('DIV'); 
     25 
     26 
     27            divFile.innerHTML = "<input type='file' size='50' maxLength='255' id='"+"inputFile_"+countDivFiles+"' name='cal[attachment][]'>"; 
     28 
     29 
     30            var linkFile = document.createElement("A"); 
     31            linkFile.id = "linkFile_"+countDivFiles; 
     32            linkFile.href='javascript:void(0)'; 
     33            linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;}; 
     34            linkFile.innerHTML="Remove"; 
     35            //divFile.innerHTML += "&nbsp;&nbsp;"; 
     36            divFile.appendChild(linkFile); 
     37            divFile.id = "divFile_"+countDivFiles; 
     38            divFiles.appendChild(divFile); 
     39 
     40 
     41 
     42            return document.getElementById("inputFile_"+countDivFiles); 
     43        } 
     44 
     45        function removeFile(id){ 
     46            var border_id = id.substr(8,1); 
     47            var el = Element(id); 
     48            el.parentNode.removeChild(el); 
     49        } 
     50 
    1251        self.name="first_Window"; 
    1352        function accounts_popup() 
     
    3877<font color="#000000" face="{font}"> 
    3978 
    40 <form action="{action_url}" method="post" name="app_form"> 
     79<form action="{action_url}" method="post" name="app_form" enctype="multipart/form-data"> 
    4180{common_hidden} 
    4281<table id="editFormTable" border="0" width="90%"   class="prefTable"> 
  • branches/2.2.0.1/phpgwapi/inc/class.common.inc.php

    r3485 r3966  
    18411841                                case 47: $s .= lang('The starting time can not be greater than end time').'.'; 
    18421842                                        break; 
     1843                                case 99: $s .= lang('The attachment is to big').'.'; 
     1844                                        break; 
    18431845                                default:        return ''; 
    18441846                        } 
Note: See TracChangeset for help on using the changeset viewer.