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