From 2234b6c9dc0d2ede23a9a6a37293fcddbf9ca0d0 Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Wed, 13 Feb 2019 13:15:29 +0100 Subject: [PATCH] MDL-64588 comment: Return whether the user can post in a comments area --- comment/classes/external.php | 2 ++ comment/tests/externallib_test.php | 1 + comment/upgrade.txt | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/comment/classes/external.php b/comment/classes/external.php index b76483d75b9..22995e7d12e 100644 --- a/comment/classes/external.php +++ b/comment/classes/external.php @@ -131,6 +131,7 @@ class core_comment_external extends external_api { 'comments' => $comments, 'count' => $commentobject->count(), 'perpage' => (!empty($CFG->commentsperpage)) ? $CFG->commentsperpage : 15, + 'canpost' => $commentobject->can_post(), 'warnings' => $warnings ); return $results; @@ -164,6 +165,7 @@ class core_comment_external extends external_api { ), 'count' => new external_value(PARAM_INT, 'Total number of comments.', VALUE_OPTIONAL), 'perpage' => new external_value(PARAM_INT, 'Number of comments per page.', VALUE_OPTIONAL), + 'canpost' => new external_value(PARAM_BOOL, 'Whether the user can post in this comment area.', VALUE_OPTIONAL), 'warnings' => new external_warnings() ) ); diff --git a/comment/tests/externallib_test.php b/comment/tests/externallib_test.php index e9eb0c2b98b..b34a553720b 100644 --- a/comment/tests/externallib_test.php +++ b/comment/tests/externallib_test.php @@ -125,6 +125,7 @@ class core_comment_externallib_testcase extends externallib_advanced_testcase { $this->assertCount(2, $result['comments']); $this->assertEquals(2, $result['count']); $this->assertEquals(15, $result['perpage']); + $this->assertTrue($result['canpost']); $this->assertEquals($user->id, $result['comments'][0]['userid']); $this->assertEquals($user->id, $result['comments'][1]['userid']); diff --git a/comment/upgrade.txt b/comment/upgrade.txt index 2510a99b488..551e77d8302 100644 --- a/comment/upgrade.txt +++ b/comment/upgrade.txt @@ -4,4 +4,4 @@ information provided here is intended especially for developers. === 3.8 === * External function get_comments now returns the total count of comments and the number of comments per page. It also has a new parameter to indicate the sorting direction (defaulted to DESC). - + * The Webservice core_comment_get_comments now indicates if the current user can post comments in the requested area.