source: trunk/expressoMail1_2/inc/class.ldap_functions.inc.php @ 325

Revision 325, 21.6 KB checked in by rafaelraymundo, 16 years ago (diff)

Alterações realizadas para unificação do ExpressoMail?


r39 | 50673548368 | 2008-06-24 18:17:33 -0300 (Ter, 24 Jun 2008) | 9 lines
Caminhos mudados:

M /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
M /trunk/expressoMail1_2/js/QuickCatalogSearch.js

Os arquivos abaixo sofreram modificacoes para tratar a exibicao do departamento na opcao "Pesquisar" do email.

  • alteracao na funcao catalogsearch() em expressoMail1_2/inc/class.ldap_functions.inc.php
  • alteracao na funcao searchCatalogList em expressoMail1_2/js/QuickCatalogSearch.js

r38 | 98954890059 | 2008-06-24 18:07:11 -0300 (Ter, 24 Jun 2008) | 1 line
Caminhos mudados:

M /trunk/expressoMail1_2/js/rich_text_editor.js

Correcao de traducoes e remocao da variavel defaultDraftsFodler


r35 | 98954890059 | 2008-06-19 21:11:11 -0300 (Qui, 19 Jun 2008) | 3 lines
Caminhos mudados:

M /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
M /trunk/expressoMail1_2/js/QuickCatalogSearch.js

Melhoria inseridas pelo Emerson:

Pesquisa por catalogos externos na Lupa(f9).


r34 | 00105772038 | 2008-06-19 19:51:58 -0300 (Qui, 19 Jun 2008) | 3 lines
Caminhos mudados:

M /trunk/expressoMail1_2/templates/default/preferences.tpl

Em preferências do Email foi removida a opção duplicada:

  • Salvar rascunhos automaticamente

r33 | 98954890059 | 2008-06-19 19:23:04 -0300 (Qui, 19 Jun 2008) | 2 lines
Caminhos mudados:

M /trunk/expressoMail1_2/js/draw_api.js

correcao de bug que nao mostrava a cota do usuario ao abrir o expressoMail.


r32 | 98954890059 | 2008-06-19 18:17:39 -0300 (Qui, 19 Jun 2008) | 3 lines
Caminhos mudados:

M /trunk/expressoMail1_2/inc/class.ScriptS.inc.php
M /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
M /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
M /trunk/expressoMail1_2/index.php
M /trunk/expressoMail1_2/js/DropDownContacts.js
M /trunk/expressoMail1_2/js/InfoContact.js
M /trunk/expressoMail1_2/js/TreeS.js
M /trunk/expressoMail1_2/js/TreeShow.js
M /trunk/expressoMail1_2/js/abas.js
M /trunk/expressoMail1_2/js/common_functions.js
M /trunk/expressoMail1_2/js/doiMenuData.js
M /trunk/expressoMail1_2/js/drag_area.js
M /trunk/expressoMail1_2/js/draw_api.js
M /trunk/expressoMail1_2/js/globals.js
M /trunk/expressoMail1_2/js/main.js
M /trunk/expressoMail1_2/js/rich_text_editor.js
M /trunk/expressoMail1_2/js/search.js
M /trunk/expressoMail1_2/js/shortcut.js
M /trunk/expressoMail1_2/preferences.php
M /trunk/expressoMail1_2/setup/phpgw_pt-br.lang
M /trunk/expressoMail1_2/setup/setup.inc.php
M /trunk/expressoMail1_2/templates/default/index.tpl
M /trunk/expressoMail1_2/templates/default/preferences.tpl

Corcacoes da celepar do bug das imagens e tabelas


r30 | 00105772038 | 2008-06-05 18:12:17 -0300 (Qui, 05 Jun 2008) | 5 lines
Caminhos mudados:

M /trunk/expressoMail1_2/js/common_functions.js
M /trunk/expressoMail1_2/js/globals.js

  • Foram inseridas funcionalidades para:

globals.js: Extenções de imagens permitidas "allowFileExtensions"

common_functions.js: Alterada a função validateFileExtension para rejeitar arquivos que não sejam imagens no corpo do email


