1 | <?php |
---|
2 | |
---|
3 | $core->blog->settings->addNamespace('maintenance'); |
---|
4 | $maintenance = new dcMaintenance($core); |
---|
5 | $tasks = $maintenance->getTasks(); |
---|
6 | |
---|
7 | $combo_ts = array( |
---|
8 | __('Never') => 0, |
---|
9 | __('Every week') => 604800, |
---|
10 | __('Every two weeks') => 1209600, |
---|
11 | __('Every month') => 2592000, |
---|
12 | __('Every two months') => 5184000 |
---|
13 | ); |
---|
14 | |
---|
15 | if (!empty($_POST['save'])) { |
---|
16 | |
---|
17 | try { |
---|
18 | $core->blog->settings->maintenance->put( |
---|
19 | 'plugin_message', |
---|
20 | !empty($_POST['settings_plugin_message']), |
---|
21 | 'boolean', |
---|
22 | 'Display alert message of late tasks on plugin page', |
---|
23 | true, |
---|
24 | true |
---|
25 | ); |
---|
26 | |
---|
27 | foreach($tasks as $t) { |
---|
28 | if (!empty($_POST['settings_recall_type']) && $_POST['settings_recall_type'] == 'all') { |
---|
29 | $ts = $_POST['settings_recall_time']; |
---|
30 | } |
---|
31 | else { |
---|
32 | $ts = empty($_POST['settings_ts_'.$t->id()]) ? 0 : $_POST['settings_ts_'.$t->id()]; |
---|
33 | } |
---|
34 | $core->blog->settings->maintenance->put( |
---|
35 | 'ts_'.$t->id(), |
---|
36 | abs((integer) $ts), |
---|
37 | 'integer', |
---|
38 | sprintf('Recall time for task %s', $t->id()), |
---|
39 | true, |
---|
40 | $t->blog() |
---|
41 | ); |
---|
42 | } |
---|
43 | |
---|
44 | http::redirect($list->getPageURL('module=maintenance&conf=1&done=1')); |
---|
45 | } |
---|
46 | catch(Exception $e) { |
---|
47 | $core->error->add($e->getMessage()); |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | echo |
---|
52 | '<p>'.__('Manage alert for maintenance task.').'</p>'. |
---|
53 | |
---|
54 | '<h4 class="pretty-title">'.__('Activation').'</h4>'. |
---|
55 | '<p><label for="settings_plugin_message" class="classic">'. |
---|
56 | form::checkbox('settings_plugin_message', 1, $core->blog->settings->maintenance->plugin_message). |
---|
57 | __('Display alert messages on late tasks').'</label></p>'. |
---|
58 | |
---|
59 | '<p class="info">'.sprintf( |
---|
60 | __('You can place list of late tasks on your %s.'), |
---|
61 | '<a href="preferences.php#user-favorites">'.__('Dashboard').'</a>' |
---|
62 | ).'</p>'. |
---|
63 | |
---|
64 | '<h4 class="pretty-title vertical-separator">'.__('Frequency').'</h4>'. |
---|
65 | |
---|
66 | '<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_all'), 'all').' '. |
---|
67 | '<label class="classic" for="settings_recall_all">'. |
---|
68 | '<strong>'.__('Use one recall time for all tasks').'</strong></label>'. |
---|
69 | |
---|
70 | '<p class="field wide vertical-separator"><label for="settings_recall_time">'.__('Recall time for all tasks:').'</label>'. |
---|
71 | form::combo('settings_recall_time', $combo_ts, 'seperate', 'recall-for-all'). |
---|
72 | '</p>'. |
---|
73 | |
---|
74 | '<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_separate'), 'separate', 1).' '. |
---|
75 | '<label class="classic" for="settings_recall_separate">'. |
---|
76 | '<strong>'.__('Use one recall time per task').'</strong></label>'; |
---|
77 | |
---|
78 | foreach($tasks as $t) |
---|
79 | { |
---|
80 | echo |
---|
81 | '<div class="two-boxes">'. |
---|
82 | |
---|
83 | '<p class="field wide"><label for="settings_ts_'.$t->id().'">'.$t->task().'</label>'. |
---|
84 | form::combo('settings_ts_'.$t->id(), $combo_ts, $t->ts(), 'recall-per-task'). |
---|
85 | '</p>'. |
---|
86 | |
---|
87 | '</div>'; |
---|
88 | } |
---|