Dotclear

source: plugins/maintenance/_config.php @ 2182:eaaf345b04f3

Revision 2182:eaaf345b04f3, 3.0 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Enable complex loop (get, post, redirect) in themes and plugins configuration files

Line 
1<?php
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 -----------------------------------------
12if (!defined('DC_CONTEXT_MODULE')) { return; }
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
26if (!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          }
54         
55          http::redirect($list->getPageURL('module=maintenance&conf=1&done=1'));
56     }
57     catch(Exception $e) {
58          $core->error->add($e->getMessage());
59     }
60}
61
62     echo 
63     '<p>'.__('Manage alert for maintenance task.').'</p>'.
64
65     '<h4 class="pretty-title">'.__('Activation').'</h4>'.
66     '<p><label for="settings_plugin_message" class="classic">'.
67     form::checkbox('settings_plugin_message', 1, $core->blog->settings->maintenance->plugin_message).
68     __('Display alert messages on late tasks').'</label></p>'.
69
70     '<p class="info">'.sprintf(
71          __('You can place list of late tasks on your %s.'),
72          '<a href="preferences.php#user-favorites">'.__('Dashboard').'</a>'
73     ).'</p>'.
74
75     '<h4 class="pretty-title vertical-separator">'.__('Frequency').'</h4>'.
76
77     '<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_all'), 'all').' '.
78     '<label class="classic" for="settings_recall_all">'.
79     '<strong>'.__('Use one recall time for all tasks').'</strong></label>'.
80
81     '<p class="field wide vertical-separator"><label for="settings_recall_time">'.__('Recall time for all tasks:').'</label>'.
82     form::combo('settings_recall_time', $combo_ts, 'seperate', 'recall-for-all').
83     '</p>'.
84
85     '<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_separate'), 'separate', 1).' '.
86     '<label class="classic" for="settings_recall_separate">'.
87     '<strong>'.__('Use one recall time per task').'</strong></label>';
88
89     foreach($tasks as $t)
90     {
91          echo
92          '<div class="two-boxes">'.
93
94          '<p class="field wide"><label for="settings_ts_'.$t->id().'">'.$t->task().'</label>'.
95          form::combo('settings_ts_'.$t->id(), $combo_ts, $t->ts(), 'recall-per-task').
96          '</p>'.
97
98          '</div>';
99     }
Note: See TracBrowser for help on using the repository browser.

Sites map