First pass to clean up code

master
Jean-Christian Paul Denis 2021-09-03 00:18:08 +02:00
parent d843671ddb
commit 55136bb6d7
16 changed files with 1794 additions and 1782 deletions

View File

@ -1,14 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of activityReport, a plugin for Dotclear 2. * @brief activityReport, a plugin for Dotclear 2
# *
# Copyright (c) 2009-2010 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')){return;} if (!defined('DC_CONTEXT_ADMIN')){return;}
@ -16,78 +17,77 @@ if (!defined('ACTIVITY_REPORT')){return;}
# Plugin menu # Plugin menu
$_menu['Plugins']->addItem( $_menu['Plugins']->addItem(
__('Activity report'), __('Activity report'),
'plugin.php?p=activityReport','index.php?pf=activityReport/icon.png', 'plugin.php?p=activityReport','index.php?pf=activityReport/icon.png',
preg_match('/plugin.php\?p=activityReport(&.*)?$/', preg_match('/plugin.php\?p=activityReport(&.*)?$/',
$_SERVER['REQUEST_URI']), $_SERVER['REQUEST_URI']),
$core->auth->check('admin',$core->blog->id) $core->auth->check('admin',$core->blog->id)
); );
# Dashboarditems # Dashboarditems
if ($core->activityReport->getSetting('dashboardItem')) if ($core->activityReport->getSetting('dashboardItem'))
{ {
$core->addBehavior( $core->addBehavior(
'adminDashboardHeaders', 'adminDashboardHeaders',
array('activityReportAdmin','dashboardHeaders') array('activityReportAdmin','dashboardHeaders')
); );
$core->addBehavior( $core->addBehavior(
'adminDashboardItems', 'adminDashboardItems',
array('activityReportAdmin','dashboardItems') array('activityReportAdmin','dashboardItems')
); );
} }
class activityReportAdmin class activityReportAdmin
{ {
# Add CSS to dashboardHeaders for items # Add CSS to dashboardHeaders for items
public static function dashboardHeaders() public static function dashboardHeaders()
{ {
return return
"\n<!-- CSS for activityReport --> \n". "\n<!-- CSS for activityReport --> \n".
"<style type=\"text/css\"> \n". "<style type=\"text/css\"> \n".
"#dashboard-items #report dt { font-weight: bold; margin: 0 0 0.4em 0; } \n". "#dashboard-items #report dt { font-weight: bold; margin: 0 0 0.4em 0; } \n".
"#dashboard-items #report dd { font-size: 0.9em; margin: 0 0 1em 0; } \n". "#dashboard-items #report dd { font-size: 0.9em; margin: 0 0 1em 0; } \n".
"#dashboard-items #report dd p { margin: 0.2em 0 0 0; } \n". "#dashboard-items #report dd p { margin: 0.2em 0 0 0; } \n".
"</style> \n"; "</style> \n";
} }
# Add report to dashboardItems # Add report to dashboardItems
public static function dashboardItems($core, $__dashboard_items) public static function dashboardItems($core, $__dashboard_items)
{ {
$r = $core->activityReport->getSetting('requests'); $r = $core->activityReport->getSetting('requests');
$g = $core->activityReport->getGroups(); $g = $core->activityReport->getGroups();
$p = array(); $p = array();
$p['limit'] = 20; $p['limit'] = 20;
$p['order'] = 'activity_dt DESC'; $p['order'] = 'activity_dt DESC';
$p['sql'] = $core->activityReport->requests2params($r); $p['sql'] = $core->activityReport->requests2params($r);
$res = ''; $res = '';
$rs = $core->activityReport->getLogs($p); $rs = $core->activityReport->getLogs($p);
if (!$rs->isEmpty()) if (!$rs->isEmpty())
{ {
while($rs->fetch()) while($rs->fetch())
{ {
$group = $rs->activity_group; $group = $rs->activity_group;
if (!isset($g[$group])) continue; if (!isset($g[$group])) continue;
$res .= $res .=
'<dd><p title="'.__($g[$group]['title']).'"><strong>'. '<dd><p title="'.__($g[$group]['title']).'"><strong>'.
__($g[$group]['actions'][$rs->activity_action]['title']). __($g[$group]['actions'][$rs->activity_action]['title']).
'</p></strong><em>'. '</p></strong><em>'.
vsprintf( vsprintf(
__($g[$group]['actions'][$rs->activity_action]['msg']), __($g[$group]['actions'][$rs->activity_action]['msg']),
$core->activityReport->decode($rs->activity_logs) $core->activityReport->decode($rs->activity_logs)
). ).
'</em></dd>'; '</em></dd>';
} }
} }
if (!empty($res)) if (!empty($res))
{ {
$__dashboard_items[1][] = $__dashboard_items[1][] =
'<h3>'.__('Activity report').'</h3>'. '<h3>'.__('Activity report').'</h3>'.
'<dl id="report">'.$res.'</dl>'; '<dl id="report">'.$res.'</dl>';
} }
} }
} }
?>

View File

@ -1,24 +1,32 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of activityReport, a plugin for Dotclear 2. * @brief activityReport, a plugin for Dotclear 2
# *
# Copyright (c) 2009-2010 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')) {
return null;
}
$this->registerModule( $this->registerModule(
/* Name */ "Activity report", 'Activity report',
/* Description*/ "Receive your blog activity by email, feed, or on dashboard", 'Receive your blog activity by email, feed, or on dashboard',
/* Author */ "JC Denis", 'Jean-Christian Denis and contributors',
/* Version */ '1.0.1', '1.0.1',
/* Permissions */ 'admin', [
/* Priority */ -1000000 'requires' => [['core', '2.19']],
'permissions' => 'admin',
'priority' => -1000000,
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/activityReport',
'details' => 'http://plugins.dotaddict.org/dc2/details/activityReport',
'repository' => 'https://raw.githubusercontent.com/JcDenis/activityReport/master/dcstore.xml'
]
); );
/* date */ #20100608
?>

View File

