source: trunk/expressoMail1_2/js/jscode/filters.js @ 2660

Revision 2660, 9.8 KB checked in by amuller, 14 years ago (diff)

Ticket #1056 - Elimina problemas de concorrência no bloqueio do email

Line 
1var rules_limit = 300;
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 = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/filtro/group_open.gif';
10                this.grp_close_img = new Image();
11                this.grp_close_img.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/filtro/group_close.gif';
12                this.filter_img = new Image();
13                this.filter_img.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/filtro/filters.gif';
14                this.for_email_img = new Image();
15                this.for_email_img.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/filtro/answered.gif';
16                this.telephone_voip = new Image();
17                this.telephone_voip.src = URL_SERVER + 'expressoMail1_2/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 = "320px";
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                                                                 "&nbsp;<input type='button' value="+get_lang("Disable")+" onclick='filter.enabled_disabled(\"DISABLED\");'>"+ 
50                                                                 "&nbsp;<input type='button' value="+get_lang("Remove")+" onclick='filter.delete_r();'>"+
51                                                                 "&nbsp;<input type='button' value="+get_lang("Close")+" onclick='filter.close_frm();'>";
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";
61                form_body.style.height = "310px";
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);
69                filter.load_rules(this.list_rules);
70       
71        }
72
73        cfilterSh.prototype.list_rules = function(){
74                if(filter.rulest.length == 0)
75                        setTimeout("filters.mount_list()",2500);
76                else
77                        filters.mount_list();
78        }
79
80        cfilterSh.prototype.mount_list = function(){
81
82                Element('form_status').innerHTML = "";
83                var list = "";
84       
85                // rules
86                if(filter.rulest.length == 0){
87                        list = "<img id='set_rules_img' src='" + this.grp_close_img.src + "' border='0' />&nbsp;<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                }else{
89                        if ( filter.rulest.length < rules_limit ) //Limit of rules
90                                list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule();'>" + get_lang("new rule") + "</a>";
91                        else
92                                list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules");
93                       
94                        list += "<div id='set_rules'>";
95                       
96                        for(var i= 0; i < filter.rulest.length; i++)
97                        {
98                                list += "<input id=rule_"+i+" type='checkBox'>&nbsp;<img src='"+this.filter_img.src+"' width='16' height='16' border='0' />&nbsp;" + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulest[i],i,'') + "<br>";
99                        }
100                        list += "</div>";                       
101                }
102               
103                list += "<br/>";
104               
105                // out office
106                if(!filter.out_officeR){
107                        list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0' />&nbsp;";
108                        list += "<span><b>"+get_lang('out office') + " - ( 0 ) </b></span> " + "<a href='javascript:filters.n_out_office()'>" + get_lang("new rule") + "</a>";                 
109                }else{
110                        list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"set_out\");' border='0' />&nbsp;";
111                        list += "<span><b>"+get_lang('out office') + " - ( 1 )</b></span>";
112                        list += "<div id='set_out'>";
113                        list += "<input id='out_0' type='checkBox'><img id='set_out_form_email_img' src='"+this.for_email_img.src+"' border='0'>";
114                        list += " " + this.vl_outOffice(filter.out_officeR) + " " ;
115                        list += "</div>";
116                }
117                list += "<br/>";
118       
119                // Voip
120                if(preferences.voip_email_redirect)
121                {
122                        if( filter.rulesVoip.length == 0)
123                        {
124                                list += "<img id='voip_rule_img' src='"+this.grp_close_img.src+"' border='0' />&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter();'>" + get_lang("new rule") + "</a>";         
125                        }
126                        else
127                        {
128                                if ( filter.rulest.length < rules_limit ) //Limit of rules
129                                        list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/>&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter()'>" + get_lang("new rule") + "</a>";
130                                else
131                                        list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/>&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules");
132                                       
133                                list += "<div id='voip_rule'>";
134                                for(var i= 0; i < filter.rulesVoip.length; i++)
135                                {
136                                        list += "<input id='voip_rule_"+i+"' type='checkBox'>&nbsp;<img src='"+this.telephone_voip.src+"' width='16' height='16' border='0'/>&nbsp;" + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulesVoip[i],i,'voip') + "<br>";
137                                }
138                                list += "</div>";
139                        }
140                }
141
142                Element("form_body").innerHTML = list;
143        }
144       
145        cfilterSh.prototype.vl_rule = function(rule,pos,type)
146        {
147                var fields = rule.split("&&");
148                if(type == 'voip')
149                        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>";
150                else
151                        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>";
152        }
153       
154        cfilterSh.prototype.vl_outOffice = function(outOffice){         
155                var aux = outOffice.split("&&");
156                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>";
157        }
158       
159        cfilterSh.prototype.n_rule = function()
160        {
161                Element('form_body').innerHTML = "";
162                Element('form_body').innerHTML = filter.forms_();       
163                Element('div_rule').style.display = "block";
164                filter.ac_form = "new_rule";
165                Element('form_buttons').style.display = 'none';
166                filter.sel_boxes();
167
168        }
169
170        cfilterSh.prototype.n_out_office = function()
171        {
172                Element('form_body').innerHTML = "";
173                Element('form_body').innerHTML = filter.forms_();       
174                Element('div_vacation').style.display = "block";                       
175                Element('form_buttons').style.display = 'none';
176                filter.ac_form = "new_out";     
177        }
178
179        cfilterSh.prototype.n_voipFilter = function()
180        {
181                Element('form_body').innerHTML = "";
182                Element('form_body').innerHTML = filter.forms_();
183                Element('div_voipFilter').style.display = "block";     
184                Element('form_buttons').style.display = 'none';
185                filter.ac_form = "new_voip";
186        }
187
188        function visibleRulesFalse(el)
189        {
190                Element(el).style.display = "none";
191                Element(el+"_img").src = filters.grp_close_img.src;
192                Element(el+"_img").onclick = function(){visibleRulesTrue(el);};
193        }
194
195        function visibleRulesTrue(el)
196        {
197                Element(el).style.display = "";
198                Element(el+"_img").src = filters.grp_open_img.src;
199                Element(el+"_img").onclick = function(){visibleRulesFalse(el);};
200        }
201
202        cfilterSh.prototype.showWindow = function (div)
203        {
204                if(! this.filter_Sh[div.id]) {
205                        div.style.width = "680px";
206                        div.style.height = "345px";
207                        div.style.visibility = "hidden";
208                        div.style.position = "absolute";
209                        div.style.zIndex = "10000";                     
210                        var title = ':: ' + get_lang('Filters management') + ' - ' + get_lang('Filters maintenance') + ':: ';
211                        var wHeight = div.offsetHeight + "px";
212                        var wWidth =  div.offsetWidth   + "px";
213
214                        win = new dJSWin({                     
215                                id: 'filter'+div.id,
216                                content_id: div.id,
217                                width: wWidth,
218                                height: wHeight,
219                                title_color: '#3978d6',
220                                bg_color: '#eee',
221                                title: title,                                           
222                                title_text_color: 'white',
223                                button_x_img: '../phpgwapi/images/winclose.gif',
224                                border: true });
225                       
226                        this.filter_Sh[div.id] = win;
227                        win.draw();
228                }else{
229                        div.innerHTML = '';
230                        win = this.filter_Sh[div.id];
231                        filter.form_m();                       
232                }
233                win.open();
234        }
235
236///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
237// build object
238        var filters;
239        filters = new cfilterSh();
Note: See TracBrowser for help on using the repository browser.