Changeset 5085


Ignore:
Timestamp:
09/11/11 09:16:08 (7 years ago)
Author:
fernando-alberto
Message:

Ticket #1269 - Desenvolvimento da nova solucao de arquivamento local MailArchiver?, tags para arquivamento

Location:
sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/inc/class.imap_functions.inc.php

    r4955 r5085  
    1515                'import_msgs'                                   => True, 
    1616                'msgs_to_archive'                               => True, 
    17                 'get_offset_gmt'                                => True 
     17                'get_offset_gmt'                                => True, 
     18                'get_msg_flags'                                 => True 
    1819        ); 
    1920 
     
    41454146        return($this->functions->CalculateDateOffset()); 
    41464147    } 
     4148     
     4149    //MailArchiver -> get message flags only, invoked at archive operation 
     4150    function get_msg_flags($args){        
     4151        $msg_folder = $args['folder']; 
     4152        $msg_n = $args['msg_number']; 
     4153         
     4154        $arr_msg = explode(",", $msg_n); 
     4155        
     4156        for($i=0; $i<count($arr_msg); $i++){ 
     4157                         
     4158            if(!$this->mbox || !is_resource($this->mbox)) 
     4159                $this->mbox = $this->open_mbox($msg_folder); 
     4160         
     4161            if(!is_resource($this->mbox)) 
     4162                return(false); 
     4163                        
     4164            $header = @imap_headerinfo($this->mbox, imap_msgno($this->mbox, $arr_msg[$i]), 80, 255); 
     4165                 
     4166            if (!is_object($header)) 
     4167                return false; 
     4168 
     4169            $taglist[$i]["msgid"] = $msg_n; 
     4170            $taglist[$i]["unseen"] = $header->Unseen; 
     4171            $taglist[$i]["recent"] = $header->Recent; 
     4172            $taglist[$i]["flagged"] = $header->Flagged; 
     4173            $taglist[$i]["draft"] = $header->Draft; 
     4174            $taglist[$i]["answered"] = $header->Answered; 
     4175            $taglist[$i]["deleted"] = $header->Deleted; 
     4176         
     4177            if($header->Answered =='A' && $header->Draft == 'X') 
     4178                $taglist[$i]['forwarded'] = 'F'; 
     4179            else 
     4180                $taglist[$i]['forwarded'] = ' '; 
     4181         
     4182            if($header->Flagged != "F" && $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) { 
     4183                $flag = preg_match('/importance *: *(.*)\r/i', 
     4184                        imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)) 
     4185                        ,$importance); 
     4186                $taglist[$i]["flagged"] = $flag==0?false:strtolower($importance[1])=="high"?"F":false; 
     4187            } 
     4188        } 
     4189         
     4190        return $taglist;         
     4191    } 
    41474192} 
    41484193?> 
  • sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/MAExpressoPattern.js

    r5049 r5085  
    7171 
    7272MAPattern.prototype.toExpressoAttachmentsHeader = function(data){ 
    73     if((typeof(data) != 'undefined') && (data.length > 0)){ 
     73    if((typeof(data) != 'undefined') && (data.length > 2)){ 
    7474        var Attdata = eval("(" + data + ")"); 
    7575        if(typeof(Attdata.attachment) != 'undefined'){                     
     
    185185 
    186186MAPattern.prototype.toExpressoHeader = function(data){    
    187     var tplHeader = 'a:16:{' 
     187    var tplHeader = 'a:26:{' 
    188188+           's:11:"ContentType";' 
    189189+           's:' + data.getContentType().length + ':"' + data.getContentType() + '";' 
     
    382382    var objTag = eval('(' + tagData + ')'); 
    383383    var tplHMail = ""; 
    384  
     384     
     385    if(objTag.tag){ 
    385386    //More than 1 attachment - because length will be 'undefined' if just one exists 
    386387    if(objTag.tag.length >= 0){ 
     
    423424            tplHMail += 's:7:"Flagged";s:1:" ";';                       
    424425    } 
     426    } 
    425427     
    426428    //No header to tag 
     
    442444    var srlData = ""; 
    443445 
    444     //There are attacments, map them 
     446    //There are attacments, map all them 
    445447    if(typeof(objAtt.attachment) != 'undefined'){ 
    446448        srlData = 's:12:"array_attach";a:' + objAtt.attachment.length + ':{'; 
    447449        for(var m=0; m<objAtt.attachment.length; m++){ 
    448             //TODO "download" parametr at webservice => var urllink = 'http://10.200.242.186:4333/part/'+objAtt.attachment[m]["@id"]+'/download'; 
    449             //var urllink = 'http://10.200.242.186:4333/part/'+objAtt.attachment[m]["@id"]; 
    450             //var urllink = mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/part/'+objAtt.attachment[m]["@id"]; 
    451450            var urllink = mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/part/download/'+objAtt.attachment[m]["@id"]; 
    452451            srlData += 's:1:"' + m + '";' 
     
    468467MAPattern.prototype.toExpressoMailURLExportFile = function(path, file){ 
    469468    var srlData = 's:15:"url_export_file";'; 
    470     //var urllink = 'http://10.200.242.186:4333/mail/'+path+'/'+file+'/download'; 
    471     //var urllink = 'http://10.200.242.186:4333/mail/'+path+'/'+file; 
    472469    var urllink = mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/mail/'+path+'/'+file; 
    473470    srlData += 's:' + urllink.length + ':"' + urllink + '";' 
     
    578575        retorno['msg_folder'] = "local_"+rs.field(7); //Now it's a local folder 
    579576        retorno['msg_number'] = rs.field(0)+plus_id; //the message number is the rowid 
    580  **/     
     577 **/  
     578} 
     579 
     580MAPattern.prototype.tagConfig = function(taglist, arcidmsg){ 
     581    if(taglist != null){ 
     582        var tagdata = ""; 
     583         
     584        //Draft folder, are "draft" 
     585        if(expresso_mail_archive.folder_destination == 'drafts'){ 
     586            tagdata += '<add value="draft"/>'; 
     587        } 
     588         
     589        //Trash folder, are "deleted"" 
     590        if(expresso_mail_archive.folder_destination == 'trash'){ 
     591            tagdata += '<add value="deleted"/>'; 
     592        } 
     593         
     594        for(var x in taglist[0]){ 
     595            if((taglist[0][x] != '') && (taglist[0][x] != ' ') && (taglist[0][x] != null) && (x != 'msgid')) 
     596                tagdata += '<add value="'+x+'"/>'; 
     597        } 
     598 
     599        if(tagdata != ""){ 
     600         
     601            var tobject = '<tag>' 
     602            +              '<message id="'+arcidmsg+'">' 
     603            +              tagdata 
     604            +              '</message>' 
     605            +             '</tag>'; 
     606            return(tobject); 
     607        } 
     608        return(null); 
     609    } 
     610    return(null); 
    581611} 
    582612--> 
  • sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/MAQueryConfig.js

    r5070 r5085  
    110110  //window.alert('setbounds low = ' + low + ' high = ' + high); 
    111111  this.lowerIndex = '"@lowerIndex":"'+(parseInt(low)-1)+'",'; 
    112   this.upperIndex = '"@upperIndex":"'+(parseInt(high)-1)+'",'; 
     112  this.upperIndex = '"@upperIndex":"'+(parseInt(high))+'",'; 
    113113} 
    114114//From receives a array of structutred data, by the model 
  • sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/mail_archiver.js

    r5073 r5085  
    170170    this.unarchievefolder = null; 
    171171    this.unarchievenewfolder = null; 
    172                            
     172    this.taglist = null;                           
    173173} 
    174174 
     
    351351 
    352352MailArchiver.prototype.CreateMessageList = function(msg_list){ 
     353    //window.alert('criando messagelist de arquivamento.'); 
     354     
     355//    for(var j=0; j<expresso_mail_archive.messageslisted.length; j++){ 
     356//        window.alert('\nAnswered = ' + expresso_mail_archive.messageslisted[j]["Answered"] + '\nFlagged = ' + expresso_mail_archive.messageslisted[j]["Flagged"] + '\nUnseen = ' + expresso_mail_archive.messageslisted[j]["Unseen"] + '\nDraft = ' + expresso_mail_archive.messageslisted[j]["Draft"]); 
     357//    } 
     358     
    353359    if((msg_list != null) && (msg_list != "") && (msg_list != " ")){ 
    354360        if (expresso_mail_archive.message_list.length == 0){ 
     
    360366                } 
    361367            } 
     368             
    362369            //Push message list to process the only one 
    363             else expresso_mail_archive.message_list.push(msg_list); 
     370            else { 
     371                //window.alert('testando marcadores default...\n->Answered = ' +expresso_mail_archive.messageslisted[i]["Answered"] + '\n->Unseen = '+expresso_mail_archive.messageslisted[i]["Unseen"]); 
     372                expresso_mail_archive.message_list.push(msg_list); 
     373            } 
    364374        } 
    365375    } 
     
    367377    else expresso_mail_archive.message_list = new Array(); 
    368378} 
     379 
    369380 
    370381//Archive Operation 
     
    374385        document.getElementById('main_title').innerHTML = get_lang("Starting to archive messages"); 
    375386        expresso_mail_archive.CreateMessageList(msgs_id); 
     387         
     388        var tagsHandler = function(data){ 
     389            if(data){ 
     390                var datah = eval(data); 
     391                //window.alert('unseen = ' +datah["unseen"] + '\nrecent = ' + datah["recent"] + '\nflagged = ' + datah["flagged"] + '\ndraft = ' + datah["draft"] + '\nanswered = ' + datah["answered"] + '\ndeleted = ' + datah["deleted"] + '\nforwarded = ' + datah["forwarded"]); 
     392                expresso_mail_archive.taglist = datah; 
     393            } 
     394        } 
    376395 
    377396        if((expresso_mail_archive.message_list.length > 0) && (expresso_mail_archive.message_list[0] != '')){ 
     397 
     398            //Get all tags from current archiving message 
     399            var pardata = "&folder=" + url_encode(current_folder)+ "&msg_number="+ expresso_mail_archive.message_list[0]; 
     400            cExecute("$this.imap_functions.get_msg_flags", tagsHandler, pardata); 
    378401 
    379402            //Sets the message counter 
     
    386409                expresso_mail_archive.folder_destination = destination_folder.substr(6,destination_folder.length); 
    387410            else 
    388                 expresso_mail_archive.folder_destination = destination_folder; 
     411                expresso_mail_archive.folder_destination = destination_folder;           
    389412             
    390413            var fcaption = expresso_mail_archive.folder_destination; 
     
    418441    } 
    419442    catch(e){ 
    420         window.alert('Archive error: %1', e); 
     443        window.alert(get_lang("Archive error: %1", (e.description)?e.description:e)); 
    421444    } 
    422445} 
     
    424447//Archive callback OK 
    425448MailArchiver.prototype.getArchiveOperationOK = function(status_message){ 
     449    //message must be tagged 
     450    var arcid = status_message.getReturn().getId(); 
     451    var tlist = expresso_mail_archive.pattern.tagConfig(expresso_mail_archive.taglist, arcid); 
     452    if(tlist != null){ 
     453        try{ 
     454            ArchiveServices.tagMessages(expresso_mail_archive.tagMessagesOperationOK, expresso_mail_archive.tagMessagesOperationFailure, sessid, tlist); 
     455        }catch (e){ 
     456            window.alert('ArchiveServices.tagMessages failed at: ' + (e.description)?e.description:e); 
     457        } 
     458    } 
     459    //archivement allready done, update controll data and interface 
    426460    expresso_mail_archive.messages_processed++; 
    427461    if(expresso_mail_archive.message_list.length > 1){ 
     
    674708            //Store folder data at this format: {folder name, number of messages contained, folder has child nodes, folder id, folder parent id, folder full path} 
    675709            //var folderData = new Array(folderlist.getReturn()[i].getName(), folderlist.getReturn()[i].getMessageCount(), folderChild, folderlist.getReturn()[i].getId(), folderlist.getReturn()[i].getParentId(), folderlist.getReturn()[i].getPath()); 
    676             var folderData = {name: folderlist.getReturn()[i].getName(), messages: folderlist.getReturn()[i].getMessageCount(), haschild: folderChild, id: folderlist.getReturn()[i].getId(), parentid: folderlist.getReturn()[i].getParentId(), path: folderlist.getReturn()[i].getPath()}; 
     710            var folderData = {name: folderlist.getReturn()[i].getName(), messages: folderlist.getReturn()[i].getMessageCount(), haschild: folderChild, id: folderlist.getReturn()[i].getId(), parentid: folderlist.getReturn()[i].getParentId(), path: folderlist.getReturn()[i].getPath(), unseen: folderlist.getReturn()[i].getUnseenCount()}; 
    677711            //window.alert('folder ' + folderData.name + ' tem ' + folderData.messages + ' mensagens.'); 
    678712            lfolders.push(folderData); 
     
    735769                folder_caption = expresso_mail_archive.folders[i]["name"]; 
    736770            } 
    737             var n_demo = new dNode({id: localBaseName + expresso_mail_archive.folders[i]["id"], caption: folder_caption, onClick: "change_folder('"+ localBaseName + expresso_mail_archive.folders[i]["id"] +"','"+ localBaseName + expresso_mail_archive.folders[i]["id"]+"', '" + expresso_mail_archive.drawdata.treeName + "')", plusSign:expresso_mail_archive.folders[i]["haschild"]}); 
    738             //var n_demo = new dNode({id: localBaseName + expresso_mail_archive.folders[i]["name"], caption: folder_caption, onClick: "change_folder('"+ localBaseName + expresso_mail_archive.folders[i]["name"] +"','"+ localBaseName + expresso_mail_archive.folders[i]["name"]+"', '" + expresso_mail_archive.drawdata.treeName + "')", plusSign:expresso_mail_archive.folders[i]["haschild"]}); 
     771             
     772            if(expresso_mail_archive.folders[i]["unseen"] == "0")            
     773                var n_demo = new dNode({id: localBaseName + expresso_mail_archive.folders[i]["id"], caption: folder_caption, onClick: "change_folder('"+ localBaseName + expresso_mail_archive.folders[i]["id"] +"','"+ localBaseName + expresso_mail_archive.folders[i]["id"]+"', '" + expresso_mail_archive.drawdata.treeName + "')", plusSign:expresso_mail_archive.folders[i]["haschild"]}); 
     774            else 
     775               //var nn = new dNode({id:data[i].folder_id, caption:lang_folder(data[i].folder_name) + '<font style=color:red>&nbsp(</font><span id="dftree_'+data[i].folder_id+'_unseen" style=color:red>'+data[i].folder_unseen+'</span><font style=color:red>)</font>', onClick:"change_folder('"+data[i].folder_id+"','"+data[i].folder_name+"')", plusSign:data[i].folder_hasChildren});  
     776               var n_demo = new dNode({id: localBaseName + expresso_mail_archive.folders[i]["id"], caption: folder_caption + '<font style=color:red>&nbsp(</font><span id="dftree_'+expresso_mail_archive.folders[i]["id"]+'_unseen" style=color:red>'+expresso_mail_archive.folders[i]["unseen"]+'</span><font style=color:red>)</font>', onClick: "change_folder('"+ localBaseName + expresso_mail_archive.folders[i]["id"] +"','"+ localBaseName + expresso_mail_archive.folders[i]["id"]+"', '" + expresso_mail_archive.drawdata.treeName + "')", plusSign:expresso_mail_archive.folders[i]["haschild"]});     
     777          
     778         //var n_demo = new dNode({id: localBaseName + expresso_mail_archive.folders[i]["name"], caption: folder_caption, onClick: "change_folder('"+ localBaseName + expresso_mail_archive.folders[i]["name"] +"','"+ localBaseName + expresso_mail_archive.folders[i]["name"]+"', '" + expresso_mail_archive.drawdata.treeName + "')", plusSign:expresso_mail_archive.folders[i]["haschild"]}); 
    739779             
    740780            //Adjust the id node names 
     
    872912//getFolderInfo callback OK 
    873913MailArchiver.prototype.getFolderInfoOperationOK = function(returnService){ 
    874    var folder_info = {id : returnService.getReturn().getId(), name : returnService.getReturn().getName(), parent : returnService.getReturn().getParentId(), numfolders: returnService.getReturn().getFolderCount(), nummessages: returnService.getReturn().getMessageCount()}; 
     914   var folder_info = {id : returnService.getReturn().getId(), name : returnService.getReturn().getName(), parent : returnService.getReturn().getParentId(), numfolders: returnService.getReturn().getFolderCount(), nummessages: returnService.getReturn().getMessageCount(), unseen: returnService.getReturn().getUnseenCount()}; 
    875915   expresso_mail_archive.folder = folder_info; 
    876916} 
     
    936976    } 
    937977    msglist["num_msgs"] = returnService.getReturn().length; 
     978    msglist["tot_unseen"] = expresso_mail_archive.folder.unseen; 
    938979    //window.alert('print_r\n\n' + print_r(msglist)); 
    939980     
     
    9861027    draw_paging(folder_num_msgs); 
    9871028    Element("tot_m").innerHTML = folder_num_msgs; 
     1029    Element('new_m').innerHTML = data_to_draw['tot_unseen'] ? '<font color="RED">'+data_to_draw['tot_unseen']+'</font>' : 0; 
    9881030    //update_menu(); 
    9891031     
Note: See TracChangeset for help on using the changeset viewer.