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