Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
mod_forum_external Class Reference
Inheritance diagram for mod_forum_external:

Static Public Member Functions

static add_discussion ($forumid, $subject, $message, $groupid=0, $options=array())
 Add a new discussion into an existing forum.
 
static add_discussion_parameters ()
 Returns description of method parameters.
 
static add_discussion_post ($postid, $subject, $message, $options=array(), $messageformat=FORMAT_HTML)
 Create new posts into an existing discussion.
 
static add_discussion_post_parameters ()
 Returns description of method parameters.
 
static add_discussion_post_returns ()
 Returns description of method result value.
 
static add_discussion_returns ()
 Returns description of method result value.
 
static can_add_discussion ($forumid, $groupid=null)
 Check if the current user can add discussions in the given forum (and optionally for the given group).
 
static can_add_discussion_parameters ()
 Returns description of method parameters.
 
static can_add_discussion_returns ()
 Returns description of method result value.
 
static delete_post ($postid)
 Deletes a post or a discussion completely when the post is the discussion topic.
 
static delete_post_parameters ()
 Returns description of method parameters.
 
static delete_post_returns ()
 Returns description of method result value.
 
static get_discussion_post ($postid)
 Get a particular discussion post.
 
static get_discussion_post_parameters ()
 Returns description of method parameters.
 
static get_discussion_post_returns ()
 Returns description of method result value.
 
static get_discussion_posts (int $discussionid, ?string $sortby, ?string $sortdirection, bool $includeinlineattachments=false)
 Get the forum posts in the specified discussion.
 
static get_discussion_posts_by_userid (int $userid, int $cmid, ?string $sortby, ?string $sortdirection)
 Get the forum posts in the specified forum instance.
 
static get_discussion_posts_by_userid_parameters ()
 Describe the post parameters.
 
static get_discussion_posts_by_userid_returns ()
 Describe the post return format.
 
static get_discussion_posts_parameters ()
 Describe the post parameters.
 
static get_discussion_posts_returns ()
 Describe the post return format.
 
static get_forum_access_information ($forumid)
 Return access information for a given forum.
 
static get_forum_access_information_parameters ()
 Describes the parameters for get_forum_access_information.
 
static get_forum_access_information_returns ()
 Describes the get_forum_access_information return value.
 
static get_forum_discussions (int $forumid, ?int $sortorder=-1, ?int $page=-1, ?int $perpage=0, ?int $groupid=0)
 Returns a list of forum discussions optionally sorted and paginated.
 
static get_forum_discussions_parameters ()
 Describes the parameters for get_forum_discussions.
 
static get_forum_discussions_returns ()
 Describes the get_forum_discussions return value.
 
static get_forums_by_courses ($courseids=array())
 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.
 
static get_forums_by_courses_parameters ()
 Describes the parameters for get_forum.
 
static get_forums_by_courses_returns ()
 Describes the get_forum return value.
 
static prepare_draft_area_for_post ($postid, $area, $draftitemid=0, $filestokeep=[])
 Prepares a draft area for editing a post.
 
static prepare_draft_area_for_post_parameters ()
 Returns description of method parameters.
 
static prepare_draft_area_for_post_returns ()
 Returns description of method result value.
 
static set_lock_state ($forumid, $discussionid, $targetstate)
 Set the lock state.
 
static set_lock_state_parameters ()
 Returns description of method parameters.
 
static set_lock_state_returns ()
 Returns description of method result value.
 
static set_pin_state ($discussionid, $targetstate)
 Set the pin state.
 
static set_pin_state_parameters ()
 Returns description of method parameters.
 
static set_pin_state_returns ()
 Returns description of method result value.
 
static set_subscription_state ($forumid, $discussionid, $targetstate)
 Set the subscription state.
 
static set_subscription_state_parameters ()
 Returns description of method parameters.
 
static set_subscription_state_returns ()
 Returns description of method result value.
 
static toggle_favourite_state ($discussionid, $targetstate)
 Toggle the favouriting value for the discussion provided.
 
static toggle_favourite_state_parameters ()
 Defines the parameters for the toggle_favourite_state method.
 
static toggle_favourite_state_returns ()
 Returns description of method result value.
 
