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