[564] | 1 | |
---|
| 2 | function charCounter(form) |
---|
| 3 | { |
---|
| 4 | if (form.value.length >= 300) |
---|
| 5 | { |
---|
| 6 | alert(get_lang("You have exceeded the number of allowed characters")); |
---|
| 7 | return false; |
---|
| 8 | } |
---|
[139] | 9 | } |
---|
[197] | 10 | |
---|
[92] | 11 | function cfilter(){ |
---|
[2] | 12 | |
---|
[2658] | 13 | this.criticalError = false; |
---|
[2] | 14 | this.mode_in = ""; |
---|
| 15 | this.rulest = new Array; |
---|
[564] | 16 | this.rulesVoip = new Array; |
---|
[197] | 17 | this.out_officeR = ""; |
---|
| 18 | this.out_officeF = false; |
---|
[2] | 19 | this.email_deny = new Array; |
---|
| 20 | this.ac_form = ""; |
---|
| 21 | this.ind = ""; |
---|
| 22 | this.email_deny = new Array; |
---|
[197] | 23 | this.email_ld = ""; |
---|
[2] | 24 | this.values = new Array("", |
---|
| 25 | ",checkBox1", |
---|
| 26 | ",select_size=1", |
---|
| 27 | ",checkBox1,select_size=1", |
---|
| 28 | ",select_rules=1", |
---|
| 29 | ",checkBox1,select_rules=1", |
---|
| 30 | ",select_size=1,select_rules=1", |
---|
| 31 | ",checkBox1,select_size=1,select_rules=1", |
---|
| 32 | ",checkBox2", |
---|
| 33 | ",checkBox1,checkBox2", |
---|
| 34 | ",checkBox2,select_size=1", |
---|
| 35 | ",ckeckBox1,checkBox2,select_size=1", |
---|
| 36 | ",checkBox2,select_rules=1", |
---|
| 37 | ",checkBox1,checkBox2,select_rules=1", |
---|
| 38 | ",checkBox2,select_size=1,select_rules=1", |
---|
| 39 | ",checkBox1,checkBox2,select_size=1,select_rules=1"); |
---|
| 40 | |
---|
| 41 | } |
---|
[564] | 42 | |
---|
[2] | 43 | |
---|
[2666] | 44 | cfilter.prototype.load_rules = function( posHandler, param ) |
---|
[564] | 45 | { |
---|
[2] | 46 | var _this = this; |
---|
[564] | 47 | var cont1 = parseInt(0); |
---|
| 48 | var cont2 = parseInt(0); |
---|
[2658] | 49 | |
---|
[564] | 50 | if( _this.rulest.length == 0 ) |
---|
| 51 | { |
---|
| 52 | var handler_sieve = function(data) |
---|
| 53 | { |
---|
[2666] | 54 | if (data.toString().indexOf('Error:') == 0) |
---|
[2658] | 55 | { |
---|
| 56 | _this.criticalError = true; |
---|
[2788] | 57 | alert(get_lang('The filters service is out of service, try again later...')); |
---|
[2658] | 58 | } |
---|
| 59 | else |
---|
| 60 | try{ |
---|
[2] | 61 | if(data.rule.length > 0){ |
---|
[564] | 62 | for(var i=0 ; i < data.rule.length; i++) |
---|
| 63 | { |
---|
| 64 | var fields = data.rule[i].split("&&"); |
---|
| 65 | if( fields[6] == 'notify' && fields[7] == preferences.voip_email_redirect ) |
---|
| 66 | _this.rulesVoip[cont1++] = data.rule[i]; |
---|
| 67 | else |
---|
| 68 | _this.rulest[cont2++] = data.rule[i]; |
---|
[2] | 69 | } |
---|
| 70 | } |
---|
[197] | 71 | _this.out_officeR = data.vacation[0]; |
---|
| 72 | _this.out_officeR = _this.out_officeR ? trim(_this.out_officeR.toString().replace("\n","")) : ""; |
---|
[2] | 73 | if(data.mode.length > 0){_this.mode_in = data.mode[0];} |
---|
[2658] | 74 | } |
---|
| 75 | catch(e){ |
---|
| 76 | _this.criticalError = true; |
---|
[2788] | 77 | alert(get_lang('The filters service is out of service, try again later...')); |
---|
[2658] | 78 | } |
---|
[2666] | 79 | if (typeof(posHandler) == 'function') |
---|
| 80 | posHandler(param); |
---|
[2] | 81 | } |
---|
| 82 | if(Element('form_status') != null) |
---|
| 83 | Element('form_status').innerHTML = "<span style='background:#cc4444;'> <font color='WHITE'>Aguarde...</font> </span>"; |
---|
| 84 | cExecute("$this.ScriptS.init_a",handler_sieve); |
---|
[197] | 85 | _this.get_email(); |
---|
| 86 | } |
---|
[2] | 87 | } |
---|
| 88 | |
---|
| 89 | cfilter.prototype.form_m = function(){ |
---|
| 90 | Element('form_body').innerHTML = ""; |
---|
| 91 | Element('form_buttons').style.display = ''; |
---|
| 92 | filters.mount_list(); |
---|
| 93 | this.ac_form = ""; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | cfilter.prototype.form_out = function(){ |
---|
| 97 | Element('form_body').innerHTML = ""; |
---|
| 98 | Element('form_body').innerHTML = this.forms_(); |
---|
| 99 | Element('div_vacation').style.display = ""; |
---|
| 100 | this.ac_form = "old_out"; |
---|
| 101 | this.r_rules_out(); |
---|
| 102 | } |
---|
| 103 | |
---|
[564] | 104 | cfilter.prototype.form_r = function(pos,type) |
---|
| 105 | { |
---|
[2] | 106 | Element('form_body').innerHTML = ""; |
---|
| 107 | Element('form_body').innerHTML = this.forms_(); |
---|
[564] | 108 | this.ind = pos; |
---|
| 109 | |
---|
| 110 | if( type === 'voip') |
---|
| 111 | { |
---|
| 112 | this.ac_form = "old_voip"; |
---|
| 113 | Element('div_voipFilter').style.display = ""; |
---|
| 114 | this.r_rules_form(pos, type); |
---|
| 115 | } |
---|
| 116 | else |
---|
| 117 | { |
---|
| 118 | this.ac_form = "old_rule"; |
---|
| 119 | Element('div_rule').style.display = ""; |
---|
| 120 | this.r_rules_form(pos, type); |
---|
| 121 | } |
---|
[2] | 122 | } |
---|
| 123 | |
---|
[564] | 124 | cfilter.prototype.get_email = function() |
---|
| 125 | { |
---|
[2] | 126 | var _this = this; |
---|
[564] | 127 | var handler_get_email = function(data) |
---|
| 128 | { |
---|
[197] | 129 | _this.email_ld = data ? data : ""; |
---|
[2] | 130 | } |
---|
[197] | 131 | cExecute("$this.user.get_email",handler_get_email); |
---|
[2] | 132 | } |
---|
| 133 | |
---|
[564] | 134 | cfilter.prototype.sel_boxes = function() |
---|
| 135 | { |
---|
[2] | 136 | var nm_folders = tree_folders.getNodesList(cyrus_delimiter); |
---|
| 137 | if(document.getElementById("select_mailboxes") != null){ |
---|
| 138 | var sel_nm = document.getElementById("select_mailboxes"); |
---|
| 139 | if(sel_nm.length > 0 ){ |
---|
| 140 | for(var i=0; i < sel_nm.options.length; i++){ |
---|
| 141 | sel_nm.options[i] = null; |
---|
| 142 | i--; |
---|
| 143 | } |
---|
| 144 | } |
---|
[689] | 145 | for(var i=0; i < nm_folders.length; i++){ |
---|
| 146 | if(nm_folders[i].id != "root" && !proxy_mensagens.is_local_folder(nm_folders[i].id)){ |
---|
[2] | 147 | var opt = new Option(nm_folders[i].caption,nm_folders[i].id,false,true); |
---|
| 148 | sel_nm[sel_nm.length] = opt; |
---|
| 149 | } |
---|
| 150 | } |
---|
| 151 | sel_nm[0].selected = true; |
---|
| 152 | } |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | cfilter.prototype.box_select = function(param){ |
---|
| 156 | var aux = this.BoxSelection[param].split(","); |
---|
| 157 | var ele1 = document.getElementById(aux[0]); |
---|
| 158 | var ele2 = document.getElementById(aux[1]); |
---|
| 159 | var noption = ""; |
---|
| 160 | if(param == 0 || param == 1){ |
---|
| 161 | if(ele1.selectedIndex != -1){ |
---|
| 162 | noption = new Option(ele1.value,ele1.value,false,false); |
---|
| 163 | ele2.options[ele2.length] = noption; |
---|
| 164 | ele1.options[ele1.selectedIndex] = null; |
---|
| 165 | ele1.selectedIndex = 0; |
---|
| 166 | } |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | |
---|
[564] | 170 | cfilter.prototype.r_rules_form = function(ind, type) |
---|
| 171 | { |
---|
| 172 | var fields = new Array; |
---|
| 173 | var _this = this; |
---|
[2] | 174 | |
---|
| 175 | // hide buttons |
---|
| 176 | Element('form_buttons').style.display = 'none'; |
---|
| 177 | |
---|
[564] | 178 | if( type === 'voip') |
---|
| 179 | { |
---|
| 180 | fields = _this.rulesVoip[ind].split("&&"); |
---|
| 181 | document.getElementById("field9").value = fields[5]; |
---|
[2] | 182 | } |
---|
[564] | 183 | else |
---|
| 184 | { |
---|
| 185 | this.sel_boxes(); |
---|
| 186 | if(this.rulest.length == 0){ |
---|
| 187 | return false; |
---|
[2] | 188 | } |
---|
[564] | 189 | fields = _this.rulest[ind].split("&&"); |
---|
| 190 | document.getElementById("field1").value = fields[3]; |
---|
| 191 | document.getElementById("field2").value = fields[4]; |
---|
| 192 | document.getElementById("field3").value = fields[5]; |
---|
| 193 | document.getElementById("field4").value = fields[11]; |
---|
| 194 | |
---|
| 195 | switch(fields[6]){ |
---|
| 196 | case "folder": |
---|
| 197 | document.getElementById("radio1").checked = true; |
---|
| 198 | var name_mb = fields[7]; |
---|
| 199 | var sel_mb = document.getElementById("select_mailboxes"); |
---|
| 200 | for(var i=0; i < sel_mb.options.length; i++){if((sel_mb.options[i].value) == name_mb){sel_mb.options[i].selected = true;}} |
---|
| 201 | break; |
---|
| 202 | case "address": |
---|
| 203 | document.getElementById("radio2").checked = true; |
---|
| 204 | document.getElementById("field5").value = fields[7]; |
---|
| 205 | break; |
---|
| 206 | case "reject": |
---|
| 207 | document.getElementById("radio3").checked = true; |
---|
| 208 | var text0 = fields[7].split("\\n"); |
---|
| 209 | for(var i=0; i < text0.length; i++){document.getElementById("field6").value += text0[i] + "\n";} |
---|
| 210 | break; |
---|
| 211 | case "discard": |
---|
| 212 | document.getElementById("radio4").checked = true; |
---|
| 213 | break; |
---|
[2] | 214 | } |
---|
[564] | 215 | var mark_values = this.values[fields[8]].split(","); |
---|
| 216 | for(var i=0; i < mark_values.length; i++){ |
---|
| 217 | if( mark_values[i] == "checkBox1" || mark_values[i] == "checkBox2"){ |
---|
| 218 | document.getElementById(mark_values[i]).checked = true; |
---|
| 219 | } |
---|
| 220 | if( mark_values[i] == "select_size=1" || mark_values[i] == "select_rules=1"){ |
---|
| 221 | var mark_val = mark_values[i].split("="); |
---|
| 222 | document.getElementById(mark_val[0]).options[mark_val[1]].selected = true; |
---|
| 223 | } |
---|
| 224 | } |
---|
[2] | 225 | } |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | cfilter.prototype.r_rules_out = function(){ |
---|
| 229 | |
---|
| 230 | var _this = this; |
---|
| 231 | if(_this.out_officeR.length == 0){ |
---|
| 232 | return false; |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | // hide buttons |
---|
| 236 | Element('form_buttons').style.display = 'none'; |
---|
| 237 | |
---|
[197] | 238 | var aux = _this.out_officeR.split("&&"); |
---|
[2] | 239 | var days = aux[1]; |
---|
| 240 | var emails = aux[2]; |
---|
| 241 | var mens = aux[3]; |
---|
| 242 | var p_emails = new Array; |
---|
| 243 | var d_emails = new Array; |
---|
| 244 | |
---|
| 245 | var p_aux = emails.split(", "); |
---|
| 246 | for(var i=0; i < p_aux.length; i++){ |
---|
| 247 | p_emails[i] = p_aux[i].substr(0,(p_aux[i].length - 1)); |
---|
| 248 | p_emails[i] = p_emails[i].substr(1,(p_aux[i].length)); |
---|
| 249 | } |
---|
| 250 | for(var i=0; i < _this.email_ld.length; i++){ |
---|
| 251 | d_emails[i] = _this.email_ld[i]; |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | diff = function(vet, comp){ |
---|
| 255 | var sel1 = new Array; |
---|
| 256 | for(var i=0; i < vet.length; i++){ |
---|
| 257 | for(var j=0; j < comp.length; j++){ |
---|
| 258 | if(vet[i] == comp[j]){ |
---|
| 259 | comp.splice(j,1); |
---|
| 260 | j--; |
---|
| 261 | } |
---|
| 262 | } |
---|
| 263 | } |
---|
| 264 | }; |
---|
| 265 | diff(p_emails,d_emails); |
---|
| 266 | var text = mens.split("\\n"); |
---|
| 267 | for(var i=0; i < text.length; i++){document.getElementById("field8").value += text[i] + " ";} |
---|
| 268 | for(var i=0; i < _this.email_ld.length; i++){ |
---|
| 269 | d_emails[i] = _this.email_ld[i]; |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | } |
---|
| 273 | |
---|
[325] | 274 | /* |
---|
| 275 | * Corrige bug 65, solução: desabilitar radio3 e field6 e desmarcar radio3 (ação de rejeição) |
---|
| 276 | * quando a caixa de seleção para manter o e-mail na caixa de entrada do usuário for selecionada |
---|
| 277 | */ |
---|
[564] | 278 | cfilter.prototype.disable_radio3 = function() |
---|
| 279 | { |
---|
[325] | 280 | radio3 = Element('radio3'); |
---|
| 281 | field6 = Element('field6'); |
---|
| 282 | cb2 = Element('checkBox2'); |
---|
| 283 | |
---|
[564] | 284 | if (cb2.checked) |
---|
| 285 | { |
---|
[325] | 286 | radio3.disabled = true; |
---|
| 287 | field6.disabled = true; |
---|
| 288 | |
---|
[564] | 289 | if (radio3.checked) |
---|
| 290 | { |
---|
[325] | 291 | radio3.checked = false; |
---|
| 292 | } |
---|
| 293 | } |
---|
[564] | 294 | else |
---|
| 295 | { |
---|
[325] | 296 | radio3.disabled = false; |
---|
| 297 | field6.disabled = false; |
---|
| 298 | } |
---|
| 299 | |
---|
| 300 | } |
---|
| 301 | |
---|
[564] | 302 | cfilter.prototype.forms_ = function() |
---|
| 303 | { |
---|
| 304 | var form = ""; |
---|
| 305 | form = "<div id='div_rule' style='display:none'><table id='table_rule' border='0' cellpading='0' cellspacing='0' width='100%'>"+ |
---|
| 306 | "<tr><td colspan='2'><input type='checkBox' id='checkBox1' name='checkb'>"+get_lang('Also check message against next rule') + "</td></tr>"+ |
---|
| 307 | "<tr><td colspan='2'><input type='checkBox' id='checkBox2' onclick='filter.disable_radio3();' name='checkb'>"+get_lang('Keep a copy of the message at your Inbox')+ "</td><tr>"+ |
---|
| 308 | "<tr><td colspan='2'><hr size='1' width='100%'></td></tr><tr>"+ |
---|
| 309 | "<td rowspan='4' width='20%'>"+get_lang('Coincident')+"<br><select id='select_rules' name='select_rules'>"+ |
---|
| 310 | "<option value='0'>"+get_lang("with all")+"</option><option value='1'>"+get_lang("with some")+"</option>"+ |
---|
| 311 | "</select></td><td>"+get_lang('The field \"%1\" of the message it contains',get_lang('From'))+".: <input type='text' id='field1' name='field1' size='35' maxlength='200'></td>"+ |
---|
| 312 | "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('To'))+".: <input type='text' id='field2' name='field2' size='35' maxlength='200'></td>"+ |
---|
| 313 | "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('Subject'))+".: <input type='text' id='field3' name='field3' size='35' maxlength='200'></td>"+ |
---|
| 314 | "</tr><tr><td>"+get_lang('The size of the message is')+".:  <select id='select_size' name='select_size'>"+ |
---|
| 315 | "<option value='0'>"+get_lang("Less than")+"</option><option value='1'>"+get_lang("Greater than")+"</option>"+ |
---|
| 316 | "</select> <input type='text' id='field4' name='field4' size='8' maxlength='8'> Kb</td>"+ |
---|
| 317 | "</tr><tr><td colspan='2'><hr size='1' width='100%'></td></tr>"+ |
---|
| 318 | "</table><table id='table_rule1' border='0' cellpading='0' cellspacing='0' width='100%'>"+ |
---|
| 319 | "<tr><td width='50%'><input type='radio' id='radio1' name='radio' value='folder'>"+get_lang('Store at')+".:</td>"+ |
---|
| 320 | "<td width='50%'><select id='select_mailboxes' name='select_mailboxes'></select></td>"+ |
---|
| 321 | "</tr><tr><td width='50%'><input type='radio' id='radio2' name='radio' value='address'>"+get_lang('Forward to the address')+".:</td>"+ |
---|
| 322 | "<td width='50%'><input type='text' id='field5' name='field5' size='35' maxlength='70'></td>"+ |
---|
| 323 | "</tr><tr><td width='50%'><input type='radio' id='radio3' name='radio' value='reject'>"+get_lang('Send a rejection message')+".:</td>"+ |
---|
| 324 | "<td width='50%'><textarea id='field6' onkeypress='return charCounter(this);' name='field6' rows='3' cols='25'></textarea></td>"+ |
---|
| 325 | "</tr><tr><td colspan='2'><input type='radio' id='radio4' name='radio' value='discard'>"+get_lang('Erase the message')+"</td>"+ |
---|
| 326 | "</tr></table></div><div id='div_vacation' style='display:none'>"+ |
---|
| 327 | "<table id='table_vacation' border='0' cellpading='0' cellspacing='0' width='100%'>"+ |
---|
| 328 | "<tr><td colspan='3'><br><b>"+get_lang('out office')+"</b></td></tr>"+ |
---|
| 329 | //"<tr><td colspan='3'><br>"+get_lang('Subject')+".: <input type='text' id='field7' name='field7' size='35' maxlength='200'/></td></tr>"+ |
---|
| 330 | "<tr><td colspan='3'><br>"+get_lang('With the following message')+".:</td>"+ |
---|
| 331 | "</tr><tr><td colspan='3'><textarea id='field8' onkeypress='return charCounter(this);' rows='8' cols='50'></textarea></td></tr></table></div>" + |
---|
| 332 | "<div id='div_voipFilter' style='display:none'>" + |
---|
| 333 | "<br/><table id='table_voipFilter'>" + |
---|
| 334 | "<tr><td>"+get_lang("Type the subject of the message for receiving a phone warning")+" .:"+ |
---|
| 335 | "</td></tr><tr><td><input type='text' id='field9' size='50' maxlength='200'>" + |
---|
| 336 | "</td></tr><br/></table></div>" + |
---|
| 337 | "<span align='right'><input type='button' value="+get_lang("Back")+" onclick='filter.form_m()'></span>"+ |
---|
| 338 | "<span align='right'><input type='button' value="+get_lang("Save")+" onclick='filter.saved_rules()'></span>"; |
---|
[2] | 339 | return form; |
---|
| 340 | } |
---|
| 341 | |
---|
| 342 | cfilter.prototype.enabled_disabled = function(param){ |
---|
| 343 | |
---|
| 344 | // Rules |
---|
| 345 | if(Element("rule_0") != null){ |
---|
| 346 | for(var i=0; i < this.rulest.length; i++){ |
---|
| 347 | if(Element("rule_"+i).checked){ |
---|
| 348 | var aux_rul = this.rulest[i].split("&&"); |
---|
| 349 | if(aux_rul[2] != param){ |
---|
| 350 | aux_rul[2] = param; |
---|
| 351 | var rl = ""; |
---|
| 352 | for(var j=0; j < aux_rul.length; j++){ |
---|
| 353 | rl += aux_rul[j] + "&&"; |
---|
| 354 | } |
---|
| 355 | rl = rl.substr(0,(rl.length - 2)); |
---|
| 356 | this.rulest[i] = rl; |
---|
| 357 | } |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | // Out Office |
---|
| 362 | if(Element("out_0") != null){ |
---|
| 363 | if(Element("out_0").checked){ |
---|
[197] | 364 | var aux_out = this.out_officeR.split("&&"); |
---|
[2] | 365 | if(param == "ENABLED") |
---|
| 366 | aux_out[4] = "on "; |
---|
| 367 | else |
---|
| 368 | aux_out[4] = "off"; |
---|
| 369 | var out = ""; |
---|
| 370 | for(var i=0; i < aux_out.length; i++){ |
---|
| 371 | out += aux_out[i] + "&&"; |
---|
| 372 | } |
---|
| 373 | out = out.substr(0,(out.length - 2)); |
---|
[197] | 374 | this.out_officeR = out; |
---|
[2] | 375 | } |
---|
| 376 | } |
---|
[564] | 377 | |
---|
| 378 | // Voip |
---|
| 379 | if(Element("voip_rule_0") != null){ |
---|
| 380 | for(var i=0; i < this.rulesVoip.length; i++){ |
---|
| 381 | if(Element("voip_rule_"+i).checked){ |
---|
| 382 | var aux_rul = this.rulesVoip[i].split("&&"); |
---|
| 383 | if(aux_rul[2] != param){ |
---|
| 384 | aux_rul[2] = param; |
---|
| 385 | var rl = ""; |
---|
| 386 | for(var j=0; j < aux_rul.length; j++){ |
---|
| 387 | rl += aux_rul[j] + "&&"; |
---|
| 388 | } |
---|
| 389 | rl = rl.substr(0,(rl.length - 2)); |
---|
| 390 | this.rulesVoip[i] = rl; |
---|
| 391 | } |
---|
| 392 | } |
---|
| 393 | } |
---|
| 394 | } |
---|
| 395 | |
---|
[2] | 396 | this.reload_rules(); |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | cfilter.prototype.new_rule = function(email){ |
---|
| 400 | |
---|
[2666] | 401 | var createFilter = function (param){ |
---|
[2788] | 402 | if (filter.criticalError){ |
---|
| 403 | alert(get_lang('The filters service is out of service, try again later...')); |
---|
| 404 | return false; |
---|
| 405 | } |
---|
[2669] | 406 | if(filter.rulest.length > 0){ |
---|
| 407 | var blockedReg = new RegExp('#rule&&[0-9]+&&ENABLED&&'+param+'&&&&&&discard&&&&0&&&&&&0'); |
---|
| 408 | for(var i=0 ; i < filter.rulest.length; i++){ |
---|
| 409 | if(blockedReg.test(filter.rulest[i])){ |
---|
| 410 | alert(get_lang("Sender blocked")+"!"); |
---|
| 411 | return false; |
---|
| 412 | } |
---|
| 413 | } |
---|
| 414 | } |
---|
[2666] | 415 | if(confirm(get_lang("Do you want to block this e-mail?"))){ |
---|
| 416 | new_r = "&&ENABLED&&" + param + "&&&&&&discard&&&&0&&&&&&0"; |
---|
| 417 | //setTimeout("filter.e_newrule('" + new_r + "')",2000); |
---|
[2669] | 418 | if (filter.e_newrule(new_r)){ |
---|
[2666] | 419 | filter.email_deny.push(param); |
---|
| 420 | write_msg(get_lang("The sender was blocked")); |
---|
| 421 | }else |
---|
| 422 | write_msg(get_lang("You have reached the maximum number of rules")); |
---|
| 423 | } |
---|
| 424 | }; |
---|
[2669] | 425 | if ( filter.rulest.length > 0 ) |
---|
| 426 | createFilter(email); |
---|
| 427 | else |
---|
| 428 | this.load_rules( createFilter, email ); |
---|
[2] | 429 | } |
---|
| 430 | |
---|
[564] | 431 | cfilter.prototype.e_newrule = function(nw_rule) |
---|
| 432 | { |
---|
[2] | 433 | |
---|
| 434 | var new_rl = ""; |
---|
[246] | 435 | if (this.rulest.length >= rules_limit) |
---|
| 436 | return false; |
---|
| 437 | |
---|
[2] | 438 | if(this.rulest.length == 0){ |
---|
| 439 | new_rl = "#rule&&1" + nw_rule; |
---|
| 440 | }else{ |
---|
| 441 | var aux = this.rulest[this.rulest.length -1 ].split("&&"); |
---|
| 442 | new_rl = "#rule&&" + (parseInt(aux[1]) + parseInt(2)) + nw_rule; |
---|
| 443 | } |
---|
| 444 | this.rulest.push(new_rl); |
---|
| 445 | this.saved_all(); |
---|
[246] | 446 | return true; |
---|
[2] | 447 | } |
---|
| 448 | |
---|
| 449 | cfilter.prototype.delete_r = function(){ |
---|
| 450 | |
---|
| 451 | // rule |
---|
| 452 | var _this = this; |
---|
| 453 | if(Element("rule_0") != null){ |
---|
| 454 | for(var i=0; i < _this.rulest.length; i++){ |
---|
| 455 | if(Element("rule_"+i).checked){_this.rulest[i] = "delete";} |
---|
| 456 | } |
---|
| 457 | for(var i=0; i < _this.rulest.length; i++){ |
---|
| 458 | if(_this.rulest[i] == "delete"){_this.rulest.splice(i,1);i--;} |
---|
| 459 | } |
---|
| 460 | } |
---|
| 461 | |
---|
| 462 | if(_this.rulest.length > 0){ |
---|
| 463 | var cont = parseInt(1); |
---|
| 464 | for(var i=0; i < _this.rulest.length ; i++){ |
---|
| 465 | var n_rulest = _this.rulest[i].split("&&"); |
---|
| 466 | n_rulest[1] = cont; |
---|
| 467 | cont = cont + parseInt(2); |
---|
| 468 | var aux = ""; |
---|
| 469 | for(var j=0; j < n_rulest.length; j++){aux += n_rulest[j] + "&&";} |
---|
| 470 | aux = aux.substr(0,(aux.length - 2)); |
---|
| 471 | _this.rulest[i] = aux; |
---|
| 472 | } |
---|
| 473 | } |
---|
| 474 | // out office |
---|
| 475 | if(Element("out_0") != null){ |
---|
[206] | 476 | if(Element("out_0").checked){ |
---|
| 477 | _this.out_officeR =''; |
---|
| 478 | _this.out_officeF = false; |
---|
| 479 | //Save outoffice in prefs: |
---|
[271] | 480 | connector.loadScript("preferences"); |
---|
[206] | 481 | prefe.save("outoffice", _this.out_officeF); |
---|
| 482 | } |
---|
[2] | 483 | } |
---|
[564] | 484 | |
---|
| 485 | // Voip |
---|
| 486 | if(Element("voip_rule_0") != null){ |
---|
| 487 | for(var i=0; i < _this.rulesVoip.length; i++){ |
---|
| 488 | if(Element("voip_rule_"+i).checked){_this.rulesVoip[i] = "delete";} |
---|
| 489 | } |
---|
| 490 | for(var i=0; i < _this.rulesVoip.length; i++){ |
---|
| 491 | if(_this.rulesVoip[i] == "delete"){_this.rulesVoip.splice(i,1);i--;} |
---|
| 492 | } |
---|
| 493 | } |
---|
| 494 | |
---|
| 495 | if(_this.rulesVoip.length > 0){ |
---|
| 496 | var cont = parseInt(1); |
---|
| 497 | for(var i=0; i < _this.rulesVoip.length ; i++){ |
---|
| 498 | var n_rulest = _this.rulesVoip[i].split("&&"); |
---|
| 499 | n_rulest[1] = cont; |
---|
| 500 | cont = cont + parseInt(2); |
---|
| 501 | var aux = ""; |
---|
| 502 | for(var j=0; j < n_rulest.length; j++){aux += n_rulest[j] + "&&";} |
---|
| 503 | aux = aux.substr(0,(aux.length - 2)); |
---|
| 504 | _this.rulesVoip[i] = aux; |
---|
| 505 | } |
---|
| 506 | } |
---|
| 507 | |
---|
[2] | 508 | _this.reload_rules(); |
---|
| 509 | } |
---|
| 510 | |
---|
[564] | 511 | cfilter.prototype.reload_rules = function() |
---|
| 512 | { |
---|
[2] | 513 | this.saved_all(); |
---|
| 514 | Element('form_body').innerHTML = ""; |
---|
| 515 | this.load_rules(); |
---|
[564] | 516 | |
---|
| 517 | if(this.out_officeF) |
---|
| 518 | { |
---|
[197] | 519 | write_msg(get_lang("Attention, you are in out of office mode."), true); |
---|
[564] | 520 | }else{ |
---|
[197] | 521 | clean_msg(); |
---|
| 522 | this.out_officeF = false; |
---|
| 523 | } |
---|
[2] | 524 | filters.mount_list(); |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | cfilter.prototype.saved_rules = function(){ |
---|
| 528 | |
---|
| 529 | var mount_rule = ""; |
---|
| 530 | var form = this.ac_form.split("_"); |
---|
| 531 | var n_rule = ""; |
---|
| 532 | |
---|
[564] | 533 | if(form[1] == "rule") |
---|
| 534 | { |
---|
[2] | 535 | mount_rule = "#rule&&"; |
---|
[564] | 536 | if(form[0] == "new") |
---|
| 537 | { |
---|
[2] | 538 | n_rule = "1&&"; |
---|
[564] | 539 | if(this.rulest.length > 0) |
---|
| 540 | { |
---|
[2] | 541 | aux = this.rulest[this.rulest.length - parseInt(1)].split("&&"); |
---|
| 542 | n_rule = (parseInt(aux[1]) + parseInt(2)) + "&&"; |
---|
| 543 | } |
---|
| 544 | mount_rule += n_rule + "ENABLED&&"; |
---|
[564] | 545 | } |
---|
| 546 | else |
---|
| 547 | { |
---|
[2] | 548 | n_rule = this.rulest[this.ind].split("&&"); |
---|
| 549 | mount_rule += n_rule[1] + "&&"; |
---|
| 550 | mount_rule += n_rule[2] + "&&"; |
---|
| 551 | } |
---|
| 552 | |
---|
[41] | 553 | if(LTrim(Element("field1").value) == "" && LTrim(Element("field2").value) == "" && LTrim(Element("field3").value) == "" && Element("field4").value == "") |
---|
| 554 | { |
---|
[53] | 555 | alert(get_lang("Define some criterion to the fields From, To and Subject with more than 3 characters!")); |
---|
[2] | 556 | return false; |
---|
| 557 | } |
---|
[41] | 558 | |
---|
| 559 | if((LTrim(Element("field1").value).length <= 3) && (LTrim(Element("field2").value).length <= 3) && (LTrim(Element("field3").value).length <= 3 && Element("field4").value == "")){ |
---|
[53] | 560 | alert(get_lang("Define some criterion to the fields From, To and Subject with more than 3 characters!")); |
---|
[2] | 561 | return false; |
---|
| 562 | } |
---|
| 563 | |
---|
| 564 | for(var i=1; i < 4; i++){mount_rule += LTrim(Element("field"+i).value) + "&&";} |
---|
| 565 | var v_checked = false; |
---|
| 566 | if(Element("radio1").checked){ |
---|
| 567 | mount_rule += "folder&&"; |
---|
| 568 | var sel_nameBox = Element("select_mailboxes"); |
---|
| 569 | for(var i=0; i < sel_nameBox.options.length; i++){if(sel_nameBox.options[i].selected == true){mount_rule += sel_nameBox.options[i].value + "&&";}} |
---|
| 570 | v_checked = true; |
---|
| 571 | } |
---|
| 572 | if(Element("radio2").checked){ |
---|
| 573 | mount_rule += "address&&"; |
---|
| 574 | if(Element("field5").value == ""){ |
---|
[53] | 575 | alert(get_lang("Inform a forwarding e-mail!")); |
---|
[2] | 576 | return false; |
---|
| 577 | }else{ |
---|
| 578 | var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i |
---|
| 579 | if(emailReg.test(Element("field5").value)){ |
---|
| 580 | mount_rule += Element("field5").value + "&&"; |
---|
| 581 | }else{ |
---|
[53] | 582 | alert(get_lang("Inform a valid e-mail!")); |
---|
[2] | 583 | return false; |
---|
| 584 | } |
---|
| 585 | } |
---|
| 586 | v_checked = true; |
---|
| 587 | } |
---|
| 588 | if(Element("radio3").checked){ |
---|
| 589 | mount_rule += "reject&&"; |
---|
| 590 | if(Element("field6").value == ""){ |
---|
[53] | 591 | alert(get_lang("Inform a text for rejection!")); |
---|
[2] | 592 | return false; |
---|
| 593 | }else{ |
---|
| 594 | mount_rule += Element("field6").value + "&&"; |
---|
| 595 | } |
---|
| 596 | v_checked = true; |
---|
| 597 | } |
---|
| 598 | if(Element("radio4").checked){ |
---|
| 599 | mount_rule += "discard&&&&"; |
---|
| 600 | v_checked = true; |
---|
| 601 | } |
---|
| 602 | if(!v_checked){ |
---|
[53] | 603 | alert(get_lang("No option marked!")); |
---|
[2] | 604 | return false; |
---|
| 605 | } |
---|
| 606 | var opts = ""; |
---|
| 607 | if(Element("checkBox1").checked == true){opts += ",checkBox1";} |
---|
| 608 | if(Element("checkBox2").checked == true){opts += ",checkBox2";} |
---|
| 609 | if(Element("select_size").options[1].selected == true){opts += ",select_size=1";} |
---|
| 610 | if(Element("select_rules").options[1].selected == true){opts += ",select_rules=1";} |
---|
| 611 | for(var i=0; i < this.values.length; i++){if(this.values[i] == opts){mount_rule += i + "&&";}} |
---|
| 612 | mount_rule += "&&&&"; |
---|
| 613 | if(LTrim(Element("field4").value) != ""){ |
---|
| 614 | mount_rule += LTrim(Element("field4").value); |
---|
| 615 | }else{ |
---|
| 616 | mount_rule += 0; |
---|
| 617 | } |
---|
| 618 | if(form[0] == "new") |
---|
[564] | 619 | { |
---|
[2] | 620 | this.rulest[this.rulest.length] = mount_rule; |
---|
[564] | 621 | } |
---|
[2] | 622 | else |
---|
| 623 | this.rulest[this.ind] = mount_rule; |
---|
[564] | 624 | } |
---|
| 625 | else if(form[1] == "out") |
---|
| 626 | { |
---|
[2] | 627 | mount_rule = ""; |
---|
[197] | 628 | var fld_emails = this.email_ld; // Get first email of list! |
---|
[2] | 629 | var fld_men = Element("field8"); |
---|
| 630 | mount_rule = "#vacation&&"; |
---|
[197] | 631 | mount_rule += "1&&"; |
---|
| 632 | mount_rule += "\"" + fld_emails + "\", "; |
---|
| 633 | mount_rule = mount_rule.substr(0,(mount_rule.length - 2)); |
---|
| 634 | mount_rule += "&&"; |
---|
| 635 | mount_rule += fld_men.value + "&&on"; |
---|
[2] | 636 | if(LTrim(fld_men.value) == ""){ |
---|
[53] | 637 | alert(get_lang("Inform a message!")); |
---|
[2] | 638 | return false; |
---|
| 639 | } |
---|
[197] | 640 | this.out_officeR = mount_rule; |
---|
[2] | 641 | } |
---|
[564] | 642 | else if(form[1] == "voip") |
---|
| 643 | { |
---|
| 644 | if( Element("field9").value != "" && LTrim(Element("field9").value) != "" ) |
---|
| 645 | { |
---|
| 646 | mount_rule = "#rule&&"; |
---|
| 647 | if(form[0] == "new") |
---|
| 648 | { |
---|
| 649 | n_rule = "1&&"; |
---|
| 650 | if( this.rulesVoip.length > 0 ) |
---|
| 651 | { |
---|
| 652 | aux = this.rulesVoip[this.rulesVoip.length - parseInt(1)].split("&&"); |
---|
| 653 | n_rule = (parseInt(aux[1]) + parseInt(2)) + "&&"; |
---|
| 654 | } |
---|
| 655 | mount_rule += n_rule + "ENABLED&&"; |
---|
| 656 | } |
---|
| 657 | else |
---|
| 658 | { |
---|
| 659 | n_rule = this.rulesVoip[this.ind].split("&&"); |
---|
| 660 | mount_rule += n_rule[1] + "&&"; |
---|
| 661 | mount_rule += n_rule[2] + "&&"; |
---|
| 662 | } |
---|
| 663 | |
---|
| 664 | if ( Element("field9").value.indexOf("#") >= 0 ) |
---|
| 665 | { |
---|
| 666 | alert(get_lang('Caracter "#" is not allowed!')); |
---|
| 667 | return false; |
---|
| 668 | } |
---|
| 669 | |
---|
| 670 | mount_rule = mount_rule + "&&&&" + Element("field9").value + "&¬ify&&" + preferences.voip_email_redirect + "&&8&&&&&&0"; |
---|
| 671 | |
---|
| 672 | if( form[0] == "new" ) |
---|
| 673 | { |
---|
| 674 | this.rulesVoip[this.rulesVoip.length] = mount_rule; |
---|
| 675 | } |
---|
| 676 | else |
---|
| 677 | { |
---|
| 678 | this.rulesVoip[this.ind] = mount_rule; |
---|
| 679 | } |
---|
| 680 | } |
---|
| 681 | else |
---|
| 682 | { |
---|
| 683 | alert( 'CAMPOS EM BRANCO !!' ); |
---|
| 684 | return false; |
---|
| 685 | } |
---|
| 686 | } |
---|
| 687 | |
---|
[2] | 688 | Element('form_buttons').style.display = ''; |
---|
| 689 | this.reload_rules(); |
---|
| 690 | } |
---|
| 691 | |
---|
[564] | 692 | cfilter.prototype.close_frm= function() |
---|
| 693 | { |
---|
[2] | 694 | filters.filter_Sh['window_ffilter_ccform'].close(); |
---|
| 695 | } |
---|
| 696 | |
---|
[564] | 697 | cfilter.prototype.saved_all = function() |
---|
| 698 | { |
---|
[2] | 699 | var aux_rul = ""; |
---|
| 700 | var _this = this; |
---|
[564] | 701 | var cont = 0; |
---|
| 702 | |
---|
| 703 | // Regras Gerais |
---|
| 704 | if(_this.rulest.length > 0) |
---|
| 705 | { |
---|
| 706 | for(var i=0; i < _this.rulest.length; i++) |
---|
| 707 | { |
---|
| 708 | var fieldsNormal = _this.rulest[i].split("&&"); |
---|
[2] | 709 | aux_rul += "_begin_##"; |
---|
[564] | 710 | for(var j=0 ; j < fieldsNormal.length; j++) |
---|
| 711 | { |
---|
| 712 | aux_rul += url_encode(fieldsNormal[j]) + "##"; |
---|
| 713 | cont = parseInt(fieldsNormal[1]); |
---|
[2] | 714 | } |
---|
| 715 | aux_rul += "_end_\n"; |
---|
| 716 | } |
---|
| 717 | } |
---|
[564] | 718 | |
---|
| 719 | // Voip |
---|
| 720 | if(_this.rulesVoip.length > 0) |
---|
| 721 | { |
---|
| 722 | for(var i=0; i < _this.rulesVoip.length; i++) |
---|
| 723 | { |
---|
| 724 | var fieldsVoip = _this.rulesVoip[i].split("&&"); |
---|
| 725 | aux_rul += "_begin_##"; |
---|
| 726 | for(var j=0 ; j < fieldsVoip.length; j++) |
---|
| 727 | { |
---|
| 728 | if(j == 1) |
---|
| 729 | { |
---|
| 730 | if( cont == 0 ) |
---|
| 731 | cont = parseInt(1); |
---|
| 732 | else |
---|
| 733 | cont = parseInt(cont) + parseInt(2); |
---|
| 734 | aux_rul += cont; |
---|
| 735 | aux_rul += "##"; |
---|
| 736 | } |
---|
| 737 | else |
---|
| 738 | aux_rul += url_encode(fieldsVoip[j]) + "##"; |
---|
| 739 | } |
---|
| 740 | aux_rul += "_end_\n"; |
---|
| 741 | } |
---|
| 742 | } |
---|
| 743 | |
---|
| 744 | // Fora do Escritório |
---|
| 745 | if(_this.out_officeR.length > 0) |
---|
| 746 | { |
---|
[197] | 747 | var aux = _this.out_officeR.split("&&"); |
---|
[2] | 748 | aux_rul += "_begin_##"; |
---|
[564] | 749 | for(var j=0 ; j < aux.length; j++) |
---|
| 750 | { |
---|
| 751 | aux_rul += url_encode(aux[j]) + "##"; |
---|
[2] | 752 | } |
---|
| 753 | aux_rul += "_end_\n"; |
---|
[564] | 754 | _this.out_officeF = (aux[4].replace("\n","") === "off") ? false : true; |
---|
[206] | 755 | //Save outoffice in prefs: |
---|
[271] | 756 | connector.loadScript("preferences"); |
---|
[206] | 757 | prefe.save("outoffice", _this.out_officeF); |
---|
[2] | 758 | } |
---|
[564] | 759 | |
---|
| 760 | var h_filter = function(data) |
---|
| 761 | { |
---|
[2] | 762 | if(data != "Ok"){alert("Erro : \n" + data);} |
---|
| 763 | } |
---|
| 764 | var args = "$this.ScriptS.rec_rules"; |
---|
| 765 | var params = "arfilter="+aux_rul; |
---|
[2658] | 766 | if(!_this.criticalError) |
---|
| 767 | cExecute(args,h_filter,params); |
---|
[2] | 768 | } |
---|
| 769 | |
---|
| 770 | // build object |
---|
| 771 | var filter; |
---|
[689] | 772 | filter = new cfilter(); |
---|