FEATURE #1426: add log of all users
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
class Gravatar
|
||||||
|
{
|
||||||
|
public static function img($email, $size = 50)
|
||||||
|
{
|
||||||
|
return "http://www.gravatar.com/avatar/" . md5(strtolower(trim($email))) . "?s=" . $size;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests;
|
||||||
|
use App\Models\ActionLog;
|
||||||
|
|
||||||
|
class ActionLogOverview extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var ActionLog
|
||||||
|
*/
|
||||||
|
private $log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActionLog constructor.
|
||||||
|
*
|
||||||
|
* @param ActionLog $log
|
||||||
|
*/
|
||||||
|
public function __construct(ActionLog $log)
|
||||||
|
{
|
||||||
|
$this->log = $log;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOverview()
|
||||||
|
{
|
||||||
|
$actions = $this->log->getLogActionsQuery(true)
|
||||||
|
->paginate(25);
|
||||||
|
|
||||||
|
$this->log->translateLogMessages($actions);
|
||||||
|
|
||||||
|
return view('admin.actionLog.overview', ['actions' => $actions]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,6 +89,10 @@ Route::group([
|
|||||||
Route::get('history/{revision}/{id}', 'History@getDiff')
|
Route::get('history/{revision}/{id}', 'History@getDiff')
|
||||||
->name('history.diff');
|
->name('history.diff');
|
||||||
|
|
||||||
|
// list of all actions
|
||||||
|
Route::get('actions', 'ActionLogOverview@getOverview')
|
||||||
|
->name('log.overview');
|
||||||
|
|
||||||
// uploader methods
|
// uploader methods
|
||||||
Route::get('upload/file', 'UploadFile@getFile')
|
Route::get('upload/file', 'UploadFile@getFile')
|
||||||
->name('upload.file');
|
->name('upload.file');
|
||||||
|
|||||||
+18
-12
@@ -22,13 +22,22 @@ class ActionLog extends Model
|
|||||||
/**
|
/**
|
||||||
* Query factory for loading action logs with their type (therefore with name and value)
|
* Query factory for loading action logs with their type (therefore with name and value)
|
||||||
*
|
*
|
||||||
|
* @param bool $joinUser
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getLogActionsQuery()
|
public function getLogActionsQuery($joinUser = false)
|
||||||
{
|
{
|
||||||
$actions = \DB::table('action_log')
|
$actions = \DB::table('action_log')
|
||||||
|
->select('action_log.*', 'action_log_types.*')
|
||||||
->join('action_log_types', 'action_log_types.id', '=', 'action_log.type_id')
|
->join('action_log_types', 'action_log_types.id', '=', 'action_log.type_id')
|
||||||
->orderBy('created_at', 'DESC');
|
->orderBy('action_log.created_at', 'DESC');
|
||||||
|
|
||||||
|
if ($joinUser) {
|
||||||
|
|
||||||
|
$actions = $actions->join('users', 'users.id', '=', 'action_log.user_id')
|
||||||
|
->select('action_log.*', 'action_log_types.*', 'users.email', 'users.name as user_name');
|
||||||
|
}
|
||||||
|
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
@@ -55,7 +64,9 @@ class ActionLog extends Model
|
|||||||
->get();
|
->get();
|
||||||
|
|
||||||
// translate and return result
|
// translate and return result
|
||||||
return $this->translateLogMessages($actions);
|
$this->translateLogMessages($actions);
|
||||||
|
|
||||||
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,17 +76,12 @@ class ActionLog extends Model
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function translateLogMessages($messages)
|
public function translateLogMessages(&$messages)
|
||||||
{
|
{
|
||||||
$log = [];
|
|
||||||
|
|
||||||
// translate name and value of each record
|
// translate name and value of each record
|
||||||
foreach ($messages as $action) {
|
foreach ($messages as $i => $action) {
|
||||||
$action->name = trans($action->name);
|
$messages[$i]->name = trans($action->name);
|
||||||
$action->value = trans($action->value, (array)json_decode($action->parameters));
|
$messages[$i]->value = trans($action->value, (array)json_decode($action->parameters));
|
||||||
$log[] = $action;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $log;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Helpers\Gravatar;
|
||||||
use Illuminate\Auth\Authenticatable;
|
use Illuminate\Auth\Authenticatable;
|
||||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticableInterface;
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticableInterface;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@@ -48,6 +49,6 @@ class User extends Model implements AuthenticableInterface
|
|||||||
*/
|
*/
|
||||||
public function gravatar($size = 50)
|
public function gravatar($size = 50)
|
||||||
{
|
{
|
||||||
return "http://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email))) . "?s=" . $size;
|
return Gravatar::img($this->email, $size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class AdminMenusProvider extends ServiceProvider
|
|||||||
$sub->route('customfields.new', trans('admin/mainMenu.customFieldsNew'), [], 10, ['icon' => 'fa fa-code']);
|
$sub->route('customfields.new', trans('admin/mainMenu.customFieldsNew'), [], 10, ['icon' => 'fa fa-code']);
|
||||||
$sub->route('customfields.overview', trans('admin/mainMenu.customFieldsOverview'), [], 50, ['icon' => 'fa fa-code-fork']);
|
$sub->route('customfields.overview', trans('admin/mainMenu.customFieldsOverview'), [], 50, ['icon' => 'fa fa-code-fork']);
|
||||||
}, 30, ['icon' => 'fa fa-code']);
|
}, 30, ['icon' => 'fa fa-code']);
|
||||||
|
$menu->route('log.overview', trans('admin/mainMenu.actionLog'), [], 40, ['icon' => 'fa fa-history']);
|
||||||
$menu->url('#', trans('admin/mainMenu.settings'), 50, ['icon' => 'fa fa-gear']);
|
$menu->url('#', trans('admin/mainMenu.settings'), 50, ['icon' => 'fa fa-gear']);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
|
'overview' => 'List of all actions',
|
||||||
'login' => 'Logged in',
|
'login' => 'Logged in',
|
||||||
'logout' => 'Logged out',
|
'logout' => 'Logged out',
|
||||||
'userEdit' => 'Updated user :name (:email)',
|
'userEdit' => 'Updated user :name (:email)',
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ return [
|
|||||||
'fileManager' => 'File manager',
|
'fileManager' => 'File manager',
|
||||||
'uploadFile' => 'New file',
|
'uploadFile' => 'New file',
|
||||||
'uploadImage' => 'New image',
|
'uploadImage' => 'New image',
|
||||||
'uploadedFiles' => 'Overview'
|
'uploadedFiles' => 'Overview',
|
||||||
|
'actionLog' => 'Log'
|
||||||
];
|
];
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
@extends('admin.layout')
|
||||||
|
|
||||||
|
@section('pageName', @trans('admin/actionLog.overview'))
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<h2>@lang('admin/actionLog.overview')</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row" data-equalizer>
|
||||||
|
@if (!empty($actions))
|
||||||
|
<ul class="accordion" data-accordion>
|
||||||
|
@foreach($actions as $action)
|
||||||
|
<li class="accordion-item" data-accordion-item>
|
||||||
|
<a class="accordion-title">
|
||||||
|
<img src="{{\App\Helpers\Gravatar::img($action->email, 20)}}" alt="{{$action->email}}" />
|
||||||
|
{{date('d.m.Y', strtotime($action->created_at))}} |
|
||||||
|
<strong>{{$action->name}}</strong>
|
||||||
|
</a>
|
||||||
|
<div class="accordion-content" data-tab-content>
|
||||||
|
<div class="row">
|
||||||
|
<div class="column large-1 text-center">
|
||||||
|
<img src="{{\App\Helpers\Gravatar::img($action->email, 70)}}" alt="{{$action->email}}" />
|
||||||
|
<p>
|
||||||
|
{{$action->user_name}}<br />
|
||||||
|
{{date('G:i', strtotime($action->created_at))}}</p>
|
||||||
|
</div>
|
||||||
|
<div class="column large-11">
|
||||||
|
{{$action->value}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
@else
|
||||||
|
<em>@lang('admin/userManagement.noActions')</em>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row pagination">
|
||||||
|
{!! $actions->render() !!}
|
||||||
|
</div>
|
||||||
|
@stop
|
||||||
Reference in New Issue
Block a user