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

View File

@ -1,24 +1,32 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
# This file is part of activityReport, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2010 JC Denis and contributors
# jcdenis@gdwd.com
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------
/**
* @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_RC_PATH')) {
return null;
}
if (!defined('DC_RC_PATH')){return;}
$this->registerModule(
/* Name */ "Activity report",
/* Description*/ "Receive your blog activity by email, feed, or on dashboard",
/* Author */ "JC Denis",
/* Version */ '1.0.1',
/* Permissions */ 'admin',
/* Priority */ -1000000
);
/* date */ #20100608
?>
'Activity report',
'Receive your blog activity by email, feed, or on dashboard',
'Jean-Christian Denis and contributors',
'1.0.1',
[
'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'
]
);

View File

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

View File

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

View File

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

View File

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

@ -3,7 +3,7 @@
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xml:lang="{{tpl:BlogLanguage}}">
<title type="html">{{tpl:BlogName encode_xml="1"}}{{tpl:SysFeedSubtitle encode_xml="1"}}</title>
<subtitle type="html">{{tpl:BlogDescription encode_xml="1"}}</subtitle>
<link href="{{tpl:SysSelfURI}}" rel="self" type="application/atom+xml"/>
@ -15,7 +15,7 @@
</author>
<id>{{tpl:BlogFeedID}}</id>
<generator uri="http://www.dotclear.net/">Dotclear</generator>
<tpl:activityReports>
<entry>

View File

@ -15,9 +15,9 @@
<copyright>{{tpl:BlogCopyrightNotice encode_xml="1"}}</copyright>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>Dotclear</generator>
<tpl:activityReports>
<item>
<title>{{tpl:activityReportTitle encode_xml="1"}}</title>
<guid isPermaLink="false">{{tpl:activityReportFeedID}}</guid>
@ -28,6 +28,6 @@
</description>
</item>
</tpl:activityReports>
</channel>
</rss>

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@
$(function(){
/* tools */
dotclear.jcTools = new jcToolsBox();
/* setting blog */
var bForm=$('#setting-blog-form');
if ($(bForm).attr('id')!=undefined){

View File

@ -259,6 +259,4 @@ $GLOBALS['__l10n']['Logs'] = 'Enregistrements';
$GLOBALS['__l10n']['Super settings'] = 'Super paramètres';
#index.php:58
$GLOBALS['__l10n']['Super logs'] = 'Super enregistrements';
?>
$GLOBALS['__l10n']['Super logs'] = 'Super enregistrements';