source: trunk/phpgwapi/templates/classic/js/listUsers.js @ 1509

Revision 1509, 5.9 KB checked in by amuller, 15 years ago (diff)

Ticket #628 - Corrigindo problema de janela pai em determinados domínios

  • 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                var rootPath = document.location.toString();
50                window.open(rootPath.substr(0,rootPath.lastIndexOf('/'))+'/phpgwapi/templates/celepar/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        function execAction(action){
54                                                               
55                if(!window.opener)                             
56                        doc = window.document;
57                else
58                        doc = window.opener.document;
59               
60                select = doc.getElementById('user_list');                                       
61                checkAttr = doc.formAcl.checkAttr;                                                                                             
62                for(i = 0; i < select.length; i++) {                                   
63                        if(select.options[i].selected){
64                                ids = getIds(select.options[i].value);
65                                                                                       
66                                for(j = 0; j < ids.length; j++){                                                                               
67                                       
68                                        if(action == 'SAVE') {
69                                                doc.getElementById(ids[j]).disabled = !checkAttr[j].checked;
70                                        }                                       
71                                        if(action == 'LOAD') {
72                                               
73                                                checkAttr[j].checked = !doc.getElementById(ids[j]).disabled;
74                                        }
75                                }                                                                                                       
76                        }                       
77                }
78               
79                if(!select.length)
80                        for(j = 0; j < checkAttr.length; j++)
81                                checkAttr[j].disabled = true;
82                               
83                else           
84                        for(j = 0; j < checkAttr.length; j++)
85                                checkAttr[j].disabled = false;
86                       
87        }
88               
89        function getIds(value){
90                       
91                ids = new Array();
92                ids[0] = value + '_1]' ;
93                ids[1] = value + '_2]' ;
94                ids[2] = value + '_4]' ;
95                ids[3] = value + '_8]' ;
96                ids[4] = value + '_16]';
97               
98                return ids;
99        }
100
101       
102        function optionFinder(oText) {                                                                                                                                                 
103
104                for(var i = 0;i < select.options.length; i++)                           
105                        select.options[i--] = null;
106                                                                                                                                                                                       
107                for(i = 0; i < users.length; i++)
108                                                                                                                                                                                       
109                        if(users[i].text.substring(0 ,oText.value.length).toUpperCase() == oText.value.toUpperCase() ||
110                                (users[i].text.substring(0 ,3) == '(G)' &&
111                                users[i].text.substring(4 ,4+oText.value.length).toUpperCase() == oText.value.toUpperCase())) {                                                                                                                                                                 
112                                sel = select.options;                                           
113                                option = new Option(users[i].text,users[i].value);
114                                option.onclick = users[i].onclick;                             
115                                sel[sel.length] = option;
116                         
117                        }                                                                                               
118        }                       
119 
120 
121        function addUser() {
122                var select = window.document.getElementById('user_list_in');
123                var selectOpener = window.opener.document.getElementById('user_list');
124       
125                var primary_group  = window.opener.document.getElementById('primary_group_list');
126
127                if(document.all)
128                        primary_group  = window.opener.document.all['primary_group_list'];
129               
130                for (i = 0 ; i < select.length ; i++) {                         
131
132                        if (select.options[i].selected) {
133                                isSelected = false;
134
135                                for(var j = 0;j < selectOpener.options.length; j++) {                                                                                                                                                   
136                                        if(selectOpener.options[j].value == select.options[i].value){
137                                                isSelected = true;                                             
138                                                break; 
139                                        }
140                                }
141
142                                if(!isSelected){
143
144                                        option = window.opener.document.createElement('option');
145                                        option.value =select.options[i].value;
146                                        option.text = select.options[i].text;
147                                        selectOpener.options[selectOpener.options.length] = option;     
148                                        if(primary_group != null) {
149                                                primary_group.options[primary_group.options.length] = window.opener.document.createElement('option');
150                                                primary_group.options[primary_group.options.length - 1].value =select.options[i].value;
151                                                primary_group.options[primary_group.options.length - 1].text = select.options[i].text;
152                                        }
153                                       
154                                }
155                               
156                        }
157                }
158               
159                selectOpener.options[selectOpener.options.length-1].selected = true;
160        }                               
161       
162        function addUserAcl() {
163                var select = window.document.getElementById('user_list_in');
164                var selectOpener = window.opener.document.getElementById('user_list');
165                for (i = 0 ; i < select.length ; i++) {                         
166
167                        if (select.options[i].selected) {
168                                isSelected = false;
169
170                                for(var j = 0;j < selectOpener.options.length; j++) {                                                                                                                                                   
171                                        if(selectOpener.options[j].value == select.options[i].value){
172                                                isSelected = true;                                             
173                                                break; 
174                                        }
175                                }
176
177                                if(!isSelected){
178
179                                        option = window.opener.document.createElement('option');
180                                        option.value =select.options[i].value;
181                                        option.text = select.options[i].text;
182                                        selectOpener.options[selectOpener.options.length] = option;     
183                                       
184                                        ids = getIds(select.options[i].value);
185                                        for(k = 0; k < ids.length; k++) {                                                                                                                       
186                                                el = window.opener.document.createElement('input');
187                                                el.type='hidden';
188                                                el.value ='Y';
189                                                el.name = ids[k];
190                                                el.disabled = true;                                             
191                                                el.id = ids[k];
192                                                window.opener.document.getElementById("tdHiddens").appendChild(el);
193                                        }
194                                }
195                               
196                        }
197                }
198                selectOpener.options[selectOpener.options.length-1].selected = true;
199                execAction('LOAD');
200        }       
Note: See TracBrowser for help on using the repository browser.