diff --git a/_config.php b/_config.php index 0322d49..66a373b 100644 --- a/_config.php +++ b/_config.php @@ -15,13 +15,204 @@ if (!defined('DC_CONTEXT_MODULE')) { return null; } -if (!activityReport::hasMailer()) { +$report =& $core->activityReport; +$super = $core->auth->isSuperAdmin() && !empty($_REQUEST['super']); +$redir = empty($_REQUEST['redir']) ? $list->getURL() . '#plugins' : $_REQUEST['redir']; - echo '

' . __('This server has no mail function, activityReport not send email report.') . '

'; +$combo_interval = [ + __('every hour') => 3600, + __('every 2 hours') => 7200, + __('2 times by day') => 43200, + __('every day') => 86400, + __('every 2 days') => 172800, + __('every week') => 604800 +]; + +$combo_obselete = [ + __('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_format = [ + __('Plain text') => 'plain', + __('HTML') => 'html' +]; + +if (!empty($_POST['save'])) { + try { + $report->setSetting('active', !empty($_POST['active'])); + $report->setSetting('dashboardItem', !empty($_POST['dashboardItem'])); + if (in_array($_POST['interval'], $combo_interval)) { + $report->setSetting('interval', (integer) $_POST['interval']); + } + if (in_array($_POST['obsolete'], $combo_obselete)) { + $report->setSetting('obsolete',(integer) $_POST['obsolete']); + } + $report->setSetting('mailinglist', explode(';',$_POST['mailinglist'])); + $report->setSetting('mailformat', isset($_POST['mailformat']) && $_POST['mailformat'] == 'html' ? 'html' : 'plain'); + $report->setSetting('dateformat', html::escapeHTML($_POST['dateformat'])); + $report->setSetting('requests', isset($_POST['requests']) ? $_POST['requests'] : []); + $report->setSetting('blogs', isset($_POST['blogs']) ? $_POST['blogs'] : []); + + if (!empty($_POST['force_report'])) { + $core->activityReport->needReport(true); + } + if (!empty($_POST['force_delete'])) { + $core->activityReport->deleteLogs(); + } + + dcPage::addSuccessNotice( + __('Configuration has been successfully updated.') + ); + $core->adminurl->redirect('admin.plugins', ['module' => 'activityReport', 'conf' => 1, 'super' => $super]); + } catch (Exception $e) { + $core->error->add($e->getMessage()); + } } -activityReportLib::settingTab($core, __('Settings')); +$last_report_ts = $report->getSetting('lastreport'); +if (!$last_report_ts) { + $last_report = __('never'); + $next_report = __('on new activity'); +} else { + $last_report = dt::str( + $core->blog->settings->system->date_format . ', ' . $core->blog->settings->system->time_format, + $last_report_ts, + $core->auth->getInfo('user_tz') + ); + $next_report = dt::str( + $core->blog->settings->system->date_format . ', ' . $core->blog->settings->system->time_format, + (integer) $report->getSetting('interval') + $next_report_ts, + $core->auth->getInfo('user_tz') + ); +} +$emails = implode(';', $report->getSetting('mailinglist')); if ($core->auth->isSuperAdmin()) { - activityReportLib::settingTab($core, __('Super settings'), true); -} \ No newline at end of file + echo sprintf( + '

%s

' , + $core->adminurl->get('admin.plugins', ['module' => 'activityReport', 'conf' => 1, 'super' => !$super]), + sprintf(__('Configure activity report for %s'), $super ? __('current blog') : _('all blogs')) + ); +} +if (activityReport::hasMailer()) { + echo '

' . + __('This server has no mail function, activityReport does not send email report.') . + '

'; +} + +echo ' +

' . __('Settings') . '

+
+

'; + +if (!$super) { + echo + '

'; +} +echo ' +

' . +form::combo('obsolete', $combo_obselete, $report->getSetting('obsolete')) . '

+ +

+

' . __('Use Dotclear date formaters. ex: %B %d at %H:%M') . '

' . + +form::hidden(['super'], $super); + +if (!$super) { + echo + '

'. __('RSS feed') . '' . + '' . + __('Rss2 feed for activity on this blog') . '
' . + '' . __('Atom feed') . '' . + '' . + __('Atom feed for activity on this blog') . '

'; +} +echo ' +
+ +

' . +form::combo('interval', $combo_interval, $report->getSetting('interval')) . '

+ +

+

' . __('Separate multiple email addresses with a semicolon ";"') . '

+ +

' . +form::combo('mailformat', $combo_format, $report->getSetting('mailformat')) . '

+ + +

+

'; + +if ($super) { + echo ' +

' . __('Blogs') . '

+

' . __('Select blogs to add to report') . '

'; + + $i = $j = 0; + $selected_blogs = $report->getSetting('blogs'); + $blogs = $core->getBlogs(); + $num_blogs = $blogs->count(); + while($blogs->fetch()) { + $blog_id = $core->con->escape($blogs->blog_id); + + echo ' +
+

+
'; + + $i++; + } + echo '
'; +} +echo ' +

' . __('Report') . '

+

' . __('Select actions by activity type to add to report') . '

'; + +$groups = $report->getGroups(); +$blog_request = $report->getSetting('requests'); + +$i = 0; +foreach($groups as $group_id => $group) { + echo '
'. __($group['title']) . '
'; + + foreach($group['actions'] as $action_id => $action) { + echo ' +

'; + } + echo '
'; +} +echo '
'; + +$report->unsetGlobal(); \ No newline at end of file diff --git a/inc/lib.activity.report.index.php b/inc/lib.activity.report.index.php index bc63759..2c05d5b 100644 --- a/inc/lib.activity.report.index.php +++ b/inc/lib.activity.report.index.php @@ -15,281 +15,6 @@ if (!defined('DC_CONTEXT_ADMIN')){return;} class activityReportLib { - public static function settingTab($core,$title,$global=false) - { - $O =& $core->activityReport; - $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : ''; - - if ($global) - { - $O->setGlobal(); - $t = 'super'; - } - else - { - $t = 'blog'; - } - - $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_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_format = array( - __('Plain text') => 'plain', - __('HTML') => 'html' - ); - - $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; - } - - # force to send report now - if (!empty($_POST[$t.'_force_report'])) - { - $core->activityReport->needReport(true); - $redirect = true; - } - - # force to delete all logs now - if (!empty($_POST[$t.'_force_delete'])) - { - $core->activityReport->deleteLogs(); - $redirect = true; - } - - if ($redirect) - { - http::redirect('plugin.php?p=activityReport&tab='.$t.'_settings&section'.$section); - } - - $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')); - - ?> -
- - - -

<?php echo __('RSS feed'); ?> - - -
- <?php echo __('Atom feed'); ?> - -

- - - -
- -
- -

-

- -

- -

- -

-

- -

- -

-

- -
    -
  • -
  • -
- -
- -
-
- getSetting('blogs'); - $blogs = $core->getBlogs(); - while($blogs->fetch()) - { - $blog_id = $core->con->escape($blogs->blog_id); - ?> -
-

-
- -
-
- -
-
- getGroups(); - $blog_request = $O->getSetting('requests'); - - $i = 0; - foreach($groups as $k_group => $v_group) - { - - ?> -
-

- $v_action) - { - ?> -

- -
-
-
-
- -

- - - - - - formNonce(); - ?> -

-
-
- unsetGlobal(); - } - public static function logTab($core,$title,$global=false) { $O =& $core->activityReport;