Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
0c9f1864
Commit
0c9f1864
authored
Oct 09, 2011
by
Petr Skoda
Browse files
add basic revision tracking support
parent
34660c59
Changes
9
Hide whitespace changes
Inline
Side-by-side
db/install.xml
View file @
0c9f1864
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB
PATH=
"mod/book/db"
VERSION=
"2011
0116
"
COMMENT=
"XMLDB file for Moodle mod_book"
<XMLDB
PATH=
"mod/book/db"
VERSION=
"2011
1009
"
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>
...
...
db/upgrade.php
View file @
0c9f1864
...
...
@@ -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
;
}
delete.php
View file @
0c9f1864
...
...
@@ -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
();
...
...
edit.php
View file @
0c9f1864
...
...
@@ -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
);
...
...
lib.php
View file @
0c9f1864
...
...
@@ -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
;
}
...
...
move.php
View file @
0c9f1864
...
...
@@ -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
);
show.php
View file @
0c9f1864
...
...
@@ -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
);
tool/importhtml/locallib.php
View file @
0c9f1864
...
...
@@ -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
)
{
...
...
version.php
View file @
0c9f1864
...
...
@@ -25,10 +25,10 @@
defined
(
'MOODLE_INTERNAL'
)
||
die
;
$module
->
version
=
2011100
8
00
;
// The current module version (Date: YYYYMMDDXX)
$module
->
version
=
2011100
9
00
;
// 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 (2011100
8
)"
;
// User-friendly version number
$module
->
release
=
"2.1dev (2011100
9
)"
;
// User-friendly version number
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment