Dotclear


Ignore:
Timestamp:
09/21/13 23:52:08 (12 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
default
Message:

Revamp plugin maintenance, step 4 bis, better place for settings according to boss and some typo, addresses #999

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/maintenance/inc/class.dc.maintenance.php

    r1969 r1984  
    2525class dcMaintenance 
    2626{ 
    27      private $core; 
     27     public $core; 
    2828     private $tasks = array(); 
    2929     private $tabs = array(); 
    3030     private $groups = array(); 
     31     private $logs = null; 
    3132 
    3233     /** 
     
    4445          $tabs = new ArrayObject(); 
    4546          $groups = new ArrayObject(); 
     47          $logs = $this->getLogs(); 
    4648 
    4749          # --BEHAVIOR-- dcMaintenanceRegister 
     
    7577               } 
    7678 
    77                $this->tasks[$task] = new $task($this->core, 'plugin.php?p=maintenance'); 
     79               $this->tasks[$task] = new $task($this, 'plugin.php?p=maintenance'); 
    7880          } 
    7981 
     
    230232 
    231233     /** 
    232       * Get expired tasks. 
    233       * 
    234       * @return     <b>array</b>   Array of expired Task ID / date 
    235       */ 
    236      public function getExpired() 
    237      { 
    238           // Retrieve logs from this task 
    239           $rs = $this->core->log->getLogs(array( 
    240                'log_table' => 'maintenance', 
    241                'blog_id' => 'all' 
    242           )); 
    243  
    244           $logs = array(); 
    245           while ($rs->fetch()) { 
    246                // Check if task exists 
    247                if (($task = $this->getTask($rs->log_msg)) !== null) { 
    248                     // Check if remider is used and tasks expired 
    249                     if ($task->ts() && strtotime($rs->log_dt) + $task->ts() < time()) { 
    250                          $logs[$rs->log_msg] = $rs->log_dt; 
    251                     } 
     234      * Get logs 
     235      * 
     236      * Return array( 
     237      *        task id => array( 
     238      *             timestamp of last execution, 
     239      *             logged on current blog or not 
     240      *        ) 
     241      * ) 
     242      * 
     243      * @return     <b>array</b> List of logged tasks 
     244      */ 
     245     public function getLogs() 
     246     { 
     247          if ($this->logs === null) { 
     248               $rs = $this->core->log->getLogs(array( 
     249                    'log_table' => 'maintenance', 
     250                    'blog_id' => 'all' 
     251               )); 
     252 
     253               $this->logs = array(); 
     254               while ($rs->fetch()) { 
     255                    $this->logs[$rs->log_msg] = array( 
     256                         'ts' => strtotime($rs->log_dt), 
     257                         'blog' => $rs->blog_id == $this->core->blog->id 
     258                    ); 
    252259               } 
    253260          } 
    254           return $logs; 
     261 
     262          return $this->logs; 
    255263     } 
    256264} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map