source: trunk/expressoAdmin1_2/inc/class.uimaillists.inc.php @ 309

Revision 309, 17.1 KB checked in by niltonneto, 16 years ago (diff)

Sincronização com versão publicada em 04/06/2008.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
RevLine 
[2]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                (
[23]16                        'list_maillists'        => True,
17                        'add_maillists'         => True,
18                        'edit_maillists'        => True,
19                        'scl_maillists'         => True,
20                        'css'                           => True
[2]21                );
22
23                var $nextmatchs;
24                var $functions;
25                       
26                function uimaillists()
27                {
28                        $this->maillist         = CreateObject('expressoAdmin1_2.maillist');
29                        $this->functions        = CreateObject('expressoAdmin1_2.functions');
30                        $this->nextmatchs       = CreateObject('phpgwapi.nextmatchs');
31
[23]32                        $c = CreateObject('phpgwapi.config','expressoAdmin1_2');
33                        $c->read_repository();
34                        $this->current_config = $c->config_data;
35
[2]36                        if(!@is_object($GLOBALS['phpgw']->js))
37                        {
38                                $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
39                        }
40                        $GLOBALS['phpgw']->js->validate_file('jscode','connector','expressoAdmin1_2');#diretorio, arquivo.js, aplicacao
41                        $GLOBALS['phpgw']->js->validate_file('jscode','expressoadmin','expressoAdmin1_2');
42                        $GLOBALS['phpgw']->js->validate_file('jscode','maillists','expressoAdmin1_2');
43                }
44               
45                function list_maillists()
46                {
47                       
[64]48                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
49                        $manager_acl = $this->functions->read_acl($manager_lid);
50                        $manager_contexts = $manager_acl['contexts'];
51                        foreach ($manager_acl['contexts_display'] as $index=>$tmp_context)
52                        {
53                                $context_display .= '<br>'.$tmp_context;
54                        }
55                       
[2]56                        // Verifica se tem acesso a este modulo
[64]57                        if (!$this->functions->check_acl($manager_lid,'list_maillists'))
[2]58                        {
59                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
60                        }
61
62                        if(isset($_POST['query']))
63                        {
64                                // limit query to limit characters
65                                if(eregi('^[a-z_0-9_%-].+$',$_POST['query']))
66                                        $GLOBALS['query'] = $_POST['query'];
67                        }
68
69                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
70                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
71                       
[309]72                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Email Lists');
[2]73                        $GLOBALS['phpgw']->common->phpgw_header();
74
75                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
76                        $p->set_file(array('maillists'   => 'maillists.tpl'));
77                        $p->set_block('maillists','list','list');
78                        $p->set_block('maillists','row','row');
79                        $p->set_block('maillists','row_empty','row_empty');
80                       
81                        // Seta as variaveis padroes.
82                        $var = Array(
83                                'th_bg'                                         => $GLOBALS['phpgw_info']['theme']['th_bg'],
84                                'back_url'                                      => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
[309]85                                'add_action'                            => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.add_maillists'),
[64]86                                'add_email_lists_disabled'      => $this->functions->check_acl($manager_lid,'add_maillists') ? '' : 'disabled',
[2]87                                'context_display'                       => $context_display,
[309]88                                'lang_email_lists_uid'          => lang('Email Lists Logins'),
89                                'lang_email_lists_names'        => lang('Email Lists Names'),
90                                'lang_add_email_lists'          => lang('Add Email Lists'),
[2]91                                'lang_edit'                             => lang('Edit'),
[309]92                                'lang_scl'                              => 'SCL',
93                                'lang_delete'                           => 'Excluir',
[2]94                                'lang_view'                                     => lang('View'),
[309]95                                'lang_back'                                     => lang('back'),
96                                'lang_context'                          => lang('context'),
[2]97                                'lang_email'                            => lang('E-mail'),
[309]98                                'lang_search'                           => lang('search')
[2]99                        );
100                        $p->set_var($var);
101
102                        // Save query
103                        $p->set_var('query', $GLOBALS['query']);
104                       
105                        //Admin make a search
106                        if ($GLOBALS['query'] != '')
107                        {
[64]108                                $maillists_info = $this->functions->get_list('maillists', $GLOBALS['query'], $manager_contexts);
[2]109                        }
[309]110                        $total = count($maillists_info);
[2]111
[309]112                        if (!count($total) && $GLOBALS['query'] != '')
[2]113                        {
114                                $p->set_var('message',lang('No matches found'));
115                        }
[309]116                        else if ($total)
[2]117                        {
[64]118                                if ($this->functions->check_acl($manager_lid,'edit_maillists'))
[2]119                                {
120                                        $can_edit = True;
121                                }
[64]122                                if ($this->functions->check_acl($manager_lid,'delete_maillists'))
[2]123                                {
124                                        $can_delete = True;
125                                }
[283]126                                if ($this->functions->check_acl($manager_lid,'edit_scl_email_lists'))
127                                {
128                                        $can_edit_scl = True;
129                                }
[2]130
[283]131
[2]132                                foreach($maillists_info as $maillist)
133                                {
134                                        $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
135                                        $var = array(
136                                                'tr_color'              => $tr_color,
137                                                'row_uid'               => $maillist['uid'],
138                                                'row_name'      => $maillist['name'],
139                                                'row_email'     => $maillist['email']
140                                        );
141                                        $p->set_var($var);
142
143                                        if ($can_edit)
144                                        {
145                                                $p->set_var('edit_link',$this->row_action('edit','maillists',$maillist['uidnumber'],$maillist['uid']));
[283]146                                        }
147                                        else
148                                        {
149                                                $p->set_var('edit_link','&nbsp;');
150                                        }
151
[309]152                                        if ( ($can_edit_scl) && ($this->current_config['expressoAdmin_scl']) )
[283]153                                        {
[23]154                                                $p->set_var('scl_link',$this->row_action('scl','maillists',$maillist['uidnumber'],$maillist['uid']));
[2]155                                        }
156                                        else
157                                        {
[23]158                                                $p->set_var('scl_link','&nbsp;');
[2]159                                        }
160
161                                        if ($can_delete)
162                                        {
[309]163                                                $p->set_var('delete_link',"<a href='#' onClick='javascript:delete_maillist(\"".$maillist['uid']."\",\"".$maillist['uidnumber']."\");'>Excluir</a>");
[2]164                                        }
165                                        else
166                                                $p->set_var('delete_link','&nbsp;');
167                                       
168                                        $p->fp('rows','row',True);
169                                }
170                        }
171                        $p->parse('rows','row_empty',True);
172                        $p->set_var($var);
173                        $p->pfp('out','list');                 
174                }
175               
176                function add_maillists()
177                {
178                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
[64]179
180                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
181                        $manager_acl = $this->functions->read_acl($manager_lid);
182                        $manager_contexts = $manager_acl['contexts'];
183
[2]184                        // Verifica se tem acesso a este modulo
[64]185                        if (!$this->functions->check_acl($manager_lid,'add_maillists'))
[2]186                        {
187                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
188                        }
189
190                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
191                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
[309]192                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create Email List');
[2]193                        $GLOBALS['phpgw']->common->phpgw_header();
194                       
195                        // Set o template
196                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
197                        $p->set_file(Array('create_maillist' => 'maillists_form.tpl'));
198
[180]199                        // Obtem combos das organizações.
[64]200                        foreach ($manager_contexts as $index=>$context)
[180]201                                $combo_manager_org .= $this->functions->get_organizations($context);
[208]202                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], '', true, true, true);                 
[180]203                       
[2]204                        // Seta variaveis utilizadas pelo tpl.
205                        $var = Array(
206                                'color_bg1'                                     => "#E8F0F0",
207                                'color_bg2'                                     => "#D3DCE3",
208                                'type'                                          => 'create_maillist',
209                                'ldap_context'                          => $GLOBALS['phpgw_info']['server']['ldap_context'],
[309]210                                'uid'                                           => 'lista-',
[2]211                                'accountStatus_checked'         => 'CHECKED',
[23]212                                'restrictionsOnEmailLists'      => $this->current_config['expressoAdmin_restrictionsOnEmailLists'],
[2]213                                'lang_back'                                     => lang('Back'),
[309]214                                'lang_save'                                     => lang('save'),
215                                'lang_maillist_organization'=> lang('Maillist Organization'),
216                                'lang_search_organization'      => lang('Search Organiztion'),
[180]217                                'lang_search_user'                      => lang('Search user'),
218                                'lang_organizations'            => lang('Organizations'),
[309]219                                'lang_maillist_uid'                     => lang('Maillist login'),
220                                'lang_maillist_mail'            => lang('Maillist Mail'),
221                                'lang_maillist_name'            => lang('Maillist name'),
222                                'lang_maillist_users'           => lang('Maillist users'),
[2]223                                'lang_add_user'                         => lang('Add User'),
224                                'lang_rem_user'                         => lang('Remove User'),
[23]225                                'lang_all_users'                        => lang('Show users from all sub-organizations'),
[309]226                                'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
227                                'combo_manager_org'                     => $combo_manager_org,
228                                'combo_all_orgs'                        => $combo_all_orgs,
229                                'defaultDomain'                         => $this->current_config['expressoAdmin_defaultDomain']
[2]230                        );
231                        $p->set_var($var);
232                       
233                        $p->pfp('out','create_maillist');
234                }
235               
236                function edit_maillists()
237                {
238                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
[64]239
240                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
241                        $manager_acl = $this->functions->read_acl($manager_lid);
242                        $manager_contexts = $manager_acl['contexts'];
243
[2]244                        // Verifica se tem acesso a este modulo
[64]245                        if (!$this->functions->check_acl($manager_lid,'edit_maillists'))
[2]246                        {
247                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
248                        }
249                       
250                        // GET all infomations about the group.
[64]251                        $maillist_info = $this->maillist->get_info($_GET['uidnumber']);
[2]252                       
253                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
254                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
[309]255                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Email Lists');
[2]256                        $GLOBALS['phpgw']->common->phpgw_header();
257
258                        // Set o template
259                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
260                        $p->set_file(Array('edit_maillist' => 'maillists_form.tpl'));
261
[180]262                        // Obtem combos das organizações.
263                        foreach ($manager_contexts as $index=>$context)
264                                $combo_manager_org .= $this->functions->get_organizations($context, trim(strtolower($maillist_info['context'])));
[208]265                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($maillist_info['context'])), true, true, true);                 
[2]266
267                        // Usuarios da lista.
[73]268                        $user_count = 0;
[180]269                        if (count($maillist_info['mailForwardingAddress_info']) > 0)
[2]270                        {
[180]271                                foreach ($maillist_info['mailForwardingAddress_info'] as $mail=>$userinfo)
[2]272                                {
[180]273                                        $array_users[$mail] = $userinfo['cn'];
274                                        $array_users_uid[$mail] = $userinfo['uid'];
275                                        $array_users_type[$mail] = $userinfo['type'];
[2]276                                }
277                                natcasesort($array_users);
[180]278                                foreach ($array_users as $mail=>$cn)
[2]279                                {
[73]280                                        $user_count++;
[180]281                                        if ($array_users_type[$mail] == 'u')
[23]282                                        {
[180]283                                                $users .= "<option value=" . $mail . ">" . $cn .  " [" . $array_users_uid[$mail] . "]</option>";
[23]284                                        }
[180]285                                        elseif ($array_users_type[$mail] == 'l')
[23]286                                        {
[180]287                                                $lists .= "<option value=" . $mail . ">" . $cn .  " [" . $array_users_uid[$mail] . "]</option>";
[23]288                                        }
[24]289                                        else
290                                        {
[180]291                                                $mail_not_found .= "<option value=" . $mail . ">" . $cn .  " [" . $array_users_uid[$mail] . "]</option>";
[24]292                                        }
[2]293                                }
[23]294                               
[180]295                                if ($mail_not_found != '')
[24]296                                {
[309]297                                        $opt_tmp_mail_not_found = '<option  value="-1" disabled>--------------------&nbsp;&nbsp;&nbsp;&nbsp;E-mails não encontrados&nbsp;&nbsp;&nbsp;&nbsp;------------------ </option>'."\n";
[180]298                                        $ea_select_usersInMaillist .= $opt_tmp_mail_not_found . $mail_not_found;
[24]299                                }
300                                if ($lists != '')
301                                {
[309]302                                        $opt_tmp_lists  = '<option  value="-1" disabled>------------------------------&nbsp;&nbsp;&nbsp;&nbsp;Listas&nbsp;&nbsp;&nbsp;&nbsp;------------------------------ </option>'."\n";
[24]303                                        $ea_select_usersInMaillist .= $opt_tmp_lists . $lists;
304                                }
[309]305                                $opt_tmp_users  = '<option  value="-1" disabled>-----------------------------&nbsp;&nbsp;&nbsp;&nbsp;Usuários&nbsp;&nbsp;&nbsp;&nbsp;---------------------------- </option>'."\n";
[24]306                                $ea_select_usersInMaillist .= $opt_tmp_users . $users;
[2]307                        }
308
309                        // Seta variaveis utilizadas pelo tpl.
310                        $var = Array(
311                                'color_bg1'                                             => "#E8F0F0",
312                                'color_bg2'                                             => "#D3DCE3",
313                                'type'                                                  => 'edit_maillist',
[23]314                                'ldap_context'                                  => $GLOBALS['phpgw_info']['server']['ldap_context'],
[309]315                                'lang_back'                                             => lang('Back'),
316                                'lang_save'                                             => lang('save'),
317                                'lang_maillist_organization'    => lang('Maillist Organization'),
318                                'lang_search_organization'              => lang('Search Organiztion'),
319                                'lang_search_user'                              => lang('Search user'),
320                                'lang_organizations'                    => lang('Organizations'),
321                                'lang_maillist_uid'                             => lang('Maillist login'),
322                                'lang_maillist_mail'                    => lang('Maillist Mail'),
323                                'lang_maillist_name'                    => lang('Maillist name'),
324                                'lang_maillist_users'                   => lang('Maillist users'),
325                                'lang_add_user'                                 => lang('Add User'),
326                                'lang_rem_user'                                 => lang('Remove User'),
327                                'lang_all_users'                                => lang('Select users from all sub-organizations'),
328                                'back_url'                                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
[180]329                                'combo_manager_org'                             => $combo_manager_org,
330                                'combo_all_orgs'                                => $combo_all_orgs,
[2]331                                'uidnumber'                                             => $_GET['uidnumber'],
332                                'uid'                                                   => $maillist_info['uid'],
333                                'mail'                                                  => $maillist_info['mail'],
334                                'cn'                                                    => $maillist_info['cn'],
[73]335                                'user_count'                                    => $user_count,
[2]336                                'accountStatus_checked'                 => $maillist_info['accountStatus'] == 'active' ? 'CHECKED' : '',
337                                'phpgwAccountVisible_checked'   => $maillist_info['phpgwAccountVisible'] == '-1' ? 'CHECKED' : '',
[180]338                                'ea_select_usersInMaillist'             => $ea_select_usersInMaillist,
[309]339                                'defaultDomain'                                 => $this->current_config['expressoAdmin_defaultDomain']
[2]340                        );
341                        $p->set_var($var);
342                       
343                        $p->pfp('out','edit_maillist');
344                }
[23]345               
346                function scl_maillists()
347                {
348                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
349                       
[64]350                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
351                        $manager_acl = $this->functions->read_acl($manager_lid);
352                        $manager_contexts = $manager_acl['contexts'];
353                                               
[23]354                        // Verifica se tem acesso a este modulo
[64]355                        if (!$this->functions->check_acl($manager_lid,'edit_maillists'))
[23]356                        {
357                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
358                        }
359                       
360                        // GET all infomations about the group.
[64]361                        $maillist_info = $this->maillist->get_scl_info($_GET['uidnumber']);
[23]362                       
363                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
364                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
[309]365                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Sending Control List');
[23]366                        $GLOBALS['phpgw']->common->phpgw_header();
367
368                        // Set o template
369                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
370                        $p->set_file(Array('sql_maillist' => 'maillists_scl.tpl'));
371
372                        // Pega combo das organizações e seleciona a org da lista.
[64]373                        // $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context'])));
374                        foreach ($manager_contexts as $index=>$context)
375                                $sectors .= $this->functions->get_organizations($context, trim(strtolower($maillist_info['context'])) );
[23]376
377                        // Usuarios de senders.
378                        if (count($maillist_info['senders_info']) > 0)
379                        {
[208]380                                foreach ($maillist_info['senders_info'] as $mail=>$senderinfo)
[23]381                                {
[208]382                                        $array_senders[$mail] = $senderinfo['cn'];
[23]383                                }
384                                natcasesort($array_senders);
[208]385                                foreach ($array_senders as $mail=>$cn)
[23]386                                {
[208]387                                        $ea_select_users_SCL_Maillist .= "<option value=" . $mail . ">" . $cn . " [" . $mail . "]</option>";
[23]388                                }
389                        }
390
391                        // Seta variaveis utilizadas pelo tpl.
392                        $var = Array(
393                                'color_bg1'                                             => "#E8F0F0",
394                                'color_bg2'                                             => "#D3DCE3",
395                                'type'                                                  => 'edit_maillist',
396                                'ldap_context'                                  => $GLOBALS['phpgw_info']['server']['ldap_context'],
397                                'dn'                                                    => $maillist_info['dn'],
[309]398                                'lang_back'                                             => lang('Back'),
399                                'lang_save'                                             => lang('save'),
400                                'lang_org'                                              => lang('Organizations'),
401                                'lang_maillist_uid'                             => lang('Maillist login'),
402                                'lang_maillist_mail'                    => lang('Maillist Mail'),
403                                'lang_maillist_name'                    => lang('Maillist name'),
404                                'lang_maillist_users'                   => lang('Maillist users'),
405                                'lang_add_user'                                 => lang('Add User'),
406                                'lang_rem_user'                                 => lang('Remove User'),
407                                'lang_all_users'                                => lang('Show users from all sub-organizations'),
[23]408                                'back_url'                                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
[64]409                                'combo_org'                                             => $sectors,
[23]410                                'uidnumber'                                             => $_GET['uidnumber'],
411                                'uid'                                                   => $maillist_info['uid'],
412                                'mail'                                                  => $maillist_info['mail'],
413                                'cn'                                                    => $maillist_info['cn'],
414                                'accountRestrictive_checked'    => $maillist_info['accountRestrictive'] == 'mailListRestriction' ? 'CHECKED' : '',
[309]415                                'participantCanSendMail_checked'=> $maillist_info['participantCanSendMail'] == 'TRUE' ? 'CHECKED' : '',
416                                'ea_select_users_SCL_Maillist'  => $ea_select_users_SCL_Maillist
[23]417                        );
418                        $p->set_var($var);
419                       
420                        $p->pfp('out','sql_maillist');
421                }
422               
[2]423                function row_action($action,$type,$uidnumber,$maillist_uid)
424                {
425                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
426                                'menuaction'            => 'expressoAdmin1_2.uimaillists.'.$action.'_'.$type,
427                                'uidnumber'                     => $uidnumber,
428                                'maillist_uid'          => $maillist_uid
429                        )).'"> '.lang($action).' </a>';
430                }
431               
432                function css()
433                {
434                        $appCSS = '';
435                        return $appCSS;
436                }
437        }
438?>
Note: See TracBrowser for help on using the repository browser.