blog->settings->addNamespace('maintenance'); $maintenance = new dcMaintenance($core); $tasks = $maintenance->getTasks(); $msg = ''; $headers = ''; $p_url = 'plugin.php?p=maintenance'; $task = null; $expired = array(); $code = empty($_POST['code']) ? null : (integer) $_POST['code']; $tab = empty($_REQUEST['tab']) ? '' : $_REQUEST['tab']; // Save settings if (!empty($_POST['settings'])) { try { $core->blog->settings->maintenance->put( 'plugin_message', !empty($_POST['settings_plugin_message']), 'boolean', 'Display alert message of late tasks on plugin page', true, true ); foreach($tasks as $t) { if (!empty($_POST['settings_recall_type']) && $_POST['settings_recall_type'] == 'all') { $ts = $_POST['settings_recall_time']; } else { $ts = empty($_POST['settings_ts_'.$t->id()]) ? 0 : $_POST['settings_ts_'.$t->id()]; } $core->blog->settings->maintenance->put( 'ts_'.$t->id(), abs((integer) $ts), 'integer', sprintf('Recall time for task %s', $t->id()), true, $t->blog() ); } http::redirect($p_url.'&done=1&tab='.$tab.'#'.$tab); } catch(Exception $e) { $core->error->add($e->getMessage()); } } // Get task object if (!empty($_REQUEST['task'])) { $task = $maintenance->getTask($_REQUEST['task']); if ($task === null) { $core->error->add('Unknow task ID'); } $task->code($code); } // Execute task if ($task && !empty($_POST['task']) && $task->id() == $_POST['task']) { try { $code = $task->execute(); if (false === $code) { throw new Exception($task->error()); } if (true === $code) { $maintenance->setLog($task->id()); http::redirect($p_url.'&task='.$task->id().'&done=1&tab='.$tab.'#'.$tab); } } catch (Exception $e) { $core->error->add($e->getMessage()); } } // Combos $combo_ts = array( __('Never') => 0, __('Every week') => 604800, __('Every two weeks') => 1209600, __('Every month') => 2592000, __('Every two months') => 5184000 ); // Display page echo '
'.__('You have not sufficient permissions to view this page.').'
'. ''; return null; } // Success message if (!empty($_GET['done']) && $tab == 'settings') { $msg = dcPage::success(__('Settings successfully updated'), true, true, false); } elseif (!empty($_GET['done']) && $task) { $msg = dcPage::success($task->success(), true, true, false); } if ($task && ($res = $task->step()) !== null) { // Page title echo dcPage::breadcrumb( array( __('Plugins') => '', ''.__('Maintenance').'' => '', ''.html::escapeHTML($task->name()).'' => '' ) ); echo $msg; // Intermediate task (task required several steps) echo ''. ''.__('Back').''. '
'. ''.form::radio(array('task', $t->id()), $t->id()).' '.
'';
// Expired task alert message
$ts = $t->expired();
if ($core->blog->settings->maintenance->plugin_message && $ts !== false) {
if ($ts === null) {
$res_task .=
'
'.
__('This task has never been executed.').' '.
__('You should execute it now.').'';
}
else {
$res_task .=
'
'.sprintf(
__('Last execution of this task was on %s.'),
dt::str($core->blog->settings->system->date_format, $ts).' '.
dt::str($core->blog->settings->system->time_format, $ts)
).' '.
__('You should execute it now.').'';
}
}
$res_task .= '
'.$tab_obj->option('summary').'
' : ''). ''. '