static update_discussion_post ($postid, $subject='', $message='', $messageformat=FORMAT_HTML, $options=[])
 Updates a post or a discussion post topic.
 
static update_discussion_post_parameters ()
 Returns description of method parameters.
 
static update_discussion_post_returns ()
 Returns description of method result value.
 
static view_forum ($forumid)
 Trigger the course module viewed event and update the module completion status.
 
static view_forum_discussion ($discussionid)
 Trigger the discussion viewed event.
 
static view_forum_discussion_parameters ()
 Returns description of method parameters.
 
static view_forum_discussion_returns ()
 Returns description of method result value.
 
static view_forum_parameters ()
 Returns description of method parameters.
 
static view_forum_returns ()
 Returns description of method result value.
 

Member Function Documentation

◆ add_discussion()

static mod_forum_external::add_discussion ( $forumid,
$subject,
$message,
$groupid = 0,
$options = array() )
static

Add a new discussion into an existing forum.

Parameters
int$forumidthe forum instance id
string$subjectnew discussion subject
string$messagenew discussion message (only html format allowed)
int$groupidthe user course group
array$optionsoptional settings
Return values
arrayof warnings and the new discussion id
Since
Moodle 3.0
Exceptions
moodle_exception

◆ add_discussion_parameters()

static mod_forum_external::add_discussion_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters
Since
Moodle 3.0

◆ add_discussion_post()

static mod_forum_external::add_discussion_post ( $postid,
$subject,
$message,
$options = array(),
$messageformat = FORMAT_HTML )
static

Create new posts into an existing discussion.

Parameters
int$postidthe post id we are going to reply to
string$subjectnew post subject
string$messagenew post message (html assumed if messageformat is not provided)
array$optionsoptional settings
string$messageformatThe format of the message, defaults to FORMAT_HTML for BC
Return values
arrayof warnings and the new post id
Since
Moodle 3.0
Exceptions
moodle_exception

◆ add_discussion_post_parameters()

static mod_forum_external::add_discussion_post_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters
Since
Moodle 3.0

◆ add_discussion_post_returns()

static mod_forum_external::add_discussion_post_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description
Since
Moodle 3.0

◆ add_discussion_returns()

static mod_forum_external::add_discussion_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description
Since
Moodle 3.0

◆ can_add_discussion()

static mod_forum_external::can_add_discussion ( $forumid,
$groupid = null )
static

Check if the current user can add discussions in the given forum (and optionally for the given group).

Parameters
int$forumidthe forum instance id
int$groupidthe group to check, default to active group. Use -1 to check if the user can post in all the groups.
Return values
arrayof warnings and the status (true if the user can add discussions)
Since
Moodle 3.1
Exceptions
moodle_exception

◆ can_add_discussion_parameters()

static mod_forum_external::can_add_discussion_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters
Since
Moodle 3.1

◆ can_add_discussion_returns()

static mod_forum_external::can_add_discussion_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description
Since
Moodle 3.1

◆ delete_post()

static mod_forum_external::delete_post ( $postid)
static

Deletes a post or a discussion completely when the post is the discussion topic.

Parameters
int$postidpost to be deleted, it can be a discussion topic post.
Return values
arrayof warnings and the status (true if the post/discussion was deleted)
Since
Moodle 3.8
Exceptions
moodle_exception

◆ delete_post_parameters()

static mod_forum_external::delete_post_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters
Since
Moodle 3.8

◆ delete_post_returns()

static mod_forum_external::delete_post_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description
Since
Moodle 3.8

◆ get_discussion_post()

static mod_forum_external::get_discussion_post ( $postid)
static

Get a particular discussion post.

Parameters
int$postidpost to fetch
Return values
arrayof post and warnings (if any)
Since
Moodle 3.8
Exceptions
moodle_exception

◆ get_discussion_post_parameters()

static mod_forum_external::get_discussion_post_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters
Since
Moodle 3.8

◆ get_discussion_post_returns()

static mod_forum_external::get_discussion_post_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description
Since
Moodle 3.8

◆ get_discussion_posts()

static mod_forum_external::get_discussion_posts ( int $discussionid,
?string $sortby,
?string $sortdirection,
bool $includeinlineattachments = false )
static

