[670] | 1 | /** |
---|
| 2 | * @author diogenes |
---|
| 3 | */ |
---|
| 4 | |
---|
| 5 | function messages_proxy() { |
---|
| 6 | |
---|
| 7 | } |
---|
| 8 | /** |
---|
| 9 | * Retorna os cabeçalhos das mensagens a serem desenhadas na caixa de email. |
---|
| 10 | */ |
---|
| 11 | messages_proxy.prototype.messages_list = function(folder,msg_range_begin,emails_per_page,sort_box_type,search_box_type,sort_box_reverse,call_back) { |
---|
| 12 | if(this.is_local_folder(folder)) { |
---|
| 13 | var real_folder = folder.substr(6); |
---|
| 14 | var msgs = expresso_local_messages.get_local_range_msgs(real_folder,msg_range_begin,emails_per_page,sort_box_type,sort_box_reverse,search_box_type); |
---|
| 15 | eval('call_back(msgs)'); |
---|
| 16 | }else { |
---|
| 17 | cExecute ("$this.imap_functions.get_range_msgs2&folder="+folder+"&msg_range_begin="+msg_range_begin+"&msg_range_end="+emails_per_page+"&sort_box_type="+sort_box_type+ "&search_box_type="+ search_box_type +"&sort_box_reverse="+sort_box_reverse+"", call_back); |
---|
| 18 | } |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | messages_proxy.prototype.get_msg = function(msg_number,msg_folder,set_flag,call_back) { |
---|
| 22 | if(this.is_local_folder(msg_folder)) { |
---|
| 23 | if(set_flag) |
---|
| 24 | expresso_local_messages.set_messages_flag(msg_number,"seen"); |
---|
| 25 | var data = expresso_local_messages.get_local_mail(msg_number); |
---|
| 26 | eval("call_back(data)"); |
---|
| 27 | }else { |
---|
| 28 | cExecute("$this.imap_functions.get_info_msg&msg_number="+ msg_number + "&msg_folder=" + msg_folder, call_back); |
---|
| 29 | } |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | messages_proxy.prototype.delete_msgs = function(folder, msgs_number, border_ID) { |
---|
| 33 | |
---|
| 34 | if (folder == 'null') |
---|
| 35 | folder = get_current_folder(); |
---|
| 36 | if (msgs_number == 'selected') |
---|
| 37 | msgs_number = get_selected_messages(); |
---|
| 38 | |
---|
| 39 | if (!this.is_local_folder(folder)) |
---|
| 40 | delete_msgs(folder, msgs_number, border_ID); |
---|
| 41 | else |
---|
| 42 | expresso_local_messages.delete_msgs(msgs_number,border_ID); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | messages_proxy.prototype.link_anexo = function (info_msg,numero_ordem_anexo) { |
---|
| 46 | |
---|
| 47 | if(info_msg.local_message==true) { |
---|
| 48 | return "javascript:download_local_attachment('"+ |
---|
| 49 | expresso_local_messages.get_url_anexo(info_msg.msg_number,info_msg.attachments[numero_ordem_anexo].pid)+ |
---|
| 50 | "')"; |
---|
| 51 | } |
---|
| 52 | else { |
---|
[1005] | 53 | return "javascript:download_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"',"+numero_ordem_anexo+",'"+info_msg.attachments[numero_ordem_anexo].pid+"','"+info_msg.attachments[numero_ordem_anexo].encoding+"','"+info_msg.attachments[numero_ordem_anexo].name+"')"; |
---|
[670] | 54 | } |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | messages_proxy.prototype.proxy_source_msg = function (id_msg,folder) { |
---|
| 58 | if(!this.is_local_folder(folder)) { |
---|
| 59 | source_msg(id_msg,folder); |
---|
| 60 | } |
---|
| 61 | else { |
---|
| 62 | var num_msg = id_msg.substr(0,(id_msg.length - 2)); |
---|
| 63 | expresso_local_messages.get_source_msg(num_msg); |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | messages_proxy.prototype.proxy_set_messages_flag = function (flag,msg_number){ |
---|
| 68 | if(this.is_local_folder(get_current_folder())) { |
---|
| 69 | expresso_local_messages.set_messages_flag(msg_number,flag); |
---|
| 70 | } |
---|
| 71 | else { |
---|
| 72 | set_messages_flag(flag,msg_number); |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | messages_proxy.prototype.is_local_folder = function(folder) { |
---|
| 77 | if(folder.indexOf("local_")==-1) |
---|
| 78 | return false; |
---|
| 79 | return true; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | messages_proxy.prototype.proxy_rename_folder = function(){ |
---|
| 84 | |
---|
| 85 | if (ttree.FOLDER == 'local_Inbox') { |
---|
| 86 | alert(get_lang("It's not possible rename the folder: ") + lang_folder(ttree.FOLDER.substr(6))); |
---|
| 87 | return false; |
---|
| 88 | } |
---|
| 89 | if(ttree.FOLDER == 'local_root') { |
---|
| 90 | alert(get_lang("It's not possible rename this folder!")); |
---|
| 91 | return false; |
---|
| 92 | } |
---|
| 93 | if (this.is_local_folder(ttree.FOLDER)) { |
---|
| 94 | folder = prompt(get_lang("Enter a name for the box"), ""); |
---|
| 95 | if(trim(folder) == "" || trim(folder) == null){ |
---|
| 96 | alert(get_lang("you have to enter the name of the new folder")); |
---|
| 97 | return false; |
---|
| 98 | } |
---|
| 99 | var temp = expresso_local_messages.rename_folder(folder, ttree.FOLDER.substr(6)); |
---|
| 100 | if (!temp) |
---|
| 101 | alert(get_lang("cannot rename folder. try other folder name")); |
---|
| 102 | ttreeBox.update_folder(); |
---|
| 103 | } |
---|
| 104 | else { |
---|
| 105 | ttreeBox.validate("rename"); |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | messages_proxy.prototype.proxy_create_folder = function() { |
---|
| 111 | if (ttree.FOLDER == 'local_root') { |
---|
| 112 | |
---|
| 113 | folder = prompt(get_lang('Enter the name of the new folder:'), ""); |
---|
| 114 | |
---|
| 115 | if(trim(folder) == "" || trim(folder) == null){ |
---|
| 116 | alert(get_lang("you have to enter the name of the new folder")); |
---|
| 117 | return false; |
---|
| 118 | } |
---|
| 119 | var temp = expresso_local_messages.create_folder(folder); |
---|
| 120 | if (!temp) |
---|
| 121 | alert(get_lang("cannot create folder. try other folder name")); |
---|
| 122 | ttreeBox.update_folder(); |
---|
| 123 | } |
---|
| 124 | else |
---|
| 125 | if (!this.is_local_folder(ttree.FOLDER)) |
---|
| 126 | ttreeBox.validate("newpast"); |
---|
| 127 | |
---|
| 128 | else |
---|
| 129 | alert(get_lang("It's not possible create inside: ") + lang_folder(ttree.FOLDER.substr(6))); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | messages_proxy.prototype.proxy_remove_folder = function() { |
---|
| 133 | if (this.is_local_folder(ttree.FOLDER)) { |
---|
| 134 | if(ttree.FOLDER == 'local_root') { |
---|
| 135 | alert(get_lang("Select a folder!")); |
---|
| 136 | return false; |
---|
| 137 | } |
---|
| 138 | if (ttree.FOLDER == 'local_Inbox') { |
---|
| 139 | alert(get_lang("It's not possible delete the folder: ") + lang_folder(ttree.FOLDER.substr(6))); |
---|
| 140 | return false; |
---|
| 141 | } |
---|
| 142 | var string_confirm = get_lang("Do you wish to exclude the folder ") + ttree.FOLDER.substr(6) + "?"; |
---|
| 143 | |
---|
| 144 | if (confirm(string_confirm)) { |
---|
| 145 | expresso_local_messages.remove_folder(ttree.FOLDER.substr(6)); |
---|
| 146 | alert(get_lang("The folder %1 was successfully removed", ttree.FOLDER.substr(6))); |
---|
| 147 | ttreeBox.update_folder(); |
---|
| 148 | } |
---|
| 149 | } |
---|
| 150 | else |
---|
| 151 | ttreeBox.del(); |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | messages_proxy.prototype.proxy_move_messages = function (folder, msgs_number, border_ID, new_folder, new_folder_name) { |
---|
| 155 | if (! folder || folder == 'null') |
---|
| 156 | folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : get_current_folder(); |
---|
| 157 | |
---|
| 158 | if ((this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { //Move entre pastas não locais... |
---|
| 159 | if (folder == new_folder){ |
---|
| 160 | write_msg(get_lang('The origin folder and the destination folder are the same.')); |
---|
| 161 | return; |
---|
| 162 | } |
---|
| 163 | if(msgs_number=='selected') |
---|
| 164 | msgs_number = get_selected_messages(); |
---|
| 165 | if (new_folder == 'local_root') |
---|
| 166 | alert(get_lang("Select a folder!")); |
---|
| 167 | if (parseInt(msgs_number) > 0 || msgs_number.length > 0) { |
---|
| 168 | expresso_local_messages.move_messages(new_folder.substr(6), msgs_number); |
---|
| 169 | this.aux_interface_remove_mails(msgs_number, new_folder_name, border_ID); |
---|
| 170 | } |
---|
| 171 | else |
---|
| 172 | write_msg(get_lang('No selected message.')); |
---|
| 173 | } |
---|
| 174 | else |
---|
| 175 | if ((!this.is_local_folder(folder)) && (!this.is_local_folder(new_folder))) { //Move entre pastas locais... |
---|
| 176 | move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name); |
---|
| 177 | } |
---|
| 178 | else if ((!this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { |
---|
| 179 | if(msgs_number=='selected') |
---|
| 180 | archive_msgs(folder,new_folder); |
---|
| 181 | else |
---|
| 182 | archive_msgs(folder,new_folder,msgs_number); |
---|
| 183 | } |
---|
| 184 | else { |
---|
[1000] | 185 | //Por Bruno Costa (bruno.vieira-costa@serpro.gov.br) permite o desarquivamento de menssagens chamando a função unarchive_msgs quando uma msg é movida de uma pasta local para uma pasta remota. |
---|
| 186 | |
---|
| 187 | expresso_local_messages.unarchive_msgs(folder,new_folder,msgs_number); |
---|
| 188 | //write_msg(get_lang("you can't move mails from local to server folders")); |
---|
[670] | 189 | } |
---|
| 190 | |
---|
| 191 | |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | messages_proxy.prototype.proxy_move_search_messages = function(border_id, new_folder, new_folder_name) { |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | /* |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | if ((this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { //Move entre pastas não locais... |
---|
| 201 | if (folder == new_folder){ |
---|
| 202 | write_msg(get_lang('The origin folder and the destination folder are the same.')); |
---|
| 203 | return; |
---|
| 204 | } |
---|
| 205 | if(msgs_number=='selected') |
---|
| 206 | msgs_number = get_selected_messages(); |
---|
| 207 | if (new_folder == 'local_root') |
---|
| 208 | alert(get_lang("Select a folder!")); |
---|
| 209 | if (parseInt(msgs_number) > 0 || msgs_number.length > 0) { |
---|
| 210 | expresso_local_messages.move_messages(new_folder.substr(6), msgs_number); |
---|
| 211 | this.aux_interface_remove_mails(msgs_number, new_folder_name, border_ID); |
---|
| 212 | } |
---|
| 213 | else |
---|
| 214 | write_msg(get_lang('No selected message.')); |
---|
| 215 | } |
---|
| 216 | else |
---|
| 217 | if ((!this.is_local_folder(folder)) && (!this.is_local_folder(new_folder))) { //Move entre pastas locais... |
---|
| 218 | move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name); |
---|
| 219 | } |
---|
| 220 | else if ((!this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { |
---|
| 221 | archive_msgs(folder,new_folder); |
---|
| 222 | } |
---|
| 223 | else { |
---|
| 224 | write_msg(get_lang("you can't move mails from local to server folders")); |
---|
| 225 | }*/ |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | messages_proxy.prototype.aux_interface_remove_mails = function(msgs_number,new_folder_name,border_ID,previous_msg) { |
---|
| 229 | Element('chk_box_select_all_messages').checked = false; |
---|
| 230 | mail_msg = Element("tbody_box"); |
---|
| 231 | msgs_number = msgs_number.split(","); |
---|
| 232 | var msg_to_delete; |
---|
| 233 | for (var i=0; i<msgs_number.length; i++){ |
---|
| 234 | msg_to_delete = Element(msgs_number[i]); |
---|
| 235 | if (msg_to_delete){ |
---|
| 236 | if ( (msg_to_delete.style.backgroundColor != '') && (preferences.use_shortcuts == '1') ) |
---|
| 237 | select_msg('null', 'down'); |
---|
| 238 | mail_msg.removeChild(msg_to_delete); |
---|
| 239 | } |
---|
| 240 | } |
---|
| 241 | if (msgs_number.length == 1) |
---|
| 242 | write_msg(get_lang("The message was moved to folder ") + new_folder_name); |
---|
| 243 | else |
---|
| 244 | write_msg(get_lang("The messages were moved to folder ") + new_folder_name); |
---|
| 245 | |
---|
| 246 | if (border_ID != '' && border_ID != 'null'){ |
---|
| 247 | delete_border(border_ID,'false'); |
---|
| 248 | } |
---|
| 249 | if(folder == get_current_folder()) |
---|
| 250 | Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - msgs_number.length; |
---|
| 251 | refresh(); |
---|
| 252 | |
---|
| 253 | } |
---|
| 254 | |
---|
[1000] | 255 | messages_proxy.prototype.msg_img = function(msgs_number,folder_name,call_back) { |
---|
| 256 | if(this.is_local_folder(folder_name)){ |
---|
| 257 | var msg = expresso_local_messages.get_local_mail(msgs_number); |
---|
| 258 | eval('call_back(msg)'); |
---|
| 259 | } |
---|
| 260 | else |
---|
| 261 | cExecute('$this.imap_functions.get_info_msg&msg_number='+msgs_number+'&msg_folder='+folder_name,call_back); |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | messages_proxy.prototype.export_all_messages = function(folder){ |
---|
| 265 | |
---|
| 266 | if (!folder){ |
---|
| 267 | folder = get_current_folder(); |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | if(!this.is_local_folder(folder)){ |
---|
| 271 | export_all_selected_msgs(); |
---|
| 272 | }else{ |
---|
| 273 | local_messages.prototype.local_messages_to_export(); |
---|
| 274 | } |
---|
| 275 | } |
---|
| 276 | |
---|
| 277 | messages_proxy.prototype.proxy_export_all_msg=function(){ |
---|
| 278 | |
---|
| 279 | var er=/^local/; |
---|
| 280 | |
---|
| 281 | |
---|
| 282 | if(ttree.FOLDER == "local_root"){return false;} //Usuario não selecionou uma pasta local e esta no começo dos nós |
---|
| 283 | var nm_bx = ttree.FOLDER.split(cyrus_delimiter); |
---|
| 284 | |
---|
| 285 | var name_f = nm_bx[nm_bx.length -1].replace("local_",""); |
---|
| 286 | |
---|
| 287 | if (!er.test(nm_bx)){ |
---|
| 288 | //Se a pasta nao for local, ou seja a string nao contem a string "local" |
---|
| 289 | ttreeBox.export_all_msg(); |
---|
| 290 | } else{ |
---|
| 291 | expresso_local_messages.get_all_local_folder_messages(name_f); |
---|
| 292 | } |
---|
| 293 | } |
---|
| 294 | |
---|
[670] | 295 | var proxy_mensagens; |
---|
| 296 | proxy_mensagens = new messages_proxy(); |
---|