source: companies/serpro/expressoAdmin1_2/inc/class.uimaillists.inc.php @ 903

Revision 903, 25.9 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

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