2022-11-27 14:38:40 +00:00
|
|
|
<?php
|
2022-11-27 20:22:12 +00:00
|
|
|
/**
|
|
|
|
* @brief dcLog, a plugin for Dotclear 2
|
|
|
|
*
|
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
|
|
|
*
|
2022-12-20 21:35:39 +00:00
|
|
|
* @author Tomtom and Contributors
|
2022-11-27 20:22:12 +00:00
|
|
|
*
|
2022-12-03 20:36:21 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
2022-11-27 20:22:12 +00:00
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
|
|
|
return null;
|
|
|
|
}
|
2022-11-27 14:38:40 +00:00
|
|
|
|
2022-11-27 20:22:12 +00:00
|
|
|
if (!dcCore::app()->auth->isSuperAdmin()) {
|
|
|
|
return null;
|
|
|
|
}
|
2022-11-27 14:38:40 +00:00
|
|
|
|
2022-11-27 20:22:12 +00:00
|
|
|
$entries = $_POST['entries'] ?? null;
|
|
|
|
$del_all_log = isset($_POST['del_all_logs']) ? true : false;
|
2022-11-27 14:38:40 +00:00
|
|
|
|
|
|
|
# Delete logs
|
2022-11-27 20:22:12 +00:00
|
|
|
if (isset($_POST['del_logs']) || isset($_POST['del_all_logs'])) {
|
|
|
|
try {
|
|
|
|
dcCore::app()->log->delLogs($entries, $del_all_log);
|
|
|
|
dcAdminNotices::addSuccessNotice(
|
|
|
|
$del_all_log ?
|
|
|
|
__('All logs have been successfully deleted') :
|
|
|
|
__('Selected logs have been successfully deleted')
|
|
|
|
);
|
2022-12-20 21:27:28 +00:00
|
|
|
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__));
|
2022-11-27 20:22:12 +00:00
|
|
|
} catch (Exception $e) {
|
|
|
|
dcCore::app()->error->add($e->getMessage());
|
|
|
|
}
|
2022-11-27 14:38:40 +00:00
|
|
|
}
|
|
|
|
|
2022-11-27 20:22:12 +00:00
|
|
|
$filter = new adminGenericFilterV2('dcloglist');
|
|
|
|
$filter->add(dcAdminFilters::getPageFilter());
|
|
|
|
$filter->add(dcAdminFilters::getInputFilter('blog_id', __('Blog:')));
|
|
|
|
$filter->add(dcAdminFilters::getInputFilter('user_id', __('User:')));
|
|
|
|
$filter->add(dcAdminFilters::getInputFilter('log_table', __('Component:')));
|
|
|
|
$filter->add(dcAdminFilters::getInputFilter('log_ip', __('IP:')));
|
|
|
|
$params = $filter->params();
|
2022-11-27 14:38:40 +00:00
|
|
|
|
2022-11-27 20:22:12 +00:00
|
|
|
try {
|
|
|
|
$logs = dcCore::app()->log->getLogs($params);
|
|
|
|
$logs_counter = $logs->count();
|
|
|
|
$logs_list = new dcLogList($logs, $logs_counter);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2022-11-27 14:38:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo
|
2022-11-27 20:22:12 +00:00
|
|
|
'<html><head><title>' . __('Log') . '</title>' .
|
|
|
|
dcPage::jsJson('dclog_list', [
|
|
|
|
'confirm_delete_selected_log' => __('Are you sure you want to delete selected logs?'),
|
|
|
|
'confirm_delete_all_log' => __('Are you sure you want to delete all logs?'),
|
|
|
|
]) .
|
2022-12-20 21:27:28 +00:00
|
|
|
$filter->js(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) .
|
|
|
|
dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/dclog.js')) .
|
2022-11-27 20:22:12 +00:00
|
|
|
'</head><body>' .
|
|
|
|
dcPage::breadcrumb([
|
|
|
|
__('System') => '',
|
2022-12-20 21:27:28 +00:00
|
|
|
__('Log') => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
|
2022-11-27 20:22:12 +00:00
|
|
|
]) .
|
|
|
|
dcPage::notices();
|
2022-11-27 14:38:40 +00:00
|
|
|
|
2022-11-27 20:22:12 +00:00
|
|
|
if (isset($logs) && isset($logs_list)) {
|
|
|
|
if ($logs->isEmpty() && !$filter->show()) {
|
|
|
|
echo '<p>' . __('There are no logs') . '</p>';
|
|
|
|
} else {
|
|
|
|
$filter->display(
|
2022-12-20 21:27:28 +00:00
|
|
|
'admin.plugin.' . basename(__DIR__),
|
|
|
|
form::hidden('p', basename(__DIR__))
|
2022-11-27 20:22:12 +00:00
|
|
|
);
|
|
|
|
$logs_list->display(
|
|
|
|
$filter->__get('page'),
|
|
|
|
$filter->__get('nb'),
|
2022-12-20 21:27:28 +00:00
|
|
|
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" method="post" id="form-entries">' .
|
2022-11-27 14:38:40 +00:00
|
|
|
|
2022-11-27 20:22:12 +00:00
|
|
|
'%s' .
|
2022-11-27 14:38:40 +00:00
|
|
|
|
2022-11-27 20:22:12 +00:00
|
|
|
'<div class="two-cols">' .
|
|
|
|
'<p class="col checkboxes-helpers"></p>' .
|
2022-11-27 14:38:40 +00:00
|
|
|
|
2022-11-27 20:22:12 +00:00
|
|
|
'<p class="col right">' .
|
|
|
|
'<input type="submit" value="' . __('Delete selected logs') . '" name="del_logs" /> ' .
|
|
|
|
'<input type="submit" value="' . __('Delete all logs') . '" name="del_all_logs" />' .
|
|
|
|
'</p>' .
|
2022-11-27 14:38:40 +00:00
|
|
|
|
2022-12-20 21:27:28 +00:00
|
|
|
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), $filter->values()) .
|
2022-11-27 20:22:12 +00:00
|
|
|
dcCore::app()->formNonce() .
|
|
|
|
'</div>' .
|
|
|
|
'</form>',
|
|
|
|
$filter->show()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2022-11-27 14:38:40 +00:00
|
|
|
|
2022-11-27 20:22:12 +00:00
|
|
|
echo '</body></html>';
|