move logs from unnecessary file and class

master
Jean-Christian Paul Denis 2021-09-03 21:08:44 +02:00
parent dd918455b8
commit 1a8189c759
3 changed files with 64 additions and 123 deletions

View File

@ -18,7 +18,6 @@ if (!defined('DC_RC_PATH')) {
$d = dirname(__FILE__) . '/inc/';
$__autoload['activityReport'] = $d . 'class.activity.report.php';
$__autoload['activityReportBehaviors'] = $d . 'class.activity.report.behaviors.php';
$__autoload['activityReportLib'] = $d . 'lib.activity.report.index.php';
try {
$core->activityReport = new activityReport($core);

View File

@ -1,99 +0,0 @@
<?php
/**
* @brief activityReport, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')){return;}
class activityReportLib
{
public static function logTab($core,$title,$global=false)
{
$O =& $core->activityReport;
if ($global)
{
$O->setGlobal();
$t = 'super';
}
else
{
$t = 'blog';
}
$params = array();
$logs = $O->getLogs($params);
?>
<div class="multi-part" id="<?php echo $t; ?>_logs" title="<?php echo $title; ?>">
<?php
if ($logs->isEmpty())
{
echo '<p>'.__('No log').'</p>';
}
else
{
?>
<table>
<thead>
<tr>
<th><?php echo __('Action'); ?></th>
<th><?php echo __('Message'); ?></th>
<th><?php echo __('Date'); ?></th>
<?php if ($global) { ?>
<th><?php echo __('Blog'); ?></th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
while($logs->fetch())
{
$off = $global && $logs->activity_blog_status == 1 ?
' offline' : '';
$date = dt::str(
$core->blog->settings->system->date_format.', '.$core->blog->settings->system->time_format,
strtotime($logs->activity_dt),
$core->auth->getInfo('user_tz')
);
$action = $O->getGroups($logs->activity_group,$logs->activity_action);
if (empty($action)) continue;
$msg = vsprintf(__($action['msg']),$O->decode($logs->activity_logs));
?>
<tr class="line<?php echo $off; ?>">
<td class="nowrap"><?php echo __($action['title']); ?></td>
<td class="maximal"><?php echo $msg; ?></td>
<td class="nowrap"><?php echo $date; ?></td>
<?php if ($global) { ?>
<td class="nowrap"><?php echo $logs->blog_id; ?></td>
<?php } ?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
?>
</div>
<?php
$O->unsetGlobal();
}
}

View File

@ -21,31 +21,72 @@ if (!defined('ACTIVITY_REPORT')) {
dcPage::check('admin');
require_once dirname(__FILE__) . '/inc/lib.activity.report.index.php';
$report =& $core->activityReport;
$super = $core->auth->isSuperAdmin() && !empty($_REQUEST['super']);
$tab = $_REQUEST['tab'] ?? 'blog_settings';
$section = $_REQUEST['section'] ?? '';
if ($super) {
$report->setGlobal();
}
$logs = $report->getLogs([]);
if ($super) {
$breadcrumb = [
__('Current blog') => $core->adminurl->get('admin.plugin.activityReport', ['super' => 0]),
'<span class="page-title">' . __('All blogs') . '</span>' => ''
];
} else {
$breadcrumb = ['<span class="page-title">' . __('Current blog') . '</span>' => ''];
if ($core->auth->isSuperAdmin()) {
$breadcrumb[__('All blogs')] = $core->adminurl->get('admin.plugin.activityReport', ['super' => 1]);
}
}
echo '<html><head><title>' . __('Activity report') . '</title></head><body>' .
dcPage::breadcrumb(array_merge([__('Activity report') => '', __('Logs') => ''], $breadcrumb),['hl' => false]) .
dcPage::notices();
if ($logs->isEmpty()) {
echo '<p>'.__('No log').'</p>';
} else {
echo '
<div class="table-outer"><table><thead>
<tr>
<th>' . __('Action') . '</th>
<th>' . __('Message') . '</th>
<th>' . __('Date') . '</th>';
if ($super) {
echo '<th>' . __('Blog') .'</th>';
}
echo '</tr></thead><tbody>';
while($logs->fetch()) {
$action = $report->getGroups($logs->activity_group, $logs->activity_action);
if (empty($action)) {
continue;
}
$off = $super && $logs->activity_blog_status == 1 ? ' offline' : '';
$date = dt::str(
$core->blog->settings->system->date_format . ', ' . $core->blog->settings->system->time_format,
strtotime($logs->activity_dt),
$core->auth->getInfo('user_tz')
);
$msg = vsprintf(__($action['msg']), $report->decode($logs->activity_logs));
echo '
<html><head><title>'. __('Activity report') . '</title>' .
dcPage::jsLoad('js/_posts_list.js') .
dcPage::jsToolBar() .
dcPage::jsPageTabs($tab) .
dcPage::jsLoad('index.php?pf=activityReport/js/main.js') .
'<script type="text/javascript">'."\n//<![CDATA[\n" .
dcPage::jsVar('jcToolsBox.prototype.text_wait',__('Please wait')) .
dcPage::jsVar('jcToolsBox.prototype.section',$section) .
"\n//]]>\n</script>\n" . '
</head><body>
<h2>' . html::escapeHTML($core->blog->name) . ' &rsaquo; ' . __('Activity report') . '</h2>';
if (!activityReport::hasMailer()) {
echo '<p class="error">' . __('This server has no mail function, activityReport not send email report.') . '</p>';
<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>';
}
activityReportLib::logTab($core, __('Logs'));
if ($core->auth->isSuperAdmin()) {
activityReportLib::logTab($core, __('Super logs'), true);
echo '</tr>';
}
echo '</tbody></table></div>';
}
$report->unsetGlobal();
echo '</body></html>';