source: trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php @ 13

Revision 13, 28.8 KB checked in by niltonneto, 17 years ago (diff)

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /***********************************************************************************\
3        * Expresso Administração                                                                                                                        *
4        * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br)       *
5        * ----------------------------------------------------------------------------------*
6        *  This program is free software; you can redistribute it and/or modify it                      *
7        *  under the terms of the GNU General Public License as published by the                        *
8        *  Free Software Foundation; either version 2 of the License, or (at your                       *
9        *  option) any later version.                                                                                                           *
10        \***********************************************************************************/
11
12        class uiaccounts
13        {
14                var $public_functions = array
15                (
16                        'list_users'                            => True,
17                        'add_users'                                     => True,
18                        'edit_user'                                     => True,
19                        'show_photo'                            => True,
20                        'show_access_log'                       => True,
21                        'css'                                           => True
22                );
23
24                var $nextmatchs;
25                var $user;
26                var $functions;
27                var $current_config;
28                var $ldap_functions;
29                var $db_functions;
30
31                function uiaccounts()
32                {
33                        $this->user                     = CreateObject('expressoAdmin1_2.user');
34                        $this->nextmatchs       = CreateObject('phpgwapi.nextmatchs');
35                        $this->functions        = CreateObject('expressoAdmin1_2.functions');
36                        $this->ldap_functions = CreateObject('expressoAdmin1_2.ldap_functions');
37                        $this->db_functions = CreateObject('expressoAdmin1_2.db_functions');
38                       
39                        $c = CreateObject('phpgwapi.config','expressoAdmin1_2');
40                        $c->read_repository();
41                        $this->current_config = $c->config_data;
42                       
43                        if(!@is_object($GLOBALS['phpgw']->js))
44                        {
45                                $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
46                        }
47                        $GLOBALS['phpgw']->js->validate_file('jscode','connector','expressoAdmin1_2');#diretorio, arquivo.js, aplicacao
48                        $GLOBALS['phpgw']->js->validate_file('jscode','expressoadmin','expressoAdmin1_2');
49                        $GLOBALS['phpgw']->js->validate_file('jscode','tabs','expressoAdmin1_2');
50                        $GLOBALS['phpgw']->js->validate_file('jscode','users','expressoAdmin1_2');
51                }
52
53                function list_users()
54                {
55                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
56                        $tmp = $this->functions->read_acl($account_lid);
57                        $context = $tmp[0]['context'];
58                        $context_display = $tmp[0]['context_display'];
59                       
60                        // Verifica se o administrador tem acesso.
61                        if (!$this->functions->check_acl($account_lid,'list_users'))
62                        {
63                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
64                        }
65
66                        if(isset($_POST['query']))
67                        {
68                                // limit query to limit characters
69                                if(eregi('^[a-z_0-9_-].+$',$_POST['query']))
70                                {
71                                        $GLOBALS['query'] = $_POST['query'];
72                                }
73                        }
74                       
75                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
76                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
77                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('User accounts');
78                        $GLOBALS['phpgw']->common->phpgw_header();
79
80                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
81                        $p->set_file(Array('accounts' => 'accounts.tpl'));
82                        $p->set_block('accounts','body');
83                        $p->set_block('accounts','row');
84                        $p->set_block('accounts','row_empty');
85
86                        $var = Array(
87                                'bg_color'                                      => $GLOBALS['phpgw_info']['theme']['bg_color'],
88                                'th_bg'                                         => $GLOBALS['phpgw_info']['theme']['th_bg'],
89                               
90                                'accounts_url'                          => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'),
91                                'back_url'                                      => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
92                                'add_action'                            => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.add_users'),
93                               
94                                'create_user_disabled'          => $this->functions->check_acl($account_lid,'add_users') ? '' : 'disabled',
95                                'context'                                       => $context,
96                                'context_display'                       => $context_display,
97                                'imapDelimiter'                         => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'],
98                               
99                                'lang_create_user'                      => lang('Create User'),
100                                'lang_loginid'                          => lang('LoginID'),
101                                'lang_cn'                                       => lang('Name'),
102                                'lang_mail'                                     => lang('E-mail'),
103                                'lang_edit'                                     => lang('edit'),
104                                'lang_rename'                           => lang('rename'),
105                                'lang_delete'                           => lang('delete'),
106                                'lang_search'                           => lang('Search'),
107                                'lang_back'                                     => lang('back'),
108                                'lang_context'                          => lang('Context')
109                               
110                        );
111                        $p->set_var($var);
112                       
113                        // Save query
114                        $p->set_var('query', $GLOBALS['query']);
115                       
116                        //Admin make a search
117                        if ($GLOBALS['query'] != '')
118                        {
119                                $account_info = $this->functions->get_list('accounts', $GLOBALS['query'], $context);
120                        }
121                       
122                        if (!count($account_info) && $GLOBALS['query'] != '')
123                        {
124                                $p->set_var('message',lang('No matches found'));
125                                $p->parse('rows','row_empty',True);
126                        }
127                        else if (count($account_info))
128                        {  // Can edit, delete or rename users ??
129                                if (($this->functions->check_acl($account_lid,'edit_users')) ||
130                                        ($this->functions->check_acl($account_lid,'change_users_password')) ||
131                                        ($this->functions->check_acl($account_lid,'edit_sambausers_attributes')) || 
132                                        ($this->functions->check_acl($account_lid,'change_users_quote')))
133                                        $can_edit = True;
134                                if ($this->functions->check_acl($account_lid,'delete_users'))
135                                        $can_delete = True;
136                                if ($this->functions->check_acl($account_lid,'rename_users'))
137                                        $can_rename = True;
138
139                                while (list($null,$account) = each($account_info))
140                                {
141                                        $this->nextmatchs->template_alternate_row_color($p);
142
143                                        $var = array(
144                                                'row_loginid'   => $account['account_lid'],
145                                                'row_cn'                => $account['account_cn'],
146                                                'row_mail'              => (!$account['account_mail']?'<font color=red>Sem E-mail</font>':$account['account_mail'])
147                                        );
148                                        $p->set_var($var);
149
150                                        if ($can_edit)
151                                                $p->set_var('row_edit',$this->row_action('edit','user',$account['account_id']));
152                                        else
153                                                $p->set_var('row_edit','&nbsp;');
154
155                                        if ($can_rename)
156                                                $p->set_var('row_rename',"<a href='#' onClick='javascript:rename_user(\"".$account['account_lid']."\",\"".$account['account_id']."\",\"".$context."\");'>Renomear</a>");
157                                        else
158                                                $p->set_var('row_rename','&nbsp;');
159
160                                        if ($can_delete)
161                                        {
162                                                $p->set_var('row_delete',"<a href='#' onClick='javascript:delete_user(\"".$account['account_lid']."\",\"".$account['account_id']."\",\"".$context."\");'>Excluir</a>");
163                                        }
164                                        else
165                                                $p->set_var('row_delete','&nbsp;');
166
167                                        $p->parse('rows','row',True);
168                                }
169                        }
170                        $p->pfp('out','body');
171                }
172
173                function add_users()
174                {
175                        $GLOBALS['phpgw']->js->validate_file('jscode','users','expressoAdmin1_2');                     
176                        $GLOBALS['phpgw']->js->set_onload('get_sectors(document.forms[0].context.value);');
177                        $GLOBALS['phpgw']->js->set_onload('get_available_groups(document.forms[0].context.value);');
178                        $GLOBALS['phpgw']->js->set_onload('get_available_maillists(document.forms[0].context.value);');
179                       
180                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
181                        $tmp = $this->functions->read_acl($manager_lid);
182                        $manager_context = $tmp[0]['context'];
183                        // Verifica se tem acesso a este modulo
184                        if (!$this->functions->check_acl($manager_lid,'add_users'))
185                        {
186                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
187                        }
188                               
189                        // Imprime nav_bar
190                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
191                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
192                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create User');
193                        $GLOBALS['phpgw']->common->phpgw_header();
194                       
195                        // Seta template
196                        $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
197                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
198                        $t->set_file(array("body" => "accounts_form.tpl"));
199                        $t->set_block('body','main');
200
201                        // Pega combo das organizações e seleciona, caso seja um post, o setor que o usuario selecionou.
202                        $sectors = $this->functions->get_organizations($manager_context);
203
204                        // Chama funcao para criar lista de aplicativos disponiveis.
205                        //$app_list['applications_list'] = $_POST['applications_list'];
206                        $applications_list = $this->functions->make_list_app($manager_lid, $manager_context, $app_list);
207
208                        // Valores default.
209                        $var = Array(
210                                'row_on'                                => "#DDDDDD",
211                                'row_off'                               => "#EEEEEE",
212                                'color_bg1'                             => "#E8F0F0",
213                                'manager_context'               => $manager_context,
214                                'type'                                  => 'create_user',
215                                //'action'                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.validade_user_data_add'),
216                                //'action'                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.boaccounts.create_user'),
217                                'back_url'                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'),
218                                'display_samba_suport'  => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none',
219                               
220                                // First ABA
221                                'display_spam_uid'                              => 'display:none',
222                                'lang_general_information'              => lang('General Information'),
223                                'lang_email_config'                             => lang('Email Config'),
224                                'lang_groups_permission'                => lang('Groups Permission'),
225                                'lang_lists_permission'                 => lang('Email Lists'),
226                                'lang_aplication_permission'    => lang('Aplication Permission'),       
227                                'lang_organizations'                    => lang('Organizations'),
228                                'lang_sector'                                   => lang('Sector'),
229                                'lang_account_lid'                              => lang('Login ID'),
230                                'lang_firstname'                                => lang('First Name'),
231                                'lang_lastname'                                 => lang('Last Name'),
232                                'lang_password'                                 => lang('Password'),
233                                'lang_re-password'                              => lang('Re-Password'),
234                                'lang_changepassword'                   => lang('Change password'),                             
235                                'lang_phone'                                    => lang('Phone'),
236                                'lang_photo'                                    => lang('Photo'),
237                                'lang_account_active'                   => lang('Account Active'),
238                                'lang_account_invisible'                => lang('Account Invisible'),
239                                'lang_never'                                    => lang('never'),
240                                'lang_back'                                             => lang('Back'),
241                                'lang_save'                                             => lang('Save'),
242                               
243                                'sectors'                                               => $sectors,
244                                'combo_organizations'                   => $sectors,
245                                'changepassword_checked'                => 'CHECKED',
246                                'phpgwaccountstatus_checked'    => 'CHECKED',
247                                'photo_bin'                                             => $GLOBALS['phpgw_info']['server']['webserver_url'].'/expressoAdmin1_2/templates/default/images/photo_celepar.png',
248                                'disabled_delete_photo'                 => 'disabled',
249                                'display_tr_default_password'   => 'none',
250                                'minimumSizeLogin'                              => $this->current_config['expressoAdmin_minimumSizeLogin'],
251                                'defaultDomain'                                 => $this->current_config['expressoAdmin_defaultDomain'],
252                                'concatenateDomain'                             => $this->current_config['expressoAdmin_concatenateDomain'],
253                                'ldap_context'                                  => ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']),
254                               
255                                //MAIL
256                                'lang_activeemailaccount'               => lang('Active email account'),
257                                'lang_email'                                    => lang('E-mail'),
258                                'lang_aliasemail'                               => lang('Alias email'),
259                                'lang_forwardingemail'                  => lang('Forwarding email'),
260                                'lang_email_quota'                              => lang('Email quota in MB'),
261                                'lang_onlyforwarding'                   => lang('Only forwarding'),
262                                'lang_quote_message'                    => lang('leave empty for no quota'),
263                                'lang_email_quota_used'                 => lang('Quota used in MB'),
264                                'accountstatus_checked'                 => 'CHECKED',
265                                'mailquota'                                             => $this->current_config['expressoAdmin_defaultUserQuota'],
266                                'changequote_disabled'                  => $this->functions->check_acl($manager_lid,'change_users_quote') ? '' : 'readonly',
267                                'imapDelimiter'                                 => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'],
268
269                                //Third ABA
270                                'lang_groups'                                   => lang('Groups'),
271                                'lang_user_groups'                              => 'Grupos do Usuário',
272                                'lang_available_groups'                 => 'Grupos disponíveis',
273                                'lang_listGroups'                               => lang('ListGroups'),
274                                'lang_primary_group'                    => lang('Primary Group'),
275                                'lang_add'                                              => lang('Add'),
276                                'lang_rem'                                              => lang('Remove'),
277                               
278                                //Fourd ABA
279                                'lang_user_mail_lists'                  => 'O usuário participa destas Listas de E-mail',
280                                'lang_available_mail_lists'             => 'Listas de E-mail disponíveis',
281                               
282                                //Five ABA
283                                'apps'                                                          => $applications_list,
284                               
285                                //SAMBA ABA
286                                'lang_samba_config'                                     => lang('Samba Config'),
287                                'lang_use_attrs_samba'                          => 'Usar atributos Samba',
288                                'lang_sambaAcctFlags'                           => lang('AcctFlags'),
289                                'lang_sambaLogonScript'                         => lang('Logon Script'),
290                                'lang_sambaHomeDirectory'                       => lang('Home Directory'),
291                                'lang_active_user'                                      => lang('Samba User Active'),
292                                'lang_desactive_user'                           => lang('Samba User Desactive'),
293                                'use_attrs_samba_checked'                       => 'CHECKED',
294                                'sambalogonscript'                                      => $this->current_config['expressoAdmin_defaultLogonScript'] != '' ? $this->current_config['expressoAdmin_defaultLogonScript'] : '',
295                                'use_suggestion_in_logon_script'        => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false',
296                        );
297                        $t->set_var($var);
298                        $t->pfp('out','main');
299                }
300               
301                function edit_user()
302                {
303                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
304                        $tmp = $this->functions->read_acl($manager_account_lid);
305                        $manager_context = $tmp[0]['context'];
306                        $alert_warning = '';
307                       
308                        // Verifica se tem acesso a este modulo
309                        $disabled = 'disabled';
310                        $disabled_password = 'disabled';
311                        $disabled_samba = 'disabled';
312                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) &&
313                                (!$this->functions->check_acl($manager_account_lid,'change_users_password')) &&
314                                (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
315                        {
316                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
317                        }
318                        // SOMENTE ALTERAÇÃO DE SENHA
319                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'change_users_password')))
320                        {
321                                $disabled = 'disabled';
322                                $disabled_password = '';
323                        }
324                        // SOMENTE ALTERAÇÃO DOS ATRIBUTOS SAMBA
325                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
326                        {
327                                $disabled = 'disabled';
328                                $disabled_samba = '';
329                        }
330                        // TOTAIS
331                        if ($this->functions->check_acl($manager_account_lid,'edit_users'))
332                        {
333                                $disabled = '';
334                                $disabled_password = '';
335                                $disabled_samba = '';
336                        }
337                       
338                        if (!$this->functions->check_acl($manager_account_lid,'change_users_quote'))
339                                $disabled_quote = 'readonly';
340                       
341                        // GET all infomations about the user.
342                        $user_info = $this->user->get_user_info($_GET['account_id'], $manager_context);
343                       
344                        // JavaScript
345                        $GLOBALS['phpgw']->js->validate_file("jscode","users","expressoAdmin1_2");
346                        $GLOBALS['phpgw']->js->set_onload("get_available_groups(document.forms[0].context.value);");
347                        $GLOBALS['phpgw']->js->set_onload("get_available_maillists(document.forms[0].context.value);");
348                        $GLOBALS['phpgw']->js->set_onload("use_samba_attrs('".$user_info['sambaUser']."');");
349                       
350                        // Seta header.
351                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
352                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
353
354                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit User');
355                        $GLOBALS['phpgw']->common->phpgw_header();
356
357                        // Seta templates.
358                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
359                        $t->set_file(array("body" => "accounts_form.tpl"));
360                        $t->set_block('body','main');
361                                                       
362                // ORGANIZATIONS
363                $orgs = $this->functions->get_organizations($manager_context, $user_info['context']);
364
365                        // GROUPS.
366                        if (count($user_info['groups_info']) > 0)
367                        {
368                                foreach ($user_info['groups_info'] as $group)
369                                {
370                                        $array_groups[$group['gidnumber']] = $group['cn'];
371                                }
372                                natcasesort($array_groups);
373                                foreach ($array_groups as $gidnumber=>$cn)
374                                {
375                                        // Grupo existe no Banco mas não no Ldap, excluimos grupo do Banco.
376                                        /*
377                                        if (!$this->ldap_functions->group_exist($gidnumber))
378                                        {
379                                                $this->db_functions->delete_group($gidnumber);
380                                                $this->db_functions->write_log("expressoAdmin deletou o grupo $gidnumber do banco, pois não existia no ldap.",'','','','');
381                                                continue;
382                                        }
383                                        */
384                                       
385                                        // O memberUid do usuário está somente no Banco, então adicionamos o memberUid no Ldap.
386                                        if (is_null($user_info['groups_ldap'][$gidnumber]))
387                                        {
388                                                $this->ldap_functions->add_user2group($gidnumber, $user_info['uid']);
389                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Incluido memberUid no Ldap]</option>";
390
391                                                if ($alert_warning == '')
392                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
393                                                $alert_warning .= "Incluido atributo memberUid do usuário no grupo $cn - $gidnumber.\\n";
394                                        }
395                                        else
396                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
397                                       
398                                        if ($gidnumber == $user_info['gidnumber'])
399                                        {
400                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . " selected>" . $cn . "</option>";
401                                        }
402                                        else
403                                        {
404                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
405                                        }
406                                }
407                               
408                                // O memberUid do usuário está somente no Ldap.
409                                $groups_db = array_flip($user_info['groups']);
410                                foreach ($user_info['groups_ldap'] as $gidnumber=>$cn)
411                                {
412                                        if (is_null($groups_db[$gidnumber]))
413                                        {
414                                                /*
415                                                $this->ldap_functions->remove_user2group($gidnumber, $user_info['uid']);
416                                                if ($alert_warning == '')
417                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
418                                                $alert_warning .= "Removido atributo memberUid do usuário do grupo $cn.\\n";
419                                                */
420                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Somente no LDAP]</option>";
421                                        }
422                                }
423                        }
424                       
425                        // MAILLISTS
426                        if (count($user_info['maillists_info']) > 0)
427                        {
428                               
429                                foreach ($user_info['maillists_info'] as $maillist)
430                                {
431                                        $array_maillist[$maillist['uidnumber']] = $maillist['uid'] . "  (" . $maillist['mail'] . ") ";
432                                }
433                                natcasesort($array_maillist);
434                                foreach ($array_maillist as $uidnumber=>$option)
435                                {
436                                        $ea_select_user_maillists_options .= "<option value=" . $uidnumber . ">" . $option . "</option>";
437                                }
438                        }
439                       
440                        // APPS.
441                        if ($disabled == 'disabled')
442                                $apps = $this->functions->make_list_app($manager_account_lid, $manager_context, $user_info['apps'], 'disabled');
443                        else
444                                $apps = $this->functions->make_list_app($manager_account_lid, $manager_context, $user_info['apps']);
445                       
446                        //PHOTO
447                        if ($user_info['photo_exist'])
448                        {
449                                $photo_bin = "./index.php?menuaction=expressoAdmin1_2.uiaccounts.show_photo&uidNumber=".$_GET['account_id']."&manager_context=$manager_context";
450                        }
451                        else
452                        {
453                                $photo_bin = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/expressoAdmin1_2/templates/default/images/photo_celepar.png';
454                                $disabled_delete_photo = 'disabled';
455                        }
456
457                        if ($alert_warning != '')
458                                $alert_warning = "alert('". $alert_warning ."')";
459
460                        $var = Array(
461                                'uidnumber'                                     => $_GET['account_id'],
462                                'manager_context'                       => $manager_context,
463                                'type'                                          => 'edit_user',
464                                'photo_exist'                           => $user_info['photo_exist'],
465                                'departmentnumber'                      => $user_info['departmentnumber'],
466                                'user_context'                          => $user_info['context'],
467                               
468                                'row_on'                                        => "#DDDDDD",
469                                'row_off'                                       => "#EEEEEE",
470                                'color_bg1'                                     => "#E8F0F0",
471                                'action'                                        => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.validate_user_data_edit'),
472                                'back_url'                                      => './index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users',
473                                'display_samba_suport'          => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none',
474                                'disabled'                                      => $disabled,
475                                'disabled_password'                     => $disabled_password,
476                                'disabled_samba'                        => $disabled_samba,
477                                'changequote_disabled'          => $disabled_quote,
478                               
479                                // First ABA
480                                'alert_warning'                                 => "$alert_warning",
481                                'display_input_account_lid'             => 'display:none',
482                                'lang_general_information'              => lang('General Information'),
483                                'lang_email_config'                             => lang('Email Config'),
484                                'lang_groups_permission'                => lang('Groups Permission'),
485                                'lang_lists_permission'                 => lang('Email Lists'),
486                                'lang_aplication_permission'    => lang('Aplication Permission'),       
487                                'lang_organizations'                    => lang('Organizations'),
488                                'lang_sector'                                   => lang('Sector'),
489                                'lang_account_lid'                              => lang('Login ID'),
490                                'lang_firstname'                                => lang('First Name'),
491                                'lang_lastname'                                 => lang('Last Name'),
492                                'lang_password'                                 => lang('Password'),
493                                'lang_phone'                                    => lang('Phone'),
494                                'lang_photo'                                    => lang('Photo'),
495                                'lang_re-password'                              => lang('Re-Password'),
496                                'lang_changepassword'                   => lang('Change password'),                             
497                                'lang_account_active'                   => lang('Account Active'),
498                                'lang_account_invisible'                => lang('Account Invisible'),
499                                'lang_back'                                             => lang('Back'),
500                                'lang_save'                                             => lang('Save'),
501                               
502                                'sectors'                                               => $orgs,
503                                'combo_organizations'                   => $orgs,
504                               
505                                'uid'                                                   => $user_info['uid'],
506                                'givenname'                                             => $user_info['givenname'],
507                                'mail1'                                                 => $user_info['mail'],
508                                'sn'                                                    => $user_info['sn'],
509                                'telephonenumber'                               => $user_info['telephonenumber'],
510                                'photo_bin'                                             => $photo_bin,
511                                'disabled_delete_photo'                 => $disabled_delete_photo,
512                               
513                                'display_tr_default_password'   => $this->functions->check_acl($manager_account_lid,'set_user_default_password') ? '' : 'none',
514                               
515                                'changepassword_checked'                => $user_info['changepassword'] == '1' ? 'CHECKED' : '',
516                                'phpgwaccountstatus_checked'    => $user_info['phpgwaccountstatus'] == 'A' ? 'CHECKED' : '',
517                                'phpgwaccountvisible_checked'   => $user_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '',
518
519                                //MAIL BORD
520                                'disabled_quota_used'                   => 'disabled',
521                                'lang_activeemailaccount'               => lang('Active email account'),
522                                'lang_email'                                    => lang('E-mail'),
523                                'lang_aliasemail'                               => lang('Alias email'),
524                                'lang_forwardingemail'                  => lang('Forwarding email'),
525                                'lang_email_quota'                              => lang('Email quota in MB'),
526                                'lang_onlyforwarding'                   => lang('Only forwarding'),
527                                'lang_email_quota_used'                 => lang('Quota used in MB'),
528                               
529                                'accountstatus_checked'         => $user_info['accountstatus'] == 'active' ? 'CHECKED' : '',
530                                'mail'                                          => $user_info['mail'],
531                                'mailalternateaddress'          => $user_info['mailalternateaddress'],
532                                'mailforwardingaddress'         => $user_info['mailforwardingaddress'],
533                                'deliverymode_checked'          => $user_info['deliverymode'] == 'forwardOnly' ? 'CHECKED' : '',
534                               
535                                'mailquota'                                     => $user_info['mailquota'],
536                                'mailquota_used'                        => $user_info['mailquota_used'],
537
538                                //Third ABA
539                                'lang_groups'                           => lang('Groups'),
540                                'lang_user_groups'                      => 'Grupos do Usuário',
541                                'lang_available_groups'         => 'Grupos disponíveis',
542                                'lang_primary_group'            => lang('Primary Group'),
543                                'lang_add'                                      => lang('Add'),
544                                'lang_rem'                                      => lang('Remove'),
545                                'ea_select_user_groups_options' => $ea_select_user_groups_options,
546                                'ea_combo_primary_user_group_options'   => $ea_combo_primary_user_group_options,
547                               
548                                //Fourd ABA
549                                'lang_user_mail_lists'                  => 'O usuário participa destas Listas de E-mail',
550                                'lang_available_mail_lists'             => 'Listas de E-mail disponíveis',
551                                'ea_select_user_maillists_options'  => $ea_select_user_maillists_options,
552                                                               
553                                //Five ABA
554                                'apps'  => $apps,
555
556                                //SAMBA ABA
557                                'lang_samba_config'                     => lang('Samba Config'),
558                                'lang_use_attrs_samba'          => 'Usar atributos Samba',
559                                'lang_sambaAcctFlags'           => lang('AcctFlags'),
560                                'lang_sambaLogonScript'         => lang('Logon Script'),
561                                'lang_sambaHomeDirectory'       => lang('Home Directory'),
562                                'lang_active_user'                      => lang('Samba User Active'),
563                                'lang_desactive_user'           => lang('Samba User Desactive'),
564                               
565                                'userSamba'                                     => $user_info['sambaUser'],
566                                'use_attrs_samba_checked'       => $user_info['sambaUser'] ? 'CHECKED' : '',
567                                'active_user_selected'          => $user_info['sambaaccflags'] == '[U          ]' ? 'selected' : '',
568                                'desactive_user_selected'       => $user_info['sambaaccflags'] == '[DU         ]' ? 'selected' : '',
569                                'sambalogonscript'                      => $user_info['sambalogonscript'],
570                                'sambahomedirectory'            => $user_info['homedirectory'],
571                                'defaultLogonScript'            => $this->current_config['expressoAdmin_defaultLogonScript'],
572                                'use_suggestion_in_logon_script' => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false'
573                        );
574                        $t->set_var($var);
575                        $t->pfp('out','body');                 
576                }
577               
578                function row_action($action,$type,$account_id)
579                {
580                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
581                                'menuaction' => 'expressoAdmin1_2.uiaccounts.'.$action.'_'.$type,
582                                'account_id' => $account_id
583                        )).'"> '.lang($action).' </a>';
584                }
585
586                function css()
587                {
588                        $appCSS =
589                        'th.activetab
590                        {
591                                color:#000000;
592                                background-color:#D3DCE3;
593                                border-top-width : 1px;
594                                border-top-style : solid;
595                                border-top-color : Black;
596                                border-left-width : 1px;
597                                border-left-style : solid;
598                                border-left-color : Black;
599                                border-right-width : 1px;
600                                border-right-style : solid;
601                                border-right-color : Black;
602                                font-size: 12px;
603                                font-family: Tahoma, Arial, Helvetica, sans-serif;
604                        }
605                       
606                        th.inactivetab
607                        {
608                                color:#000000;
609                                background-color:#E8F0F0;
610                                border-bottom-width : 1px;
611                                border-bottom-style : solid;
612                                border-bottom-color : Black;
613                                font-size: 12px;
614                                font-family: Tahoma, Arial, Helvetica, sans-serif;                             
615                        }
616                       
617                        .td_left {border-left:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
618                        .td_right {border-right:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
619                       
620                        div.activetab{ display:inline; }
621                        div.inactivetab{ display:none; }';
622                       
623                        return $appCSS;
624                }
625
626                function show_photo()
627                {
628                        $uidNumber = $_GET['uidNumber'];
629                        $manager_context = $_GET['manager_context'];
630                        $photo = $this->get_photo($uidNumber, $manager_context);
631                       
632                if ($photo)
633                        {
634                        header("Content-Type: image/jpeg");
635                                $width = imagesx($photo);
636                                $height = imagesy($photo);
637                    $twidth = 80;
638                $theight = 106;
639                                $small_photo = imagecreatetruecolor ($twidth, $theight);
640                                imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
641                                imagejpeg($small_photo,"",100);
642                                return;
643                        }
644                }
645               
646                function get_photo($uidNumber, $manager_context)
647                {
648                        $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect();
649                        $filter="(&(phpgwAccountType=u)(uidNumber=".$uidNumber."))";
650                        $justthese = array("jpegphoto");
651
652                        $search = ldap_search($ldap_conn, $manager_context, $filter, $justthese);
653                        $entry = ldap_first_entry($ldap_conn, $search);
654                        $jpeg_data = ldap_get_values_len($ldap_conn, $entry, "jpegphoto");
655                        $jpegphoto = imagecreatefromstring($jpeg_data[0]);
656                        return $jpegphoto;
657                }
658               
659                function show_access_log()
660                {       
661                        $account_id = $_GET['account_id'];
662                       
663                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
664                        $tmp = $this->functions->read_acl($manager_account_lid);
665                        $manager_context = $tmp[0]['context'];
666                       
667                        // Verifica se tem acesso a este modulo
668                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'change_users_password')))
669                        {
670                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
671                        }
672
673                        // Seta header.
674                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
675                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
676
677                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Access Log');
678                        $GLOBALS['phpgw']->common->phpgw_header();
679
680                        // Seta templates.
681                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
682                        $t->set_file(array("body" => "accesslog.tpl"));
683                        $t->set_block('body','main');
684                        $t->set_block('body','row','row');
685
686                        // GET access log from the user.
687                        $GLOBALS['phpgw']->db->limit_query("select loginid,ip,li,lo,account_id,sessionid from phpgw_access_log WHERE account_id=".$account_id." order by li desc",$start,__LINE__,__FILE__);
688                        while ($GLOBALS['phpgw']->db->next_record())
689                        {
690                                $records[] = array(
691                                        'loginid'    => $GLOBALS['phpgw']->db->f('loginid'),
692                                        'ip'         => $GLOBALS['phpgw']->db->f('ip'),
693                                        'li'         => $GLOBALS['phpgw']->db->f('li'),
694                                        'lo'         => $GLOBALS['phpgw']->db->f('lo'),
695                                        'account_id' => $GLOBALS['phpgw']->db->f('account_id'),
696                                        'sessionid'  => $GLOBALS['phpgw']->db->f('sessionid')
697                                );
698                        }
699
700                        // Seta as vcariaveis
701                        while (is_array($records) && list(,$record) = each($records))
702                        {
703                                $var = array(
704                                        'row_loginid' => $record['loginid'],
705                                        'row_ip'      => $record['ip'],
706                                        'row_li'      => date("d/m/Y - H:i:s", $record['li']),
707                                        'row_lo'      => $record['lo'] == 0 ? 0 : date("d/m/Y - H:i:s", $record['lo'])
708                                );
709                                $t->set_var($var);
710                                $t->fp('rows','row',True);
711                        }
712
713                        $var = Array(
714                                'th_bg'                 => $GLOBALS['phpgw_info']['theme']['th_bg'],
715                                'lang_back'             => 'Back',
716                                'back_url'              => "./index.php?menuaction=expressoAdmin1_2.uiaccounts.edit_user&account_id=$account_id",
717                                'lang_loginid'  => lang('Login ID'),
718                                'lang_ip'               => lang('IP'),
719                                'lang_login'    => lang('Log IN'),
720                                'lang_logout'   => lang('Log OUT')
721                        );
722                        $t->set_var($var);
723                        $t->pfp('out','body');
724                }
725        }
726?>
Note: See TracBrowser for help on using the repository browser.