Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

External forum API

Copyright: 2012 Mark Nelson <markn@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 2777 lines (126 kb)
Included or required:0 times
Referenced: 21 times
Includes or requires: 0 files

Defines 1 class

mod_forum_external:: (62 methods):
  get_forums_by_courses_parameters()
  get_forums_by_courses()
  get_forums_by_courses_returns()
  get_discussion_posts()
  get_discussion_posts_parameters()
  get_discussion_posts_returns()
  get_forum_discussion_posts_parameters()
  get_forum_discussion_posts()
  get_forum_discussion_posts_returns()
  get_forum_discussion_posts_is_deprecated()
  get_forum_discussions_paginated_is_deprecated()
  get_forum_discussions_paginated_parameters()
  get_forum_discussions_paginated()
  get_forum_discussions_paginated_returns()
  get_forum_discussions_parameters()
  get_forum_discussions()
  get_forum_discussions_returns()
  view_forum_parameters()
  view_forum()
  view_forum_returns()
  view_forum_discussion_parameters()
  view_forum_discussion()
  view_forum_discussion_returns()
  add_discussion_post_parameters()
  add_discussion_post()
  add_discussion_post_returns()
  toggle_favourite_state()
  toggle_favourite_state_returns()
  toggle_favourite_state_parameters()
  add_discussion_parameters()
  add_discussion()
  add_discussion_returns()
  can_add_discussion_parameters()
  can_add_discussion()
  can_add_discussion_returns()
  get_forum_access_information_parameters()
  get_forum_access_information()
  get_forum_access_information_returns()
  set_subscription_state()
  set_subscription_state_parameters()
  set_subscription_state_returns()
  set_lock_state()
  set_lock_state_parameters()
  set_lock_state_returns()
  set_pin_state()
  set_pin_state_parameters()
  set_pin_state_returns()
  delete_post_parameters()
  delete_post()
  delete_post_returns()
  get_discussion_posts_by_userid()
  get_discussion_posts_by_userid_parameters()
  get_discussion_posts_by_userid_returns()
  get_discussion_post_parameters()
  get_discussion_post()
  get_discussion_post_returns()
  prepare_draft_area_for_post_parameters()
  prepare_draft_area_for_post()
  prepare_draft_area_for_post_returns()
  update_discussion_post_parameters()
  update_discussion_post()
  update_discussion_post_returns()


Class: mod_forum_external  - X-Ref

get_forums_by_courses_parameters()   X-Ref
Describes the parameters for get_forum.

return: external_function_parameters

