Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe
2014-07-16 18:21:42 -04:00
6 changed files with 71 additions and 0 deletions

View File

@@ -484,4 +484,49 @@ class UsersController extends AdminController
->make();
}
/**
* Unsuspend the given user.
*
* @param int $id
* @return Redirect
*/
public function getUnsuspend($id = null)
{
try {
// Get user information
$user = Sentry::getUserProvider()->findById($id);
// Check if we are not trying to unsuspend ourselves
if ($user->id === Sentry::getId()) {
// Prepare the error message
$error = Lang::get('admin/users/message.error.unsuspend');
// Redirect to the user management page
return Redirect::route('users')->with('error', $error);
}
// Do we have permission to unsuspend this user?
if ($user->isSuperUser() and ! Sentry::getUser()->isSuperUser()) {
// Redirect to the user management page
return Redirect::route('users')->with('error', 'Insufficient permissions!');
}
// Unsuspend the user
$throttle = Sentry::findThrottlerByUserId($id);
$throttle->unsuspend();
// Prepare the success message
$success = Lang::get('admin/users/message.success.unsuspend');
// Redirect to the user management page
return Redirect::route('users')->with('success', $success);
} catch (UserNotFoundException $e) {
// Prepare the error message
$error = Lang::get('admin/users/message.user_not_found', compact('id' ));
// Redirect to the user management page
return Redirect::route('users')->with('error', $error);
}
}
}

View File

@@ -23,6 +23,7 @@ return array(
'create' => 'There was an issue creating the user. Please try again.',
'update' => 'There was an issue updating the user. Please try again.',
'delete' => 'There was an issue deleting the user. Please try again.',
'unsuspend' => 'There was an issue unsuspending the user. Please try again.'
),
);

View File

@@ -74,4 +74,18 @@ class User extends SentryUserModel
return $this->belongsTo('User','manager_id')->withTrashed();
}
public function accountStatus()
{
$throttle = Sentry::findThrottlerByUserId($this->id);
if ($throttle->isBanned()) {
return 'banned';
} elseif ($throttle->isSuspended()) {
return 'suspended';
} else {
return '';
}
}
}

View File

@@ -157,6 +157,8 @@ Route::group(array('prefix' => 'admin'), function () {
Route::get('{userId}/delete', array('as' => 'delete/user', 'uses' => 'Controllers\Admin\UsersController@getDelete'));
Route::get('{userId}/restore', array('as' => 'restore/user', 'uses' => 'Controllers\Admin\UsersController@getRestore'));
Route::get('{userId}/view', array('as' => 'view/user', 'uses' => 'Controllers\Admin\UsersController@getView'));
Route::get('{userId}/unsuspend', array('as' => 'unsuspend/user', 'uses' => 'Controllers\Admin\UsersController@getUnsuspend'));
Route::get('datatable', array('as'=>'api.users', 'uses'=>'Controllers\Admin\UsersController@getDatatable'));
});

View File

@@ -42,6 +42,7 @@
<th class="col-md-1">@lang('general.assets')</th>
<th class="col-md-1">@lang('general.licenses')</th>
<th class="col-md-1">@lang('admin/users/table.activated')</th>
<th></th>
<th class="col-md-2 actions">@lang('table.actions')</th>
</tr>
</thead>
@@ -64,6 +65,13 @@
<td>{{ $user->isActivated() ? '<i class="icon-ok"></i>' : ''}}</td>
<td>
@if ($user->accountStatus()=='suspended')
<a href="{{ route('unsuspend/user', $user->id) }}" class="btn btn-warning"><span class="icon-time icon-white"></span></a>
@endif
</td>
<td>
@if ( ! is_null($user->deleted_at))
<a href="{{ route('restore/user', $user->id) }}" class="btn btn-warning"><i class="icon-share-alt icon-white"></i></a>
@else

View File

@@ -141,6 +141,7 @@ View User {{{ $user->fullName() }}} ::
<td>{{{ $log->added_on }}}</td>
<td>{{{ $log->action_type }}}</td>
<td>
@if ((isset($log->assetlog->name)) && ($log->assetlog->deleted_at==''))
<a href="{{ route('view/hardware', $log->asset_id) }}">{{{ $log->assetlog->asset_tag }}}</a>
@elseif ((isset($log->assetlog->name)) && ($log->assetlog->deleted_at!=''))