diff --git a/admin/manage_users.php b/admin/manage_users.php index 3d584d63..0eaebde9 100644 --- a/admin/manage_users.php +++ b/admin/manage_users.php @@ -79,6 +79,7 @@ $default_userdata = array( 'user' => '', 'signature' => '', 'isadmin' => 1, + 'active' => 1, 'categories' => array('1'), 'features' => array('can_view_tickets','can_reply_tickets','can_change_cat','can_assign_self','can_view_unassigned','can_view_online'), 'signature' => '', @@ -137,6 +138,7 @@ if ( $action = hesk_REQUEST('a') ) elseif ($action == 'save') {update_user();} elseif ($action == 'remove') {remove();} elseif ($action == 'autoassign') {toggle_autoassign();} + elseif ($action == 'active') {toggle_active();} else {hesk_error($hesklang['invalid_action']);} } @@ -427,6 +429,13 @@ while ($myuser = hesk_dbFetchAssoc($res)) $autoassign_code = ''; } + /* Is the user active? */ + if ($myuser['active']) { + $activeMarkup = ''; + } else { + $activeMarkup = ''; + } + echo << $myuser[name] @@ -443,7 +452,7 @@ if ($hesk_settings['rating']) } echo <<$autoassign_code $edit_code $remove_code +$autoassign_code $edit_code $remove_code $activeMarkup EOC; @@ -533,7 +542,7 @@ function edit_user() if ( ! isset($_SESSION['save_userdata'])) { - $res = hesk_dbQuery("SELECT `user`,`pass`,`isadmin`,`name`,`email`,`signature`,`categories`,`autoassign`,`heskprivileges` AS `features`, `can_manage_settings` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `id`='".intval($id)."' LIMIT 1"); + $res = hesk_dbQuery("SELECT `user`,`pass`,`isadmin`,`name`,`email`,`signature`,`categories`,`autoassign`,`heskprivileges` AS `features`, `can_manage_settings`, `active` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `id`='".intval($id)."' LIMIT 1"); $_SESSION['userdata'] = hesk_dbFetchAssoc($res); /* Store original username for display until changes are saved successfully */ @@ -699,6 +708,9 @@ function edit_user() +
+ +
@@ -1050,4 +1062,33 @@ function toggle_autoassign() hesk_process_messages($tmp,'./manage_users.php','SUCCESS'); } // End toggle_autoassign() + +function toggle_active() +{ + global $hesk_settings, $hesklang; + + /* Security check */ + hesk_token_check(); + + $myuser = intval(hesk_GET('id')) or hesk_error($hesklang['no_valid_id']); + $_SESSION['seluser'] = $myuser; + + if (intval(hesk_GET('s'))) + { + $active = 1; + $tmp = $hesklang['user_activated']; + } else + { + $active = 0; + $tmp = $hesklang['user_deactivated']; + } + + hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` SET `active` = '".$active."' WHERE `id` = '".intval($myuser)."'"); + + if (hesk_dbAffectedRows() != 1) { + hesk_process_messages($hesklang['int_error'].': '.$hesklang['user_not_found'],'./manage_users.php'); + } + + hesk_process_messages($tmp,'./manage_users.php','SUCCESS'); +} ?>