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