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( + '' , + $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 ' '; +} + +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 + '' .
+ '' .
+ __('Rss2 feed for activity on this blog') . '
' .
+ '' .
+ '' .
+ __('Atom feed for activity on this blog') . '
' . +form::combo('interval', $combo_interval, $report->getSetting('interval')) . '
+ + +' . __('Separate multiple email addresses with a semicolon ";"') . '
+ +' . +form::combo('mailformat', $combo_format, $report->getSetting('mailformat')) . '
+ +' . __('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 ' +' . __('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 '