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