Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Static Public Member Functions | |
static | add_discussion ($forumid, $subject, $message, $groupid=0, $options=array()) |
Add a new discussion into an existing forum. More... | |
static | add_discussion_parameters () |
Returns description of method parameters. More... | |
static | add_discussion_post ($postid, $subject, $message, $options=array(), $messageformat=FORMAT_HTML) |
Create new posts into an existing discussion. More... | |
static | add_discussion_post_parameters () |
Returns description of method parameters. More... | |
static | add_discussion_post_returns () |
Returns description of method result value. More... | |
static | add_discussion_returns () |
Returns description of method result value. More... | |
static | call_external_function ($function, $args, $ajaxonly=false) |
Call an external function validating all params/returns correctly. More... | |
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). More... | |
static | can_add_discussion_parameters () |
Returns description of method parameters. More... | |
static | can_add_discussion_returns () |
Returns description of method result value. More... | |
static | clean_returnvalue (external_description $description, $response) |
Clean response If a response attribute is unknown from the description, we just ignore the attribute. More... | |
static | delete_post ($postid) |
Deletes a post or a discussion completely when the post is the discussion topic. More... | |
static | delete_post_parameters () |
Returns description of method parameters. More... | |
static | delete_post_returns () |
Returns description of method result value. More... | |
static | external_function_info ($function, $strictness=MUST_EXIST) |
Returns detailed function information. More... | |
static | get_discussion_post ($postid) |
Get a particular discussion post. More... | |
static | get_discussion_post_parameters () |
Returns description of method parameters. More... | |
static | get_discussion_post_returns () |
Returns description of method result value. More... | |
static | get_discussion_posts (int $discussionid, ?string $sortby, ?string $sortdirection) |
Get the forum posts in the specified discussion. More... | |
static | get_discussion_posts_by_userid (int $userid=0, int $cmid, ?string $sortby, ?string $sortdirection) |
Get the forum posts in the specified forum instance. More... | |
static | get_discussion_posts_by_userid_parameters () |
Describe the post parameters. More... | |
static | get_discussion_posts_by_userid_returns () |
Describe the post return format. More... | |
static | get_discussion_posts_parameters () |
Describe the post parameters. More... | |
static | get_discussion_posts_returns () |
Describe the post return format. More... | |
static | get_forum_access_information ($forumid) |
Return access information for a given forum. More... | |
static | get_forum_access_information_parameters () |
Describes the parameters for get_forum_access_information. More... | |
static | get_forum_access_information_returns () |
Describes the get_forum_access_information return value. More... | |
static | get_forum_discussion_posts ($discussionid, $sortby="created", $sortdirection="DESC") |
Returns a list of forum posts for a discussion. More... | |
static | get_forum_discussion_posts_is_deprecated () |
Mark the get_forum_discussion_posts web service as deprecated. More... | |
static | get_forum_discussion_posts_parameters () |
Describes the parameters for get_forum_discussion_posts. More... | |
static | get_forum_discussion_posts_returns () |
Describes the get_forum_discussion_posts return value. More... | |
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. More... | |
static | get_forum_discussions_paginated ($forumid, $sortby='timemodified', $sortdirection='DESC', $page=-1, $perpage=0) |
Returns a list of forum discussions optionally sorted and paginated. More... | |
static | get_forum_discussions_paginated_parameters () |
Describes the parameters for get_forum_discussions_paginated. More... | |
static | get_forum_discussions_paginated_returns () |
Describes the get_forum_discussions_paginated return value. More... | |
static | get_forum_discussions_parameters () |
Describes the parameters for get_forum_discussions. More... | |
static | get_forum_discussions_returns () |
Describes the get_forum_discussions return value. More... | |
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. More... | |
static | get_forums_by_courses_parameters () |
Describes the parameters for get_forum. More... | |
static | get_forums_by_courses_returns () |
Describes the get_forum return value. More... | |
static | prepare_draft_area_for_post ($postid, $area, $draftitemid=0, $filestokeep=[]) |
Prepares a draft area for editing a post. More... | |
static | prepare_draft_area_for_post_parameters () |
Returns description of method parameters. More... | |
static | prepare_draft_area_for_post_returns () |
Returns description of method result value. More... | |
static | set_context_restriction ($context) |
Set context restriction for all following subsequent function calls. More... | |
static | set_lock_state ($forumid, $discussionid, $targetstate) |
Set the lock state. More... | |
static | set_lock_state_parameters () |
Returns description of method parameters. More... | |
static | set_lock_state_returns () |
Returns description of method result value. More... | |
static | set_pin_state ($discussionid, $targetstate) |
Set the pin state. More... | |
static | set_pin_state_parameters () |
Returns description of method parameters. More... | |
static | set_pin_state_returns () |
Returns description of method result value. More... | |
static | set_subscription_state ($forumid, $discussionid, $targetstate) |
Set the subscription state. More... | |
static | set_subscription_state_parameters () |
Returns description of method parameters. More... | |
static | set_subscription_state_returns () |
Returns description of method result value. More... | |
static | set_timeout ($seconds=360) |
This method has to be called before every operation that takes a longer time to finish! More... | |
static | toggle_favourite_state ($discussionid, $targetstate) |
Toggle the favouriting value for the discussion provided. More... | |
static | toggle_favourite_state_parameters () |
Defines the parameters for the toggle_favourite_state method. More... | |
static | toggle_favourite_state_returns () |
Returns description of method result value. More... | |
static | update_discussion_post ($postid, $subject='', $message='', $messageformat=FORMAT_HTML, $options=[]) |
Updates a post or a discussion post topic. More... | |
static | update_discussion_post_parameters () |
Returns description of method parameters. More... | |
static | update_discussion_post_returns () |
Returns description of method result value. More... | |
static | validate_context ($context) |
Makes sure user may execute functions in this context. More... | |
static | validate_parameters (external_description $description, $params) |
Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown. More... | |
static | view_forum ($forumid) |
Trigger the course module viewed event and update the module completion status. More... | |
static | view_forum_discussion ($discussionid) |
Trigger the discussion viewed event. More... | |
static | view_forum_discussion_parameters () |
Returns description of method parameters. More... | |
static | view_forum_discussion_returns () |
Returns description of method result value. More... | |
static | view_forum_parameters () |
Returns description of method parameters. More... | |
static | view_forum_returns () |
Returns description of method result value. More... | |
Static Protected Member Functions | |
static | get_context_from_params ($param) |
Get context from passed parameters. More... | |
static | get_context_parameters () |
Returns a prepared structure to use a context parameters. More... | |
|
static |
Add a new discussion into an existing forum.
int | $forumid | the forum instance id |
string | $subject | new discussion subject |
string | $message | new discussion message (only html format allowed) |
int | $groupid | the user course group |
array | $options | optional settings |
array | of warnings and the new discussion id |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
Create new posts into an existing discussion.
int | $postid | the post id we are going to reply to |
string | $subject | new post subject |
string | $message | new post message (html assumed if messageformat is not provided) |
array | $options | optional settings |
string | $messageformat | The format of the message, defaults to FORMAT_HTML for BC |
array | of warnings and the new post id |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
|
static |
|
staticinherited |
Call an external function validating all params/returns correctly.
Note that an external function may modify the state of the current page, so this wrapper saves and restores tha PAGE and COURSE global variables before/after calling the external function.
string | $function | A webservice function name. |
array | $args | Params array (named params) |
boolean | $ajaxonly | If true, an extra check will be peformed to see if ajax is required. |
array | containing keys for error (bool), exception and data. |
|
static |
Check if the current user can add discussions in the given forum (and optionally for the given group).
int | $forumid | the forum instance id |
int | $groupid | the group to check, default to active group. Use -1 to check if the user can post in all the groups. |
array | of warnings and the status (true if the user can add discussions) |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
|
staticinherited |
Clean response If a response attribute is unknown from the description, we just ignore the attribute.
If a response attribute is incorrect, invalid_response_exception is thrown. Note: this function is similar to validate parameters, however it is distinct because parameters validation must be distinct from cleaning return values.
external_description | $description | description of the return values |
mixed | $response | the actual response |
mixed | response with added defaults for optional items, invalid_response_exception thrown if any problem found |
|
static |
Deletes a post or a discussion completely when the post is the discussion topic.
int | $postid | post to be deleted, it can be a discussion topic post. |
array | of warnings and the status (true if the post/discussion was deleted) |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
|
staticinherited |
Returns detailed function information.
string | object | $function | name of external function or record from external_function |
int | $strictness | IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; MUST_EXIST means throw exception if no record or multiple records found |
stdClass | description or false if not found or exception thrown |
|
staticprotectedinherited |
Get context from passed parameters.
The passed array must either contain a contextid or a combination of context level and instance id to fetch the context. For example, the context level can be "course" and instanceid can be courseid.
See context_helper::get_all_levels() for a list of valid context levels.
array | $param |
invalid_parameter_exception |
context |
|
staticprotectedinherited |
Returns a prepared structure to use a context parameters.
external_single_structure |
Reimplemented in tool_lp\external, and core_competency\external.
|
static |
Get a particular discussion post.
int | $postid | post to fetch |
array | of post and warnings (if any) |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
|
static |
Get the forum posts in the specified discussion.
int | $discussionid | |
string | $sortby | |
string | $sortdirection |
array |
|
static |
Get the forum posts in the specified forum instance.
int | $userid | |
int | $cmid | |
string | $sortby | |
string | $sortdirection |
array |
|
static |
Describe the post parameters.
external_function_parameters |
|
static |
Describe the post return format.
external_single_structure |
|
static |
Describe the post parameters.
external_function_parameters |
|
static |
Describe the post return format.
external_single_structure |
|
static |
Return access information for a given forum.
int | $forumid | forum instance id |
array | of warnings and the access information |
moodle_exception |
|
static |
Describes the parameters for get_forum_access_information.
external_external_function_parameters |
|
static |
Describes the get_forum_access_information return value.
external_single_structure |
|
static |
Returns a list of forum posts for a discussion.
int | $discussionid | the post ids |
string | $sortby | sort by this element (id, created or modified) |
string | $sortdirection | sort direction: ASC or DESC |
array | the forum post details |
|
static |
Mark the get_forum_discussion_posts web service as deprecated.
bool |
|
static |
Describes the parameters for get_forum_discussion_posts.
external_function_parameters |
|
static |
Describes the get_forum_discussion_posts return value.
external_single_structure |
|
static |
Returns a list of forum discussions optionally sorted and paginated.
int | $forumid | the forum instance id |
int | $sortorder | The sort order |
int | $page | page number |
int | $perpage | items per page |
int | $groupid | the user course group |
array | the forum discussion details including warnings |
|
static |
Returns a list of forum discussions optionally sorted and paginated.
int | $forumid | the forum instance id |
string | $sortby | sort by this element (id, timemodified, timestart or timeend) |
string | $sortdirection | sort direction: ASC or DESC |
int | $page | page number |
int | $perpage | items per page |
array | the forum discussion details including warnings |
|
static |
Describes the parameters for get_forum_discussions_paginated.
external_function_parameters |
|
static |
Describes the get_forum_discussions_paginated return value.
external_single_structure |
|
static |
Describes the parameters for get_forum_discussions.
external_function_parameters |
|
static |
Describes the get_forum_discussions return value.
external_single_structure |
|
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.
array | $courseids | the course ids |
array | the forum details |
|
static |
|
static |
|
static |
Prepares a draft area for editing a post.
int | $postid | post to prepare the draft area for |
string | $area | area to prepare attachment or post |
int | $draftitemid | the draft item id to use. 0 to generate a new one. |
array | $filestokeep | only keep these files in the draft file area. Empty for keeping all. |
array | of files in the area, the area options and the draft item id |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
|
staticinherited |
Set context restriction for all following subsequent function calls.
stdClass | $context | the context restriction |
|
static |
Set the lock state.
int | $forumid | |
int | $discussionid | |
string | $targetstate |
stdClass |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
Returns description of method result value.
external_description |
|
static |
Set the pin state.
int | $discussionid | |
bool | $targetstate |
stdClass |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
Returns description of method result value.
external_single_structure |
|
static |
Set the subscription state.
int | $forumid | |
int | $discussionid | |
bool | $targetstate |
stdClass |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
Returns description of method result value.
external_description |
|
staticinherited |
This method has to be called before every operation that takes a longer time to finish!
int | $seconds | max expected time the next operation needs |
|
static |
Toggle the favouriting value for the discussion provided.
int | $discussionid | The discussion we need to favourite |
bool | $targetstate | The state of the favourite value |
array | The exported discussion |
|
static |
Defines the parameters for the toggle_favourite_state method.
external_function_parameters |
|
static |
|
static |
Updates a post or a discussion post topic.
int | $postid | post to be updated, it can be a discussion topic post. |
string | $subject | updated post subject |
string | $message | updated post message (HTML assumed if messageformat is not provided) |
int | $messageformat | The format of the message, defaults to FORMAT_HTML |
array | $options | different configuration options for the post to be updated. |
array | of warnings and the status (true if the post/discussion was deleted) |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
|
staticinherited |
Makes sure user may execute functions in this context.
stdClass | $context |
|
staticinherited |
Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown.
This is a simple recursive method which is intended to be called from each implementation method of external API.
external_description | $description | description of parameters |
mixed | $params | the actual parameters |
mixed | params with added defaults for optional items, invalid_parameters_exception thrown if any problem found |
|
static |
Trigger the course module viewed event and update the module completion status.
int | $forumid | the forum instance id |
array | of warnings and status result |
moodle_exception |
|
static |
Trigger the discussion viewed event.
int | $discussionid | the discussion id |
array | of warnings and status result |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |