Changeset 564
- Timestamp:
- 01/05/09 17:20:41 (15 years ago)
- Location:
- trunk/expressoMail1_2
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.ScriptS.inc.php
r330 r564 13 13 var $rules; // Regras do sieve; 14 14 var $errstr; // Erros retornados; 15 var $size; // var tamanho;16 var $so; // para verificarse a regra foi criada por outro tipo serviço de filtros;15 var $size; // Tamanho; 16 var $so; // Verifica se a regra foi criada por outro tipo serviço de filtros; 17 17 var $continuebit; 18 18 var $sizebit; … … 22 22 var $newrules = array(); 23 23 var $newout; 24 var $teste; 25 var $EmailVoip; 26 var $EmailExpresso; 24 27 25 28 function ScriptS(){ … … 42 45 $this->keepbit = 8; 43 46 $this->regexbit = 128; 47 48 $this->EmailVoip = trim($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_email_redirect']); 49 $this->EmailExpresso = trim($_SESSION['phpgw_info']['expressomail']['user']['email']); 44 50 45 51 } … … 189 195 return "Ok"; 190 196 }else{ 191 return "Problemas na criação do arquivo! ";197 return "Problemas na criação do arquivo!\n" . $this->teste; 192 198 } 193 199 } 194 200 195 function convert_specialchar($input){ 196 $special_char = false; 197 for ( $i = 0; $i < strlen($input); $i++ ) 198 if ( preg_match('/[ÁáÉéÍíÓóÚúÀàÈèÌìÒòÙùÇçÃãÕõÂâÊêÔô®©§ªºÐ¹²³°¢¿Æ£µøæß«»Ø÷±¬]/', $input[$i]) ) 199 { 200 $special_char = true; 201 $input = preg_replace('/'.$input[$i].'/', '=' . bin2hex($input[$i]), $input); 202 } 203 204 if ( $special_char ) 205 { 206 /* When using arrays with pattern and replacement, the keys are processed in the order they appear in the array. See preg_replace in php.net/preg_replace */ 201 function convert_specialchar($input) 202 { 203 $special_char = false; 204 for ( $i = 0; $i < strlen($input); $i++ ) 205 { 206 if ( preg_match('/[ÁáÉéÍíÓóÚúÀàÈèÌìÒòÙùüÇçÃãÕõÂâÊêÔô®©§ªºÐ¹²³°¢¿Æ£µøæß«»Ø÷±¬]/', $input[$i]) ) 207 { 208 $special_char = true; 209 $input = preg_replace('/'.$input[$i].'/', '=' . bin2hex($input[$i]), $input); 210 } 211 } 212 213 if ( $special_char ) 214 { 215 /* * 216 * When using arrays with pattern and replacement, 217 * the keys are processed in the order they appear in the array. 218 * See preg_replace in php.net/preg_replace 219 * */ 207 220 $patterns[0] = '/=c3/i'; 208 221 $patterns[1] = '/ /'; … … 210 223 $replacements[0] = '_'; 211 224 $input = preg_replace($patterns, $replacements, $input); 212 } 213 // if (($input{0}) && (!eregi('^[a-zA-Z0-9=\-@&\.#\$!?%:\+_<>\(\)\"\ ]+$',$input))) 214 // return false; 215 // else 216 return($input); 217 } 225 } 226 227 return($input); 228 } 218 229 219 230 // Grava a nova regra; … … 227 238 $regexused = 0; 228 239 $rejectused = 0; 240 $notify = 0; 229 241 $newscriptbody = ""; 230 242 $continue = 1; 243 $tmpSubject = ""; 231 244 232 245 // Recebe os valores das regras; … … 237 250 $rule['from'] = $this->convert_specialchar($tmp1[3]); 238 251 $rule['to'] = $this->convert_specialchar($tmp1[4]); 239 $rule['subject'] = $this->convert_specialchar($tmp1[5]); 252 $tmpSubject = $tmp1[5]; 253 $rule['subject'] = $this->convert_specialchar($tmp1[5]); 240 254 $rule['action'] = $tmp1[6]; 241 255 $rule['action_arg'] = utf8_encode(preg_replace("/\\r\\n/","\r\n",$tmp1[7])); … … 337 351 if (!$rule['unconditional']) $newruletext .= ") {\n\t"; 338 352 339 if (preg_match("/folder/i",$rule['action'])) { 353 if (preg_match("/folder/i",$rule['action'])) 354 { 340 355 $newruletext .= "fileinto \"" . $rule['action_arg'] . "\";"; 341 356 } 342 if (preg_match("/reject/i",$rule['action'])) { 357 358 if (preg_match("/reject/i",$rule['action'])) 359 { 343 360 $newruletext .= "reject text: \n" . $rule['action_arg'] . "\n.\n;"; 344 361 $rejectused = 1; 345 362 } 346 if (preg_match("/address/i",$rule['action'])) { 363 364 if (preg_match("/address/i",$rule['action'])) 365 { 347 366 $newruletext .= "redirect \"" . $rule['action_arg'] . "\";"; 348 367 } 368 369 if (preg_match("/notify/i",$rule['action'])) 370 { 371 $newruletext .= "notify :method \"mailto\" :options [\"".$this->EmailVoip ."\"]:" . 372 "message \"<expressovoip><from>". $this->EmailExpresso."</from>". 373 "<br/><Subject>".utf8_encode($tmpSubject)."</Subject></expressovoip>\";"; 374 $notify = 1; 375 } 376 349 377 if (preg_match("/discard/i",$rule['action'])) { 350 378 $newruletext .= "discard;"; … … 362 390 } 363 391 }// Fim do Foreach; 364 392 $this->teste = $newscriptbody; 365 393 // Para a regras fora do escritorio; 366 394 unset($tmp); … … 389 417 if ($activerules) { 390 418 $newscripthead .= "require [\"fileinto\""; 419 420 if($notify){ 421 $newscripthead .= ",\"notify\""; 422 } 391 423 if($regexused){ 392 424 $newscripthead .= ",\"regex\""; … … 405 437 } 406 438 407 //preg_replace("/[\\n\\r]/","", $p);408 409 410 439 // Cria o rodapé do arquivo; 411 440 $newscriptfoot = ""; -
trunk/expressoMail1_2/index.php
r537 r564 42 42 $voip_enabled = false; 43 43 $voip_groups = array(); 44 44 45 if($GLOBALS['phpgw_info']['server']['voip_groups']) { 46 $emailVoip = false; 45 47 foreach(explode(",",$GLOBALS['phpgw_info']['server']['voip_groups']) as $i => $voip_group){ 46 48 $a_voip = explode(";",$voip_group); … … 50 52 if(array_search($group['account_name'],$voip_groups) !== FALSE){ 51 53 $voip_enabled = true; 54 $emailVoip = $GLOBALS['phpgw_info']['server']['voip_email_redirect']; 52 55 break; 53 56 } … … 70 73 $_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email']; 71 74 75 72 76 $_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = array( 73 77 'voip_enabled' => $voip_enabled, 78 'voip_email_redirect' => $emailVoip, 74 79 'outoffice' => $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['outoffice'], 75 80 'telephone_number' => $GLOBALS['phpgw_info']['user']['telephonenumber'], … … 93 98 94 99 ); 95 100 96 101 $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 97 102 $template->set_var("txt_loading",lang("Loading")); -
trunk/expressoMail1_2/js/filter.js
r377 r564 1 function charCounter(form) 2 { 3 if (form.value.length >= 300) { 4 alert(get_lang("You have exceeded the number of allowed characters")); 5 return false; 6 } 7 8 } 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 } 9 } 9 10 10 11 function cfilter(){ … … 12 13 this.mode_in = ""; 13 14 this.rulest = new Array; 15 this.rulesVoip = new Array; 14 16 this.out_officeR = ""; 15 17 this.out_officeF = false; … … 37 39 38 40 } 39 40 cfilter.prototype.load_rules = function(){ 41 42 43 cfilter.prototype.load_rules = function() 44 { 41 45 var _this = this; 42 if(_this.rulest.length == 0){ 43 var handler_sieve = function(data){ 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 { 44 53 if(data.rule.length > 0){ 45 for(var i=0 ; i < data.rule.length; i++){ 46 _this.rulest[_this.rulest.length] = data.rule[i]; 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]; 47 61 } 48 62 } … … 73 87 } 74 88 75 cfilter.prototype.form_r = function(pos){ 89 cfilter.prototype.form_r = function(pos,type) 90 { 76 91 Element('form_body').innerHTML = ""; 77 92 Element('form_body').innerHTML = this.forms_(); 78 Element('div_rule').style.display = ""; 79 this.ac_form = "old_rule"; 80 this.ind = pos; 81 this.r_rules_form(pos); 82 } 83 84 cfilter.prototype.get_email = function(){ 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 } 107 } 108 109 cfilter.prototype.get_email = function() 110 { 85 111 var _this = this; 86 var handler_get_email = function(data){ 112 var handler_get_email = function(data) 113 { 87 114 _this.email_ld = data ? data : ""; 88 115 } … … 90 117 } 91 118 92 cfilter.prototype.sel_boxes = function(){ 119 cfilter.prototype.sel_boxes = function() 120 { 93 121 var nm_folders = tree_folders.getNodesList(cyrus_delimiter); 94 122 if(document.getElementById("select_mailboxes") != null){ … … 100 128 } 101 129 } 102 for(var i=0; i < nm_folders.length; i++){ 103 if(nm_folders[i].id != "root"){ 130 for(var i=0; i < nm_folders.length; i++) 131 { 132 if(nm_folders[i].id != "root") 133 { 104 134 var opt = new Option(nm_folders[i].caption,nm_folders[i].id,false,true); 105 135 sel_nm[sel_nm.length] = opt; … … 125 155 } 126 156 127 cfilter.prototype.r_rules_form = function(ind){ 157 cfilter.prototype.r_rules_form = function(ind, type) 158 { 159 var fields = new Array; 160 var _this = this; 128 161 129 162 // hide buttons 130 163 Element('form_buttons').style.display = 'none'; 131 132 this.sel_boxes(); 133 var aux = new Array; 134 var _this = this; 135 if(this.rulest.length == 0){ 136 return false; 137 } 138 aux = _this.rulest[ind].split("&&"); 139 document.getElementById("field1").value = aux[3]; 140 document.getElementById("field2").value = aux[4]; 141 document.getElementById("field3").value = aux[5]; 142 document.getElementById("field4").value = aux[11]; 143 144 switch(aux[6]){ 145 case "folder": 146 document.getElementById("radio1").checked = true; 147 var name_mb = aux[7]; 148 var sel_mb = document.getElementById("select_mailboxes"); 149 for(var i=0; i < sel_mb.options.length; i++){if((sel_mb.options[i].value) == name_mb){sel_mb.options[i].selected = true;}} 150 break; 151 case "address": 152 document.getElementById("radio2").checked = true; 153 document.getElementById("field5").value = aux[7]; 154 break; 155 case "reject": 156 document.getElementById("radio3").checked = true; 157 var text0 = aux[7].split("\\n"); 158 for(var i=0; i < text0.length; i++){document.getElementById("field6").value += text0[i] + "\n";} 159 break; 160 case "discard": 161 document.getElementById("radio4").checked = true; 162 break; 163 } 164 var mark_values = this.values[aux[8]].split(","); 165 for(var i=0; i < mark_values.length; i++){ 166 if( mark_values[i] == "checkBox1" || mark_values[i] == "checkBox2"){ 167 document.getElementById(mark_values[i]).checked = true; 168 } 169 if( mark_values[i] == "select_size=1" || mark_values[i] == "select_rules=1"){ 170 var mark_val = mark_values[i].split("="); 171 document.getElementById(mark_val[0]).options[mark_val[1]].selected = true; 164 165 if( type === 'voip') 166 { 167 fields = _this.rulesVoip[ind].split("&&"); 168 document.getElementById("field9").value = fields[5]; 169 } 170 else 171 { 172 this.sel_boxes(); 173 if(this.rulest.length == 0){ 174 return false; 175 } 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; 201 } 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 } 172 211 } 173 212 } … … 224 263 * quando a caixa de seleção para manter o e-mail na caixa de entrada do usuário for selecionada 225 264 */ 226 cfilter.prototype.disable_radio3 = function() {227 265 cfilter.prototype.disable_radio3 = function() 266 { 228 267 radio3 = Element('radio3'); 229 268 field6 = Element('field6'); 230 269 cb2 = Element('checkBox2'); 231 270 232 if (cb2.checked){ 271 if (cb2.checked) 272 { 233 273 radio3.disabled = true; 234 274 field6.disabled = true; 235 275 236 if (radio3.checked){ 276 if (radio3.checked) 277 { 237 278 radio3.checked = false; 238 279 } 239 280 } 240 else{ 281 else 282 { 241 283 radio3.disabled = false; 242 284 field6.disabled = false; … … 245 287 } 246 288 247 cfilter.prototype.forms_ = function(){ 248 var form = ""; 249 form = "<div id='div_rule' style='display:none'><table id='table_rule' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 250 "<tr><td colspan='2'><input type='checkBox' id='checkBox1' name='checkb'>"+get_lang('Also check message against next rule') + "</td></tr>"+ 251 "<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>"+ 252 "<tr><td colspan='2'><hr size='1' width='100%'></td></tr><tr>"+ 253 "<td rowspan='4' width='20%'>"+get_lang('Coincident')+"<br><select id='select_rules' name='select_rules'>"+ 254 "<option value='0'>"+get_lang("with all")+"</option><option value='1'>"+get_lang("with some")+"</option>"+ 255 "</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>"+ 256 "</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>"+ 257 "</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>"+ 258 "</tr><tr><td>"+get_lang('The size of the message is')+".:  <select id='select_size' name='select_size'>"+ 259 "<option value='0'>"+get_lang("Less than")+"</option><option value='1'>"+get_lang("Greater than")+"</option>"+ 260 "</select> <input type='text' id='field4' name='field4' size='8' maxlength='8'> Kb</td>"+ 261 "</tr><tr><td colspan='2'><hr size='1' width='100%'></td></tr>"+ 262 "</table><table id='table_rule1' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 263 "<tr><td width='50%'><input type='radio' id='radio1' name='radio' value='folder'>"+get_lang('Store at')+".:</td>"+ 264 "<td width='50%'><select id='select_mailboxes' name='select_mailboxes'></select></td>"+ 265 "</tr><tr><td width='50%'><input type='radio' id='radio2' name='radio' value='address'>"+get_lang('Forward to the address')+".:</td>"+ 266 "<td width='50%'><input type='text' id='field5' name='field5' size='35' maxlength='70'></td>"+ 267 "</tr><tr><td width='50%'><input type='radio' id='radio3' name='radio' value='reject'>"+get_lang('Send a rejection message')+".:</td>"+ 268 "<td width='50%'><textarea id='field6' onkeypress='return charCounter(this);' name='field6' rows='3' cols='25'></textarea></td>"+ 269 "</tr><tr><td colspan='2'><input type='radio' id='radio4' name='radio' value='discard'>"+get_lang('Erase the message')+"</td>"+ 270 "</tr></table></div><div id='div_vacation' style='display:none'>"+ 271 "<table id='table_vacation' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 272 "<tr><td colspan='3'><br><b>"+get_lang('out office')+"</b></td></tr>"+ 273 //"<tr><td colspan='3'><br>"+get_lang('Subject')+".: <input type='text' id='field7' name='field7' size='35' maxlength='200'/></td></tr>"+ 274 "<tr><td colspan='3'><br>"+get_lang('With the following message')+".:</td>"+ 275 "</tr><tr><td colspan='3'><textarea id='field8' onkeypress='return charCounter(this);' rows='8' cols='50'></textarea></td></tr></table></div>"+ 276 "<span align='right'><input type='button' value="+get_lang("Back")+" onclick='filter.form_m()'></span>"+ 277 "<span align='right'><input type='button' value="+get_lang("Save")+" onclick='filter.saved_rules()'></span>"; 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>"; 278 326 return form; 279 327 } … … 314 362 } 315 363 } 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 316 383 this.reload_rules(); 317 384 } … … 347 414 } 348 415 349 cfilter.prototype.e_newrule = function(nw_rule){ 416 cfilter.prototype.e_newrule = function(nw_rule) 417 { 350 418 351 419 var new_rl = ""; … … 399 467 } 400 468 } 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 401 493 _this.reload_rules(); 402 494 } 403 495 404 cfilter.prototype.reload_rules = function(){ 496 cfilter.prototype.reload_rules = function() 497 { 405 498 this.saved_all(); 406 499 Element('form_body').innerHTML = ""; 407 500 this.load_rules(); 408 409 if(this.out_officeF){ 501 502 if(this.out_officeF) 503 { 410 504 write_msg(get_lang("Attention, you are in out of office mode."), true); 411 }else 505 }else{ 412 506 clean_msg(); 413 507 this.out_officeF = false; … … 422 516 var n_rule = ""; 423 517 424 if(form[1] == "rule"){ 518 if(form[1] == "rule") 519 { 425 520 mount_rule = "#rule&&"; 426 if(form[0] == "new"){ 521 if(form[0] == "new") 522 { 427 523 n_rule = "1&&"; 428 if(this.rulest.length > 0){ 524 if(this.rulest.length > 0) 525 { 429 526 aux = this.rulest[this.rulest.length - parseInt(1)].split("&&"); 430 527 n_rule = (parseInt(aux[1]) + parseInt(2)) + "&&"; 431 528 } 432 529 mount_rule += n_rule + "ENABLED&&"; 433 }else{ 530 } 531 else 532 { 434 533 n_rule = this.rulest[this.ind].split("&&"); 435 534 mount_rule += n_rule[1] + "&&"; … … 503 602 } 504 603 if(form[0] == "new") 604 { 505 605 this.rulest[this.rulest.length] = mount_rule; 606 } 506 607 else 507 608 this.rulest[this.ind] = mount_rule; 508 }else{ 609 } 610 else if(form[1] == "out") 611 { 509 612 mount_rule = ""; 510 613 var fld_emails = this.email_ld; // Get first email of list! … … 522 625 this.out_officeR = mount_rule; 523 626 } 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 524 673 Element('form_buttons').style.display = ''; 525 674 this.reload_rules(); 526 675 } 527 676 528 cfilter.prototype.close_frm= function(){ 677 cfilter.prototype.close_frm= function() 678 { 529 679 filters.filter_Sh['window_ffilter_ccform'].close(); 530 680 } 531 681 532 cfilter.prototype.saved_all = function(){ 682 cfilter.prototype.saved_all = function() 683 { 533 684 var aux_rul = ""; 534 685 var _this = this; 535 if(_this.rulest.length > 0){ 536 for(var i=0; i < _this.rulest.length; i++){ 537 var aux = _this.rulest[i].split("&&"); 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("&&"); 538 694 aux_rul += "_begin_##"; 539 for(var j=0 ; j < aux.length; j++){ 540 if( (j +1) > aux.length){aux_rul += url_encode(aux[j]);} 541 else{aux_rul += url_encode(aux[j]) + "##";} 695 for(var j=0 ; j < fieldsNormal.length; j++) 696 { 697 aux_rul += url_encode(fieldsNormal[j]) + "##"; 698 cont = parseInt(fieldsNormal[1]); 542 699 } 543 700 aux_rul += "_end_\n"; 544 701 } 545 702 } 546 if(_this.out_officeR.length > 0){ 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 { 547 732 var aux = _this.out_officeR.split("&&"); 548 733 aux_rul += "_begin_##"; 549 for(var j=0 ; j < aux.length; j++) {550 if( (j +1) > aux.length){aux_rul += url_encode(aux[j]);}551 else{aux_rul += url_encode(aux[j]) + "##";}734 for(var j=0 ; j < aux.length; j++) 735 { 736 aux_rul += url_encode(aux[j]) + "##"; 552 737 } 553 738 aux_rul += "_end_\n"; 554 _this.out_officeF = (aux[4].replace("\n","") == "off") ? false : true;739 _this.out_officeF = (aux[4].replace("\n","") === "off") ? false : true; 555 740 //Save outoffice in prefs: 556 741 connector.loadScript("preferences"); 557 742 prefe.save("outoffice", _this.out_officeF); 558 743 } 559 var h_filter = function(data){ 744 745 var h_filter = function(data) 746 { 560 747 if(data != "Ok"){alert("Erro : \n" + data);} 561 748 } -
trunk/expressoMail1_2/js/filters.js
r246 r564 14 14 this.for_email_img = new Image(); 15 15 this.for_email_img.src = 'templates/default/images/filtro/answered.gif'; 16 this.telephone_voip = new Image(); 17 this.telephone_voip.src = 'templates/default/images/filtro/telephone_voip.jpg'; 16 18 } 17 19 … … 30 32 var form_cont = document.createElement("SPAN"); 31 33 form_cont.id = "form_status"; 32 form_cont.style.display = " ";34 form_cont.style.display = "block"; 33 35 form_cont.style.position = "absolute"; 34 36 form_cont.style.top = "10px"; … … 81 83 Element('form_status').innerHTML = ""; 82 84 var list = ""; 85 83 86 // rules 84 87 if(filter.rulest.length == 0){ 85 list = "<img id='set_rules_img' src='" +this.grp_close_img.src+"' border='0'> <span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>";88 list = "<img id='set_rules_img' src='" + this.grp_close_img.src + "' border='0' /> <span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>"; 86 89 }else{ 87 if ( filter.rulest.length < rules_limit ) //Limit of rules88 list = "<img id='set_rules_img' src='" +this.grp_open_img.src+"' onclick=filters.hidden(\"set_rules\") border='0'> <span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>";90 if ( filter.rulest.length < rules_limit ) //Limit of rules 91 list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' /> <span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule();'>" + get_lang("new rule") + "</a>"; 89 92 else 90 list = "<img id='set_rules_img' src='" +this.grp_open_img.src+"' onclick=filters.hidden(\"set_rules\") border='0'> <span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules");91 93 list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' /> <span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules"); 94 92 95 list += "<div id='set_rules'>"; 93 for(var i=0; i < filter.rulest.length; i++){ 94 list += "<input id=rule_"+i+" type='checkBox'> <img src='"+this.filter_img.src+"' width='16' height='16' border='0'> " + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulest[i],i) + "<br>"; 96 97 for(var i= 0; i < filter.rulest.length; i++) 98 { 99 list += "<input id=rule_"+i+" type='checkBox'> <img src='"+this.filter_img.src+"' width='16' height='16' border='0' /> " + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulest[i],i,'') + "<br>"; 95 100 } 96 } 97 list += "</div><br>"; 101 list += "</div>"; 102 } 103 104 list += "<br/>"; 105 98 106 // out office 99 107 if(!filter.out_officeR){ 100 list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0' > ";108 list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0' /> "; 101 109 list += "<span><b>"+get_lang('out office') + " - ( 0 ) </b></span> " + "<a href='javascript:filters.n_out_office()'>" + get_lang("new rule") + "</a>"; 102 110 }else{ 103 list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick= filters.hidden(\"set_out\") border='0'> ";111 list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"set_out\");' border='0' /> "; 104 112 list += "<span><b>"+get_lang('out office') + " - ( 1 )</b></span>"; 105 113 list += "<div id='set_out'>"; … … 108 116 list += "</div>"; 109 117 } 118 list += "<br/>"; 119 120 // Voip 121 if(preferences.voip_email_redirect) 122 { 123 if( filter.rulesVoip.length == 0) 124 { 125 list += "<img id='voip_rule_img' src='"+this.grp_close_img.src+"' border='0' /> <span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter();'>" + get_lang("new rule") + "</a>"; 126 } 127 else 128 { 129 if ( filter.rulest.length < rules_limit ) //Limit of rules 130 list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/> <span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter()'>" + get_lang("new rule") + "</a>"; 131 else 132 list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/> <span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules"); 133 134 list += "<div id='voip_rule'>"; 135 for(var i= 0; i < filter.rulesVoip.length; i++) 136 { 137 list += "<input id='voip_rule_"+i+"' type='checkBox'> <img src='"+this.telephone_voip.src+"' width='16' height='16' border='0'/> " + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulesVoip[i],i,'voip') + "<br>"; 138 } 139 list += "</div>"; 140 } 141 } 142 110 143 Element("form_body").innerHTML = list; 111 144 } 112 145 113 cfilterSh.prototype.vl_rule = function(rule,pos){ 114 var aux = rule.split("&&"); 115 return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(aux[2]) + "</font>" + " - <b>" + get_lang("E-mail rule") + ":</b> " + aux[3] + " - <b>" + get_lang("Action") + ":</b> " + aux[6] + "</a>"; 146 cfilterSh.prototype.vl_rule = function(rule,pos,type) 147 { 148 var fields = rule.split("&&"); 149 if(type == 'voip') 150 return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"','voip')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(fields[2]) + "</font>" + " - " + fields[3] + " <b>" + get_lang("Subject") + ":</b> " + fields[5] + "</a>"; 151 else 152 return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"','')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(fields[2]) + "</font>" + " - <b>" + get_lang("E-mail rule") + ":</b> " + fields[3] + " - <b>" + get_lang("Action") + ":</b> " + fields[6] + "</a>"; 116 153 } 117 154 … … 121 158 } 122 159 123 cfilterSh.prototype.n_rule = function(){ 160 cfilterSh.prototype.n_rule = function() 161 { 124 162 Element('form_body').innerHTML = ""; 125 163 Element('form_body').innerHTML = filter.forms_(); 126 Element('div_rule').style.display = " ";164 Element('div_rule').style.display = "block"; 127 165 filter.ac_form = "new_rule"; 128 166 Element('form_buttons').style.display = 'none'; … … 131 169 } 132 170 133 cfilterSh.prototype.n_out_office = function(){ 171 cfilterSh.prototype.n_out_office = function() 172 { 134 173 Element('form_body').innerHTML = ""; 135 174 Element('form_body').innerHTML = filter.forms_(); 136 Element('div_vacation').style.display = " ";175 Element('div_vacation').style.display = "block"; 137 176 Element('form_buttons').style.display = 'none'; 138 177 filter.ac_form = "new_out"; 139 } 140 141 cfilterSh.prototype.hidden = function(el){ 142 var _this = this; 178 } 179 180 cfilterSh.prototype.n_voipFilter = function() 181 { 182 Element('form_body').innerHTML = ""; 183 Element('form_body').innerHTML = filter.forms_(); 184 Element('div_voipFilter').style.display = "block"; 185 Element('form_buttons').style.display = 'none'; 186 filter.ac_form = "new_voip"; 187 } 188 189 function visibleRulesFalse(el) 190 { 143 191 Element(el).style.display = "none"; 144 Element(el+"_img").src = _this.grp_close_img.src;145 Element(el+"_img").onclick = function(){ filters.un_hidden(el);}146 } 147 148 cfilterSh.prototype.un_hidden = function(el){149 var _this = this;192 Element(el+"_img").src = filters.grp_close_img.src; 193 Element(el+"_img").onclick = function(){visibleRulesTrue(el);}; 194 } 195 196 function visibleRulesTrue(el) 197 { 150 198 Element(el).style.display = ""; 151 Element(el+"_img").src = _this.grp_open_img.src; 152 Element(el+"_img").onclick = function(){filters.hidden(el);} 153 } 154 155 cfilterSh.prototype.showWindow = function (div){ 199 Element(el+"_img").src = filters.grp_open_img.src; 200 Element(el+"_img").onclick = function(){visibleRulesFalse(el);}; 201 } 202 203 cfilterSh.prototype.showWindow = function (div) 204 { 156 205 if(! this.filter_Sh[div.id]) { 157 206 div.style.width = "680px";
Note: See TracChangeset
for help on using the changeset viewer.