source: contrib/listAdmin/inc/class.uimaillists.inc.php @ 3312

Revision 3312, 25.4 KB checked in by rafaelraymundo, 14 years ago (diff)

Ticket #1174 - Disponibilização do módulo de Listas(Mailman)

Line 
1<?php
2        /*************************************************************************************\
3        * Expresso Administração                                                                                                     *
4        * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br)        *
5        * -----------------------------------------------------------------------------------*
6        *  This program is free software; you can redistribute it and/or modify it                       *
7        *  under the terms of the GNU General Public License as published by the                         *
8        *  Free Software Foundation; either version 2 of the License, or (at your                        *
9        *  option) any later version.                                                                                                            *
10        \*************************************************************************************/
11
12        class uimaillists
13        {
14                var $public_functions = array
15                (
16                        'list_maillists'        => True,
17                        'add_maillists'         => True,
18                        'edit_maillists'        => True,
19                        'scl_maillists'         => True,
20                        'adm_maillists'         => True,
21                        'css'                   => True
22                );
23
24                var $nextmatchs;
25                var $functions;
26                       
27                function uimaillists()
28                {
29                        $this->maillist         = CreateObject('listAdmin.maillist');
30                        $this->functions        = CreateObject('listAdmin.functions');
31                        $this->ldap_functions   = CreateObject('listAdmin.ldap_functions');
32                        $this->nextmatchs       = CreateObject('phpgwapi.nextmatchs');
33
34                        $c = CreateObject('phpgwapi.config','listAdmin');
35                        $c->read_repository();
36                        $this->current_config = $c->config_data;
37
38                        if(!@is_object($GLOBALS['phpgw']->js))
39                        {
40                                $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
41                        }
42                        $GLOBALS['phpgw']->js->validate_file('jscode','connector','listAdmin');#diretorio, arquivo.js, aplicacao
43                        $GLOBALS['phpgw']->js->validate_file('jscode','expressoadmin','listAdmin');
44                        $GLOBALS['phpgw']->js->validate_file('jscode','maillists','listAdmin');
45                }
46               
47                function list_maillists()
48                {
49                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
50                        //$acl = $this->functions->read_acl($account_lid);
51                        $context = $GLOBALS['phpgw_info']['server']['ldap_context']; //$acl[0]['context'];
52                        $context_display = ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']); //$acl[0]['context_display'];
53                       
54                        if(isset($_POST['query']))
55                        {
56                                // limit query to limit characters
57                                if(eregi('^[a-z_0-9_%-].+$',$_POST['query']))
58                                        $GLOBALS['query'] = $_POST['query'];
59                        }
60
61                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
62                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
63                       
64                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['listAdmin']['title'].' - '.lang('Email Lists');
65                        $GLOBALS['phpgw']->common->phpgw_header();
66
67                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
68                        $p->set_file(array('maillists'   => 'maillists.tpl'));
69                        $p->set_block('maillists','list','list');
70                        $p->set_block('maillists','row','row');
71                        $p->set_block('maillists','row_empty','row_empty');
72
73
74                        //Pega o id do usuario atual da sessao
75                        $usuarioAtual=$_SESSION['phpgw_info']['expresso']['user']['account_lid'];
76                        //Pega o uidnumber do usuario atual
77                        $admUidnumber = $this->ldap_functions->uid2uidnumber($usuarioAtual);
78
79                        //Pega o email do usuario atual
80                        $admlista = $this->ldap_functions->uidnumber2mail($admUidnumber);
81
82                        $desabilitado = 'disabled';
83
84                        if($this->ldap_functions->is_user_listAdmin($usuarioAtual) == 1)
85                        {
86                                $desabilitado = '';
87                                $can_edit = True;
88                                $can_delete = True;
89                        }
90                        else
91                        {
92                                $can_edit = True;
93                                $can_delete = False;
94                        }
95
96
97                        // Seta as variaveis padroes.
98                        $var = Array(
99                                'th_bg'                                 => $GLOBALS['phpgw_info']['theme']['th_bg'],
100                                'back_url'                              => $GLOBALS['phpgw']->link('/listAdmin/index.php'),
101                                'add_action'                            => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.add_maillists'),
102                                'add_email_lists_disabled'              => $this->functions->check_acl($account_lid,'add_maillists') ? '' : 'disabled',
103                                'context'                               => $context,
104                                'context_display'                       => $context_display,
105                                'desabilitado'                          => $desabilitado,
106                                'lang_email_lists_uid'                  => lang('Email Lists Logins'),
107                                'lang_email_lists_names'                => lang('Email Lists Names'),
108                                'lang_add_email_lists'                  => lang('Add Email Lists'),
109                                'lang_edit'                             => lang('Edit'),
110                                'lang_scl'                              => 'SCL',
111                                'lang_adm'                              => 'ADM',
112                                'lang_delete'                           => 'Excluir',
113                                'lang_view'                             => lang('View'),
114                                'lang_back'                             => lang('back'),
115                                'lang_context'                          => lang('context'),
116                                'lang_email'                            => lang('E-mail'),
117                                'lang_search'                           => lang('search')
118                        );
119                        $p->set_var($var);
120
121                        // Save query
122                        $p->set_var('query', $GLOBALS['query']);
123
124                        //Variavel recebe o contexto onde estao gravadas as listas no sistema;
125                        $contextoListas = $this->current_config['dn_listas'];
126
127                        //Admin make a search
128                        if( ($GLOBALS['query'] != '') && (strlen($GLOBALS['query']) < 4) ) {
129                                $p->set_var('message',lang('Search argument too short'));
130                        }else if ($GLOBALS['query'] != ''){
131                                //Pede a lista de listas para o usuario atual
132                                $maillists_info = $this->functions->get_list('maillists', $GLOBALS['query'], $contextoListas, $admlista);
133                        }
134
135                        $total = count($maillists_info);
136
137
138                        if (!count($total) && $GLOBALS['query'] != '')
139                        {
140                                $p->set_var('message',lang('No matches found'));
141                        }
142                        else if ($total)
143                        {
144
145                                foreach($maillists_info as $maillist)
146                                {
147                                        $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
148                                        $var = array(
149                                                'tr_color'              => $tr_color,
150                                                'row_uid'               => $maillist['uid'],
151                                                'row_name'              => $maillist['name'],
152                                                'row_email'             => $maillist['email']
153                                        );
154                                        $p->set_var($var);
155
156                                        if ($can_edit)
157                                        {
158                                                $p->set_var('edit_link',$this->row_action('edit','maillists',$maillist['uidnumber'],$maillist['uid']));
159                                                $p->set_var('scl_link',$this->row_action('scl','maillists',$maillist['uidnumber'],$maillist['uid']));
160                                                $p->set_var('adm_link',$this->row_action('adm','maillists',$maillist['uidnumber'],$maillist['uid']));
161                                        }
162                                        else
163                                        {
164                                                $p->set_var('edit_link','&nbsp;');
165                                                $p->set_var('scl_link','&nbsp;');
166                                                $p->set_var('adm_link','&nbsp;');
167                                        }
168
169                                        if ($can_delete)
170                                        {
171                                                $p->set_var('delete_link',"<a href='#' onClick='javascript:delete_maillist(\"".$maillist['uid']."\",\"".$maillist['uidnumber']."\",\"".$context."\");'>Excluir</a>");
172                                        }
173                                        else
174                                        {
175                                                $p->set_var('delete_link','&nbsp;');
176                                        }
177                                       
178                                        $p->fp('rows','row',True);
179                                }
180                        }
181                        $p->parse('rows','row_empty',True);
182                        $p->set_var($var);
183                        $p->pfp('out','list');
184
185                }
186               
187                function add_maillists()
188                {
189                        //$GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
190                       
191                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
192                        //$acl = $this->functions->read_acl($account_lid);
193                        //$context = $acl[0]['context'];
194                        $context = $GLOBALS['phpgw_info']['server']['ldap_context']; //$acl[0]['context'];
195                        //$context_display = ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']); //$acl[0]['context_display'];
196                       
197                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
198                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
199                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['listAdmin']['title'].' - '.lang('Create Email List');
200                        $GLOBALS['phpgw']->common->phpgw_header();
201                       
202                        // Set o template
203                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
204                        $p->set_file(Array('create_maillist' => 'maillists_form.tpl'));
205
206                        // Pega combo das organizações.
207                        $org = $this->functions->get_organizations($context, '');
208
209                        // Seta variaveis utilizadas pelo tpl.
210                        $var = Array(
211                                'color_bg1'                                     => "#E8F0F0",
212                                'color_bg2'                                     => "#D3DCE3",
213                                'type'                                          => 'create_maillist',
214                                'ldap_context'                                  => $GLOBALS['phpgw_info']['server']['ldap_context'],
215                                'uid'                                           => 'lista-',
216                                'exibir_div'                                    => ' style="display: none;" ',
217                                'accountStatus_checked'                         => 'CHECKED',
218//                              'defaultMemberModeration_checked'               => 'CHECKED',   
219                                'accountAdm_checked'                            => 'CHECKED',
220                                'restrictionsOnEmailLists'                      => $this->current_config['expressoAdmin_restrictionsOnEmailLists'],
221                                'lang_back'                                     => lang('Back'),
222                                'lang_save'                                     => lang('save'),
223                                'lang_org'                                      => lang('Organizations'),
224                                'lang_maillist_uid'                             => lang('Maillist login'),
225                                'lang_maillist_mail'                            => lang('Maillist Mail'),
226                                'lang_maillist_name'                            => lang('Maillist name'),
227                                'lang_maillist_description'                     => lang('Maillist description'),
228                                'lang_maillist_users'                           => lang('Maillist users'),
229                                'lang_add_user'                                 => lang('Add User'),
230                                'lang_rem_user'                                 => lang('Remove User'),
231                                'lang_all_users'                                => lang('Show users from all sub-organizations'),
232                                'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.list_maillists'),
233                                'combo_org'                                     => $org,
234                                'ea_select_usersInMaillist'                     => $ea_select_usersInMaillist
235                        );
236                        $p->set_var($var);
237                       
238                        $p->pfp('out','create_maillist');
239                }
240               
241               
242                function edit_maillists()
243                {
244       
245                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
246                       
247                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
248                        //$acl = $this->functions->read_acl($account_lid);
249                        //$manager_context = $acl[0]['context'];
250                        $manager_context = $GLOBALS['phpgw_info']['server']['ldap_context']; //$acl[0]['context'];
251                        //$context_display = ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']); //$acl[0]['context_display'];
252                       
253
254                        //Teste o tipo de lista que esta sendo editada (corporativa ou funcional);
255                        $uid_lista = $_GET['maillist_uid']; //recebe o uid da lista selecionada;
256                        $str = explode("-", $uid_lista); //separa pelo "-";
257                        $str = $str[0]; //pega o primeiro elemento, que neste caso e o que indica o tipo de lista
258
259                        $somente_leitura = "";
260                        $desabilitado = "";
261                        if(($str == "listacorp") || ($str == "listafunc")) {
262                                $somente_leitura = "readonly"; //se lista for corp ou func, a variavel recebe readonly - sera usada em todos os input do form de edicao de listas;
263                                $desabilitado = "disabled";
264                        }
265
266                        //Pega o id do administrador do Expresso (expresso-admin)
267                        $expressoAdmin                                          = $GLOBALS['phpgw_info']['server']['header_admin_user'];
268
269                        //Pega o id do usuario atual da sessao
270                        $usuarioAtual                                           = $_SESSION['phpgw_info']['expresso']['user']['account_lid'];
271
272                        if($expressoAdmin != $usuarioAtual) {
273
274                                $soAdminLe = "readonly"; //se usuarioAtual for diferente de expressoAdmin, a variavel recebe readonly - sera usada nos input com uid, mail e cn da lista;
275
276                        }
277
278
279
280
281                        // GET all infomations about the group.
282                        $maillist_info = $this->maillist->get_info($_GET['uidnumber'], $manager_context);
283                        // debug_array($maillist_info);
284                                       
285       
286                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
287                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
288                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['listAdmin']['title'].' - '.lang('Edit Email Lists');
289                        $GLOBALS['phpgw']->common->phpgw_header();
290
291                        // Set o template
292                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
293                        $p->set_file(Array('edit_maillist' => 'maillists_form.tpl'));
294
295                        // Pega combo das organizações e seleciona a org da lista.
296                        $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context'])));
297
298                        // Usuarios da lista.
299                        if (count($maillist_info['members_info']) > 0)
300                        {
301                                foreach ($maillist_info['members_info'] as $uidnumber=>$userinfo)
302                                {
303                                        $array_users[$uidnumber] = $userinfo['cn'];
304                                        $array_users_uid[$uidnumber] = $userinfo['uid'];
305                                        $array_users_type[$uidnumber] = $userinfo['type'];
306                                }
307                                natcasesort($array_users);
308                                foreach ($array_users as $uidnumber=>$cn)
309                                {
310                                        if ($array_users_type[$uidnumber] == 'u')
311                                        {
312                                                //$users .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
313                                                $users .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $maillist_info['members_info'][$uidnumber]['mail'] . "]</option>";
314                                        }
315                                        elseif ($array_users_type[$uidnumber] == 'l')
316                                        {
317                                                $lists .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
318                                        }
319                                        else
320                                        {
321                                                $unknow .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
322                                        }
323                                }
324                               
325                                if ($unknow != '')
326                                {
327                                        //$opt_tmp_unknow = '<option  value="-1" disabled>--------------------&nbsp;&nbsp;&nbsp;&nbsp;E-mails não encontrados&nbsp;&nbsp;&nbsp;&nbsp;------------------ </option>'."\n";
328                                        $opt_tmp_unknow = '<option  value="-1" disabled>-----------&nbsp;&nbsp;&nbsp;Usu&aacute;rios n&atilde;o pertencentes ou n&atilde;o criados no Expresso&nbsp;&nbsp;&nbsp;---------- </option>'."\n";
329                                        $ea_select_usersInMaillist .= $opt_tmp_unknow . $unknow;
330                                }
331                                if ($lists != '')
332                                {
333                                        $opt_tmp_lists  = '<option  value="-1" disabled>------------------------------&nbsp;&nbsp;&nbsp;&nbsp;Listas&nbsp;&nbsp;&nbsp;&nbsp;------------------------------ </option>'."\n";
334                                        $ea_select_usersInMaillist .= $opt_tmp_lists . $lists;
335                                }
336                                $opt_tmp_users  = '<option  value="-1" disabled>-----------------------------&nbsp;&nbsp;&nbsp;&nbsp;Usuários&nbsp;&nbsp;&nbsp;&nbsp;---------------------------- </option>'."\n";
337                                $ea_select_usersInMaillist .= $opt_tmp_users . $users;
338                        }
339
340                        // Seta variaveis utilizadas pelo tpl.
341                        $var = Array(
342                                'color_bg1'                                     => "#E8F0F0",
343                                'color_bg2'                                     => "#D3DCE3",
344                                'type'                                          => 'edit_maillist',
345                                'ldap_context'                                  => $GLOBALS['phpgw_info']['server']['ldap_context'],
346                                'lang_back'                                     => lang('Back'),
347                                'lang_save'                                     => lang('save'),
348                                'lang_org'                                      => lang('Organizations'),
349                                'lang_maillist_uid'                             => lang('Maillist login'),
350                                'lang_maillist_mail'                            => lang('Maillist Mail'),
351                                'lang_maillist_name'                            => lang('Maillist name'),
352                                'lang_maillist_users'                           => lang('Maillist users'),
353                                'lang_maillist_description'                     => lang('Maillist description'),
354                                'lang_add_user'                                 => lang('Add User'),
355                                'lang_rem_user'                                 => lang('Remove User'),
356                                'lang_all_users'                                => lang('Select users from all sub-organizations'),
357                                'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.list_maillists'),
358//                              'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.list_maillists'),
359                                'combo_org'                                     => $org,
360                                'manager_context'                               => $manager_context,
361                                'somente_leitura'                               => $somente_leitura, //recebe a variavel testada acima;
362                                'desabilitado'                                  => $desabilitado, //recebe a variavel testada acima;
363                                'soAdminLe'                                     => $soAdminLe, //recebe a variavel testada acima;
364                                'uidnumber'                                     => $_GET['uidnumber'],
365                                'uid'                                           => $maillist_info['uid'],
366                                'defaultMemberModeration'                       => $maillist_info['defaultMemberModeration'],
367                                'admlista'                                      => $maillist_info['admlista'],
368                                'listPass'                                      => $maillist_info['listPass'],
369                                'exibir_div'                                    => '',
370                                'mail'                                          => $maillist_info['mail'],
371                                'description'                                   => $maillist_info['description'],
372                                'cn'                                            => $maillist_info['cn'],
373                                'accountStatus_checked'                         => $maillist_info['accountStatus'] == 'active' ? 'CHECKED' : '',
374                                'accountAdm_checked'                            => $maillist_info['accountAdm'] == 'active' ? 'CHECKED' : '',
375
376                                'phpgwAccountVisible_checked'                   => $maillist_info['phpgwAccountVisible'] == '-1' ? 'CHECKED' : '',
377                                'defaultMemberModeration_checked'               => $maillist_info['defaultMemberModeration'] == '1' ? 'CHECKED' : '',
378                                'ea_select_usersInMaillist'                     => $ea_select_usersInMaillist
379                        );
380                        $p->set_var($var);
381                       
382                        $p->pfp('out','edit_maillist');
383                }
384               
385                function adm_maillists() //Funcao que trata do modulo/template de administradores de listas
386                {
387       
388//                      $GLOBALS['phpgw']->js->set_onload('get_available_users_only(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
389                       
390                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
391                        //$acl = $this->functions->read_acl($account_lid);
392                        //$manager_context = $acl[0]['context'];
393                        $manager_context = $GLOBALS['phpgw_info']['server']['ldap_context']; //$acl[0]['context'];
394                        //$context_display = ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']); //$acl[0]['context_display'];
395                       
396                        //Teste o tipo de lista que esta sendo editada (corporativa ou funcional);
397                        $uid_lista = $_GET['maillist_uid']; //recebe o uid da lista selecionada;
398                        $str = explode("-", $uid_lista); //separa pelo "-";
399                        $str = $str[0]; //pega o primeiro elemento, que neste caso e o que indica o tipo de lista
400
401                        $somente_leitura = "";
402                        $desabilitado = "";
403                        if(($str == "listacorp") || ($str == "listafunc")) {
404                                $somente_leitura = "readonly"; //se lista for corp ou func, a variavel recebe readonly - sera usada nos input com uid, mail e cn da lista;
405                                $desabilitado = "disabled";
406                        }
407
408
409                        // GET all infomations about the group.
410                        $maillist_info = $this->maillist->get_adm_info($_GET['uidnumber'], $manager_context);
411                        // debug_array($maillist_info);
412                                       
413       
414                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
415                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
416                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['listAdmin']['title'].' - '.lang('Admin Lists');
417                        $GLOBALS['phpgw']->common->phpgw_header();
418
419                        // Set o template
420                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
421                        $p->set_file(Array('adm_maillist' => 'maillists_adm.tpl'));
422
423                        // Pega combo das organizações e seleciona a org da lista.
424                        $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context'])));
425
426                        // Usuarios da lista.
427                        if (count($maillist_info['members_info']) > 0)
428                        {
429                                foreach ($maillist_info['members_info'] as $uidnumber=>$userinfo)
430                                {
431                                        $array_users[$uidnumber] = $userinfo['cn'];
432                                        $array_users_uid[$uidnumber] = $userinfo['uid'];
433                                        $array_users_type[$uidnumber] = $userinfo['type'];
434                                }
435                                natcasesort($array_users);
436                                foreach ($array_users as $uidnumber=>$cn)
437                                {
438                                        if ($array_users_type[$uidnumber] == 'u')
439                                        {
440//                                              $users .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
441                                                $users .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $maillist_info['members_info'][$uidnumber]['mail'] . "]</option>";
442                                        }
443                                        else
444                                        {
445                                                $unknow .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
446                                        }
447                                }
448                               
449                                if ($unknow != '')
450                                {
451                                        //$opt_tmp_unknow = '<option  value="-1" disabled>--------------------&nbsp;&nbsp;&nbsp;&nbsp;E-mails não encontrados&nbsp;&nbsp;&nbsp;&nbsp;------------------ </option>'."\n";
452                                        $opt_tmp_unknow = '<option  value="-1" disabled>-----------&nbsp;&nbsp;&nbsp;Usu&aacute;rios n&atilde;o pertencentes ou n&atilde;o criados no Expresso&nbsp;&nbsp;&nbsp;---------- </option>'."\n";
453                                        $ea_select_ADM_Maillist .= $opt_tmp_unknow . $unknow;
454                                }
455                                $opt_tmp_users  = '<option  value="-1" disabled>-----------------------------&nbsp;&nbsp;&nbsp;&nbsp;Usuários&nbsp;&nbsp;&nbsp;&nbsp;---------------------------- </option>'."\n";
456                                $ea_select_ADM_Maillist .= $opt_tmp_users . $users;
457                        }
458
459                        // Seta variaveis utilizadas pelo tpl.
460                        $var = Array(
461                                'color_bg1'                                     => "#E8F0F0",
462                                'color_bg2'                                     => "#D3DCE3",
463                                'type'                                          => 'adm_maillist',
464                                'ldap_context'                                  => $GLOBALS['phpgw_info']['server']['ldap_context'],
465                                'dn_listas'                                     => $GLOBALS['phpgw_info']['server']['dn_listas'],
466                                'lang_back'                                     => lang('Back'),
467                                'lang_save'                                     => lang('save'),
468                                'lang_org'                                      => lang('Organizations'),
469                                'lang_maillist_uid'                             => lang('Maillist login'),
470                                'lang_maillist_mail'                            => lang('Maillist Mail'),
471                                'lang_maillist_name'                            => lang('Maillist name'),
472                                'lang_maillist_description'                     => lang('Maillist description'),
473                                'lang_maillist_users'                           => lang('Maillist users'),
474                                'lang_maillist_adm'                             => lang('Maillist adm'),
475                                'lang_add_user'                                 => lang('Add User'),
476                                'lang_rem_user'                                 => lang('Remove User'),
477                                'lang_all_users'                                => lang('Select users from all sub-organizations'),
478                                'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.list_maillists'),
479                                'combo_org'                                     => $org,
480                                'teste'                                         => $maillist_info['context'],
481                                'manager_context'                               => $manager_context,
482                                'uidnumber'                                     => $_GET['uidnumber'],
483                                'uid'                                           => $maillist_info['uid'],
484                                'admlista'                                      => $maillist_info['admlista'],
485                                'somente_leitura'                               => $somente_leitura, //recebe a variavel testada acima;
486                                'desabilitado'                                  => $desabilitado, //recebe a variavel testada acima;
487                                'mail'                                          => $maillist_info['mail'],
488                                'cn'                                            => $maillist_info['cn'],
489                                'description'                                   => $maillist_info['description'],
490                                'accountStatus_checked'                         => $maillist_info['accountStatus'] == 'active' ? 'CHECKED' : '',
491                                'accountAdm_checked'                            => $maillist_info['accountAdm'] == 'active' ? 'CHECKED' : '',
492
493                                'phpgwAccountVisible_checked'                   => $maillist_info['phpgwAccountVisible'] == '-1' ? 'CHECKED' : '',
494                                'ea_select_ADM_Maillist'                        => $ea_select_ADM_Maillist
495                        );
496
497                        $p->set_var($var);
498                       
499                        $p->pfp('out','adm_maillist');
500                }
501
502                function scl_maillists()
503                {
504                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
505                       
506                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
507                        //$acl = $this->functions->read_acl($account_lid);
508                        //$manager_context = $acl[0]['context'];
509                        $manager_context = $GLOBALS['phpgw_info']['server']['ldap_context']; //$acl[0]['context'];
510                        //$context_display = ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']); //$acl[0]['context_display'];
511                       
512                        //Teste o tipo de lista que esta sendo editada (corporativa ou funcional);
513                        $uid_lista = $_GET['maillist_uid']; //recebe o uid da lista selecionada;
514                        $str = explode("-", $uid_lista); //separa pelo "-";
515                        $str = $str[0]; //pega o primeiro elemento, que neste caso e o que indica o tipo de lista
516
517                        $somente_leitura = "";
518                        $desabilitado = "";
519                        if(($str == "listacorp") || ($str == "listafunc")) {
520                                $somente_leitura = "readonly"; //se lista for corp ou func, a variavel recebe readonly - sera usada nos input com uid, mail e cn da lista;
521                                $desabilitado = "disabled";
522                        }
523
524                        // GET all infomations about the group.
525                        $maillist_info = $this->maillist->get_scl_info($_GET['uidnumber'], $manager_context);
526                        //_debug_array($maillist_info);
527                       
528                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
529                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
530                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['listAdmin']['title'].' - '.lang('Edit Sending Control List');
531                        $GLOBALS['phpgw']->common->phpgw_header();
532
533                        // Set o template
534                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
535                        $p->set_file(Array('sql_maillist' => 'maillists_scl.tpl'));
536
537                        // Pega combo das organizações e seleciona a org da lista.
538                        $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context'])));
539
540                        // Usuarios de senders.
541                        if (count($maillist_info['senders_info']) > 0)
542                        {
543                                foreach ($maillist_info['senders_info'] as $uidnumber=>$senderinfo)
544                                {
545                                        $array_senders[$uidnumber] = $senderinfo['cn'];
546                                }
547                                natcasesort($array_senders);
548                                foreach ($array_senders as $uidnumber=>$cn)
549                                {
550                                        $ea_select_users_SCL_Maillist .= "<option value=" . $uidnumber . ">" . $cn . " [" . $maillist_info['senders_info'][$uidnumber]['mail'] . "]</option>";
551                                }
552                        }
553
554                        // Seta variaveis utilizadas pelo tpl.
555                        $var = Array(
556                                'color_bg1'                                     => "#E8F0F0",
557                                'color_bg2'                                     => "#D3DCE3",
558                                'type'                                          => 'edit_maillist',
559                                'ldap_context'                                  => $GLOBALS['phpgw_info']['server']['ldap_context'],
560                                'dn'                                            => $maillist_info['dn'],
561                                'lang_back'                                     => lang('Back'),
562                                'lang_save'                                     => lang('save'),
563                                'lang_org'                                      => lang('Organizations'),
564                                'lang_maillist_uid'                             => lang('Maillist login'),
565                                'lang_maillist_mail'                            => lang('Maillist Mail'),
566                                'lang_maillist_name'                            => lang('Maillist name'),
567                                'lang_maillist_description'                     => lang('Maillist description'),
568                                'lang_maillist_users'                           => lang('Maillist users'),
569                                'lang_add_user'                                 => lang('Add User'),
570                                'lang_rem_user'                                 => lang('Remove User'),
571                                'lang_all_users'                                => lang('Show users from all sub-organizations'),
572                                'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=listAdmin.uimaillists.list_maillists'),
573                                'combo_org'                                     => $org,
574                                'manager_context'                               => $manager_context,
575                                'uidnumber'                                     => $_GET['uidnumber'],
576                                'uid'                                           => $maillist_info['uid'],
577                                'mail'                                          => $maillist_info['mail'],
578                                'cn'                                            => $maillist_info['cn'],
579                                'description'                                   => $maillist_info['description'],
580                                'admlista'                                      => $maillist_info['admlista'],
581                                'somente_leitura'                               => $somente_leitura, //recebe a variavel testada acima;
582                                'desabilitado'                                  => $desabilitado, //recebe a variavel testada acima;
583                                'listPass'                                      => $maillist_info['listPass'],
584                                'accountRestrictive_checked'                    => $maillist_info['accountRestrictive'] == 'mailListRestriction' ? 'CHECKED' : '',
585                                'participantCanSendMail_checked'                => $maillist_info['participantCanSendMail'] == 'TRUE' ? 'CHECKED' : '',
586                                'ea_select_users_SCL_Maillist'                  => $ea_select_users_SCL_Maillist
587                        );
588                        $p->set_var($var);
589                       
590                        $p->pfp('out','sql_maillist');
591                }
592       
593                function row_action($action,$type,$uidnumber,$maillist_uid)
594                {
595                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
596                                'menuaction'                                    => 'listAdmin.uimaillists.'.$action.'_'.$type,
597                                'uidnumber'                                     => $uidnumber,
598                                'maillist_uid'                                  => $maillist_uid
599                                )).'"> '.lang($action).' </a>';
600                }
601               
602                function css()
603                {
604                        $appCSS = '';
605                        return $appCSS;
606                }
607        }
608?>
Note: See TracBrowser for help on using the repository browser.