Second pass to clean up code
This commit is contained in:
parent
55136bb6d7
commit
60289b71c4
@ -15,6 +15,9 @@ themes and plugins from Dotclear administration pages.
|
||||
* Permissions superadmin or admin
|
||||
* Dotclear 2.19
|
||||
|
||||
* plugin add a table to database
|
||||
* plugin send email
|
||||
|
||||
## USAGE
|
||||
|
||||
First install _activityReport_, manualy from a zip package or from
|
||||
|
59
_admin.php
59
_admin.php
@ -11,48 +11,42 @@
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')){return;}
|
||||
|
||||
if (!defined('ACTIVITY_REPORT')){return;}
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
if (!defined('ACTIVITY_REPORT')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
# 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->adminurl->get('admin.plugin.activityReport'),
|
||||
dcPage::getPF('activityReport/icon.png'),
|
||||
preg_match('/' . preg_quote($core->adminurl->get('admin.plugin.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')
|
||||
);
|
||||
if ($core->activityReport->getSetting('dashboardItem')) {
|
||||
$core->addBehavior('adminDashboardHeaders', ['activityReportAdmin', 'dashboardHeaders']);
|
||||
$core->addBehavior('adminDashboardItems', ['activityReportAdmin', 'dashboardItems']);
|
||||
}
|
||||
|
||||
class activityReportAdmin
|
||||
{
|
||||
# Add CSS to dashboardHeaders for items
|
||||
/**
|
||||
* 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";
|
||||
return dcPage::jsLoad('index.php?pf=activityReport/style.css');
|
||||
}
|
||||
|
||||
# Add report to dashboardItems
|
||||
public static function dashboardItems($core, $__dashboard_items)
|
||||
/**
|
||||
* Add report to dashboardItems
|
||||
*/
|
||||
public static function dashboardItems(dcCore $core, $__dashboard_items)
|
||||
{
|
||||
$r = $core->activityReport->getSetting('requests');
|
||||
$g = $core->activityReport->getGroups();
|
||||
@ -64,13 +58,13 @@ class activityReportAdmin
|
||||
|
||||
$res = '';
|
||||
$rs = $core->activityReport->getLogs($p);
|
||||
if (!$rs->isEmpty())
|
||||
{
|
||||
while($rs->fetch())
|
||||
{
|
||||
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>' .
|
||||
@ -83,8 +77,7 @@ class activityReportAdmin
|
||||
'</em></dd>';
|
||||
}
|
||||
}
|
||||
if (!empty($res))
|
||||
{
|
||||
if (!empty($res)) {
|
||||
$__dashboard_items[1][] =
|
||||
'<h3>' . __('Activity report') . '</h3>' .
|
||||
'<dl id="report">' . $res . '</dl>';
|
||||
|
21
_install.php
21
_install.php
@ -11,22 +11,18 @@
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')){return;}
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$new_version = $core->plugins->moduleInfo('activityReport', 'version');
|
||||
$old_version = $core->getVersion('activityReport');
|
||||
|
||||
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');
|
||||
if (version_compare($old_version, $new_version, '>=')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
# Table
|
||||
try {
|
||||
$s = new dbStruct($core->con, $core->prefix);
|
||||
$s->activity
|
||||
->activity_id ('bigint', 0, false)
|
||||
@ -59,13 +55,10 @@ try
|
||||
$si = new dbStruct($core->con, $core->prefix);
|
||||
$changes = $si->synchronize($s);
|
||||
|
||||
# Version
|
||||
$core->setVersion('activityReport', $new_version);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
return false;
|
17
_prepend.php
17
_prepend.php
@ -11,28 +11,25 @@
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')){return;}
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
global $__autoload, $core;
|
||||
$__autoload['activityReport'] = dirname(__FILE__) . '/inc/class.activity.report.php';
|
||||
|
||||
$__autoload['activityReport'] =
|
||||
dirname(__FILE__).'/inc/class.activity.report.php';
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$core->activityReport = new activityReport($core);
|
||||
|
||||
$core->url->register(
|
||||
'activityReport',
|
||||
'reports',
|
||||
'^reports/((atom|rss2)/(.+))$',
|
||||
array('activityReportPublicUrl','feed')
|
||||
['activityReportPublicUrl', 'feed']
|
||||
);
|
||||
|
||||
define('ACTIVITY_REPORT', true);
|
||||
|
||||
require_once dirname(__FILE__) . '/inc/class.activity.report.behaviors.php';
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
//throw new Exception('Failed to launch activityReport');
|
||||
}
|
29
_public.php
29
_public.php
@ -11,16 +11,19 @@
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')){return;}
|
||||
|
||||
if (!defined('ACTIVITY_REPORT')){return;}
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
if (!defined('ACTIVITY_REPORT')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates/tpl');
|
||||
$core->tpl->addBlock('activityReports',array('activityReportPublicTpl','activityReports'));
|
||||
$core->tpl->addValue('activityReportFeedID',array('activityReportPublicTpl','activityReportFeedID'));
|
||||
$core->tpl->addValue('activityReportTitle',array('activityReportPublicTpl','activityReportTitle'));
|
||||
$core->tpl->addValue('activityReportDate',array('activityReportPublicTpl','activityReportDate'));
|
||||
$core->tpl->addValue('activityReportContent',array('activityReportPublicTpl','activityReportContent'));
|
||||
$core->tpl->addBlock('activityReports', ['activityReportPublicTpl','activityReports']);
|
||||
$core->tpl->addValue('activityReportFeedID', ['activityReportPublicTpl','activityReportFeedID']);
|
||||
$core->tpl->addValue('activityReportTitle', ['activityReportPublicTpl','activityReportTitle']);
|
||||
$core->tpl->addValue('activityReportDate', ['activityReportPublicTpl','activityReportDate']);
|
||||
$core->tpl->addValue('activityReportContent', ['activityReportPublicTpl','activityReportContent']);
|
||||
|
||||
class activityReportPublicUrl extends dcUrlHandlers
|
||||
{
|
||||
@ -28,8 +31,7 @@ class activityReportPublicUrl extends dcUrlHandlers
|
||||
{
|
||||
global $core, $_ctx;
|
||||
|
||||
if (!preg_match('/^(atom|rss2)\/(.+)$/',$args,$m))
|
||||
{
|
||||
if (!preg_match('/^(atom|rss2)\/(.+)$/', $args, $m)) {
|
||||
self::p404();
|
||||
return;
|
||||
}
|
||||
@ -37,8 +39,7 @@ class activityReportPublicUrl extends dcUrlHandlers
|
||||
self::p404();
|
||||
return;
|
||||
}
|
||||
if (!$core->activityReport->getSetting('active'))
|
||||
{
|
||||
if (!$core->activityReport->getSetting('active')) {
|
||||
self::p404();
|
||||
return;
|
||||
}
|
||||
@ -81,7 +82,7 @@ class activityReportPublicTpl
|
||||
$p .= "\$params['limit'] = array(0, \$params['limit']);\n";
|
||||
}
|
||||
|
||||
$res =
|
||||
return
|
||||
"<?php \n" .
|
||||
$p .
|
||||
'$_ctx->activityreport_params = $params; ' . "\n" .
|
||||
@ -89,8 +90,6 @@ class activityReportPublicTpl
|
||||
'while ($_ctx->activityreports->fetch()) : ?>'.$content.'<?php endwhile; ' .
|
||||
'$_ctx->activityreports = null; $_ctx->activityreport_params = null; ' . "\n" .
|
||||
"?>";
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function activityReportFeedID($attr)
|
||||
|
@ -11,7 +11,9 @@
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')){return;}
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->addUserAction(
|
||||
/* type */ 'tables',
|
||||
|
51
index.php
51
index.php
@ -11,9 +11,13 @@
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')){return;}
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!defined('ACTIVITY_REPORT')){return;}
|
||||
if (!defined('ACTIVITY_REPORT')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcPage::check('admin');
|
||||
|
||||
@ -21,12 +25,8 @@ require_once dirname(__FILE__).'/inc/lib.activity.report.index.php';
|
||||
|
||||
$tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : 'blog_settings';
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo __('Activity report'); ?></title>
|
||||
<?php
|
||||
echo
|
||||
echo '
|
||||
<html><head><title><?php echo __('Activity report'); ?></title>' .
|
||||
dcPage::jsLoad('js/_posts_list.js') .
|
||||
dcPage::jsToolBar() .
|
||||
dcPage::jsPageTabs($tab) .
|
||||
@ -34,38 +34,19 @@ dcPage::jsLoad('index.php?pf=activityReport/js/main.js').
|
||||
'<script type="text/javascript">'."\n//<![CDATA[\n" .
|
||||
dcPage::jsVar('jcToolsBox.prototype.text_wait',__('Please wait')) .
|
||||
dcPage::jsVar('jcToolsBox.prototype.section',$section) .
|
||||
"\n//]]>\n</script>\n";
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<h2><?php
|
||||
echo html::escapeHTML($core->blog->name).
|
||||
' › '.__('Activity report');
|
||||
?></h2>
|
||||
"\n//]]>\n</script>\n" . '
|
||||
</head><body>
|
||||
<h2>' . html::escapeHTML($core->blog->name) . ' › ' . __('Activity report') . '</h2>';
|
||||
|
||||
<?php
|
||||
if (!activityReport::hasMailer())
|
||||
{
|
||||
?>
|
||||
<p class="error"><?php echo __('This server has no mail function, activityReport not send email report.'); ?></p>
|
||||
<?php
|
||||
if (!activityReport::hasMailer()) {
|
||||
|
||||
echo '<p class="error">' . __('This server has no mail function, activityReport not send email report.') . '</p>';
|
||||
}
|
||||
activityReportLib::settingTab($core,__('Settings'));
|
||||
activityReportLib::logTab($core,__('Logs'));
|
||||
|
||||
if ($core->auth->isSuperAdmin())
|
||||
{
|
||||
if ($core->auth->isSuperAdmin()) {
|
||||
activityReportLib::settingTab($core, __('Super settings'), true);
|
||||
activityReportLib::logTab($core, __('Super logs'), true);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<hr class="clear"/>
|
||||
<p class="right">
|
||||
activityReport -
|
||||
<?php echo $core->plugins->moduleInfo('activityReport','version'); ?>
|
||||
<img alt="activityReport" src="index.php?pf=activityReport/icon.png" />
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
echo '</html>';
|
Loading…
Reference in New Issue
Block a user