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