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

Revision 233, 17.9 KB checked in by wmerlotto, 16 years ago (diff)

Internacionalizacao do ExpressoAdmin

  • Property svn:eol-style set to native
  • Property svn:executable set to *
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                        'css'                           => True
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
32                        $c = CreateObject('phpgwapi.config','expressoAdmin1_2');
33                        $c->read_repository();
34                        $this->current_config = $c->config_data;
35
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                       
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                       
56                        // Verifica se tem acesso a este modulo
57                        if (!$this->functions->check_acl($manager_lid,'list_maillists'))
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                       
72                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Email Lists');
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'),
85                                'add_action'                            => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.add_maillists'),
86                                'add_email_lists_disabled'      => $this->functions->check_acl($manager_lid,'add_maillists') ? '' : 'disabled',
87                                'context_display'                       => $context_display,
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'),
91                                'lang_edit'                             => lang('Edit'),
92                                'lang_scl'                              => 'SCL',
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                       
105                        //Admin make a search
106                        if ($GLOBALS['query'] != '')
107                        {
108                                $maillists_info = $this->functions->get_list('maillists', $GLOBALS['query'], $manager_contexts);
109                        }
110                        $total = count($maillists_info);
111
112
113                        if (!count($total) && $GLOBALS['query'] != '')
114                        {
115                                $p->set_var('message',lang('No matches found'));
116                        }
117                        else if ($total)
118                        {
119                                if ($this->functions->check_acl($manager_lid,'edit_maillists'))
120                                {
121                                        $can_edit = True;
122                                }
123                                if ($this->functions->check_acl($manager_lid,'delete_maillists'))
124                                {
125                                        $can_delete = True;
126                                }
127
128                                foreach($maillists_info as $maillist)
129                                {
130                                        $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
131                                        $var = array(
132                                                'tr_color'              => $tr_color,
133                                                'row_uid'               => $maillist['uid'],
134                                                'row_name'      => $maillist['name'],
135                                                'row_email'     => $maillist['email']
136                                        );
137                                        $p->set_var($var);
138
139                                        if ($can_edit)
140                                        {
141                                                $p->set_var('edit_link',$this->row_action('edit','maillists',$maillist['uidnumber'],$maillist['uid']));
142                                                $p->set_var('scl_link',$this->row_action('scl','maillists',$maillist['uidnumber'],$maillist['uid']));
143                                        }
144                                        else
145                                        {
146                                                $p->set_var('edit_link','&nbsp;');
147                                                $p->set_var('scl_link','&nbsp;');
148                                        }
149
150                                        if ($can_delete)
151                                        {
152                                                $p->set_var('delete_link',"<a href='#' onClick='javascript:delete_maillist(\"".$maillist['uid']."\",\"".$maillist['uidnumber']."\");'>Excluir</a>");
153                                        }
154                                        else
155                                                $p->set_var('delete_link','&nbsp;');
156                                       
157                                        $p->fp('rows','row',True);
158                                }
159                        }
160                        $p->parse('rows','row_empty',True);
161                        $p->set_var($var);
162                        $p->pfp('out','list');                 
163                }
164               
165                function add_maillists()
166                {
167                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
168
169                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
170                        $manager_acl = $this->functions->read_acl($manager_lid);
171                        $manager_contexts = $manager_acl['contexts'];
172
173                        // Verifica se tem acesso a este modulo
174                        if (!$this->functions->check_acl($manager_lid,'add_maillists'))
175                        {
176                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
177                        }
178
179                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
180                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
181                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create Email List');
182                        $GLOBALS['phpgw']->common->phpgw_header();
183                       
184                        // Set o template
185                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
186                        $p->set_file(Array('create_maillist' => 'maillists_form.tpl'));
187
188                        // Obtem combos das organizações.
189                        foreach ($manager_contexts as $index=>$context)
190                                $combo_manager_org .= $this->functions->get_organizations($context);
191                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], '', true, true, true);                 
192                       
193                        // Seta variaveis utilizadas pelo tpl.
194                        $var = Array(
195                                'color_bg1'                                     => "#E8F0F0",
196                                'color_bg2'                                     => "#D3DCE3",
197                                'type'                                          => 'create_maillist',
198                                'ldap_context'                          => $GLOBALS['phpgw_info']['server']['ldap_context'],
199                                'uid'                                           => 'lista-',
200                                'accountStatus_checked'         => 'CHECKED',
201                                'restrictionsOnEmailLists'      => $this->current_config['expressoAdmin_restrictionsOnEmailLists'],
202                                'lang_back'                                     => lang('Back'),
203                                'lang_save'                                     => lang('save'),
204                                'lang_maillist_organization'=> lang('Maillist Organization'),
205                                'lang_search_organization'      => lang('Search Organiztion'),
206                                'lang_search_user'                      => lang('Search user'),
207                                'lang_organizations'            => lang('Organizations'),
208                                'lang_maillist_uid'                     => lang('Maillist login'),
209                                'lang_maillist_mail'            => lang('Maillist Mail'),
210                                'lang_maillist_name'            => lang('Maillist name'),
211                                'lang_maillist_users'           => lang('Maillist users'),
212                                'lang_add_user'                         => lang('Add User'),
213                                'lang_rem_user'                         => lang('Remove User'),
214                                'lang_all_users'                        => lang('Show users from all sub-organizations'),
215                                'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
216                                'combo_manager_org'                     => $combo_manager_org,
217                                'combo_all_orgs'                        => $combo_all_orgs,
218                                'defaultDomain'                         => $this->current_config['expressoAdmin_defaultDomain'],
219                                'combo_org'                                     => $sectors,
220                                'login_field_has_spaces'        => lang('Login field has spaces'),
221                                'list_email_field_is_empty'     => lang('List e-mail field is empty'),
222                                'no_user_is_part_of_the_list'   => lang('No user is part of the list'),
223                                'email_list_successfully_created'       => lang('E-Mail list successfully created!'),
224                                'email_list_successfully_saved'         => lang('E-Mail list successfully saved!'),
225                                'sending_control_list_successfully_saved'       => lang('Sending control list sucessfully saved!'),
226                                'it_is_not_possible_select_users'            => lang('It is not possible to select all the users of the organization root'),
227                                'email_list_successfully_deleted'               => lang('E-Mail list successfully deleted'),
228                                'login_field_incomplete'   => lang('The LOGIN field is incomplete.\n The list name must be in the following format:\n
229                                                                    list-ORGANIZATION-LIST_NAME.\n Ex: lista-celepar-rh'),
230                                'field_email_is_invalid'   => lang('Field E-mail is invalid'),
231                                'delete_list' =>('Delete list')
232                        );
233
234                        $p->set_var($var);
235                       
236                        $p->pfp('out','create_maillist');
237                }
238               
239                function edit_maillists()
240                {
241                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
242
243                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
244                        $manager_acl = $this->functions->read_acl($manager_lid);
245                        $manager_contexts = $manager_acl['contexts'];
246
247                        // Verifica se tem acesso a este modulo
248                        if (!$this->functions->check_acl($manager_lid,'edit_maillists'))
249                        {
250                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
251                        }
252                       
253                        // GET all infomations about the group.
254                        $maillist_info = $this->maillist->get_info($_GET['uidnumber']);
255                       
256                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
257                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
258                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Email Lists');
259                        $GLOBALS['phpgw']->common->phpgw_header();
260
261                        // Set o template
262                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
263                        $p->set_file(Array('edit_maillist' => 'maillists_form.tpl'));
264
265                        // Obtem combos das organizações.
266                        foreach ($manager_contexts as $index=>$context)
267                                $combo_manager_org .= $this->functions->get_organizations($context, trim(strtolower($maillist_info['context'])));
268                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($maillist_info['context'])), true, true, true);                 
269
270                        // Usuarios da lista.
271                        $user_count = 0;
272                        if (count($maillist_info['mailForwardingAddress_info']) > 0)
273                        {
274                                foreach ($maillist_info['mailForwardingAddress_info'] as $mail=>$userinfo)
275                                {
276                                        $array_users[$mail] = $userinfo['cn'];
277                                        $array_users_uid[$mail] = $userinfo['uid'];
278                                        $array_users_type[$mail] = $userinfo['type'];
279                                }
280                                natcasesort($array_users);
281                                foreach ($array_users as $mail=>$cn)
282                                {
283                                        $user_count++;
284                                        if ($array_users_type[$mail] == 'u')
285                                        {
286                                                $users .= "<option value=" . $mail . ">" . $cn .  " [" . $array_users_uid[$mail] . "]</option>";
287                                        }
288                                        elseif ($array_users_type[$mail] == 'l')
289                                        {
290                                                $lists .= "<option value=" . $mail . ">" . $cn .  " [" . $array_users_uid[$mail] . "]</option>";
291                                        }
292                                        else
293                                        {
294                                                $mail_not_found .= "<option value=" . $mail . ">" . $cn .  " [" . $array_users_uid[$mail] . "]</option>";
295                                        }
296                                }
297                               
298                                if ($mail_not_found != '')
299                                {
300                                        $opt_tmp_mail_not_found = '<option  value="-1" disabled>--------------------&nbsp;&nbsp;&nbsp;&nbsp;E-mails não encontrados&nbsp;&nbsp;&nbsp;&nbsp;------------------ </option>'."\n";
301                                        $ea_select_usersInMaillist .= $opt_tmp_mail_not_found . $mail_not_found;
302                                }
303                                if ($lists != '')
304                                {
305                                        $opt_tmp_lists  = '<option  value="-1" disabled>------------------------------&nbsp;&nbsp;&nbsp;&nbsp;Listas&nbsp;&nbsp;&nbsp;&nbsp;------------------------------ </option>'."\n";
306                                        $ea_select_usersInMaillist .= $opt_tmp_lists . $lists;
307                                }
308                                $opt_tmp_users  = '<option  value="-1" disabled>-----------------------------&nbsp;&nbsp;&nbsp;&nbsp;Usuários&nbsp;&nbsp;&nbsp;&nbsp;---------------------------- </option>'."\n";
309                                $ea_select_usersInMaillist .= $opt_tmp_users . $users;
310                        }
311
312                        // Seta variaveis utilizadas pelo tpl.
313                        $var = Array(
314                                'color_bg1'                                             => "#E8F0F0",
315                                'color_bg2'                                             => "#D3DCE3",
316                                'type'                                                  => 'edit_maillist',
317                                'ldap_context'                                  => $GLOBALS['phpgw_info']['server']['ldap_context'],
318                                'lang_back'                                             => lang('Back'),
319                                'lang_save'                                             => lang('save'),
320                                'lang_maillist_organization'    => lang('Maillist Organization'),
321                                'lang_search_organization'              => lang('Search Organiztion'),
322                                'lang_search_user'                              => lang('Search user'),
323                                'lang_organizations'                    => lang('Organizations'),
324                                'lang_maillist_uid'                             => lang('Maillist login'),
325                                'lang_maillist_mail'                    => lang('Maillist Mail'),
326                                'lang_maillist_name'                    => lang('Maillist name'),
327                                'lang_maillist_users'                   => lang('Maillist users'),
328                                'lang_add_user'                                 => lang('Add User'),
329                                'lang_rem_user'                                 => lang('Remove User'),
330                                'lang_all_users'                                => lang('Select users from all sub-organizations'),
331                                'back_url'                                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
332                                'combo_manager_org'                             => $combo_manager_org,
333                                'combo_all_orgs'                                => $combo_all_orgs,
334                                'uidnumber'                                             => $_GET['uidnumber'],
335                                'uid'                                                   => $maillist_info['uid'],
336                                'mail'                                                  => $maillist_info['mail'],
337                                'cn'                                                    => $maillist_info['cn'],
338                                'user_count'                                    => $user_count,
339                                'accountStatus_checked'                 => $maillist_info['accountStatus'] == 'active' ? 'CHECKED' : '',
340                                'phpgwAccountVisible_checked'   => $maillist_info['phpgwAccountVisible'] == '-1' ? 'CHECKED' : '',
341                                'ea_select_usersInMaillist'             => $ea_select_usersInMaillist,
342                                'defaultDomain'                                 => $this->current_config['expressoAdmin_defaultDomain']
343                        );
344                        $p->set_var($var);
345                       
346                        $p->pfp('out','edit_maillist');
347                }
348               
349                function scl_maillists()
350                {
351                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
352                       
353                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
354                        $manager_acl = $this->functions->read_acl($manager_lid);
355                        $manager_contexts = $manager_acl['contexts'];
356                                               
357                        // Verifica se tem acesso a este modulo
358                        if (!$this->functions->check_acl($manager_lid,'edit_maillists'))
359                        {
360                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
361                        }
362                       
363                        // GET all infomations about the group.
364                        $maillist_info = $this->maillist->get_scl_info($_GET['uidnumber']);
365                       
366                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
367                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
368                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Sending Control List');
369                        $GLOBALS['phpgw']->common->phpgw_header();
370
371                        // Set o template
372                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
373                        $p->set_file(Array('sql_maillist' => 'maillists_scl.tpl'));
374
375                        // Pega combo das organizações e seleciona a org da lista.
376                        // $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context'])));
377                        foreach ($manager_contexts as $index=>$context)
378                                $sectors .= $this->functions->get_organizations($context, trim(strtolower($maillist_info['context'])) );
379
380                        // Usuarios de senders.
381                        if (count($maillist_info['senders_info']) > 0)
382                        {
383                                foreach ($maillist_info['senders_info'] as $mail=>$senderinfo)
384                                {
385                                        $array_senders[$mail] = $senderinfo['cn'];
386                                }
387                                natcasesort($array_senders);
388                                foreach ($array_senders as $mail=>$cn)
389                                {
390                                        $ea_select_users_SCL_Maillist .= "<option value=" . $mail . ">" . $cn . " [" . $mail . "]</option>";
391                                }
392                        }
393
394                        // Seta variaveis utilizadas pelo tpl.
395                        $var = Array(
396                                'color_bg1'                                             => "#E8F0F0",
397                                'color_bg2'                                             => "#D3DCE3",
398                                'type'                                                  => 'edit_maillist',
399                                'ldap_context'                                  => $GLOBALS['phpgw_info']['server']['ldap_context'],
400                                'dn'                                                    => $maillist_info['dn'],
401                                'lang_back'                                             => lang('Back'),
402                                'lang_save'                                             => lang('save'),
403                                'lang_org'                                              => lang('Organizations'),
404                                'lang_maillist_uid'                             => lang('Maillist login'),
405                                'lang_maillist_mail'                    => lang('Maillist Mail'),
406                                'lang_maillist_name'                    => lang('Maillist name'),
407                                'lang_maillist_users'                   => lang('Maillist users'),
408                                'lang_add_user'                                 => lang('Add User'),
409                                'lang_rem_user'                                 => lang('Remove User'),
410                                'lang_all_users'                                => lang('Show users from all sub-organizations'),
411                                'back_url'                                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
412                                'combo_org'                                             => $sectors,
413                                'uidnumber'                                             => $_GET['uidnumber'],
414                                'uid'                                                   => $maillist_info['uid'],
415                                'mail'                                                  => $maillist_info['mail'],
416                                'cn'                                                    => $maillist_info['cn'],
417                                'accountRestrictive_checked'    => $maillist_info['accountRestrictive'] == 'mailListRestriction' ? 'CHECKED' : '',
418                                'participantCanSendMail_checked'=> $maillist_info['participantCanSendMail'] == 'TRUE' ? 'CHECKED' : '',
419                                'ea_select_users_SCL_Maillist'  => $ea_select_users_SCL_Maillist
420                        );
421                        $p->set_var($var);
422                       
423                        $p->pfp('out','sql_maillist');
424                }
425               
426                function row_action($action,$type,$uidnumber,$maillist_uid)
427                {
428                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
429                                'menuaction'            => 'expressoAdmin1_2.uimaillists.'.$action.'_'.$type,
430                                'uidnumber'                     => $uidnumber,
431                                'maillist_uid'          => $maillist_uid
432                        )).'"> '.lang($action).' </a>';
433                }
434               
435                function css()
436                {
437                        $appCSS = '';
438                        return $appCSS;
439                }
440        }
441?>
Note: See TracBrowser for help on using the repository browser.