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

Revision 2712, 15.6 KB checked in by rodsouza, 14 years ago (diff)

Ticket #1058 - Adaptando todo o expressoAdmin1_2 para não realizar reload.

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