Changeset 1518


Ignore:
Timestamp:
10/20/09 15:24:08 (14 years ago)
Author:
eduardoalex
Message:

Ticket #656 - funcionalidade de arquivamento programado no expressoMail

Location:
trunk
Files:
5 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.exporteml.inc.php

    r1377 r1518  
    318318                        $fileNameReal = $this->remove_accents($attachment['name']); 
    319319                        $ContentType = $this->getFileType($fileNameReal); 
    320                         $fileName = $fileNameReal . ".php"; 
     320                        $fileName = $fileNameReal; 
     321                        if(strpos($ContentType,"text")!==false || 
     322                                        strpos($ContentType,"image")!==false || 
     323                                        strpos($ContentType,"audio")!==false) 
     324                                $fileName.= ".php"; 
    321325                        $f = fopen($tempDir . '/'.$tempSubDir.'/'.$fileName,"wb"); 
    322326                        if(!$f) 
     
    326330                        $urlPath = 'tmpLclAtt/'.$tempSubDir.'/'.$fileName; 
    327331                         
    328                         $headers = "<?php header('Content-Type: ".$ContentType."'); 
    329                                 header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
    330                                 header('Pragma: public'); 
    331                                 header('Expires: 0'); // set expiration time 
    332                                 header('Content-Disposition: attachment; filename=\"". addslashes($fileNameReal) ."\"');\n echo "; 
    333                          
    334                         if($attachment['encoding'] == 'base64') { 
    335                                 $headers.=" imap_base64('".$fileContent."');?>"; 
    336                         } 
    337                         else if($attachment['encoding'] == 'quoted_printable_decode') { 
    338                                 $headers.=" quoted_printable_decode('".$fileContent."');?>"; 
     332                        if(strpos($ContentType,"text")!==false || 
     333                                        strpos($ContentType,"image")!==false || 
     334                                        strpos($ContentType,"audio")!==false) { 
     335                                $headers = "<?php header('Content-Type: ".$ContentType."'); 
     336                                        header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
     337                                        header('Pragma: public'); 
     338                                        header('Expires: 0'); // set expiration time 
     339                                        header('Content-Disposition: attachment; filename=\"". addslashes($fileNameReal) ."\"');\n echo "; 
     340                         
     341                                if($attachment['encoding'] == 'base64') { 
     342                                        $headers.="imap_base64('".$fileContent."');?>"; 
     343                                } 
     344                                else if($attachment['encoding'] == 'quoted_printable_decode') { 
     345                                        $headers.="quoted_printable_decode('".$fileContent."');?>"; 
     346                                } 
     347                                else { 
     348                                        $headers.="'".$fileContent."';?>"; 
     349                                } 
    339350                        } 
    340351                        else { 
    341                                 $headers.=" '".$fileContent."';?>"; 
     352                                if($attachment['encoding'] == 'base64') { 
     353                                        $headers=imap_base64($fileContent); 
     354                                } 
     355                                else if($attachment['encoding'] == 'quoted_printable_decode') { 
     356                                        $headers=quoted_printable_decode($fileContent); 
     357                                } 
     358                                else { 
     359                                        $headers=$fileContent; 
     360                                } 
    342361                        } 
    343362                         
     
    366385                if ($strFileType == ".gif") 
    367386                        $ContentType = "image/gif"; 
     387                if ($strFileType == ".png") 
     388                        $ContentType = "image/png"; 
    368389                if ($strFileType == ".jpg" || $strFileType == "jpeg") 
    369390                        $ContentType = "image/jpeg"; 
  • trunk/expressoMail1_2/inc/class.imap_functions.inc.php

    r1489 r1518  
    1313                'get_info_msgs'                                 => True, 
    1414                'get_folders_list'                              => True, 
    15                 'import_msgs'                                   => True 
     15                'import_msgs'                                   => True, 
     16                'msgs_to_archive'                               => True 
    1617        ); 
    1718 
     
    364365                return $return; 
    365366 
     367        } 
     368         
     369        function msgs_to_archive($params) { 
     370                 
     371                $folder = $params['folder']; 
     372                $all_ids = $this-> get_msgs($folder, 'SORTSIZE', false, 0,-1,-1); 
     373 
     374                $messages_not_to_copy = explode(",",$params['mails']); 
     375                $ids = array(); 
     376                 
     377                foreach($all_ids as $each_id=>$value) { 
     378                        if(!in_array($each_id,$messages_not_to_copy)) 
     379                                array_push($ids,$each_id); 
     380                } 
     381 
     382                if (empty($ids)) 
     383                        return array(); 
     384 
     385                $params = array("folder"=>$folder,"msgs_number"=>implode(",",$ids)); 
     386                 
     387                 
     388                return $this->get_info_msgs($params); 
     389                 
     390                 
    366391        } 
    367392 
     
    20472072                        foreach($imapsort as $iuid) 
    20482073                                $sort[$iuid] = ""; 
    2049                         $slice_array = true; 
     2074                         
     2075                        if ($offsetBegin == -1 && $offsetEnd ==-1 ) 
     2076                                $slice_array = false; 
     2077                        else 
     2078                                $slice_array = true; 
    20502079                } 
    20512080                else 
  • trunk/expressoMail1_2/inc/hook_preferences.inc.php

    r1121 r1518  
    1313        $file = array( 
    1414                'Preferences'                   => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname), 
    15                 'Expresso Offline'                      => $GLOBALS['phpgw']->link('/expressoMail1_2/offline_preferences.php') 
     15                'Expresso Offline'                      => $GLOBALS['phpgw']->link('/expressoMail1_2/offline_preferences.php'), 
     16                'Programed Archiving' => $GLOBALS['phpgw']->link('/expressoMail1_2/programed_archiving.php') 
    1617        ); 
    1718        //Do not modify below this line 
  • trunk/expressoMail1_2/index.php

    r1507 r1518  
    7373    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['num_max_certs_to_cipher'] = $GLOBALS['phpgw_info']['server']['num_max_certs_to_cipher'] ?  $GLOBALS['phpgw_info']['server']['num_max_certs_to_cipher'] : "10"; 
    7474    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_signature_cripto'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_cripto'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_cripto'] : "0"; 
    75 $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size'] = $current_config['expressoMail_Max_attachment_size'] ? $current_config['expressoMail_Max_attachment_size']."M" : ini_get('upload_max_filesize');  
     75        $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['keep_after_auto_archiving'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['keep_after_auto_archiving'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['keep_after_auto_archiving'] : "0"; 
     76 
     77        $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size'] = $current_config['expressoMail_Max_attachment_size'] ? $current_config['expressoMail_Max_attachment_size']."M" : ini_get('upload_max_filesize');  
    7678        $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
    7779        $template->set_var("txt_loading",lang("Loading")); 
     
    166168                                                        "js/messages_proxy.js," . 
    167169                                                        "js/rich_text_editor.js," . 
     170                                                        "js/mail_sync.js," . 
    168171                                                        "js/wfolders.js,", 
    169172                                                        $GLOBALS['phpgw_info']['flags']['update_version']); 
  • trunk/expressoMail1_2/js/common_functions.js

    r1503 r1518  
    7373 
    7474function unloadMess(){ 
    75         var mess = get_lang("Your message has not been sent and will be discarted."); 
    76         for(var i = 0; i < BordersArray.length;i++) { 
    77                 var body = Element('body_'+BordersArray[i].sequence); 
    78                 if (body && body.contentWindow && body.contentWindow.document.designMode.toLowerCase() == 'on') { 
    79                         return mess; 
     75        if (expresso_mail_sync.folders.length != 0) { 
     76                var mess = get_lang("You're about archiving your e-mails from server. Do you really want to stop this action?"); 
     77                return mess; 
     78        } 
     79        else { 
     80                var mess = get_lang("Your message has not been sent and will be discarted."); 
     81                for (var i = 0; i < BordersArray.length; i++) { 
     82                        var body = Element('body_' + BordersArray[i].sequence); 
     83                        if (body && body.contentWindow && body.contentWindow.document.designMode.toLowerCase() == 'on') { 
     84                                return mess; 
     85                        } 
    8086                } 
    8187        } 
  • trunk/expressoMail1_2/js/draw_api.js

    r1495 r1518  
    179179                        } 
    180180                        else{ 
    181                                 if (expresso_offline)  
    182                                         tree_folders = new dFTree({name: 'tree_folders'}); 
    183                                 var root_local = new dNode({ 
    184                                         id: "local_root", 
    185                                         caption: get_lang('local folders') 
    186                                 }); 
    187                                 tree_folders.add(root_local, "root"); //coloca root local 
    188                                 var local_folders = expresso_local_messages.list_local_folders(); 
    189                                 for (var i in local_folders) { //Coloca as pastas locais. 
    190                                         var node_root = "local_root"; 
    191                                         var new_caption = local_folders[i][0]; 
    192                                         if(local_folders[i][0].indexOf("/")!="-1") { 
    193                                                 final_pos = local_folders[i][0].lastIndexOf("/"); 
    194                                                 node_root = "local_"+local_folders[i][0].substr(0,final_pos); 
    195                                                 new_caption = local_folders[i][0].substr(final_pos+1); 
     181                                if (!window.google || !google.gears) { 
     182                                        temp = confirm(get_lang("To use local messages you have to install google gears. Would you like to be redirected to gears installation page?")); 
     183                                        if (temp) { 
     184                                                location.href = "http://gears.google.com/?action=install&message=" + 
     185                                                "Para utilizar o recurso de mensagens locais, instale o google gears&return=" + 
     186                                                document.location.href; 
    196187                                        } 
    197                                         if (local_folders[i][1] > 0)  
    198                                                 var nodeLocal = new dNode({ 
    199                                                         id: "local_" + local_folders[i][0], 
    200                                                         caption: lang_folder(new_caption) + '<font style=color:red>&nbsp(</font><span id="local_unseen" style=color:red>' + local_folders[i][1] + '</span><font style=color:red>)</font>', 
    201                                                         onClick: "change_folder('local_" + local_folders[i][0] + "','" + new_caption + "')", 
    202                                                         plusSign: local_folders[i][2] 
     188                                        else { 
     189                                                preferences.use_local_messages = 0; 
     190                                        } 
     191                                } 
     192                                else { 
     193                                        if (expresso_offline)  
     194                                                tree_folders = new dFTree({ 
     195                                                        name: 'tree_folders' 
    203196                                                }); 
    204                                         else  
    205                                                 var nodeLocal = new dNode({ 
    206                                                         id: "local_" + local_folders[i][0], 
    207                                                         caption: lang_folder(new_caption), 
    208                                                         onClick: "change_folder('local_" + local_folders[i][0] + "','" + new_caption + "')", 
    209                                                         plusSign: local_folders[i][2] 
    210                                                 }); 
    211                                         tree_folders.add(nodeLocal, node_root); 
     197                                        var root_local = new dNode({ 
     198                                                id: "local_root", 
     199                                                caption: get_lang('local folders') 
     200                                        }); 
     201                                        tree_folders.add(root_local, "root"); //coloca root local 
     202                                        var local_folders = expresso_local_messages.list_local_folders(); 
     203                                        for (var i in local_folders) { //Coloca as pastas locais. 
     204                                                var node_root = "local_root"; 
     205                                                var new_caption = local_folders[i][0]; 
     206                                                if (local_folders[i][0].indexOf("/") != "-1") { 
     207                                                        final_pos = local_folders[i][0].lastIndexOf("/"); 
     208                                                        node_root = "local_" + local_folders[i][0].substr(0, final_pos); 
     209                                                        new_caption = local_folders[i][0].substr(final_pos + 1); 
     210                                                } 
     211                                                if (local_folders[i][1] > 0)  
     212                                                        var nodeLocal = new dNode({ 
     213                                                                id: "local_" + local_folders[i][0], 
     214                                                                caption: lang_folder(new_caption) + '<font style=color:red>&nbsp(</font><span id="local_unseen" style=color:red>' + local_folders[i][1] + '</span><font style=color:red>)</font>', 
     215                                                                onClick: "change_folder('local_" + local_folders[i][0] + "','" + new_caption + "')", 
     216                                                                plusSign: local_folders[i][2] 
     217                                                        }); 
     218                                                else  
     219                                                        var nodeLocal = new dNode({ 
     220                                                                id: "local_" + local_folders[i][0], 
     221                                                                caption: lang_folder(new_caption), 
     222                                                                onClick: "change_folder('local_" + local_folders[i][0] + "','" + new_caption + "')", 
     223                                                                plusSign: local_folders[i][2] 
     224                                                        }); 
     225                                                tree_folders.add(nodeLocal, node_root); 
     226                                        } 
    212227                                } 
    213228                        } 
  • trunk/expressoMail1_2/js/globals.js

    r1507 r1518  
    3838        '<tr>'+ 
    3939        '<td style="padding-left:17px" width=33% id="content_quota" align=left></td>'+ 
    40         '<td class="divAppboxHeader" width=33%>Expresso Mail</td>'+ 
     40        '<td class="divAppboxHeader" width=33% id="main_title">Expresso Mail</td>'+ 
    4141        '<td width=33% id="div_menu_c3" align=right></td>'+ 
    4242        '</tr></table>'; 
  • trunk/expressoMail1_2/js/local_messages.js

    r1477 r1518  
    3131                if(this.store==null) 
    3232                        this.store = this.localServer.createStore('test-store');                         
    33                 this.dbGears.open('database-test'); 
     33                 
     34                var db_in_other_use = true; 
     35                while (db_in_other_use) { 
     36                        try { 
     37                                this.dbGears.open('database-test'); 
     38                                db_in_other_use = false; 
     39                        }  
     40                        catch (ex) { 
     41                                db_in_other_use=true; 
     42                        } 
     43                } 
     44                 
     45                /*var db_is_opened = true; 
     46                while (db_is_opened) { 
     47                        try { 
     48                                this.dbGears.open('database-test'); 
     49                                db_is_opened = true; 
     50                        }  
     51                        catch (ex) { 
     52                                db_is_opened=false; 
     53                        } 
     54                }*/ 
     55                 
     56//              this.dbGears.open('database-test'); 
    3457                this.dbGears.execute('create table if not exists folder (folder text,uid_usuario int,unique(folder,uid_usuario))'); 
    3558                this.dbGears.execute('create table if not exists mail' + 
     
    3861                this.dbGears.execute('create table if not exists anexo' + 
    3962                ' (id_mail int,nome_anexo text,url text,pid int)'); 
     63                this.dbGears.execute('create table if not exists folders_sync' + 
     64                ' (id_folder text,folder_name text,uid_usuario int)'); 
     65                this.dbGears.execute('create table if not exists msgs_to_remove (id_msg int,folder text,uid_usuario int)'); 
    4066 
    4167                //some people that used old version of local messages could not have the size column. If it's the first version 
     
    908934        } 
    909935         
     936        local_messages.prototype.get_folders_to_sync = function() { 
     937                this.init_local_messages(); 
     938                var rs = this.dbGears.execute("select id_folder,folder_name from folders_sync where uid_usuario="+account_id); 
     939                var retorno = new Array(); 
     940                while(rs.isValidRow()) { 
     941                        temp = new Array(); 
     942                        temp[0] = rs.field(0); 
     943                        temp[1] = rs.field(1); 
     944                        retorno.push(temp); 
     945                        rs.next(); 
     946                } 
     947                this.finalize(); 
     948                return retorno; 
     949        } 
     950         
    910951        local_messages.prototype.install_offline = function(urlOffline,urlIcone,uid_usuario,login,pass,redirect) { 
    911952                if (!window.google || !google.gears) { 
  • trunk/expressoMail1_2/js/main.js

    r1443 r1518  
    2424                ConstructMenuTools(); 
    2525 
     26                if ((preferences.use_local_messages==1) && (!window.google || !google.gears)) { 
     27                        temp = confirm(get_lang("To use local messages you have to install google gears. Would you like to be redirected to gears installation page?")); 
     28                        if (temp) { 
     29                                location.href = "http://gears.google.com/?action=install&message="+ 
     30                                "Para utilizar o recurso de mensagens locais, instale o google gears&return=" + document.location.href; 
     31                        } 
     32                        else { 
     33                                preferences.use_local_messages=0; 
     34                        } 
     35                } 
     36 
    2637        // Insere a applet de criptografia 
    2738        if (preferences.use_signature_digital_cripto == '1'){ 
     
    5162        cExecute ("$this.functions.get_preferences", save_preferences); 
    5263        setTimeout('auto_refresh()', time_refresh); 
    53         if(window.google && google.gears) 
    54                 if(expresso_local_messages.is_offline_installed()) 
     64        if (window.google && google.gears) { 
     65                setTimeout('auto_archiving()', 30000); 
     66                if (expresso_local_messages.is_offline_installed()) { 
    5567                        check_mail_in_queue(); 
     68                } 
     69        } 
    5670} 
    5771 
     
    357371        refresh(preferences.alert_new_msg); 
    358372        setTimeout('auto_refresh()', time_refresh); 
     373} 
     374 
     375function auto_archiving() { 
     376        expresso_mail_sync.start_sync(); 
     377        setTimeout('auto_archiving()',600000); 
    359378} 
    360379 
  • trunk/preferences/index.php

    r1231 r1518  
    2323                'pref' => 'index.tpl' 
    2424        ); 
    25  
    26         //Check preferences that influences the hooks 
    27         $c = CreateObject('phpgwapi.config','expressoMail1_2'); 
    28     $c->read_repository(); 
    29     $current_config = $c->config_data; 
    30         $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['enable_expresso_offline'] = $current_config['enable_expresso_offline']; 
    31  
     25        //Check preferences that influences the hooks  
     26        $c = CreateObject('phpgwapi.config','expressoMail1_2');  
     27        $c->read_repository();  
     28        $current_config = $c->config_data;  
     29        $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['enable_expresso_offline'] = $current_config['enable_expresso_offline'];  
     30        /*print_r($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']); 
     31        exit;*/ 
     32         
    3233        $pref_tpl->set_file($templates); 
    3334 
     
    145146                        if($text == 'Expresso Offline' &&  
    146147                                $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['enable_expresso_offline']!='True') 
     148                                continue; 
     149                        if($text == 'Programed Archiving' &&   
     150                                $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages']!='1') 
    147151                                continue;                        
    148152                        section_item($url,lang($text)); 
Note: See TracChangeset for help on using the changeset viewer.