2014-07-30 17:18:59 +10:00
|
|
|
<?php namespace System\Controllers;
|
|
|
|
|
|
|
|
use Lang;
|
|
|
|
use Flash;
|
|
|
|
use BackendMenu;
|
|
|
|
use Backend\Classes\Controller;
|
|
|
|
use System\Classes\SettingsManager;
|
2014-07-30 17:44:50 +10:00
|
|
|
use System\Models\RequestLog;
|
2014-07-30 17:18:59 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Request Logs controller
|
|
|
|
*
|
|
|
|
* @package october\system
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
*/
|
|
|
|
class RequestLogs extends Controller
|
|
|
|
{
|
2017-07-27 17:35:14 +10:00
|
|
|
/**
|
|
|
|
* @var array Extensions implemented by this controller.
|
|
|
|
*/
|
2014-07-30 17:18:59 +10:00
|
|
|
public $implement = [
|
2017-07-27 17:35:14 +10:00
|
|
|
\Backend\Behaviors\FormController::class,
|
|
|
|
\Backend\Behaviors\ListController::class
|
2014-07-30 17:18:59 +10:00
|
|
|
];
|
2017-07-27 17:35:14 +10:00
|
|
|
/**
|
|
|
|
* @var array `FormController` configuration.
|
|
|
|
*/
|
2014-07-30 17:18:59 +10:00
|
|
|
public $formConfig = 'config_form.yaml';
|
|
|
|
|
2017-07-27 17:35:14 +10:00
|
|
|
/**
|
|
|
|
* @var array `ListController` configuration.
|
|
|
|
*/
|
2014-07-30 17:18:59 +10:00
|
|
|
public $listConfig = 'config_list.yaml';
|
|
|
|
|
2017-07-27 17:35:14 +10:00
|
|
|
/**
|
|
|
|
* @var array Permissions required to view this page.
|
|
|
|
*/
|
|
|
|
public $requiredPermissions = ['system.access_logs'];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
2014-07-30 17:18:59 +10:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
BackendMenu::setContext('October.System', 'system', 'settings');
|
|
|
|
SettingsManager::setContext('October.System', 'request_logs');
|
|
|
|
}
|
|
|
|
|
2015-11-28 11:10:06 +11:00
|
|
|
public function index_onRefresh()
|
|
|
|
{
|
|
|
|
return $this->listRefresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function index_onEmptyLog()
|
2014-07-30 17:44:50 +10:00
|
|
|
{
|
|
|
|
RequestLog::truncate();
|
2014-08-16 05:18:37 +01:00
|
|
|
Flash::success(Lang::get('system::lang.request_log.empty_success'));
|
2014-07-30 17:44:50 +10:00
|
|
|
return $this->listRefresh();
|
|
|
|
}
|
2015-02-21 13:49:32 +11:00
|
|
|
|
|
|
|
public function index_onDelete()
|
|
|
|
{
|
|
|
|
if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
|
|
|
|
foreach ($checkedIds as $recordId) {
|
2019-07-18 22:50:37 +08:00
|
|
|
if (!$record = RequestLog::find($recordId)) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-02-21 13:49:32 +11:00
|
|
|
$record->delete();
|
|
|
|
}
|
|
|
|
|
|
|
|
Flash::success(Lang::get('backend::lang.list.delete_selected_success'));
|
|
|
|
}
|
2015-02-21 19:16:14 +11:00
|
|
|
else {
|
|
|
|
Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
|
|
|
|
}
|
2015-02-21 13:49:32 +11:00
|
|
|
|
|
|
|
return $this->listRefresh();
|
|
|
|
}
|
2014-10-18 11:58:50 +02:00
|
|
|
}
|