Changeset 1940:0fb7e85337bf for plugins/maintenance/inc
- Timestamp:
- 09/18/13 10:51:42 (12 years ago)
- Branch:
- default
- Location:
- plugins/maintenance/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/maintenance/inc/class.dc.maintenance.php
r1925 r1940 137 137 return $res; 138 138 } 139 140 /** 141 * Set log for a task. 142 * 143 * @param id <b>string</b> Task ID 144 */ 145 public function setLog($id) 146 { 147 // Check if taks exists 148 if (!$this->getTask($id)) { 149 return null; 150 } 151 152 // Get logs from this task 153 $rs = $this->core->con->select ( 154 'SELECT log_id '. 155 'FROM '.$this->core->prefix.'log '. 156 "WHERE log_msg = '".$this->core->con->escape($id)."' ". 157 "AND log_table = 'maintenance' " 158 ); 159 160 $logs = array(); 161 while ($rs->fetch()) { 162 $logs[] = $rs->log_id; 163 } 164 165 // Delete old logs 166 if (!empty($logs)) { 167 $this->core->log->delLogs($logs); 168 } 169 170 // Add new log 171 $cur = $this->core->con->openCursor($this->core->prefix.'log'); 172 173 $cur->log_msg = $id; 174 $cur->log_table = 'maintenance'; 175 $cur->user_id = $this->core->auth->userID(); 176 177 $this->core->log->addLog($cur); 178 } 179 180 /** 181 * Delete all maintenance logs. 182 */ 183 public function delLogs() 184 { 185 // Retrieve logs from this task 186 $rs = $this->core->log->getLogs(array( 187 'log_table' => 'maintenance', 188 'blog_id' => 'all' 189 )); 190 191 $logs = array(); 192 while ($rs->fetch()) { 193 $logs[] = $rs->log_id; 194 } 195 196 // Delete old logs 197 if (!empty($logs)) { 198 $this->core->log->delLogs($logs); 199 } 200 } 201 202 /** 203 * Get expired task. 204 * 205 * @return <b>array</b> Array of expired Task ID / date 206 */ 207 public function getExpired() 208 { 209 // Retrieve logs from this task 210 $rs = $this->core->log->getLogs(array( 211 'log_table' => 'maintenance', 212 'blog_id' => 'all' 213 )); 214 215 $logs = array(); 216 while ($rs->fetch()) { 217 // Check if task exists 218 if (($task = $this->getTask($rs->log_msg)) !== null) { 219 // Check if tasks expired 220 if (strtotime($rs->log_dt) + $task->ts() < time()) { 221 $logs[$rs->log_msg] = $rs->log_dt; 222 } 223 } 224 } 225 return $logs; 226 } 139 227 } -
plugins/maintenance/inc/class.dc.maintenance.task.php
r1925 r1940 24 24 protected $p_url; 25 25 protected $code; 26 protected $ts = 604800; // one week 26 27 27 28 protected $id; … … 33 34 protected $error; 34 35 protected $success; 35 protected $reminder;36 36 37 37 /** … … 85 85 86 86 /** 87 * Get timestamp between maintenances. 88 * 89 * @return <b>intetger</b> Timestamp 90 */ 91 public function ts() 92 { 93 return abs((integer) $this->ts); 94 } 95 96 /** 87 97 * Get task ID. 88 98 * … … 165 175 } 166 176 167 /** @todo */168 public function reminder()169 {170 return null;171 }172 173 177 /** 174 178 * Get header.
Note: See TracChangeset
for help on using the changeset viewer.