diff --git a/_admin.php b/_admin.php
index 8143bf6..8ebd933 100644
--- a/_admin.php
+++ b/_admin.php
@@ -1,14 +1,15 @@
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 \n".
- " \n";
- }
+ # Add CSS to dashboardHeaders for items
+ public static function dashboardHeaders()
+ {
+ return
+ "\n \n".
+ " \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 .=
- '
'.
- __($g[$group]['actions'][$rs->activity_action]['title']).
- '
'.
- vsprintf(
- __($g[$group]['actions'][$rs->activity_action]['msg']),
- $core->activityReport->decode($rs->activity_logs)
- ).
- '';
- }
- }
- if (!empty($res))
- {
- $__dashboard_items[1][] =
- ''.__('Activity report').'
'.
- ''.$res.'
';
- }
- }
-}
-?>
\ No newline at end of file
+ $res .=
+ ''.
+ __($g[$group]['actions'][$rs->activity_action]['title']).
+ '
'.
+ vsprintf(
+ __($g[$group]['actions'][$rs->activity_action]['msg']),
+ $core->activityReport->decode($rs->activity_logs)
+ ).
+ '';
+ }
+ }
+ if (!empty($res))
+ {
+ $__dashboard_items[1][] =
+ ''.__('Activity report').'
'.
+ ''.$res.'
';
+ }
+ }
+}
\ No newline at end of file
diff --git a/_define.php b/_define.php
index 4859123..769c7ab 100644
--- a/_define.php
+++ b/_define.php
@@ -1,24 +1,32 @@
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
-?>
\ No newline at end of file
+ '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'
+ ]
+);
\ No newline at end of file
diff --git a/_install.php b/_install.php
index ae34c72..19bdeee 100644
--- a/_install.php
+++ b/_install.php
@@ -1,14 +1,15 @@
=')) {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;
-?>
\ No newline at end of file
+return false;
\ No newline at end of file
diff --git a/_prepend.php b/_prepend.php
index 3abd00b..8f11215 100644
--- a/_prepend.php
+++ b/_prepend.php
@@ -1,38 +1,38 @@
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');
-}
-?>
\ No newline at end of file
+ //throw new Exception('Failed to launch activityReport');
+}
\ No newline at end of file
diff --git a/_public.php b/_public.php
index 40aef1e..e62e3fd 100644
--- a/_public.php
+++ b/_public.php
@@ -1,14 +1,15 @@
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 =
- "activityreport_params = $params; '."\n".
- '$_ctx->activityreports = $core->activityReport->getLogs($params); unset($params); '."\n".
- 'while ($_ctx->activityreports->fetch()) : ?>'.$content.'activityreports = null; $_ctx->activityreport_params = null; '."\n".
- "?>";
+ $res =
+ "activityreport_params = $params; '."\n".
+ '$_ctx->activityreports = $core->activityReport->getLogs($params); unset($params); '."\n".
+ 'while ($_ctx->activityreports->fetch()) : ?>'.$content.'activityreports = null; $_ctx->activityreport_params = null; '."\n".
+ "?>";
- return $res;
- }
+ return $res;
+ }
- public static function activityReportFeedID($attr)
- {
- return
- 'urn:md5:activityreports->blog_id.'.
- '$_ctx->activityreports->activity_id.$_ctx->activityreports->activity_dt); '.
- '?>';
- }
+ public static function activityReportFeedID($attr)
+ {
+ return
+ 'urn:md5:activityreports->blog_id.'.
+ '$_ctx->activityreports->activity_id.$_ctx->activityreports->activity_dt); '.
+ '?>';
+ }
- public static function activityReportTitle($attr)
- {
- $f = $GLOBALS['core']->tpl->getFilters($attr);
- return '';
- }
+ public static function activityReportTitle($attr)
+ {
+ $f = $GLOBALS['core']->tpl->getFilters($attr);
+ return '';
+ }
- public static function activityReportContent($attr)
- {
- $f = $GLOBALS['core']->tpl->getFilters($attr);
- return '';
- }
+ public static function activityReportContent($attr)
+ {
+ $f = $GLOBALS['core']->tpl->getFilters($attr);
+ return '';
+ }
- 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 'activityreports->activity_dt),\$core->blog->settings->system->blog_timezone)").'; ?>';
- } elseif ($iso8601) {
- return 'activityreports->activity_dt),\$core->blog->settings->system->blog_timezone)").'; ?>';
- } elseif (!empty($format)) {
- return 'activityreports->activity_dt)").'; ?>';
- } else {
- return 'blog->settings->system->date_format,\$_ctx->activityreports->activity_dt)").'; ?>';
- }
- }
+ $f = $GLOBALS['core']->tpl->getFilters($attr);
+
+ if ($rfc822) {
+ return 'activityreports->activity_dt),\$core->blog->settings->system->blog_timezone)").'; ?>';
+ } elseif ($iso8601) {
+ return 'activityreports->activity_dt),\$core->blog->settings->system->blog_timezone)").'; ?>';
+ } elseif (!empty($format)) {
+ return 'activityreports->activity_dt)").'; ?>';
+ } else {
+ return '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 '';
- }
-}
-?>
\ No newline at end of file
+ if (!empty($groups[$group]['actions'][$action]['msg'])) {
+ $core->initWikiComment();
+ return $core->wikiTransform(vsprintf(__($groups[$group]['actions'][$action]['msg']),$logs));
+ }
+ return '';
+ }
+}
\ No newline at end of file
diff --git a/_uninstall.php b/_uninstall.php
index bb74757..0561be0 100644
--- a/_uninstall.php
+++ b/_uninstall.php
@@ -1,56 +1,56 @@
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')
-);
-?>
\ No newline at end of file
+ /* type */ 'plugins',
+ /* action */ 'delete',
+ /* ns */ 'activityReport',
+ /* description */ sprintf(__('delete %s plugin files'),'activityReport')
+);
\ No newline at end of file
diff --git a/dcstore.xml b/dcstore.xml
new file mode 100644
index 0000000..d5867c4
--- /dev/null
+++ b/dcstore.xml
@@ -0,0 +1,11 @@
+
+
+Rapport d'activité
+1.0.1
+Jean-Christian Denis and contributors
+Receive your blog activity by email, feed, or on dashboard
+https://github.com/JcDenis/activityReport/releases/download/v1.0.1/plugin-activityReport.zip
+http://plugins.dotaddict.org/dc2/details/activityReport
+https://github.com/JcDenis/activityReport
+
+
\ No newline at end of file
diff --git a/default-templates/tpl/activityreport-atom.xml b/default-templates/tpl/activityreport-atom.xml
index edde1e3..da1b21c 100644
--- a/default-templates/tpl/activityreport-atom.xml
+++ b/default-templates/tpl/activityreport-atom.xml
@@ -3,7 +3,7 @@
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xml:lang="{{tpl:BlogLanguage}}">
-
+
{{tpl:BlogName encode_xml="1"}}{{tpl:SysFeedSubtitle encode_xml="1"}}
{{tpl:BlogDescription encode_xml="1"}}
@@ -15,7 +15,7 @@
{{tpl:BlogFeedID}}
Dotclear
-
+
diff --git a/default-templates/tpl/activityreport-rss2.xml b/default-templates/tpl/activityreport-rss2.xml
index 32d46fa..24834c4 100644
--- a/default-templates/tpl/activityreport-rss2.xml
+++ b/default-templates/tpl/activityreport-rss2.xml
@@ -15,9 +15,9 @@
{{tpl:BlogCopyrightNotice encode_xml="1"}}
http://blogs.law.harvard.edu/tech/rss
Dotclear
-
+
-
+
-
{{tpl:activityReportTitle encode_xml="1"}}
{{tpl:activityReportFeedID}}
@@ -28,6 +28,6 @@
-
+
\ No newline at end of file
diff --git a/inc/class.activity.report.behaviors.php b/inc/class.activity.report.behaviors.php
index f095a7b..e171c1f 100644
--- a/inc/class.activity.report.behaviors.php
+++ b/inc/class.activity.report.behaviors.php
@@ -1,14 +1,15 @@
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);
- }
-}
-?>
\ No newline at end of file
+ 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);
+ }
+}
\ No newline at end of file
diff --git a/inc/class.activity.report.php b/inc/class.activity.report.php
index d38849e..c801288 100644
--- a/inc/class.activity.report.php
+++ b/inc/class.activity.report.php
@@ -1,824 +1,824 @@
core =& $core;
- $this->con = $core->con;
- $this->table = $core->prefix.'activity';
- $this->blog = $core->con->escape($core->blog->id);
- $this->ns = $core->con->escape($ns);
-
- $this->getSettings();
-
- # Check if some logs are too olds
- $this->obsoleteLogs();
- }
-
- public function setGlobal()
- {
- $this->_global = 1;
- }
-
- public function unsetGlobal()
- {
- $this->_global = 0;
- }
-
- public function getGroups($group=null,$action=null)
- {
- if ($action !== null)
- {
- return isset($this->groups[$group]['actions'][$action]) ?
- $this->groups[$group]['actions'][$action] : null;
- }
- elseif ($group !== null)
- {
- return isset($this->groups[$group]) ?
- $this->groups[$group] : null;
- }
- else
- {
- return $this->groups;
- }
- }
-
- public function addGroup($group,$title)
- {
- $this->groups[$group] = array(
- 'title' => $title,
- 'actions'=>array()
- );
- return true;
- }
-
- public function addAction($group,$action,$title,$msg,$behavior,$function)
- {
- if (!isset($this->groups[$group])) return false;
-
- $this->groups[$group]['actions'][$action] = array(
- 'title' => $title,
- 'msg' => $msg
- );
- $this->core->addBehavior($behavior,$function);
- return true;
- }
-
- private function getSettings()
- {
- $settings = array();
-
- $settings['active'] = false;
- $settings['obsolete'] = 2419200;
- $settings['dashboardItem'] = false;
- $settings['interval'] = 86400;
- $settings['lastreport'] = 0;
- $settings['mailinglist'] = array();
- $settings['mailformat'] = 'plain';
- $settings['dateformat'] = '%Y-%m-%d %H:%M:%S';
- $settings['requests'] = array();
- $settings['blogs'] = array();
-
- $this->settings[0] = $this->settings[1] = $settings;
-
- $rs = $this->con->select(
- 'SELECT setting_id, setting_value, blog_id '.
- 'FROM '.$this->table.'_setting '.
- "WHERE setting_type='".$this->ns."' ".
- "AND (blog_id='".$this->blog."' OR blog_id IS NULL) ".
- 'ORDER BY setting_id DESC '
- );
-
- while($rs->fetch())
- {
- $k = $rs->f('setting_id');
- $v = $rs->f('setting_value');
- $b = $rs->f('blog_id');
- $g = $b === null ? 1 : 0;
-
- if (isset($settings[$k]))
- {
- $this->settings[$g][$k] = self::decode($v);
- }
- }
- # Force blog
- $this->settings[0]['blogs'] = array(1=>$this->blog);
- }
-
- public function getSetting($n)
- {
- return isset($this->settings[$this->_global][$n]) ?
- $this->settings[$this->_global][$n] :
- null;
- }
-
- public function setSetting($n,$v)
- {
- if (!isset($this->settings[$this->_global][$n])) return null;
-
- $c = $this->delSetting($n);
-
- $cur = $this->con->openCursor($this->table.'_setting');
- $this->con->writeLock($this->table.'_setting');
-
- $cur->blog_id = $this->_global ? null : $this->blog;
- $cur->setting_id = $this->con->escape($n);
- $cur->setting_type = $this->ns;
- $cur->setting_value = (string) self::encode($v);
-
- $cur->insert();
- $this->con->unlock();
-
- $this->settings[$this->_global][$n] = $v;
-
- return true;
- }
-
- private function delSetting($n)
- {
- return $this->con->execute(
- 'DELETE FROM '.$this->table.'_setting '.
- "WHERE blog_id".($this->_global ? ' IS NULL' : "='".$this->blog."'").' '.
- "AND setting_id='".$this->con->escape($n)."' ".
- "AND setting_type='".$this->ns."' "
- );
- }
-
- # Action params to put in params['sql']
- public static function requests2params($requests)
- {
- $r = array();
- foreach($requests as $group => $actions)
- {
- foreach($actions as $action => $is)
- {
- $r[] = "activity_group='".$group."' AND activity_action='".$action."' ";
- }
- }
- return empty($r) ? '' : 'AND ('.implode('OR ',$r).') ';
- }
-
- public function getLogs($p,$count_only=false)
- {
- if ($count_only)
- {
- $r = 'SELECT count(E.activity_id) ';
- }
- else
- {
- $content_r = empty($p['no_content']) ? 'activity_logs, ' : '';
-
- if (!empty($params['columns']) && is_array($params['columns']))
- {
- $content_r .= implode(', ',$params['columns']).', ';
- }
-
- $r =
- 'SELECT E.activity_id, E.blog_id, B.blog_url, B.blog_name, '.$content_r.
- 'E.activity_group, E.activity_action, E.activity_dt, '.
- 'E.activity_blog_status, E.activity_super_status ';
- }
-
- $r .=
- 'FROM '.$this->table.' E '.
- 'LEFT JOIN '.$this->core->prefix.'blog B on E.blog_id=B.blog_id ';
-
- if (!empty($p['from']))
- {
- $r .= $p['from'].' ';
- }
-
- if ($this->_global)
- {
- $r .= "WHERE E.activity_super_status = 0 ";
- }
- else
- {
- $r .= "WHERE E.activity_blog_status = 0 ";
- }
-
- if (!empty($p['activity_type']))
- {
- $r .= "AND E.activity_type = '".$this->con->escape($p['activity_type'])."' ";
- }
- else
- {
- $r .= "AND E.activity_type = '".$this->ns."' ";
- }
-
- if (!empty($p['blog_id']))
- {
- if(is_array($p['blog_id']))
- {
- $r .= 'AND E.blog_id'.$this->con->in($p['blog_id']);
- }
- else
- {
- $r .= "AND E.blog_id = '".$this->con->escape($p['blog_id'])."' ";
- }
- }
- elseif($this->_global)
- {
- $r .= 'AND E.blog_id IS NOT NULL ';
- }
- else
- {
- $r .= "AND E.blog_id='".$this->blog."' ";
- }
-
- if (isset($p['activity_group']))
- {
- if (is_array($p['activity_group']) && !empty($p['activity_group']))
- {
- $r .= 'AND E.activity_group '.$this->con->in($p['activity_group']);
- }
- elseif ($p['activity_group'] != '')
- {
- $r .= "AND E.activity_group = '".$this->con->escape($p['activity_group'])."' ";
- }
- }
-
- if (isset($p['activity_action']))
- {
- if (is_array($p['activity_action']) && !empty($p['activity_action']))
- {
- $r .= 'AND E.activity_action '.$this->con->in($p['activity_action']);
- }
- elseif ($p['activity_action'] != '')
- {
- $r .= "AND E.activity_action = '".$this->con->escape($p['activity_action'])."' ";
- }
- }
-
- if (isset($p['activity_blog_status']))
- {
- $r .= "AND E.activity_blog_status = ".((integer) $p['activity_blog_status'])." ";
- }
-
- if (isset($p['activity_super_status']))
- {
- $r .= "AND E.activity_super_status = ".((integer) $p['activity_super_status'])." ";
- }
-
- if (isset($p['from_date_ts']))
- {
- $dt = date('Y-m-d H:i:s',$p['from_date_ts']);
- $r .= "AND E.activity_dt >= TIMESTAMP '".$dt."' ";
- }
- if (isset($p['to_date_ts']))
- {
- $dt = date('Y-m-d H:i:s',$p['to_date_ts']);
- $r .= "AND E.activity_dt < TIMESTAMP '".$dt."' ";
- }
-
- if (!empty($p['sql']))
- {
- $r .= $p['sql'].' ';
- }
-
- if (!$count_only)
- {
- if (!empty($p['order']))
- {
- $r .= 'ORDER BY '.$this->con->escape($p['order']).' ';
- } else {
- $r .= 'ORDER BY E.activity_dt DESC ';
- }
- }
-
- if (!$count_only && !empty($p['limit']))
- {
- $r .= $this->con->limit($p['limit']);
- }
-
- return $this->con->select($r);
- }
-
- public function addLog($group,$action,$logs)
- {
- try
- {
- $cur = $this->con->openCursor($this->table);
- $this->con->writeLock($this->table);
-
- $cur->activity_id = $this->getNextId();
- $cur->activity_type = $this->ns;
- $cur->blog_id = $this->blog;
- $cur->activity_group = $this->con->escape((string) $group);
- $cur->activity_action = $this->con->escape((string) $action);
- $cur->activity_logs = self::encode($logs);
- $cur->activity_dt = date('Y-m-d H:i:s');
-
- $cur->insert();
- $this->con->unlock();
- }
- catch (Exception $e) {
- $this->con->unlock();
- $this->core->error->add($e->getMessage());
- }
-
- # Test if email report is needed
- $this->needReport();
- }
-
- private function parseLogs($rs)
- {
- if ($rs->isEmpty()) return '';
-
- include dirname(__FILE__).'/lib.parselogs.config.php';
-
- $from = time();
- $to = 0;
- $res = $blog = $group = '';
- $tz = $this->_global ? 'UTC' : $this->core->blog->settings->system->blog_timezone;
-
- $dt = $this->settings[$this->_global]['dateformat'];
- $dt = empty($dt) ? '%Y-%m-%d %H:%M:%S' : $dt;
-
- $tpl = $this->settings[$this->_global]['mailformat'];
- $tpl = $tpl == 'html' ? $format['html'] : $format['plain'];
-
- $blog_open = $group_open = false;
-
- while($rs->fetch())
- {
- # Blog
- if ($rs->blog_id != $blog && $this->_global)
- {
- if ($group_open) {
- $res .= $tpl['group_close'];
- $group_open = false;
- }
- if ($blog_open) {
- $res .= $tpl['blog_close'];
- }
-
- $blog = $rs->blog_id;
- $group = '';
-
- $res .= str_replace(array('%TEXT%','%URL%'),array($rs->blog_name.' ('.$rs->blog_id.')',$rs->blog_url),$tpl['blog_title']);
-
- $res .= $tpl['blog_open'];
- $blog_open = true;
- }
-
- if (isset($this->groups[$rs->activity_group]))
- {
- # Type
- if ($rs->activity_group != $group)
- {
- if ($group_open) {
- $res .= $tpl['group_close'];
- }
-
- $group = $rs->activity_group;
-
- $res .= str_replace('%TEXT%',__($this->groups[$group]['title']),$tpl['group_title']);
-
- $res .= $tpl['group_open'];
- $group_open = true;
- }
-
- # Action
- $time = strtotime($rs->activity_dt);
- $data = self::decode($rs->activity_logs);
-
- $res .= str_replace(array('%TIME%','%TEXT%'),array(dt::str($dt,$time,$tz),vsprintf(__($this->groups[$group]['actions'][$rs->activity_action]['msg']),$data)),$tpl['action']);
-
- # Period
- if ($time < $from) $from = $time;
- if ($time > $to) $to = $time;
- }
- }
-
- if ($group_open) {
- $res .= $tpl['group_close'];
- }
- if ($blog_open) {
- $res .= $tpl['blog_close'];
- }
-
- if ($to == 0) {
- $res .= str_replace('%TEXT%',__('An error occured when parsing report.'),$tpl['error']);
- }
-
- # Top of msg
- if (empty($res)) return '';
-
- $period = str_replace('%TEXT%',__('Activity report'),$tpl['period_title']);
- $period .= $tpl['period_open'];
-
- $period .= str_replace('%TEXT%',__("You received a message from your blog's activity report module."),$tpl['info']);
- if (!$this->_global)
- {
- $period .= str_replace('%TEXT%',$rs->blog_name,$tpl['info']);
- $period .= str_replace('%TEXT%',$rs->blog_url,$tpl['info']);
- }
- $period .= str_replace('%TEXT%',sprintf(__('Period from %s to %s'),dt::str($dt,$from,$tz),dt::str($dt,$to,$tz)),$tpl['info']);
- $period .= $tpl['period_close'];
-
- $res = str_replace(array('%PERIOD%','%TEXT%'),array($period,$res),$tpl['page']);
-
- return $res;
- }
-
- private function obsoleteLogs()
- {
- # Get blogs and logs count
- $rs = $this->con->select(
- "SELECT blog_id ".
- 'FROM '.$this->table.' '.
- "WHERE activity_type='".$this->ns."' ".
- 'GROUP BY blog_id '
- );
-
- if ($rs->isEmpty()) return;
-
- while ($rs->fetch())
- {
- $ts = time();
- $obs_blog = dt::str('%Y-%m-%d %H:%M:%S',$ts - (integer) $this->settings[0]['obsolete']);
- $obs_global = dt::str('%Y-%m-%d %H:%M:%S',$ts - (integer) $this->settings[1]['obsolete']);
-
- $this->con->execute(
- 'DELETE FROM '.$this->table.' '.
- "WHERE activity_type='".$this->ns."' ".
- "AND (activity_dt < TIMESTAMP '".$obs_blog."' ".
- "OR activity_dt < TIMESTAMP '".$obs_global."') ".
- "AND blog_id = '".$this->con->escape($rs->blog_id)."' "
- );
-
- if ($this->con->changes())
- {
- try
- {
- $cur = $this->con->openCursor($this->table);
- $this->con->writeLock($this->table);
-
- $cur->activity_id = $this->getNextId();
- $cur->activity_type = $this->ns;
- $cur->blog_id = $rs->blog_id;
- $cur->activity_group = 'activityReport';
- $cur->activity_action = 'message';
- $cur->activity_logs = self::encode(__('Activity report deletes some old logs.'));
- $cur->activity_dt = date('Y-m-d H:i:s');
-
- $cur->insert();
- $this->con->unlock();
- }
- catch (Exception $e) {
- $this->con->unlock();
- $this->core->error->add($e->getMessage());
- }
- }
- }
- }
-
- private function cleanLogs()
- {
- $this->con->execute(
- 'DELETE FROM '.$this->table.' '.
- "WHERE activity_type='".$this->ns."' ".
- "AND activity_blog_status = 1 ".
- "AND activity_super_status = 1 "
- );
- }
-
- public function deleteLogs()
- {
- if (!$this->core->auth->isSuperAdmin()) return;
-
- return $this->con->execute(
- 'DELETE FROM '.$this->table.' '.
- "WHERE activity_type='".$this->ns."' "
- );
- }
-
- private function updateStatus($from_date_ts,$to_date_ts)
- {
- $r =
- 'UPDATE '.$this->table.' ';
-
- if ($this->_global)
- {
- $r .=
- "SET activity_super_status = 1 WHERE blog_id IS NOT NULL ";
- }
- else
- {
- $r .=
- "SET activity_blog_status = 1 WHERE blog_id = '".$this->blog."' ";
- }
-
- $r .=
- "AND activity_type = '".$this->ns."' ".
- "AND activity_dt >= TIMESTAMP '".date('Y-m-d H:i:s',$from_date_ts)."' ".
- "AND activity_dt < TIMESTAMP '".date('Y-m-d H:i:s',$to_date_ts)."' ";
-
- $this->con->execute($r);
- }
-
- public function getNextId()
- {
- return $this->con->select(
- 'SELECT MAX(activity_id) FROM '.$this->table
- )->f(0) + 1;
- }
-
- # Lock a file to see if an update is ongoing
- public function lockUpdate()
- {
- try
- {
- # Need flock function
- if (!function_exists('flock')) {
- throw New Exception("Can't call php function named flock");
- }
- # Cache writable ?
- if (!is_writable(DC_TPL_CACHE)) {
- throw new Exception("Can't write in cache fodler");
- }
- # Set file path
- $f_md5 = $this->_global ? md5(DC_MASTER_KEY) : md5($this->blog);
- $cached_file = sprintf('%s/%s/%s/%s/%s.txt',
- DC_TPL_CACHE,
- 'activityreport',
- substr($f_md5,0,2),
- substr($f_md5,2,2),
- $f_md5
- );
- # Real path
- $cached_file = path::real($cached_file,false);
- # Make dir
- if (!is_dir(dirname($cached_file))) {
-
- files::makeDir(dirname($cached_file),true);
- }
- # Make file
- if (!file_exists($cached_file)) {
- !$fp = @fopen($cached_file, 'w');
- if ($fp === false) {
- throw New Exception("Can't create file");
- }
- fwrite($fp,'1',strlen('1'));
- fclose($fp);
- }
- # Open file
- if (!($fp = @fopen($cached_file, 'r+'))) {
- throw New Exception("Can't open file");
- }
- # Lock file
- if (!flock($fp,LOCK_EX)) {
- throw New Exception("Can't lock file");
- }
- if ($this->_global)
- {
- $this->lock_global = $fp;
- }
- else
- {
- $this->lock_blog = $fp;
- }
- return true;
- }
- catch (Exception $e)
- {
- throw $e;
- }
- return false;
- }
-
- public function unlockUpdate()
- {
- if ($this->_global)
- {
- @fclose($this->lock_global);
- $this->lock_global = null;
- }
- else
- {
- @fclose($this->lock_blog);
- $this->lock_blog = null;
- }
- }
-
- public static function hasMailer()
- {
- return function_exists('mail') || function_exists('_mail');
- }
-
- public function needReport($force=false)
- {
- try
- {
- # Check if server has mail function
- if (!self::hasMailer())
- {
- throw new Exception('No mail fonction');
- }
-
- # Limit to one update at a time
- $this->lockUpdate();
-
- $send = false;
- $now = time();
-
- $active = (boolean) $this->settings[$this->_global]['active'];
- $mailinglist = $this->settings[$this->_global]['mailinglist'];
- $mailformat = $this->settings[$this->_global]['mailformat'];
- $requests = $this->settings[$this->_global]['requests'];
- $lastreport = (integer) $this->settings[$this->_global]['lastreport'];
- $interval = (integer) $this->settings[$this->_global]['interval'];
- $blogs = $this->settings[$this->_global]['blogs'];
-
- if ($force) $lastreport = 0;
-
- # Check if report is needed
- if ($active && !empty($mailinglist) && !empty($requests) && !empty($blogs)
- && ($lastreport + $interval) < $now )
- {
- # Get datas
- $params = array();
- $params['from_date_ts'] = $lastreport;
- $params['to_date_ts'] = $now;
- $params['blog_id'] = $blogs;
- $params['sql'] = self::requests2params($requests);
- $params['order'] = 'blog_id ASC, activity_group ASC, activity_action ASC, activity_dt ASC ';
-
- $logs = $this->getLogs($params);
- if (!$logs->isEmpty())
- {
- # Datas to readable text
- $content = $this->parseLogs($logs);
- if (!empty($content))
- {
- # Send mails
- $send = $this->sendReport($mailinglist,$content,$mailformat);
- }
- }
-
- # Update db
- if ($send || $this->_global) // if global : delete all blog logs even if not selected
- {
- # Update log status
- $this->updateStatus($lastreport,$now);
- # Delete old logs
- $this->cleanLogs();
- # Then set update time
- $this->setSetting('lastreport',$now);
- }
- }
-
- # If this is on a blog, we need to test superAdmin report
- if (!$this->_global)
- {
- $this->_global = true;
- $this->needReport();
- $this->_global = false;
-
- if ($send)
- {
- $this->core->callBehavior('messageActivityReport','Activity report has been successfully send by mail.');
- }
- }
- $this->unlockUpdate();
- }
- catch (Exception $e)
- {
- $this->unlockUpdate();
- //throw $e;
- }
- return true;
- }
-
- private function sendReport($recipients,$msg,$mailformat='')
- {
- if (!is_array($recipients) || empty($msg) || !text::isEmail($this->mailer)) return false;
- $mailformat = $mailformat == 'html' ? 'html' : 'plain';
-
- # Checks recipients addresses
- $rc2 = array();
- foreach ($recipients as $v)
- {
- $v = trim($v);
- if (!empty($v) && text::isEmail($v))
- {
- $rc2[] = $v;
- }
- }
- $recipients = $rc2;
- unset($rc2);
-
- if (empty($recipients)) return false;
-
- # Sending mails
- try
- {
- $headers = array(
- 'From: '.mail::B64Header(__('Activity report module')).' <'.$this->mailer.'>',
- 'Reply-To: <'.$this->mailer.'>',
- 'Content-Type: text/'.$mailformat.'; charset=UTF-8;',
- 'MIME-Version: 1.0',
- 'X-Originating-IP: '.http::realIP(),
- 'X-Mailer: Dotclear',
- 'X-Blog-Id: '.mail::B64Header($this->core->blog->id),
- 'X-Blog-Name: '.mail::B64Header($this->core->blog->name),
- 'X-Blog-Url: '.mail::B64Header($this->core->blog->url)
- );
-
- $subject = $this->_global ?
- mail::B64Header(__('Blog activity report')) :
- mail::B64Header('['.$this->core->blog->name.'] '.__('Blog activity report'));
-
- $done = true;
- foreach ($recipients as $email)
- {
- if (true !== mail::sendMail($email,$subject,$msg,$headers)) {
- $done = false;
- }
- }
- }
- catch (Exception $e)
- {
- $done = false;
- }
-
- return $done;
- }
-
- public function getUserCode()
- {
- $code =
- pack('a32',$this->core->auth->userID()).
- pack('H*',crypt::hmac(DC_MASTER_KEY,$this->core->auth->getInfo('user_pwd')));
- return bin2hex($code);
- }
-
- public function checkUserCode($code)
- {
- $code = pack('H*',$code);
-
- $user_id = trim(@pack('a32',substr($code,0,32)));
- $pwd = @unpack('H40hex',substr($code,32,40));
-
- if ($user_id === false || $pwd === false) {
- return false;
- }
-
- $pwd = $pwd['hex'];
-
- $strReq = 'SELECT user_id, user_pwd '.
- 'FROM '.$this->core->prefix.'user '.
- "WHERE user_id = '".$this->core->con->escape($user_id)."' ";
-
- $rs = $this->core->con->select($strReq);
-
- if ($rs->isEmpty()) {
- return false;
- }
-
- if (crypt::hmac(DC_MASTER_KEY,$rs->user_pwd) != $pwd) {
- return false;
- }
-
- return $rs->user_id;
- }
-
- public static function encode($a)
- {
- return @base64_encode(@serialize($a));
- }
-
- public static function decode($a)
- {
- return @unserialize(@base64_decode($a));
- }
-}
-?>
\ No newline at end of file
+ public $core;
+ public $con;
+
+ public $mailer = 'noreply.dotclear.activityreport@jcdenis.com';
+
+ private $ns = 'activityReport';
+ private $_global = 0;
+ private $blog = null;
+ private $table = '';
+ private $groups = array();
+ private $settings = array();
+ private $lock_blog = null;
+ private $lock_global = null;
+
+ public function __construct($core,$ns='activityReport')
+ {
+ $this->core =& $core;
+ $this->con = $core->con;
+ $this->table = $core->prefix.'activity';
+ $this->blog = $core->con->escape($core->blog->id);
+ $this->ns = $core->con->escape($ns);
+
+ $this->getSettings();
+
+ # Check if some logs are too olds
+ $this->obsoleteLogs();
+ }
+
+ public function setGlobal()
+ {
+ $this->_global = 1;
+ }
+
+ public function unsetGlobal()
+ {
+ $this->_global = 0;
+ }
+
+ public function getGroups($group=null,$action=null)
+ {
+ if ($action !== null)
+ {
+ return isset($this->groups[$group]['actions'][$action]) ?
+ $this->groups[$group]['actions'][$action] : null;
+ }
+ elseif ($group !== null)
+ {
+ return isset($this->groups[$group]) ?
+ $this->groups[$group] : null;
+ }
+ else
+ {
+ return $this->groups;
+ }
+ }
+
+ public function addGroup($group,$title)
+ {
+ $this->groups[$group] = array(
+ 'title' => $title,
+ 'actions'=>array()
+ );
+ return true;
+ }
+
+ public function addAction($group,$action,$title,$msg,$behavior,$function)
+ {
+ if (!isset($this->groups[$group])) return false;
+
+ $this->groups[$group]['actions'][$action] = array(
+ 'title' => $title,
+ 'msg' => $msg
+ );
+ $this->core->addBehavior($behavior,$function);
+ return true;
+ }
+
+ private function getSettings()
+ {
+ $settings = array();
+
+ $settings['active'] = false;
+ $settings['obsolete'] = 2419200;
+ $settings['dashboardItem'] = false;
+ $settings['interval'] = 86400;
+ $settings['lastreport'] = 0;
+ $settings['mailinglist'] = array();
+ $settings['mailformat'] = 'plain';
+ $settings['dateformat'] = '%Y-%m-%d %H:%M:%S';
+ $settings['requests'] = array();
+ $settings['blogs'] = array();
+
+ $this->settings[0] = $this->settings[1] = $settings;
+
+ $rs = $this->con->select(
+ 'SELECT setting_id, setting_value, blog_id '.
+ 'FROM '.$this->table.'_setting '.
+ "WHERE setting_type='".$this->ns."' ".
+ "AND (blog_id='".$this->blog."' OR blog_id IS NULL) ".
+ 'ORDER BY setting_id DESC '
+ );
+
+ while($rs->fetch())
+ {
+ $k = $rs->f('setting_id');
+ $v = $rs->f('setting_value');
+ $b = $rs->f('blog_id');
+ $g = $b === null ? 1 : 0;
+
+ if (isset($settings[$k]))
+ {
+ $this->settings[$g][$k] = self::decode($v);
+ }
+ }
+ # Force blog
+ $this->settings[0]['blogs'] = array(1=>$this->blog);
+ }
+
+ public function getSetting($n)
+ {
+ return isset($this->settings[$this->_global][$n]) ?
+ $this->settings[$this->_global][$n] :
+ null;
+ }
+
+ public function setSetting($n,$v)
+ {
+ if (!isset($this->settings[$this->_global][$n])) return null;
+
+ $c = $this->delSetting($n);
+
+ $cur = $this->con->openCursor($this->table.'_setting');
+ $this->con->writeLock($this->table.'_setting');
+
+ $cur->blog_id = $this->_global ? null : $this->blog;
+ $cur->setting_id = $this->con->escape($n);
+ $cur->setting_type = $this->ns;
+ $cur->setting_value = (string) self::encode($v);
+
+ $cur->insert();
+ $this->con->unlock();
+
+ $this->settings[$this->_global][$n] = $v;
+
+ return true;
+ }
+
+ private function delSetting($n)
+ {
+ return $this->con->execute(
+ 'DELETE FROM '.$this->table.'_setting '.
+ "WHERE blog_id".($this->_global ? ' IS NULL' : "='".$this->blog."'").' '.
+ "AND setting_id='".$this->con->escape($n)."' ".
+ "AND setting_type='".$this->ns."' "
+ );
+ }
+
+ # Action params to put in params['sql']
+ public static function requests2params($requests)
+ {
+ $r = array();
+ foreach($requests as $group => $actions)
+ {
+ foreach($actions as $action => $is)
+ {
+ $r[] = "activity_group='".$group."' AND activity_action='".$action."' ";
+ }
+ }
+ return empty($r) ? '' : 'AND ('.implode('OR ',$r).') ';
+ }
+
+ public function getLogs($p,$count_only=false)
+ {
+ if ($count_only)
+ {
+ $r = 'SELECT count(E.activity_id) ';
+ }
+ else
+ {
+ $content_r = empty($p['no_content']) ? 'activity_logs, ' : '';
+
+ if (!empty($params['columns']) && is_array($params['columns']))
+ {
+ $content_r .= implode(', ',$params['columns']).', ';
+ }
+
+ $r =
+ 'SELECT E.activity_id, E.blog_id, B.blog_url, B.blog_name, '.$content_r.
+ 'E.activity_group, E.activity_action, E.activity_dt, '.
+ 'E.activity_blog_status, E.activity_super_status ';
+ }
+
+ $r .=
+ 'FROM '.$this->table.' E '.
+ 'LEFT JOIN '.$this->core->prefix.'blog B on E.blog_id=B.blog_id ';
+
+ if (!empty($p['from']))
+ {
+ $r .= $p['from'].' ';
+ }
+
+ if ($this->_global)
+ {
+ $r .= "WHERE E.activity_super_status = 0 ";
+ }
+ else
+ {
+ $r .= "WHERE E.activity_blog_status = 0 ";
+ }
+
+ if (!empty($p['activity_type']))
+ {
+ $r .= "AND E.activity_type = '".$this->con->escape($p['activity_type'])."' ";
+ }
+ else
+ {
+ $r .= "AND E.activity_type = '".$this->ns."' ";
+ }
+
+ if (!empty($p['blog_id']))
+ {
+ if(is_array($p['blog_id']))
+ {
+ $r .= 'AND E.blog_id'.$this->con->in($p['blog_id']);
+ }
+ else
+ {
+ $r .= "AND E.blog_id = '".$this->con->escape($p['blog_id'])."' ";
+ }
+ }
+ elseif($this->_global)
+ {
+ $r .= 'AND E.blog_id IS NOT NULL ';
+ }
+ else
+ {
+ $r .= "AND E.blog_id='".$this->blog."' ";
+ }
+
+ if (isset($p['activity_group']))
+ {
+ if (is_array($p['activity_group']) && !empty($p['activity_group']))
+ {
+ $r .= 'AND E.activity_group '.$this->con->in($p['activity_group']);
+ }
+ elseif ($p['activity_group'] != '')
+ {
+ $r .= "AND E.activity_group = '".$this->con->escape($p['activity_group'])."' ";
+ }
+ }
+
+ if (isset($p['activity_action']))
+ {
+ if (is_array($p['activity_action']) && !empty($p['activity_action']))
+ {
+ $r .= 'AND E.activity_action '.$this->con->in($p['activity_action']);
+ }
+ elseif ($p['activity_action'] != '')
+ {
+ $r .= "AND E.activity_action = '".$this->con->escape($p['activity_action'])."' ";
+ }
+ }
+
+ if (isset($p['activity_blog_status']))
+ {
+ $r .= "AND E.activity_blog_status = ".((integer) $p['activity_blog_status'])." ";
+ }
+
+ if (isset($p['activity_super_status']))
+ {
+ $r .= "AND E.activity_super_status = ".((integer) $p['activity_super_status'])." ";
+ }
+
+ if (isset($p['from_date_ts']))
+ {
+ $dt = date('Y-m-d H:i:s',$p['from_date_ts']);
+ $r .= "AND E.activity_dt >= TIMESTAMP '".$dt."' ";
+ }
+ if (isset($p['to_date_ts']))
+ {
+ $dt = date('Y-m-d H:i:s',$p['to_date_ts']);
+ $r .= "AND E.activity_dt < TIMESTAMP '".$dt."' ";
+ }
+
+ if (!empty($p['sql']))
+ {
+ $r .= $p['sql'].' ';
+ }
+
+ if (!$count_only)
+ {
+ if (!empty($p['order']))
+ {
+ $r .= 'ORDER BY '.$this->con->escape($p['order']).' ';
+ } else {
+ $r .= 'ORDER BY E.activity_dt DESC ';
+ }
+ }
+
+ if (!$count_only && !empty($p['limit']))
+ {
+ $r .= $this->con->limit($p['limit']);
+ }
+
+ return $this->con->select($r);
+ }
+
+ public function addLog($group,$action,$logs)
+ {
+ try
+ {
+ $cur = $this->con->openCursor($this->table);
+ $this->con->writeLock($this->table);
+
+ $cur->activity_id = $this->getNextId();
+ $cur->activity_type = $this->ns;
+ $cur->blog_id = $this->blog;
+ $cur->activity_group = $this->con->escape((string) $group);
+ $cur->activity_action = $this->con->escape((string) $action);
+ $cur->activity_logs = self::encode($logs);
+ $cur->activity_dt = date('Y-m-d H:i:s');
+
+ $cur->insert();
+ $this->con->unlock();
+ }
+ catch (Exception $e) {
+ $this->con->unlock();
+ $this->core->error->add($e->getMessage());
+ }
+
+ # Test if email report is needed
+ $this->needReport();
+ }
+
+ private function parseLogs($rs)
+ {
+ if ($rs->isEmpty()) return '';
+
+ include dirname(__FILE__).'/lib.parselogs.config.php';
+
+ $from = time();
+ $to = 0;
+ $res = $blog = $group = '';
+ $tz = $this->_global ? 'UTC' : $this->core->blog->settings->system->blog_timezone;
+
+ $dt = $this->settings[$this->_global]['dateformat'];
+ $dt = empty($dt) ? '%Y-%m-%d %H:%M:%S' : $dt;
+
+ $tpl = $this->settings[$this->_global]['mailformat'];
+ $tpl = $tpl == 'html' ? $format['html'] : $format['plain'];
+
+ $blog_open = $group_open = false;
+
+ while($rs->fetch())
+ {
+ # Blog
+ if ($rs->blog_id != $blog && $this->_global)
+ {
+ if ($group_open) {
+ $res .= $tpl['group_close'];
+ $group_open = false;
+ }
+ if ($blog_open) {
+ $res .= $tpl['blog_close'];
+ }
+
+ $blog = $rs->blog_id;
+ $group = '';
+
+ $res .= str_replace(array('%TEXT%','%URL%'),array($rs->blog_name.' ('.$rs->blog_id.')',$rs->blog_url),$tpl['blog_title']);
+
+ $res .= $tpl['blog_open'];
+ $blog_open = true;
+ }
+
+ if (isset($this->groups[$rs->activity_group]))
+ {
+ # Type
+ if ($rs->activity_group != $group)
+ {
+ if ($group_open) {
+ $res .= $tpl['group_close'];
+ }
+
+ $group = $rs->activity_group;
+
+ $res .= str_replace('%TEXT%',__($this->groups[$group]['title']),$tpl['group_title']);
+
+ $res .= $tpl['group_open'];
+ $group_open = true;
+ }
+
+ # Action
+ $time = strtotime($rs->activity_dt);
+ $data = self::decode($rs->activity_logs);
+
+ $res .= str_replace(array('%TIME%','%TEXT%'),array(dt::str($dt,$time,$tz),vsprintf(__($this->groups[$group]['actions'][$rs->activity_action]['msg']),$data)),$tpl['action']);
+
+ # Period
+ if ($time < $from) $from = $time;
+ if ($time > $to) $to = $time;
+ }
+ }
+
+ if ($group_open) {
+ $res .= $tpl['group_close'];
+ }
+ if ($blog_open) {
+ $res .= $tpl['blog_close'];
+ }
+
+ if ($to == 0) {
+ $res .= str_replace('%TEXT%',__('An error occured when parsing report.'),$tpl['error']);
+ }
+
+ # Top of msg
+ if (empty($res)) return '';
+
+ $period = str_replace('%TEXT%',__('Activity report'),$tpl['period_title']);
+ $period .= $tpl['period_open'];
+
+ $period .= str_replace('%TEXT%',__("You received a message from your blog's activity report module."),$tpl['info']);
+ if (!$this->_global)
+ {
+ $period .= str_replace('%TEXT%',$rs->blog_name,$tpl['info']);
+ $period .= str_replace('%TEXT%',$rs->blog_url,$tpl['info']);
+ }
+ $period .= str_replace('%TEXT%',sprintf(__('Period from %s to %s'),dt::str($dt,$from,$tz),dt::str($dt,$to,$tz)),$tpl['info']);
+ $period .= $tpl['period_close'];
+
+ $res = str_replace(array('%PERIOD%','%TEXT%'),array($period,$res),$tpl['page']);
+
+ return $res;
+ }
+
+ private function obsoleteLogs()
+ {
+ # Get blogs and logs count
+ $rs = $this->con->select(
+ "SELECT blog_id ".
+ 'FROM '.$this->table.' '.
+ "WHERE activity_type='".$this->ns."' ".
+ 'GROUP BY blog_id '
+ );
+
+ if ($rs->isEmpty()) return;
+
+ while ($rs->fetch())
+ {
+ $ts = time();
+ $obs_blog = dt::str('%Y-%m-%d %H:%M:%S',$ts - (integer) $this->settings[0]['obsolete']);
+ $obs_global = dt::str('%Y-%m-%d %H:%M:%S',$ts - (integer) $this->settings[1]['obsolete']);
+
+ $this->con->execute(
+ 'DELETE FROM '.$this->table.' '.
+ "WHERE activity_type='".$this->ns."' ".
+ "AND (activity_dt < TIMESTAMP '".$obs_blog."' ".
+ "OR activity_dt < TIMESTAMP '".$obs_global."') ".
+ "AND blog_id = '".$this->con->escape($rs->blog_id)."' "
+ );
+
+ if ($this->con->changes())
+ {
+ try
+ {
+ $cur = $this->con->openCursor($this->table);
+ $this->con->writeLock($this->table);
+
+ $cur->activity_id = $this->getNextId();
+ $cur->activity_type = $this->ns;
+ $cur->blog_id = $rs->blog_id;
+ $cur->activity_group = 'activityReport';
+ $cur->activity_action = 'message';
+ $cur->activity_logs = self::encode(__('Activity report deletes some old logs.'));
+ $cur->activity_dt = date('Y-m-d H:i:s');
+
+ $cur->insert();
+ $this->con->unlock();
+ }
+ catch (Exception $e) {
+ $this->con->unlock();
+ $this->core->error->add($e->getMessage());
+ }
+ }
+ }
+ }
+
+ private function cleanLogs()
+ {
+ $this->con->execute(
+ 'DELETE FROM '.$this->table.' '.
+ "WHERE activity_type='".$this->ns."' ".
+ "AND activity_blog_status = 1 ".
+ "AND activity_super_status = 1 "
+ );
+ }
+
+ public function deleteLogs()
+ {
+ if (!$this->core->auth->isSuperAdmin()) return;
+
+ return $this->con->execute(
+ 'DELETE FROM '.$this->table.' '.
+ "WHERE activity_type='".$this->ns."' "
+ );
+ }
+
+ private function updateStatus($from_date_ts,$to_date_ts)
+ {
+ $r =
+ 'UPDATE '.$this->table.' ';
+
+ if ($this->_global)
+ {
+ $r .=
+ "SET activity_super_status = 1 WHERE blog_id IS NOT NULL ";
+ }
+ else
+ {
+ $r .=
+ "SET activity_blog_status = 1 WHERE blog_id = '".$this->blog."' ";
+ }
+
+ $r .=
+ "AND activity_type = '".$this->ns."' ".
+ "AND activity_dt >= TIMESTAMP '".date('Y-m-d H:i:s',$from_date_ts)."' ".
+ "AND activity_dt < TIMESTAMP '".date('Y-m-d H:i:s',$to_date_ts)."' ";
+
+ $this->con->execute($r);
+ }
+
+ public function getNextId()
+ {
+ return $this->con->select(
+ 'SELECT MAX(activity_id) FROM '.$this->table
+ )->f(0) + 1;
+ }
+
+ # Lock a file to see if an update is ongoing
+ public function lockUpdate()
+ {
+ try
+ {
+ # Need flock function
+ if (!function_exists('flock')) {
+ throw New Exception("Can't call php function named flock");
+ }
+ # Cache writable ?
+ if (!is_writable(DC_TPL_CACHE)) {
+ throw new Exception("Can't write in cache fodler");
+ }
+ # Set file path
+ $f_md5 = $this->_global ? md5(DC_MASTER_KEY) : md5($this->blog);
+ $cached_file = sprintf('%s/%s/%s/%s/%s.txt',
+ DC_TPL_CACHE,
+ 'activityreport',
+ substr($f_md5,0,2),
+ substr($f_md5,2,2),
+ $f_md5
+ );
+ # Real path
+ $cached_file = path::real($cached_file,false);
+ # Make dir
+ if (!is_dir(dirname($cached_file))) {
+
+ files::makeDir(dirname($cached_file),true);
+ }
+ # Make file
+ if (!file_exists($cached_file)) {
+ !$fp = @fopen($cached_file, 'w');
+ if ($fp === false) {
+ throw New Exception("Can't create file");
+ }
+ fwrite($fp,'1',strlen('1'));
+ fclose($fp);
+ }
+ # Open file
+ if (!($fp = @fopen($cached_file, 'r+'))) {
+ throw New Exception("Can't open file");
+ }
+ # Lock file
+ if (!flock($fp,LOCK_EX)) {
+ throw New Exception("Can't lock file");
+ }
+ if ($this->_global)
+ {
+ $this->lock_global = $fp;
+ }
+ else
+ {
+ $this->lock_blog = $fp;
+ }
+ return true;
+ }
+ catch (Exception $e)
+ {
+ throw $e;
+ }
+ return false;
+ }
+
+ public function unlockUpdate()
+ {
+ if ($this->_global)
+ {
+ @fclose($this->lock_global);
+ $this->lock_global = null;
+ }
+ else
+ {
+ @fclose($this->lock_blog);
+ $this->lock_blog = null;
+ }
+ }
+
+ public static function hasMailer()
+ {
+ return function_exists('mail') || function_exists('_mail');
+ }
+
+ public function needReport($force=false)
+ {
+ try
+ {
+ # Check if server has mail function
+ if (!self::hasMailer())
+ {
+ throw new Exception('No mail fonction');
+ }
+
+ # Limit to one update at a time
+ $this->lockUpdate();
+
+ $send = false;
+ $now = time();
+
+ $active = (boolean) $this->settings[$this->_global]['active'];
+ $mailinglist = $this->settings[$this->_global]['mailinglist'];
+ $mailformat = $this->settings[$this->_global]['mailformat'];
+ $requests = $this->settings[$this->_global]['requests'];
+ $lastreport = (integer) $this->settings[$this->_global]['lastreport'];
+ $interval = (integer) $this->settings[$this->_global]['interval'];
+ $blogs = $this->settings[$this->_global]['blogs'];
+
+ if ($force) $lastreport = 0;
+
+ # Check if report is needed
+ if ($active && !empty($mailinglist) && !empty($requests) && !empty($blogs)
+ && ($lastreport + $interval) < $now )
+ {
+ # Get datas
+ $params = array();
+ $params['from_date_ts'] = $lastreport;
+ $params['to_date_ts'] = $now;
+ $params['blog_id'] = $blogs;
+ $params['sql'] = self::requests2params($requests);
+ $params['order'] = 'blog_id ASC, activity_group ASC, activity_action ASC, activity_dt ASC ';
+
+ $logs = $this->getLogs($params);
+ if (!$logs->isEmpty())
+ {
+ # Datas to readable text
+ $content = $this->parseLogs($logs);
+ if (!empty($content))
+ {
+ # Send mails
+ $send = $this->sendReport($mailinglist,$content,$mailformat);
+ }
+ }
+
+ # Update db
+ if ($send || $this->_global) // if global : delete all blog logs even if not selected
+ {
+ # Update log status
+ $this->updateStatus($lastreport,$now);
+ # Delete old logs
+ $this->cleanLogs();
+ # Then set update time
+ $this->setSetting('lastreport',$now);
+ }
+ }
+
+ # If this is on a blog, we need to test superAdmin report
+ if (!$this->_global)
+ {
+ $this->_global = true;
+ $this->needReport();
+ $this->_global = false;
+
+ if ($send)
+ {
+ $this->core->callBehavior('messageActivityReport','Activity report has been successfully send by mail.');
+ }
+ }
+ $this->unlockUpdate();
+ }
+ catch (Exception $e)
+ {
+ $this->unlockUpdate();
+ //throw $e;
+ }
+ return true;
+ }
+
+ private function sendReport($recipients,$msg,$mailformat='')
+ {
+ if (!is_array($recipients) || empty($msg) || !text::isEmail($this->mailer)) return false;
+ $mailformat = $mailformat == 'html' ? 'html' : 'plain';
+
+ # Checks recipients addresses
+ $rc2 = array();
+ foreach ($recipients as $v)
+ {
+ $v = trim($v);
+ if (!empty($v) && text::isEmail($v))
+ {
+ $rc2[] = $v;
+ }
+ }
+ $recipients = $rc2;
+ unset($rc2);
+
+ if (empty($recipients)) return false;
+
+ # Sending mails
+ try
+ {
+ $headers = array(
+ 'From: '.mail::B64Header(__('Activity report module')).' <'.$this->mailer.'>',
+ 'Reply-To: <'.$this->mailer.'>',
+ 'Content-Type: text/'.$mailformat.'; charset=UTF-8;',
+ 'MIME-Version: 1.0',
+ 'X-Originating-IP: '.http::realIP(),
+ 'X-Mailer: Dotclear',
+ 'X-Blog-Id: '.mail::B64Header($this->core->blog->id),
+ 'X-Blog-Name: '.mail::B64Header($this->core->blog->name),
+ 'X-Blog-Url: '.mail::B64Header($this->core->blog->url)
+ );
+
+ $subject = $this->_global ?
+ mail::B64Header(__('Blog activity report')) :
+ mail::B64Header('['.$this->core->blog->name.'] '.__('Blog activity report'));
+
+ $done = true;
+ foreach ($recipients as $email)
+ {
+ if (true !== mail::sendMail($email,$subject,$msg,$headers)) {
+ $done = false;
+ }
+ }
+ }
+ catch (Exception $e)
+ {
+ $done = false;
+ }
+
+ return $done;
+ }
+
+ public function getUserCode()
+ {
+ $code =
+ pack('a32',$this->core->auth->userID()).
+ pack('H*',crypt::hmac(DC_MASTER_KEY,$this->core->auth->getInfo('user_pwd')));
+ return bin2hex($code);
+ }
+
+ public function checkUserCode($code)
+ {
+ $code = pack('H*',$code);
+
+ $user_id = trim(@pack('a32',substr($code,0,32)));
+ $pwd = @unpack('H40hex',substr($code,32,40));
+
+ if ($user_id === false || $pwd === false) {
+ return false;
+ }
+
+ $pwd = $pwd['hex'];
+
+ $strReq = 'SELECT user_id, user_pwd '.
+ 'FROM '.$this->core->prefix.'user '.
+ "WHERE user_id = '".$this->core->con->escape($user_id)."' ";
+
+ $rs = $this->core->con->select($strReq);
+
+ if ($rs->isEmpty()) {
+ return false;
+ }
+
+ if (crypt::hmac(DC_MASTER_KEY,$rs->user_pwd) != $pwd) {
+ return false;
+ }
+
+ return $rs->user_id;
+ }
+
+ public static function encode($a)
+ {
+ return @base64_encode(@serialize($a));
+ }
+
+ public static function decode($a)
+ {
+ return @unserialize(@base64_decode($a));
+ }
+}
\ No newline at end of file
diff --git a/inc/lib.activity.report.index.php b/inc/lib.activity.report.index.php
index 4586dae..bc63759 100644
--- a/inc/lib.activity.report.index.php
+++ b/inc/lib.activity.report.index.php
@@ -1,374 +1,374 @@
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§ion'.$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§ion'.$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'));
- ?>
-
+ $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'));
-
+ $emails = implode(';',$O->getSetting('mailinglist'));
-
-
-
-
-
-
-
-
-
+ ?>
+
getLogs($params);
+ ?>
+
+
- ?>
-
-
+
+
+
+
+
+ formNonce();
+ ?>
+
+
+
+ unsetGlobal();
+ }
- if ($logs->isEmpty())
- {
- echo '
'.__('No log').'
';
- }
- else
- {
+ public static function logTab($core,$title,$global=false)
+ {
+ $O =& $core->activityReport;
+ if ($global)
+ {
+ $O->setGlobal();
+ $t = 'super';
+ }
+ else
+ {
+ $t = 'blog';
+ }
- ?>
-
-
-
- |
- |
- |
-
- |
-
-
-
-
- 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);
+ ?>
+
+ isEmpty())
+ {
+ echo '
'.__('No log').'
';
+ }
+ else
+ {
- $msg = vsprintf(__($action['msg']),$O->decode($logs->activity_logs));
- ?>
-
- |
- |
- |
-
- blog_id; ?> |
-
-
-
+
+
+
+ |
+ |
+ |
+
+ |
+
+
+
+
+
-
-
- 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;
- ?>
-
- decode($logs->activity_logs));
+ ?>
+
+ |
+ |
+ |
+
+ blog_id; ?> |
+
+
+ unsetGlobal();
- }
-}
-?>
\ No newline at end of file
+ ?>
+
+
+
+
+ unsetGlobal();
+ }
+}
\ No newline at end of file
diff --git a/inc/lib.parselogs.config.php b/inc/lib.parselogs.config.php
index 404db46..8248bf1 100644
--- a/inc/lib.parselogs.config.php
+++ b/inc/lib.parselogs.config.php
@@ -1,14 +1,15 @@
\ No newline at end of file
+));
\ No newline at end of file
diff --git a/index.php b/index.php
index 12ebd9a..2184863 100644
--- a/index.php
+++ b/index.php
@@ -1,14 +1,15 @@
-
-
+
+ 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);
}
?>
diff --git a/js/main.js b/js/main.js
index 291050f..42b9906 100644
--- a/js/main.js
+++ b/js/main.js
@@ -12,7 +12,7 @@
$(function(){
/* tools */
dotclear.jcTools = new jcToolsBox();
-
+
/* setting blog */
var bForm=$('#setting-blog-form');
if ($(bForm).attr('id')!=undefined){
diff --git a/locales/fr/main.lang.php b/locales/fr/main.lang.php
index 54e0d2c..4d856ef 100644
--- a/locales/fr/main.lang.php
+++ b/locales/fr/main.lang.php
@@ -259,6 +259,4 @@ $GLOBALS['__l10n']['Logs'] = 'Enregistrements';
$GLOBALS['__l10n']['Super settings'] = 'Super paramètres';
#index.php:58
-$GLOBALS['__l10n']['Super logs'] = 'Super enregistrements';
-
-?>
\ No newline at end of file
+$GLOBALS['__l10n']['Super logs'] = 'Super enregistrements';
\ No newline at end of file