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

Revision 2, 10.8 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • 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                        'css'                                                   => True
20                );
21
22                var $nextmatchs;
23                var $functions;
24                       
25                function uimaillists()
26                {
27                        $this->maillist         = CreateObject('expressoAdmin1_2.maillist');
28                        $this->functions        = CreateObject('expressoAdmin1_2.functions');
29                        $this->nextmatchs       = CreateObject('phpgwapi.nextmatchs');
30
31                        if(!@is_object($GLOBALS['phpgw']->js))
32                        {
33                                $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
34                        }
35                        $GLOBALS['phpgw']->js->validate_file('jscode','connector','expressoAdmin1_2');#diretorio, arquivo.js, aplicacao
36                        $GLOBALS['phpgw']->js->validate_file('jscode','expressoadmin','expressoAdmin1_2');
37                        $GLOBALS['phpgw']->js->validate_file('jscode','maillists','expressoAdmin1_2');
38                }
39               
40                function list_maillists()
41                {
42                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
43                        $acl = $this->functions->read_acl($account_lid);
44                        $context = $acl[0]['context'];
45                        $context_display = $acl[0]['context_display'];
46                       
47                        // Verifica se tem acesso a este modulo
48                        if (!$this->functions->check_acl($account_lid,'list_maillists'))
49                        {
50                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
51                        }
52
53                        if(isset($_POST['query']))
54                        {
55                                // limit query to limit characters
56                                if(eregi('^[a-z_0-9_%-].+$',$_POST['query']))
57                                        $GLOBALS['query'] = $_POST['query'];
58                        }
59
60                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
61                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
62                       
63                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Email Lists');
64                        $GLOBALS['phpgw']->common->phpgw_header();
65
66                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
67                        $p->set_file(array('maillists'   => 'maillists.tpl'));
68                        $p->set_block('maillists','list','list');
69                        $p->set_block('maillists','row','row');
70                        $p->set_block('maillists','row_empty','row_empty');
71                       
72                        // Seta as variaveis padroes.
73                        $var = Array(
74                                'th_bg'                                         => $GLOBALS['phpgw_info']['theme']['th_bg'],
75                                'back_url'                                      => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
76                                'add_action'                            => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.add_maillists'),
77                                'add_email_lists_disabled'      => $this->functions->check_acl($account_lid,'add_maillists') ? '' : 'disabled',
78                                'context'                                       => $context,
79                                'context_display'                       => $context_display,
80                                'lang_email_lists_uid'          => lang('Email Lists Logins'),
81                                'lang_email_lists_names'        => lang('Email Lists Names'),
82                                'lang_add_email_lists'          => lang('Add Email Lists'),
83                                'lang_edit'                             => lang('Edit'),
84                                'lang_delete'                           => 'Excluir',
85                                'lang_view'                                     => lang('View'),
86                                'lang_back'                                     => lang('back'),
87                                'lang_context'                          => lang('context'),
88                                'lang_email'                            => lang('E-mail'),
89                                'lang_search'                           => lang('search')
90                        );
91                        $p->set_var($var);
92
93                        // Save query
94                        $p->set_var('query', $GLOBALS['query']);
95                       
96                        //Admin make a search
97                        if ($GLOBALS['query'] != '')
98                        {
99                                $maillists_info = $this->functions->get_list('maillists', $GLOBALS['query'], $context);
100                        }
101                        $total = count($maillists_info);
102
103
104                        if (!count($total) && $GLOBALS['query'] != '')
105                        {
106                                $p->set_var('message',lang('No matches found'));
107                        }
108                        else if ($total)
109                        {
110                                if ($this->functions->check_acl($account_lid,'edit_maillists'))
111                                {
112                                        $can_edit = True;
113                                }
114                                if ($this->functions->check_acl($account_lid,'delete_maillists'))
115                                {
116                                        $can_delete = True;
117                                }
118
119                                foreach($maillists_info as $maillist)
120                                {
121                                        $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
122                                        $var = array(
123                                                'tr_color'              => $tr_color,
124                                                'row_uid'               => $maillist['uid'],
125                                                'row_name'      => $maillist['name'],
126                                                'row_email'     => $maillist['email']
127                                        );
128                                        $p->set_var($var);
129
130                                        if ($can_edit)
131                                        {
132                                                $p->set_var('edit_link',$this->row_action('edit','maillists',$maillist['uidnumber'],$maillist['uid']));
133                                        }
134                                        else
135                                        {
136                                                $p->set_var('edit_link','&nbsp;');
137                                        }
138
139                                        if ($can_delete)
140                                        {
141                                                $p->set_var('delete_link',"<a href='#' onClick='javascript:delete_maillist(\"".$maillist['uid']."\",\"".$maillist['uidnumber']."\",\"".$context."\");'>Excluir</a>");
142                                        }
143                                        else
144                                                $p->set_var('delete_link','&nbsp;');
145                                       
146                                        $p->fp('rows','row',True);
147                                }
148                        }
149                        $p->parse('rows','row_empty',True);
150                        $p->set_var($var);
151                        $p->pfp('out','list');                 
152                }
153               
154                function add_maillists()
155                {
156                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
157                       
158                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
159                        $acl = $this->functions->read_acl($account_lid);
160                        $context = $acl[0]['context'];
161                       
162                        // Verifica se tem acesso a este modulo
163                        if (!$this->functions->check_acl($account_lid,'add_maillists'))
164                        {
165                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
166                        }
167
168                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
169                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
170                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create Email List');
171                        $GLOBALS['phpgw']->common->phpgw_header();
172                       
173                        // Set o template
174                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
175                        $p->set_file(Array('create_maillist' => 'maillists_form.tpl'));
176
177                        // Pega combo das organizações.
178                        $org = $this->functions->get_organizations($context, '');
179
180                        // Seta variaveis utilizadas pelo tpl.
181                        $var = Array(
182                                'color_bg1'                                     => "#E8F0F0",
183                                'color_bg2'                                     => "#D3DCE3",
184                                'type'                                          => 'create_maillist',
185                                'ldap_context'                          => $GLOBALS['phpgw_info']['server']['ldap_context'],
186                                'uid'                                           => 'lista-',
187                                'accountStatus_checked'         => 'CHECKED',
188                                'lang_back'                                     => lang('Back'),
189                                'lang_save'                                     => lang('save'),
190                                'lang_org'                                      => lang('Organizations'),
191                                'lang_maillist_uid'                     => lang('Maillist login'),
192                                'lang_maillist_mail'            => lang('Maillist Mail'),
193                                'lang_maillist_name'            => lang('Maillist name'),
194                                'lang_maillist_users'           => lang('Maillist users'),
195                                'lang_add_user'                         => lang('Add User'),
196                                'lang_rem_user'                         => lang('Remove User'),
197                                'lang_all_users'                        => lang('Select users from all sub-organizations'),
198                                'back_url'                                      => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
199                                'combo_org'                                     => $org,
200                        );
201                        $p->set_var($var);
202                       
203                        $p->pfp('out','create_maillist');
204                }
205               
206               
207                function edit_maillists()
208                {
209                        $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
210                       
211                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
212                        $acl = $this->functions->read_acl($account_lid);
213                        $manager_context = $acl[0]['context'];
214                       
215                        // Verifica se tem acesso a este modulo
216                        if (!$this->functions->check_acl($account_lid,'edit_maillists'))
217                        {
218                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
219                        }
220                       
221                        // GET all infomations about the group.
222                        $maillist_info = $this->maillist->get_info($_GET['uidnumber'], $manager_context);
223                        //_debug_array($maillist_info);
224                       
225                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
226                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
227                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Email Lists');
228                        $GLOBALS['phpgw']->common->phpgw_header();
229
230                        // Set o template
231                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
232                        $p->set_file(Array('edit_maillist' => 'maillists_form.tpl'));
233
234                        // Pega combo das organizações e seleciona a org da lista.
235                        $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context'])));
236
237                        // Usuarios da lista.
238                        if (count($maillist_info['members_info']) > 0)
239                        {
240                                foreach ($maillist_info['members_info'] as $uidnumber=>$userinfo)
241                                {
242                                        $array_users[$uidnumber] = $userinfo['cn'];
243                                        $array_users_uid[$uidnumber] = $userinfo['uid'];
244                                }
245                                natcasesort($array_users);
246                                foreach ($array_users as $uidnumber=>$cn)
247                                {
248                                        $ea_select_usersInMaillist .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
249                                }
250                        }
251
252                        // Seta variaveis utilizadas pelo tpl.
253                        $var = Array(
254                                'color_bg1'                                             => "#E8F0F0",
255                                'color_bg2'                                             => "#D3DCE3",
256                                'type'                                                  => 'edit_maillist',
257                                'ldap_context'                          => $GLOBALS['phpgw_info']['server']['ldap_context'],
258                                'lang_back'                                             => lang('Back'),
259                                'lang_save'                                             => lang('save'),
260                                'lang_org'                                              => lang('Organizations'),
261                                'lang_maillist_uid'                             => lang('Maillist login'),
262                                'lang_maillist_mail'                    => lang('Maillist Mail'),
263                                'lang_maillist_name'                    => lang('Maillist name'),
264                                'lang_maillist_users'                   => lang('Maillist users'),
265                                'lang_add_user'                                 => lang('Add User'),
266                                'lang_rem_user'                                 => lang('Remove User'),
267                                'lang_all_users'                                => lang('Select users from all sub-organizations'),
268                                'back_url'                                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
269                                'combo_org'                                             => $org,
270                                'manager_context'                               => $manager_context,
271                                'uidnumber'                                             => $_GET['uidnumber'],
272                                'uid'                                                   => $maillist_info['uid'],
273                                'mail'                                                  => $maillist_info['mail'],
274                                'cn'                                                    => $maillist_info['cn'],
275                                'accountStatus_checked'                 => $maillist_info['accountStatus'] == 'active' ? 'CHECKED' : '',
276                                'phpgwAccountVisible_checked'   => $maillist_info['phpgwAccountVisible'] == '-1' ? 'CHECKED' : '',
277                                'ea_select_usersInMaillist'             => $ea_select_usersInMaillist
278                        );
279                        $p->set_var($var);
280                       
281                        $p->pfp('out','edit_maillist');
282                }
283                               
284                function row_action($action,$type,$uidnumber,$maillist_uid)
285                {
286                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
287                                'menuaction'            => 'expressoAdmin1_2.uimaillists.'.$action.'_'.$type,
288                                'uidnumber'                     => $uidnumber,
289                                'maillist_uid'          => $maillist_uid
290                        )).'"> '.lang($action).' </a>';
291                }
292               
293                function css()
294                {
295                        $appCSS = '';
296                        return $appCSS;
297                }
298        }
299?>
Note: See TracBrowser for help on using the repository browser.