Changeset 1595
- Timestamp:
- 11/05/09 16:22:24 (14 years ago)
- Location:
- trunk/expressoMail1_2
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.exporteml.inc.php
r1558 r1595 277 277 $body = $this-> getBody($id_msg); 278 278 279 $file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".php"; 279 $tempSubDir = md5($_SESSION[ 'phpgw_session' ][ 'session_id' ].microtime()); 280 $file = "source_".$tempSubDir.".php"; 281 //$file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".php"; 280 282 $f = fopen($tempDir.'/'.$file,"w"); 281 283 fputs($f,$phpheader.$header ."\r\n\r\n". $body); -
trunk/expressoMail1_2/js/common_functions.js
r1526 r1595 73 73 74 74 function unloadMess(){ 75 if (expresso_mail_sync. folders.length != 0) {75 if (expresso_mail_sync.working) { 76 76 var mess = get_lang("You're about archiving your e-mails from server. Do you really want to stop this action?"); 77 77 return mess; -
trunk/expressoMail1_2/js/draw_api.js
r1564 r1595 1279 1279 var option_reply_without_history = '<span onmouseover="this.className=\'message_options_active\'" onmouseout="this.className=\'message_options\'" class="message_options" onclick=new_message("reply_without_history","'+ID+'");>'+get_lang("Reply without history")+'</span> | '; 1280 1280 var option_reply_to_all_without_history = '<span onmouseover="this.className=\'message_options_active\'" onmouseout="this.className=\'message_options\'" class="message_options" onclick=new_message("reply_to_all_without_history","'+ID+'");>'+get_lang("Reply to all without history")+'</span> |'; 1281 var option_source_msg = '<span class="message_options" onclick= source_msg("'+ID+'","'+url_encode(info_msg.msg_folder)+'");>'+get_lang("Message Font")+'</span> </div>';1281 var option_source_msg = '<span class="message_options" onclick=proxy_mensagens.proxy_source_msg("'+ID+'","'+url_encode(info_msg.msg_folder)+'");>'+get_lang("Message Font")+'</span> </div>'; 1282 1282 1283 1283 div_other_options.innerHTML = option_reply_to_all + option_reply_without_history + option_reply_to_all_without_history + option_source_msg; -
trunk/expressoMail1_2/js/local_messages.js
r1518 r1595 33 33 34 34 var db_in_other_use = true; 35 var start_trying = new Date().getTime(); 35 36 while (db_in_other_use) { 36 37 try { … … 39 40 } 40 41 catch (ex) { 41 db_in_other_use=true; 42 if(new Date.getTime()-start_trying>10000) { //too much time trying, throw an exception 43 throw ex; 44 } 42 45 } 43 46 } … … 934 937 } 935 938 936 local_messages.prototype.get_folders_to_sync = function() { 939 local_messages.prototype.get_folders_to_sync = function() {//Precisa ter visibilidade ao array de linguagens. 937 940 this.init_local_messages(); 938 941 var rs = this.dbGears.execute("select id_folder,folder_name from folders_sync where uid_usuario="+account_id); … … 941 944 temp = new Array(); 942 945 temp[0] = rs.field(0); 943 temp[1] = rs.field(1); 946 if(temp[0]=='INBOX/Drafts' ||temp[0]=='INBOX/Trash' || temp[0]=='INBOX/Sent') { 947 temp[1] = array_lang[rs.field(1).toLowerCase()]; 948 } 949 else { 950 temp[1] = rs.field(1); 951 } 952 944 953 retorno.push(temp); 945 954 rs.next(); -
trunk/expressoMail1_2/js/mail_sync.js
r1518 r1595 2 2 * @author diogenes 3 3 */ 4 5 /** 6 * @param folders: 7 * 1 - rowid of folder in sqlite 8 * 2 - folder name in sqlite 9 * 3 - ids to not download(for auto archiving) or ids to download(for archiving) 10 * 4 - true for auto archiving and false for normal archiving. 11 */ 4 12 function mail_sync() { 5 this.dbGears = null;6 this.localServer = null;7 this.store = null;13 // this.dbGears = null; 14 // this.localServer = null; 15 // this.store = null; 8 16 this.folders = new Array(); 9 17 this.messages = null; 10 18 this.attachs = null; 11 19 this.url_attachs = null; 20 this.working = false; 21 this.is_auto = null; 22 this.errors = new Array(); 23 // this.main_title = null; 24 12 25 this.main_title = null; 26 this.dbGears = google.gears.factory.create('beta.database'); 27 this.localServer = google.gears.factory.create('beta.localserver'); 28 this.store = this.localServer.createStore('test-store'); 13 29 } 14 30 15 31 mail_sync.prototype.open_conn = function(){ 16 32 var db_in_other_use = true; 33 var start_trying = new Date().getTime(); 17 34 while (db_in_other_use) { 18 35 try { … … 21 38 } 22 39 catch (ex) { 23 db_in_other_use=true; 40 if(new Date.getTime()-start_trying>10000) { //too much time trying, throw an exception 41 throw ex; 42 } 24 43 } 25 44 } … … 27 46 28 47 mail_sync.prototype.start_sync = function() { 29 if(this. folders.length!=0) {48 if(this.working) { 30 49 //Já está sincronizando... 31 50 return; 32 51 } 33 this.main_title = document.getElementById('main_title').innerHTML;34 this.dbGears = google.gears.factory.create('beta.database');52 //this.main_title = document.getElementById('main_title').innerHTML; 53 /*this.dbGears = google.gears.factory.create('beta.database'); 35 54 this.localServer = google.gears.factory.create('beta.localserver'); 36 this.store = this.localServer.createStore('test-store'); 55 this.store = this.localServer.createStore('test-store'); */ 56 this.working=true; 37 57 this.messages = null; 38 58 this.attachs = null; … … 48 68 temp[1] = rs.field(1); 49 69 temp[2] = null; 70 temp[3] = false; 50 71 var rs2 = this.dbGears.execute("select mail.original_id from mail inner join folder on mail.id_folder=folder.rowid where folder.folder = ? and mail.uid_usuario=?",[temp[1]==get_lang('Inbox')?'Inbox':temp[1],account_id]); 51 72 while(rs2.isValidRow()) { … … 85 106 } 86 107 108 mail_sync.prototype.archive_msgs = function(folder,folder_dest,ids) { 109 //this.main_title = document.getElementById('main_title').innerHTML; 110 var temp = new Array(); 111 temp[0] = folder; 112 temp[1] = folder_dest.substr(6); 113 temp[2] = ids; 114 temp[3] = true; 115 this.folders.push(temp); 116 Element('chk_box_select_all_messages').checked = false; 117 118 array_ids = ids.split(","); 119 for (var i in array_ids) { 120 if (Element("check_box_message_" + array_ids[i])) 121 Element("check_box_message_" + array_ids[i]).checked = false; 122 remove_className(Element(array_ids[i]), 'selected_msg'); 123 } 124 if(!this.working) { 125 this.working=true; 126 this.syncronize_folders(); 127 } 128 else { 129 write_msg(get_lang("An archiving is in process, but dont worry, expresso will process this messages after the actual archiving")); 130 } 131 } 132 87 133 mail_sync.prototype.syncronize_folders = function() { 88 134 if (this.folders.length == 0) { 89 135 document.getElementById('main_title').innerHTML = get_lang("Deleting downloadeds msgs..."); 90 136 expresso_mail_sync.remove_archived_mails(); 137 this.working=false; 138 update_menu(); 91 139 return; 92 140 } 93 141 var folder_to_sync = this.folders.pop(); 94 folder_to_sync[1] = folder_to_sync[0].toUpperCase()=="INBOX"?"Inbox":folder_to_sync[1]; 142 folder_to_sync[1] = folder_to_sync[0].toUpperCase()=="INBOX" && !folder_to_sync[3]?"Inbox":folder_to_sync[1]; 143 144 if(folder_to_sync[3]) { //Em caso de arquivamento normal, pode ser que a pasta inbox ainda não tenha sido criada. 145 expresso_mail_sync.open_conn() 146 if(!expresso_mail_sync.has_local_mails()) { 147 expresso_mail_sync.dbGears.execute("insert into folder (folder,uid_usuario) values (?,?)",["Inbox",account_id]); 148 } 149 expresso_mail_sync.dbGears.close(); 150 ttreeBox.update_folder(); 151 152 } 95 153 96 154 var start_sync_mails = function(data) { 97 155 expresso_mail_sync.messages=data; 98 document.getElementById('main_title').innerHTML = get_lang("Auto archiving")+" "+lang_folder(folder_to_sync[1])+": 0 / "+data.length; 156 if(expresso_mail_sync.is_auto) 157 document.getElementById('main_title').innerHTML = get_lang("Auto archiving")+" "+lang_folder(folder_to_sync[1])+": 0 / "+data.length; 158 else 159 document.getElementById('main_title').innerHTML = get_lang("Archiving messages on folder")+" "+lang_folder(folder_to_sync[1])+": 0 / "+data.length; 99 160 100 161 expresso_mail_sync.syncronize_mails(folder_to_sync[1]); 101 162 } 102 document.getElementById('main_title').innerHTML = get_lang("Starting to sync folder ")+lang_folder(folder_to_sync[1]); 103 cExecute("$this.imap_functions.msgs_to_archive&folder=" + folder_to_sync[0]+"&mails="+folder_to_sync[2] , start_sync_mails); 163 164 165 if (folder_to_sync[3]) { 166 document.getElementById('main_title').innerHTML = get_lang("Starting to archive messages"); 167 cExecute("$this.imap_functions.get_info_msgs&folder=" + folder_to_sync[0] + "&msgs_number=" + folder_to_sync[2], start_sync_mails); 168 this.is_auto = false; 169 } 170 else { 171 document.getElementById('main_title').innerHTML = get_lang("Starting to sync folder")+" "+lang_folder(folder_to_sync[1]); 172 cExecute("$this.imap_functions.msgs_to_archive&folder=" + folder_to_sync[0] + "&mails=" + folder_to_sync[2], start_sync_mails); 173 this.is_auto = true; 174 } 175 104 176 } 105 177 … … 118 190 new_value = parseInt(new_value) + 1; 119 191 document.getElementById('main_title').innerHTML = document.getElementById('main_title').innerHTML.replace(value_to_change,new_value+" /"); 120 121 192 msg_to_sync = connector.unserialize(msg_to_sync); 193 122 194 var source_msg = new Array(); 123 195 source_msg['url'] = msg_to_sync.url_export_file; 124 196 125 197 if (typeof(msg_to_sync['array_attach'])=='object'&&(msg_to_sync['array_attach'] instanceof Array)) 126 198 expresso_mail_sync.attachs = msg_to_sync['array_attach'].slice(); … … 134 206 if (expresso_mail_sync.attachs == null || expresso_mail_sync.attachs.length == 0) { 135 207 expresso_mail_sync.insert_mail(msg, folder_dest); 208 136 209 return; 137 210 } … … 140 213 141 214 var call_back = function(url,success,captureId) { 142 //TODO: Tratar se houver erro ao baixar anexo... 143 expresso_mail_sync.download_attachs(msg,folder_dest); 215 216 if (!success) { 217 /* 218 * 0 - original id 219 * 1 - message subject 220 * 2 - original folder 221 */ 222 var mail_error = new Array(); 223 mail_error[0] = msg.msg_number; 224 mail_error[1] = msg.subject; 225 mail_error[2] = msg.msg_folder; 226 expresso_mail_sync.errors.push(mail_error); 227 alert('erro ao baixar: '+url); 228 229 /*if (typeof(msg['array_attach']) == 'object' && (msg['array_attach'] instanceof Array)) { 230 for (var i in msg['array_attach']) { //remove os anexos que já foram baixados para essa mensagem... 231 expresso_mail_sync.store.remove(msg['array_attach'][i]['url']); 232 } 233 }*/ 234 expresso_mail_sync.syncronize_mails(folder_dest); //Pula para o próximo e-mail. 235 } 236 else { 237 expresso_mail_sync.download_attachs(msg, folder_dest);//continua baixando o próximo anexo 238 } 144 239 } 145 240 expresso_mail_sync.store.capture(attach_to_capt['url'],call_back); … … 147 242 148 243 mail_sync.prototype.insert_mail = function(msg,folder) { 149 150 244 try { 151 // document.getElementById('div_menu_c3').innerHTML = document.getElementById('div_menu_c3').innerHTML.replace(/(\d+) de/,(((int)"$1")+1)+" de"); 152 // document.getElementById('div_menu_c3').innerHTML += expresso_mail_sync.messages.length + "restantes"; 153 245 154 246 expresso_mail_sync.open_conn(); 155 247 156 248 var msg_info = msg; 157 249 var msg_header = msg['header']; … … 162 254 var login = msg_info.login; 163 255 var original_id = msg_info.msg_number; 164 var original_folder = msg_info.msg_folder ;165 256 var original_folder = msg_info.msg_folder=='INBOX/Lixeira/tmpMoveToLocal'?msg_info.msg_folder+(Date.parse(new Date)):msg_info.msg_folder; 257 166 258 //Os campos abaixo precisam estar isolados para busca de mensagens em cima deles. 167 259 var from = connector.serialize(msg_info.from); … … 182 274 //A data no header pode vir como horário ao invés de data, caso o usuário tenha arquivado no mesmo 183 275 //dia que recebeu a msg. Para esses casos, usar a data aux que vem com o dia. 184 if(msg_header.udate.indexOf(" :")!=-1) {276 if(msg_header.udate.indexOf("/")==-1) { 185 277 msg_header.udate = msg_header.aux_date; 186 278 } 279 187 280 188 281 /** … … 203 296 id_folder = rs.field(0); 204 297 205 206 298 if(msg_info.Unseen=="U") 207 299 unseen = 1; 208 300 this.dbGears.execute("insert into mail (mail,original_id,original_folder,header,timestamp,uid_usuario,unseen,id_folder,ffrom,subject,fto,cc,body,size) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)",[mail,original_id,original_folder,header,timestamp,login,unseen,id_folder,from,subject,to,cc,body,size]); 209 301 302 303 210 304 //Preenche os anexos. 211 305 var id_mail = this.dbGears.lastInsertRowId; … … 215 309 } 216 310 217 if(preferences.keep_after_auto_archiving!=1) 311 var check_remove; 312 if(this.is_auto) 313 check_remove = preferences.keep_after_auto_archiving; 314 else 315 check_remove = preferences.keep_archived_messages; 316 317 318 319 if(check_remove!=1) 218 320 this.dbGears.execute("insert into msgs_to_remove (id_msg,folder,uid_usuario) values (?,?,?)",[original_id,original_folder,account_id]); 219 220 321 221 322 } catch (error) { 222 //TODO: O que fazer se der erro ao baixar um email? 323 /* 324 * 0 - original id 325 * 1 - message subject 326 * 2 - original folder 327 */ 328 var mail_error = new Array(); 329 mail_error[0] = original_id; 330 mail_error[1] = subject; 331 mail_error[2] = original_folder; 332 this.errors.push(mail_error); 333 334 if (typeof(msg_info['array_attach'])=='object'&&(msg_info['array_attach'] instanceof Array)) { 335 for(var i in msg_info['array_attach']) { //remove os anexos que já foram baixados para essa mensagem... 336 this.store.remove(msg_info['array_attach'][i]['url']); 337 } 338 } 339 223 340 } 224 341 this.dbGears.close(); 225 342 this.syncronize_mails(folder); 343 } 344 345 mail_sync.prototype.has_local_mails = function() {//This function considers that the connection with base is already opened. 346 var rs = this.dbGears.execute("select rowid from folder limit 0,1"); 347 if(rs.isValidRow()) 348 return true; 349 else 350 return false; 226 351 } 227 352 … … 257 382 Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length; 258 383 } 384 ttreeBox.update_folder(); 259 385 refresh(); 260 386 expresso_mail_sync.remove_archived_mails(); … … 268 394 else { 269 395 this.dbGears.close(); 270 document.getElementById('main_title').innerHTML = get_lang("End of auto download messages"); 271 window.setTimeout("eval('document.getElementById(\"main_title\").innerHTML =expresso_mail_sync.main_title')",3000); 396 document.getElementById('main_title').innerHTML = get_lang("End of archive messages"); 397 if(this.errors.length>0) { 398 //TODO: Tratar melhor quando existirem erros... 399 write_msg(get_lang("at least, one of selected mails is already archived, expresso tried to archive the others, check them later")); 400 this.errors=new Array(); 401 } 402 window.setTimeout("eval('document.getElementById(\"main_title\").innerHTML =\"Expresso Mail\"')",3000); 272 403 } 273 404 -
trunk/expressoMail1_2/js/main.js
r1531 r1595 767 767 return; 768 768 } 769 var has_local_messages_before = expresso_local_messages.has_local_mails(); //vejo se já tinha mensagens locais 769 770 if(!id_msgs) 771 id_msgs = get_selected_messages(); 772 773 if(folder_dest=='local_root' || folder_dest==null) //Caso seja o primeiro arquivamento... 774 folder_dest = 'local_Inbox'; 775 776 if (parseInt(id_msgs) > 0 || id_msgs.length > 0) 777 expresso_mail_sync.archive_msgs(folder,folder_dest,id_msgs); 778 //cExecute("$this.imap_functions.get_info_msgs&folder=" + folder + "&msgs_number=" + id_msgs , handler_arquivar_mensagens); 779 else 780 write_msg(get_lang('No selected message.')); 781 /*var has_local_messages_before = expresso_local_messages.has_local_mails(); //vejo se já tinha mensagens locais 770 782 var handler_arquivar_mensagens = function(data) { 771 783 var sucess = true; … … 819 831 cExecute("$this.imap_functions.get_info_msgs&folder=" + folder + "&msgs_number=" + id_msgs , handler_arquivar_mensagens); 820 832 else 821 write_msg(get_lang('No selected message.')); 833 write_msg(get_lang('No selected message.'));*/ 822 834 823 835 } -
trunk/expressoMail1_2/programed_archiving.php
r1518 r1595 9 9 ); 10 10 11 11 12 12 require_once('../header.inc.php'); 13 13 … … 89 89 } 90 90 $GLOBALS['phpgw']->template->set_var('all_folders',$options); 91 92 91 echo '<script language="javascript">var array_lang = new Array();</script>'; 92 include("inc/load_lang.php"); 93 93 94 94 $GLOBALS['phpgw']->template->set_var('lang_Would_you_like_to_keep_messages_on_server_?',lang("Would you like to keep archived messages?"));
Note: See TracChangeset
for help on using the changeset viewer.