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

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