Get the forum posts in the specified discussion.

Parameters
int$discussionid
string$sortby
string$sortdirection
bool$includeinlineattachmentsWhether inline attachments should be included or not.
Return values
array

◆ get_discussion_posts_by_userid()

static mod_forum_external::get_discussion_posts_by_userid ( int $userid,
int $cmid,
?string $sortby,
?string $sortdirection )
static

Get the forum posts in the specified forum instance.

Parameters
int$userid
int$cmid
string$sortby
string$sortdirection
Return values
array

◆ get_discussion_posts_by_userid_parameters()

static mod_forum_external::get_discussion_posts_by_userid_parameters ( )
static

Describe the post parameters.

Return values
external_function_parameters

◆ get_discussion_posts_by_userid_returns()

static mod_forum_external::get_discussion_posts_by_userid_returns ( )
static

Describe the post return format.

Return values
external_single_structure

◆ get_discussion_posts_parameters()

static mod_forum_external::get_discussion_posts_parameters ( )
static

Describe the post parameters.

Return values
external_function_parameters

◆ get_discussion_posts_returns()

static mod_forum_external::get_discussion_posts_returns ( )
static

Describe the post return format.

Return values
external_single_structure

◆ get_forum_access_information()

static mod_forum_external::get_forum_access_information ( $forumid)
static

Return access information for a given forum.

Parameters
int$forumidforum instance id
Return values
arrayof warnings and the access information
Since
Moodle 3.7
Exceptions
moodle_exception

◆ get_forum_access_information_parameters()

static mod_forum_external::get_forum_access_information_parameters ( )
static

Describes the parameters for get_forum_access_information.

Return values
external_external_function_parameters
Since
Moodle 3.7

◆ get_forum_access_information_returns()

static mod_forum_external::get_forum_access_information_returns ( )
static

Describes the get_forum_access_information return value.

Return values
external_single_structure
Since
Moodle 3.7

◆ get_forum_discussions()

static mod_forum_external::get_forum_discussions ( int $forumid,
?int $sortorder = -1,
?int $page = -1,
?int $perpage = 0,
?int $groupid = 0 )
static

Returns a list of forum discussions optionally sorted and paginated.

Parameters
int$forumidthe forum instance id
int$sortorderThe sort order
int$pagepage number
int$perpageitems per page
int$groupidthe user course group
Return values
arraythe forum discussion details including warnings
Since
Moodle 3.7

◆ get_forum_discussions_parameters()

static mod_forum_external::get_forum_discussions_parameters ( )
static

Describes the parameters for get_forum_discussions.

Return values
external_function_parameters
Since
Moodle 3.7

◆ get_forum_discussions_returns()

static mod_forum_external::get_forum_discussions_returns ( )
static

Describes the get_forum_discussions return value.

Return values
external_single_structure
Since
Moodle 3.7

◆ get_forums_by_courses()

static mod_forum_external::get_forums_by_courses ( $courseids = array())
static

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.

Parameters
array$courseidsthe course ids
Return values
arraythe forum details
Since
Moodle 2.5

◆ get_forums_by_courses_parameters()

static mod_forum_external::get_forums_by_courses_parameters ( )
static

Describes the parameters for get_forum.

Return values
external_function_parameters
Since
Moodle 2.5

◆ get_forums_by_courses_returns()

static mod_forum_external::get_forums_by_courses_returns ( )
static

Describes the get_forum return value.

Return values
external_single_structure
Since
Moodle 2.5

◆ prepare_draft_area_for_post()

static mod_forum_external::prepare_draft_area_for_post ( $postid,
$area,
$draftitemid = 0,
$filestokeep = [] )
static

Prepares a draft area for editing a post.

Parameters
int$postidpost to prepare the draft area for
string$areaarea to prepare attachment or post
int$draftitemidthe draft item id to use. 0 to generate a new one.
array$filestokeeponly keep these files in the draft file area. Empty for keeping all.
Return values
arrayof files in the area, the area options and the draft item id
Since
Moodle 3.8
Exceptions
moodle_exception

◆ prepare_draft_area_for_post_parameters()

