source: trunk/phpgwapi/templates/default/js/listUsers.js @ 4992

Revision 4992, 6.1 KB checked in by roberto.santosjunior, 13 years ago (diff)

Ticket #1820 - Compartilhamento da agenda nao e efetivado quando realizado.r4948

  • Property svn:executable set to *
Line 
1//Funcoes
2       
3        function remUser(){
4                primary_group  = self.document.getElementById('primary_group_list');
5                select = self.document.getElementById('user_list');                                                     
6                       
7                for(var i = 0;i < select.options.length; i++) {
8                        if(select.options[i].selected) {       
9                                if(primary_group != null) {             
10                                        for(var j = 0;j < primary_group.options.length; j++) {
11                                                if(primary_group.options[j].value == select.options[i].value) {
12                                                        primary_group.options[j] = null;
13                                                        if(primary_group.options.length > 0)
14                                                                primary_group.options[0].selected = true;
15                                                       
16                                                        break;
17                                                }
18                                        }       
19                                }       
20                                select.options[i--] = null;                                                     
21                        }
22                }
23               
24                if(select.options.length)
25                        select.options[0].selected = true;                                     
26        }
27       
28        function remUserAcl(){
29                select = self.document.getElementById('user_list');                                                             
30                for(var i = 0;i < select.options.length; i++)                           
31                        if(select.options[i].selected){
32                                ids = getIds(select.options[i].value);
33                                for(j = 0; j < ids.length; j++)
34                                        document.getElementById(ids[j]).disabled = true;
35                               
36                                select.options[i--] = null;
37                        }
38               
39                if(select.options.length)
40                        select.options[0].selected = true;                     
41               
42                execAction('LOAD');
43        }
44       
45        function openListUsers(newWidth,newHeight,currentApp,type){                     
46               
47                newScreenX  = screen.width - newWidth;         
48                newScreenY  = 0;
49
50                window.open('phpgwapi/templates/default/listUsers.php?'+(type == 'g' ? 'type=g&' : '')+'currentApp='+currentApp,"","width="+newWidth+",height="+newHeight+",screenX="+newScreenX+",left="+newScreenX+",screenY="+newScreenY+",top="+newScreenY+",status=1,toolbar=no,scrollbars=yes,resizable=no");
51               
52        }
53                                                                                       
54        function execAction(action){
55
56                if(window.opener){
57                    try{
58                        doc = window.opener.document;
59                        select = doc.getElementById('user_list');
60                    }
61                    catch(e){
62                        doc = window.document;
63                        }
64                }
65                else{
66                    doc = window.document;
67                }
68
69                select = doc.getElementById('user_list');                                       
70                checkAttr = doc.formAcl.checkAttr;                                                                                             
71                for(i = 0; i < select.length; i++) {                                   
72                        if(select.options[i].selected){
73                                ids = getIds(select.options[i].value);
74                                                                                       
75                                for(j = 0; j < ids.length; j++){                                                                               
76                                       
77                                        if(action == 'SAVE') {
78                                                doc.getElementById(ids[j]).disabled = !checkAttr[j].checked;
79                                        }                                       
80                                        if(action == 'LOAD') {
81                                               
82                                                checkAttr[j].checked = !doc.getElementById(ids[j]).disabled;
83                                        }
84                                }                                                                                                       
85                        }                       
86                }
87               
88                if(!select.length)
89                        for(j = 0; j < checkAttr.length; j++)
90                                checkAttr[j].disabled = true;
91                               
92                else           
93                        for(j = 0; j < checkAttr.length; j++)
94                                checkAttr[j].disabled = false;
95                       
96        }
97               
98        function getIds(value){
99                       
100                ids = new Array();
101                ids[0] = value + '_1]' ;
102                ids[1] = value + '_2]' ;
103                ids[2] = value + '_4]' ;
104                ids[3] = value + '_8]' ;
105                ids[4] = value + '_16]';
106               
107                return ids;
108        }
109
110       
111        function optionFinder(oText) {                                                                                                                                                 
112
113                for(var i = 0;i < select.options.length; i++)                           
114                        select.options[i--] = null;
115                                                                                                                                                                                       
116                for(i = 0; i < users.length; i++)
117                                                                                                                                                                                       
118                        if(users[i].text.substring(0 ,oText.value.length).toUpperCase() == oText.value.toUpperCase() ||
119                                (users[i].text.substring(0 ,3) == '(G)' &&
120                                users[i].text.substring(4 ,4+oText.value.length).toUpperCase() == oText.value.toUpperCase())) {                                                                                                                                                                 
121                                sel = select.options;                                           
122                                option = new Option(users[i].text,users[i].value);
123                                option.onclick = users[i].onclick;                             
124                                sel[sel.length] = option;
125                         
126                        }                                                                                               
127        }                       
128 
129 
130        function addUser() {
131                var select = window.document.getElementById('user_list_in');
132                var selectOpener = window.opener.document.getElementById('user_list');
133       
134                var primary_group  = window.opener.document.getElementById('primary_group_list');
135
136                if(document.all)
137                        primary_group  = window.opener.document.all['primary_group_list'];
138               
139                for (i = 0 ; i < select.length ; i++) {                         
140
141                        if (select.options[i].selected) {
142                                isSelected = false;
143
144                                for(var j = 0;j < selectOpener.options.length; j++) {                                                                                                                                                   
145                                        if(selectOpener.options[j].value == select.options[i].value){
146                                                isSelected = true;                                             
147                                                break; 
148                                        }
149                                }
150
151                                if(!isSelected){
152
153                                        option = window.opener.document.createElement('option');
154                                        option.value =select.options[i].value;
155                                        option.text = select.options[i].text;
156                                        selectOpener.options[selectOpener.options.length] = option;     
157                                        if(primary_group != null) {
158                                                primary_group.options[primary_group.options.length] = window.opener.document.createElement('option');
159                                                primary_group.options[primary_group.options.length - 1].value =select.options[i].value;
160                                                primary_group.options[primary_group.options.length - 1].text = select.options[i].text;
161                                        }
162                                       
163                                }
164                               
165                        }
166                }
167               
168                selectOpener.options[selectOpener.options.length-1].selected = true;
169        }                               
170       
171        function addUserAcl() {
172                var select = window.document.getElementById('user_list_in');
173                var selectOpener = window.opener.document.getElementById('user_list');
174                for (i = 0 ; i < select.length ; i++) {                         
175
176                        if (select.options[i].selected) {
177                                isSelected = false;
178
179                                for(var j = 0;j < selectOpener.options.length; j++) {                                                                                                                                                   
180                                        if(selectOpener.options[j].value == select.options[i].value){
181                                                isSelected = true;                                             
182                                                break; 
183                                        }
184                                }
185
186                                if(!isSelected){
187
188                                        option = window.opener.document.createElement('option');
189                                        option.value =select.options[i].value;
190                                        option.text = select.options[i].text;
191                                        if( option.value.charAt(0) == 'g' )
192                                                option.text = "(G) "+option.text;
193                                        selectOpener.options[selectOpener.options.length] = option;     
194                                       
195                                        ids = getIds(select.options[i].value);
196                                        for(k = 0; k < ids.length; k++) {                                                                                                                       
197                                                el = window.opener.document.createElement('input');
198                                                el.type='hidden';
199                                                el.value ='Y';
200                                                el.name = ids[k];
201                                                el.disabled = true;                                             
202                                                el.id = ids[k];
203                                                window.opener.document.getElementById("tdHiddens").appendChild(el);
204                                        }
205                                }
206                               
207                        }
208                }
209                selectOpener.options[selectOpener.options.length-1].selected = true;
210                execAction('LOAD');
211        }       
Note: See TracBrowser for help on using the repository browser.