Skip to content

Commit

Permalink
MDL-56103 wiki: Return version in get_page_contents
Browse files Browse the repository at this point in the history
  • Loading branch information
dpalou committed Sep 27, 2016
1 parent 26162ef commit 7f98de7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion mod/wiki/classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,12 @@ public static function get_page_contents($pageid) {
$page->cachedcontent, FORMAT_HTML, $context->id, 'mod_wiki', 'attachments', $subwiki->id);
$returnedpage['caneditpage'] = wiki_user_can_edit($subwiki);

// Get page version.
$version = wiki_get_current_version($page->id);
if (!empty($version)) {
$returnedpage['version'] = $version->version;
}

$result = array();
$result['page'] = $returnedpage;
$result['warnings'] = $warnings;
Expand All @@ -660,7 +666,8 @@ public static function get_page_contents_returns() {
'title' => new external_value(PARAM_RAW, 'Page title.'),
'cachedcontent' => new external_value(PARAM_RAW, 'Page contents.'),
'contentformat' => new external_format_value('cachedcontent', VALUE_OPTIONAL),
'caneditpage' => new external_value(PARAM_BOOL, 'True if user can edit the page.')
'caneditpage' => new external_value(PARAM_BOOL, 'True if user can edit the page.'),
'version' => new external_value(PARAM_INT, 'Latest version of the page.', VALUE_OPTIONAL),
), 'Page'
),
'warnings' => new external_warnings()
Expand Down
6 changes: 4 additions & 2 deletions mod/wiki/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,8 @@ public function test_get_page_contents() {
'title' => $this->firstpage->title,
'cachedcontent' => $this->firstpage->cachedcontent,
'contentformat' => 1,
'caneditpage' => true
'caneditpage' => true,
'version' => 1
);

$result = mod_wiki_external::get_page_contents($this->firstpage->id);
Expand Down Expand Up @@ -1016,7 +1017,8 @@ public function test_get_page_contents_with_groups() {
'title' => $this->fpsepg1indstu->title,
'cachedcontent' => $this->fpsepg1indstu->cachedcontent,
'contentformat' => 1,
'caneditpage' => true
'caneditpage' => true,
'version' => 1
);

$result = mod_wiki_external::get_page_contents($this->fpsepg1indstu->id);
Expand Down
1 change: 1 addition & 0 deletions mod/wiki/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ information provided here is intended especially for developers.
* External functions that were returning file information now return the following file fields:
filename, filepath, mimetype, filesize, timemodified and fileurl.
Those fields are now marked as VALUE_OPTIONAL for backwards compatibility.
* External function get_page_contents now returns the page version. This new field is marked as VALUE_OPTIONAL for backwards compatibility.

=== 3.1 ===
* Added a new param $sort to wiki_get_page_list function. Default value behaves exactly like before (sort by title ASC).

0 comments on commit 7f98de7

Please sign in to comment.