r28 | 98954890059 | 2008-05-28 17:37:52 -0300 (Qua, 28 Mai 2008) | 2 lines
Caminhos mudados:

M /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
M /trunk/expressoMail1_2/js/main.js

Alterada a funcao empty_trash() para mudar de Lixeira para imapDefaultTrashFolder.


r27 | 00105772038 | 2008-05-28 17:11:41 -0300 (Qua, 28 Mai 2008) | 1 line
Caminhos mudados:

M /trunk/expressoMail1_2/setup/phpgw_pt-br.lang

Incluida tradução para mensagem de 'alert' ao tentar excluir emails de uma pasta compartilhada


r26 | 98954890059 | 2008-05-28 13:08:26 -0300 (Qua, 28 Mai 2008) | 1 line
Caminhos mudados:

M /trunk/expressoMail1_2/js/main.js

Inserido get_lang na ACL das pastas compartilhadas. Função move_msgs()


r24 | 98954890059 | 2008-05-27 17:53:30 -0300 (Ter, 27 Mai 2008) | 2 lines
Caminhos mudados:

M /trunk/expressoMail1_2/js/preferences.js

Aumentado o tamanho da janela javascript das preferencias do expressoMail.


r23 | 03436989789 | 2008-05-27 17:43:54 -0300 (Ter, 27 Mai 2008) | 3 lines
Caminhos mudados:

M /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
M /trunk/expressoMail1_2/js/QuickCatalogSearch.js

Substituição de links no email.


r22 | 98954890059 | 2008-05-27 17:07:32 -0300 (Ter, 27 Mai 2008) | 2 lines
Caminhos mudados:

M /trunk/expressoMail1_2/js/draw_api.js

Corrigido um bug na visualizacao das pastas compartilhadas.


r19 | 03436989789 | 2008-05-27 15:37:01 -0300 (Ter, 27 Mai 2008) | 3 lines
Caminhos mudados:

M /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php

Pesquisa em catalogos externos


r17 | 03436989789 | 2008-05-27 13:18:56 -0300 (Ter, 27 Mai 2008) | 3 lines
Caminhos mudados:

M /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
M /trunk/expressoMail1_2/js/QuickCatalogSearch.js

Busca de catálogos externos no email.


r15 | 98954890059 | 2008-05-27 12:19:50 -0300 (Ter, 27 Mai 2008) | 3 lines
Caminhos mudados:

M /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
M /trunk/expressoMail1_2/js/QuickCatalogSearch.js

Procura em catálogos externos


r6 | 98954890059 | 2008-05-21 16:14:33 -0300 (Qua, 21 Mai 2008) | 2 lines
Caminhos mudados:

M /trunk/expressoMail1_2/js/draw_api.js

Correção para atualizar a visualização das cotas
de pastas compartilhadas ao mudar de pasta.


r5 | 98954890059 | 2008-05-21 16:02:37 -0300 (Qua, 21 Mai 2008) | 3 lines
Caminhos mudados:

M /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
M /trunk/expressoMail1_2/js/draw_api.js

Alterações iniciais do serpro:

-Mostrar quotas das pastas compartilhadas


r4 | 03436989789 | 2008-05-21 13:25:29 -0300 (Qua, 21 Mai 2008) | 10 lines
Caminhos mudados:

M /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
M /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
M /trunk/expressoMail1_2/index.php
M /trunk/expressoMail1_2/js/common_functions.js
M /trunk/expressoMail1_2/js/filter.js
M /trunk/expressoMail1_2/js/main.js
M /trunk/expressoMail1_2/js/preferences.js
M /trunk/expressoMail1_2/js/rich_text_editor.js
M /trunk/expressoMail1_2/preferences.php
M /trunk/expressoMail1_2/setup/phpgw_pt-br.lang
M /trunk/expressoMail1_2/templates/default/preferences.tpl

