Merge branch 'MDL-57627-master' of git://github.com/crazyserver/moodle

This commit is contained in:
Dan Poltawski 2017-01-16 08:22:25 +00:00
commit 0893bb0897
3 changed files with 12 additions and 1 deletions

View File

@ -97,6 +97,7 @@ class mod_forum_external extends external_api {
$forum->numdiscussions = forum_count_discussions($forum, $cm, $course);
$forum->cmid = $forum->coursemodule;
$forum->cancreatediscussions = forum_user_can_post_discussion($forum, null, -1, $cm, $context);
$forum->istracked = forum_tp_is_tracked($forum);
// Add the forum to the array to return.
$arrforums[$forum->id] = $forum;
@ -144,6 +145,7 @@ class mod_forum_external extends external_api {
'numdiscussions' => new external_value(PARAM_INT, 'Number of discussions in the forum', VALUE_OPTIONAL),
'cancreatediscussions' => new external_value(PARAM_BOOL, 'If the user can create discussions', VALUE_OPTIONAL),
'lockdiscussionafter' => new external_value(PARAM_INT, 'After what period a discussion is locked', VALUE_OPTIONAL),
'istracked' => new external_value(PARAM_BOOL, 'If the user is tracking the forum', VALUE_OPTIONAL),
), 'forum'
)
);

View File

@ -28,6 +28,7 @@ defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/webservice/tests/helpers.php');
require_once($CFG->dirroot . '/mod/forum/lib.php');
class mod_forum_external_testcase extends externallib_advanced_testcase {
@ -59,7 +60,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
$this->resetAfterTest(true);
// Create a user.
$user = self::getDataGenerator()->create_user();
$user = self::getDataGenerator()->create_user(array('trackforums' => 1));
// Set to the user.
self::setUser($user);
@ -72,12 +73,14 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
$record = new stdClass();
$record->introformat = FORMAT_HTML;
$record->course = $course1->id;
$record->trackingtype = FORUM_TRACKING_FORCED;
$forum1 = self::getDataGenerator()->create_module('forum', $record);
// Second forum.
$record = new stdClass();
$record->introformat = FORMAT_HTML;
$record->course = $course2->id;
$record->trackingtype = FORUM_TRACKING_OFF;
$forum2 = self::getDataGenerator()->create_module('forum', $record);
$forum2->introfiles = [];
@ -90,6 +93,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
// Expect one discussion.
$forum1->numdiscussions = 1;
$forum1->cancreatediscussions = true;
$forum1->istracked = true;
$forum1->introfiles = [];
$record = new stdClass();
@ -102,6 +106,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
$forum2->numdiscussions = 2;
// Default limited role, no create discussion capability enabled.
$forum2->cancreatediscussions = false;
$forum2->istracked = false;
// Check the forum was correctly created.
$this->assertEquals(2, $DB->count_records_select('forum', 'id = :forum1 OR id = :forum2',

View File

@ -1,6 +1,10 @@
This files describes API changes in /mod/forum/*,
information provided here is intended especially for developers.
=== 3.3 ===
* External function get_forums_by_courses now returns and additional field "istracked" that indicates if the user
is tracking the related forum.
=== 3.2 ===
* The setting $CFG->forum_replytouser has been removed in favour of a centralized noreplyaddress setting.
Please use $CFG->noreplyaddress setting instead.