source: branches/2.2/expressoAdmin1_2/inc/class.uimaillists.inc.php @ 4215

Revision 4215, 15.8 KB checked in by diegomoreno, 13 years ago (diff)

Ticket #1828 - expressoAdmin1_2 - Ajuste para pesquisar corretamente os usuarios.

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