/// First, me get all the distinct backups for that course in backup_log
$executions = $DB->get_records_sql("SELECT DISTINCT laststarttime,laststarttime
FROM {backup_log}
- WHERE courseid = ?
- ORDER BY laststarttime DESC", array($courseid));
+ WHERE courseid = ? AND backuptype = ?
+ ORDER BY laststarttime DESC", array($courseid,'scheduledbackup'));
/// Iterate over backup executions
if (!$executions) {
echo "</tr>";
$logs = $DB->get_records_sql("SELECT *
FROM {backup_log}
- WHERE courseid = ? AND laststarttime = ?
- ORDER BY id", array($courseid, $execution->laststarttime));
+ WHERE courseid = ? AND laststarttime = ? AND backuptype = ?
+ ORDER BY id", array($courseid, $execution->laststarttime,'scheduledbackup'));
if ($logs) {
foreach ($logs as $log) {
echo "<tr>";
//for info in backup_logs to unlock status as necessary
$timetosee = 1800; //Half an hour looking for activity
$timeafter = time() - $timetosee;
- $numofrec = $DB->count_records_select ("backup_log","time > ?", array($timeafter));
+ $numofrec = $DB->count_records_select ("backup_log","time > ? AND backuptype = ?", array($timeafter, 'scheduledbackup'));
if (!$numofrec) {
$timetoseemin = $timetosee/60;
mtrace(" No activity in last ".$timetoseemin." minutes. Unlocking status");
global $DB;
if ($starttime) {
- $log = new object();
- $log->courseid = $courseid;
- $log->time = time();
- $log->laststarttime = $starttime;
- $log->info = $message;
-
- $DB->insert_record("backup_log", $log);
+ add_to_backup_log($starttime,$courseid,$message, 'scheduledbackup');
}
}
backup_add_static_preferences($preferences);
return $preferences;
}
+ function add_to_backup_log($starttime,$courseid,$message, $backuptype) {
+ global $DB;
+ $log = new object();
+ $log->courseid = $courseid;
+ $log->time = time();
+ $log->laststarttime = $starttime;
+ $log->info = $message;
+ $log->backuptype = $backuptype;
+ $DB->insert_record('backup_log', $log);
+ }
?>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="time"/>
<FIELD NAME="time" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid" NEXT="laststarttime"/>
<FIELD NAME="laststarttime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="time" NEXT="info"/>
- <FIELD NAME="info" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="laststarttime"/>
+ <FIELD NAME="info" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="laststarttime" NEXT="backuptype"/>
+ <FIELD NAME="backuptype" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="info"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="courseid"/>
/// Main savepoint reached
upgrade_main_savepoint($result, 2009021800);
}
+ if ($result && $oldversion < 2009021801) {
+ /// Define field backuptype to be added to backup_log
+ $table = new XMLDBTable('backup_log');
+ $field = new XMLDBField('backuptype');
+ $field = new xmldb_field('backuptype', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, null, null, 'info');
+ /// Conditionally Launch add field backuptype and set all old records as 'scheduledbackup' records.
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ $DB->execute("UPDATE {backup_log} SET backuptype='scheduledbackup'");
+ }
+ /// Main savepoint reached
+ upgrade_main_savepoint($result, 2009021801);
+ }
return $result;
}
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2009021800; // YYYYMMDD = date of the last version bump
+ $version = 2009021801; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20090303)'; // Human-friendly version name