// Tempo do auto refresh (em milisegundos)
var time_refresh = 300000;
// tempo do auto save (em milisegundos)
// 20000 = 20 segundos
var autosave_time = 40000;
var results_search_messages = "";
var cabecalho = '
ExpressoLivre - ExpressoMail
';
//Os IE's < 9 não possui suporte a trim() introduzida no JavaScript 1.8.1
if(!String.prototype.trim){
String.prototype.trim = function(){
return this.replace(/^\s+|\s+$/g,'');
}
}
function mount_url_folder(folders){
return folders.join(cyrus_delimiter);
}
function init(){
if (!is_ie)
Element('tableDivAppbox').width = '100%';
var save_contacts = function(data){
contacts = data;
if (preferences.use_local_messages == 1 && window.google && google.gears)
if (expresso_local_messages.is_offline_installed())
expresso_local_messages.capt_url('controller.php?action=$this.db_functions.get_dropdown_contacts_to_cache');
}
var save_preferences = function(data){
preferences = data;
if(preferences.show_name_print_messages == "1") {
var getUserName = document.getElementById("user_info");
var userName = getUserName.innerHTML;
var position = userName.indexOf("-");
var userName = userName.substring(3, position);
cabecalho = '
' + userName;
}
current_folder="INBOX";
if( (window.google && google.gears) && !google.gears.factory.getPermission())
preferences.use_local_messages=0;
if ((preferences.use_local_messages==1) && (!window.google || !google.gears)) {
temp = confirm(get_lang("To use local messages you have to install google gears. Would you like to be redirected to gears installation page?"));
if (temp) {
location.href = "http://gears.google.com/?action=install&message="+
"Para utilizar o recurso de mensagens locais, instale o google gears&return=" + document.location.href;
}
else {
preferences.use_local_messages=0;
}
}
if (preferences.use_local_messages==1) { //O I.E 7 estava se atrapalhando caso esses loads fossem feitos após as chamadas ajax. Antes não apresentou problemas...
connector.loadScript('mail_sync');
if (is_ie)
connector.loadScript('TreeShow');
setTimeout('auto_archiving()', 30000);
}
//Substituido por padrão Jquery
cExecute ("$this.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1", handler_draw_box);
cExecute ("$this.db_functions.get_dropdown_contacts", save_contacts); //Save contacts needs preferences.
if(preferences.hide_folders == "1")
Element('divAppboxHeader').innerHTML = title_app_menu;
if (preferences.delete_trash_messages_after_n_days != 0)
cExecute ("$this.imap_functions.automatic_trash_cleanness&before_date="+preferences.delete_trash_messages_after_n_days+"&cyrus_delimiter="+cyrus_delimiter, handler_automatic_trash_cleanness);
//if(preferences.outoffice == "1")
//
//Troca da forma de construção de menu para o plugin jquery.contextMenu
//ConstructMenuTools();
if ( (preferences.use_local_messages==1) && (expresso_local_messages.is_offline_installed()) ) //Precisa ser feito após a renderização da caixa de emails
check_mail_in_queue();
// Insere a applet de criptografia
if (preferences.use_signature_digital_cripto == '1'){
loadApplet();
}
// Fim da inserção da applet
DataLayer.get("folder", true);
cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu);
if($.cookie('collapse_folders') == "true"){
if(!is_ie)
$("#folderscol").addClass( "hidden");
else
$("#folderscol").hide();
$(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-e").children().attr('title', "Expandir");
refresh();
resizeWindow();
}
else{
$(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-w").children().attr('title', "Ocultar");
refresh();
resizeWindow();
}
$(".collapse_folders_td").attr('title', "Ocultar/Expandir").click(function(){
if($("#folderscol").css("display") != "none"){
if(!is_ie)
$("#folderscol").addClass( "hidden");
else
$("#folderscol").hide();
$(".collapse_folders").removeClass("ui-icon-triangle-1-w");
$(".collapse_folders").addClass("ui-icon-triangle-1-e").attr('title', "Expandir");
$.cookie('collapse_folders', "true");
refresh();
resizeWindow();
}else{
if(!is_ie)
$("#folderscol").removeClass( "hidden");
else
$("#folderscol").show();
$(".collapse_folders").removeClass("ui-icon-triangle-1-e");
$(".collapse_folders").addClass("ui-icon-triangle-1-w").attr('title', "Ocultar");
$.cookie('collapse_folders', "false");
refresh();
resizeWindow();
}
resizeWindow();
}).hover(
function(){
$(this).addClass("collapse_folders_td_over");
},
function(){
$(this).removeClass("collapse_folders_td_over");
}
);
}
var handler_automatic_trash_cleanness = function(data){
if (data != false){
write_msg(data.length +' '+ Element('txt_clear_trash').value);
}
}
// Versão
Element('divAppboxHeader').innerHTML = title_app;
// Get cyrus delimiter
cyrus_delimiter = Element('cyrus_delimiter').value;
cExecute ("$this.functions.get_preferences", save_preferences);
cExecute ("phpgwapi.browser.isMobile", function( data ){
mobile_device = ( ( data.constructor == Boolean ) ? data : ( data === 'true' ) );
});
setTimeout('auto_refresh()', time_refresh);
$("#divAppbox").css("padding-left", "0px");
}
function init_offline(){
current_folder = 'local_Inbox';
if (account_id != null) {
if (!is_ie)
Element('tableDivAppbox').width = '100%';
else
connector.createXMLHTTP();
Element('divStatusBar').innerHTML = '
' +
'
' +
'
' +
'
' +
'ExpressoMail Offline - Versão 1.0
' +
'
' +
'
';
//Troca da forma de construção de menu para o plugin jquery.contextMenu
//ConstructMenuTools();
draw_tree_folders();
proxy_mensagens.messages_list('local_Inbox', 1, preferences.max_email_per_page, 'SORTARRIVAL', null, 1,1,1, function handler(data){
draw_box(data, 'local_Inbox');
})
// Get cyrus delimiter
cyrus_delimiter = Element('cyrus_delimiter').value;
cExecute ("$this.db_functions.get_dropdown_contacts_to_cache", function(data) {contacts = data;});
//cExecute ("$this.functions.get_preferences", save_preferences);
}
}
/**
* Carrega a applet java no objeto search_div
* @author Mário César Kolling
*/
function loadApplet(){
var search_div = Element('search_div');
var applet = null;
if (navigator.userAgent.match('MSIE')){
applet = document.createElement('');
var parameters = {
type:'application/x-java-applet;version=1.5',
code:'ExpressoSmimeApplet',
codebase:'/security/',
mayscript:'true',
token: token_param,
locale: locale,
archive:'ExpressoCertMail.jar,' +
'ExpressoCert.jar,' +
'bcmail-jdk15-142.jar,' +
'mail.jar,' +
'activation.jar,' +
'bcprov-jdk15-142.jar,' +
'commons-codec-1.3.jar,' +
'commons-httpclient-3.1.jar,' +
'commons-logging-1.1.1.jar'
//debug:'true'
}
if (parameters != 'undefined' && parameters != null){
for (var parameter in parameters) {
var param = document.createElement("PARAM");
param.setAttribute("name",parameter);
param.setAttribute("value",parameters[parameter]);
applet.appendChild(param);
}
}
}
else
{
applet = document.createElement('embed');
applet.innerHTML = ' ';
}
if( applet != null )
{
applet.style.top = "-100px";
applet.style.left = "-100px";
window.document.body.insertBefore( applet, document.body.lastChild );
}
}
function disable_field(field,condition) {
var comando = "if ("+condition+") { document.getElementById('"+field.id+"').disabled=true;} else { document.getElementById('"+field.id+"').disabled=false; }";
eval(comando);
}
/*
função que remove todos os anexos...
*/
function remove_all_attachments(folder,msg_num) {
var call_back = function(data) {
if(!data.status) {
alert(data.msg);
}
else {
msg_to_delete = Element(msg_num);
change_tr_properties(msg_to_delete, data.msg_no);
msg_to_delete.childNodes[1].innerHTML = "";
write_msg(get_lang("Attachments removed"));
delete_border(msg_num+'_r','false'); //close email tab
}
};
if (confirm(get_lang("delete all attachments confirmation")))
cExecute ("$this.imap_functions.remove_attachments&folder="
+folder+"&msg_num="+msg_num, call_back);
}
function watch_changes_in_msg(border_id)
{
if (document.getElementById('border_id_'+border_id))
{
function keypress_handler ()
{
away=false;
var save_link = content.find(".save");
save_link.onclick = function onclick(event) {openTab.toPreserve[border_id] = true;save_msg(border_id);} ;
save_link.button({disabled: false});
$(".header-button").button();
};
var content = $("#content_id_"+border_id);
var subject_obj = content.find(".subject");
if ( subject_obj.addEventListener )
subject_obj.addEventListener('keypress', keypress_handler, false);
else if ( subject_obj.attachEvent )
subject_obj.attachEvent('onkeypress', keypress_handler);
var to_obj = content.find('[name="input_to"]');
if ( to_obj.addEventListener )
to_obj.addEventListener('keypress', keypress_handler, false);
else if ( to_obj.attachEvent )
to_obj.attachEvent('onkeypress', keypress_handler);
var cc_obj = content.find('[name="input_cc"]');
if ( cc_obj.addEventListener )
cc_obj.addEventListener('keypress', keypress_handler, false);
else if ( cc_obj.attachEvent )
cc_obj.attachEvent('onkeypress', keypress_handler);
if(content.find('[name="input_cco"]').length){
var cco_obj = content.find('[name="input_cco"]');
if ( cco_obj.addEventListener )
cco_obj.addEventListener('keypress', keypress_handler, false);
else if ( cco_obj.attachEvent )
cco_obj.attachEvent('onkeypress', keypress_handler);
}
//var important_obj = $("important_message_options_"+border_id).bind('click',keypress_handler);
//important_obj.addEventListener('click', keypress_handler, false);
var txtarea_obj = Element('body_'+border_id);
if (txtarea_obj){
if ((preferences.plain_text_editor == 1)||(Element('body_')+border_id).checked){
if ( txtarea_obj.addEventListener )
txtarea_obj.addEventListener('keypress', keypress_handler, false);
else if ( txtarea_obj.attachEvent )
txtarea_obj.attachEvent('onkeypress', keypress_handler);
}
}
}
}
function show_msg_img(msg_number,folder){
var call_back = function(data){
data.showImg = true;
if (!Element(data.msg_number)){
trElement = document.createElement('DIV');
trElement.id = data.msg_number;
Element("tbody_box").appendChild(trElement);
}
show_msg(data);
}
proxy_mensagens.msg_img(msg_number,folder,call_back);
}
function show_msg(msg_info){
if(!verify_session(msg_info))
return;
if (typeof(msg_info) != 'object')
alert(get_lang("Error in show_msg param is not object"));
if (msg_info.status_get_msg_info == 'false')
{
write_msg(get_lang("Problems reading your message")+ ".");
return;
}
var handler_sendNotification = function(data){
if (data)
write_msg(get_lang("A read confirmation was sent."));
else
write_msg(get_lang("Error in SMTP sending read confirmation."));
}
if(msg_info.source)
{
// Abrindo um e-mail criptografado
// Verifica se existe o objeto applet
if (!Element('cert_applet')){
// se não existir, mostra mensagem de erro.
write_msg(get_lang('The preference "%1" isn\'t enabled.', get_lang('Enable digitally sign/cipher the message?')));
} else {
// se existir prepara os dados para serem enviados e chama a
// operação na applet
connector.showProgressBar();
// if ((msg_info.DispositionNotificationTo) && ((msg_info.Unseen == 'U') || (msg_info.Recent == 'N'))){
/* var confNotification = confirm(get_lang("The sender waits your notification of reading. Do you want to confirm this?"), "");
if (confNotification)*/
// cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&subject="+url_encode(msg_info.subject), handler_sendNotification);
// }
Element('cert_applet').doButtonClickAction('decript',
msg_info.msg_number,
msg_info.source,
msg_info.msg_folder); // Passa os dados para a applet
}
return;
}
if (msg_info.status_get_msg_info == 'false')
{
write_msg(get_lang("Problems reading your message")+ ".");
return;
}
if (msg_info.status == 'false'){
eval(msg_info.command_to_exec);
}
else{
var ID = msg_info.original_ID ? msg_info.original_ID : msg_info.msg_number;
var folderName = msg_info.msg_folder;
folderName = folderName.replace(" ", "_");
var id_msg_read = ID+"_r_"+folderName;
//var id_msg_read = ID+"_r";
//Evita a tentativa de criação de uma aba cujo ID já existe
if (Element("border_id_"+id_msg_read) && currentTab > 0)
id_msg_read += "n";
//Quando for na página search, não atribui o seletor de atalho na mensagem que o usuario clicou.
if(typeof(ID) == "string" && ID.indexOf("_") != -1)
searchId = ID.split("_")[1].substr(0,1);
else
searchId = ID;
if(searchId != "s"){
if (preferences.use_shortcuts == '1')
select_msg(ID, 'null');
}
// Call function to draw message
// If needed, delete old border
var isPartMsg = false;
for(var ii = 0; ii < partMsgs.length; ii++)
if(partMsgs[ii] == ID) isPartMsg = true;
if(msg_info.alarm == false){
if ((openTab.type[currentTab] == 2 || openTab.type[currentTab] == 3) && isPartMsg === false)
delete_border(currentTab,'false');
}
if(Element("border_id_" + id_msg_read)) {
alternate_border(id_msg_read);
resizeWindow();
}
else {
var border_id = create_border(msg_info.subject, id_msg_read);
if(border_id)
{
openTab.type[border_id] = 2;
openTab.imapBox[border_id] = msg_info.msg_folder;
draw_message(msg_info,border_id);
var unseen_sort = document.getElementById('span_flag_UNSEEN').getAttribute('onclick');
unseen_sort = unseen_sort.toString();
if ( !(unseen_sort.indexOf("'UNSEEN' == 'UNSEEN'") < 0) )
{
var sort_type = sort_box_type;
sort_box_type = null;
sort_box('UNSEEN', sort_type);
}
}
else
return;
}
var domains = "";
if ((msg_info.DispositionNotificationTo) && (!msg_is_read(ID) || (msg_info.Recent == 'N')))
{
if (preferences.notification_domains != undefined && preferences.notification_domains != "")
{
domains = preferences.notification_domains.split(',');
}
else
{
var confNotification = true;
}
for (var i = 0; i < domains.length; i++)
if (msg_info.DispositionNotificationTo.match(domains[i]+">"))
{
var confNotification = true;
break;
}
if (confNotification == undefined)
var confNotification = confirm(get_lang("The sender:\n%1\nwaits your notification of reading. Do you want to confirm this?",msg_info.DispositionNotificationTo), "");
if (confNotification)
cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&date="+msg_info.udate+"&subject="+url_encode(msg_info.subject), handler_sendNotification);
}
//Change msg class to read.
if (!msg_is_read(ID))
{
set_msg_as_read(ID, true);
if (msg_info.cacheHit || (!proxy_mensagens.is_local_folder(get_current_folder()) && msg_info.original_ID))
{
set_message_flag(ID, "seen"); // avoid caducous (lazy) data
}
}
}
setTimeout('resizeWindow()',300);
}
function auto_refresh(){
refresh(preferences.alert_new_msg);
setTimeout('auto_refresh()', time_refresh);
}
function auto_archiving() {
expresso_mail_sync.start_sync();
setTimeout('auto_archiving()',600000);
}
function refresh(alert_new_msg){
var handler_refresh = function(data){
if(data['msg_range_end'])
if(data['msg_range_end'] > 0)
current_page = data['msg_range_end']/preferences.max_email_per_page;
if(!verify_session(data))
return;
var total_messages_element = Element('tot_m');
var box = Element("tbody_box");
if (box.childNodes.length == 0)
showEmptyBoxMsg(box);
if (data.length > 0){
Element("table_message_header_box_"+numBox).emptyBody = false;
table_element = Element("table_box");
var msg_info = document.getElementById('msg_info');
if (msg_info != null)
{
var msg_tr = msg_info.parentNode.parentNode;
msg_tr.removeChild(msg_info.parentNode);
if (!Element("colgroup_main_"+numBox)) {
var colgr_element = buildColGroup();
colgr_element.setAttribute("id","colgroup_main_"+numBox);
table_element.appendChild(colgr_element);
}
}
var box = Element("tbody_box");
//table_element.insertBefore(box, Element("colgroup_main_"+numBox)); // keeps colgroup as the last child
//table_element.appendChild(Element("colgroup_main_"+numBox));
$(table_element).append(Element("colgroup_main_"+numBox));
if (data.msgs_to_delete.length > 0){
for (var i=0; i 1)
return $("
");
},
iframeFix: true,
delay: 150,
cursorAt: {top: 5, left: 56},
refreshPositions: true,
containment: "#divAppbox"
}).bind("contextmenu", function(){
if($(this).find("input:checkbox").attr("checked") != "checked"){
$(this).find("input:checkbox").trigger('click');
$(this).addClass("selected_msg");
}
});
//_dragArea.makeDragged(new_msg, data[i].msg_number, data[i].subject, true);
if( data[i].next_msg_number != undefined && data[i].next_msg_number != null ){
try {
box.insertBefore(new_msg, box.childNodes[data[i].msg_key_position]);
}
catch (e){
box.insertBefore(new_msg, box.firstChild);
}
}
else if (data[i].Recent == 'N'){
box.insertBefore(new_msg,box.firstChild);
}
else {
box.appendChild(new_msg);
}
}
}
if(parseInt(preferences.use_shortcuts))
select_msg("null","reload_msg","null");
if(parseInt(alert_new_msg) && data.new_msgs > 0)
alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!");
build_quota(data['quota']);
}
if(data.new_msgs){
total_messages_element.innerHTML = parseInt( total_messages_element.innerHTML ) + data.new_msgs;
}else if(data.tot_msgs){
total_messages_element.innerHTML = data.tot_msgs;
}
// Update Box BgColor
var box = Element("tbody_box");
if(box.childNodes.length > 1){
updateBoxBgColor(box.childNodes);
}
connector.purgeCache();
update_menu();
resizeMailList();
}
msg_range_end = (current_page*preferences.max_email_per_page);
msg_range_begin = (msg_range_end-(preferences.max_email_per_page)+1);
//Get element tBody.
main = Element("tbody_box");
if(!main)
return;
// Get all TR (messages) in tBody.
main_list = main.childNodes;
var tmp = '';
var string_msgs_in_main = '';
var len = main_list.length;
for (var j=0; j < len; j++)
tmp += main_list[j].id + ',';
string_msgs_in_main = tmp.substring(0,(tmp.length-1));
if(!expresso_offline)
$.ajax({
url: 'controller.php?' + $.param( {action: '$this.imap_functions.refresh',
folder: current_folder,
msgs_existent: string_msgs_in_main,
msg_range_begin: msg_range_begin,
msg_range_end: msg_range_end,
sort_box_type: sort_box_type,
search_box_type: search_box_type,
sort_box_reverse: sort_box_reverse } ),
success: function( data ){
data = connector.unserialize( data );
if( data )
handler_refresh( data );
}
});
}
function delete_msgs(folder, msgs_number, border_ID, show_success_msg,archive){
if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( msgs_number, folder ) ){
alert( "Impossivel deletar mensagens que estão ainda estão sendo arquivadas." );
return;
}
var userTrashFolder = '';
if (arguments.length < 4) show_success_msg = true;
if (folder == 'null') folder = current_folder;
if(folder.substr(0,4) == 'user')
{
var arrayFolder = folder.split(cyrus_delimiter);
userTrashFolder = 'user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Trash'];
/** TODO Mudar quando melhorias forem implementadas na API de atualização do cache */
DataLayer.remove('folder', false);
DataLayer.get('folder');
var has_folder = DataLayer.get('folder', userTrashFolder);
if(!has_folder){
create_new_folder(special_folders['Trash'], 'user'+cyrus_delimiter+arrayFolder[1]);
}
}
else userTrashFolder = mount_url_folder(["INBOX",special_folders["Trash"]]);
if(openTab.type[currentTab] == 1)
return move_search_msgs('content_id_'+currentTab,userTrashFolder,special_folders['Trash']);
if(currentTab.toString().indexOf("_r") != -1)
msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));
if (!archive && (parseInt(preferences.save_deleted_msg)) && (folder != userTrashFolder)){
move_msgs2(folder, msgs_number, border_ID, userTrashFolder,special_folders['Trash'],show_success_msg );
return;
}
var handler_delete_msgs = function(data){
Element('chk_box_select_all_messages').checked = false;
if (currentTab)
mail_msg = Element("tbody_box_"+currentTab);
else
mail_msg = Element("tbody_box");
if ( preferences.use_shortcuts == '1') {
//Last msg is selected
if (mail_msg && exist_className(mail_msg.childNodes[mail_msg.childNodes.length-1], 'selected_shortcut_msg') ) {
select_msg('null', 'up', true);
}
else {
if (!select_msg('null', 'down', true)) {
select_msg('null', 'up', true);
}
}
}
if (show_success_msg) {
if (data.msgs_number.length == 1)
write_msg(get_lang("The message was deleted."));
else
write_msg(get_lang("The messages were deleted."));
}
if (openTab.type[currentTab] > 1){
var msg_to_delete = Element(msgs_number);
if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete) {
if (msg_to_delete.previousSibling){
var previous_msg = msg_to_delete.previousSibling.id;
$.ajax({
url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg',
msg_number: previous_msg,
msg_folder: current_folder,
decoded: true } ),
success: function( data ){
data = connector.unserialize( data );
if( data )
show_msg( data );
}
});
}
else
delete_border(currentTab,'false');
}
else
delete_border(currentTab,'false');
}
for (var i=0; i 0 || parseInt(msgs_number) > 0)
cExecute ("$this.imap_functions.delete_msgs&folder="+folder+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&search_box_type="+search_box_type+"&sort_box_reverse="+sort_box_reverse, handler_delete_msgs);
else
write_msg(get_lang('No selected message.'));
}
function move_search_msgs(border_id, new_folder, new_folder_name, action){
var msg_to_delete = "";
var msg_to_move = "";
var selected_messages = '';
var temp_msg;
var remove_currente_folder = "";
var id_border = currentTab.replace(/[a-zA-Z_]+/, "");
var delete_msg = false;
if(new_folder_name == special_folders['Trash']){
delete_msg = true;
}
selected_messages = get_selected_messages_search();
if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( selected_messages, folder ) ){
alert( "Impossivel mover mensagens que estão ainda estão sendo arquivadas." );
return;
}
var handler_move_search_msgs = function(data){
if(!data || !data.msgs_number)
return;
else if(data.deleted) {
if(data.no_move && data.move)
alert(get_lang("Unable to remove the message (s) of shared folders which you do not have permission."));
else if (data.msgs_number.length == 1)
write_msg(get_lang("The message was deleted."));
else
write_msg(get_lang("The messages were deleted."));
}else if(data.status == false && data.move ){
alert(get_lang("Unable to remove the message (s) of shared folders which you do not have permission."));
}else if(data.status == false){
alert(get_lang("You don't have permission for this operation in this shared folder!"));
return false;
}else{
if (data.msgs_number.length == 1)
write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name));
else
write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name));
}
if(data.no_move){
var no_remove = data.no_move.split(',');
var continua = true;
selected_messages = selected_messages.split(",");
for (i = 0; i < selected_messages.length; i++){
for(j = 0; j < no_remove.length; j++)
if(selected_messages[i] == no_remove[j])
continua = false;
if(continua)
removeAll(selected_messages[i]+'_s'+id_border);
continua = true;
}
}else{
selected_messages = selected_messages.split(",");
for (i = 0; i < selected_messages.length; i++){
removeAll(selected_messages[i]+'_s'+id_border);
}
}
// Update Box BgColor
var box = Element("tbody_box_"+getNumBoxFromTabId(currentTab)).childNodes;
if(box.length > 1){
updateBoxBgColor(box);
}
connector.purgeCache();
if(remove_currente_folder != ""){
var mail_msg = Element('tbody_box').childNodes;
remove_currente_folder = remove_currente_folder.substring(0,(remove_currente_folder.length-1));
remove_currente_folder = remove_currente_folder.split(",");
for(i = 0; i < remove_currente_folder.length; i++)
removeAll(remove_currente_folder[i]);
// Update Box BgColor
var box = Element("tbody_box");
if(box.childNodes.length > 0){
updateBoxBgColor(box.childNodes);
}
if(folder == get_current_folder()){
Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - remove_currente_folder.length;
}
}
draw_tree_folders();
EsearchE.refresh();
}
if (selected_messages){
var selected_param = "";
if (selected_messages.indexOf(',') != -1)
{
selected_msg_array = selected_messages.split(",");
for (i = 0; i < selected_msg_array.length; i++){
var tr = Element(selected_msg_array[i]+'_s'+id_border);
if(tr.getAttribute('name') == current_folder)
remove_currente_folder += tr.id.replace(/_[a-zA-Z0-9]+/,"")+',';
if ((action == 'delete' && tr.getAttribute('name') == mount_url_folder(["INBOX",special_folders["Trash"]])) || !(parseInt(preferences.save_deleted_msg)))
{
msg_to_delete += ','+special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");
}
else if (!(tr.getAttribute('name') == new_folder && action != 'delete'))
{
msg_to_move = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name'));
selected_param += ','+msg_to_move+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");
}else{
write_msg(get_lang('At least one message have the same origin'));
return false;
}
}
}
else
{
var tr=Element(selected_messages+'_s'+id_border);
if(tr.getAttribute('name') == current_folder)
remove_currente_folder += tr.id.replace(/_[a-zA-Z0-9]+/,"")+',';
if((action == 'delete' && tr.getAttribute('name') == mount_url_folder(["INBOX",special_folders["Trash"]])) || !(parseInt(preferences.save_deleted_msg))){
msg_to_delete = special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");
}else if (!(tr.getAttribute('name') == new_folder && action != 'delete')){
trfolder = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name'));
selected_param=trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");
}else{
write_msg(get_lang('The origin folder and the destination folder are the same.'));
return false;
}
}
var params = "";
if(msg_to_delete != "" && msg_to_move != ""){
params += "&selected_messages_move="+url_encode(selected_param);
params += "&new_folder_move="+url_encode(new_folder);
params += "&new_folder_name_move="+url_encode(new_folder_name);
new_folder = mount_url_folder(["INBOX",special_folders["Trash"]]);
new_folder_name = special_folders['Trash'];
params += "&selected_messages_delete="+url_encode(msg_to_delete);
params += "&new_folder_delete="+url_encode(new_folder);
cExecute ("$this.imap_functions.move_delete_search_messages", handler_move_search_msgs, params);
}else if(msg_to_delete != ""){
new_folder = mount_url_folder(["INBOX",special_folders["Trash"]]);
new_folder_name = special_folders['Trash'];
params += "&delete=true";
params += "&selected_messages="+url_encode(msg_to_delete);
params += "&new_folder="+url_encode(new_folder);
cExecute ("$this.imap_functions.move_search_messages", handler_move_search_msgs, params);
}else{
params = "&selected_messages="+url_encode(selected_param);
params += "&delete=false";
params += "&new_folder="+url_encode(new_folder);
params += "&new_folder_name="+url_encode(new_folder_name);
cExecute ("$this.imap_functions.move_search_messages", handler_move_search_msgs, params);
}
}
else
write_msg(get_lang('No selected message.'));
}
function move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,show_success_msg, not_opem_previus){
not_opem_previus = typeof(not_opem_previus) != 'undefined' ? not_opem_previus : false;
var folder_error = new_folder_name;
if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( msgs_number, folder ) ){
alert( "Impossivel mover mensagens que estão ainda estão sendo arquivadas." );
return;
}
if (! folder || folder == 'null')
folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder());
if(openTab.type[currentTab] == 1)
return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name);
var handler_move_msgs = function(data){
if(typeof(data) == 'string')
if (data.match(/^(.*)TRYCREATE(.*)$/)){
connector.loadScript('TreeS');
var move_to_folder = data.match(/^(.*)Spam(.*)$/) ? "Spam" : special_folders['Trash'];
alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.', folder_error));
connector.loadScript('TreeShow');
ttree.FOLDER = 'root';
ttreeBox.new_past(move_to_folder);
return false;
}else{
alert(get_lang('Error moving message.')+":\n"+data);
return false;
}
//Este bloco verifica as permissoes ACL sobre pastas compartilhadas
if(data.status == false){
alert(get_lang("You don't have permission for this operation in this shared folder!"));
return false;
}
mail_msg = ( Element("divScrollMain_"+numBox) ) ? Element("divScrollMain_"+numBox).firstChild.firstChild : Element("divScrollMain_0").firstChild.firstChild;
if (data.msgs_number.length == 1){
write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name));
}
else{
write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name));
}
if (openTab.type[currentTab] > 1){
msg_to_delete = Element(msgs_number);
if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete)
{
if (msg_to_delete.previousSibling){
var previous_msg = msg_to_delete.previousSibling.id;
//cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + current_folder, show_msg);
if(!not_opem_previus){
$.ajax({
url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg',
msg_number: previous_msg,
msg_folder: folder,
decoded: true } ),
success: function( data ){
data = connector.unserialize( data );
if( data )
show_msg( data );
}
});
}
}
//se houver pagina anterior a paginação deve ser refeita
else if (current_page > 1){
$('#msg_opt_previous_'+msg_to_delete.getAttribute('id') + '_r').trigger('click');
}
else
delete_border(currentTab,'false');
}
else{
delete_border(currentTab,'false');
}
if(msg_to_delete)
mail_msg.removeChild(msg_to_delete);
// Update Box BgColor
var box = Element("tbody_box");
if(box.childNodes.length > 0){
updateBoxBgColor(box.childNodes);
}
if(folder == get_current_folder()){
Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - 1;
}
return;
}
Element('chk_box_select_all_messages').checked = false;
if (! mail_msg)
mail_msg = Element("tbody_box");
data.msgs_number = data.msgs_number.split(",");
var msg_to_delete;
if( typeof(msgs_number) == 'string' )
all_search_msg = msgs_number.split(',');
else if( typeof(msgs_number) == 'number')
all_search_msg = msgs_number;
for (var i=0; i <= all_search_msg.length; i++)
{
msg_to_delete = Element(folder+';'+all_search_msg[i]);
if (msg_to_delete)
msg_to_delete.parentNode.removeChild(msg_to_delete);
}
if ( preferences.use_shortcuts == '1') {
var all_messages = Element('tbody_box').childNodes;
// verificar se a msg selecionada com o checkbox é a mesma selecionada com o shortcut
var msg_list_shortcut = get_selected_messages_shortcut().split(',');
if(data.msgs_number.length > 0 && msg_list_shortcut.length > 0 && data.msgs_number.toString() == msg_list_shortcut.toString()){
//Last msg is selected
if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') ) {
select_msg('null', 'up', true);
}
else {
if (!select_msg('null', 'down', true)) {
select_msg('null', 'up', true);
}
}
}
}
for (var i=0; i 0 || msgs_number.length > 0){
$.ajax({
url: 'controller.php?' + $.param( {action: '$this.imap_functions.move_messages',
folder: folder,
msgs_number: msgs_number,
border_ID: border_ID,
sort_box_type: sort_box_type,
search_box_type: search_box_type,
sort_box_reverse: sort_box_reverse,
reuse_border: border_ID,
new_folder: new_folder,
new_folder_name: new_folder_name,
get_previous_msg: ( !not_opem_previus ? preferences.delete_and_show_previous_message : false ),
decoded: true } ),
success: function( data ){
data = connector.unserialize( data );
if( data )
handler_move_msgs( data );
}
});
}else
write_msg(get_lang('No selected message.'));
}
function move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name, not_opem_previus) {
move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,true, not_opem_previus);
}
//Caso deseja-se que não se abra a mensagem anterior independente da
//preferencia do usuario
function move_msgs_not_previus(folder, msgs_number, border_ID, new_folder, new_folder_name) {
move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,true, true);
}
function normalizeMsgNumber( msgNumber ){
if (msgNumber || msgNumber == 'selected')
msgNumber = get_selected_messages();
// se a aba estiver aberta e selecionada, apenas a msg da aba é movida
if(currentTab.toString().indexOf("_r") != -1)
{
//se a aba for aberta atraves de uma pesquisa
if(currentTab.toString().indexOf('_s') != -1)
msgNumber = currentTab.toString().substr(0,currentTab.toString().indexOf('_s'));
else
msgNumber = currentTab.toString().substr(0,currentTab.toString().indexOf('_r'));
}
if (parseInt(msgNumber) <= 0 || msgNumber.length <= 0){
write_msg(get_lang('No selected message.'));
return( false );
}
return( msgNumber );
}
function archive_search_msgs(folder_dest) {
var id_msgs = "";
id_msgs = get_selected_messages_search();
var msg_to_arquive = "";
var messages = "";
var id_border = currentTab.replace(/[a-zA-Z_]+/, "");
if ( parseInt(id_msgs) <= 0 || id_msgs.length <= 0 )
return write_msg(get_lang('No selected message.'));
if(folder_dest=='local_root' || folder_dest==null) //Caso seja o primeiro arquivamento...
folder_dest = 'local_Inbox';
id_msgs = expresso_local_messages.checkArchived( id_msgs, folder_dest );
if( !id_msgs ){
write_msg( "Todas as mensagens já foram arquivadas anteriormente." );
return;
}
document.getElementById("overlay").style.visibility = "visible";
var handler_arquivar_mensagens = function(data) {
var msgs_info = [];
for( var i = 0; i < data.length; i++ )
msgs_info[i] = connector.unserialize( data[i] );
//vejo se já tinha mensagens locais
var h = expresso_local_messages.has_local_mails();
expresso_local_messages.insert_mails( msgs_info, folder_dest, function( s, f ){complete_archiving( s, f, h )} );
document.getElementById("overlay").style.visibility = "hidden";
}
id_msgs = id_msgs.split(',');
for (i = 0; i < id_msgs.length; i++){
var tr = Element(id_msgs[i]+'_s'+id_border);
msg_to_arquive = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name'));
messages += ','+msg_to_arquive+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");
}
$.ajax({
url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg',
msg_number: messages,
msg_folder: folder_dest,
decoded: true } ),
success: function( data ){
data = connector.unserialize( data );
if( data )
handler_arquivar_mensagens( data );
}
});
}
function archive_msgs(folder,folder_dest,id_msgs) {
if(proxy_mensagens.is_local_folder(folder)) {
write_msg(get_lang("You cant archive local mails"));
return;
}
if(currentTab.toString().indexOf("_r") != -1)
id_msgs = currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));
if(currentTab.toString().indexOf("_s") != -1)
id_msgs = currentTab.toString().substr(0,currentTab.toString().indexOf("_s"));
if(!id_msgs){
if (currentTab != 0 && currentTab.indexOf("search_") >= 0){
archive_search_msgs(folder_dest);
return;
}else
id_msgs = get_selected_messages();
}
if ( parseInt(id_msgs) <= 0 || id_msgs.length <= 0 )
return write_msg(get_lang('No selected message.'));
if(folder_dest=='local_root' || folder_dest==null) //Caso seja o primeiro arquivamento...
folder_dest = 'local_Inbox';
id_msgs = expresso_local_messages.checkArchived( id_msgs, folder_dest );
if( !id_msgs ){
write_msg( "Todas as mensagens já foram arquivadas anteriormente." );
return;
}
document.getElementById("overlay").style.visibility = "visible";
var handler_arquivar_mensagens = function(data) {
var msgs_info = [];
for( var i = 0; i < data.length; i++ )
msgs_info[i] = connector.unserialize( data[i] );
//vejo se já tinha mensagens locais
var h = expresso_local_messages.has_local_mails();
expresso_local_messages.insert_mails( msgs_info, folder_dest, function( s, f ){complete_archiving( s, f, h )} );
document.getElementById("overlay").style.visibility = "hidden";
}
$.ajax({
url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg',
msg_number: id_msgs,
msg_folder: folder,
decoded: true } ),
success: function( data ){
data = connector.unserialize( data );
if( data )
handler_arquivar_mensagens( data );
}
});
}
function complete_archiving( success, fails, has_local_messages_before )
{
var msgs_to_remove = {};
var target = mount_url_folder(["INBOX",special_folders["Trash"],'tmpMoveToLocal']);
success = expresso_local_messages.select_mail( [ 'original_id', 'original_folder' ], success );
for (var i = 0; i < success.length; i++) {
var msg_info = success[i];
// if ( msg_info.dest_folder == target )
// {
// msg_info.msg_folder += (Date.parse(new Date));
// }
//////////////// deselecionando ////////////////
Element('chk_box_select_all_messages').checked = false;
if ( Element("check_box_message_" + msg_info.original_id) )
{
Element("check_box_message_" + msg_info.original_id).checked = false;
}
if ( Element(msg_info.original_id) )
{
remove_className(Element(msg_info.original_id), 'selected_msg');
}
// if ( tree_folders._selected.id.indexOf( 'local_' ) == 0 || msg_info.dest_folder.indexOf( target ) == 0 )
// {
// openTab.imapBox[0] = '';
// tree_folders.getNodeById( 'local_Inbox' )._select( );
// change_folder('local_Inbox','Inbox');
// }
/////////////////////////////////////////////////
//As mensagens arquivadas devem ser removidas, caso o usuario tenha isso configurado.
msgs_to_remove[ msg_info.original_folder ] = msgs_to_remove[ msg_info.original_folder ] || [];
msgs_to_remove[ msg_info.original_folder ].push( msg_info.original_id );
}
if (preferences.keep_archived_messages == 0) {
//Remove as mensagens
for( var folder in msgs_to_remove ){
if(folder != 'undefined')
delete_msgs(folder, msgs_to_remove[folder],'null',false,true);
}
}
if( !has_local_messages_before && expresso_local_messages.has_local_mails() )
ttreeBox.update_folder();
else
update_menu();
}
function action_msg_selected_from_search(aba, evento){
if(evento == "delete")
move_search_msgs(aba,'INBOX/Trash', 'Trash', 'delete');
}
function get_all_messages_search(){
var aba = document.getElementById('content_id_'+currentTab);
var messages = "";
jQuery(function() {
jQuery("#"+aba.id+" tr").each(function(i, main_list) {
messages += main_list.id.replace(/_[a-zA-Z0-9]+/,"") + ',' ;
});
});
if(messages.indexOf(',') == 0)
messages = messages.substring(1,(messages.length));
return messages.substring(0,(messages.length-1));
}
function get_selected_messages_search(){
var aba = document.getElementById('content_id_'+currentTab);
var selected_messages = "";
jQuery("#"+aba.id+" tr").each(function(i, main_list) {
var check_box = main_list.firstChild.firstChild;
if(check_box && check_box.checked) {
selected_messages += main_list.id.replace(/_[a-zA-Z0-9]+/,"") + ',' ;
};
});
if (selected_messages != ""){
if(selected_messages.indexOf(',') == 0)
selected_messages = selected_messages.substring(1,(selected_messages.length));
selected_messages = selected_messages.substring(0,(selected_messages.length-1));
return selected_messages;
}else{
return false;
}
}
function get_selected_messages_search_role(){
var aba = document.getElementById('content_id_'+currentTab);
var selected_messages = "";
jQuery("#"+aba.id+" tr").each(function(i, main_list) {
var check_box = main_list.firstChild.firstChild;
if(check_box && check_box.checked && check_box.id != 'chk_box_select_all_messages_search') {
selected_messages += main_list.role + ',' ;
};
});
if (selected_messages != ""){
if(selected_messages.indexOf(',') == 0)
selected_messages = selected_messages.substring(1,(selected_messages.length));
selected_messages = selected_messages.substring(0,(selected_messages.length-1));
return selected_messages;
}else{
return false;
}
}
function get_selected_messages_shortcut(){
var main;
try{
main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild;
}catch(e){
};
if (! main)
main = Element("tbody_box_"+numBox);
if (! main)
main = Element("tbody_box");
// Get all TR (messages) in tBody.
var main_list = main.childNodes;
var selected_messages_by_shortcuts = '';
var j = 0;
for (j; j<(main_list.length); j++)
{
if ( exist_className(Element(main_list[j].id), 'selected_shortcut_msg') )
{
selected_messages_by_shortcuts += main_list[j].id + ',';
}
}
selected_messages_by_shortcuts = selected_messages_by_shortcuts.substring(0,(selected_messages_by_shortcuts.length-1));
return selected_messages_by_shortcuts;
}
function get_selected_messages(){
var main;
try{
main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild;
}catch(e){
};
if (! main)
main = Element("tbody_box_"+numBox);
if (! main)
main = Element("tbody_box");
// Get all TR (messages) in tBody.
var main_list = main.childNodes;
var _tab_prefix = getTabPrefix();
var selected_messages = '';
var selected_messages_by_shortcuts = '';
var j = 0;
for (j; j<(main_list.length); j++)
{
if ( (!isNaN(parseInt(numBox))) && (numBox == 0)) {
check_box = Element("check_box_message_" + main_list[j].id);
} else {
id_mensagem = main_list[j].id.split('_');
check_box = Element("search_" + numBox + "_check_box_message_" + id_mensagem[0]);
}
if ( (check_box) && (check_box.checked) )
selected_messages += main_list[j].id + ',';
if (preferences.use_shortcuts == '1')
{
if ( exist_className(Element(main_list[j].id), 'selected_shortcut_msg') )
{
selected_messages_by_shortcuts += main_list[j].id + ',';
}
}
}
selected_messages = selected_messages.substring(0,(selected_messages.length-1));
/* Verifica se está na tela de pesquisa. */
if(selected_messages.indexOf("_") != -1)
{
results_search_messages = selected_messages;
/* Retira a informação da aba */
selected_messages = selected_messages.substring(0,selected_messages.indexOf("_"));
}
if (preferences.use_shortcuts == '1')
{
selected_messages_by_shortcuts = selected_messages_by_shortcuts.substring(0,(selected_messages_by_shortcuts.length-1));
var array_selected_messages_by_shortcuts = selected_messages_by_shortcuts.split(",");
var array_selected_messages = selected_messages.split(",");
if ((array_selected_messages.length == 0) && (array_selected_messages_by_shortcuts.length > 0))
{
return selected_messages_by_shortcuts;
}
}
if (selected_messages == '')
return false;
else
return selected_messages;
}
function replaceAll(string, token, newtoken) {
while (string.indexOf(token) != -1) {
string = string.replace(token, newtoken);
}
return string;
}
function new_message_to(email) {
var new_border_ID = new_message('new','null');
document.getElementById("to_" + new_border_ID).value=email;
}
function new_message(type, border_ID){
if(RichTextEditor.editorReady === false) return false;
RichTextEditor.editorReady = false;
if (Element('show_img_link_'+border_ID))
{
show_msg_img(border_ID.match(/^\d*/)[0], Element('input_folder_'+border_ID).value);
}
var new_border_ID = draw_new_message(parseInt(border_ID.replace('_r','')));
if(typeof(openTab.type[new_border_ID]) != "undefined") {
if(tabTypes[type] == openTab.type[new_border_ID]) {
if (type != 'edit')
{
delete_border(currentTab);
new_border_ID = draw_new_message(parseInt(border_ID));
}
} else {
var a_types = {6 : get_lang("Forward"),7 : get_lang("Reply"),
8 : get_lang("Reply to all with history"),
9 : get_lang("Reply without history"),
10: get_lang("Reply to all without history")};
if(new_border_ID != 0)
if(!confirm(get_lang("Your message to %1 has not been saved or sent. "+
"To %2 will be necessary open it again. Discard your message?",
a_types[openTab.type[new_border_ID]].toUpperCase(),
a_types[tabTypes[type]].toUpperCase()))){
return new_border_ID;
} else {
delete_border(currentTab);
new_border_ID = draw_new_message(parseInt(border_ID));
}
}
}
if (new_border_ID == 'maximo'){
RichTextEditor.editorReady = true;
return false;
}
if (new_border_ID == false)
{
RichTextEditor.editorReady = true;
setTimeout('new_message(\''+type+'\',\''+border_ID+'\');',500);
return false;
}
openTab.type[new_border_ID] = tabTypes[type];
// Salva a pasta da mensagem respondida ou encaminhada:
var folder_message = Element("input_folder_"+border_ID);
if(folder_message) {
var input_current_folder = document.createElement('input');
input_current_folder.id = "new_input_folder_"+border_ID;
input_current_folder.name = "input_folder";
input_current_folder.type = "hidden";
input_current_folder.value = folder_message.value;
Element("content_id_" + new_border_ID).appendChild(input_current_folder);
}//Fim.
var title = '';
data = [];
if (Element("from_" + border_ID)){
if (document.getElementById("reply_to_" + border_ID)){
data.to = document.getElementById("reply_to_values_" + border_ID).value;
data.to = data.to.replace(/</gi,"<");
data.to = data.to.replace(/>/gi,">");
}
else {
if (document.getElementById("sender_values_"+border_ID))
{
data.to = document.getElementById("sender_values_"+border_ID).value;
data.to = data.to.replace(/</gi,"<");
data.to = data.to.replace(/>/gi,">");
}
else if(document.getElementById("from_values_"+border_ID)) {
data.to = document.getElementById("from_values_"+border_ID).value;
data.to = data.to.replace(/</gi,"<");
data.to = data.to.replace(/>/gi,">");
}
}
if (document.getElementById("to_values_" + border_ID)){
data.to_all = document.getElementById("to_values_" + border_ID).value;
data.to_all_alternative = document.getElementById("user_email_alternative").value;
data.to_all = data.to_all.replace(/\n/gi," ");
data.to_all = data.to_all.replace(/</gi,"<");
data.to_all = data.to_all.replace(/>/gi,">");
var _array_to_all = data.to_all.split(",");
var _array_to_alternative = data.to_all_alternative.split(",");
}
}
if (document.getElementById("cc_" + border_ID)){
data.cc = document.getElementById("cc_values_" + border_ID).value;
data.cc = data.cc.replace(/</gi,"<");
data.cc = data.cc.replace(/>/gi,">");
var _array_cc = data.cc.split(",");
}
if (document.getElementById("cco_" + border_ID)){
data.cco = document.getElementById("cco_values_" + border_ID).value;
data.cco = data.cco.replace(/</gi,"<");
data.cco = data.cco.replace(/>/gi,">");
}
if ($("#subject_" + border_ID))
data.subject = $("#subject_" + border_ID).text();
if(data.subject == get_lang("(no subject) "))
data.subject = '';
if (document.getElementById("body_" + border_ID))
data.body = document.getElementById("body_" + border_ID).innerHTML;
if (Element('date_' + border_ID)){
data.date = Element('date_' + border_ID).innerHTML;
}
if (Element('date_day_' + border_ID)){
data.date_day = Element('date_day_' + border_ID).value;
}
if (Element('date_hour_' + border_ID)){
data.date_hour = Element('date_hour_' + border_ID).value;
}
var signature = RichTextEditor.getSignatureDefault();
if(type!="new" && type!="edit" && document.getElementById("is_local_"+border_ID) != null)
data.is_local_message = (document.getElementById("is_local_"+border_ID).value=="1")?true:false;
if(typeof($.fn.elastic) == "undefined"){
$.lazy({
src: '../prototype/plugins/jquery-elastic/jquery.elastic.source.js',
name: 'elastic'
});
}
var content = $("#content_id_"+new_border_ID);
switch(type){
case "reply_without_history":
RichTextEditor.replyController = true; //Seta o editor como modo reply
content.find('[name="input_to"]').val(data.to);
title = "Re: " + html_entities(data.subject);
content.find(".subject").val("Re: " + data.subject);
useOriginalAttachments(new_border_ID,border_ID);
content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val());
// Insert the signature automaticaly at message body if use_signature preference is set
if (preferences.use_signature == "1"){
RichTextEditor.setInitData(new_border_ID,'
' + signature ,true) ;
}
break;
case "reply_with_history":
RichTextEditor.replyController = true; //Seta o editor como modo reply
title = "Re: " + html_entities(data.subject);
content.find(".subject").val("Re: " + data.subject);
content.find('[name="input_to"]').val(data.to);
content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val());
block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour);
useOriginalAttachments(new_border_ID,border_ID);
// Insert the signature automaticaly at message body if use_signature preference is set
if (preferences.use_signature == "1"){
RichTextEditor.setInitData(new_border_ID, '
'+ block_quoted_body,true);
}
break;
case "reply_to_all_without_history":
RichTextEditor.replyController = true; //Seta o editor como modo reply
// delete user email from to_all array.
data.to_all = new Array();
data.to_all = removeUserEmail(_array_to_all);
data.to_all = removeAlternative(data.to_all,_array_to_alternative);
content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val());
data.to_all = data.to_all.join(",");
title = "Re: " + html_entities(data.subject);
content.find(".subject").val("Re: " + data.subject);
if (data.to.indexOf(Element("user_email").value) > 0 )
content.find('[name="input_to"]').val(data.to_all);
else
content.find('[name="input_to"]').val(data.to + ',' + data.to_all);
if (data.cc){
data.cc = new Array();
data.cc = removeUserEmail(_array_cc);
data.cc = removeAlternative(data.cc,_array_to_alternative);
if (data.cc != get_lang("undisclosed-recipient"))
data.cc = data.cc.join(",");
else
data.cc = "";
if(data.cc != ""){
content.find('[name="input_cc"]').val(data.cc);
input_binds(content.find('[name="input_cc"]'), new_border_ID);
content.find(".cc-tr").show();//cc-button
//document.getElementById("a_cc_link" + new_border_ID).value = data.cc;
content.find(".cc-button").toggleClass("expressomail-button-icon-ative");
content.find(".cc-button").find("span").html("Remover CC");
content.find('[name="input_cc"]').elastic().unbind('blur');
content.find('[name="input_cc"]').trigger("update");
}
}
useOriginalAttachments(new_border_ID,border_ID);
if (preferences.use_signature == "1"){
RichTextEditor.setInitData(new_border_ID,'
' + signature,true);
}
break;
case "reply_to_all_with_history":
RichTextEditor.replyController = true; //Seta o editor como modo reply
//delete user email from to_all array.
data.to_all = new Array();
data.to_all = removeUserEmail(_array_to_all);
data.to_all = removeAlternative(data.to_all,_array_to_alternative);
content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val());
if (data.to_all != get_lang("undisclosed-recipient"))
data.to_all = data.to_all.join(",");
else
data.to_all = "";
title = "Re: " + html_entities(data.subject);
if (data.to.indexOf(Element("user_email").value) > 0 )
content.find('[name="input_to"]').val(data.to_all);
else
content.find('[name="input_to"]').val(data.to + ',' + data.to_all);
if (data.cc){
data.cc = new Array();
data.cc = removeUserEmail(_array_cc);
data.cc = removeAlternative(data.cc,_array_to_alternative);
if (data.cc != get_lang("undisclosed-recipient"))
data.cc = data.cc.join(",");
else
data.cc = "";
if(data.cc != ""){
content.find('[name="input_cc"]').val(data.cc);
input_binds(content.find('[name="input_cc"]'), new_border_ID);
content.find(".cc-tr").show();
content.find(".cc-button").toggleClass("expressomail-button-icon-ative");
content.find(".cc-button").find("span").html("Remover CC");
content.find('[name="input_cc"]').elastic().unbind('blur');
content.find('[name="input_cc"]').trigger("update");
}
}
content.find(".subject").val("Re: " + data.subject);
block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour);
useOriginalAttachments(new_border_ID,border_ID);
if (preferences.use_signature == "1"){
RichTextEditor.setInitData(new_border_ID,'
' + signature + '
'+ block_quoted_body,true);
}else{
RichTextEditor.setInitData(new_border_ID,block_quoted_body,true);
}
break;
case "forward":
title = "Fw: " + html_entities(data.subject);
content.find(".subject").val("Fw: " + data.subject);
var divFiles = Element("divFiles_"+new_border_ID);
var campo_arquivo;
content.find('[name="msg_forward_from"]').val($("#msg_number_" + border_ID).val());
if (Element("attachments_" + border_ID))
addOriginalAttachments(new_border_ID,border_ID);
// Insert the signature automaticaly at message body if use_signature preference is set
if (preferences.use_signature == "1"){
$("#body_"+new_border_ID).val('