source: branches/2.2/expressoMail1_2/js/QuickCatalogSearch.js @ 3305

Revision 3305, 22.6 KB checked in by eduardoalex, 14 years ago (diff)

Ticket #1242 - Adicionada a possibilidade de criar um contato no catalogo pessoal atraves da pesquisa de usuarios.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1        function emQuickCatalogSearch ()
2        {
3                this.arrayWin = new Array();
4                this.el;
5                this.cc_contacts = new Array();
6                this.cc_groups  = new Array();
7        }
8
9        emQuickCatalogSearch.prototype.showList = function(data, begin, end){
10                connector.loadScript("ccQuickAdd");
11               
12                id = '1';
13                _this = this;
14                var el = document.createElement("DIV");
15                el.style.visibility = "hidden";
16                el.style.position = "absolute";
17                el.style.left = "0px";
18                el.style.top = "0px";
19                el.style.width = "0px";
20                el.style.height = "0px";
21                el.id = 'window_QuickCatalogSearch';
22                document.body.appendChild(el);
23                el.innerHTML = "";
24               
25               
26                func_add_contact = function () {
27                        var select_QuickCatalogSearch = document.getElementById("select_QuickCatalogSearch");
28                        var contact_selected = select_QuickCatalogSearch.options[select_QuickCatalogSearch.selectedIndex].text;
29                        contact_selected = contact_selected.split('(');
30                       
31                        var data = [];
32                        data[0] = "";
33                       
34                        var first_and_last_name = contact_selected[0].split(" ");
35                       
36                        data[0] = first_and_last_name[0];
37                        data[1] = first_and_last_name[0];
38                        data[2] = "";
39                       
40                        for (i=1; i < first_and_last_name.length; i++)
41                                data[2] += first_and_last_name[i] + " ";
42                       
43                        data[2] = data[2].replace(/\s*$/g,'');
44                       
45                        data[3] = contact_selected[1].replace(")","");
46                       
47                        ccQuickAddOne.showList( data );                                 
48                };             
49               
50                if (document.getElementById('select_QuickCatalogSearch') == null){
51
52                        var title_innerHTML = get_lang('Select a name') + ':';
53                        if (data.quickSearch_only_in_userSector)
54                                title_innerHTML += "<font color='BLACK' nowrap> ("+get_lang('Showing only the results found in your organization')+".)</font>"
55
56                        var title = document.createElement("SPAM");
57                        title.id = 'window_QuickCatalogSearch_title';
58                        title.innerHTML = "&nbsp;&nbsp;<b><font color='BLUE' nowrap>"+title_innerHTML+"</font></b><br>&nbsp;&nbsp;";
59                        el.appendChild(title);
60                       
61                        var cmb = document.createElement("SELECT");
62                        cmb.id = "select_QuickCatalogSearch";
63                        cmb.style.width = "685px";
64                        cmb.size = "12";
65                        cmb.onkeypress = function (e)
66                        {
67                                if (is_ie)
68                                {
69                                        if ((window.event.keyCode) == 13)
70                                        {
71                                                QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end);
72                                        }
73                                        else if ((window.event.keyCode) == 27)
74                                        {
75                                                QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID);
76                                        }
77                                }
78                                else
79                                {
80                                        if ((e.keyCode) == 13)
81                                        {
82                                                QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end);
83                                        }
84                                        else if ((e.keyCode) == 27)
85                                        {
86                                                QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID);
87                                        }
88                                }
89                        };
90                        el.appendChild(cmb);
91
92                        var space = document.createElement('SPAN');
93                        space.innerHTML = "<BR>&nbsp;&nbsp;";
94                        el.appendChild(space);
95
96                        var butt = document.createElement('BUTTON');
97                        var buttext = document.createTextNode('OK');
98                        butt.id = "QuickCatalogSearch_button_ok";
99                        butt.appendChild(buttext);
100                        butt.onclick = function () {QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end);};
101                        el.appendChild(butt);
102
103                        var space = document.createElement('SPAN');
104                        space.innerHTML = "&nbsp;&nbsp;";
105                        el.appendChild(space);
106
107                        var butt = document.createElement('BUTTON');
108                        butt.id = "QuickCatalogSearch_button_close";
109                        var buttext = document.createTextNode(get_lang('Close'));
110                        butt.appendChild(buttext);
111                        butt.onclick = function () {QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID);};
112                        el.appendChild(butt);
113                       
114                        var space = document.createElement('SPAN');
115                        space.innerHTML = "&nbsp;&nbsp;";
116                        el.appendChild(space);
117
118                        var butt = document.createElement('BUTTON');
119                        butt.id = "QuickCatalogSearch_button_add_contact";
120                        var buttext = document.createTextNode(get_lang("Add Contact"));
121                        butt.appendChild(buttext);
122                        butt.onclick = func_add_contact;
123                        el.appendChild(butt);                   
124                }
125                else{
126                        var title_innerHTML = get_lang('Select a name') + ':';
127                        if (data.quickSearch_only_in_userSector)
128                                title_innerHTML += "<font color='BLACK' nowrap> ("+get_lang('Showing only the results found in your organization')+".)</font>"
129
130                        var title = Element('window_QuickCatalogSearch_title');
131                        title.innerHTML = "&nbsp;&nbsp;<b><font color='BLUE' nowrap>"+title_innerHTML+"</font></b><br>&nbsp;&nbsp;";
132                       
133                        var cmb = document.getElementById('select_QuickCatalogSearch');
134                        cmb.onkeypress = function (e)
135                        {
136                                if (is_ie)
137                                {
138                                        if ((window.event.keyCode) == 13)
139                                        {
140                                                QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end);
141                                        }
142                                        else if ((window.event.keyCode) == 27)
143                                        {
144                                                QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID);
145                                        }
146                                }
147                                else
148                                {
149                                        if ((e.keyCode) == 13)
150                                        {
151                                                QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end);
152                                        }
153                                        else if ((e.keyCode) == 27)
154                                        {
155                                                QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID);
156                                        }
157                                }
158                        };
159
160                        for (i=0; i<cmb.length; i++)
161                                cmb.options[i--] = null;
162                       
163                        var butt_ok = document.getElementById("QuickCatalogSearch_button_ok");
164                        var butt_close = document.getElementById("QuickCatalogSearch_button_close");
165                        var butt_add_contact = document.getElementById("QuickCatalogSearch_button_add_contact");
166                        butt_ok.onclick = function () {QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end);};
167                        butt_close.onclick = function () {QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID);};
168                        butt_add_contact.onclick = func_add_contact;
169                }
170
171                for (i=0; i<data.length; i++){
172                        var Op = document.createElement("OPTION");
173                        Op.text = data[i].cn + ' (' + data[i].mail + ')';
174                        if (data[i].phone != '')
175                                Op.text += ' - ' + data[i].phone;
176                        if (data[i].ou != '')
177                                Op.text += ' - ' + data[i].ou; // adicionado "data[i].ou" para exibir setor (F9)
178                        Op.value = '"' + data[i].cn + '" ' + '<' + data[i].mail + '>';
179                        cmb.options.add(Op);
180                }
181                cmb.options[0].selected = true;
182                _this.showWindow(el);
183        }
184       
185        emQuickCatalogSearch.prototype.showWindow = function (div)
186        {
187                if(! div) {
188                        alert(get_lang('The list has no participant.'));
189                        return;
190                }
191                                                       
192                if(! this.arrayWin[div.id]) {
193                        div.style.width = "700px";
194                        div.style.height = "230px";
195                        var title = get_lang('The results were found in the Global Catalog')+':';
196                        var wHeight = div.offsetHeight + "px";
197                        var wWidth =  div.offsetWidth   + "px";
198                        div.style.width = div.offsetWidth - 5;
199
200                        win = new dJSWin({                     
201                                id: 'QuickCatalogSearch_'+div.id,
202                                content_id: div.id,
203                                width: wWidth,
204                                height: wHeight,
205                                title_color: '#3978d6',
206                                bg_color: '#eee',
207                                title: title,                                           
208                                title_text_color: 'white',
209                                button_x_img: '../phpgwapi/images/winclose.gif',
210                                border: true });
211                       
212                        this.arrayWin[div.id] = win;
213                        win.draw();
214                }
215                else {
216                        win = this.arrayWin[div.id];
217                }
218                //document.getElementById('QuickCatalogSearch_window_QuickCatalogSearch').style.display = "";
219                win.open();
220                document.getElementById('select_QuickCatalogSearch').focus();
221        }
222       
223        emQuickCatalogSearch.prototype.transfer_result = function (field, ID, begin, end){
224                cm = document.getElementById('select_QuickCatalogSearch');
225                option_selected = cm.options[cm.selectedIndex].value + ", ";
226                emailList = document.getElementById(field + "_" + ID).value;
227               
228                new_emailList = emailList.substring(0, begin) + option_selected + emailList.substring((parseInt(end) + 2), emailList.length);
229                document.getElementById(field + "_" + ID).value = new_emailList;
230                document.getElementById(field + "_" + ID).focus();
231               
232                //document.getElementById('QuickCatalogSearch_window_QuickCatalogSearch').style.display = "none";
233                this.arrayWin['window_QuickCatalogSearch'].close();
234        }
235       
236        emQuickCatalogSearch.prototype.close_QuickSearch_window = function (field, ID){
237                //document.getElementById('QuickCatalogSearch_window_QuickCatalogSearch').style.display = "none";
238                document.getElementById(field + "_" + ID).focus();
239                this.arrayWin['window_QuickCatalogSearch'].close();
240        }
241
242        emQuickCatalogSearch.prototype.close_window = function(id) {
243                this.arrayWin[id].close();
244                var group_values = Element('list_values');
245                var user_values = Element('user_values');       
246        }
247        emQuickCatalogSearch.prototype.showCatalogList = function (border_id){
248                var el = Element('catalog_list');
249
250                if(el) {
251                        Element('border_id').value = border_id;
252                        win = this.arrayWin[el.id];
253                        win.open();
254                        return;         
255                }
256                var border_input   = document.createElement("INPUT");
257                border_input.type  = 'hidden';
258                border_input.id    = 'border_id';
259                border_input.value = border_id;
260                document.body.appendChild(border_input);
261                el = document.createElement("DIV");             
262                el.id = 'catalog_list';
263                document.body.appendChild(el);                 
264                el.style.visibility = "hidden";
265                el.style.position = "absolute";
266                el.style.width = "700px";
267                el.style.height = is_ie ? "360px" : "375px";           
268                el.style.left = "0px";
269                el.style.top = "0px";                   
270                el.innerHTML = "<table border='0' cellpading='0' cellspacing='0' width='100%'>"+
271                                           "<tr><td id='td1' style='cursor:pointer' align='center' onclick='QuickCatalogSearch.select_div(\"tab1\")'><a href='#' class='catalog' onclick='QuickCatalogSearch.select_div(\"tab1\");'>"+get_lang('Global Catalog')+"</a></td>"+
272                                           "<td id='td2' style='background:#cecece;cursor:pointer' onclick='QuickCatalogSearch.select_div(\"tab2\")' align='center'><a href='#' class='catalog' onclick='QuickCatalogSearch.select_div(\"tab2\");'>"+get_lang('Personal Catalog')+"</a></td></tr>"+
273                                           '</table>'+
274                                           '<div id="tab1" align="center"><br>'+
275                                           '<table border="0" cellpading="0" cellspacing="0">'+
276                                           '<tr><td>'+get_lang("Select an organization and click on button <b>Search</b>")+'&nbsp;:</td></tr>'+
277                                        '<tr><td><select style="display:none;width:150px" id="select_catalog" name="select_catalog" onchange="javascript:QuickCatalogSearch.update_organizations();"></select>&nbsp'+
278                                        '<select id="select_organization" style="width:150px" name="select_organization"></select>&nbsp;'+   
279                                        '<input type="text" id="search_for" name="search_for" value="" size="30" maxlength="30"/>&nbsp;<input type="button" onclick="QuickCatalogSearch.searchCatalogList(true)" class="button" value="'+get_lang('Search')+'">&nbsp;<input style="display:visible" type="button" onclick="QuickCatalogSearch.searchCatalogList(false)" class="button" value="'+get_lang('List All')+'"></td></tr>'+
280                                           '<tr><td><input onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" id="type_l" type="radio" name="type" value="l"/>'+get_lang('Public Lists')+'&nbsp;&nbsp;<input type="radio" id="type_u" name="type" value="u" onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" checked/>'+get_lang('Users')+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
281                                           '<span style="visibility:hidden;background:#cc4444" id=msg_search>&nbsp;&nbsp;<font face="Verdana" size="1" color="WHITE">'+get_lang('Search in Catalog')+'...</font>&nbsp;</span></td></tr>'+
282                                           '<tr><td>'+
283                                           '<span id="list_span"><select multiple style="display:none;width:580px" size="14" id="list_values"></select></span>'+
284                                           '<span id="user_span"><select multiple style="width:580px" size="14" id="user_values"></select></span>'+
285                                           '</td></tr>'+
286                                           '<tr><td nowrap><center>'+get_lang('Click here to add into the fields')+':&nbsp;<input type="button" class="button" value="'+get_lang('TO')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'to\')">&nbsp;'+
287                                           '<input type="button" class="button" value="'+get_lang('CC')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cc\')">&nbsp;'+
288                                           '<input type="button" class="button" value="'+get_lang('CCo')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cco\')">'+
289                                           '</center></td></tr><tr><td nowrap><center><input type="button" value="'+get_lang('Close')+'" onClick="javascript:QuickCatalogSearch.close_window(\'catalog_list\')"></center></td></tr>'+
290                                           '</table>'+
291                                           '</div>'+
292                                           '<div style="display:none" id="tab2" align="center">'+
293                                           '<br><br><br>'+
294                                           '<table border="0" cellpading="0" cellspacing="0">'+
295                                           '<tr><td>'+get_lang("Select the type of contact that you want to view")+'&nbsp;:</td></tr>'+
296                                           '<tr><td><input onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" type="radio" name="type" value="p"/>' + get_lang('People') + '&nbsp;&nbsp;<input type="radio" name="type" value="g" onclick="javascript:QuickCatalogSearch.changeOptions(this.value)"/>' + get_lang('Groups') + ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
297                                           '<tr><td>'+
298                                           '<span id="personal_span"><select multiple style="width:580px" size="14" id="list_personal"></select></span>'+
299                                           '<span id="groups_span"><select multiple style="display:none;width:580px" size="14" id="list_groups"></select></span>'+
300                                           '</td></tr>'+
301                                           '<tr><td nowrap><center>'+get_lang('Click here to add into the fields')+':&nbsp;<input type="button" class="button" value="'+get_lang('TO')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'to1\')">&nbsp;'+
302                                           '<input type="button" class="button" value="'+get_lang('CC')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cc1\')">&nbsp;'+
303                                           '<input type="button" class="button" value="'+get_lang('CCo')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cco1\')">'+
304                                           '</center></td></tr><tr><td nowrap><center><input type="button" value="'+get_lang('Close')+'" onClick="javascript:QuickCatalogSearch.close_window(\'catalog_list\')"></center></td></tr>'+
305                                           '</table>'+
306                                           '</div>';
307
308                var title = get_lang('Search in the Global Catalog');
309                var wHeight = el.offsetHeight - (is_ie ? 10 : 0) + "px";
310                var wWidth =  el.offsetWidth   + "px";
311                el.style.width = el.offsetWidth;
312               
313                Element('search_for').onkeypress = function (e) {
314                        if ((is_ie && (window.event.keyCode == 13)) || (!is_ie && e.keyCode == 13)) {
315                                QuickCatalogSearch.searchCatalogList(true);
316                        }
317                };
318
319                win = new dJSWin({                     
320                        id: 'win_'+el.id,
321                        content_id: el.id,
322                        width: wWidth,
323                        height: wHeight,
324                        title_color: '#3978d6',
325                        bg_color: '#eee',
326                        title: title,                                           
327                        title_text_color: 'white',
328                        button_x_img: '../phpgwapi/images/winclose.gif',
329                        border: true });
330                       
331                this.arrayWin[el.id] = win;             
332                win.draw();
333                win.open();
334
335                var handler_catalogs = function(data){
336                        var user_catalog = get_lang("Global Catalog");
337                        if(data.length > 1) {
338                                Element('select_catalog').style.display = '';
339                                for(i = 0; i < data.length; i++) {             
340                                        Element('select_catalog').options[i] = new Option(data[i],i);
341                                        if(user_catalog.toUpperCase() == data[i].toUpperCase())
342                                                Element('select_catalog').options[i].selected = true;
343                                }
344                        }
345                }
346                cExecute ("$this.ldap_functions.get_catalogs", handler_catalogs);               
347               
348                this.update_organizations();
349                var handler_cc_contacts= function(data){
350                        if(data && data.length > 0){
351                                var aux = data.split(",");
352                                for(var i=0; i< aux.length; i++){
353                                        QuickCatalogSearch.cc_contacts[QuickCatalogSearch.cc_contacts.length] = aux[i];                         
354                                }
355                        }
356                }
357                cExecute("$this.db_functions.get_cc_contacts",handler_cc_contacts);
358
359                var handler_cc_groups = function(data){
360                        if(data && data.length > 0){
361                                var aux = data.split(",");
362                                for(var i=0; i < data.length; i++){
363                                        QuickCatalogSearch.cc_groups[QuickCatalogSearch.cc_groups.length] = aux[i];                                                             
364                                }       
365                        }
366                }
367                cExecute("$this.db_functions.get_cc_groups",handler_cc_groups);
368       
369        }
370       
371        emQuickCatalogSearch.prototype.select_div = function(element){
372                if(element == 'tab1'){
373                   Element('tab1').style.display = '';
374                   Element('tab2').style.display = 'none';
375                   Element('td1').style.background = '#eee';   
376                   Element('td2').style.background = '#cecece';
377                }
378                if(element == 'tab2'){
379                   Element('tab1').style.display = 'none';
380                   Element('tab2').style.display = '';
381                   Element('td1').style.background = '#cecece';
382                   Element('td2').style.background = '#eee';               
383
384                }
385        }
386       
387        emQuickCatalogSearch.prototype.load_catalog = function(){
388       
389                var _this = this;
390                var content = new Array;
391                var select = Element('list_personal').style.display == 'none'? Element('list_groups'): Element('list_personal');
392               
393                if(Element('list_personal').style.display == 'none'){
394                        content = _this.cc_groups;
395                }else{
396                        content = _this.cc_contacts;
397                }
398                if(select.options.length > 0){
399                        for(var i=0; i < select.options.length; i++){
400                                select.options[i] = null;
401                                i--;
402                        }
403                }
404                for(var i=0; i < content.length; i++){
405                        if(content[i] != undefined){
406                                var aux = content[i].split(";");
407                                var opt = new Option(aux[0] + ' (' + aux[1] + ')','"' + aux[0] + '" ' + '<' + aux[1] + '>',false,false);
408                                select[select.length] = opt;
409                        }
410                }
411                content.splice(0,(content.lenght));
412        }
413
414        emQuickCatalogSearch.prototype.update_organizations = function(){
415                while(Element('select_organization').options.length > 0) {
416                        Element('select_organization').remove(0);
417                }
418                var handler_org = function(data){
419                        Element('select_organization').options[0] = new Option(get_lang('all'),'all');
420                        if (data != null){
421                                var user_organization = Element('user_organization').value;
422                                for(x = 0; x < data.length; x++) {
423                                        Element('select_organization').options[x+1] = new Option(data[x].toUpperCase(),data[x]);
424                                        if(user_organization.toUpperCase() == data[x].toUpperCase())
425                                                Element('select_organization').options[x+1].selected = true;
426                                }
427                        }
428                }               
429                cExecute ("$this.ldap_functions.get_organizations&referral=false&catalog="+Element('select_catalog').value, handler_org);               
430        }
431
432        emQuickCatalogSearch.prototype.changeOptions = function(type){ 
433
434                switch(type){
435                        case 'u':
436                                Element('list_values').style.display = 'none';
437                                Element('user_values').style.display = '';
438                                break;
439                       
440                        case 'l':               
441                                Element('user_values').style.display = 'none';
442                                Element('list_values').style.display = '';             
443                                break;
444
445                        case 'p':
446                                Element('list_personal').style.display = '';
447                                Element('list_groups').style.display = 'none'
448                                QuickCatalogSearch.load_catalog();                             
449                                break;
450                       
451                        case 'g':
452                                Element('list_personal').style.display = 'none';
453                                Element('list_groups').style.display = ''
454                                QuickCatalogSearch.load_catalog();
455                                break;
456                }
457
458        }
459
460        emQuickCatalogSearch.prototype.addContacts = function(field) {
461               
462                var border_id   = Element('border_id').value;
463                var select              = Element('user_values').style.display == 'none' ? Element('list_values') : Element('user_values');
464                if(field == "to1" || field == "cc1" || field == "cco1"){
465                        field = field.substr(0,field.length - 1);
466                        var select = Element('list_personal').style.display == 'none' ? Element('list_groups') : Element('list_personal');
467                }
468                var fieldOpener = Element(field+"_"+border_id);
469                var not_selected = true;               
470                for (i = 0 ; i < select.length ; i++) {                 
471                        if (select.options[i].selected && select.options[i].value != '-1') {
472                                if(fieldOpener.value.length > 0 && (fieldOpener.value.lastIndexOf(',') != (fieldOpener.value.length -1))){
473                                        fieldOpener.value += ",";
474                                }
475                                fieldOpener.value += select.options[i].value + ",";
476                                not_selected = false;
477                                select.options[i].selected = false;
478                        }
479                }
480               
481                if(not_selected)
482                        return false;
483                       
484                if(field != 'to'){
485                        a_link = Element("a_"+field+"_link_"+border_id);
486                        if(a_link)
487                                a_link.onclick();                       
488                }                               
489        }
490       
491        emQuickCatalogSearch.prototype.searchCatalogList = function (itemSearch){
492
493                if(itemSearch && Element('search_for').value.length < preferences.search_characters_number){
494                        alert(get_lang('Your search argument must be longer than %1 characters.', preferences.search_characters_number));
495                        Element('search_for').focus();
496                        return false;
497                }
498                var organization = Element('select_organization').value;               
499                var search               = itemSearch ? Element('search_for').value : '';
500                var catalog              = Element('select_catalog').value;
501                var max_result  = 400;
502
503                var handler_searchResults = function(data){
504                        Element('msg_search').style.visibility = 'hidden';
505                        if(data.error){
506                                alert(get_lang('More than %1 results. Please, try to refine your search.',max_result));
507                                return false;
508                        }else if(data.users.length == 0 && data.groups.length == 0){
509                                alert(get_lang('None result was found.'));
510                        }
511
512                       
513                        var group = Element('list_span');
514                        var user  = Element('user_span');       
515                        if(is_ie){
516                                group.innerHTML = '';
517                                user.innerHTML = '';
518                        }
519                        else {
520                                group = Element('list_values');
521                                user  = Element('user_values');
522                                for(var i = 0;i < group.options.length; i++)                           
523                                        group.options[i--] = null;
524                                for(var i = 0;i < user.options.length; i++)                             
525                                        user.options[i--] = null;
526                        }
527
528                        var arr         = new Array(max_result);
529
530                        for(i = 0; data.groups && i < data.groups.length; i++) {
531                                // Maneiras diferentes de se montar uma tag OPTION, pois no IE o objeto Option é muito lento.
532                                if(is_ie)
533                                        arr[i] = '<option value="'+'&quot;'+data.groups[i].name+'&quot; &lt;'+data.groups[i].email+'&gt;">'+data.groups[i].name+' ('+data.groups[i].email+')'+'</option>';
534                                else
535                                        group.options[i] = new Option(data.groups[i].name+' ('+data.groups[i].email+')','"'+data.groups[i].name+'" <'+data.groups[i].email+'>');
536                        }
537       
538                       
539                        if(is_ie)
540                                group.innerHTML = '<select multiple style="display:none;width:580px" size="14" id="list_values">'+ arr.join() +'</select>';
541
542                        arr = new Array(max_result);
543                       
544                        for(i = 0; data.users && i < data.users.length; i++) {
545                        /*******************************************************************************************/
546                        /* O resultado pratico do bloco de codigo a seguir eh a exibicao dos valores em tela,
547                        ja que vai verificar se o departamento e o email estao vazios ou nulos e a partir dai o
548                        resultado apresentado em tela sera exibido de maneira mais apresentavel;
549                        */
550                                //verifica se departamento eh null ou nao;
551                                var department = data.users[i].department ? " - " + data.users[i].department : "";
552                                //verifica se email eh null ou nao;
553                                var email = data.users[i].email ? data.users[i].email : "";
554
555                                // Maneiras diferentes de se montar uma tag OPTION, pois no IE o objeto Option é muito lento.
556                                if(is_ie)
557                                        arr[i] = '<option value="'+'&quot;'+data.users[i].name+'&quot; &lt;'+email+'&gt;">'+data.users[i].name+' ('+email+')'+department+'</option>';
558                                else {
559                                        user.options[i] = new Option(data.users[i].name+' ('+email+')'+department,'"'+data.users[i].name+'" <'+email+'>'); // incluido data.users[i].department para exibir setor na opcao "Pesquisar" do email;
560                                }
561                        }
562       
563                        if(is_ie)
564                                user.innerHTML = '<select multiple style="width:580px" size="14" id="user_values">'+ arr.join() +'</select>';
565
566                        // Display entries found.
567                        var type = (data.groups.length > 0 && data.users.length == 0) ? 'l' : 'u';
568                        Element("type_"+type).checked = true;
569                        QuickCatalogSearch.changeOptions(type);
570                }
571
572                Element('msg_search').style.visibility = 'visible';
573                cExecute ("$this.ldap_functions.catalogsearch&max_result="+max_result+"&organization="+organization+"&search_for="+search+"&catalog="+catalog, handler_searchResults);
574        }
575
576       
577/* Build the Object */
578        var QuickCatalogSearch;
579        QuickCatalogSearch = new emQuickCatalogSearch();
Note: See TracBrowser for help on using the repository browser.