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