Changeset 620


Ignore:
Timestamp:
01/21/09 10:52:34 (15 years ago)
Author:
eduardoalex
Message:

Ticket #407

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/calendar/inc/class.uiicalendar.inc.php

    r60 r620  
    2121                var $public_functions = array( 
    2222                        'test'          => True, 
    23                         'import'                => True 
     23                        'import'                => True, 
     24                        'import_from_mail' => True 
    2425                ); 
    2526 
     
    7677                } 
    7778 
     79                function import_from_mail() { 
     80                        $msg_number = $_GET['msg_number']; 
     81                        $idx_file = $_GET['idx_file']; 
     82                        $newfilename = $_GET['newfilename']; 
     83                        $msg_part = $_GET['msg_part']; 
     84                        $msg_folder = $_GET['msg_folder']; 
     85                        $encoding = strtolower($_GET['encoding']); 
     86                        $fileContent = ""; 
     87 
     88                        if($msg_number && $msg_part && $msg_folder && (intval($idx_file == '0' ? '1' : $idx_file))) { 
     89                                $username = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 
     90                                $password = $_SESSION['phpgw_info']['expressomail']['user']['passwd']; 
     91                                $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; 
     92                                $imap_port      = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];           
     93                                if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes') 
     94                                { 
     95                                        $imap_options = '/tls/novalidate-cert'; 
     96                                } 
     97                                else 
     98                                { 
     99                                        $imap_options = '/notls/novalidate-cert'; 
     100                                } 
     101                                $mbox_stream = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password);           
     102                                $fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID); 
     103 
     104                                $imap_attachment = CreateObject("expressoMail1_2.imap_attachment");                      
     105                                $a = $imap_attachment->download_attachment($mbox_stream, $msg_number); 
     106                                 
     107                                $filename = $a[$idx_file]['name']; 
     108                        } 
     109                        else 
     110                                $filename = $idx_file; 
     111                                         
     112                        $filename        = $filename    ? $filename     : "attachment.bin"; 
     113                        $newfilename = $newfilename ? $newfilename      : $filename; 
     114                        $strFileType = strrev(substr(strrev(strtolower($filename)),0,4));        
     115                         
     116                        if($fileContent) { 
     117                                if($encoding == 'base64') 
     118                                        $calendar = imap_base64($fileContent); 
     119                                else if($encoding == 'quoted-printable') 
     120                                        $calendar = quoted_printable_decode($fileContent); 
     121                                else 
     122                                        $calendar = $fileContent; 
     123                        } 
     124                        $this->bo->import(explode("\n",$calendar),true); 
     125                         
     126                         
     127                } 
     128 
     129 
    78130                function import() 
    79131                { 
  • trunk/expressoMail1_2/js/draw_api.js

    r617 r620  
    13261326                        else 
    13271327                                link_attachment.innerHTML += ' (' + msg_size + ' bytes)'; 
    1328                         link_attachment.innerHTML += '<BR>'; 
    1329                         attachments.appendChild(link_attachment); 
     1328                        if((url_decode(info_msg.attachments[i].name).indexOf(".ics")!=-1) || (url_decode(info_msg.attachments[i].name).indexOf(".vcard")!=-1)){ 
     1329                                //Link para importar calendário 
     1330                                var link_import_attachment = document.createElement("A"); 
     1331                                link_import_attachment.setAttribute("href","../index.php?menuaction=calendar.uiicalendar.import_from_mail&msg_folder="+info_msg.msg_folder+"&msg_number="+info_msg.msg_number+"&msg_part="+info_msg.attachments[i].pid+"&idx_file="+i+"&encoding="+info_msg.attachments[i].encoding); 
     1332                                link_import_attachment.innerHTML=get_lang("Import to calendar")+"<br>"; 
     1333                                var space = document.createElement("span"); 
     1334                                space.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;"; 
     1335                                attachments.appendChild(link_attachment); 
     1336                                attachments.appendChild(space); 
     1337                                attachments.appendChild(link_import_attachment); 
     1338                        } 
     1339                        else { 
     1340                                link_attachment.innerHTML += '<BR>'; 
     1341                                attachments.appendChild(link_attachment); 
     1342                        } 
    13301343                } 
    13311344                tr6.appendChild(td6); 
Note: See TracChangeset for help on using the changeset viewer.