Skip to content

Commit

Permalink
MDL-64588 comment: Return whether the user can post in a comments area
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva authored and snake committed Oct 1, 2019
1 parent 9528b1f commit 2234b6c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions comment/classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public static function get_comments($contextlevel, $instanceid, $component, $ite
'comments' => $comments,
'count' => $commentobject->count(),
'perpage' => (!empty($CFG->commentsperpage)) ? $CFG->commentsperpage : 15,
'canpost' => $commentobject->can_post(),
'warnings' => $warnings
);
return $results;
Expand Down Expand Up @@ -164,6 +165,7 @@ public static function get_comments_returns() {
),
'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()
)
);
Expand Down
1 change: 1 addition & 0 deletions comment/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public function test_get_comments() {
$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']);
Expand Down
2 changes: 1 addition & 1 deletion comment/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 2234b6c

Please sign in to comment.