#59 Partial implementation of active users on the manage users page

merge-requests/2/head
Mike Koch 10 years ago
parent 6c126ec78e
commit e14e5f1050

@ -79,6 +79,7 @@ $default_userdata = array(
'user' => '', 'user' => '',
'signature' => '', 'signature' => '',
'isadmin' => 1, 'isadmin' => 1,
'active' => 1,
'categories' => array('1'), 'categories' => array('1'),
'features' => array('can_view_tickets','can_reply_tickets','can_change_cat','can_assign_self','can_view_unassigned','can_view_online'), 'features' => array('can_view_tickets','can_reply_tickets','can_change_cat','can_assign_self','can_view_unassigned','can_view_online'),
'signature' => '', 'signature' => '',
@ -137,6 +138,7 @@ if ( $action = hesk_REQUEST('a') )
elseif ($action == 'save') {update_user();} elseif ($action == 'save') {update_user();}
elseif ($action == 'remove') {remove();} elseif ($action == 'remove') {remove();}
elseif ($action == 'autoassign') {toggle_autoassign();} elseif ($action == 'autoassign') {toggle_autoassign();}
elseif ($action == 'active') {toggle_active();}
else {hesk_error($hesklang['invalid_action']);} else {hesk_error($hesklang['invalid_action']);}
} }
@ -427,6 +429,13 @@ while ($myuser = hesk_dbFetchAssoc($res))
$autoassign_code = ''; $autoassign_code = '';
} }
/* Is the user active? */
if ($myuser['active']) {
$activeMarkup = '<a href="manage_users.php?a=active&amp;s=0&amp;id='.$myuser['id'].'&amp;token='.hesk_token_echo(0).'" data-toggle="tooltip" data-placement="top" title="'.$hesklang['disable_user'].'"><i style="color: green; font-size: 16px" class="fa fa-user"></i></a>';
} else {
$activeMarkup = '<a href="manage_users.php?a=active&amp;s=0&amp;id='.$myuser['id'].'&amp;token='.hesk_token_echo(0).'" data-toggle="tooltip" data-placement="top" title="'.$hesklang['enable_user'].'"><i style="color: gray; font-size: 16px" class="fa fa-user"></i></a>';
}
echo <<<EOC echo <<<EOC
<tr> <tr>
<td>$myuser[name]</td> <td>$myuser[name]</td>
@ -443,7 +452,7 @@ if ($hesk_settings['rating'])
} }
echo <<<EOC echo <<<EOC
<td>$autoassign_code $edit_code $remove_code</td> <td>$autoassign_code $edit_code $remove_code $activeMarkup</td>
</tr> </tr>
EOC; EOC;
@ -533,7 +542,7 @@ function edit_user()
if ( ! isset($_SESSION['save_userdata'])) 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); $_SESSION['userdata'] = hesk_dbFetchAssoc($res);
/* Store original username for display until changes are saved successfully */ /* Store original username for display until changes are saved successfully */
@ -699,6 +708,9 @@ function edit_user()
<?php } else { ?> <?php } else { ?>
<input type="hidden" name="manage_settings" value="1"> <input type="hidden" name="manage_settings" value="1">
<?php } ?> <?php } ?>
<div class="checkbox">
<label><input type="checkbox" name="manage_active" <?php if ($_SESSION['userdata']['active']) { echo 'checked';} ?>> <?php echo $hesklang['active_user']; ?></label>
</div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -1050,4 +1062,33 @@ function toggle_autoassign()
hesk_process_messages($tmp,'./manage_users.php','SUCCESS'); hesk_process_messages($tmp,'./manage_users.php','SUCCESS');
} // End toggle_autoassign() } // 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');
}
?> ?>

Loading…
Cancel
Save