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

Revision 5593, 15.4 KB checked in by wmerlotto, 12 years ago (diff)

Ticket #2398 - Compatibilizacao com PHP-5.3 no modulo ExpressoAdmin

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