Commit 0c9f1864 authored by Petr Skoda's avatar Petr Skoda
Browse files

add basic revision tracking support

parent 34660c59
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/book/db" VERSION="20110116" COMMENT="XMLDB file for Moodle mod_book"
<XMLDB PATH="mod/book/db" VERSION="20111009" COMMENT="XMLDB file for Moodle mod_book"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
......@@ -12,8 +12,9 @@
<FIELD NAME="intro" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" PREVIOUS="name" NEXT="introformat"/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="intro" NEXT="numbering"/>
<FIELD NAME="numbering" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="introformat" NEXT="customtitles"/>
<FIELD NAME="customtitles" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="numbering" NEXT="timecreated"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="customtitles" NEXT="timemodified"/>
<FIELD NAME="customtitles" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="numbering" NEXT="revision"/>
<FIELD NAME="revision" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="customtitles" NEXT="timecreated"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="revision" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated"/>
</FIELDS>
<KEYS>
......
......@@ -182,6 +182,20 @@ function xmldb_book_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2011090800, 'book');
}
if ($oldversion < 2011100900) {
// Define field revision to be added to book
$table = new xmldb_table('book');
$field = new xmldb_field('revision', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'customtitles');
// Conditionally launch add field revision
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// book savepoint reached
upgrade_mod_savepoint(true, 2011100900, 'book');
}
return true;
}
......@@ -74,8 +74,9 @@ if ($confirm) { // the operation was confirmed.
add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id, $book->id, $cm->id);
book_preload_chapters($book); //fix structure
redirect('view.php?id='.$cm->id);
$DB->set_field('book', 'revision', $book->revision+1, array('id'=>$book->id));
redirect('view.php?id='.$cm->id);
}
echo $OUTPUT->header();
......
......@@ -98,6 +98,7 @@ if ($mform->is_cancelled()) {
// store the files
$data = file_postupdate_standard_editor($data, 'content', $options, $context, 'mod_book', 'chapter', $data->id);
$DB->update_record('book_chapters', $data);
$DB->set_field('book', 'revision', $book->revision+1, array('id'=>$book->id));
add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->id, 'book '.$book->id);
add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id.'&chapterid='.$data->id, $book->id, $cm->id);
......
......@@ -85,6 +85,9 @@ function book_update_instance($data, $mform) {
$DB->update_record('book', $data);
$book = $DB->get_record('book', array('id'=>$data->id));
$DB->set_field('book', 'revision', $book->revision+1, array('id'=>$book->id));
return true;
}
......
......@@ -183,5 +183,7 @@ add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->
add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id, $book->id, $cm->id);
book_preload_chapters($book); // fix structure
$DB->set_field('book', 'revision', $book->revision+1, array('id'=>$book->id));
redirect('view.php?id='.$cm->id.'&chapterid='.$chapter->id);
......@@ -70,5 +70,7 @@ add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->
add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id, $book->id, $cm->id);
book_preload_chapters($book); // fix structure
$DB->set_field('book', 'revision', $book->revision+1, array('id'=>$book->id));
redirect('view.php?id='.$cm->id.'&chapterid='.$chapter->id);
......@@ -141,6 +141,10 @@ function toolbook_importhtml_import_chapters($package, $type, $book, $context, $
add_to_log($book->course, 'course', 'update mod', '../mod/book/view.php?id='.$context->instanceid, 'book '.$book->id);
$fs->delete_area_files($context->id, 'mod_book', 'importhtmltemp', 0);
// update the revision flag - this takes a long time, better to refetch the current value
$book = $DB->get_record('book', array('id'=>$book->id));
$DB->set_field('book', 'revision', $book->revision+1, array('id'=>$book->id));
}
function toolbook_importhtml_parse_headings($html) {
......
......@@ -25,10 +25,10 @@
defined('MOODLE_INTERNAL') || die;
$module->version = 2011100800; // The current module version (Date: YYYYMMDDXX)
$module->version = 2011100900; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2011070100; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
$module->component = 'mod_book'; // Full name of the plugin (used for diagnostics)
$module->maturity = MATURITY_BETA;
$module->release = "2.1dev (20111008)"; // User-friendly version number
$module->release = "2.1dev (20111009)"; // User-friendly version number
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment