2021-09-02 22:04:20 +00:00
|
|
|
<?php
|
2021-09-02 22:18:08 +00:00
|
|
|
/**
|
|
|
|
* @brief activityReport, a plugin for Dotclear 2
|
2022-11-18 20:24:30 +00:00
|
|
|
*
|
2021-09-02 22:18:08 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2022-11-18 20:24:30 +00:00
|
|
|
*
|
2021-09-02 22:18:08 +00:00
|
|
|
* @author Jean-Christian Denis and contributors
|
2022-11-18 20:24:30 +00:00
|
|
|
*
|
2021-09-02 22:18:08 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-09-02 22:51:23 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-09-02 22:04:20 +00:00
|
|
|
|
2022-11-18 20:24:30 +00:00
|
|
|
if (!defined('ACTIVITY_REPORT_V2')) {
|
2021-09-02 22:51:23 +00:00
|
|
|
return null;
|
|
|
|
}
|
2021-09-02 22:04:20 +00:00
|
|
|
|
2022-11-30 21:34:52 +00:00
|
|
|
dcPage::check(dcCore::app()->auth->makePermissions([
|
|
|
|
dcAuth::PERMISSION_ADMIN,
|
|
|
|
]));
|
2021-09-02 22:04:20 +00:00
|
|
|
|
2022-11-18 20:24:30 +00:00
|
|
|
$super = dcCore::app()->auth->isSuperAdmin() && !empty($_REQUEST['super']);
|
2021-09-03 19:08:44 +00:00
|
|
|
|
|
|
|
if ($super) {
|
2022-11-18 20:24:30 +00:00
|
|
|
dcCore::app()->activityReport->setGlobal();
|
2021-09-02 22:04:20 +00:00
|
|
|
}
|
|
|
|
|
2022-11-18 20:24:30 +00:00
|
|
|
$logs = dcCore::app()->activityReport->getLogs([]);
|
2021-09-03 19:08:44 +00:00
|
|
|
|
|
|
|
if ($super) {
|
|
|
|
$breadcrumb = [
|
2022-11-18 20:24:30 +00:00
|
|
|
__('Current blog') => dcCore::app()->adminurl->get('admin.plugin.activityReport', ['super' => 0]),
|
|
|
|
'<span class="page-title">' . __('All blogs') . '</span>' => '',
|
2021-09-03 19:08:44 +00:00
|
|
|
];
|
|
|
|
} else {
|
|
|
|
$breadcrumb = ['<span class="page-title">' . __('Current blog') . '</span>' => ''];
|
2022-11-18 20:24:30 +00:00
|
|
|
if (dcCore::app()->auth->isSuperAdmin()) {
|
|
|
|
$breadcrumb[__('All blogs')] = dcCore::app()->adminurl->get('admin.plugin.activityReport', ['super' => 1]);
|
2021-09-03 19:08:44 +00:00
|
|
|
}
|
2021-09-02 22:04:20 +00:00
|
|
|
}
|
2021-09-03 19:08:44 +00:00
|
|
|
|
|
|
|
echo '<html><head><title>' . __('Activity report') . '</title></head><body>' .
|
2022-11-18 20:24:30 +00:00
|
|
|
dcPage::breadcrumb(array_merge([__('Activity report') => '', __('Logs') => ''], $breadcrumb), ['hl' => false]) .
|
2021-09-03 19:08:44 +00:00
|
|
|
dcPage::notices();
|
|
|
|
|
|
|
|
if ($logs->isEmpty()) {
|
2022-11-18 20:24:30 +00:00
|
|
|
echo '<p>' . __('No log') . '</p>';
|
2021-09-03 19:08:44 +00:00
|
|
|
} else {
|
|
|
|
echo '
|
|
|
|
<div class="table-outer"><table><thead>
|
|
|
|
<tr>
|
|
|
|
<th>' . __('Action') . '</th>
|
|
|
|
<th>' . __('Message') . '</th>
|
|
|
|
<th>' . __('Date') . '</th>';
|
|
|
|
if ($super) {
|
2022-11-18 20:24:30 +00:00
|
|
|
echo '<th>' . __('Blog') . '</th>';
|
2021-09-03 19:08:44 +00:00
|
|
|
}
|
|
|
|
echo '</tr></thead><tbody>';
|
|
|
|
|
2022-11-18 20:24:30 +00:00
|
|
|
while ($logs->fetch()) {
|
|
|
|
$action = dcCore::app()->activityReport->getGroups($logs->activity_group, $logs->activity_action);
|
2021-09-03 19:08:44 +00:00
|
|
|
|
|
|
|
if (empty($action)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-11-18 20:24:30 +00:00
|
|
|
$off = $super && $logs->activity_blog_status == 1 ? ' offline' : '';
|
2021-09-03 19:08:44 +00:00
|
|
|
$date = dt::str(
|
2022-11-18 20:24:30 +00:00
|
|
|
dcCore::app()->blog->settings->system->date_format . ', ' . dcCore::app()->blog->settings->system->time_format,
|
2021-09-03 19:08:44 +00:00
|
|
|
strtotime($logs->activity_dt),
|
2022-11-18 20:24:30 +00:00
|
|
|
dcCore::app()->auth->getInfo('user_tz')
|
2021-09-03 19:08:44 +00:00
|
|
|
);
|
2022-11-18 20:24:30 +00:00
|
|
|
$msg = vsprintf(__($action['msg']), dcCore::app()->activityReport->decode($logs->activity_logs));
|
2021-09-03 21:34:18 +00:00
|
|
|
|
2021-09-03 19:08:44 +00:00
|
|
|
echo '
|
|
|
|
<tr class="line' . $off . '">
|
|
|
|
<td class="nowrap">' . __($action['title']) . '</td>
|
|
|
|
<td class="maximal">' . $msg . '</td>
|
|
|
|
<td class="nowrap">' . $date . '</td>';
|
|
|
|
if ($super) {
|
|
|
|
echo '<td class="nowrap">' . $logs->blog_id . '</td>';
|
|
|
|
}
|
|
|
|
echo '</tr>';
|
|
|
|
}
|
|
|
|
echo '</tbody></table></div>';
|
|
|
|
}
|
2022-11-18 20:24:30 +00:00
|
|
|
dcCore::app()->activityReport->unsetGlobal();
|
2021-09-03 19:08:44 +00:00
|
|
|
|
2022-11-18 20:24:30 +00:00
|
|
|
echo '</body></html>';
|