Dotclear


Ignore:
Timestamp:
09/22/13 02:49:48 (12 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
default
Message:

Revamp plugin maintenance, step 5, now open to admin user and various fixes, addresses #999

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/maintenance/index.php

    r1985 r1989  
    1212if (!defined('DC_CONTEXT_ADMIN')) { return; } 
    1313 
    14 dcPage::checkSuper(); 
    15  
    16 // main class 
     14// Set env 
     15 
     16$core->blog->settings->addNamespace('maintenance'); 
    1717 
    1818$maintenance = new dcMaintenance($core); 
    19 $core->blog->settings->addNamespace('maintenance'); 
    20  
    21 // Set var 
     19$tasks = $maintenance->getTasks(); 
    2220 
    2321$msg = ''; 
     
    2826 
    2927$code = empty($_POST['code']) ? null : (integer) $_POST['code']; 
    30 $tab = empty($_REQUEST['tab']) ? 'maintenance' : $_REQUEST['tab']; 
     28$tab = empty($_REQUEST['tab']) ? '' : $_REQUEST['tab']; 
    3129 
    3230// Save settings 
     
    3937               !empty($_POST['settings_plugin_message']),  
    4038               'boolean',  
    41                'Display alert message of expired tasks on plugin page',  
     39               'Display alert message of late tasks on plugin page',  
    4240               true,  
    4341               true 
    4442          ); 
    4543 
    46           foreach($maintenance->getTasks() as $t) { 
     44          foreach($tasks as $t) { 
    4745               if (!empty($_POST['settings_recall_time']) && $_POST['settings_recall_time'] == 'seperate') { 
    4846                    $ts = empty($_POST['settings_ts_'.$t->id()]) ? 0 : $_POST['settings_ts_'.$t->id()]; 
     
    5755                    sprintf('Recall time for task %s', $t->id()),  
    5856                    true,  
    59                     true 
     57                    $t->blog() 
    6058               ); 
    6159          } 
     
    138136</head> 
    139137<body>'; 
     138 
     139// Check if there is somthing to display according to user permissions 
     140if (empty($tasks)) { 
     141     echo dcPage::breadcrumb( 
     142          array( 
     143               __('Plugins') => '', 
     144               '<a href="'.$p_url.'">'.__('Maintenance').'</a>' => '', 
     145               '<span class="page-title">'.html::escapeHTML($task->name()).'</span>' => '' 
     146          ) 
     147     ). 
     148     '<p class="warn">'.__('You have not sufficient permissions to view this page.').'</p>'. 
     149     '</body></html>'; 
     150 
     151     return null; 
     152} 
    140153 
    141154// Success message 
     
    201214     { 
    202215          $res_group = ''; 
    203           foreach($maintenance->getGroups($core) as $group_id => $group_name) 
     216          foreach($maintenance->getGroups() as $group_id => $group_name) 
    204217          { 
    205218               $res_task = ''; 
    206                foreach($maintenance->getTasks($core) as $t) 
     219               foreach($tasks as $t) 
    207220               { 
    208221                    if ($t->group() != $group_id || $t->tab() != $tab_id) { 
     
    256269               form::hidden(array('tab'), $tab_id). 
    257270               $core->formNonce().'</p>'. 
    258                '<p class="form-note info">'.__('This may take a very long time.').'.</p>'. 
     271               '<p class="form-note info">'.__('This may take a very long time.').'</p>'. 
    259272               '</form>'. 
    260273               '</div>'; 
     
    264277     // Advanced tasks (that required a tab) 
    265278 
    266      foreach($maintenance->getTasks($core) as $t) 
     279     foreach($tasks as $t) 
    267280     { 
    268281          if ($t->group() !== null) { 
     
    292305     '<p><label for="settings_plugin_message" class="classic">'. 
    293306     form::checkbox('settings_plugin_message', 1, $core->blog->settings->maintenance->plugin_message). 
    294      __('Display alert messages on expired tasks').'</label></p>'. 
     307     __('Display alert messages on late tasks').'</label></p>'. 
    295308 
    296309     '<p><label for="settings_recall_time">'.__('Recall time for all tasks:').'</label>'. 
     
    300313     '<p>'.__('Recall time per task:').'</p>'; 
    301314 
    302      foreach($maintenance->getTasks($core) as $t) 
     315     foreach($tasks as $t) 
    303316     { 
    304317          echo 
     
    319332     '</form>'. 
    320333     '<p class="info">'.sprintf( 
    321           __('You can place list of expired tasks on your %s.'), 
     334          __('You can place list of late tasks on your %s.'), 
    322335          '<a href="preferences.php#user-favorites">'.__('Dashboard').'</a>' 
    323336     ).'</a></p>'. 
Note: See TracChangeset for help on using the changeset viewer.

Sites map