Alterações iniciais do sepro:

  • Assinatura automática no corpo das mensagens
  • Fixar assinatura no corpo das mensagens
  • Questão dos Catálogos Externos (Ao clicar em um email o módulo abre nova mensagem)
  • Inserção de imagens em Firefox3
  • Quota nas pastas compartilhadas
  • Traduções nas pastas

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php                   
2include_once("class.imap_functions.inc.php");
3
4function ldapRebind($ldap_connection, $ldap_url)
5{
6        @ldap_bind($ldap_connection, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']);
7}
8                       
9class ldap_functions
10{
11        var $ds;
12        var $ldap_host;
13        var $ldap_context;
14        var $imap;
15       
16        // usa o host e context do contact center.
17        function ldapConnect($refer = false,$catalogo = 0){
18        include("../contactcenter/setup/external_catalogs.inc.php");
19                if ($catalogo == 0){
20                        $this->ldap_host        = $_SESSION['phpgw_info']['expressomail']['ldap_server']['host'];
21                        $this->ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn'];
22                        $this->bind_dn = $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'];
23                        $this->bind_dn_pw = $_SESSION['phpgw_info']['expressomail']['ldap_server']['pw'];
24                        $this->branch = 'ou';                   
25                }else {
26                       
27                        $this->ldap_host        =   $external_srcs[$catalogo]['host'];
28                        $this->ldap_context =   $external_srcs[$catalogo]['dn'];
29                        $this->bind_dn = $external_srcs[$catalogo]['acc'];
30                        $this->bind_dn_pw = $external_srcs[$catalogo]['pw'];
31                        $this->object_class = $external_srcs[$catalogo]['obj'];
32                        $this->base_dn = $external_srcs[$catalogo]['dn'];
33                        $this->branch = $external_srcs[$catalogo]['branch'];
34
35                }
36                $this->ds = ldap_connect($this->ldap_host);
37                ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3);
38                ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer);
39                if ($refer){
40                        ldap_set_rebind_proc($this->ds, ldapRebind);
41                }
42                @ldap_bind($this->ds,$this->bind_dn,$this->bind_dn_pw );                               
43               
44        }
45
46        //Teste jakjr retornando o DS
47        function ldapConnect2($refer = false){
48                $ds = ldap_connect($_SESSION['phpgw_info']['expressomail']['ldap_server']['host']);
49               
50                if (!$ds)
51                        return false;
52               
53                ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
54                ldap_set_option($ds, LDAP_OPT_REFERRALS, $refer);
55                if ($refer)
56                        ldap_set_rebind_proc($ds, ldapRebind);
57                @ldap_bind($ds, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']);
58               
59                return $ds;                             
60        }
61
62
63        // usa o host e context do setup.
64        function ldapRootConnect($refer = false){
65                $this->ldap_host        = $_SESSION['phpgw_info']['expressomail']['server']['ldap_host'];
66                $this->ldap_context = $_SESSION['phpgw_info']['expressomail']['server']['ldap_context'];
67                $this->ds                       = ldap_connect($this->ldap_host);
68                ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3);
69                ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer);
70                ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'],$_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']);                             
71
72        }
73
74        function quicksearch($params)
75        {       
76                include_once("../contactcenter/setup/external_catalogs.inc.php");
77                include_once("class.functions.inc.php");
78                $functions = new functions;                                             
79
80                $search_for     = utf8_encode($params['search_for']);
81                $field          = $params['field'];
82                $ID                     = $params['ID'];
83               
84                $search_for     = explode(" ",$search_for);
85                $aux="";
86                foreach ($search_for as $search)
87                        {
88                        if(!$aux)
89                                {
90                                $aux=$search;
91                                }
92                                else
93                                {
94                                $aux=$aux."*".$search;
95                                }
96                        }
97                $search_for=$aux;
98                $contacts_result = array();
99                $contacts_result['field'] = $field;
100                $contacts_result['ID'] = $ID;
101               
102                // follow the referral
103                $this->ldapConnect(true);
104               
105                if ($this->ds)
106                        {
107                        if (($field != 'null') && ($ID != 'null'))
108                                {
109                                $filter="(& (|(phpgwAccountType=u)(phpgwAccountType=l)) (|(cn=*$search_for*)(mail=*$search_for*)) (!(phpgwaccountvisible=-1)) )";
110                                $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid", "employeeNumber", "ou");
111                                }
112                        else
113                                {
114                                $filter="(& (phpgwAccountType=u)(cn=*$search_for*) (!(phpgwaccountvisible=-1)) )";
115                                $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "jpegPhoto", "uid", "employeeNumber", "ou");
116                                }
117                        $sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, 201);
118                        $count_entries = ldap_count_entries($this->ds,$sr);
119                       
120                        // Get user org dn.                     
121                        $user_dn = $_SESSION['phpgw_info']['expressomail']['user']['account_dn'];
122                        $user_sector_dn = ldap_explode_dn ( $user_dn, false );
123                        array_shift($user_sector_dn);
124                        array_shift($user_sector_dn);
125                        $user_sector_dn = implode(",", $user_sector_dn);
126                       
127                        // New search only on user sector
128                        if ($count_entries > 200)
129                        {
130                                // Close old ldap conection
131                                ldap_close($this->ds);
132                               
133                                // Reopen a local ldap connection, following referral
134                                $this->ldapRootConnect(true);
135                               
136                                $sr=ldap_search($this->ds, $user_sector_dn, $filter, $justthese, 0, 201);
137                                $count_entries = ldap_count_entries($this->ds,$sr);
138                               
139                                if ($count_entries > 200){
140                                        $return = array();
141                                        $return['status'] = false;
142                                        $return['error'] = "many results";
143                                        return $return;
144                                }
145                                else
146                                {
147                                        $quickSearch_only_in_userSector = true;
148                                }
149                        }
150                       
151                        $info = ldap_get_entries($this->ds, $sr);
152                       
153                        $tmp = array();
154                        $tmp_users_from_user_org = array();
155                       
156                        if (!$quickSearch_only_in_userSector)
157                                {
158                                $catalogsNum=count($external_srcs);
159                                for ($i=0; $i<=count($external_srcs); $i++)
160                                        {
161                                        if ($external_srcs[$i]["quicksearch"])
162                                                {
163                                                $this->ldapConnect(true,$i);
164                                                $filter="(|(cn=*$search_for*)(mail=*$search_for*))";
165                                                $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid", "employeeNumber", "ou");
166                                                $sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, 201);
167                                                $count_entries = ldap_count_entries($this->ds,$sr);
168                                                $search = ldap_get_entries($this->ds, $sr);
169                                                for ($i=0; $i<$search["count"]; $i++)
170                                                        {
171                                                        $info[] = $search[$i];
172                                                        }
173                                                $info["count"] = count($info)-1;
174                                                }
175                                        }
176                                }
177                       
178                        for ($i=0; $i<$info["count"]; $i++)
179                                {
180                                if ($quickSearch_only_in_userSector)
181                                        {
182                                        $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]);
183                                        }
184                                else
185                                        {
186                                        if (preg_match("/$user_sector_dn/i", $info[$i]['dn']))
187                                                {
188                                                $tmp_users_from_user_org[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]);
189                                                }
190                                        else
191                                                {
192                                                $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]);
193                                                }
194                                        }
195                                }
196                        natcasesort($tmp_users_from_user_org);
197                        natcasesort($tmp);
198                       
199                        if (($field != 'null') && ($ID != 'null'))
200                        {
201                                $i = 0;
202                               
203                                $tmp = array_merge($tmp, $tmp_users_from_user_org);
204                                natcasesort($tmp);
205                               
206                                foreach ($tmp as $info => $cn)
207                                {
208                                        $contacts_result[$i] = array();
209                                        $contacts_result[$i]["cn"] = $cn;
210                                        list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"], $contacts_result[$i]["mobile"], $contacts_result[$i]["uid"], $contacts_result[$i]["jpegphoto"], $contacts_result[$i]["employeenumber"], $contacts_result[$i]["ou"]) = split ('%', $info);
211                                        $i++;
212                                }
213                                $contacts_result['quickSearch_only_in_userSector'] = $quickSearch_only_in_userSector;
214                        }
215                        else
216                        {
217                                $options_users_from_user_org = '';
218                                $options = '';
219
220                                /* List of users from user org */
221                                $i = 0;
222                                foreach ($tmp_users_from_user_org as $info => $cn)
223                                {
224                                        $contacts_result[$i] = array();
225                                        $options_users_from_user_org .= $this->make_quicksearch_card($info, $cn);
226                                        $i++;
227                                }
228
229                                /* List of users from others org */
230                                foreach ($tmp as $info => $cn)
231                                {
232                                        $contacts_result[$i] = array();
233                                        $options .= $this->make_quicksearch_card($info, $cn);
234                                        $i++;
235                                }
236                               
237                                if ($quickSearch_only_in_userSector)
238                                {
239                                        if ($options != '')
240                                        {
241                                                $head_option =
242                                                        '<tr class="quicksearchcontacts_unselected">' .
243                                                                '<td colspan="2" width="100%" align="center">' .
244                                                                        $functions->getLang('More than 200 results were found') . '.<br>' .
245                                                                        $functions->getLang('Showing only the results found in your organization') . '.';
246                                                                '</td>' .
247                                                        '</tr>';
248                                                $contacts_result = $head_option . $options_users_from_user_org . $options;
249                                        }
250                                        else
251                                        {
252                                                $return = array();
253                                                $return['status'] = false;
254                                                $return['error'] = "many results";
255                                                return $return;
256                                        }
257                                }
258                                else
259                                {
260                                        if (($options_users_from_user_org != '') && ($options != ''))
261                                        {
262                                                $head_option0 =
263                                                        '<tr class="quicksearchcontacts_unselected">' .
264                                                                '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' .
265                                                                        $functions->getLang('Users from your organization') . '.';
266                                                                '</B></td>' .
267                                                        '</tr>';
268
269                                                $head_option1 =
270                                                        '<tr class="quicksearchcontacts_unselected">' .
271                                                                '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' .
272                                                                        $functions->getLang('Users from others organizations') . '.';
273                                                                '</B></td>' .
274                                                        '</tr>';
275                                        }
276                                        $contacts_result = $head_option0 . $options_users_from_user_org . $head_option1 . $options;
277                                }
278                        }
279                }
280                ldap_close($this->ds);
281                return $contacts_result;
282        }
283
284        function make_quicksearch_card($info, $cn)
285        {
286                include_once("class.functions.inc.php");
287                $functions = new functions;                                             
288               
289                $contacts_result = array();
290                $contacts_result["cn"] = $cn;
291                list ($contacts_result["mail"], $contacts_result["phone"], $contacts_result["mobile"], $contacts_result["uid"], $contacts_result["jpegphoto"]) = split ('%', $info);
292                                       
293                if ($contacts_result['jpegphoto'])
294                        $photo_link = '<img src="./inc/show_user_photo.php?mail='.$contacts_result['mail'].'">';
295                else
296                        $photo_link = '<img src="./templates/default/images/photo.png">';
297                                       
298                $phoneUser = $contacts_result['phone'];
299                                       
300                if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_enabled'] && $phoneUser) {
301                        $phoneUser = '<a title="'.$functions->getLang("Call to Comercial Number").'" href="#" onclick="InfoContact.connectVoip(\''.$phoneUser.'\',\'com\')">'.$phoneUser.'</a>';
302                        if($contacts_result['mobile']){
303                                $phoneUser .= ' / <a title="'.$functions->getLang("Call to Mobile Number").'" href="#" onclick="InfoContact.connectVoip(\''.$contacts_result['mobile'].'\',\'mob\')">'.$contacts_result['mobile'].'</a>';
304                        }
305                }
306                $option =
307                        '<tr class="quicksearchcontacts_unselected">' .
308                                '<td class="cc" width="1%">' .
309                                        '<a title="'.$functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\')">' .
310                                                $photo_link .
311                                        '</a>' .
312                                '</td>' .
313                                '<td class="cc">' .
314                                        '<span name="cn">' . $contacts_result['cn'] . '</span>' . '<br>' .
315                                        '<a title="'.$functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\')">' .
316                                                '<font color=blue>' .
317                                                        '<span name="mail">' . $contacts_result['mail'] . '</span>' . '<br>' .
318                                                '</font>' .
319                                        '</a>' .
320                                        $phoneUser .
321                                '</td>' .
322                        '</tr>';
323                return $option;
324        }
325
326        function get_catalogs(){
327                include("../contactcenter/setup/external_catalogs.inc.php");
328                $catalogs = array();
329                $catalogs[0] = "Catalogo geral";
330                foreach ($external_srcs as $key => $valor ){
331                        $catalogs[$key] = $valor['name'];
332                }
333                return $catalogs;
334        }
335        function get_organizations($params){
336
337                $organizations = array();
338                $params['referral']?$referral = $params['referral']:$referral = false;
339                $cat = $params['catalog'];
340
341                $this->ldapConnect($referral,$cat);
342
343                        if($this->branch != '') {
344                                $filter=$this->branch."=*";
345                                $justthese = array("$this->branch");
346                                $sr = ldap_list($this->ds, $this->ldap_context, $filter, $justthese);
347                                $info = ldap_get_entries($this->ds, $sr);
348
349                                for ($i=0; $i<$info["count"]; $i++)
350                                        $organizations[$i] = $info[$i]["ou"][0];
351
352                                ldap_close($this->ds);
353                                sort($organizations);
354                                return $organizations;
355                        }else{
356                        return null;
357                }
358        }
359        function get_organizations2($params){
360                $organizations = array();
361                $referral = $params['referral'];
362                $this->ldapRootConnect($referral);
363                if ($this->ds) {
364                        $filter="ou=*";         
365                        $justthese = array("ou");
366                        $sr = ldap_list($this->ds, $this->ldap_context, $filter, $justthese);
367                        $info = ldap_get_entries($this->ds, $sr);
368                       
369                        for ($i=0; $i<$info["count"]; $i++)
370                        {
371                                $organizations[$i]['ou'] = $info[$i]["ou"][0];
372                                $organizations[$i]['dn'] = $info[$i]["dn"];
373                        }
374                       
375                        ldap_close($this->ds);
376                        sort($organizations);                                   
377                }
378                return $organizations;
379        }
380
381        function catalogsearch($params)
382        {       
383                //$this->ldapConnect(true);
384                include("../contactcenter/inc/external_catalogs.inc.php");
385                $cn     = $params['search_for'] ? "*".utf8_encode($params['search_for'])."*" : "*";
386                $max_result       = $params['max_result'] ? $params['max_result'] : '200';
387                $catalog = $params['catalog'];
388                $error = False;
389                       
390                $this->ldapConnect(false,$catalog);
391               
392                $params['organization'] == 'todos'?$user_context = $this->ldap_context :$user_context = $this->branch."=".$params['organization'].",".$this->ldap_context;             
393               
394                if ($this->ds) {                                                                                       
395                        if ($catalog == 0){
396                                //os atributos "employeeNumber" e "ou" foram adicionado ao vetor de busca;
397                                $justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible", "employeeNumber", "ou");
398                                $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(cn=".$cn."))";
399                                //$user_context = "ou=".$params['organization'].",".$this->ldap_context;
400                        }else {
401                                //os atributos "employeeNumber" e "ou" foram adicionado ao vetor de busca;
402                                $justthese = array("cn", "mail", "employeeNumber", "ou");
403                                $filter="(&(objectClass=".$this->object_class.")(cn=".$cn."))";
404                                //$user_context = $this->branch."=".$params['organization'].",".$external_srcs[$catalog]['dn'];
405                        }
406                       
407                        $sr=ldap_search($this->ds, $user_context, $filter, $justthese,0,200);
408                        $count_entries = ldap_count_entries($this->ds,$sr);
409                        if ($count_entries > $max_result){
410                                $info = null;
411                                $error = True;                                         
412                        }
413                        else
414                                $info = ldap_get_entries($this->ds, $sr);               
415                       
416                        ldap_close($this->ds);                 
417                       
418                        $u_tmp = array();
419                        $g_tmp = array();
420                       
421                        for ($i=0; $i<$info["count"]; $i++){
422                                if((!$catalog==0)||(strtoupper($info[$i]["phpgwaccounttype"][0]) == 'U') && ($info[$i]["phpgwaccountvisible"][0] != '-1'))
423                                        //aqui eh feita a concatenacao do departamento ao cn;
424                                        $u_tmp[$info[$i]["mail"][0]] = utf8_decode($info[$i]["cn"][0]). '%' . $info[$i]["ou"][0];
425                                else
426                                        $g_tmp[$info[$i]["mail"][0]] = utf8_decode($info[$i]["cn"][0]);
427                        }                                                                               
428                       
429                        natcasesort($u_tmp);
430                        natcasesort($g_tmp);
431
432                        $i = 0;
433                        $users = array();
434
435
436                        foreach ($u_tmp as $mail => $cn){
437
438                                $tmp = explode("%", $cn); //explode o cn pelo caracter "%" e joga em $tmp;
439                                $name = $tmp[0]; //pega o primeiro item (cn) do vetor resultante do explode acima;
440                                $department = $tmp[1]; //pega o segundo item (ou) do vetor resultanto do explode acima;
441                                $users[$i++] = array("name" => $name, "email" => $mail, "department" => $department);
442
443                        }
444
445                        unset($u_tmp);
446                       
447                        $i = 0;                 
448                        $groups = array();
449                       
450                        foreach ($g_tmp as $mail => $cn){                               
451                                $groups[$i++] = array("name" => $cn, "email" => $mail);
452                        }
453                        unset($g_tmp);
454                       
455                        return  array('users' => $users, 'groups' => $groups, 'error' => $error);
456                }else                           
457                return null;
458        }
459       
460        function get_emails_ldap(){
461
462                $result['mail']= array();
463                $result['mailalter']= array();         
464                $user = $_SESSION['phpgw_info']['expressomail']['user']['account_lid'];
465                $this->ldapRootConnect(false);
466                if ($this->ds) {
467                        $filter="uid=".$user;           
468                        $justthese = array("mail","mailAlternateAddress");
469                        $sr = ldap_search($this->ds,$this->ldap_context, $filter, $justthese);
470                        $ent = ldap_get_entries($this->ds, $sr);
471                        ldap_close($this->ds);
472                       
473                        for ($i=0; $i<$ent["count"]; $i++){
474                                $result['mail'][] = $ent[$i]["mail"][0];
475                                $result['mailalter'][] = $ent[$i]["mailalternateaddress"][0];                           
476                        }
477                }
478                return $result;
479        }
480       
481        //Busca usuï¿œrios de um contexto e jï¿œ retorna as options do select;
482        function get_available_users($params)
483    {
484        $this->ldapRootConnect();
485        //Monta lista de Grupos e Usuï¿œrios
486        $users = Array();
487        $groups = Array();
488        $user_context= $params['context'];
489        $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner'];
490
491        if ($this->ds)
492        {
493            $justthese = array("gidNumber","cn");
494            if ($params['type'] == 'search')
495                $sr=ldap_search($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese);
496            else
497                $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese);
498            $info = ldap_get_entries($this->ds, $sr);
499            for ($i=0; $i<$info["count"]; $i++)
500                $groups[$uids=$info[$i]["gidnumber"][0]] = Array('name'    =>    $uids=$info[$i]["cn"][0], 'type'    =>    g);           
501            $justthese = array("phpgwaccountvisible","uidNumber","cn");
502            if ($params['type'] == 'search')
503                $sr=ldap_search($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese);
504            else
505                $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese);
506
507            $info = ldap_get_entries($this->ds, $sr);
508            for ($i=0; $i<$info["count"]; $i++)
509            {
510                if ($info[$i]["phpgwaccountvisible"][0] == '-1')
511                    continue;
512                $users[$uids=$info[$i]["uidnumber"][0]] = Array('name'    =>    $uids=$info[$i]["cn"][0], 'type'    =>    u);
513            }
514        }
515        ldap_close($this->ds);
516           
517        @asort($users);
518        @reset($users);   
519        @asort($groups);
520        @reset($groups);
521        $user_options ='';
522        $group_options ='';
523
524        foreach($groups as $id => $user_array) {
525                $newId = $id.'U';
526                $group_options .= '<option  value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n";
527        }
528        foreach($users as $id => $user_array) {
529            if($owner != $id){
530                $newId = $id.'U';
531                $user_options .= '<option  value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n";
532            }
533        }
534        return array("users" => $user_options, "groups" => $group_options);
535    }
536
537        //Busca usuï¿œrios de um contexto e jï¿œ retorna as options do select;
538        function get_available_users2($params)
539        {
540                $this->ldapRootConnect();
541               
542                $context= $params['context'];
543                $justthese = array("cn", "uid", "cn");
544                $filter = "(&(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))";
545
546            if ($this->ds)
547            {
548                        $sr=ldap_search($this->ds, $context, $filter, $justthese);
549                        $entries = ldap_get_entries($this->ds, $sr);
550                       
551                        for ($i=0; $i<$entries["count"]; $i++){
552                                if($_SESSION['phpgw_info']['expressomail']['user']['account_lid'] != $entries[$i]["uid"][0]){
553                                        $u_tmp[$entries[$i]["uid"][0]] = $entries[$i]["cn"][0];
554                                }
555                        }
556                       
557                        natcasesort($u_tmp);
558
559                        $i = 0;
560                        $users = array();
561                       
562                        if (count($u_tmp))
563                        {
564                                foreach ($u_tmp as $uidnumber => $cn)
565                                {
566                                        $options .= "<option value=$uidnumber>$cn</option>";
567                                }
568                                unset($u_tmp);
569                        }
570
571                        ldap_close($this->ds);
572                return $options;
573                }
574        }
575       
576        function uid2cn($uid)
577        {       
578                // do not follow the referral
579                $this->ldapRootConnect(false);
580                if ($this->ds)
581                {
582                        $filter="(&(phpgwAccountType=u)(uid=$uid))";           
583                        $justthese = array("cn");
584                        $sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese);
585                       
586                        $info = ldap_get_entries($this->ds, $sr);
587                        return utf8_decode($info[0]["cn"][0]);
588                }
589                return false;
590        }
591        function getSharedUsersFrom($params){           
592                $uids = explode(";",$params['uids']);
593
594                $this->imap = new imap_functions();
595                $filter = '';
596
597                foreach($uids as $index => $uid){
598                        $params = array();             
599                        $acl = $this->imap->getacltouser($uid);
600                        if(preg_match("/a/",$acl))
601                                $filter .= "(uid=$uid)";
602                }
603
604                $this->ldapRootConnect(false);
605                $filter="(&(phpgwAccountType=u)(|$filter))";
606                if ($this->ds) {                                       
607                        $justthese = array("cn","mail");
608                        $sr             =       ldap_search($this->ds, $this->ldap_context, $filter, $justthese);
609                        ldap_sort($this->ds,$sr,"cn");                 
610                        $info   =       ldap_get_entries($this->ds, $sr);
611                        $info['myname'] = $_SESSION['phpgw_info']['expressomail']['user']['fullname'];                                         
612                        for ($i = 0;$i < $info["count"]; $i++)
613                                $info[$i]['cn'][0] = utf8_decode($info[$i]['cn'][0]);
614                        return $info;
615                }
616        }
617
618        function getUserByEmail($params)
619        {
620                $filter="(&(phpgwAccountType=u)(mail=" . $params['email'] . "))";
621                $ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn'];
622                $justthese = array("cn","uid","telephoneNumber","jpegPhoto","mobile");
623
624                // Follow the referral
625                $ds = $this->ldapConnect2(true);
626                if ($ds)
627                {                       
628                        $sr=ldap_search($ds, $ldap_context, $filter, $justthese);
629                       
630                        if (!$sr)
631                                return null;
632                       
633                        $entry = ldap_first_entry($ds, $sr);
634                       
635                        if($entry) {                                           
636                                $obj =  array("cn" => utf8_decode(ldap_get_values($ds, $entry, "cn")),
637                                                  "email" => $params['email'],
638                                                  "uid" => ldap_get_values($ds, $entry, "uid"),
639                                                  "type" => "global",
640                                                  "mobile" =>  @ldap_get_values($ds, $entry, "mobile"),
641                                                  "telefone" =>  @ldap_get_values($ds, $entry, "telephonenumber")
642                                        );
643
644                                $_SESSION['phpgw_info']['expressomail']['contact_photo'] = @ldap_get_values_len($ds, $entry, "jpegphoto");
645                                ldap_close($ds);
646                                return $obj;
647                        }
648                }
649                return null;
650        }
651}
652?>
Note: See TracBrowser for help on using the repository browser.