@ -1,14 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of activityReport, a plugin for Dotclear 2. * @brief activityReport, a plugin for Dotclear 2
# *
# Copyright (c) 2009-2010 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')){return;} if (!defined('DC_CONTEXT_ADMIN')){return;}
@ -19,53 +20,52 @@ if (version_compare($old_version,$new_version,'>=')) {return;}
try try
{ {
# Check DC version # Check DC version
if (version_compare(DC_VERSION,'2.2-beta','<')) if (version_compare(DC_VERSION,'2.2-beta','<'))
{ {
throw new Exception('translater requires Dotclear 2.2'); throw new Exception('translater requires Dotclear 2.2');
} }
# Table # Table
$s = new dbStruct($core->con,$core->prefix); $s = new dbStruct($core->con,$core->prefix);
$s->activity $s->activity
->activity_id ('bigint',0,false) ->activity_id ('bigint',0,false)
->activity_type ('varchar',32,false,"'activityReport'") ->activity_type ('varchar',32,false,"'activityReport'")
->blog_id ('varchar',32,true) ->blog_id ('varchar',32,true)
->activity_group('varchar',32,false) ->activity_group('varchar',32,false)
->activity_action ('varchar',32,false) ->activity_action ('varchar',32,false)
->activity_logs ('text',0,false) ->activity_logs ('text',0,false)
->activity_dt ('timestamp',0,false,'now()') ->activity_dt ('timestamp',0,false,'now()')
->activity_blog_status ('smallint',0,false,0) ->activity_blog_status ('smallint',0,false,0)
->activity_super_status ('smallint',0,false,0) ->activity_super_status ('smallint',0,false,0)
->primary('pk_activity','activity_id') ->primary('pk_activity','activity_id')
->index('idx_activity_type','btree','activity_type') ->index('idx_activity_type','btree','activity_type')
->index('idx_activity_blog_id','btree','blog_id') ->index('idx_activity_blog_id','btree','blog_id')
->index('idx_activity_action','btree','activity_group','activity_action') ->index('idx_activity_action','btree','activity_group','activity_action')
->index('idx_activity_blog_status','btree','activity_blog_status') ->index('idx_activity_blog_status','btree','activity_blog_status')
->index('idx_activity_super_status','btree','activity_super_status'); ->index('idx_activity_super_status','btree','activity_super_status');
$s->activity_setting $s->activity_setting
->setting_id('varchar',64,false) ->setting_id('varchar',64,false)
->blog_id ('varchar',32,true) ->blog_id ('varchar',32,true)
->setting_type('varchar',32,false) ->setting_type('varchar',32,false)
->setting_value('text',0,false) ->setting_value('text',0,false)
->unique('uk_activity_setting','setting_id','blog_id','setting_type') ->unique('uk_activity_setting','setting_id','blog_id','setting_type')
->index('idx_activity_setting_blog_id','btree','blog_id') ->index('idx_activity_setting_blog_id','btree','blog_id')
->index('idx_activity_setting_type','btree','setting_type'); ->index('idx_activity_setting_type','btree','setting_type');
$si = new dbStruct($core->con,$core->prefix); $si = new dbStruct($core->con,$core->prefix);
$changes = $si->synchronize($s); $changes = $si->synchronize($s);
# Version # Version
$core->setVersion('activityReport',$new_version); $core->setVersion('activityReport',$new_version);
return true; return true;
} }
catch (Exception $e) catch (Exception $e)
{ {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
return false; return false;
?>

View File

@ -1,38 +1,38 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of activityReport, a plugin for Dotclear 2. * @brief activityReport, a plugin for Dotclear 2
# *
# Copyright (c) 2009-2010 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')){return;}
global $__autoload, $core; global $__autoload, $core;
$__autoload['activityReport'] = $__autoload['activityReport'] =
dirname(__FILE__).'/inc/class.activity.report.php'; dirname(__FILE__).'/inc/class.activity.report.php';
try try
{ {
$core->activityReport = new activityReport($core); $core->activityReport = new activityReport($core);
$core->url->register( $core->url->register(
'activityReport', 'activityReport',
'reports', 'reports',
'^reports/((atom|rss2)/(.+))$', '^reports/((atom|rss2)/(.+))$',
array('activityReportPublicUrl','feed') array('activityReportPublicUrl','feed')
); );
define('ACTIVITY_REPORT',true); define('ACTIVITY_REPORT',true);
require_once dirname(__FILE__).'/inc/class.activity.report.behaviors.php'; require_once dirname(__FILE__).'/inc/class.activity.report.behaviors.php';
} }
catch (Exception $e) { catch (Exception $e) {
//throw new Exception('Failed to launch activityReport'); //throw new Exception('Failed to launch activityReport');
} }
?>

View File

@ -1,14 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of activityReport, a plugin for Dotclear 2. * @brief activityReport, a plugin for Dotclear 2
# *
# Copyright (c) 2009-2010 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')){return;}
@ -23,152 +24,151 @@ $core->tpl->addValue('activityReportContent',array('activityReportPublicTpl','ac
class activityReportPublicUrl extends dcUrlHandlers class activityReportPublicUrl extends dcUrlHandlers
{ {
public static function feed($args) public static function feed($args)
{ {
global $core, $_ctx; global $core, $_ctx;
if (!preg_match('/^(atom|rss2)\/(.+)$/',$args,$m)) if (!preg_match('/^(atom|rss2)\/(.+)$/',$args,$m))
{ {
self::p404(); self::p404();
return; return;
} }
if (!defined('ACTIVITY_REPORT')){ if (!defined('ACTIVITY_REPORT')){
self::p404(); self::p404();
return; return;
} }
if (!$core->activityReport->getSetting('active')) if (!$core->activityReport->getSetting('active'))
{ {
self::p404(); self::p404();
return; return;
} }
$mime = $m[1] == 'atom' ? 'application/atom+xml' : 'application/xml'; $mime = $m[1] == 'atom' ? 'application/atom+xml' : 'application/xml';
if (false === $core->activityReport->checkUserCode($m[2])) { if (false === $core->activityReport->checkUserCode($m[2])) {
self::p404(); self::p404();
return; return;
} }
$_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_feed; $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_feed;
$_ctx->short_feed_items = $core->blog->settings->system->short_feed_items; $_ctx->short_feed_items = $core->blog->settings->system->short_feed_items;
header('X-Robots-Tag: '.context::robotsPolicy($core->blog->settings->system->robots_policy,'')); header('X-Robots-Tag: '.context::robotsPolicy($core->blog->settings->system->robots_policy,''));
self::serveDocument('activityreport-'.$m[1].'.xml',$mime); self::serveDocument('activityreport-'.$m[1].'.xml',$mime);
return; return;
} }
} }
class activityReportPublicTpl class activityReportPublicTpl
{ {
public static function activityReports($attr,$content) public static function activityReports($attr,$content)
{ {
$lastn = 0; $lastn = 0;
if (isset($attr['lastn'])) { if (isset($attr['lastn'])) {
$lastn = abs((integer) $attr['lastn'])+0; $lastn = abs((integer) $attr['lastn'])+0;
} }
$p = 'if (!isset($_page_number)) { $_page_number = 1; }'."\n\$params = array();\n"; $p = 'if (!isset($_page_number)) { $_page_number = 1; }'."\n\$params = array();\n";
if ($lastn > 0) { if ($lastn > 0) {
$p .= "\$params['limit'] = ".$lastn.";\n"; $p .= "\$params['limit'] = ".$lastn.";\n";
} else { } else {
$p .= "\$params['limit'] = \$_ctx->nb_entry_per_page;\n"; $p .= "\$params['limit'] = \$_ctx->nb_entry_per_page;\n";
} }
if (!isset($attr['ignore_pagination']) || $attr['ignore_pagination'] == "0") { if (!isset($attr['ignore_pagination']) || $attr['ignore_pagination'] == "0") {
$p .= "\$params['limit'] = array(((\$_page_number-1)*\$params['limit']),\$params['limit']);\n"; $p .= "\$params['limit'] = array(((\$_page_number-1)*\$params['limit']),\$params['limit']);\n";
} else { } else {
$p .= "\$params['limit'] = array(0, \$params['limit']);\n"; $p .= "\$params['limit'] = array(0, \$params['limit']);\n";
} }
$res = $res =
"<?php \n". "<?php \n".
$p. $p.
'$_ctx->activityreport_params = $params; '."\n". '$_ctx->activityreport_params = $params; '."\n".
'$_ctx->activityreports = $core->activityReport->getLogs($params); unset($params); '."\n". '$_ctx->activityreports = $core->activityReport->getLogs($params); unset($params); '."\n".
'while ($_ctx->activityreports->fetch()) : ?>'.$content.'<?php endwhile; '. 'while ($_ctx->activityreports->fetch()) : ?>'.$content.'<?php endwhile; '.
'$_ctx->activityreports = null; $_ctx->activityreport_params = null; '."\n". '$_ctx->activityreports = null; $_ctx->activityreport_params = null; '."\n".
"?>"; "?>";
return $res; return $res;
} }
public static function activityReportFeedID($attr) public static function activityReportFeedID($attr)
{ {
return return
'urn:md5:<?php echo md5($_ctx->activityreports->blog_id.'. 'urn:md5:<?php echo md5($_ctx->activityreports->blog_id.'.
'$_ctx->activityreports->activity_id.$_ctx->activityreports->activity_dt); '. '$_ctx->activityreports->activity_id.$_ctx->activityreports->activity_dt); '.
'?>'; '?>';
} }
public static function activityReportTitle($attr) public static function activityReportTitle($attr)
{ {
$f = $GLOBALS['core']->tpl->getFilters($attr); $f = $GLOBALS['core']->tpl->getFilters($attr);
return '<?php echo '.sprintf($f,'activityReportContext::parseTitle()').'; ?>'; return '<?php echo '.sprintf($f,'activityReportContext::parseTitle()').'; ?>';
} }
public static function activityReportContent($attr) public static function activityReportContent($attr)
{ {
$f = $GLOBALS['core']->tpl->getFilters($attr); $f = $GLOBALS['core']->tpl->getFilters($attr);
return '<?php echo '.sprintf($f,'activityReportContext::parseContent()').'; ?>'; return '<?php echo '.sprintf($f,'activityReportContext::parseContent()').'; ?>';
} }
public static function activityReportDate($attr) public static function activityReportDate($attr)
{ {
$format = ''; $format = '';
if (!empty($attr['format'])) { if (!empty($attr['format'])) {
$format = addslashes($attr['format']); $format = addslashes($attr['format']);
} }
$iso8601 = !empty($attr['iso8601']); $iso8601 = !empty($attr['iso8601']);
$rfc822 = !empty($attr['rfc822']); $rfc822 = !empty($attr['rfc822']);
$f = $GLOBALS['core']->tpl->getFilters($attr); $f = $GLOBALS['core']->tpl->getFilters($attr);
if ($rfc822) { if ($rfc822) {
return '<?php echo '.sprintf($f,"dt::rfc822(strtotime(\$_ctx->activityreports->activity_dt),\$core->blog->settings->system->blog_timezone)").'; ?>'; return '<?php echo '.sprintf($f,"dt::rfc822(strtotime(\$_ctx->activityreports->activity_dt),\$core->blog->settings->system->blog_timezone)").'; ?>';
} elseif ($iso8601) { } elseif ($iso8601) {
return '<?php echo '.sprintf($f,"dt::iso8601(strtotime(\$_ctx->activityreports->activity_dt),\$core->blog->settings->system->blog_timezone)").'; ?>'; return '<?php echo '.sprintf($f,"dt::iso8601(strtotime(\$_ctx->activityreports->activity_dt),\$core->blog->settings->system->blog_timezone)").'; ?>';
} elseif (!empty($format)) { } elseif (!empty($format)) {
return '<?php echo '.sprintf($f,"dt::dt2str('".$format."',\$_ctx->activityreports->activity_dt)").'; ?>'; return '<?php echo '.sprintf($f,"dt::dt2str('".$format."',\$_ctx->activityreports->activity_dt)").'; ?>';
} else { } else {
return '<?php echo '.sprintf($f,"dt::dt2str(\$core->blog->settings->system->date_format,\$_ctx->activityreports->activity_dt)").'; ?>'; return '<?php echo '.sprintf($f,"dt::dt2str(\$core->blog->settings->system->date_format,\$_ctx->activityreports->activity_dt)").'; ?>';
} }
} }
} }
class activityReportContext class activityReportContext
{ {
public static function parseTitle() public static function parseTitle()
{ {
global $core,$_ctx; global $core,$_ctx;
$groups = $core->activityReport->getGroups(); $groups = $core->activityReport->getGroups();
$group = $_ctx->activityreports->activity_group; $group = $_ctx->activityreports->activity_group;
$action = $_ctx->activityreports->activity_action; $action = $_ctx->activityreports->activity_action;
if (!empty($groups[$group]['actions'][$action]['title'])) { if (!empty($groups[$group]['actions'][$action]['title'])) {
return __($groups[$group]['actions'][$action]['title']); return __($groups[$group]['actions'][$action]['title']);
} }
return ''; return '';
} }
public static function parseContent() public static function parseContent()
{ {
global $core,$_ctx; global $core,$_ctx;
$groups = $core->activityReport->getGroups(); $groups = $core->activityReport->getGroups();
$group = $_ctx->activityreports->activity_group; $group = $_ctx->activityreports->activity_group;
$action = $_ctx->activityreports->activity_action; $action = $_ctx->activityreports->activity_action;
$logs = $_ctx->activityreports->activity_logs; $logs = $_ctx->activityreports->activity_logs;
$logs = $core->activityReport->decode($logs); $logs = $core->activityReport->decode($logs);
if (!empty($groups[$group]['actions'][$action]['msg'])) { if (!empty($groups[$group]['actions'][$action]['msg'])) {
$core->initWikiComment(); $core->initWikiComment();
return $core->wikiTransform(vsprintf(__($groups[$group]['actions'][$action]['msg']),$logs)); return $core->wikiTransform(vsprintf(__($groups[$group]['actions'][$action]['msg']),$logs));
} }
return ''; return '';
} }
} }
?>

View File

@ -1,56 +1,56 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of activityReport, a plugin for Dotclear 2. * @brief activityReport, a plugin for Dotclear 2
# *
# Copyright (c) 2009-2010 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')){return;} if (!defined('DC_CONTEXT_ADMIN')){return;}
$this->addUserAction( $this->addUserAction(
/* type */ 'tables', /* type */ 'tables',
/* action */ 'delete', /* action */ 'delete',
/* ns */ 'activity', /* ns */ 'activity',
/* description */ sprintf(__('delete %s table'),'"activity"') /* description */ sprintf(__('delete %s table'),'"activity"')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'tables', /* type */ 'tables',
/* action */ 'delete', /* action */ 'delete',
/* ns */ 'activity_setting', /* ns */ 'activity_setting',
/* description */ sprintf(__('delete %s table'),'"activity_setting"') /* description */ sprintf(__('delete %s table'),'"activity_setting"')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'plugins', /* type */ 'plugins',
/* action */ 'delete', /* action */ 'delete',
/* ns */ 'activityReport', /* ns */ 'activityReport',
/* description */ __('delete plugin files') /* description */ __('delete plugin files')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'versions', /* type */ 'versions',
/* action */ 'delete', /* action */ 'delete',
/* ns */ 'activityReport', /* ns */ 'activityReport',
/* description */ __('delete the version number') /* description */ __('delete the version number')
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'versions', /* type */ 'versions',
/* action */ 'delete', /* action */ 'delete',
/* ns */ 'activityReport', /* ns */ 'activityReport',
/* description */ sprintf(__('delete %s version number'),'activityReport') /* description */ sprintf(__('delete %s version number'),'activityReport')
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'plugins', /* type */ 'plugins',
/* action */ 'delete', /* action */ 'delete',
/* ns */ 'activityReport', /* ns */ 'activityReport',
/* description */ sprintf(__('delete %s plugin files'),'activityReport') /* description */ sprintf(__('delete %s plugin files'),'activityReport')
); );
?>

11
dcstore.xml 100644
View File

@ -0,0 +1,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="activityReport">
<name>Rapport d'activité</name>
<version>1.0.1</version>
<author>Jean-Christian Denis and contributors</author>
<desc>Receive your blog activity by email, feed, or on dashboard</desc>
<file>https://github.com/JcDenis/activityReport/releases/download/v1.0.1/plugin-activityReport.zip</file>
<da:details>http://plugins.dotaddict.org/dc2/details/activityReport</da:details>
<da:support>https://github.com/JcDenis/activityReport</da:support>
</module>
</modules>

View File

@ -1,14 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of activityReport, a plugin for Dotclear 2. * @brief activityReport, a plugin for Dotclear 2
# *
# Copyright (c) 2009-2010 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')){return;}
@ -19,12 +20,12 @@ if (!defined('ACTIVITY_REPORT')){return;}
$core->activityReport->addGroup('activityReport',__('ActivityReport messages')); $core->activityReport->addGroup('activityReport',__('ActivityReport messages'));
$core->activityReport->addAction( $core->activityReport->addAction(
'activityReport', 'activityReport',
'message', 'message',
__('Special messages'), __('Special messages'),
__('%s'), __('%s'),
'messageActivityReport', 'messageActivityReport',
array('activityReportBehaviors','messageActivityReport') array('activityReportBehaviors','messageActivityReport')
); );
/* Blog /* Blog
@ -35,25 +36,24 @@ $core->activityReport->addGroup('blog',__('Actions on blog'));
# from BEHAVIOR adminAfterBlogUpdate in admin/blog_pref.php # from BEHAVIOR adminAfterBlogUpdate in admin/blog_pref.php
$core->activityReport->addAction( $core->activityReport->addAction(
'blog', 'blog',
'update', 'update',
__('updating blog'), __('updating blog'),
__('Blog was updated by "%s"'), __('Blog was updated by "%s"'),
'adminAfterBlogUpdate', 'adminAfterBlogUpdate',
array('activityReportBehaviors','blogUpdate') array('activityReportBehaviors','blogUpdate')
); );
# from BEHAVIOR publicHeadContent in template # from BEHAVIOR publicHeadContent in template
$core->activityReport->addAction( $core->activityReport->addAction(
'blog', 'blog',
'p404', 'p404',
__('404 error'), __('404 error'),
__('New 404 error page at "%s"'), __('New 404 error page at "%s"'),
'publicHeadContent', 'publicHeadContent',
array('activityReportBehaviors','blogP404') array('activityReportBehaviors','blogP404')
); );
/* Post /* Post
-------------------------*/ -------------------------*/
$core->activityReport->addGroup('post',__('Actions on posts')); $core->activityReport->addGroup('post',__('Actions on posts'));
@ -62,60 +62,58 @@ $core->activityReport->addGroup('post',__('Actions on posts'));
# duplicate adminAfterPostCreate in admin/post.php # duplicate adminAfterPostCreate in admin/post.php
# duplicate adminAfterPostCreate in admin/services.php # duplicate adminAfterPostCreate in admin/services.php
$core->activityReport->addAction( $core->activityReport->addAction(
'post', 'post',
'create', 'create',
__('post creation'), __('post creation'),
__('A new post called "%s" was created by "%s" at %s'), __('A new post called "%s" was created by "%s" at %s'),
'adminAfterPostCreate', 'adminAfterPostCreate',
array('activityReportBehaviors','postCreate') array('activityReportBehaviors','postCreate')
); );
# Plugin contribute # Plugin contribute
# from BEHAVIOR publicAfterPostCreate in plugins/contribute/_public.php # from BEHAVIOR publicAfterPostCreate in plugins/contribute/_public.php
$core->activityReport->addAction( $core->activityReport->addAction(
'post', 'post',
'create', 'create',
__('post creation'), __('post creation'),
__('A new post called "%s" was created by "%s" at %s'), __('A new post called "%s" was created by "%s" at %s'),
'publicAfterPostCreate', 'publicAfterPostCreate',
array('activityReportBehaviors','postCreate') array('activityReportBehaviors','postCreate')
); );
# from BEHAVIOR coreAfterPostUpdate in inc/core/class.dc.blog.php (DC2.2) # from BEHAVIOR coreAfterPostUpdate in inc/core/class.dc.blog.php (DC2.2)
# duplicate adminAfterPostUpdate in admin/post.php # duplicate adminAfterPostUpdate in admin/post.php
$core->activityReport->addAction( $core->activityReport->addAction(
'post', 'post',
'update', 'update',
__('updating post'), __('updating post'),
__('Post called "%s" has been updated by "%s" at %s'), __('Post called "%s" has been updated by "%s" at %s'),
'adminAfterPostUpdate', 'adminAfterPostUpdate',
array('activityReportBehaviors','postUpdate') array('activityReportBehaviors','postUpdate')
); );
# from BEHAVIOR adminBeforePostDelete in admin/posts_actions.php # from BEHAVIOR adminBeforePostDelete in admin/posts_actions.php
# from BEHAVIOR adminBeforePostDelete in admin/post.php # from BEHAVIOR adminBeforePostDelete in admin/post.php
$core->activityReport->addAction( $core->activityReport->addAction(
'post', 'post',
'delete', 'delete',
__('post deletion'), __('post deletion'),
__('Post called "%s" has been deleted by "%s"'), __('Post called "%s" has been deleted by "%s"'),
'adminBeforePostDelete', 'adminBeforePostDelete',
array('activityReportBehaviors','postDelete') array('activityReportBehaviors','postDelete')
); );
# Wrong attempt on passworded enrty # Wrong attempt on passworded enrty
# from BEHAVIOR urlHandlerServeDocument in inc/public/lib.urlhandlers.php # from BEHAVIOR urlHandlerServeDocument in inc/public/lib.urlhandlers.php
$core->activityReport->addAction( $core->activityReport->addAction(
'post', 'post',
'protection', 'protection',
__('Post protection'), __('Post protection'),
__('An attempt failed on a passworded post with password "%s" at "%s"'), __('An attempt failed on a passworded post with password "%s" at "%s"'),
'urlHandlerServeDocument', 'urlHandlerServeDocument',
array('activityReportBehaviors','postPasswordAttempt') array('activityReportBehaviors','postPasswordAttempt')
); );
/* Comment /* Comment
-------------------------*/ -------------------------*/
$core->activityReport->addGroup('comment',__('Actions on comments')); $core->activityReport->addGroup('comment',__('Actions on comments'));
@ -124,23 +122,23 @@ $core->activityReport->addGroup('comment',__('Actions on comments'));
# duplicate adminAfterCommentCreate in admin/comment.php # duplicate adminAfterCommentCreate in admin/comment.php
# duplicate publicAfterCommentCreate in inc/public/lib.urlhandlers.php # duplicate publicAfterCommentCreate in inc/public/lib.urlhandlers.php
$core->activityReport->addAction( $core->activityReport->addAction(
'comment', 'comment',
'create', 'create',
__('comment creation'), __('comment creation'),
__('A new comment was created by "%s" on post "%s" at %s'), __('A new comment was created by "%s" on post "%s" at %s'),
'coreAfterCommentCreate', 'coreAfterCommentCreate',
array('activityReportBehaviors','commentCreate') array('activityReportBehaviors','commentCreate')
); );
# from BEHAVIOR coreAfterCommentUpdate in inc/core/class.dc.blog.php # from BEHAVIOR coreAfterCommentUpdate in inc/core/class.dc.blog.php
# duplicate adminAfterCommentUpdate in admin/comment.php # duplicate adminAfterCommentUpdate in admin/comment.php
$core->activityReport->addAction( $core->activityReport->addAction(
'comment', 'comment',
'update', 'update',
__('updating comment'), __('updating comment'),
__('Comment has been updated by "%s" at %s'), __('Comment has been updated by "%s" at %s'),
'coreAfterCommentUpdate', 'coreAfterCommentUpdate',
array('activityReportBehaviors','commentUpdate') array('activityReportBehaviors','commentUpdate')
); );
# Missing coreBeforeCommentDelete in inc/core/class.dc.blog.php # Missing coreBeforeCommentDelete in inc/core/class.dc.blog.php
@ -149,287 +147,283 @@ $core->activityReport->addAction(
# from BEHAVIOR coreAfterCommentCreate in inc/core/class.dc.blog.php # from BEHAVIOR coreAfterCommentCreate in inc/core/class.dc.blog.php
# duplicate publicAfterTrackbackCreate in inc/core/class.dc.trackback.php # duplicate publicAfterTrackbackCreate in inc/core/class.dc.trackback.php
$core->activityReport->addAction( $core->activityReport->addAction(
'comment', 'comment',
'trackback', 'trackback',
__('trackback creation'), __('trackback creation'),
__('A new trackback to "%" at "%s" was created on post "%s" at %s'), __('A new trackback to "%" at "%s" was created on post "%s" at %s'),
'coreAfterCommentCreate', 'coreAfterCommentCreate',
array('activityReportBehaviors','trackbackCreate') array('activityReportBehaviors','trackbackCreate')
); );
/* Category /* Category
-------------------------*/ -------------------------*/
$core->activityReport->addGroup('category',__('Actions on categories')); $core->activityReport->addGroup('category',__('Actions on categories'));
# from BEHAVIOR adminAfterCategoryCreate in admin/category.php # from BEHAVIOR adminAfterCategoryCreate in admin/category.php
$core->activityReport->addAction( $core->activityReport->addAction(
'category', 'category',
'create', 'create',
__('category creation'), __('category creation'),
__('A new category called "%s" was created by "%s" at %s'), __('A new category called "%s" was created by "%s" at %s'),
'adminAfterCategoryCreate', 'adminAfterCategoryCreate',
array('activityReportBehaviors','categoryCreate') array('activityReportBehaviors','categoryCreate')
); );
# from BEHAVIOR adminAfterCategoryUpdate in admin/category.php # from BEHAVIOR adminAfterCategoryUpdate in admin/category.php
$core->activityReport->addAction( $core->activityReport->addAction(
'category', 'category',
'update', 'update',
__('updating category'), __('updating category'),
__('Category called "%s" has been updated by "%s" at %s'), __('Category called "%s" has been updated by "%s" at %s'),
'adminAfterCategoryUpdate', 'adminAfterCategoryUpdate',
array('activityReportBehaviors','categoryUpdate') array('activityReportBehaviors','categoryUpdate')
); );
# Missing adminBeforeCategoryDelete in admin/category.php # Missing adminBeforeCategoryDelete in admin/category.php
/* User /* User
-------------------------*/ -------------------------*/
$core->activityReport->addGroup('user',__('Actions on users')); $core->activityReport->addGroup('user',__('Actions on users'));
# from BEHAVIOR adminAfterUserCreate in admin/user.php # from BEHAVIOR adminAfterUserCreate in admin/user.php
$core->activityReport->addAction( $core->activityReport->addAction(
'user', 'user',
'create', 'create',
__('user creation'), __('user creation'),
__('A new user named "%s" was created by "%s"'), __('A new user named "%s" was created by "%s"'),
'adminAfterUserCreate', 'adminAfterUserCreate',
array('activityReportBehaviors','userCreate') array('activityReportBehaviors','userCreate')
); );
# from BEHAVIOR adminAfterUserUpdated in admin/user.php # from BEHAVIOR adminAfterUserUpdated in admin/user.php
$core->activityReport->addAction( $core->activityReport->addAction(
'user', 'user',
'update', 'update',
__('updating user'), __('updating user'),
__('User named "%s" has been updated by "%s"'), __('User named "%s" has been updated by "%s"'),
'adminAfterUserUpdate', 'adminAfterUserUpdate',
array('activityReportBehaviors','userUpdate') array('activityReportBehaviors','userUpdate')
); );
# from BEHAVIOR adminBeforeUserDelete in admin/users.php # from BEHAVIOR adminBeforeUserDelete in admin/users.php
$core->activityReport->addAction( $core->activityReport->addAction(
'user', 'user',
'delete', 'delete',
__('user deletion'), __('user deletion'),
__('User named "%s" has been deleted by "%"'), __('User named "%s" has been deleted by "%"'),
'adminBeforeUserDelete', 'adminBeforeUserDelete',
array('activityReportBehaviors','userDelete') array('activityReportBehaviors','userDelete')
); );
class activityReportBehaviors class activityReportBehaviors
{ {
public static function messageActivityReport($message) public static function messageActivityReport($message)
{ {
global $core; global $core;
$logs = array($message); $logs = array($message);
$core->activityReport->addLog('activityReport','message',$logs); $core->activityReport->addLog('activityReport','message',$logs);
} }
public static function blogUpdate($cur,$blog_id) public static function blogUpdate($cur,$blog_id)
{ {
global $core; global $core;
$logs = array($core->auth->getInfo('user_cn')); $logs = array($core->auth->getInfo('user_cn'));
$core->activityReport->addLog('blog','update',$logs); $core->activityReport->addLog('blog','update',$logs);
} }
public static function blogP404() public static function blogP404()
{ {
global $core; global $core;
if ($core->url->type != '404') return; if ($core->url->type != '404') return;
$logs = array($core->blog->url.$_SERVER['QUERY_STRING']); $logs = array($core->blog->url.$_SERVER['QUERY_STRING']);
$core->activityReport->addLog('blog','p404',$logs); $core->activityReport->addLog('blog','p404',$logs);
} }
public static function postCreate($cur,$post_id) public static function postCreate($cur,$post_id)
{ {
global $core; global $core;
$type = $cur->post_type ? $cur->post_type : 'post'; $type = $cur->post_type ? $cur->post_type : 'post';
$post_url = $core->blog->getPostURL('',$cur->post_dt,$cur->post_title,$post_id); $post_url = $core->blog->getPostURL('',$cur->post_dt,$cur->post_title,$post_id);
$logs = array( $logs = array(
$cur->post_title, $cur->post_title,
$core->auth->getInfo('user_cn'), $core->auth->getInfo('user_cn'),
$core->blog->url.$core->url->getBase($type).'/'.$post_url $core->blog->url.$core->url->getBase($type).'/'.$post_url
); );
$core->activityReport->addLog('post','create',$logs); $core->activityReport->addLog('post','create',$logs);
} }
public static function postUpdate($cur,$post_id) public static function postUpdate($cur,$post_id)
{ {
global $core; global $core;
$type = $cur->post_type ? $cur->post_type : 'post'; $type = $cur->post_type ? $cur->post_type : 'post';
$post_url = $core->blog->getPostURL('',$cur->post_dt,$cur->post_title,$post_id); $post_url = $core->blog->getPostURL('',$cur->post_dt,$cur->post_title,$post_id);
$logs = array( $logs = array(
$cur->post_title, $cur->post_title,
$core->auth->getInfo('user_cn'), $core->auth->getInfo('user_cn'),
$core->blog->url.$core->url->getBase($type).'/'.$post_url $core->blog->url.$core->url->getBase($type).'/'.$post_url
); );
$core->activityReport->addLog('post','update',$logs); $core->activityReport->addLog('post','update',$logs);
} }
public static function postDelete($post_id) public static function postDelete($post_id)
{ {
global $core; global $core;
$posts = $core->blog->getPosts(array('post_id'=>$post_id,'limit'=>1)); $posts = $core->blog->getPosts(array('post_id'=>$post_id,'limit'=>1));
$logs = array( $logs = array(
$posts->post_title, $posts->post_title,
$core->auth->getInfo('user_cn') $core->auth->getInfo('user_cn')
); );
$core->activityReport->addLog('post','delete',$logs); $core->activityReport->addLog('post','delete',$logs);
} }
public static function postPasswordAttempt($result) public static function postPasswordAttempt($result)
{ {
global $core; global $core;
if ($result['tpl'] != 'password-form.html' || empty($_POST['password'])) return; if ($result['tpl'] != 'password-form.html' || empty($_POST['password'])) return;
$logs = array( $logs = array(
$_POST['password'], $_POST['password'],
http::getSelfURI() http::getSelfURI()
); );
$core->activityReport->addLog('post','protection',$logs); $core->activityReport->addLog('post','protection',$logs);
} }
public static function commentCreate($blog,$cur) public static function commentCreate($blog,$cur)
{ {
global $core; global $core;
if ($cur->comment_trackback) return; if ($cur->comment_trackback) return;
$posts = $core->blog->getPosts(array('post_id'=>$cur->post_id,'limit'=>1)); $posts = $core->blog->getPosts(array('post_id'=>$cur->post_id,'limit'=>1));
$logs = array( $logs = array(
$cur->comment_author, $cur->comment_author,
$posts->post_title, $posts->post_title,
$core->blog->url.$core->url->getBase($posts->post_type). $core->blog->url.$core->url->getBase($posts->post_type).
'/'.$posts->post_url.'#c'.$cur->comment_id '/'.$posts->post_url.'#c'.$cur->comment_id
); );
$core->activityReport->addLog('comment','create',$logs); $core->activityReport->addLog('comment','create',$logs);
} }
public static function commentUpdate($blog,$cur,$old) public static function commentUpdate($blog,$cur,$old)
{ {
global $core; global $core;
$posts = $core->blog->getPosts(array('post_id'=>$old->post_id,'limit'=>1)); $posts = $core->blog->getPosts(array('post_id'=>$old->post_id,'limit'=>1));
$logs = array( $logs = array(
$core->auth->getInfo('user_cn'), $core->auth->getInfo('user_cn'),
$posts->post_title, $posts->post_title,
$core->blog->url.$core->url->getBase($posts->post_type). $core->blog->url.$core->url->getBase($posts->post_type).
'/'.$posts->post_url.'#c'.$old->comment_id '/'.$posts->post_url.'#c'.$old->comment_id
); );
$core->activityReport->addLog('comment','update',$logs); $core->activityReport->addLog('comment','update',$logs);
} }
public static function trackbackCreate($cur,$comment_id) public static function trackbackCreate($cur,$comment_id)
{ {
global $core; global $core;
// From blog args are $blog,$cur #thks to bruno // From blog args are $blog,$cur #thks to bruno
$c = $cur instanceOf dcBlog ? $comment_id : $cur; $c = $cur instanceOf dcBlog ? $comment_id : $cur;
if (!$c->comment_trackback || !$c->comment_site) return; if (!$c->comment_trackback || !$c->comment_site) return;
$posts = $core->blog->getPosts( $posts = $core->blog->getPosts(
array('post_id'=>$c->post_id,'no_content'=>true,'limit'=>1)); array('post_id'=>$c->post_id,'no_content'=>true,'limit'=>1));
if ($posts->isEmpty()) return; if ($posts->isEmpty()) return;
$logs = array( $logs = array(
$c->comment_author, $c->comment_author,
$c->comment_site, $c->comment_site,
$posts->post_title, $posts->post_title,
$core->blog->url.$core->url->getBase($posts->post_type). $core->blog->url.$core->url->getBase($posts->post_type).
'/'.$posts->post_url '/'.$posts->post_url
); );
$core->activityReport->addLog('comment','trackback',$logs); $core->activityReport->addLog('comment','trackback',$logs);
} }
public static function categoryCreate($cur,$cat_id) public static function categoryCreate($cur,$cat_id)
{ {
global $core; global $core;
$logs = array( $logs = array(
$cur->cat_title, $cur->cat_title,
$core->auth->getInfo('user_cn'), $core->auth->getInfo('user_cn'),
$core->blog->url.$core->url->getBase('category').'/'.$cur->cat_url $core->blog->url.$core->url->getBase('category').'/'.$cur->cat_url
); );
$core->activityReport->addLog('category','create',$logs); $core->activityReport->addLog('category','create',$logs);
} }
public static function categoryUpdate($cur,$cat_id) public static function categoryUpdate($cur,$cat_id)
{ {
global $core; global $core;
$logs = array( $logs = array(
$cur->cat_title, $cur->cat_title,
$core->auth->getInfo('user_cn'), $core->auth->getInfo('user_cn'),
$core->blog->url.$core->url->getBase('category').'/'.$cur->cat_url $core->blog->url.$core->url->getBase('category').'/'.$cur->cat_url
); );
$core->activityReport->addLog('category','update',$logs); $core->activityReport->addLog('category','update',$logs);
} }
public static function userCreate($cur,$user_id) public static function userCreate($cur,$user_id)
{ {
global $core; global $core;
$user_cn = dcUtils::getUserCN($cur->user_id, $cur->user_name, $user_cn = dcUtils::getUserCN($cur->user_id, $cur->user_name,
$cur->user_firstname, $cur->user_displayname); $cur->user_firstname, $cur->user_displayname);
$logs = array( $logs = array(
$user_cn, $user_cn,
$core->auth->getInfo('user_cn') $core->auth->getInfo('user_cn')
); );
$core->activityReport->addLog('user','create',$logs); $core->activityReport->addLog('user','create',$logs);
} }
public static function usertUpdate($cur,$user_id) public static function usertUpdate($cur,$user_id)
{ {
global $core; global $core;
$user_cn = dcUtils::getUserCN($cur->user_id, $cur->user_name, $user_cn = dcUtils::getUserCN($cur->user_id, $cur->user_name,
$cur->user_firstname, $cur->user_displayname); $cur->user_firstname, $cur->user_displayname);
$logs = array( $logs = array(
$user_cn, $user_cn,
$core->auth->getInfo('user_cn') $core->auth->getInfo('user_cn')
); );
$core->activityReport->addLog('user','update',$logs); $core->activityReport->addLog('user','update',$logs);
} }
public static function userDelete($user_id) public static function userDelete($user_id)
{ {
global $core; global $core;
$users = $core->getUser($id); $users = $core->getUser($id);
$user_cn = dcUtils::getUserCN($users->user_id, $users->user_name, $user_cn = dcUtils::getUserCN($users->user_id, $users->user_name,
$users->user_firstname, $users->user_displayname); $users->user_firstname, $users->user_displayname);
$logs = array( $logs = array(
$user_cn, $user_cn,
$core->auth->getInfo('user_cn') $core->auth->getInfo('user_cn')
); );
$core->activityReport->addLog('user','delete',$logs); $core->activityReport->addLog('user','delete',$logs);
} }
} }
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,374 +1,374 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of activityReport, a plugin for Dotclear 2. * @brief activityReport, a plugin for Dotclear 2
# *
# Copyright (c) 2009-2010 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')){return;} if (!defined('DC_CONTEXT_ADMIN')){return;}
class activityReportLib class activityReportLib
{ {
public static function settingTab($core,$title,$global=false) public static function settingTab($core,$title,$global=false)
{ {
$O =& $core->activityReport; $O =& $core->activityReport;
$section = isset($_REQUEST['section']) ? $_REQUEST['section'] : ''; $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : '';
if ($global) if ($global)
{ {
$O->setGlobal(); $O->setGlobal();
$t = 'super'; $t = 'super';
} }
else else
{ {
$t = 'blog'; $t = 'blog';
} }
$combo_int = array( $combo_int = array(
__('every hour') => 3600, __('every hour') => 3600,
__('every 2 hours') => 7200, __('every 2 hours') => 7200,
__('2 times by day') => 43200, __('2 times by day') => 43200,
__('every day') => 86400, __('every day') => 86400,
__('every 2 days') => 172800, __('every 2 days') => 172800,
__('every week') => 604800 __('every week') => 604800
); );
$combo_obs = array( $combo_obs = array(
__('every hour') => 3600, __('every hour') => 3600,
__('every 2 hours') => 7200, __('every 2 hours') => 7200,
__('2 times by day') => 43200, __('2 times by day') => 43200,
__('every day') => 86400, __('every day') => 86400,
__('every 2 days') => 172800, __('every 2 days') => 172800,
__('every week') => 604800, __('every week') => 604800,
__('every 2 weeks') => 1209600, __('every 2 weeks') => 1209600,
__('every 4 weeks') => 2419200 __('every 4 weeks') => 2419200
); );
$combo_format = array( $combo_format = array(
__('Plain text') => 'plain', __('Plain text') => 'plain',
__('HTML') => 'html' __('HTML') => 'html'
); );
$redirect = false; $redirect = false;
if (!empty($_POST[$t.'_settings'])) if (!empty($_POST[$t.'_settings']))
{ {
# Active notification on this blog # Active notification on this blog
$O->setSetting('active',isset($_POST['active'])); $O->setSetting('active',isset($_POST['active']));
# Add dashboard items # Add dashboard items
$O->setSetting('dashboardItem',isset($_POST['dashboardItem'])); $O->setSetting('dashboardItem',isset($_POST['dashboardItem']));
# Report interval # Report interval
if (in_array($_POST['interval'],$combo_int)) if (in_array($_POST['interval'],$combo_int))
{ {
$O->setSetting('interval',(integer) $_POST['interval']); $O->setSetting('interval',(integer) $_POST['interval']);
} }
# check obsolete logs interval # check obsolete logs interval
if (in_array($_POST['obsolete'],$combo_obs)) if (in_array($_POST['obsolete'],$combo_obs))
{ {
$O->setSetting('obsolete',(integer) $_POST['obsolete']); $O->setSetting('obsolete',(integer) $_POST['obsolete']);
} }
# mail list # mail list
$O->setSetting('mailinglist',explode(';',$_POST['mailinglist'])); $O->setSetting('mailinglist',explode(';',$_POST['mailinglist']));
# mail format # mail format
$mailformat = isset($_POST['mailformat']) && $_POST['mailformat'] == 'html' ? 'html' : 'plain'; $mailformat = isset($_POST['mailformat']) && $_POST['mailformat'] == 'html' ? 'html' : 'plain';
$O->setSetting('mailformat',$mailformat); $O->setSetting('mailformat',$mailformat);
# date format # date format
$O->setSetting('dateformat',html::escapeHTML($_POST['dateformat'])); $O->setSetting('dateformat',html::escapeHTML($_POST['dateformat']));
# request infos # request infos
$requests = isset($_POST['requests']) ? $_POST['requests'] : array(); $requests = isset($_POST['requests']) ? $_POST['requests'] : array();
$O->setSetting('requests',$requests); $O->setSetting('requests',$requests);
#blogs #blogs
$blogs = isset($_POST['blogs']) ? $_POST['blogs'] : array(); $blogs = isset($_POST['blogs']) ? $_POST['blogs'] : array();
$O->setSetting('blogs',$blogs); $O->setSetting('blogs',$blogs);
$redirect = true; $redirect = true;
} }
# force to send report now # force to send report now
if (!empty($_POST[$t.'_force_report'])) if (!empty($_POST[$t.'_force_report']))
{ {
$core->activityReport->needReport(true); $core->activityReport->needReport(true);
$redirect = true; $redirect = true;
} }
# force to delete all logs now # force to delete all logs now
if (!empty($_POST[$t.'_force_delete'])) if (!empty($_POST[$t.'_force_delete']))
{ {
$core->activityReport->deleteLogs(); $core->activityReport->deleteLogs();
$redirect = true; $redirect = true;
} }
if ($redirect) if ($redirect)
{ {
http::redirect('plugin.php?p=activityReport&tab='.$t.'_settings&amp;section'.$section); http::redirect('plugin.php?p=activityReport&tab='.$t.'_settings&amp;section'.$section);
} }
$bl = $O->getSetting('lastreport'); $bl = $O->getSetting('lastreport');
$blog_last = !$bl ? __('never') : dt::str($core->blog->settings->system->date_format.', '.$core->blog->settings->system->time_format,$bl,$core->auth->getInfo('user_tz')); $blog_last = !$bl ? __('never') : dt::str($core->blog->settings->system->date_format.', '.$core->blog->settings->system->time_format,$bl,$core->auth->getInfo('user_tz'));
$bi = $O->getSetting('interval'); $bi = $O->getSetting('interval');
$blog_next = !$bl ? __('on new activity') : dt::str($core->blog->settings->system->date_format.', '.$core->blog->settings->system->time_format,$bl+$bi,$core->auth->getInfo('user_tz')); $blog_next = !$bl ? __('on new activity') : dt::str($core->blog->settings->system->date_format.', '.$core->blog->settings->system->time_format,$bl+$bi,$core->auth->getInfo('user_tz'));
$emails = implode(';',$O->getSetting('mailinglist')); $emails = implode(';',$O->getSetting('mailinglist'));
?> ?>
<div class="multi-part" id="<?php echo $t; ?>_settings" title="<?php echo $title; ?>"> <div class="multi-part" id="<?php echo $t; ?>_settings" title="<?php echo $title; ?>">
<?php if (!$global) { ?> <?php if (!$global) { ?>
<p><img alt="<?php echo __('RSS feed'); ?>" src="index.php?pf=activityReport/inc/img/feed.png" /> <p><img alt="<?php echo __('RSS feed'); ?>" src="index.php?pf=activityReport/inc/img/feed.png" />
<a title="<?php echo __('RSS feed'); ?>" href="<?php echo $core->blog->url.$core->url->getBase('activityReport').'/rss2/'.$O->getUserCode(); ?>"> <a title="<?php echo __('RSS feed'); ?>" href="<?php echo $core->blog->url.$core->url->getBase('activityReport').'/rss2/'.$O->getUserCode(); ?>">
<?php echo __('Rss2 feed for activity on this blog'); ?></a> <?php echo __('Rss2 feed for activity on this blog'); ?></a>
<br /> <br />
<img alt="<?php echo __('Atom feed'); ?>" src="index.php?pf=activityReport/inc/img/feed.png" /> <img alt="<?php echo __('Atom feed'); ?>" src="index.php?pf=activityReport/inc/img/feed.png" />
<a title="<?php echo __('Atom feed'); ?>" href="<?php echo $core->blog->url.$core->url->getBase('activityReport').'/atom/'.$O->getUserCode(); ?>"> <a title="<?php echo __('Atom feed'); ?>" href="<?php echo $core->blog->url.$core->url->getBase('activityReport').'/atom/'.$O->getUserCode(); ?>">
<?php echo __('Atom feed for activity on this blog'); ?></a></p> <?php echo __('Atom feed for activity on this blog'); ?></a></p>
<?php } ?> <?php } ?>
<form id="setting-<?php echo $t; ?>-form" method="post" action="plugin.php"> <form id="setting-<?php echo $t; ?>-form" method="post" action="plugin.php">
<fieldset id="setting-<?php echo $t; ?>-setting"><legend><?php echo __('Settings'); ?></legend> <fieldset id="setting-<?php echo $t; ?>-setting"><legend><?php echo __('Settings'); ?></legend>
<p><label class="classic"><?php echo <p><label class="classic"><?php echo
form::checkbox(array('active'),'1', form::checkbox(array('active'),'1',
$O->getSetting('active')).' '. $O->getSetting('active')).' '.
($global ? ($global ?
__('Enable super administrator report') : __('Enable super administrator report') :
__('Enable report on this blog') __('Enable report on this blog')
); ?> ); ?>
</label></p> </label></p>
<p><label class="classic"><?php echo __('Automatic cleaning of old logs:').'<br />'. <p><label class="classic"><?php echo __('Automatic cleaning of old logs:').'<br />'.
form::combo(array('obsolete'),$combo_obs,$O->getSetting('obsolete')); ?> form::combo(array('obsolete'),$combo_obs,$O->getSetting('obsolete')); ?>
</label></p> </label></p>
<?php <?php
if (!$global) if (!$global)
{ {
?> ?>
<p><label class="classic"><?php echo <p><label class="classic"><?php echo
form::checkbox(array('dashboardItem'),'1', form::checkbox(array('dashboardItem'),'1',
$O->getSetting('dashboardItem')).' '. $O->getSetting('dashboardItem')).' '.
__('Add activity report on dashboard items'); ?> __('Add activity report on dashboard items'); ?>
</label></p> </label></p>
<?php <?php
} }
?> ?>
<p><label class="classic"><?php echo __('Send report:').'<br />'. <p><label class="classic"><?php echo __('Send report:').'<br />'.
form::combo(array('interval'),$combo_int,$O->getSetting('interval')); ?> form::combo(array('interval'),$combo_int,$O->getSetting('interval')); ?>
</label></p> </label></p>
<p><label class="classic"><?php echo __('Date format:').'<br />'. <p><label class="classic"><?php echo __('Date format:').'<br />'.
form::field(array('dateformat'),60,255,$O->getSetting('dateformat')); ?> form::field(array('dateformat'),60,255,$O->getSetting('dateformat')); ?>
</label></p> </label></p>
<p class="form-note"><?php echo __('Use Dotclear date formaters. ex: %B %d at %H:%M'); ?></p> <p class="form-note"><?php echo __('Use Dotclear date formaters. ex: %B %d at %H:%M'); ?></p>
<p><label class="classic"><?php echo __('Report format:').'<br />'. <p><label class="classic"><?php echo __('Report format:').'<br />'.
form::combo(array('mailformat'),$combo_format,$O->getSetting('mailformat')); ?> form::combo(array('mailformat'),$combo_format,$O->getSetting('mailformat')); ?>
</label></p> </label></p>
<p><label class="classic"><?php echo __('Recipients:').'<br />'. <p><label class="classic"><?php echo __('Recipients:').'<br />'.
form::field(array('mailinglist'),60,255,$emails); ?> form::field(array('mailinglist'),60,255,$emails); ?>
</label></p> </label></p>
<p class="form-note"><?php echo __('Separate multiple email addresses with a semicolon ";"'); ?></p> <p class="form-note"><?php echo __('Separate multiple email addresses with a semicolon ";"'); ?></p>
<ul> <ul>
<li><?php echo __('Last report by email:').' '.$blog_last; ?></li> <li><?php echo __('Last report by email:').' '.$blog_last; ?></li>
<li><?php echo __('Next report by email:').' '.$blog_next; ?></li> <li><?php echo __('Next report by email:').' '.$blog_next; ?></li>
</ul> </ul>
</fieldset> </fieldset>
<?php <?php
if ($global) if ($global)
{ {
?> ?>
<fieldset id="setting-<?php echo $t; ?>-blog"><legend><?php echo __('Blogs'); ?></legend> <fieldset id="setting-<?php echo $t; ?>-blog"><legend><?php echo __('Blogs'); ?></legend>
<div class="three-cols"> <div class="three-cols">
<?php <?php
$i = 0; $i = 0;
$selected_blogs = $O->getSetting('blogs'); $selected_blogs = $O->getSetting('blogs');
$blogs = $core->getBlogs(); $blogs = $core->getBlogs();
while($blogs->fetch()) while($blogs->fetch())
{ {
$blog_id = $core->con->escape($blogs->blog_id); $blog_id = $core->con->escape($blogs->blog_id);
?> ?>
<div class="col"> <div class="col">
<p><label class="classic"><?php echo <p><label class="classic"><?php echo
form::checkbox(array('blogs['.$i.']'),$blog_id, form::checkbox(array('blogs['.$i.']'),$blog_id,
in_array($blog_id,$selected_blogs)).' '. in_array($blog_id,$selected_blogs)).' '.
$blogs->blog_name.' ('.$blog_id.')'; ?> $blogs->blog_name.' ('.$blog_id.')'; ?>
</label></p> </label></p>
</div> </div>
<?php <?php
$i++; $i++;
} }
?> ?>
</div> </div>
</fieldset> </fieldset>
<?php <?php
} }
?> ?>
<fieldset id="setting-<?php echo $t; ?>-report"><legend><?php echo __('Report'); ?></legend> <fieldset id="setting-<?php echo $t; ?>-report"><legend><?php echo __('Report'); ?></legend>
<div class="three-cols"> <div class="three-cols">
<?php <?php
$groups = $O->getGroups(); $groups = $O->getGroups();
$blog_request = $O->getSetting('requests'); $blog_request = $O->getSetting('requests');
$i = 0; $i = 0;
foreach($groups as $k_group => $v_group) foreach($groups as $k_group => $v_group)
{ {
?> ?>
<div class="col"> <div class="col">
<h3><?php echo __($v_group['title']); ?></h3> <h3><?php echo __($v_group['title']); ?></h3>
<?php <?php
foreach($v_group['actions'] as $k_action => $v_action) foreach($v_group['actions'] as $k_action => $v_action)
{ {
?> ?>
<p><label class="classic"><?php echo <p><label class="classic"><?php echo
form::checkbox(array('requests['.$k_group.']['.$k_action.']'),'1', form::checkbox(array('requests['.$k_group.']['.$k_action.']'),'1',
isset($blog_request[$k_group][$k_action])).' '.__($v_action['title']); ?> isset($blog_request[$k_group][$k_action])).' '.__($v_action['title']); ?>
</label></p> </label></p>
<?php <?php
} }
?> ?>
</div> </div>
<?php <?php
$i++; $i++;
if ($i == 3) { if ($i == 3) {
?></div><div class="three-cols"><?php ?></div><div class="three-cols"><?php
$i = 0; $i = 0;
} }
} }
?> ?>
</div> </div>
</fieldset> </fieldset>
<p> <p>
<input type="submit" name="<?php echo $t; ?>_settings" value="<?php echo __('Save'); ?>" /> <input type="submit" name="<?php echo $t; ?>_settings" value="<?php echo __('Save'); ?>" />
<?php <?php
if (!empty($emails)) if (!empty($emails))
{ {
?> ?>
<input type="submit" name="<?php echo $t; ?>_force_report" value="<?php echo __('Send report by email now'); ?>" /> <input type="submit" name="<?php echo $t; ?>_force_report" value="<?php echo __('Send report by email now'); ?>" />
<?php <?php
} }
if ($global) if ($global)
{ {
?> ?>
<input type="submit" name="<?php echo $t; ?>_force_delete" value="<?php echo __('Delete all logs'); ?>" /> <input type="submit" name="<?php echo $t; ?>_force_delete" value="<?php echo __('Delete all logs'); ?>" />
<?php <?php
} }
echo echo
form::hidden(array('p'),'activityReport'). form::hidden(array('p'),'activityReport').
form::hidden(array('tab'),$t.'_settings'). form::hidden(array('tab'),$t.'_settings').
form::hidden(array('section'),$section). form::hidden(array('section'),$section).
$core->formNonce(); $core->formNonce();
?> ?>
</p> </p>
</form> </form>
</div> </div>
<?php <?php
$O->unsetGlobal(); $O->unsetGlobal();
} }
public static function logTab($core,$title,$global=false) public static function logTab($core,$title,$global=false)
{ {
$O =& $core->activityReport; $O =& $core->activityReport;
if ($global) if ($global)
{ {
$O->setGlobal(); $O->setGlobal();
$t = 'super'; $t = 'super';
} }
else else
{ {
$t = 'blog'; $t = 'blog';
} }
$params = array(); $params = array();
$logs = $O->getLogs($params); $logs = $O->getLogs($params);
?> ?>
<div class="multi-part" id="<?php echo $t; ?>_logs" title="<?php echo $title; ?>"> <div class="multi-part" id="<?php echo $t; ?>_logs" title="<?php echo $title; ?>">
<?php <?php
if ($logs->isEmpty()) if ($logs->isEmpty())
{ {
echo '<p>'.__('No log').'</p>'; echo '<p>'.__('No log').'</p>';
} }
else else
{ {
?> ?>
<table> <table>
<thead> <thead>
<tr> <tr>
<th><?php echo __('Action'); ?></th> <th><?php echo __('Action'); ?></th>
<th><?php echo __('Message'); ?></th> <th><?php echo __('Message'); ?></th>
<th><?php echo __('Date'); ?></th> <th><?php echo __('Date'); ?></th>
<?php if ($global) { ?> <?php if ($global) { ?>
<th><?php echo __('Blog'); ?></th> <th><?php echo __('Blog'); ?></th>
<?php } ?> <?php } ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
while($logs->fetch()) while($logs->fetch())
{ {
$off = $global && $logs->activity_blog_status == 1 ? $off = $global && $logs->activity_blog_status == 1 ?
' offline' : ''; ' offline' : '';
$date = dt::str( $date = dt::str(
$core->blog->settings->system->date_format.', '.$core->blog->settings->system->time_format, $core->blog->settings->system->date_format.', '.$core->blog->settings->system->time_format,
strtotime($logs->activity_dt), strtotime($logs->activity_dt),
$core->auth->getInfo('user_tz') $core->auth->getInfo('user_tz')
); );
$action = $O->getGroups($logs->activity_group,$logs->activity_action); $action = $O->getGroups($logs->activity_group,$logs->activity_action);
if (empty($action)) continue; if (empty($action)) continue;
$msg = vsprintf(__($action['msg']),$O->decode($logs->activity_logs)); $msg = vsprintf(__($action['msg']),$O->decode($logs->activity_logs));
?> ?>
<tr class="line<?php echo $off; ?>"> <tr class="line<?php echo $off; ?>">
<td class="nowrap"><?php echo __($action['title']); ?></td> <td class="nowrap"><?php echo __($action['title']); ?></td>
<td class="maximal"><?php echo $msg; ?></td> <td class="maximal"><?php echo $msg; ?></td>
<td class="nowrap"><?php echo $date; ?></td> <td class="nowrap"><?php echo $date; ?></td>
<?php if ($global) { ?> <?php if ($global) { ?>
<td class="nowrap"><?php echo $logs->blog_id; ?></td> <td class="nowrap"><?php echo $logs->blog_id; ?></td>
<?php } ?> <?php } ?>
</tr> </tr>
<?php <?php
} }
?> ?>
</tbody> </tbody>
</table> </table>
<?php <?php
} }
?> ?>
</div> </div>
<?php <?php
$O->unsetGlobal(); $O->unsetGlobal();
} }
} }
?>

View File

@ -1,14 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of activityReport, a plugin for Dotclear 2. * @brief activityReport, a plugin for Dotclear 2
# *
# Copyright (c) 2009-2010 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
$format = array( $format = array(
@ -67,4 +68,3 @@ $format = array(
"%PERIOD%\n-----------------------------------------------------------\n%TEXT%" "%PERIOD%\n-----------------------------------------------------------\n%TEXT%"
)); ));
?>

View File

@ -1,14 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of activityReport, a plugin for Dotclear 2. * @brief activityReport, a plugin for Dotclear 2
# *
# Copyright (c) 2009-2010 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')){return;} if (!defined('DC_CONTEXT_ADMIN')){return;}
@ -45,17 +46,17 @@ dcPage::jsVar('jcToolsBox.prototype.section',$section).
<?php <?php
if (!activityReport::hasMailer()) if (!activityReport::hasMailer())
{ {
?> ?>
<p class="error"><?php echo __('This server has no mail function, activityReport not send email report.'); ?></p> <p class="error"><?php echo __('This server has no mail function, activityReport not send email report.'); ?></p>
<?php <?php
} }
activityReportLib::settingTab($core,__('Settings')); activityReportLib::settingTab($core,__('Settings'));
activityReportLib::logTab($core,__('Logs')); activityReportLib::logTab($core,__('Logs'));
if ($core->auth->isSuperAdmin()) if ($core->auth->isSuperAdmin())
{ {
activityReportLib::settingTab($core,__('Super settings'),true); activityReportLib::settingTab($core,__('Super settings'),true);
activityReportLib::logTab($core,__('Super logs'),true); activityReportLib::logTab($core,__('Super logs'),true);
} }
?> ?>

View File

@ -260,5 +260,3 @@ $GLOBALS['__l10n']['Super settings'] = 'Super paramètres';
#index.php:58 #index.php:58
$GLOBALS['__l10n']['Super logs'] = 'Super enregistrements'; $GLOBALS['__l10n']['Super logs'] = 'Super enregistrements';
?>