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

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