[2] | 1 | function cfilter(){ |
---|
| 2 | |
---|
| 3 | this.mode_in = ""; |
---|
| 4 | this.rulest = new Array; |
---|
| 5 | this.out_officeR = new Array; |
---|
| 6 | this.email_deny = new Array; |
---|
| 7 | this.ac_form = ""; |
---|
| 8 | this.ind = ""; |
---|
| 9 | this.email_deny = new Array; |
---|
| 10 | this.email_ld = new Array; |
---|
| 11 | this.values = new Array("", |
---|
| 12 | ",checkBox1", |
---|
| 13 | ",select_size=1", |
---|
| 14 | ",checkBox1,select_size=1", |
---|
| 15 | ",select_rules=1", |
---|
| 16 | ",checkBox1,select_rules=1", |
---|
| 17 | ",select_size=1,select_rules=1", |
---|
| 18 | ",checkBox1,select_size=1,select_rules=1", |
---|
| 19 | ",checkBox2", |
---|
| 20 | ",checkBox1,checkBox2", |
---|
| 21 | ",checkBox2,select_size=1", |
---|
| 22 | ",ckeckBox1,checkBox2,select_size=1", |
---|
| 23 | ",checkBox2,select_rules=1", |
---|
| 24 | ",checkBox1,checkBox2,select_rules=1", |
---|
| 25 | ",checkBox2,select_size=1,select_rules=1", |
---|
| 26 | ",checkBox1,checkBox2,select_size=1,select_rules=1"); |
---|
| 27 | this.BoxSelection = new Array("select_2,select_1","select_1,select_2"); |
---|
| 28 | |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | cfilter.prototype.load_rules = function(){ |
---|
| 32 | var _this = this; |
---|
| 33 | if(_this.rulest.length == 0){ |
---|
| 34 | var handler_sieve = function(data){ |
---|
| 35 | if(data.rule.length > 0){ |
---|
| 36 | for(var i=0 ; i < data.rule.length; i++){ |
---|
| 37 | _this.rulest[_this.rulest.length] = data.rule[i]; |
---|
| 38 | } |
---|
| 39 | } |
---|
| 40 | if(data.vacation.length > 0){_this.out_officeR[0] = data.vacation[0];} |
---|
| 41 | if(data.mode.length > 0){_this.mode_in = data.mode[0];} |
---|
| 42 | } |
---|
| 43 | if(Element('form_status') != null) |
---|
| 44 | Element('form_status').innerHTML = "<span style='background:#cc4444;'> <font color='WHITE'>Aguarde...</font> </span>"; |
---|
| 45 | cExecute("$this.ScriptS.init_a",handler_sieve); |
---|
| 46 | _this.email_ldap(); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | cfilter.prototype.form_m = function(){ |
---|
| 51 | Element('form_body').innerHTML = ""; |
---|
| 52 | Element('form_buttons').style.display = ''; |
---|
| 53 | filters.mount_list(); |
---|
| 54 | this.ac_form = ""; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | cfilter.prototype.form_out = function(){ |
---|
| 58 | Element('form_body').innerHTML = ""; |
---|
| 59 | Element('form_body').innerHTML = this.forms_(); |
---|
| 60 | Element('div_vacation').style.display = ""; |
---|
| 61 | this.ac_form = "old_out"; |
---|
| 62 | this.r_rules_out(); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | cfilter.prototype.form_r = function(pos){ |
---|
| 66 | Element('form_body').innerHTML = ""; |
---|
| 67 | Element('form_body').innerHTML = this.forms_(); |
---|
| 68 | Element('div_rule').style.display = ""; |
---|
| 69 | this.ac_form = "old_rule"; |
---|
| 70 | this.ind = pos; |
---|
| 71 | this.r_rules_form(pos); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | cfilter.prototype.email_ldap = function(){ |
---|
| 75 | var _this = this; |
---|
| 76 | var handler_ldap = function(data){ |
---|
| 77 | _this.email_ld[0] = data.mail != "" ? data.mail: ""; |
---|
| 78 | _this.email_ld[1] = data.mailalter != "" ? data.mailalter: ""; |
---|
| 79 | } |
---|
| 80 | cExecute("$this.ldap_functions.get_emails_ldap",handler_ldap); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | cfilter.prototype.sel_boxes = function(){ |
---|
| 84 | var nm_folders = tree_folders.getNodesList(cyrus_delimiter); |
---|
| 85 | if(document.getElementById("select_mailboxes") != null){ |
---|
| 86 | var sel_nm = document.getElementById("select_mailboxes"); |
---|
| 87 | if(sel_nm.length > 0 ){ |
---|
| 88 | for(var i=0; i < sel_nm.options.length; i++){ |
---|
| 89 | sel_nm.options[i] = null; |
---|
| 90 | i--; |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | for(var i=0; i < nm_folders.length; i++){ |
---|
| 94 | if(nm_folders[i].id != "root"){ |
---|
| 95 | var opt = new Option(nm_folders[i].caption,nm_folders[i].id,false,true); |
---|
| 96 | sel_nm[sel_nm.length] = opt; |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | sel_nm[0].selected = true; |
---|
| 100 | } |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | cfilter.prototype.box_select = function(param){ |
---|
| 104 | var aux = this.BoxSelection[param].split(","); |
---|
| 105 | var ele1 = document.getElementById(aux[0]); |
---|
| 106 | var ele2 = document.getElementById(aux[1]); |
---|
| 107 | var noption = ""; |
---|
| 108 | if(param == 0 || param == 1){ |
---|
| 109 | if(ele1.selectedIndex != -1){ |
---|
| 110 | noption = new Option(ele1.value,ele1.value,false,false); |
---|
| 111 | ele2.options[ele2.length] = noption; |
---|
| 112 | ele1.options[ele1.selectedIndex] = null; |
---|
| 113 | ele1.selectedIndex = 0; |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | cfilter.prototype.r_rules_form = function(ind){ |
---|
| 119 | |
---|
| 120 | // hide buttons |
---|
| 121 | Element('form_buttons').style.display = 'none'; |
---|
| 122 | |
---|
| 123 | this.sel_boxes(); |
---|
| 124 | var aux = new Array; |
---|
| 125 | var _this = this; |
---|
| 126 | if(this.rulest.length == 0){ |
---|
| 127 | return false; |
---|
| 128 | } |
---|
| 129 | aux = _this.rulest[ind].split("&&"); |
---|
| 130 | document.getElementById("field1").value = aux[3]; |
---|
| 131 | document.getElementById("field2").value = aux[4]; |
---|
| 132 | document.getElementById("field3").value = aux[5]; |
---|
| 133 | document.getElementById("field4").value = aux[11]; |
---|
| 134 | |
---|
| 135 | switch(aux[6]){ |
---|
| 136 | case "folder": |
---|
| 137 | document.getElementById("radio1").checked = true; |
---|
| 138 | var name_mb = aux[7]; |
---|
| 139 | var sel_mb = document.getElementById("select_mailboxes"); |
---|
| 140 | for(var i=0; i < sel_mb.options.length; i++){if((sel_mb.options[i].value) == name_mb){sel_mb.options[i].selected = true;}} |
---|
| 141 | break; |
---|
| 142 | case "address": |
---|
| 143 | document.getElementById("radio2").checked = true; |
---|
| 144 | document.getElementById("field5").value = aux[7]; |
---|
| 145 | break; |
---|
| 146 | case "reject": |
---|
| 147 | document.getElementById("radio3").checked = true; |
---|
| 148 | var text0 = aux[7].split("\\n"); |
---|
| 149 | for(var i=0; i < text0.length; i++){document.getElementById("field6").value += text0[i] + "\n";} |
---|
| 150 | break; |
---|
| 151 | case "discard": |
---|
| 152 | document.getElementById("radio4").checked = true; |
---|
| 153 | break; |
---|
| 154 | } |
---|
| 155 | var mark_values = this.values[aux[8]].split(","); |
---|
| 156 | for(var i=0; i < mark_values.length; i++){ |
---|
| 157 | if( mark_values[i] == "checkBox1" || mark_values[i] == "checkBox2"){ |
---|
| 158 | document.getElementById(mark_values[i]).checked = true; |
---|
| 159 | } |
---|
| 160 | if( mark_values[i] == "select_size=1" || mark_values[i] == "select_rules=1"){ |
---|
| 161 | var mark_val = mark_values[i].split("="); |
---|
| 162 | document.getElementById(mark_val[0]).options[mark_val[1]].selected = true; |
---|
| 163 | } |
---|
| 164 | } |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | cfilter.prototype.r_rules_out = function(){ |
---|
| 168 | |
---|
| 169 | var _this = this; |
---|
| 170 | if(_this.out_officeR.length == 0){ |
---|
| 171 | return false; |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | // hide buttons |
---|
| 175 | Element('form_buttons').style.display = 'none'; |
---|
| 176 | |
---|
| 177 | var aux = _this.out_officeR[0].split("&&"); |
---|
| 178 | var days = aux[1]; |
---|
| 179 | var emails = aux[2]; |
---|
| 180 | var mens = aux[3]; |
---|
| 181 | var p_emails = new Array; |
---|
| 182 | var d_emails = new Array; |
---|
| 183 | |
---|
| 184 | var p_aux = emails.split(", "); |
---|
| 185 | for(var i=0; i < p_aux.length; i++){ |
---|
| 186 | p_emails[i] = p_aux[i].substr(0,(p_aux[i].length - 1)); |
---|
| 187 | p_emails[i] = p_emails[i].substr(1,(p_aux[i].length)); |
---|
| 188 | } |
---|
| 189 | for(var i=0; i < _this.email_ld.length; i++){ |
---|
| 190 | d_emails[i] = _this.email_ld[i]; |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | var el = document.getElementById("select_1"); |
---|
| 194 | var el2 = document.getElementById("select_2"); |
---|
| 195 | |
---|
| 196 | diff = function(vet, comp){ |
---|
| 197 | var sel1 = new Array; |
---|
| 198 | for(var i=0; i < vet.length; i++){ |
---|
| 199 | for(var j=0; j < comp.length; j++){ |
---|
| 200 | if(vet[i] == comp[j]){ |
---|
| 201 | comp.splice(j,1); |
---|
| 202 | j--; |
---|
| 203 | } |
---|
| 204 | } |
---|
| 205 | } |
---|
| 206 | var el1 = document.getElementById("select_1"); |
---|
| 207 | var el2 = document.getElementById("select_2"); |
---|
| 208 | for(var i=0; i < vet.length; i++){ |
---|
| 209 | var opt = new Option(vet[i],vet[i],false,false); |
---|
| 210 | el1.options[el1.length] = opt; |
---|
| 211 | } |
---|
| 212 | for(var i=0; i < comp.length; i++){ |
---|
| 213 | var opt = new Option(comp[i],comp[i],false,false); |
---|
| 214 | el2.options[el2.length] = opt; |
---|
| 215 | } |
---|
| 216 | }; |
---|
| 217 | diff(p_emails,d_emails); |
---|
| 218 | document.getElementById("select_days").value = days; |
---|
| 219 | var text = mens.split("\\n"); |
---|
| 220 | for(var i=0; i < text.length; i++){document.getElementById("field8").value += text[i] + " ";} |
---|
| 221 | for(var i=0; i < _this.email_ld.length; i++){ |
---|
| 222 | d_emails[i] = _this.email_ld[i]; |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | cfilter.prototype.forms_ = function(){ |
---|
| 228 | var form = ""; |
---|
| 229 | form = "<div id='div_rule' style='display:none'><table id='table_rule' border='0' cellpading='0' cellspacing='0' width='100%'>"+ |
---|
| 230 | "<tr><td colspan='2'><input type='checkBox' id='checkBox1' name='checkb'>"+get_lang('To also check message against next rule') + "</td></tr>"+ |
---|
| 231 | "<tr><td colspan='2'><input type='checkBox' id='checkBox2' name='checkb'>"+get_lang('To keep a copy of the message in its Box of Entrance')+ "</td><tr>"+ |
---|
| 232 | "<tr><td colspan='2'><hr size='1' width='100%'></td></tr><tr>"+ |
---|
| 233 | "<td rowspan='4' width='20%'>"+get_lang('Coincident')+"<br><select id='select_rules' name='select_rules'>"+ |
---|
| 234 | "<option value='0'>com todas</option><option value='1'>com algumas</option>"+ |
---|
| 235 | "</select></td><td>"+get_lang('The field \"From:\" of the message it contains')+".: <input type='text' id='field1' name='field1' size='35' maxlength='200'></td>"+ |
---|
| 236 | "</tr><tr><td>"+get_lang('The field \"To: \" of the message it contains')+".: <input type='text' id='field2' name='field2' size='35' maxlength='200'></td>"+ |
---|
| 237 | "</tr><tr><td>"+get_lang('The field \"Subject: \" of the message it contains')+".: <input type='text' id='field3' name='field3' size='35' maxlength='200'></td>"+ |
---|
| 238 | "</tr><tr><td>"+get_lang('The size of the message is')+".:  <select id='select_size' name='select_size'>"+ |
---|
| 239 | "<option value='0'>Menor que</option><option value='1'>Maior que</option>"+ |
---|
| 240 | "</select> <input type='text' id='field4' name='field4' size='8' maxlength='8'> Kb</td>"+ |
---|
| 241 | "</tr><tr><td colspan='2'><hr size='1' width='100%'></td></tr>"+ |
---|
| 242 | "</table><table id='table_rule1' border='0' cellpading='0' cellspacing='0' width='100%'>"+ |
---|
| 243 | "<tr><td width='50%'><input type='radio' id='radio1' name='radio' value='folder'>"+get_lang('To file')+".:</td>"+ |
---|
| 244 | "<td width='50%'><select id='select_mailboxes' name='select_mailboxes'></select></td>"+ |
---|
| 245 | "</tr><tr><td width='50%'><input type='radio' id='radio2' name='radio' value='address'>"+get_lang('It directs for the address')+".:</td>"+ |
---|
| 246 | "<td width='50%'><input type='text' id='field5' name='field5' size='35' maxlength='70'></td>"+ |
---|
| 247 | "</tr><tr><td width='50%'><input type='radio' id='radio3' name='radio' value='reject'>"+get_lang('It sends a rejection message')+".:</td>"+ |
---|
| 248 | "<td width='50%'><textarea id='field6' name='field6' rows='3' cols='25'></textarea></td>"+ |
---|
| 249 | "</tr><tr><td colspan='2'><input type='radio' id='radio4' name='radio' value='discard'>"+get_lang('It erases the message')+"</td>"+ |
---|
| 250 | "</tr></table></div><div id='div_vacation' style='display:none'>"+ |
---|
| 251 | "<table id='table_vacation' border='0' cellpading='0' cellspacing='0' width='100%'>"+ |
---|
| 252 | "<tr><td width='40%' valign='top'>"+get_lang('To answer messages sent')+":<select multiple id='select_1' name='select_1' size='6' style='width:250px'></select></td>"+ |
---|
| 253 | "<td width='8%'><table border='0' cellpading='0' cellspacing='0' width='100%'>"+ |
---|
| 254 | "<tr><td align='right' valign='top'><br><a href=javascript:void(0) onclick='filter.box_select(0);'><<</a> <br><br></td>"+ |
---|
| 255 | "</tr><tr><td align='left' valign='middle'><br><br> <a href=javascript:void(0) onclick='filter.box_select(1);'>>></a> <br></td>"+ |
---|
| 256 | "</tr></table></td><td width='52%' valign='top'>"+get_lang('Emails of the account')+":<br><select multiple id='select_2' name='select_2' size='6' style='width:250px'></select>"+ |
---|
| 257 | "</td></tr><tr><td colspan='3'><hr size='1' width='100%'></td>"+ |
---|
| 258 | "</tr><tr><td colspan='3'>"+get_lang('During (days are of the office)')+": <input type='text' id='select_days' size='3'> "+get_lang('day(s)')+"</td>"+ |
---|
| 259 | "</tr><tr><td colspan='3'><hr size='1' width='100%'></td></tr><tr><td colspan='3'>"+get_lang('With the following message')+".:</td>"+ |
---|
| 260 | "</tr><tr><td colspan='3'><textarea id='field8' rows='3' cols='50'></textarea></td></tr></table></div>"+ |
---|
| 261 | "<span align='right'><input type='button' value="+get_lang("to come back")+" onclick='filter.form_m()'></span>"+ |
---|
| 262 | "<span align='right'><input type='button' value="+get_lang("to save")+" onclick='filter.saved_rules()'></span>"; |
---|
| 263 | return form; |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | cfilter.prototype.enabled_disabled = function(param){ |
---|
| 267 | |
---|
| 268 | // Rules |
---|
| 269 | if(Element("rule_0") != null){ |
---|
| 270 | for(var i=0; i < this.rulest.length; i++){ |
---|
| 271 | if(Element("rule_"+i).checked){ |
---|
| 272 | var aux_rul = this.rulest[i].split("&&"); |
---|
| 273 | if(aux_rul[2] != param){ |
---|
| 274 | aux_rul[2] = param; |
---|
| 275 | var rl = ""; |
---|
| 276 | for(var j=0; j < aux_rul.length; j++){ |
---|
| 277 | rl += aux_rul[j] + "&&"; |
---|
| 278 | } |
---|
| 279 | rl = rl.substr(0,(rl.length - 2)); |
---|
| 280 | this.rulest[i] = rl; |
---|
| 281 | } |
---|
| 282 | } |
---|
| 283 | } |
---|
| 284 | } |
---|
| 285 | // Out Office |
---|
| 286 | if(Element("out_0") != null){ |
---|
| 287 | if(Element("out_0").checked){ |
---|
| 288 | var aux_out = this.out_officeR[0].split("&&"); |
---|
| 289 | if(param == "ENABLED") |
---|
| 290 | aux_out[4] = "on "; |
---|
| 291 | else |
---|
| 292 | aux_out[4] = "off"; |
---|
| 293 | var out = ""; |
---|
| 294 | for(var i=0; i < aux_out.length; i++){ |
---|
| 295 | out += aux_out[i] + "&&"; |
---|
| 296 | } |
---|
| 297 | out = out.substr(0,(out.length - 2)); |
---|
| 298 | this.out_officeR[0] = out; |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | this.reload_rules(); |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | cfilter.prototype.new_rule = function(email){ |
---|
| 305 | |
---|
| 306 | if(this.email_deny.length > 0){ |
---|
| 307 | for(var i=0 ; i < this.email_deny.length; i++){ |
---|
| 308 | if(this.email_deny[i] == email){ |
---|
| 309 | alert("Remetente bloqueado!"); |
---|
| 310 | return false; |
---|
| 311 | } |
---|
| 312 | } |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | // Verifica Email |
---|
| 316 | var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i |
---|
| 317 | if(!emailReg.test(email)){ |
---|
| 318 | alert(get_lang("It informs a valid email!")); |
---|
| 319 | return false; |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | this.load_rules(); |
---|
| 323 | if(confirm("Deseja bloquear este email?")){ |
---|
| 324 | new_r = "&&ENABLED&&" + email + "&&&&&&discard&&&&0&&&&&&0"; |
---|
| 325 | setTimeout("filter.e_newrule('" + new_r + "')",2000); |
---|
| 326 | this.email_deny.push(email); |
---|
| 327 | write_msg("Este remetente foi bloqueado."); |
---|
| 328 | } |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | cfilter.prototype.e_newrule = function(nw_rule){ |
---|
| 332 | |
---|
| 333 | var new_rl = ""; |
---|
| 334 | if(this.rulest.length == 0){ |
---|
| 335 | new_rl = "#rule&&1" + nw_rule; |
---|
| 336 | }else{ |
---|
| 337 | var aux = this.rulest[this.rulest.length -1 ].split("&&"); |
---|
| 338 | new_rl = "#rule&&" + (parseInt(aux[1]) + parseInt(2)) + nw_rule; |
---|
| 339 | } |
---|
| 340 | this.rulest.push(new_rl); |
---|
| 341 | this.saved_all(); |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | cfilter.prototype.delete_r = function(){ |
---|
| 345 | |
---|
| 346 | // rule |
---|
| 347 | var _this = this; |
---|
| 348 | if(Element("rule_0") != null){ |
---|
| 349 | for(var i=0; i < _this.rulest.length; i++){ |
---|
| 350 | if(Element("rule_"+i).checked){_this.rulest[i] = "delete";} |
---|
| 351 | } |
---|
| 352 | for(var i=0; i < _this.rulest.length; i++){ |
---|
| 353 | if(_this.rulest[i] == "delete"){_this.rulest.splice(i,1);i--;} |
---|
| 354 | } |
---|
| 355 | } |
---|
| 356 | |
---|
| 357 | if(_this.rulest.length > 0){ |
---|
| 358 | var cont = parseInt(1); |
---|
| 359 | for(var i=0; i < _this.rulest.length ; i++){ |
---|
| 360 | var n_rulest = _this.rulest[i].split("&&"); |
---|
| 361 | n_rulest[1] = cont; |
---|
| 362 | cont = cont + parseInt(2); |
---|
| 363 | var aux = ""; |
---|
| 364 | for(var j=0; j < n_rulest.length; j++){aux += n_rulest[j] + "&&";} |
---|
| 365 | aux = aux.substr(0,(aux.length - 2)); |
---|
| 366 | _this.rulest[i] = aux; |
---|
| 367 | } |
---|
| 368 | } |
---|
| 369 | // out office |
---|
| 370 | if(Element("out_0") != null){ |
---|
| 371 | if(Element("out_0").checked){_this.out_officeR.splice(0,1);} |
---|
| 372 | } |
---|
| 373 | _this.reload_rules(); |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | cfilter.prototype.reload_rules = function(){ |
---|
| 377 | this.saved_all(); |
---|
| 378 | Element('form_body').innerHTML = ""; |
---|
| 379 | this.load_rules(); |
---|
| 380 | filters.mount_list(); |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | cfilter.prototype.saved_rules = function(){ |
---|
| 384 | |
---|
| 385 | var mount_rule = ""; |
---|
| 386 | var form = this.ac_form.split("_"); |
---|
| 387 | var n_rule = ""; |
---|
| 388 | |
---|
| 389 | if(form[1] == "rule"){ |
---|
| 390 | mount_rule = "#rule&&"; |
---|
| 391 | if(form[0] == "new"){ |
---|
| 392 | n_rule = "1&&"; |
---|
| 393 | if(this.rulest.length > 0){ |
---|
| 394 | aux = this.rulest[this.rulest.length - parseInt(1)].split("&&"); |
---|
| 395 | n_rule = (parseInt(aux[1]) + parseInt(2)) + "&&"; |
---|
| 396 | } |
---|
| 397 | mount_rule += n_rule + "ENABLED&&"; |
---|
| 398 | }else{ |
---|
| 399 | n_rule = this.rulest[this.ind].split("&&"); |
---|
| 400 | mount_rule += n_rule[1] + "&&"; |
---|
| 401 | mount_rule += n_rule[2] + "&&"; |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | if(LTrim(Element("field1").value) == "" && LTrim(Element("field2").value) == "" && LTrim(Element("field3").value) == ""){ |
---|
| 405 | alert(get_lang("It defines criteria for the fields From, To and Subject with more than 3 characters!")); |
---|
| 406 | return false; |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | if((LTrim(Element("field1").value).length <= 3) && (LTrim(Element("field2").value).length <= 3) && (LTrim(Element("field3").value).length <= 3)){ |
---|
| 410 | alert(get_lang("It defines criteria for the fields From, To and Subject with more than 3 characters!")); |
---|
| 411 | return false; |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | for(var i=1; i < 4; i++){mount_rule += LTrim(Element("field"+i).value) + "&&";} |
---|
| 415 | var v_checked = false; |
---|
| 416 | if(Element("radio1").checked){ |
---|
| 417 | mount_rule += "folder&&"; |
---|
| 418 | var sel_nameBox = Element("select_mailboxes"); |
---|
| 419 | for(var i=0; i < sel_nameBox.options.length; i++){if(sel_nameBox.options[i].selected == true){mount_rule += sel_nameBox.options[i].value + "&&";}} |
---|
| 420 | v_checked = true; |
---|
| 421 | } |
---|
| 422 | if(Element("radio2").checked){ |
---|
| 423 | mount_rule += "address&&"; |
---|
| 424 | if(Element("field5").value == ""){ |
---|
| 425 | alert(get_lang("It informs a guiding email!")); |
---|
| 426 | return false; |
---|
| 427 | }else{ |
---|
| 428 | var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i |
---|
| 429 | if(emailReg.test(Element("field5").value)){ |
---|
| 430 | mount_rule += Element("field5").value + "&&"; |
---|
| 431 | }else{ |
---|
| 432 | alert(get_lang("It informs a valid email!")); |
---|
| 433 | return false; |
---|
| 434 | } |
---|
| 435 | } |
---|
| 436 | v_checked = true; |
---|
| 437 | } |
---|
| 438 | if(Element("radio3").checked){ |
---|
| 439 | mount_rule += "reject&&"; |
---|
| 440 | if(Element("field6").value == ""){ |
---|
| 441 | alert(get_lang("It informs a text for rejection!")); |
---|
| 442 | return false; |
---|
| 443 | }else{ |
---|
| 444 | mount_rule += Element("field6").value + "&&"; |
---|
| 445 | } |
---|
| 446 | v_checked = true; |
---|
| 447 | } |
---|
| 448 | if(Element("radio4").checked){ |
---|
| 449 | mount_rule += "discard&&&&"; |
---|
| 450 | v_checked = true; |
---|
| 451 | } |
---|
| 452 | if(!v_checked){ |
---|
| 453 | alert(get_lang("No option was not marked!")); |
---|
| 454 | return false; |
---|
| 455 | } |
---|
| 456 | var opts = ""; |
---|
| 457 | if(Element("checkBox1").checked == true){opts += ",checkBox1";} |
---|
| 458 | if(Element("checkBox2").checked == true){opts += ",checkBox2";} |
---|
| 459 | if(Element("select_size").options[1].selected == true){opts += ",select_size=1";} |
---|
| 460 | if(Element("select_rules").options[1].selected == true){opts += ",select_rules=1";} |
---|
| 461 | for(var i=0; i < this.values.length; i++){if(this.values[i] == opts){mount_rule += i + "&&";}} |
---|
| 462 | mount_rule += "&&&&"; |
---|
| 463 | if(LTrim(Element("field4").value) != ""){ |
---|
| 464 | mount_rule += LTrim(Element("field4").value); |
---|
| 465 | }else{ |
---|
| 466 | mount_rule += 0; |
---|
| 467 | } |
---|
| 468 | if(form[0] == "new") |
---|
| 469 | this.rulest[this.rulest.length] = mount_rule; |
---|
| 470 | else |
---|
| 471 | this.rulest[this.ind] = mount_rule; |
---|
| 472 | }else{ |
---|
| 473 | mount_rule = ""; |
---|
| 474 | var fld_days = Element("select_days"); |
---|
| 475 | var fld_emails = Element("select_1"); |
---|
| 476 | var fld_men = Element("field8"); |
---|
| 477 | mount_rule = "#vacation&&"; |
---|
| 478 | if(LTrim(fld_days.value) != ""){ |
---|
| 479 | if(fld_days.value > 0 && fld_days.value < 32){ |
---|
| 480 | mount_rule += fld_days.value + "&&"; |
---|
| 481 | }else{ |
---|
| 482 | alert(get_lang("It informs between 1 and 31!")); |
---|
| 483 | return false; |
---|
| 484 | } |
---|
| 485 | }else{ |
---|
| 486 | alert(get_lang("It informs the days!")); |
---|
| 487 | return false; |
---|
| 488 | } |
---|
| 489 | if(fld_emails.options.length > 0){ |
---|
| 490 | for(var i=0; i < fld_emails.options.length; i++){ |
---|
| 491 | mount_rule += "\"" + fld_emails.options[i].value + "\", "; |
---|
| 492 | } |
---|
| 493 | mount_rule = mount_rule.substr(0,(mount_rule.length - 2)); |
---|
| 494 | mount_rule += "&&"; |
---|
| 495 | mount_rule += fld_men.value + "&&on "; |
---|
| 496 | }else{ |
---|
| 497 | alert(get_lang("It informs email(s) for guiding!")); |
---|
| 498 | return false; |
---|
| 499 | } |
---|
| 500 | if(LTrim(fld_men.value) == ""){ |
---|
| 501 | alert(get_lang("It informs a message!")); |
---|
| 502 | return false; |
---|
| 503 | } |
---|
| 504 | this.out_officeR[0] = mount_rule; |
---|
| 505 | } |
---|
| 506 | Element('form_buttons').style.display = ''; |
---|
| 507 | this.reload_rules(); |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | cfilter.prototype.close_frm= function(){ |
---|
| 511 | filters.filter_Sh['window_ffilter_ccform'].close(); |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | cfilter.prototype.saved_all = function(){ |
---|
| 515 | var aux_rul = ""; |
---|
| 516 | var _this = this; |
---|
| 517 | if(_this.rulest.length > 0){ |
---|
| 518 | for(var i=0; i < _this.rulest.length; i++){ |
---|
| 519 | var aux = _this.rulest[i].split("&&"); |
---|
| 520 | aux_rul += "_begin_##"; |
---|
| 521 | for(var j=0 ; j < aux.length; j++){ |
---|
| 522 | if( (j +1) > aux.length){aux_rul += url_encode(aux[j]);} |
---|
| 523 | else{aux_rul += url_encode(aux[j]) + "##";} |
---|
| 524 | } |
---|
| 525 | aux_rul += "_end_\n"; |
---|
| 526 | } |
---|
| 527 | } |
---|
| 528 | if(_this.out_officeR.length > 0){ |
---|
| 529 | var aux = _this.out_officeR[0].split("&&"); |
---|
| 530 | aux_rul += "_begin_##"; |
---|
| 531 | for(var j=0 ; j < aux.length; j++){ |
---|
| 532 | if( (j +1) > aux.length){aux_rul += url_encode(aux[j]);} |
---|
| 533 | else{aux_rul += url_encode(aux[j]) + "##";} |
---|
| 534 | } |
---|
| 535 | aux_rul += "_end_\n"; |
---|
| 536 | } |
---|
| 537 | var h_filter = function(data){ |
---|
| 538 | if(data != "Ok"){alert("Erro : \n" + data);} |
---|
| 539 | } |
---|
| 540 | var args = "$this.ScriptS.rec_rules"; |
---|
| 541 | var params = "arfilter="+aux_rul; |
---|
| 542 | cExecute(args,h_filter,params); |
---|
| 543 | } |
---|
| 544 | |
---|
| 545 | // build object |
---|
| 546 | var filter; |
---|
| 547 | filter = new cfilter(); |
---|