[3187] | 1 | var rules_limit = 20000; |
---|
[246] | 2 | |
---|
[2] | 3 | function cfilterSh(){ |
---|
| 4 | this.filter_Sh = new Array; |
---|
| 5 | this.qvfaf = ""; |
---|
| 6 | |
---|
| 7 | // Images |
---|
| 8 | this.grp_open_img = new Image(); |
---|
[803] | 9 | this.grp_open_img.src = 'templates/'+template+'/images/filtro/group_open.gif'; |
---|
[2] | 10 | this.grp_close_img = new Image(); |
---|
[803] | 11 | this.grp_close_img.src = 'templates/'+template+'/images/filtro/group_close.gif'; |
---|
[2] | 12 | this.filter_img = new Image(); |
---|
[803] | 13 | this.filter_img.src = 'templates/'+template+'/images/filtro/filters.gif'; |
---|
[2] | 14 | this.for_email_img = new Image(); |
---|
[803] | 15 | this.for_email_img.src = 'templates/'+template+'/images/filtro/answered.gif'; |
---|
[564] | 16 | this.telephone_voip = new Image(); |
---|
[803] | 17 | this.telephone_voip.src = 'templates/'+template+'/images/filtro/telephone_voip.jpg'; |
---|
[2] | 18 | } |
---|
| 19 | |
---|
| 20 | cfilterSh.prototype.Forms = function(){ |
---|
| 21 | |
---|
| 22 | var form = document.createElement("DIV"); |
---|
| 23 | form.id = "window_ffilter_ccform"; |
---|
| 24 | form.style.visibility = "hidden"; |
---|
| 25 | form.style.position = "absolute"; |
---|
| 26 | form.style.left = "0px"; |
---|
| 27 | form.style.top = "0px"; |
---|
| 28 | form.style.width = "0px"; |
---|
| 29 | form.style.height = "0px"; |
---|
| 30 | document.body.appendChild(form); |
---|
| 31 | |
---|
| 32 | var form_cont = document.createElement("SPAN"); |
---|
| 33 | form_cont.id = "form_status"; |
---|
[564] | 34 | form_cont.style.display = "block"; |
---|
[2] | 35 | form_cont.style.position = "absolute"; |
---|
[197] | 36 | form_cont.style.top = "10px"; |
---|
[2] | 37 | form_cont.style.left = "600px"; |
---|
| 38 | form_cont.innerHTML = ""; |
---|
| 39 | form.appendChild(form_cont); |
---|
| 40 | |
---|
| 41 | var form_buttons = document.createElement("DIV"); |
---|
| 42 | form_buttons.id = "form_buttons"; |
---|
| 43 | form_buttons.style.position = "absolute"; |
---|
| 44 | form_buttons.style.display = ""; |
---|
[3441] | 45 | form_buttons.style.top = "347px"; |
---|
[2] | 46 | form_buttons.style.left = "5px"; |
---|
| 47 | form_buttons.style.width = "655px"; |
---|
| 48 | form_buttons.innerHTML = "<input type='button' value="+get_lang("Enable")+" onclick='filter.enabled_disabled(\"ENABLED\");'>"+ |
---|
| 49 | " <input type='button' value="+get_lang("Disable")+" onclick='filter.enabled_disabled(\"DISABLED\");'>"+ |
---|
[53] | 50 | " <input type='button' value="+get_lang("Remove")+" onclick='filter.delete_r();'>"+ |
---|
| 51 | " <input type='button' value="+get_lang("Close")+" onclick='filter.close_frm();'>"; |
---|
[2] | 52 | |
---|
| 53 | form.appendChild(form_buttons); |
---|
| 54 | |
---|
| 55 | var form_body = document.createElement("DIV"); |
---|
| 56 | form_body.id = "form_body"; |
---|
| 57 | form_body.style.position = "absolute"; |
---|
| 58 | form_body.style.left = "5px"; |
---|
| 59 | form_body.style.top = "5px"; |
---|
| 60 | form_body.style.width = "668px"; |
---|
[3441] | 61 | form_body.style.height = "337px"; |
---|
[2] | 62 | form_body.style.borderStyle = "outset"; |
---|
| 63 | form_body.style.borderColor = "black"; |
---|
| 64 | form_body.style.borderWidth = "1px"; |
---|
| 65 | form_body.style.overflow = "auto"; |
---|
| 66 | form.appendChild(form_body); |
---|
| 67 | |
---|
| 68 | this.showWindow(form); |
---|
[3018] | 69 | if ( filter.rulest.length > 0 ) |
---|
| 70 | this.list_rules(); |
---|
| 71 | else |
---|
| 72 | filter.load_rules(this.list_rules); |
---|
[2] | 73 | } |
---|
| 74 | |
---|
| 75 | cfilterSh.prototype.list_rules = function(){ |
---|
[3018] | 76 | if(filter.criticalError) |
---|
| 77 | return false; |
---|
| 78 | else |
---|
| 79 | filters.mount_list(); |
---|
[2] | 80 | } |
---|
| 81 | |
---|
| 82 | cfilterSh.prototype.mount_list = function(){ |
---|
| 83 | |
---|
| 84 | Element('form_status').innerHTML = ""; |
---|
| 85 | var list = ""; |
---|
[564] | 86 | |
---|
[2] | 87 | // rules |
---|
| 88 | if(filter.rulest.length == 0){ |
---|
[564] | 89 | 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>"; |
---|
[2] | 90 | }else{ |
---|
[564] | 91 | if ( filter.rulest.length < rules_limit ) //Limit of rules |
---|
| 92 | 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>"; |
---|
[246] | 93 | else |
---|
[564] | 94 | 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"); |
---|
| 95 | |
---|
[2] | 96 | list += "<div id='set_rules'>"; |
---|
[564] | 97 | |
---|
| 98 | for(var i= 0; i < filter.rulest.length; i++) |
---|
| 99 | { |
---|
| 100 | 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>"; |
---|
[2] | 101 | } |
---|
[564] | 102 | list += "</div>"; |
---|
[2] | 103 | } |
---|
[564] | 104 | |
---|
| 105 | list += "<br/>"; |
---|
| 106 | |
---|
[2] | 107 | // out office |
---|
[197] | 108 | if(!filter.out_officeR){ |
---|
[564] | 109 | list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0' /> "; |
---|
[2] | 110 | list += "<span><b>"+get_lang('out office') + " - ( 0 ) </b></span> " + "<a href='javascript:filters.n_out_office()'>" + get_lang("new rule") + "</a>"; |
---|
| 111 | }else{ |
---|
[564] | 112 | list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"set_out\");' border='0' /> "; |
---|
[197] | 113 | list += "<span><b>"+get_lang('out office') + " - ( 1 )</b></span>"; |
---|
[2] | 114 | list += "<div id='set_out'>"; |
---|
| 115 | list += "<input id='out_0' type='checkBox'><img id='set_out_form_email_img' src='"+this.for_email_img.src+"' border='0'>"; |
---|
[197] | 116 | list += " " + this.vl_outOffice(filter.out_officeR) + " " ; |
---|
[2] | 117 | list += "</div>"; |
---|
| 118 | } |
---|
[564] | 119 | list += "<br/>"; |
---|
| 120 | |
---|
| 121 | // Voip |
---|
| 122 | if(preferences.voip_email_redirect) |
---|
| 123 | { |
---|
| 124 | if( filter.rulesVoip.length == 0) |
---|
| 125 | { |
---|
| 126 | 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>"; |
---|
| 127 | } |
---|
| 128 | else |
---|
| 129 | { |
---|
| 130 | if ( filter.rulest.length < rules_limit ) //Limit of rules |
---|
| 131 | 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>"; |
---|
| 132 | else |
---|
| 133 | 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"); |
---|
| 134 | |
---|
| 135 | list += "<div id='voip_rule'>"; |
---|
| 136 | for(var i= 0; i < filter.rulesVoip.length; i++) |
---|
| 137 | { |
---|
| 138 | 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>"; |
---|
| 139 | } |
---|
| 140 | list += "</div>"; |
---|
| 141 | } |
---|
| 142 | } |
---|
| 143 | |
---|
[2] | 144 | Element("form_body").innerHTML = list; |
---|
| 145 | } |
---|
| 146 | |
---|
[564] | 147 | cfilterSh.prototype.vl_rule = function(rule,pos,type) |
---|
[3026] | 148 | { |
---|
| 149 | var fields = rule.split("&&"); |
---|
| 150 | if(type == 'voip') |
---|
[4735] | 151 | { |
---|
[3026] | 152 | 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>"; |
---|
[4735] | 153 | } |
---|
| 154 | else |
---|
| 155 | { |
---|
[3026] | 156 | var _criteria = " "; |
---|
| 157 | if (fields[3].length > 0) |
---|
| 158 | _criteria = "<b>"+get_lang("is from")+"</b>:"+fields[3]; |
---|
| 159 | if (fields[4].length > 0) |
---|
[3905] | 160 | _criteria += "<b> "+get_lang("is to")+"</b>:"+fields[4]; |
---|
[3026] | 161 | if (fields[5].length > 0) |
---|
[3905] | 162 | _criteria += "<b> "+get_lang("subject is")+"</b>:"+fields[5]; |
---|
[4735] | 163 | if ( parseInt( fields[11] ) > 0 ) |
---|
| 164 | { |
---|
| 165 | if( fields[8] == "2" || fields[8] == "10" ) |
---|
| 166 | _criteria += "<b> "+get_lang("size is over than")+"</b>:"+fields[11]; |
---|
| 167 | |
---|
| 168 | if( fields[8] == "0" || fields[8] == "8" ) |
---|
| 169 | _criteria += "<b> "+get_lang("size is under than")+"</b>:"+fields[11]; |
---|
| 170 | } |
---|
| 171 | |
---|
[3026] | 172 | var _action = " "; |
---|
| 173 | if (fields[6] == 'folder') |
---|
[4735] | 174 | { |
---|
| 175 | var _folderName = ( (fields[7].split(cyrus_delimiter))[1] != undefined ) ? (fields[7].split(cyrus_delimiter))[2] != undefined ? (fields[7].split(cyrus_delimiter))[2] : (fields[7].split(cyrus_delimiter))[1] : fields[7]; |
---|
| 176 | _action = get_lang("Store at")+" "+ lang_folder( _folderName ); |
---|
| 177 | } |
---|
[3828] | 178 | else if (fields[6] == 'address') |
---|
| 179 | _action = get_lang("Forward to")+ " "+(fields[7]); |
---|
[3026] | 180 | else |
---|
| 181 | _action = get_lang(fields[6]); |
---|
| 182 | 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("if email") + " </b>" + _criteria + " - <b>" + get_lang("Action") + ":</b> " + _action + "</a>"; |
---|
| 183 | } |
---|
| 184 | } |
---|
[2] | 185 | |
---|
[4735] | 186 | cfilterSh.prototype.vl_outOffice = function(outOffice) |
---|
| 187 | { |
---|
[2] | 188 | var aux = outOffice.split("&&"); |
---|
[4855] | 189 | return get_lang("Rule") + " - <a href='javascript:void(0)' onclick=filter.form_out()> " + "<b>" + get_lang("Status") + " : </b><font color='red'>" + (aux[4].replace("\n","") === "off" ? get_lang("Disabled") : get_lang("Enabled")) + "</font></a>"; |
---|
[2] | 190 | } |
---|
| 191 | |
---|
[564] | 192 | cfilterSh.prototype.n_rule = function() |
---|
| 193 | { |
---|
[2] | 194 | Element('form_body').innerHTML = ""; |
---|
| 195 | Element('form_body').innerHTML = filter.forms_(); |
---|
[564] | 196 | Element('div_rule').style.display = "block"; |
---|
[2] | 197 | filter.ac_form = "new_rule"; |
---|
| 198 | Element('form_buttons').style.display = 'none'; |
---|
| 199 | filter.sel_boxes(); |
---|
| 200 | |
---|
| 201 | } |
---|
| 202 | |
---|
[564] | 203 | cfilterSh.prototype.n_out_office = function() |
---|
| 204 | { |
---|
[2] | 205 | Element('form_body').innerHTML = ""; |
---|
| 206 | Element('form_body').innerHTML = filter.forms_(); |
---|
[564] | 207 | Element('div_vacation').style.display = "block"; |
---|
[2] | 208 | Element('form_buttons').style.display = 'none'; |
---|
| 209 | filter.ac_form = "new_out"; |
---|
[564] | 210 | } |
---|
[2] | 211 | |
---|
[564] | 212 | cfilterSh.prototype.n_voipFilter = function() |
---|
| 213 | { |
---|
| 214 | Element('form_body').innerHTML = ""; |
---|
| 215 | Element('form_body').innerHTML = filter.forms_(); |
---|
| 216 | Element('div_voipFilter').style.display = "block"; |
---|
| 217 | Element('form_buttons').style.display = 'none'; |
---|
| 218 | filter.ac_form = "new_voip"; |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | function visibleRulesFalse(el) |
---|
| 222 | { |
---|
[2] | 223 | Element(el).style.display = "none"; |
---|
[564] | 224 | Element(el+"_img").src = filters.grp_close_img.src; |
---|
| 225 | Element(el+"_img").onclick = function(){visibleRulesTrue(el);}; |
---|
[2] | 226 | } |
---|
| 227 | |
---|
[564] | 228 | function visibleRulesTrue(el) |
---|
| 229 | { |
---|
[2] | 230 | Element(el).style.display = ""; |
---|
[564] | 231 | Element(el+"_img").src = filters.grp_open_img.src; |
---|
| 232 | Element(el+"_img").onclick = function(){visibleRulesFalse(el);}; |
---|
[2] | 233 | } |
---|
| 234 | |
---|
[564] | 235 | cfilterSh.prototype.showWindow = function (div) |
---|
| 236 | { |
---|
[2] | 237 | if(! this.filter_Sh[div.id]) { |
---|
| 238 | div.style.width = "680px"; |
---|
[3441] | 239 | div.style.height = "372px"; |
---|
[2] | 240 | div.style.visibility = "hidden"; |
---|
| 241 | div.style.position = "absolute"; |
---|
| 242 | div.style.zIndex = "10000"; |
---|
[61] | 243 | var title = ':: ' + get_lang('Filters management') + ' - ' + get_lang('Filters maintenance') + ':: '; |
---|
[2] | 244 | var wHeight = div.offsetHeight + "px"; |
---|
| 245 | var wWidth = div.offsetWidth + "px"; |
---|
| 246 | |
---|
| 247 | win = new dJSWin({ |
---|
| 248 | id: 'filter'+div.id, |
---|
| 249 | content_id: div.id, |
---|
| 250 | width: wWidth, |
---|
| 251 | height: wHeight, |
---|
| 252 | title_color: '#3978d6', |
---|
| 253 | bg_color: '#eee', |
---|
| 254 | title: title, |
---|
| 255 | title_text_color: 'white', |
---|
| 256 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
| 257 | border: true }); |
---|
| 258 | |
---|
| 259 | this.filter_Sh[div.id] = win; |
---|
| 260 | win.draw(); |
---|
| 261 | }else{ |
---|
| 262 | div.innerHTML = ''; |
---|
| 263 | win = this.filter_Sh[div.id]; |
---|
| 264 | filter.form_m(); |
---|
| 265 | } |
---|
| 266 | win.open(); |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 270 | // build object |
---|
| 271 | var filters; |
---|
[803] | 272 | filters = new cfilterSh(); |
---|