fix and enhance dashboard content
This commit is contained in:
parent
9386b1b4cd
commit
54747275eb
141
_admin.php
141
_admin.php
@ -18,69 +18,120 @@ if (!defined('ACTIVITY_REPORT')) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Plugin menu
|
|
||||||
$_menu['Plugins']->addItem(
|
$_menu['Plugins']->addItem(
|
||||||
__('Activity report'),
|
__('Activity report'),
|
||||||
$core->adminurl->get('admin.plugin.activityReport'),
|
$core->adminurl->get('admin.plugin.activityReport'),
|
||||||
dcPage::getPF('activityReport/icon.png'),
|
dcPage::getPF('activityReport/icon.png'),
|
||||||
preg_match('/' . preg_quote($core->adminurl->get('admin.plugin.activityReport')) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
preg_match(
|
||||||
|
'/' . preg_quote($core->adminurl->get('admin.plugin.activityReport')) . '(&.*)?$/',
|
||||||
|
$_SERVER['REQUEST_URI']
|
||||||
|
),
|
||||||
$core->auth->check('admin',$core->blog->id)
|
$core->auth->check('admin',$core->blog->id)
|
||||||
);
|
);
|
||||||
|
|
||||||
# Dashboarditems
|
$core->addBehavior('adminDashboardOptionsForm', ['activityReportAdmin', 'adminDashboardOptionsForm']);
|
||||||
if ($core->activityReport->getSetting('dashboardItem')) {
|
$core->addBehavior('adminAfterDashboardOptionsUpdate', ['activityReportAdmin', 'adminAfterDashboardOptionsUpdate']);
|
||||||
$core->addBehavior('adminDashboardHeaders', ['activityReportAdmin', 'dashboardHeaders']);
|
|
||||||
$core->addBehavior('adminDashboardItems', ['activityReportAdmin', 'dashboardItems']);
|
|
||||||
}
|
|
||||||
|
|
||||||
class activityReportAdmin
|
class activityReportAdmin
|
||||||
{
|
{
|
||||||
/**
|
public static function adminDashboardContents(dcCore $core, $items)
|
||||||
* Add CSS to dashboardHeaders for items
|
|
||||||
*/
|
|
||||||
public static function dashboardHeaders()
|
|
||||||
{
|
{
|
||||||
return dcPage::jsLoad('index.php?pf=activityReport/style.css');
|
$core->auth->user_prefs->addWorkspace('activityReport');
|
||||||
|
$limit = abs((integer) $core->auth->user_prefs->activityReport->dashboard_item);
|
||||||
|
if (!$limit) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$p = [
|
||||||
|
'limit' => $limit,
|
||||||
|
'order' => 'activity_dt DESC',
|
||||||
|
'sql' => $core->activityReport->requests2params($core->activityReport->getSetting('requests'))
|
||||||
|
];
|
||||||
|
$lines = [];
|
||||||
|
$rs = $core->activityReport->getLogs($p);
|
||||||
|
if ($rs->isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$groups = $core->activityReport->getGroups();
|
||||||
|
while($rs->fetch()) {
|
||||||
|
$group = $rs->activity_group;
|
||||||
|
|
||||||
|
if (!isset($groups[$group])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$lines[] =
|
||||||
|
'<dt title="' . __($groups[$group]['title']) . '">' .
|
||||||
|
'<strong>' . __($groups[$group]['actions'][$rs->activity_action]['title']) . '</strong>' .
|
||||||
|
'<br />' . dt::str(
|
||||||
|
$core->blog->settings->system->date_format . ', ' . $core->blog->settings->system->time_format,
|
||||||
|
strtotime($rs->activity_dt),
|
||||||
|
$core->auth->getInfo('user_tz')
|
||||||
|
) . '<dt>' .
|
||||||
|
'<dd><p>' .
|
||||||
|
'<em>' .vsprintf(
|
||||||
|
__($groups[$group]['actions'][$rs->activity_action]['msg']),
|
||||||
|
$core->activityReport->decode($rs->activity_logs)
|
||||||
|
) . '</em></p></dd>';
|
||||||
|
}
|
||||||
|
if (empty($lines)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$items[] = new ArrayObject([
|
||||||
|
'<div id="activity-report-logs" class="box medium">' .
|
||||||
|
'<h3>' . __('Activity report') . '</h3>' .
|
||||||
|
'<dl id="reports">' . implode('', $lines) . '</dl>' .
|
||||||
|
'<p><a href="'.$core->adminurl->get('admin.plugin.activityReport') .'">' .
|
||||||
|
__('View all logs') . '</a></p>' .
|
||||||
|
'</div>'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static function adminDashboardOptionsForm(dcCore $core)
|
||||||
* Add report to dashboardItems
|
|
||||||
*/
|
|
||||||
public static function dashboardItems(dcCore $core, $__dashboard_items)
|
|
||||||
{
|
{
|
||||||
$r = $core->activityReport->getSetting('requests');
|
$core->auth->user_prefs->addWorkspace('activityReport');
|
||||||
$g = $core->activityReport->getGroups();
|
|
||||||
|
|
||||||
$p = array();
|
echo
|
||||||
$p['limit'] = 20;
|
'<div class="fieldset">' .
|
||||||
$p['order'] = 'activity_dt DESC';
|
'<h4>' . __('Activity report') . '</h4>' .
|
||||||
$p['sql'] = $core->activityReport->requests2params($r);
|
'<p><label for="activityReport_dashboard_item">' .
|
||||||
|
__('Number of activities to show on dashboard:') . '</label>' .
|
||||||
|
form::combo(
|
||||||
|
'activityReport_dashboard_item',
|
||||||
|
self::comboList(),
|
||||||
|
self::comboList($core->auth->user_prefs->activityReport->dashboard_item)
|
||||||
|
) . '</p>' .
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
$res = '';
|
public static function adminAfterDashboardOptionsUpdate($user_id = null)
|
||||||
$rs = $core->activityReport->getLogs($p);
|
{
|
||||||
if (!$rs->isEmpty()) {
|
global $core;
|
||||||
while($rs->fetch()) {
|
|
||||||
$group = $rs->activity_group;
|
|
||||||
|
|
||||||
if (!isset($g[$group])) {
|
if (is_null($user_id)) {
|
||||||
continue;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
$res .=
|
|
||||||
'<dd><p title="' . __($g[$group]['title']) . '"><strong>' .
|
|
||||||
__($g[$group]['actions'][$rs->activity_action]['title']) .
|
|
||||||
'</p></strong><em>' .
|
|
||||||
vsprintf(
|
|
||||||
__($g[$group]['actions'][$rs->activity_action]['msg']),
|
|
||||||
$core->activityReport->decode($rs->activity_logs)
|
|
||||||
) .
|
|
||||||
'</em></dd>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!empty($res)) {
|
|
||||||
$__dashboard_items[1][] =
|
$core->auth->user_prefs->addWorkspace('activityReport');
|
||||||
'<h3>' . __('Activity report') . '</h3>' .
|
$core->auth->user_prefs->activityReport->put(
|
||||||
'<dl id="report">' . $res . '</dl>';
|
'dashboard_item',
|
||||||
|
self::comboList(@$_POST['activityReport_dashboard_item']),
|
||||||
|
'integer'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function comboList($q = true)
|
||||||
|
{
|
||||||
|
$l = [
|
||||||
|
__('Do not show activity report') => 0,
|
||||||
|
5 => 5,
|
||||||
|
10 => 10,
|
||||||
|
15 => 15,
|
||||||
|
20 => 20,
|
||||||
|
50 => 50,
|
||||||
|
100 => 100
|
||||||
|
];
|
||||||
|
if (true === $q) {
|
||||||
|
return $l;
|
||||||
}
|
}
|
||||||
|
return in_array($q, $l) ? $l[$q] : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
11
_config.php
11
_config.php
@ -51,7 +51,6 @@ $combo_format = [
|
|||||||
if (!empty($_POST['save'])) {
|
if (!empty($_POST['save'])) {
|
||||||
try {
|
try {
|
||||||
$report->setSetting('active', !empty($_POST['active']));
|
$report->setSetting('active', !empty($_POST['active']));
|
||||||
$report->setSetting('dashboardItem', !empty($_POST['dashboardItem']));
|
|
||||||
if (in_array($_POST['interval'], $combo_interval)) {
|
if (in_array($_POST['interval'], $combo_interval)) {
|
||||||
$report->setSetting('interval', (integer) $_POST['interval']);
|
$report->setSetting('interval', (integer) $_POST['interval']);
|
||||||
}
|
}
|
||||||
@ -114,20 +113,14 @@ if (activityReport::hasMailer()) {
|
|||||||
echo '
|
echo '
|
||||||
<div class="fieldset two-cols" id="settings"><h4>' . __('Settings') . '</h4>
|
<div class="fieldset two-cols" id="settings"><h4>' . __('Settings') . '</h4>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
|
||||||
<p><label class="classic" for="active">' .
|
<p><label class="classic" for="active">' .
|
||||||
form::checkbox('active', '1', $report->getSetting('active')).' '.
|
form::checkbox('active', '1', $report->getSetting('active')).' '.
|
||||||
($super ?
|
($super ?
|
||||||
__('Enable super administrator report') :
|
__('Enable super administrator report') :
|
||||||
__('Enable report on this blog')
|
__('Enable report on this blog')
|
||||||
) . '</label></p>';
|
) . '</label></p>
|
||||||
|
|
||||||
if (!$super) {
|
|
||||||
echo
|
|
||||||
'<p><label class="classic" for="dashboardItem">' .
|
|
||||||
form::checkbox('dashboardItem', 1, $report->getSetting('dashboardItem')).' '.
|
|
||||||
__('Add activity report on dashboard items') . '</label></p>';
|
|
||||||
}
|
|
||||||
echo '
|
|
||||||
<p><label for="obselete">' . __('Automatic cleaning of old logs:') . '</label>' .
|
<p><label for="obselete">' . __('Automatic cleaning of old logs:') . '</label>' .
|
||||||
form::combo('obsolete', $combo_obselete, $report->getSetting('obsolete')) . '</p>
|
form::combo('obsolete', $combo_obselete, $report->getSetting('obsolete')) . '</p>
|
||||||
|
|
||||||
|
@ -92,7 +92,6 @@ class activityReport
|
|||||||
$settings = [
|
$settings = [
|
||||||
'active' => false,
|
'active' => false,
|
||||||
'obsolete' => 2419200,
|
'obsolete' => 2419200,
|
||||||
'dashboardItem' => false,
|
|
||||||
'interval' => 86400,
|
'interval' => 86400,
|
||||||
'lastreport' => 0,
|
'lastreport' => 0,
|
||||||
'mailinglist' => [],
|
'mailinglist' => [],
|
||||||
|
Loading…
Reference in New Issue
Block a user