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