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

Revision 27, 30.2 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                        // Cria combo de dominio samba
209                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
210                        {
211                                $a_sambadomains = $this->db_functions->get_sambadomains_list();
212                                $sambadomainname_options = '';
213                                if (count($a_sambadomains))
214                                {
215                                        foreach ($a_sambadomains as $a_sambadomain)
216                                        {
217                                                $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>";
218                                        }
219                                }
220                        }
221                       
222                        // Valores default.
223                        $var = Array(
224                                'row_on'                                => "#DDDDDD",
225                                'row_off'                               => "#EEEEEE",
226                                'color_bg1'                             => "#E8F0F0",
227                                'manager_context'               => $manager_context,
228                                'type'                                  => 'create_user',
229                                'back_url'                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'),
230                                'display_samba_suport'  => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none',
231                               
232                                // First ABA
233                                'display_spam_uid'                              => 'display:none',
234                                'lang_general_information'              => lang('General Information'),
235                                'lang_email_config'                             => lang('Email Config'),
236                                'lang_groups_permission'                => lang('Groups Permission'),
237                                'lang_lists_permission'                 => lang('Email Lists'),
238                                'lang_aplication_permission'    => lang('Aplication Permission'),       
239                                'lang_organizations'                    => lang('Organizations'),
240                                'lang_sector'                                   => lang('Sector'),
241                                'lang_account_lid'                              => lang('Login ID'),
242                                'lang_firstname'                                => lang('First Name'),
243                                'lang_lastname'                                 => lang('Last Name'),
244                                'lang_password'                                 => lang('Password'),
245                                'lang_re-password'                              => lang('Re-Password'),
246                                'lang_changepassword'                   => lang('Change password'),                             
247                                'lang_phone'                                    => lang('Phone'),
248                                'lang_photo'                                    => lang('Photo'),
249                                'lang_account_active'                   => lang('Account Active'),
250                                'lang_account_invisible'                => lang('Account Invisible'),
251                                'lang_never'                                    => lang('never'),
252                                'lang_back'                                             => lang('Back'),
253                                'lang_save'                                             => lang('Save'),
254                               
255                                'sectors'                                               => $sectors,
256                                'combo_organizations'                   => $sectors,
257                                'changepassword_checked'                => 'CHECKED',
258                                'phpgwaccountstatus_checked'    => 'CHECKED',
259                                'photo_bin'                                             => $GLOBALS['phpgw_info']['server']['webserver_url'].'/expressoAdmin1_2/templates/default/images/photo_celepar.png',
260                                'disabled_delete_photo'                 => 'disabled',
261                                'display_tr_default_password'   => 'none',
262                                'minimumSizeLogin'                              => $this->current_config['expressoAdmin_minimumSizeLogin'],
263                                'defaultDomain'                                 => $this->current_config['expressoAdmin_defaultDomain'],
264                                'concatenateDomain'                             => $this->current_config['expressoAdmin_concatenateDomain'],
265                                'ldap_context'                                  => ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']),
266                               
267                                //MAIL
268                                'lang_activeemailaccount'               => lang('Active email account'),
269                                'lang_email'                                    => lang('E-mail'),
270                                'lang_aliasemail'                               => lang('Alias email'),
271                                'lang_forwardingemail'                  => lang('Forwarding email'),
272                                'lang_email_quota'                              => lang('Email quota in MB'),
273                                'lang_onlyforwarding'                   => lang('Only forwarding'),
274                                'lang_quote_message'                    => lang('leave empty for no quota'),
275                                'lang_email_quota_used'                 => lang('Quota used in MB'),
276                                'accountstatus_checked'                 => 'CHECKED',
277                                'mailquota'                                             => $this->current_config['expressoAdmin_defaultUserQuota'],
278                                'changequote_disabled'                  => $this->functions->check_acl($manager_lid,'change_users_quote') ? '' : 'readonly',
279                                'imapDelimiter'                                 => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'],
280
281                                //Third ABA
282                                'lang_groups'                                   => lang('Groups'),
283                                'lang_user_groups'                              => 'Grupos do Usuário',
284                                'lang_available_groups'                 => 'Grupos disponíveis',
285                                'lang_listGroups'                               => lang('ListGroups'),
286                                'lang_primary_group'                    => lang('Primary Group'),
287                                'lang_add'                                              => lang('Add'),
288                                'lang_rem'                                              => lang('Remove'),
289                               
290                                //Fourd ABA
291                                'lang_user_mail_lists'                  => 'O usuário participa destas Listas de E-mail',
292                                'lang_available_mail_lists'             => 'Listas de E-mail disponíveis',
293                               
294                                //Five ABA
295                                'apps'                                                          => $applications_list,
296                               
297                                //SAMBA ABA
298                                'lang_samba_config'                                     => lang('Samba Config'),
299                                'lang_use_attrs_samba'                          => lang('Use samba attributes'),
300                                'lang_sambadomain'                                      => lang('Domain'),
301                                'lang_sambaAcctFlags'                           => lang('AcctFlags'),
302                                'lang_sambaLogonScript'                         => lang('Logon Script'),
303                                'lang_sambaHomeDirectory'                       => lang('Home Directory'),
304                                'lang_active_user'                                      => lang('Samba User Active'),
305                                'lang_desactive_user'                           => lang('Samba User Desactive'),
306                                'use_attrs_samba_checked'                       => 'CHECKED',
307                                'sambadomainname_options'                       => $sambadomainname_options,
308                                'sambalogonscript'                                      => $this->current_config['expressoAdmin_defaultLogonScript'] != '' ? $this->current_config['expressoAdmin_defaultLogonScript'] : '',
309                                'use_suggestion_in_logon_script'        => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false',
310                        );
311                        $t->set_var($var);
312                        $t->pfp('out','main');
313                }
314               
315                function edit_user()
316                {
317                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
318                        $tmp = $this->functions->read_acl($manager_account_lid);
319                        $manager_context = $tmp[0]['context'];
320                        $alert_warning = '';
321                       
322                        // Verifica se tem acesso a este modulo
323                        $disabled = 'disabled';
324                        $disabled_password = 'disabled';
325                        $disabled_samba = 'disabled';
326                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) &&
327                                (!$this->functions->check_acl($manager_account_lid,'change_users_password')) &&
328                                (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
329                        {
330                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
331                        }
332                        // SOMENTE ALTERAÇÃO DE SENHA
333                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'change_users_password')))
334                        {
335                                $disabled = 'disabled';
336                                $disabled_password = '';
337                        }
338                        // SOMENTE ALTERAÇÃO DOS ATRIBUTOS SAMBA
339                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
340                        {
341                                $disabled = 'disabled';
342                                $disabled_samba = '';
343                        }
344                        // TOTAIS MENOS O SAMBA
345                        if (($this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
346                        {
347                                $disabled = '';
348                                $disabled_password = '';
349                                $disabled_samba = 'disabled';
350                        }
351                        // TOTAIS
352                        elseif ($this->functions->check_acl($manager_account_lid,'edit_users'))
353                        {
354                                $disabled = '';
355                                $disabled_password = '';
356                                $disabled_samba = '';
357                        }
358                       
359                        if (!$this->functions->check_acl($manager_account_lid,'change_users_quote'))
360                                $disabled_quote = 'readonly';
361                       
362                        // GET all infomations about the user.
363                        $user_info = $this->user->get_user_info($_GET['account_id'], $manager_context);
364                       
365                        // JavaScript
366                        $GLOBALS['phpgw']->js->validate_file("jscode","users","expressoAdmin1_2");
367                        $GLOBALS['phpgw']->js->set_onload("get_available_groups(document.forms[0].context.value);");
368                        $GLOBALS['phpgw']->js->set_onload("get_available_maillists(document.forms[0].context.value);");
369                        $GLOBALS['phpgw']->js->set_onload("use_samba_attrs('".$user_info['sambaUser']."');");
370                       
371                        // Seta header.
372                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
373                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
374
375                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit User');
376                        $GLOBALS['phpgw']->common->phpgw_header();
377
378                        // Seta templates.
379                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
380                        $t->set_file(array("body" => "accounts_form.tpl"));
381                        $t->set_block('body','main');
382                                                       
383                // ORGANIZATIONS
384                $orgs = $this->functions->get_organizations($manager_context, $user_info['context']);
385
386                        // GROUPS.
387                        if (count($user_info['groups_info']) > 0)
388                        {
389                                foreach ($user_info['groups_info'] as $group)
390                                {
391                                        $array_groups[$group['gidnumber']] = $group['cn'];
392                                }
393                                natcasesort($array_groups);
394                                foreach ($array_groups as $gidnumber=>$cn)
395                                {
396                                        // Grupo existe no Banco mas não no Ldap, excluimos grupo do Banco.
397                                        /*
398                                        if (!$this->ldap_functions->group_exist($gidnumber))
399                                        {
400                                                $this->db_functions->delete_group($gidnumber);
401                                                $this->db_functions->write_log("expressoAdmin deletou o grupo $gidnumber do banco, pois não existia no ldap.",'','','','');
402                                                continue;
403                                        }
404                                        */
405                                       
406                                        // O memberUid do usuário está somente no Banco, então adicionamos o memberUid no Ldap.
407                                        if (is_null($user_info['groups_ldap'][$gidnumber]))
408                                        {
409                                                $this->ldap_functions->add_user2group($gidnumber, $user_info['uid']);
410                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Incluido memberUid no Ldap]</option>";
411
412                                                if ($alert_warning == '')
413                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
414                                                $alert_warning .= "Incluido atributo memberUid do usuário no grupo $cn - $gidnumber.\\n";
415                                        }
416                                        else
417                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
418                                       
419                                        if ($gidnumber == $user_info['gidnumber'])
420                                        {
421                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . " selected>" . $cn . "</option>";
422                                        }
423                                        else
424                                        {
425                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
426                                        }
427                                }
428                               
429                                // O memberUid do usuário está somente no Ldap.
430                                $groups_db = array_flip($user_info['groups']);
431                                foreach ($user_info['groups_ldap'] as $gidnumber=>$cn)
432                                {
433                                        if (is_null($groups_db[$gidnumber]))
434                                        {
435                                                /*
436                                                $this->ldap_functions->remove_user2group($gidnumber, $user_info['uid']);
437                                                if ($alert_warning == '')
438                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
439                                                $alert_warning .= "Removido atributo memberUid do usuário do grupo $cn.\\n";
440                                                */
441                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Somente no LDAP]</option>";
442                                        }
443                                }
444                        }
445                       
446                        // MAILLISTS
447                        if (count($user_info['maillists_info']) > 0)
448                        {
449                               
450                                foreach ($user_info['maillists_info'] as $maillist)
451                                {
452                                        $array_maillist[$maillist['uidnumber']] = $maillist['uid'] . "  (" . $maillist['mail'] . ") ";
453                                }
454                                natcasesort($array_maillist);
455                                foreach ($array_maillist as $uidnumber=>$option)
456                                {
457                                        $ea_select_user_maillists_options .= "<option value=" . $uidnumber . ">" . $option . "</option>";
458                                }
459                        }
460                       
461                        // APPS.
462                        if ($disabled == 'disabled')
463                                $apps = $this->functions->make_list_app($manager_account_lid, $manager_context, $user_info['apps'], 'disabled');
464                        else
465                                $apps = $this->functions->make_list_app($manager_account_lid, $manager_context, $user_info['apps']);
466                       
467                        //PHOTO
468                        if ($user_info['photo_exist'])
469                        {
470                                $photo_bin = "./index.php?menuaction=expressoAdmin1_2.uiaccounts.show_photo&uidNumber=".$_GET['account_id']."&manager_context=$manager_context";
471                        }
472                        else
473                        {
474                                $photo_bin = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/expressoAdmin1_2/templates/default/images/photo_celepar.png';
475                                $disabled_delete_photo = 'disabled';
476                        }
477
478                        // Cria combo de dominios do samba
479                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
480                        {
481                                $a_sambadomains = $this->db_functions->get_sambadomains_list();
482                                $sambadomainname_options = '';
483                                if (count($a_sambadomains))
484                                {
485                                        foreach ($a_sambadomains as $a_sambadomain)
486                                        {
487                                                if ($a_sambadomain['samba_domain_sid'] == $user_info['sambasid'])
488                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "' SELECTED>" . $a_sambadomain['samba_domain_name'] . "</option>";
489                                                else
490                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>";
491                                        }
492                                }
493                        }
494
495                        if ($alert_warning != '')
496                                $alert_warning = "alert('". $alert_warning ."')";
497
498                        $var = Array(
499                                'uidnumber'                                     => $_GET['account_id'],
500                                'manager_context'                       => $manager_context,
501                                'type'                                          => 'edit_user',
502                                'photo_exist'                           => $user_info['photo_exist'],
503                                'departmentnumber'                      => $user_info['departmentnumber'],
504                                'user_context'                          => $user_info['context'],
505                               
506                                'row_on'                                        => "#DDDDDD",
507                                'row_off'                                       => "#EEEEEE",
508                                'color_bg1'                                     => "#E8F0F0",
509                                'action'                                        => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.validate_user_data_edit'),
510                                'back_url'                                      => './index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users',
511                                'display_samba_suport'          => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none',
512                                'disabled'                                      => $disabled,
513                                'disabled_password'                     => $disabled_password,
514                                'disabled_samba'                        => $disabled_samba,
515                                'changequote_disabled'          => $disabled_quote,
516                               
517                                // First ABA
518                                'alert_warning'                                 => "$alert_warning",
519                                'display_input_account_lid'             => 'display:none',
520                                'lang_general_information'              => lang('General Information'),
521                                'lang_email_config'                             => lang('Email Config'),
522                                'lang_groups_permission'                => lang('Groups Permission'),
523                                'lang_lists_permission'                 => lang('Email Lists'),
524                                'lang_aplication_permission'    => lang('Aplication Permission'),       
525                                'lang_organizations'                    => lang('Organizations'),
526                                'lang_sector'                                   => lang('Sector'),
527                                'lang_account_lid'                              => lang('Login ID'),
528                                'lang_firstname'                                => lang('First Name'),
529                                'lang_lastname'                                 => lang('Last Name'),
530                                'lang_password'                                 => lang('Password'),
531                                'lang_phone'                                    => lang('Phone'),
532                                'lang_photo'                                    => lang('Photo'),
533                                'lang_re-password'                              => lang('Re-Password'),
534                                'lang_changepassword'                   => lang('Change password'),                             
535                                'lang_account_active'                   => lang('Account Active'),
536                                'lang_account_invisible'                => lang('Account Invisible'),
537                                'lang_back'                                             => lang('Back'),
538                                'lang_save'                                             => lang('Save'),
539                               
540                                'sectors'                                               => $orgs,
541                                'combo_organizations'                   => $orgs,
542                               
543                                'uid'                                                   => $user_info['uid'],
544                                'givenname'                                             => $user_info['givenname'],
545                                'mail1'                                                 => $user_info['mail'],
546                                'sn'                                                    => $user_info['sn'],
547                                'telephonenumber'                               => $user_info['telephonenumber'],
548                                'photo_bin'                                             => $photo_bin,
549                                'disabled_delete_photo'                 => $disabled_delete_photo,
550                               
551                                'display_tr_default_password'   => $this->functions->check_acl($manager_account_lid,'set_user_default_password') ? '' : 'none',
552                               
553                                'changepassword_checked'                => $user_info['changepassword'] == '1' ? 'CHECKED' : '',
554                                'phpgwaccountstatus_checked'    => $user_info['phpgwaccountstatus'] == 'A' ? 'CHECKED' : '',
555                                'phpgwaccountvisible_checked'   => $user_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '',
556
557                                //MAIL BORD
558                                'disabled_quota_used'                   => 'disabled',
559                                'lang_activeemailaccount'               => lang('Active email account'),
560                                'lang_email'                                    => lang('E-mail'),
561                                'lang_aliasemail'                               => lang('Alias email'),
562                                'lang_forwardingemail'                  => lang('Forwarding email'),
563                                'lang_email_quota'                              => lang('Email quota in MB'),
564                                'lang_onlyforwarding'                   => lang('Only forwarding'),
565                                'lang_email_quota_used'                 => lang('Quota used in MB'),
566                               
567                                'accountstatus_checked'         => $user_info['accountstatus'] == 'active' ? 'CHECKED' : '',
568                                'mail'                                          => $user_info['mail'],
569                                'mailalternateaddress'          => $user_info['mailalternateaddress'],
570                                'mailforwardingaddress'         => $user_info['mailforwardingaddress'],
571                                'deliverymode_checked'          => $user_info['deliverymode'] == 'forwardOnly' ? 'CHECKED' : '',
572                               
573                                'mailquota'                                     => $user_info['mailquota'],
574                                'mailquota_used'                        => $user_info['mailquota_used'],
575
576                                //Third ABA
577                                'lang_groups'                           => lang('Groups'),
578                                'lang_user_groups'                      => 'Grupos do Usuário',
579                                'lang_available_groups'         => 'Grupos disponíveis',
580                                'lang_primary_group'            => lang('Primary Group'),
581                                'lang_add'                                      => lang('Add'),
582                                'lang_rem'                                      => lang('Remove'),
583                                'ea_select_user_groups_options' => $ea_select_user_groups_options,
584                                'ea_combo_primary_user_group_options'   => $ea_combo_primary_user_group_options,
585                               
586                                //Fourd ABA
587                                'lang_user_mail_lists'                  => 'O usuário participa destas Listas de E-mail',
588                                'lang_available_mail_lists'             => 'Listas de E-mail disponíveis',
589                                'ea_select_user_maillists_options'  => $ea_select_user_maillists_options,
590                                                               
591                                //Five ABA
592                                'apps'  => $apps,
593
594                                //SAMBA ABA
595                                'lang_samba_config'                     => lang('Samba Config'),
596                                'lang_use_attrs_samba'          => lang('Use samba attributes'),
597                                'lang_sambadomain'                      => lang('Domain'),
598                                'lang_sambaAcctFlags'           => lang('AcctFlags'),
599                                'lang_sambaLogonScript'         => lang('Logon Script'),
600                                'lang_sambaHomeDirectory'       => lang('Home Directory'),
601                                'lang_active_user'                      => lang('Samba User Active'),
602                                'lang_desactive_user'           => lang('Samba User Desactive'),
603                               
604                                'userSamba'                                     => $user_info['sambaUser'],
605                                'sambadomainname_options'       => $sambadomainname_options,
606                                'use_attrs_samba_checked'       => $user_info['sambaUser'] ? 'CHECKED' : '',
607                                'active_user_selected'          => $user_info['sambaaccflags'] == '[U          ]' ? 'selected' : '',
608                                'desactive_user_selected'       => $user_info['sambaaccflags'] == '[DU         ]' ? 'selected' : '',
609                                'sambalogonscript'                      => $user_info['sambalogonscript'],
610                                'sambahomedirectory'            => $user_info['homedirectory'],
611                                'defaultLogonScript'            => $this->current_config['expressoAdmin_defaultLogonScript'],
612                                'use_suggestion_in_logon_script' => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false'
613                        );
614                        $t->set_var($var);
615                        $t->pfp('out','body');                 
616                }
617               
618                function row_action($action,$type,$account_id)
619                {
620                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
621                                'menuaction' => 'expressoAdmin1_2.uiaccounts.'.$action.'_'.$type,
622                                'account_id' => $account_id
623                        )).'"> '.lang($action).' </a>';
624                }
625
626                function css()
627                {
628                        $appCSS =
629                        'th.activetab
630                        {
631                                color:#000000;
632                                background-color:#D3DCE3;
633                                border-top-width : 1px;
634                                border-top-style : solid;
635                                border-top-color : Black;
636                                border-left-width : 1px;
637                                border-left-style : solid;
638                                border-left-color : Black;
639                                border-right-width : 1px;
640                                border-right-style : solid;
641                                border-right-color : Black;
642                                font-size: 12px;
643                                font-family: Tahoma, Arial, Helvetica, sans-serif;
644                        }
645                       
646                        th.inactivetab
647                        {
648                                color:#000000;
649                                background-color:#E8F0F0;
650                                border-bottom-width : 1px;
651                                border-bottom-style : solid;
652                                border-bottom-color : Black;
653                                font-size: 12px;
654                                font-family: Tahoma, Arial, Helvetica, sans-serif;                             
655                        }
656                       
657                        .td_left {border-left:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
658                        .td_right {border-right:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
659                       
660                        div.activetab{ display:inline; }
661                        div.inactivetab{ display:none; }';
662                       
663                        return $appCSS;
664                }
665
666                function show_photo()
667                {
668                        $uidNumber = $_GET['uidNumber'];
669                        $manager_context = $_GET['manager_context'];
670                        $photo = $this->get_photo($uidNumber, $manager_context);
671                       
672                if ($photo)
673                        {
674                        header("Content-Type: image/jpeg");
675                                $width = imagesx($photo);
676                                $height = imagesy($photo);
677                    $twidth = 80;
678                $theight = 106;
679                                $small_photo = imagecreatetruecolor ($twidth, $theight);
680                                imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
681                                imagejpeg($small_photo,"",100);
682                                return;
683                        }
684                }
685               
686                function get_photo($uidNumber, $manager_context)
687                {
688                        $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect();
689                        $filter="(&(phpgwAccountType=u)(uidNumber=".$uidNumber."))";
690                        $justthese = array("jpegphoto");
691
692                        $search = ldap_search($ldap_conn, $manager_context, $filter, $justthese);
693                        $entry = ldap_first_entry($ldap_conn, $search);
694                        $jpeg_data = ldap_get_values_len($ldap_conn, $entry, "jpegphoto");
695                        $jpegphoto = imagecreatefromstring($jpeg_data[0]);
696                        return $jpegphoto;
697                }
698               
699                function show_access_log()
700                {       
701                        $account_id = $_GET['account_id'];
702                       
703                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
704                        $tmp = $this->functions->read_acl($manager_account_lid);
705                        $manager_context = $tmp[0]['context'];
706                       
707                        // Verifica se tem acesso a este modulo
708                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'change_users_password')))
709                        {
710                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
711                        }
712
713                        // Seta header.
714                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
715                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
716
717                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Access Log');
718                        $GLOBALS['phpgw']->common->phpgw_header();
719
720                        // Seta templates.
721                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
722                        $t->set_file(array("body" => "accesslog.tpl"));
723                        $t->set_block('body','main');
724                        $t->set_block('body','row','row');
725
726                        // GET access log from the user.
727                        $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__);
728                        while ($GLOBALS['phpgw']->db->next_record())
729                        {
730                                $records[] = array(
731                                        'loginid'    => $GLOBALS['phpgw']->db->f('loginid'),
732                                        'ip'         => $GLOBALS['phpgw']->db->f('ip'),
733                                        'li'         => $GLOBALS['phpgw']->db->f('li'),
734                                        'lo'         => $GLOBALS['phpgw']->db->f('lo'),
735                                        'account_id' => $GLOBALS['phpgw']->db->f('account_id'),
736                                        'sessionid'  => $GLOBALS['phpgw']->db->f('sessionid')
737                                );
738                        }
739
740                        // Seta as vcariaveis
741                        while (is_array($records) && list(,$record) = each($records))
742                        {
743                                $var = array(
744                                        'row_loginid' => $record['loginid'],
745                                        'row_ip'      => $record['ip'],
746                                        'row_li'      => date("d/m/Y - H:i:s", $record['li']),
747                                        'row_lo'      => $record['lo'] == 0 ? 0 : date("d/m/Y - H:i:s", $record['lo'])
748                                );
749                                $t->set_var($var);
750                                $t->fp('rows','row',True);
751                        }
752
753                        $var = Array(
754                                'th_bg'                 => $GLOBALS['phpgw_info']['theme']['th_bg'],
755                                'lang_back'             => 'Back',
756                                'back_url'              => "./index.php?menuaction=expressoAdmin1_2.uiaccounts.edit_user&account_id=$account_id",
757                                'lang_loginid'  => lang('Login ID'),
758                                'lang_ip'               => lang('IP'),
759                                'lang_login'    => lang('Log IN'),
760                                'lang_logout'   => lang('Log OUT')
761                        );
762                        $t->set_var($var);
763                        $t->pfp('out','body');
764                }
765        }
766?>
Note: See TracBrowser for help on using the repository browser.