get_forums_by_courses($courseids = array()   X-Ref
Returns a list of forums in a provided list of courses,
if no list is provided all forums that the user can view
will be returned.

param: array $courseids the course ids
return: array the forum details

get_forums_by_courses_returns()   X-Ref
Describes the get_forum return value.

return: external_single_structure

get_discussion_posts(int $discussionid, ?string $sortby, ?string $sortdirection)   X-Ref
Get the forum posts in the specified discussion.

param: int $discussionid
param: string $sortby
param: string $sortdirection
return: array

get_discussion_posts_parameters()   X-Ref
Describe the post parameters.

return: external_function_parameters

get_discussion_posts_returns()   X-Ref
Describe the post return format.

return: external_single_structure

get_forum_discussion_posts_parameters()   X-Ref
Describes the parameters for get_forum_discussion_posts.

return: external_function_parameters

get_forum_discussion_posts($discussionid, $sortby = "created", $sortdirection = "DESC")   X-Ref
Returns a list of forum posts for a discussion

param: int $discussionid the post ids
param: string $sortby sort by this element (id, created or modified)
param: string $sortdirection sort direction: ASC or DESC
return: array the forum post details

get_forum_discussion_posts_returns()   X-Ref
Describes the get_forum_discussion_posts return value.

return: external_single_structure

get_forum_discussion_posts_is_deprecated()   X-Ref
Mark the get_forum_discussion_posts web service as deprecated.

return: bool

get_forum_discussions_paginated_is_deprecated()   X-Ref
Mark the get_forum_discussions_paginated web service as deprecated.

return: bool

get_forum_discussions_paginated_parameters()   X-Ref
Describes the parameters for get_forum_discussions_paginated.

return: external_function_parameters

get_forum_discussions_paginated($forumid, $sortby = 'timemodified', $sortdirection = 'DESC',$page = -1, $perpage = 0)   X-Ref
Returns a list of forum discussions optionally sorted and paginated.

param: int $forumid the forum instance id
param: string $sortby sort by this element (id, timemodified, timestart or timeend)
param: string $sortdirection sort direction: ASC or DESC
param: int $page page number
param: int $perpage items per page
return: array the forum discussion details including warnings

get_forum_discussions_paginated_returns()   X-Ref
Describes the get_forum_discussions_paginated return value.

return: external_single_structure

get_forum_discussions_parameters()   X-Ref
Describes the parameters for get_forum_discussions.

return: external_function_parameters

get_forum_discussions(int $forumid, ?int $sortorder = -1, ?int $page = -1,?int $perpage = 0, ?int $groupid = 0)   X-Ref
Returns a list of forum discussions optionally sorted and paginated.

param: int $forumid the forum instance id
param: int $sortorder The sort order
param: int $page page number
param: int $perpage items per page
param: int $groupid the user course group
return: array the forum discussion details including warnings

get_forum_discussions_returns()   X-Ref
Describes the get_forum_discussions return value.

return: external_single_structure

view_forum_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

view_forum($forumid)   X-Ref
Trigger the course module viewed event and update the module completion status.

param: int $forumid the forum instance id
return: array of warnings and status result

view_forum_returns()   X-Ref
Returns description of method result value

return: external_description

view_forum_discussion_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

view_forum_discussion($discussionid)   X-Ref
Trigger the discussion viewed event.

param: int $discussionid the discussion id
return: array of warnings and status result

view_forum_discussion_returns()   X-Ref
Returns description of method result value

return: external_description

add_discussion_post_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

add_discussion_post($postid, $subject, $message, $options = array()   X-Ref
Create new posts into an existing discussion.

param: int $postid the post id we are going to reply to
param: string $subject new post subject
param: string $message new post message (html assumed if messageformat is not provided)
param: array $options optional settings
param: string $messageformat The format of the message, defaults to FORMAT_HTML for BC
return: array of warnings and the new post id

add_discussion_post_returns()   X-Ref
Returns description of method result value

return: external_description

toggle_favourite_state($discussionid, $targetstate)   X-Ref
Toggle the favouriting value for the discussion provided

param: int $discussionid The discussion we need to favourite
param: bool $targetstate The state of the favourite value
return: array The exported discussion

toggle_favourite_state_returns()   X-Ref
Returns description of method result value

return: external_description

toggle_favourite_state_parameters()   X-Ref
Defines the parameters for the toggle_favourite_state method

return: external_function_parameters

add_discussion_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

add_discussion($forumid, $subject, $message, $groupid = 0, $options = array()   X-Ref
Add a new discussion into an existing forum.

param: int $forumid the forum instance id
param: string $subject new discussion subject
param: string $message new discussion message (only html format allowed)
param: int $groupid the user course group
param: array $options optional settings
return: array of warnings and the new discussion id

add_discussion_returns()   X-Ref
Returns description of method result value

return: external_description

can_add_discussion_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

can_add_discussion($forumid, $groupid = null)   X-Ref
Check if the current user can add discussions in the given forum (and optionally for the given group).

param: int $forumid the forum instance id
param: int $groupid the group to check, default to active group. Use -1 to check if the user can post in all the groups.
return: array of warnings and the status (true if the user can add discussions)

can_add_discussion_returns()   X-Ref
Returns description of method result value

return: external_description

get_forum_access_information_parameters()   X-Ref
Describes the parameters for get_forum_access_information.

return: external_external_function_parameters

get_forum_access_information($forumid)   X-Ref
Return access information for a given forum.

param: int $forumid forum instance id
return: array of warnings and the access information

get_forum_access_information_returns()   X-Ref
Describes the get_forum_access_information return value.

return: external_single_structure

set_subscription_state($forumid, $discussionid, $targetstate)   X-Ref
Set the subscription state.

param: int     $forumid
param: int     $discussionid
param: bool    $targetstate
return: \stdClass

set_subscription_state_parameters()   X-Ref
Returns description of method parameters.

return: external_function_parameters

set_subscription_state_returns()   X-Ref
Returns description of method result value.

return: external_description

set_lock_state($forumid, $discussionid, $targetstate)   X-Ref
Set the lock state.

param: int     $forumid
param: int     $discussionid
param: string    $targetstate
return: \stdClass

set_lock_state_parameters()   X-Ref
Returns description of method parameters.

return: external_function_parameters

set_lock_state_returns()   X-Ref
Returns description of method result value.

return: external_description

set_pin_state($discussionid, $targetstate)   X-Ref
Set the pin state.

param: int     $discussionid
param: bool    $targetstate
return: \stdClass

set_pin_state_parameters()   X-Ref
Returns description of method parameters.

return: external_function_parameters

set_pin_state_returns()   X-Ref
Returns description of method result value.

return: external_single_structure

delete_post_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

delete_post($postid)   X-Ref
Deletes a post or a discussion completely when the post is the discussion topic.

param: int $postid post to be deleted, it can be a discussion topic post.
return: array of warnings and the status (true if the post/discussion was deleted)

delete_post_returns()   X-Ref
Returns description of method result value

return: external_description

get_discussion_posts_by_userid(int $userid, int $cmid, ?string $sortby, ?string $sortdirection)   X-Ref
Get the forum posts in the specified forum instance.

param: int $userid
param: int $cmid
param: string $sortby
param: string $sortdirection
return: array

get_discussion_posts_by_userid_parameters()   X-Ref
Describe the post parameters.

return: external_function_parameters

get_discussion_posts_by_userid_returns()   X-Ref
Describe the post return format.

return: external_single_structure

get_discussion_post_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

get_discussion_post($postid)   X-Ref
Get a particular discussion post.

param: int $postid post to fetch
return: array of post and warnings (if any)

get_discussion_post_returns()   X-Ref
Returns description of method result value

return: external_description

prepare_draft_area_for_post_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

prepare_draft_area_for_post($postid, $area, $draftitemid = 0, $filestokeep = [])   X-Ref
Prepares a draft area for editing a post.

param: int $postid post to prepare the draft area for
param: string $area area to prepare attachment or post
param: int $draftitemid the draft item id to use. 0 to generate a new one.
param: array $filestokeep only keep these files in the draft file area. Empty for keeping all.
return: array of files in the area, the area options and the draft item id

prepare_draft_area_for_post_returns()   X-Ref
Returns description of method result value

return: external_description

update_discussion_post_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

update_discussion_post($postid, $subject = '', $message = '', $messageformat = FORMAT_HTML,$options = [])   X-Ref
Updates a post or a discussion post topic.

param: int $postid post to be updated, it can be a discussion topic post.
param: string $subject updated post subject
param: string $message updated post message (HTML assumed if messageformat is not provided)
param: int $messageformat The format of the message, defaults to FORMAT_HTML
param: array $options different configuration options for the post to be updated.
return: array of warnings and the status (true if the post/discussion was deleted)

update_discussion_post_returns()   X-Ref
Returns description of method result value

return: external_description