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

Revision 73, 16.2 KB checked in by niltonneto, 17 years ago (diff)

* empty log message *

  • 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                        // Pega combo das organizações.
189                        foreach ($manager_contexts as $index=>$context)
190                                $sectors .= $this->functions->get_organizations($context);
191
192                        // Seta variaveis utilizadas pelo tpl.
193                        $var = Array(
194                                'color_bg1'                                     => "#E8F0F0",
195                                'color_bg2'                                     => "#D3DCE3",
196                                'type'                                          => 'create_maillist',
197                                'ldap_context'                          => $GLOBALS['phpgw_info']['server']['ldap_context'],
198                                'uid'                                           => 'lista-',
199                                'accountStatus_checked'         => 'CHECKED',
200                                'restrictionsOnEmailLists'      => $this->current_config['expressoAdmin_restrictionsOnEmailLists'],
201                                'lang_back'                                     => lang('Back'),
202                                'lang_save'                                     => lang('save'),
203                                'lang_maillist_organization'=> lang('Maillist Organization'),
204                                'lang_search_organization'      => lang('Search Organiztion'),
205                                'lang_org'                                      => lang('Organizations'),
206                                'lang_maillist_uid'                     => lang('Maillist login'),
207                                'lang_maillist_mail'            => lang('Maillist Mail'),
208                                'lang_maillist_name'            => lang('Maillist name'),
209                                'lang_maillist_users'           => lang('Maillist users'),
210                                'lang_add_user'                         => lang('Add User'),
211                                'lang_rem_user'                         => lang('Remove User'),
212                                'lang_all_users'                        => lang('Show users from all sub-organizations'),
213                                'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
214                                'combo_org'                                     => $sectors
215                        );
216                        $p->set_var($var);
217                       
218                        $p->pfp('out','create_maillist');
219                }
220               
221                function edit_maillists()
222                {
223                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
224
225                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
226                        $manager_acl = $this->functions->read_acl($manager_lid);
227                        $manager_contexts = $manager_acl['contexts'];
228
229                        // Verifica se tem acesso a este modulo
230                        if (!$this->functions->check_acl($manager_lid,'edit_maillists'))
231                        {
232                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
233                        }
234                       
235                        // GET all infomations about the group.
236                        $maillist_info = $this->maillist->get_info($_GET['uidnumber']);
237                       
238                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
239                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
240                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Email Lists');
241                        $GLOBALS['phpgw']->common->phpgw_header();
242
243                        // Set o template
244                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
245                        $p->set_file(Array('edit_maillist' => 'maillists_form.tpl'));
246
247                        // Pega combo das organizações e seleciona a org da lista.
248                        foreach ($manager_contexts as $index=>$context)
249                                $sectors .= $this->functions->get_organizations($context, trim(strtolower($maillist_info['context'])) );
250
251                        // Usuarios da lista.
252                        $user_count = 0;
253                        if (count($maillist_info['members_info']) > 0)
254                        {
255                                foreach ($maillist_info['members_info'] as $uidnumber=>$userinfo)
256                                {
257                                        $array_users[$uidnumber] = $userinfo['cn'];
258                                        $array_users_uid[$uidnumber] = $userinfo['uid'];
259                                        $array_users_type[$uidnumber] = $userinfo['type'];
260                                }
261                                natcasesort($array_users);
262                                foreach ($array_users as $uidnumber=>$cn)
263                                {
264                                        $user_count++;
265                                        if ($array_users_type[$uidnumber] == 'u')
266                                        {
267                                                $users .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
268                                        }
269                                        elseif ($array_users_type[$uidnumber] == 'l')
270                                        {
271                                                $lists .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
272                                        }
273                                        else
274                                        {
275                                                $unknow .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
276                                        }
277                                }
278                               
279                                if ($unknow != '')
280                                {
281                                        $opt_tmp_unknow = '<option  value="-1" disabled>--------------------&nbsp;&nbsp;&nbsp;&nbsp;E-mails não encontrados&nbsp;&nbsp;&nbsp;&nbsp;------------------ </option>'."\n";
282                                        $ea_select_usersInMaillist .= $opt_tmp_unknow . $unknow;
283                                }
284                                if ($lists != '')
285                                {
286                                        $opt_tmp_lists  = '<option  value="-1" disabled>------------------------------&nbsp;&nbsp;&nbsp;&nbsp;Listas&nbsp;&nbsp;&nbsp;&nbsp;------------------------------ </option>'."\n";
287                                        $ea_select_usersInMaillist .= $opt_tmp_lists . $lists;
288                                }
289                                $opt_tmp_users  = '<option  value="-1" disabled>-----------------------------&nbsp;&nbsp;&nbsp;&nbsp;Usuários&nbsp;&nbsp;&nbsp;&nbsp;---------------------------- </option>'."\n";
290                                $ea_select_usersInMaillist .= $opt_tmp_users . $users;
291                        }
292
293                        // Seta variaveis utilizadas pelo tpl.
294                        $var = Array(
295                                'color_bg1'                                             => "#E8F0F0",
296                                'color_bg2'                                             => "#D3DCE3",
297                                'type'                                                  => 'edit_maillist',
298                                'ldap_context'                                  => $GLOBALS['phpgw_info']['server']['ldap_context'],
299                                'lang_back'                                             => lang('Back'),
300                                'lang_save'                                             => lang('save'),
301                                'lang_maillist_organization'=> lang('Maillist Organization'),
302                                'lang_search_organization'      => lang('Search Organiztion'),
303                                'lang_org'                                              => lang('Organizations'),
304                                'lang_maillist_uid'                             => lang('Maillist login'),
305                                'lang_maillist_mail'                    => lang('Maillist Mail'),
306                                'lang_maillist_name'                    => lang('Maillist name'),
307                                'lang_maillist_users'                   => lang('Maillist users'),
308                                'lang_add_user'                                 => lang('Add User'),
309                                'lang_rem_user'                                 => lang('Remove User'),
310                                'lang_all_users'                                => lang('Select users from all sub-organizations'),
311                                'back_url'                                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
312                                'combo_org'                                             => $sectors,
313                                'uidnumber'                                             => $_GET['uidnumber'],
314                                'uid'                                                   => $maillist_info['uid'],
315                                'mail'                                                  => $maillist_info['mail'],
316                                'cn'                                                    => $maillist_info['cn'],
317                                'user_count'                                    => $user_count,
318                                'accountStatus_checked'                 => $maillist_info['accountStatus'] == 'active' ? 'CHECKED' : '',
319                                'phpgwAccountVisible_checked'   => $maillist_info['phpgwAccountVisible'] == '-1' ? 'CHECKED' : '',
320                                'ea_select_usersInMaillist'             => $ea_select_usersInMaillist
321                        );
322                        $p->set_var($var);
323                       
324                        $p->pfp('out','edit_maillist');
325                }
326               
327                function scl_maillists()
328                {
329                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
330                       
331                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
332                        $manager_acl = $this->functions->read_acl($manager_lid);
333                        $manager_contexts = $manager_acl['contexts'];
334                                               
335                        // Verifica se tem acesso a este modulo
336                        if (!$this->functions->check_acl($manager_lid,'edit_maillists'))
337                        {
338                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
339                        }
340                       
341                        // GET all infomations about the group.
342                        $maillist_info = $this->maillist->get_scl_info($_GET['uidnumber']);
343                       
344                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
345                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
346                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Sending Control List');
347                        $GLOBALS['phpgw']->common->phpgw_header();
348
349                        // Set o template
350                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
351                        $p->set_file(Array('sql_maillist' => 'maillists_scl.tpl'));
352
353                        // Pega combo das organizações e seleciona a org da lista.
354                        // $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context'])));
355                        foreach ($manager_contexts as $index=>$context)
356                                $sectors .= $this->functions->get_organizations($context, trim(strtolower($maillist_info['context'])) );
357
358                        // Usuarios de senders.
359                        if (count($maillist_info['senders_info']) > 0)
360                        {
361                                foreach ($maillist_info['senders_info'] as $uidnumber=>$senderinfo)
362                                {
363                                        $array_senders[$uidnumber] = $senderinfo['cn'];
364                                }
365                                natcasesort($array_senders);
366                                foreach ($array_senders as $uidnumber=>$cn)
367                                {
368                                        $ea_select_users_SCL_Maillist .= "<option value=" . $uidnumber . ">" . $cn . " [" . $maillist_info['senders_info'][$uidnumber]['mail'] . "]</option>";
369                                }
370                        }
371
372                        // Seta variaveis utilizadas pelo tpl.
373                        $var = Array(
374                                'color_bg1'                                             => "#E8F0F0",
375                                'color_bg2'                                             => "#D3DCE3",
376                                'type'                                                  => 'edit_maillist',
377                                'ldap_context'                                  => $GLOBALS['phpgw_info']['server']['ldap_context'],
378                                'dn'                                                    => $maillist_info['dn'],
379                                'lang_back'                                             => lang('Back'),
380                                'lang_save'                                             => lang('save'),
381                                'lang_org'                                              => lang('Organizations'),
382                                'lang_maillist_uid'                             => lang('Maillist login'),
383                                'lang_maillist_mail'                    => lang('Maillist Mail'),
384                                'lang_maillist_name'                    => lang('Maillist name'),
385                                'lang_maillist_users'                   => lang('Maillist users'),
386                                'lang_add_user'                                 => lang('Add User'),
387                                'lang_rem_user'                                 => lang('Remove User'),
388                                'lang_all_users'                                => lang('Show users from all sub-organizations'),
389                                'back_url'                                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
390                                'combo_org'                                             => $sectors,
391                                'uidnumber'                                             => $_GET['uidnumber'],
392                                'uid'                                                   => $maillist_info['uid'],
393                                'mail'                                                  => $maillist_info['mail'],
394                                'cn'                                                    => $maillist_info['cn'],
395                                'accountRestrictive_checked'    => $maillist_info['accountRestrictive'] == 'mailListRestriction' ? 'CHECKED' : '',
396                                'participantCanSendMail_checked'=> $maillist_info['participantCanSendMail'] == 'TRUE' ? 'CHECKED' : '',
397                                'ea_select_users_SCL_Maillist'  => $ea_select_users_SCL_Maillist
398                        );
399                        $p->set_var($var);
400                       
401                        $p->pfp('out','sql_maillist');
402                }
403               
404                function row_action($action,$type,$uidnumber,$maillist_uid)
405                {
406                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
407                                'menuaction'            => 'expressoAdmin1_2.uimaillists.'.$action.'_'.$type,
408                                'uidnumber'                     => $uidnumber,
409                                'maillist_uid'          => $maillist_uid
410                        )).'"> '.lang($action).' </a>';
411                }
412               
413                function css()
414                {
415                        $appCSS = '';
416                        return $appCSS;
417                }
418        }
419?>
Note: See TracBrowser for help on using the repository browser.