[2163] | 1 | <?php |
---|
[2165] | 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
| 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
| 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
[2182] | 12 | if (!defined('DC_CONTEXT_MODULE')) { return; } |
---|
[2163] | 13 | |
---|
| 14 | $core->blog->settings->addNamespace('maintenance'); |
---|
| 15 | $maintenance = new dcMaintenance($core); |
---|
| 16 | $tasks = $maintenance->getTasks(); |
---|
| 17 | |
---|
| 18 | $combo_ts = array( |
---|
| 19 | __('Never') => 0, |
---|
| 20 | __('Every week') => 604800, |
---|
| 21 | __('Every two weeks') => 1209600, |
---|
| 22 | __('Every month') => 2592000, |
---|
| 23 | __('Every two months') => 5184000 |
---|
| 24 | ); |
---|
| 25 | |
---|
| 26 | if (!empty($_POST['save'])) { |
---|
| 27 | |
---|
| 28 | try { |
---|
| 29 | $core->blog->settings->maintenance->put( |
---|
| 30 | 'plugin_message', |
---|
| 31 | !empty($_POST['settings_plugin_message']), |
---|
| 32 | 'boolean', |
---|
| 33 | 'Display alert message of late tasks on plugin page', |
---|
| 34 | true, |
---|
| 35 | true |
---|
| 36 | ); |
---|
| 37 | |
---|
| 38 | foreach($tasks as $t) { |
---|
| 39 | if (!empty($_POST['settings_recall_type']) && $_POST['settings_recall_type'] == 'all') { |
---|
| 40 | $ts = $_POST['settings_recall_time']; |
---|
| 41 | } |
---|
| 42 | else { |
---|
| 43 | $ts = empty($_POST['settings_ts_'.$t->id()]) ? 0 : $_POST['settings_ts_'.$t->id()]; |
---|
| 44 | } |
---|
| 45 | $core->blog->settings->maintenance->put( |
---|
| 46 | 'ts_'.$t->id(), |
---|
| 47 | abs((integer) $ts), |
---|
| 48 | 'integer', |
---|
| 49 | sprintf('Recall time for task %s', $t->id()), |
---|
| 50 | true, |
---|
| 51 | $t->blog() |
---|
| 52 | ); |
---|
| 53 | } |
---|
[2227] | 54 | |
---|
| 55 | dcPage::addSuccessNotice(__('Maintenance plugin has been successfully configured.')); |
---|
| 56 | http::redirect($list->getURL('module=maintenance&conf=1')); |
---|
[2163] | 57 | } |
---|
| 58 | catch(Exception $e) { |
---|
| 59 | $core->error->add($e->getMessage()); |
---|
| 60 | } |
---|
| 61 | } |
---|
| 62 | |
---|
[2227] | 63 | echo |
---|
| 64 | '<p>'.__('Set up reminders for maintenance tasks.').'</p>'. |
---|
[2163] | 65 | |
---|
[2227] | 66 | '<h4 class="pretty-title">'.__('Activation').'</h4>'. |
---|
| 67 | '<p><label for="settings_plugin_message" class="classic">'. |
---|
| 68 | form::checkbox('settings_plugin_message', 1, $core->blog->settings->maintenance->plugin_message). |
---|
| 69 | __('Display alert messages on late tasks').'</label></p>'. |
---|
[2163] | 70 | |
---|
[2227] | 71 | '<p class="info">'.sprintf( |
---|
| 72 | __('You can place list of late tasks on your %s.'), |
---|
| 73 | '<a href="preferences.php#user-favorites">'.__('Dashboard').'</a>' |
---|
| 74 | ).'</p>'. |
---|
[2163] | 75 | |
---|
[2227] | 76 | '<h4 class="pretty-title vertical-separator">'.__('Frequency').'</h4>'. |
---|
[2163] | 77 | |
---|
[2227] | 78 | '<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_all'), 'all').' '. |
---|
| 79 | '<label class="classic" for="settings_recall_all">'. |
---|
| 80 | '<strong>'.__('Use one recall time for all tasks').'</strong></label>'. |
---|
[2163] | 81 | |
---|
[2227] | 82 | '<p class="field wide vertical-separator"><label for="settings_recall_time">'.__('Recall time for all tasks:').'</label>'. |
---|
| 83 | form::combo('settings_recall_time', $combo_ts, 'seperate', 'recall-for-all'). |
---|
| 84 | '</p>'. |
---|
| 85 | |
---|
| 86 | '<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_separate'), 'separate', 1).' '. |
---|
| 87 | '<label class="classic" for="settings_recall_separate">'. |
---|
| 88 | '<strong>'.__('Use one recall time per task').'</strong></label>'; |
---|
| 89 | |
---|
| 90 | foreach($tasks as $t) |
---|
| 91 | { |
---|
| 92 | echo |
---|
| 93 | '<div class="two-boxes">'. |
---|
| 94 | |
---|
| 95 | '<p class="field wide"><label for="settings_ts_'.$t->id().'">'.$t->task().'</label>'. |
---|
| 96 | form::combo('settings_ts_'.$t->id(), $combo_ts, $t->ts(), 'recall-per-task'). |
---|
[2163] | 97 | '</p>'. |
---|
| 98 | |
---|
[2227] | 99 | '</div>'; |
---|
| 100 | } |
---|