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.task.php

    r1969 r1984  
    2121class dcMaintenanceTask 
    2222{ 
     23     protected $maintenance; 
    2324     protected $core; 
    2425     protected $p_url; 
    2526     protected $code; 
    26      protected $ts = 604800; // one week 
     27     protected $ts = 0; 
     28     protected $expired = 0; 
    2729     protected $ajax = false; 
     30     protected $blog = false; 
    2831 
    2932     protected $id; 
     
    4346      * use method init() to do it. 
    4447      * 
    45       * @param core <b>dcCore</b>  dcCore instance 
     48      * @param maintenance    <b>dcMaintenance</b>     dcMaintenance instance 
    4649      * @param p_url     <b>string</b>  Maintenance plugin url 
    4750      */ 
    48      public function __construct($core, $p_url) 
    49      { 
    50           $this->core =& $core; 
     51     public function __construct($maintenance, $p_url) 
     52     { 
     53          $this->maintenance = $maintenance; 
     54          $this->core = $maintenance->core; 
    5155          $this->init(); 
    5256 
     
    6468          } 
    6569 
    66           $core->auth->user_prefs->addWorkspace('maintenance'); 
    67           $ts = $core->auth->user_prefs->maintenance->get('ts_'.$this->id); 
    68            
     70          $this->core->blog->settings->addNamespace('maintenance'); 
     71          $ts = $this->core->blog->settings->maintenance->get('ts_'.$this->id); 
     72 
    6973          $this->ts = abs((integer) $ts); 
    7074     } 
     
    99103     { 
    100104          return $this->ts === false ? false : abs((integer) $this->ts); 
     105     } 
     106 
     107     /** 
     108      * Get task expired. 
     109      * 
     110      * This return: 
     111      * - Timstamp of last update if it expired 
     112      * - False if it not expired or has no recall time 
     113      * - Null if it has never been executed 
     114      * 
     115      * @return     <b>mixed</b>   Last update 
     116      */ 
     117     public function expired() 
     118     { 
     119          if ($this->expired === 0) { 
     120               if (!$this->ts()) { 
     121                    $this->expired = false; 
     122               } 
     123               else { 
     124                    $this->expired = null; 
     125                    $logs = array(); 
     126                    foreach($this->maintenance->getLogs() as $id => $log) 
     127                    { 
     128                         if ($id != $this->id() || $this->blog && !$log['blog']) { 
     129                              continue; 
     130                         } 
     131 
     132                         $this->expired = $log['ts'] + $this->ts() < time() ? $log['ts'] : false; 
     133                    } 
     134               } 
     135          } 
     136          return $this->expired; 
    101137     } 
    102138 
     
    251287     protected function log() 
    252288     { 
    253           $maintenance = new dcMaintenance($this->core); 
    254           $maintenance->setLog($this->id); 
     289          $this->maintenance->setLog($this->id); 
    255290     } 
    256291} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map