static mod_forum_external::prepare_draft_area_for_post_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters
Since
Moodle 3.8

◆ prepare_draft_area_for_post_returns()

static mod_forum_external::prepare_draft_area_for_post_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description
Since
Moodle 3.8

◆ set_lock_state()

static mod_forum_external::set_lock_state ( $forumid,
$discussionid,
$targetstate )
static

Set the lock state.

Parameters
int$forumid
int$discussionid
string$targetstate
Return values
stdClass

◆ set_lock_state_parameters()

static mod_forum_external::set_lock_state_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters

◆ set_lock_state_returns()

static mod_forum_external::set_lock_state_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description

◆ set_pin_state()

static mod_forum_external::set_pin_state ( $discussionid,
$targetstate )
static

Set the pin state.

Parameters
int$discussionid
bool$targetstate
Return values
stdClass

◆ set_pin_state_parameters()

static mod_forum_external::set_pin_state_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters

◆ set_pin_state_returns()

static mod_forum_external::set_pin_state_returns ( )
static

Returns description of method result value.

Return values
external_single_structure

◆ set_subscription_state()

static mod_forum_external::set_subscription_state ( $forumid,
$discussionid,
$targetstate )
static

Set the subscription state.

Parameters
int$forumid
int$discussionid
bool$targetstate
Return values
stdClass

◆ set_subscription_state_parameters()

static mod_forum_external::set_subscription_state_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters

◆ set_subscription_state_returns()

static mod_forum_external::set_subscription_state_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description

◆ toggle_favourite_state()

static mod_forum_external::toggle_favourite_state ( $discussionid,
$targetstate )
static

Toggle the favouriting value for the discussion provided.

Parameters
int$discussionidThe discussion we need to favourite
bool$targetstateThe state of the favourite value
Return values
arrayThe exported discussion

◆ toggle_favourite_state_parameters()

static mod_forum_external::toggle_favourite_state_parameters ( )
static

Defines the parameters for the toggle_favourite_state method.

Return values
external_function_parameters

◆ toggle_favourite_state_returns()

static mod_forum_external::toggle_favourite_state_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description
Since
Moodle 3.0

◆ update_discussion_post()

static mod_forum_external::update_discussion_post ( $postid,
$subject = '',
$message = '',
$messageformat = FORMAT_HTML,
$options = [] )
static

Updates a post or a discussion post topic.

Parameters
int$postidpost to be updated, it can be a discussion topic post.
string$subjectupdated post subject
string$messageupdated post message (HTML assumed if messageformat is not provided)
int$messageformatThe format of the message, defaults to FORMAT_HTML
array$optionsdifferent configuration options for the post to be updated.
Return values
arrayof warnings and the status (true if the post/discussion was deleted)
Since
Moodle 3.8
Exceptions
moodle_exception
Todo
support more options: timed posts, groups change and tags.

◆ update_discussion_post_parameters()

static mod_forum_external::update_discussion_post_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters
Since
Moodle 3.8

◆ update_discussion_post_returns()

static mod_forum_external::update_discussion_post_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description
Since
Moodle 3.8

◆ view_forum()

static mod_forum_external::view_forum ( $forumid)
static

Trigger the course module viewed event and update the module completion status.

Parameters
int$forumidthe forum instance id
Return values
arrayof warnings and status result
Since
Moodle 2.9
Exceptions
moodle_exception

◆ view_forum_discussion()

static mod_forum_external::view_forum_discussion ( $discussionid)
static

Trigger the discussion viewed event.

Parameters
int$discussionidthe discussion id
Return values
arrayof warnings and status result
Since
Moodle 2.9
Exceptions
moodle_exception

◆ view_forum_discussion_parameters()

static mod_forum_external::view_forum_discussion_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters
Since
Moodle 2.9

◆ view_forum_discussion_returns()

static mod_forum_external::view_forum_discussion_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description
Since
Moodle 2.9

◆ view_forum_parameters()

static mod_forum_external::view_forum_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters
Since
Moodle 2.9

◆ view_forum_returns()

static mod_forum_external::view_forum_returns ( )
static

Returns description of method result value.

Return values
core_external\external_description
Since
Moodle 2.9

The documentation for this class was generated from the following file: