Index: branches/2.5/expressoMail1_2/js/doiMenuData.js
===================================================================
--- branches/2.5/expressoMail1_2/js/doiMenuData.js	(revision 8127)
+++ branches/2.5/expressoMail1_2/js/doiMenuData.js	(revision 8232)
@@ -142,10 +142,11 @@
     function loadMenu(){
         var archive = "";
-        if(use_local_messages != 0){
-            archive = {"name": get_lang("Archive"), "icon": "archive", callback: function(key, opt){ proxy_mensagens.archive_message('inbox', 'get_selected_messages'); }}
-        }else{
-            archive = "";
+
+        if( preferences['use_followupflags_and_labels'] == "1" )
+            var labelItems = getLabels();
+
+        var revertSortBox = function(){
+            if (search_box_type == "UNSEEN") sort_box_reverse = sort_box_reverse ? 0 : 1; 
         }
-    	var labelItems = getLabels();
 
     	$.contextMenu({
@@ -156,28 +157,51 @@
                     return true;
                 }
-                if( current.indexOf("local") == -1){ 
-                    archive = {"name": get_lang("Archive"), "icon": "archive", callback: function(key, opt){ proxy_mensagens.archive_message(get_current_folder(), 'get_selected_messages'); }} 
-                    
-                } else { 
-                    archive = {"name": get_lang("Unarchive"), "icon": "archive", callback: function(key, opt){ proxy_mensagens.unarchive_message(get_current_folder(), 'get_selected_messages'); }} 
-                }
-                var itensNotLocal = {
-                    "label": { "name": get_lang("Labels"), "items": labelItems},
-                    "follouwpflag":{"name": get_lang("Follow up"), callback: function(key, opt){ configureFollowupflag(); } },
-                    "sep2": "---------"
-                }
+                if(use_local_messages != 0){
+                    if( current.indexOf("local") != -1){
+                       archive = {"name": get_lang("Unarchive"), "icon": "archive", callback: function(key, opt){ proxy_mensagens.unarchive_message('inbox', 'get_selected_messages'); }}
+                    } else {
+                        archive = {"name": get_lang("Archive"), "icon": "archive", callback: function(key, opt){ proxy_mensagens.unarchive_message('inbox', 'get_selected_messages'); }}
+                    }
+                }
+
+                if( preferences['use_followupflags_and_labels'] == "1" )
+                    var itensNotLocal = {
+                        "label": { "name": get_lang("Labels"), "items": labelItems},
+                        "follouwpflag":{"name": get_lang("Follow up"), callback: function(key, opt){ configureFollowupflag(); } },
+                        "sep2": "---------"
+                    }
 
                 var items= {
-                    "flagSeen":      {"name": get_lang("Mark as") + " " + get_lang('seen'), "icon": "seen", callback: function(key, opt){ proxy_mensagens.proxy_set_messages_flag('seen','get_selected_messages'); }},
-                    "flagUnseen":    {"name": get_lang("Mark as") + " " + get_lang('unseen'), "icon": "unseen", callback: function(key, opt){ proxy_mensagens.proxy_set_messages_flag('unseen','get_selected_messages'); }},
-                    "flagFlagged":   {"name": get_lang("Mark as") + " " + get_lang('important'), "icon": "important", callback: function(key, opt){ proxy_mensagens.proxy_set_messages_flag('flagged','get_selected_messages'); }},
-                    "flagUnflagged": {"name": get_lang("Mark as") + " " + get_lang('normal'), callback: function(key, opt){ proxy_mensagens.proxy_set_messages_flag('unflagged','get_selected_messages'); }},
+                    "flagSeen":      {"name": get_lang("Mark as") + " " + get_lang('seen'), "icon": "seen", callback: function(key, opt){ revertSortBox(); proxy_mensagens.proxy_set_messages_flag('seen','get_selected_messages'); }},
+                    "flagUnseen":    {"name": get_lang("Mark as") + " " + get_lang('unseen'), "icon": "unseen", callback: function(key, opt){ revertSortBox(); proxy_mensagens.proxy_set_messages_flag('unseen','get_selected_messages'); }},
+                    "flagFlagged":   {"name": get_lang("Mark as") + " " + get_lang('important'), "icon": "important", callback: function(key, opt){ revertSortBox(); proxy_mensagens.proxy_set_messages_flag('flagged','get_selected_messages'); }},
+                    "flagUnflagged": {"name": get_lang("Mark as") + " " + get_lang('normal'), callback: function(key, opt){ revertSortBox(); proxy_mensagens.proxy_set_messages_flag('unflagged','get_selected_messages'); }},
                     "sep1": "---------"
                 }
-
+				
+				// Desabilita a opção de criar filtro a partir da mensagem, caso mais de uma mensagem esteja selecionada: 
+				var is_filterFromMsg_disabled = function () { 
+					var base_selector = ".table_box tbody tr.selected_msg"; 
+					return ($(base_selector).length > 1) || ($(base_selector + " td span").text().indexOf(get_lang("Draft")) > -1); 
+				} 
+				
                 var lastItens = {
                     "move": {"name": get_lang("Move to")+"...", "icon": "move", callback: function(key, opt){ wfolders.makeWindow('', 'move_to'); }},
                     "remove": {"name": get_lang("Delete"),      "icon": "delete", callback: function(key, opt){ proxy_mensagens.delete_msgs('null','selected','null'); }},
                     "export": {"name": get_lang("Export"),      "icon": "export", callback: function(key, opt){ proxy_mensagens.export_all_messages(); }},
+					/*Abre o diálogo de criação de filtro a partir da mensagem:*/ 
+					"filterFromMsg": { 
+						"name": get_lang("Create filter from message"),  
+						"icon": "filter",  
+						callback: function (key, opt) { 
+							var msg_number = get_selected_messages(); 
+							var msg = onceOpenedHeadersMessages[current_folder][msg_number]; 
+							if (msg !== undefined) 
+							{ 
+								filter_from_msg(msg); 
+							} 
+						}, 
+						disabled: is_filterFromMsg_disabled() 
+					}, 
                     "archive": archive
                 }
@@ -318,6 +342,6 @@
     	} else {
             var labeleds =  (messageInfo.forceIcon ? messageInfo.labels : DataLayer.get('labeled', {
-    			criteria: {deepness: '2'},
-    			filter: [
+    			criteria: {deepness: 2},
+                filter: [
     				'AND',
     				['=', 'folderName', msg_folder], 
@@ -337,5 +361,5 @@
 
                 for (var i=0; i < labeleds.length; i++){
-                    menuItems[ labeleds[i].id ? labeleds[i].id : labeleds[i].label.id] = labeleds[i].id ? labeleds[i] : labeleds[i].label;
+                    menuItems[ (labeleds[i].id ? labeleds[i].id : labeleds[i].label.id) ] = labeleds[i].label ? labeleds[i].label : labeleds[i];
                 }
     		} else {
@@ -351,4 +375,6 @@
     		menuItensLabel[index] = {type: "label", customName: menuItems[index].name, id: msg_folder+"/"+msg_number+"#"+index};		
     	}
+
+
     	$.contextMenu.types.label = function(item, opt, root) {
             $('<span>'+item.customName+'</span><span class="removeLabeled" title="'+get_lang("Remove Label")+'">x</span>')
