Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)

Classes

class  forum_file_info_container
 Class representing the virtual node with all itemids in the file browser. More...
 
class  forum_portfolio_caller
 

Functions

 forum_activity_actionbar (?forum_entity $forum, $groupid, stdClass $course, string $search='')
 Retrieve HTML for the page action.
 
object forum_add_attachment ($post, $forum, $cm, $mform=null, $unused=null)
 If successful, this function returns the name of the file.
 
 forum_add_discussion ($discussion, $mform=null, $unused=null, $userid=null)
 Given an object containing all the necessary data, create a new discussion and return the id.
 
 forum_add_instance ($forum, $mform=null)
 STANDARD FUNCTIONS ///////////////////////////////////////////////////////////.
 
 forum_add_new_post ($post, $mform, $unused=null)
 Add a new post in an existing discussion.
 
 forum_can_create_attachment ($forum, $context)
 Check if the user can create attachments in a forum.
 
object forum_change_discussionid ($postid, $discussionid)
 recursively sets the discussion field to $discussionid on $postid and all its children used when pruning a post
 
 forum_check_blocking_threshold ($thresholdwarning)
 Throws an error if the user is no longer allowed to post due to having reached or exceeded the number of posts specified in 'Post threshold for blocking' setting.
 
 forum_check_throttling ($forum, $cm=null)
 Returns a warning object if a user has reached the number of posts equal to the warning/blocking setting, or false if there is no warning to show.
 
 forum_check_updates_since (cm_info $cm, $from, $filter=array())
 Check if the module has any update that affects the current user since a given time.
 
 forum_count_discussion_replies ($forumid, $forumsort="", $limit=-1, $page=-1, $perpage=0, $canseeprivatereplies=false)
 Returns an array of counts of replies to each discussion.
 
object forum_count_discussions ($forum, $cm, $course)
 @global object @global object
 
object forum_count_user_posts ($forumid, $userid)
 Get all the posts for a user in a forum suitable for forum_print_post.
 
object forum_delete_discussion ($discussion, $fulldelete, $course, $cm, $forum)
 Deletes a discussion and handles all associated cleanup.
 
object forum_delete_instance ($id)
 Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it.
 
object forum_delete_post ($post, $children, $course, $cm, $forum, $skipcompletion=false)
 Deletes a single forum post.
 
 forum_discussion_is_locked ($forum, $discussion)
 Determine whether the specified discussion is time-locked.
 
 forum_discussion_pin ($modcontext, $forum, $discussion)
 Set the discussion to pinned and trigger the discussion pinned event.
 
 forum_discussion_unpin ($modcontext, $forum, $discussion)
 Set discussion to unpinned and trigger the discussion unpin event.
 
object forum_discussion_update_last_post ($discussionid)
 Sets the last post for a given discussion.
 
 forum_discussion_view ($modcontext, $forum, $discussion)
 Trigger the discussion viewed event.
 
object forum_discussions_user_has_posted_in ($forumid, $userid)
 @global object
 
 forum_extend_settings_navigation (settings_navigation $settingsnav, navigation_node $forumnode)
 Adds module specific settings to the settings block.
 
 forum_filter_user_groups_discussions ()
 
 forum_get_all_discussion_posts ($discussionid, $sort, $tracking=false)
 Gets all posts in discussion including top parent.
 
 forum_get_context ($forumid, $context=null)
 Determine the current context if one was not already specified.
 
object forum_get_course_forum ($courseid, $type)
 @global object
 
 forum_get_coursemodule_info ($coursemodule)
 Add a get_coursemodule_info function in case any forum type wants to add 'extra' information for the course (see resource).
 
moodle_database forum_get_courses_user_posted_in ($user, $discussionsonly=false, $includecontexts=true, $limitfrom=null, $limitnum=null)
 Gets all of the courses where the provided user has posted in a forum.
 
 forum_get_default_sort_order ($desc=true, $compare='d.timemodified', $prefix='d', $pinned=true)
 Get the sql to use in the ORDER BY clause for forum discussions.
 
 forum_get_discussion_neighbours ($cm, $discussion, $forum)
 Gets the neighbours (previous and next) of a discussion.
 
 forum_get_discussion_subscription_icon ($forum, $discussionid, $returnurl=null, $includetext=false)
 Return the markup for the discussion subscription toggling icon.
 
 forum_get_discussion_subscription_icon_preloaders ()
 Return a pair of spans containing classes to allow the subscribe and unsubscribe icons to be pre-loaded by a browser.
 
object forum_get_discussions ($cm, $forumsort="", $fullpost=true, $unused=-1, $limit=-1, $userlastmodified=false, $page=-1, $perpage=0, $groupid=-1, $updatedsince=0)
 Get all discussions in a forum.
 
object forum_get_discussions_count ($cm)
 @global object @global object @uses CONEXT_MODULE @uses VISIBLEGROUPS
 
object forum_get_discussions_unread ($cm)
 @global object @global object @uses CONTEXT_MODULE @uses VISIBLEGROUPS
 
 forum_get_email_message_id ($postid, $usertoid)
 Create a message-id string to use in the custom headers of forum notification emails.
 
 forum_get_extra_capabilities ()
 Returns all other caps used in module.
 
 forum_get_file_areas ($course, $cm, $context)
 Lists all browsable file areas.
 
 forum_get_file_info ($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename)
 File browsing support for forum module.
 
object forum_get_firstpost_from_discussion ($discussionid)
 Given a discussion id, return the first post from the discussion.
 
 forum_get_forum_types ()
 Returns array of forum types chooseable on the forum editing form.
 
 forum_get_forum_types_all ()
 Returns array of all forum layout modes.
 
moodle_database forum_get_forums_user_posted_in ($user, array $courseids=null, $discussionsonly=false, $limitfrom=null, $limitnum=null)
 Gets all of the forums a user has posted in for one or more courses.
 
 forum_get_layout_modes (bool $useexperimentalui=false)
 Returns array of forum layout modes.
 
 forum_get_post_actions ()
 List the actions that correspond to a post of this module.
 
object forum_get_post_from_log ($log)
 Given a log entry, return the forum post details for it.
 
object forum_get_post_full ($postid)
 Gets a post with all info ready for forum_print_post Most of these joins are just to get the forum id.
 
moodle_database forum_get_posts_by_user ($user, array $courses, $musthaveaccess=false, $discussionsonly=false, $limitfrom=0, $limitnum=50)
 Returns posts made by the selected user in the requested courses.
 
object forum_get_readable_forums ($userid, $courseid=0)
 An array of forum objects that the user is allowed to read/search through.
 
object forum_get_recent_mod_activity (&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0)
 Returns all forum posts since a given time in specified forum.
 
 forum_get_subscribe_link ($forum, $context, $messages=array(), $cantaccessagroup=false, $unused1=true, $backtoindex=false, $unused2=null)
 Generate and return the subscribe or unsubscribe link for a forum.
 
 forum_get_subscriptionmode_options ()
 List the options for forum subscription modes.
 
 forum_get_user_digest_options ($user=null)
 Retrieve the list of available user digest options.
 
object forum_get_user_involved_discussions ($forumid, $userid)
 Get all the discussions user participated in.
 
 forum_get_user_maildigest_bulk ($digests, $user, $forumid)
 Determine the maildigest setting for the specified user against the specified forum.
 
 forum_get_user_posted_mailnow (int $did, int $userid)
 Returns true if user posted with mailnow in given discussion.
 
object forum_get_user_posted_time ($did, $userid)
 Returns creation time of the first user's post in given discussion $DB.
 
object forum_get_user_posts ($forumid, $userid)
 Get all the posts for a user in a forum suitable for forum_print_post.
 
 forum_get_view_actions ()
 List the actions that correspond to a view of this module.
 
object forum_go_back_to ($default)
 
 forum_grade_item_delete ($forum)
 Delete grade item for given forum.
 
 forum_grade_item_update ($forum, $ratings=null, $forumgrades=null)
 Create/update grade items for given forum.
 
 forum_grading_areas_list ()
 Lists all gradable areas for the advanced grading methods gramework.
 
 forum_instance_created ($context, $forum)
 Handle changes following the creation of a forum instance.
 
 forum_is_author_hidden ($post, $forum)
 Checks whether the author's name and picture for a given post should be hidden or not.
 
 forum_is_cutoff_date_reached ($forum)
 Determine whether the specified forum's cutoff date is reached.
 
 forum_is_due_date_reached ($forum)
 Determine whether the specified forum's due date is reached.
 
 forum_is_user_group_discussion (cm_info $cm, $discussiongroupid)
 Returns whether the discussion group is visible by the current user or not.
 
object forum_move_attachments ($discussion, $forumfrom, $forumto)
 Given a discussion object that is being moved to $forumto, this function checks all posts in that discussion for attachments, and if any are found, these are moved to the new forum directory.
 
 forum_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types.
 
 forum_pluginfile ($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array())
 Serves the forum attachments.
 
 forum_post_is_visible_privately ($post, $cm)
 Check whether the forum post is a private reply visible to this user.
 
 forum_post_subscription ($fromform, $forum, $discussion)
 Given a new post, subscribes or unsubscribes as appropriate.
 
object forum_print_attachments ($post, $cm, $type)
 Returns attachments as formated text/html optionally with separate images.
 
 forum_print_mode_form ($id, $mode, $forumtype='')
 Print the drop down that allows the user to select how they want to have the discussion displayed.
 
 forum_print_overview ()
 
object forum_print_recent_activity ($course, $viewfullnames, $timestart)
 Given a course and a date, prints a summary of all the new messages posted in the course since that date.
 
 forum_print_recent_mod_activity ($activity, $courseid, $detail, $modnames, $viewfullnames)
 Outputs the forum post indicated by $activity.
 
 forum_rating_permissions ($contextid, $component, $ratingarea)
 Return rating related permissions.
 
 forum_rating_validate ($params)
 Validates a submitted rating.
 
 forum_refresh_events (int $courseid, stdClass $instance, stdClass $cm)
 This callback will check the provided instance of this module and make sure there are up-to-date events created for it.
 
 forum_reset_course_form_defaults ($course)
 Course reset form defaults.
 
 forum_reset_course_form_definition (&$mform)
 Called by course/reset.php.
 
object forum_reset_gradebook ($courseid, $type='')
 Removes all grades from gradebook.
 
object forum_reset_userdata ($data)
 This function is used by the reset_course_userdata function in moodlelib.
 
 forum_scale_used_anywhere (int $scaleid)
 Checks if scale is being used by any instance of forum.
 
object forum_search_form ($course, $search='')
 
object forum_search_posts ($searchterms, $courseid, $limitfrom, $limitnum, &$totalcount, $extrasql='')
 Returns a list of posts found using an array of search terms.
 
object forum_set_return ()
 @global object
 
 forum_set_user_maildigest ($forum, $maildigest, $user=null)
 Set the per-forum maildigest option for the specified user.
 
 forum_supports ($feature)
 Indicates API features that the forum supports.
 
object forum_tp_add_read_record ($userid, $postid)
 Mark post as read.
 
object forum_tp_can_track_forums ($forum=false, $user=false)
 Determine if a user can track forums and optionally a particular forum.
 
object forum_tp_clean_read_records ()
 Clean old records from the forum_read table.
 
object forum_tp_count_forum_unread_posts ($cm, $course, $resetreadcache=false)
 Returns the count of records for the provided user and forum and [optionally] group.
 
object forum_tp_delete_read_records ($userid=-1, $postid=-1, $discussionid=-1, $forumid=-1)
 Deletes read records for the specified index.
 
object forum_tp_get_course_unread_posts ($userid, $courseid)
 Returns the count of records for the provided user and course.
 
object forum_tp_get_untracked_forums ($userid, $courseid)
 Get a list of forums not tracked by the user.
 
object forum_tp_is_post_old ($post, $time=null)
 
object forum_tp_is_post_read ($userid, $post)
 
object forum_tp_is_tracked ($forum, $user=false)
 Tells whether a specific forum is tracked by the user.
 
object forum_tp_mark_discussion_read ($user, $discussionid)
 Marks a whole discussion as read, for a given user.
 
object forum_tp_mark_forum_read ($user, $forumid, $groupid=false)
 Marks a whole forum as read, for a given user.
 
 forum_tp_mark_post_read ($userid, $post, $unused=null)
 If its an old post, do nothing.
 
object forum_tp_mark_posts_read ($user, $postids)
 Mark posts as read.
 
object forum_tp_start_tracking ($forumid, $userid=false)
 @global object
 
object forum_tp_stop_tracking ($forumid, $userid=false)
 @global object
 
 forum_trigger_content_uploaded_event ($post, $cm, $name)
 Sends post content to plagiarism plugin.
 
 forum_trigger_post_updated_event ($post, $discussion, $context, $forum)
 Trigger post updated event.
 
 forum_update_calendar ($forum, $cmid)
 Update the calendar entries for this forum activity.
 
 forum_update_grades ($forum, $userid=0)
 Update activity grades.
 
object forum_update_instance ($forum, $mform)
 Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will update an existing instance with new data.
 
 forum_update_post ($newpost, $mform, $unused=null)
 Update a post.
 
object forum_user_can_post ($forum, $discussion, $user=NULL, $cm=NULL, $course=NULL, $context=NULL)
 This function checks whether the user can reply to posts in a forum discussion.
 
object forum_user_can_post_discussion ($forum, $currentgroup=null, $unused=-1, $cm=NULL, $context=NULL)
 
 forum_user_can_reply_privately (\context_module $context, stdClass $parent)
 Check whether the user can reply privately to the parent post.
 
object forum_user_can_see_discussion ($forum, $discussion, $context, $user=NULL)
 @global object @uses DEBUG_DEVELOPER
 
 forum_user_can_see_group_discussion ($discussion, $cm, $context)
 Check to ensure a user can view a group discussion.
 
 forum_user_can_see_post ($forum, $discussion, $post, $user=null, $cm=null, $checkdeleted=true)
 Check whether a user can see the specified post.
 
 forum_user_can_see_timed_discussion ($discussion, $user, $context)
 Check to ensure a user can view a timed discussion.
 
object forum_user_complete ($course, $user, $mod, $forum)
 @global object
 
object forum_user_has_posted ($forumid, $did, $userid)
 @global object
 
 forum_user_has_posted_discussion ($forumid, $userid, $groupid=null)
 Returns true if user created new discussion already.
 
 forum_user_outline ($course, $user, $mod, $forum)
 
 forum_view ($forum, $course, $cm, $context)
 Mark the activity completed (if required) and trigger the course_module_viewed event.
 
 mod_forum_core_calendar_event_action_shows_item_count (calendar_event $event, $itemcount=0)
 Callback function that determines whether an action event should be showing its item count based on the event type and the item count.
 
 mod_forum_core_calendar_event_timestart_updated (\calendar_event $event, stdClass $forum)
 This function will update the forum module according to the event that has been modified.
 
 mod_forum_core_calendar_get_event_action_string (string $eventtype)
 Callback to fetch the activity event type lang string.
 
 mod_forum_core_calendar_get_valid_event_timestart_range (\calendar_event $event, stdClass $forum)
 This function calculates the minimum and maximum cutoff values for the timestart of the given event.
 
 mod_forum_core_calendar_provide_event_action (calendar_event $event, core_calendar\action_factory $factory, int $userid=0)
 This function receives a calendar event and returns the action associated with it, or null if there is none.
 
 mod_forum_count_all_discussions (\mod_forum\local\entities\forum $forum, stdClass $user, ?int $groupid)
 Get a count of all discussions in a forum.
 
 mod_forum_get_completion_active_rule_descriptions ($cm)
 Callback which returns human-readable strings describing the active completion custom rules for the module instance.
 
 mod_forum_get_discussion_summaries (\mod_forum\local\entities\forum $forum, stdClass $user, ?int $groupid, ?int $sortorder, ?int $pageno=0, ?int $pagesize=0)
 Fetch the data used to display the discussions on the current page.
 
 mod_forum_get_fontawesome_icon_map ()
 Get icon mapping for font-awesome.
 
 mod_forum_get_groups_from_groupid (\mod_forum\local\entities\forum $forum, stdClass $user, ?int $groupid)
 Get the list of groups to show based on the current user and requested groupid.
 
 mod_forum_get_tagged_posts ($tag, $exclusivemode=false, $fromctx=0, $ctx=0, $rec=1, $page=0)
 Returns forum posts tagged with a specified tag.
 
 mod_forum_inplace_editable ($itemtype, $itemid, $newvalue)
 Manage inplace editable saves.
 
 mod_forum_myprofile_navigation (core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course)
 Add nodes to myprofile page.
 
 mod_forum_rating_can_see_item_ratings ($params)
 Can the current user see ratings for a given itemid?
 
 mod_forum_user_preferences ()
 Return a list of all the user preferences used by mod_forum.
 

Variables

const FORUM_CHOOSESUBSCRIBE 0
 
const FORUM_DISALLOWSUBSCRIBE 3
 
const FORUM_DISCUSSION_PINNED 1
 
const FORUM_DISCUSSION_UNPINNED 0
 
const FORUM_EVENT_TYPE_DUE 'due'
 Library of functions for forum outside of the core api.
 
const FORUM_FORCESUBSCRIBE 1
 
const FORUM_INITIALSUBSCRIBE 2
 
const FORUM_MAILED_ERROR 2
 
const FORUM_MAILED_PENDING 0
 
const FORUM_MAILED_SUCCESS 1
 
const FORUM_MODE_FLATNEWEST -1
 
const FORUM_MODE_FLATOLDEST 1
 Include required files.
 
const FORUM_MODE_NESTED 3
 
const FORUM_MODE_NESTED_V2 4
 
const FORUM_MODE_THREADED 2
 
const FORUM_POSTS_ALL_USER_GROUPS (!defined('FORUM_CRON_USER_CACHE')) -2
 FORUM_POSTS_ALL_USER_GROUPS - All the posts in groups where the user is enrolled.
 
const FORUM_TRACKING_FORCED 2
 FORUM_TRACKING_FORCED - Tracking is on, regardless of user setting.
 
const FORUM_TRACKING_OFF 0
 FORUM_TRACKING_OFF - Tracking is not available for this forum.
 
const FORUM_TRACKING_OPTIONAL 1
 FORUM_TRACKING_OPTIONAL - Tracking is based on user preference.
 

Detailed Description

Function Documentation

◆ forum_activity_actionbar()

forum_activity_actionbar ( ?forum_entity $forum,
$groupid,
stdClass $course,
string $search = '' )

Retrieve HTML for the page action.

Parameters
forum_entity | null$forumThe forum entity.
mixed$groupidfalse if groups not used, int if groups used, 0 means all groups
stdClass$courseThe course object.
string$searchThe search string.
Return values
stringrendered HTML string.

◆ forum_add_attachment()

object forum_add_attachment ( $post,
$forum,
$cm,
$mform = null,
$unused = null )

If successful, this function returns the name of the file.

Parameters
object$postis a full post record, including course and forum
object$forum
object$cm
mixed$mform
string$unused
Return values
bool

◆ forum_add_discussion()

forum_add_discussion ( $discussion,
$mform = null,
$unused = null,
$userid = null )

Given an object containing all the necessary data, create a new discussion and return the id.

Parameters
object$post
mixed$mform
string$unused
int$userid
Return values
object

◆ forum_add_instance()

forum_add_instance ( $forum,
$mform = null )

STANDARD FUNCTIONS ///////////////////////////////////////////////////////////.

Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will create a new instance and return the id number of the new instance.

Parameters
stdClass$forumadd forum instance
mod_forum_mod_form$mform
Return values
intintance id

◆ forum_add_new_post()

forum_add_new_post ( $post,
$mform,
$unused = null )

Add a new post in an existing discussion.

Parameters
stdClass$postThe post data
mixed$mformThe submitted form
string$unused
Return values
int

◆ forum_can_create_attachment()

forum_can_create_attachment ( $forum,
$context )

Check if the user can create attachments in a forum.

Parameters
stdClass$forumforum object
stdClass$contextcontext object
Return values
booltrue if the user can create attachments, false otherwise
Since
Moodle 3.3

◆ forum_change_discussionid()

object forum_change_discussionid ( $postid,
$discussionid )

recursively sets the discussion field to $discussionid on $postid and all its children used when pruning a post

Parameters
int$postid
int$discussionid
Return values
bool

◆ forum_check_blocking_threshold()

forum_check_blocking_threshold ( $thresholdwarning)

Throws an error if the user is no longer allowed to post due to having reached or exceeded the number of posts specified in 'Post threshold for blocking' setting.

Since
Moodle 2.5
Parameters
stdClass$thresholdwarningthe warning information returned from the function forum_check_throttling.

◆ forum_check_throttling()

forum_check_throttling ( $forum,
$cm = null )

Returns a warning object if a user has reached the number of posts equal to the warning/blocking setting, or false if there is no warning to show.

Parameters
int | stdClass$forumthe forum id or the forum object
stdClass$cmthe course module
Return values
stdClass|boolreturns an object with the warning information, else returns false if no warning is required.

◆ forum_check_updates_since()

forum_check_updates_since ( cm_info $cm,
$from,
$filter = array() )

Check if the module has any update that affects the current user since a given time.

Parameters
cm_info$cmcourse module data
int$fromthe time to check updates from
array$filterif we need to check only specific updates
Return values
stdClassan object with the different type of areas indicating if they were updated or not
Since
Moodle 3.2

◆ forum_count_discussion_replies()

forum_count_discussion_replies ( $forumid,
$forumsort = "",
$limit = -1,
$page = -1,
$perpage = 0,
$canseeprivatereplies = false )

Returns an array of counts of replies to each discussion.

Parameters
int$forumid
string$forumsort
int$limit
int$page
int$perpage
boolean$canseeprivaterepliesWhether the current user can see private replies.
Return values
array

◆ forum_count_discussions()

object forum_count_discussions ( $forum,
$cm,
$course )

@global object @global object

Parameters
object$forum
object$cm
object$course
Return values
mixed

◆ forum_count_user_posts()

object forum_count_user_posts ( $forumid,
$userid )

Get all the posts for a user in a forum suitable for forum_print_post.

@global object

Parameters
int$forumid
int$userid
Return values
stdClass|falsecollection of counts or false

◆ forum_delete_discussion()

object forum_delete_discussion ( $discussion,
$fulldelete,
$course,
$cm,
$forum )

Deletes a discussion and handles all associated cleanup.

Parameters
object$discussionDiscussion to delete
bool$fulldeleteTrue when deleting entire forum
object$courseCourse
object$cmCourse-module
object$forumForum
Return values
bool

◆ forum_delete_instance()

object forum_delete_instance ( $id)

Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it.

Parameters
int$idforum instance id
Return values
boolsuccess

◆ forum_delete_post()

object forum_delete_post ( $post,
$children,
$course,
$cm,
$forum,
$skipcompletion = false )

Deletes a single forum post.

Parameters
object$postForum post object
mixed$childrenWhether to delete children. If false, returns false if there are any children (without deleting the post). If true, recursively deletes all children. If set to special value 'ignore', deletes post regardless of children (this is for use only when deleting all posts in a disussion).
object$courseCourse
object$cmCourse-module
object$forumForum
bool$skipcompletionTrue to skip updating completion state if it would otherwise be updated, i.e. when deleting entire forum anyway.
Return values
bool

◆ forum_discussion_is_locked()

forum_discussion_is_locked ( $forum,
$discussion )

Determine whether the specified discussion is time-locked.

Parameters
stdClass$forumThe forum that the discussion belongs to
stdClass$discussionThe discussion to test
Return values
bool

◆ forum_discussion_pin()

forum_discussion_pin ( $modcontext,
$forum,
$discussion )

Set the discussion to pinned and trigger the discussion pinned event.

Parameters
stdClass$modcontextmodule context object
stdClass$forumforum object
stdClass$discussiondiscussion object
Since
Moodle 3.1

◆ forum_discussion_unpin()

forum_discussion_unpin ( $modcontext,
$forum,
$discussion )

Set discussion to unpinned and trigger the discussion unpin event.

Parameters
stdClass$modcontextmodule context object
stdClass$forumforum object
stdClass$discussiondiscussion object
Since
Moodle 3.1

◆ forum_discussion_update_last_post()

object forum_discussion_update_last_post ( $discussionid)

Sets the last post for a given discussion.

@global object

Parameters
into$discussionid
Return values
bool|int

◆ forum_discussion_view()

forum_discussion_view ( $modcontext,
$forum,
$discussion )

Trigger the discussion viewed event.

Parameters
stdClass$modcontextmodule context object
stdClass$forumforum object
stdClass$discussiondiscussion object
Since
Moodle 2.9

◆ forum_discussions_user_has_posted_in()

object forum_discussions_user_has_posted_in ( $forumid,
$userid )

@global object

Parameters
int$forumid
int$userid
Return values
array

◆ forum_extend_settings_navigation()

forum_extend_settings_navigation ( settings_navigation $settingsnav,
navigation_node $forumnode )

Adds module specific settings to the settings block.

Parameters
settings_navigation$settingsThe settings navigation object
navigation_node$forumnodeThe node to add module settings to

◆ forum_filter_user_groups_discussions()

forum_filter_user_groups_discussions ( )
Deprecated
since Moodle 3.3, when the block_course_overview block was removed.

◆ forum_get_all_discussion_posts()

forum_get_all_discussion_posts ( $discussionid,
$sort,
$tracking = false )

Gets all posts in discussion including top parent.

Parameters
int$discussionidThe Discussion to fetch.
string$sortThe sorting to apply.
bool$trackingWhether the user tracks this forum.
Return values
arrayThe posts in the discussion.

◆ forum_get_context()

forum_get_context ( $forumid,
$context = null )

Determine the current context if one was not already specified.

If a context of type context_module is specified, it is immediately returned and not checked.

Parameters
int$forumidThe ID of the forum
context_module$contextThe current context.
Return values
context_moduleThe context determined

◆ forum_get_course_forum()

object forum_get_course_forum ( $courseid,
$type )

@global object

Parameters
int$courseid
string$type

◆ forum_get_coursemodule_info()

forum_get_coursemodule_info ( $coursemodule)

Add a get_coursemodule_info function in case any forum type wants to add 'extra' information for the course (see resource).

Given a course_module object, this function returns any "extra" information that may be needed when printing this activity in a course listing. See get_array_of_activities() in course/lib.php.

Parameters
stdClass$coursemoduleThe coursemodule object (record).
Return values
cached_cm_infoAn object on information that the courses will know about (most noticeably, an icon).

◆ forum_get_courses_user_posted_in()

moodle_database forum_get_courses_user_posted_in ( $user,
$discussionsonly = false,
$includecontexts = true,
$limitfrom = null,
$limitnum = null )

Gets all of the courses where the provided user has posted in a forum.

$DB The database connection

Parameters
stdClass$userThe user who's posts we are looking for
bool$discussionsonlyIf true only look for discussions started by the user
bool$includecontextsIf set to trye contexts for the courses will be preloaded
int$limitfromThe offset of records to return
int$limitnumThe number of records to return
Return values
arrayAn array of courses

◆ forum_get_default_sort_order()

forum_get_default_sort_order ( $desc = true,
$compare = 'd.timemodified',
$prefix = 'd',
$pinned = true )

Get the sql to use in the ORDER BY clause for forum discussions.

This has the ordering take timed discussion windows into account.

Parameters
bool$descTrue for DESC, False for ASC.
string$compareThe field in the SQL to compare to normally sort by.
string$prefixThe prefix being used for the discussion table.
bool$pinnedsort pinned posts to the top
Return values
string

◆ forum_get_discussion_neighbours()

forum_get_discussion_neighbours ( $cm,
$discussion,
$forum )

Gets the neighbours (previous and next) of a discussion.

The calculation is based on the timemodified when time modified or time created is identical It will revert to using the ID to sort consistently. This is better tha skipping a discussion.

For blog-style forums, the calculation is based on the original creation time of the blog post.

Please note that this does not check whether or not the discussion passed is accessible by the user, it simply uses it as a reference to find the neighbours. On the other hand, the returned neighbours are checked and are accessible to the current user.

Parameters
object$cmThe CM record.
object$discussionThe discussion record.
object$forumThe forum instance record.
Return values
arrayThat always contains the keys 'prev' and 'next'. When there is a result they contain the record with minimal information such as 'id' and 'name'. When the neighbour is not found the value is false.

◆ forum_get_discussion_subscription_icon()

forum_get_discussion_subscription_icon ( $forum,
$discussionid,
$returnurl = null,
$includetext = false )

Return the markup for the discussion subscription toggling icon.

Parameters
stdClass$forumThe forum object.
int$discussionidThe discussion to create an icon for.
Return values
stringThe generated markup.

◆ forum_get_discussion_subscription_icon_preloaders()

forum_get_discussion_subscription_icon_preloaders ( )

Return a pair of spans containing classes to allow the subscribe and unsubscribe icons to be pre-loaded by a browser.

Return values
stringThe generated markup

◆ forum_get_discussions()

object forum_get_discussions ( $cm,
$forumsort = "",
$fullpost = true,
$unused = -1,
$limit = -1,
$userlastmodified = false,
$page = -1,
$perpage = 0,
$groupid = -1,
$updatedsince = 0 )

Get all discussions in a forum.

@global object @global object @uses CONTEXT_MODULE @uses VISIBLEGROUPS

Parameters
object$cm
string$forumsort
bool$fullpost
int$unused
int$limit
bool$userlastmodified
int$page
int$perpage
int$groupidif groups enabled, get discussions for this group overriding the current group. Use FORUM_POSTS_ALL_USER_GROUPS for all the user groups
int$updatedsinceretrieve only discussions updated since the given time
Return values
array

◆ forum_get_discussions_count()

object forum_get_discussions_count ( $cm)

@global object @global object @uses CONEXT_MODULE @uses VISIBLEGROUPS

Parameters
object$cm
Return values
array

◆ forum_get_discussions_unread()

object forum_get_discussions_unread ( $cm)

@global object @global object @uses CONTEXT_MODULE @uses VISIBLEGROUPS

Parameters
object$cm
Return values
array

◆ forum_get_email_message_id()

forum_get_email_message_id ( $postid,
$usertoid )

Create a message-id string to use in the custom headers of forum notification emails.

message-id is used by email clients to identify emails and to nest conversations

Parameters
int$postidThe ID of the forum post we are notifying the user about
int$usertoidThe ID of the user being notified
Return values
stringA unique message-id

◆ forum_get_extra_capabilities()

forum_get_extra_capabilities ( )

Returns all other caps used in module.

Return values
array

◆ forum_get_file_areas()

forum_get_file_areas ( $course,
$cm,
$context )

Lists all browsable file areas.

Parameters
stdClass$coursecourse object
stdClass$cmcourse module object
stdClass$contextcontext object
Return values
array

◆ forum_get_file_info()

forum_get_file_info ( $browser,
$areas,
$course,
$cm,
$context,
$filearea,
$itemid,
$filepath,
$filename )

File browsing support for forum module.

Parameters
stdClass$browserfile browser object
stdClass$areasfile areas
stdClass$coursecourse object
stdClass$cmcourse module
stdClass$contextcontext module
string$fileareafile area
int$itemiditem ID
string$filepathfile path
string$filenamefile name
Return values
file_infoinstance or null if not found

◆ forum_get_firstpost_from_discussion()

object forum_get_firstpost_from_discussion ( $discussionid)

Given a discussion id, return the first post from the discussion.

@global object

Parameters
int$dicsussionid
Return values
array

◆ forum_get_forum_types()

forum_get_forum_types ( )

Returns array of forum types chooseable on the forum editing form.

Return values
array

◆ forum_get_forum_types_all()

forum_get_forum_types_all ( )

Returns array of all forum layout modes.

Return values
array

◆ forum_get_forums_user_posted_in()

moodle_database forum_get_forums_user_posted_in ( $user,
array $courseids = null,
$discussionsonly = false,
$limitfrom = null,
$limitnum = null )

Gets all of the forums a user has posted in for one or more courses.

$DB

Parameters
stdClass$user
array$courseidsAn array of courseids to search or if not provided all courses the user has posted within
bool$discussionsonlyIf true then only forums where the user has started a discussion will be returned.
int$limitfromThe offset of records to return
int$limitnumThe number of records to return
Return values
arrayAn array of forums the user has posted within in the provided courses

◆ forum_get_layout_modes()

forum_get_layout_modes ( bool $useexperimentalui = false)

Returns array of forum layout modes.

Parameters
bool$useexperimentaluiuse experimental layout modes or not
Return values
array

◆ forum_get_post_actions()

forum_get_post_actions ( )

List the actions that correspond to a post of this module.

This is used by the participation report.

Note: This is not used by new logging system. Event with crud = ('c' || 'u' || 'd') and edulevel = LEVEL_PARTICIPATING will be considered as post action.

Return values
array

◆ forum_get_post_from_log()

object forum_get_post_from_log ( $log)

Given a log entry, return the forum post details for it.

@global object

Parameters
object$log
Return values
array|null

◆ forum_get_post_full()

object forum_get_post_full ( $postid)

Gets a post with all info ready for forum_print_post Most of these joins are just to get the forum id.

@global object

Parameters
int$postid
Return values
mixedarray of posts or false

◆ forum_get_posts_by_user()

moodle_database forum_get_posts_by_user ( $user,
array $courses,
$musthaveaccess = false,
$discussionsonly = false,
$limitfrom = 0,
$limitnum = 50 )

Returns posts made by the selected user in the requested courses.

This method can be used to return all of the posts made by the requested user within the given courses. For each course the access of the current user and requested user is checked and then for each post access to the post and forum is checked as well.

This function is safe to use with usercapabilities.

$DB

Parameters
stdClass$userThe user whose posts we want to get
array$coursesThe courses to search
bool$musthaveaccessIf set to true errors will be thrown if the user cannot access one or more of the courses to search
bool$discussionsonlyIf set to true only discussion starting posts will be returned.
int$limitfromThe offset of records to return
int$limitnumThe number of records to return
Return values
stdClassAn object the following properties ->totalcount: the total number of posts made by the requested user that the current user can see. ->courses: An array of courses the current user can see that the requested user has posted in. ->forums: An array of forums relating to the posts returned in the property below. ->posts: An array containing the posts to show for this request.

◆ forum_get_readable_forums()

object forum_get_readable_forums ( $userid,
$courseid = 0 )

An array of forum objects that the user is allowed to read/search through.

@global object @global object

Parameters
int$userid
int$courseidif 0, we look for forums throughout the whole site.
Return values
arrayof forum objects, or false if no matches Forum objects have the following attributes: id, type, course, cmid, cmvisible, cmgroupmode, accessallgroups, viewhiddentimedposts

◆ forum_get_recent_mod_activity()

object forum_get_recent_mod_activity ( & $activities,
& $index,
$timestart,
$courseid,
$cmid,
$userid = 0,
$groupid = 0 )

Returns all forum posts since a given time in specified forum.

Todo
Document this functions args

@global object @global object @global object

◆ forum_get_subscribe_link()

forum_get_subscribe_link ( $forum,
$context,
$messages = array(),
$cantaccessagroup = false,
$unused1 = true,
$backtoindex = false,
$unused2 = null )

Generate and return the subscribe or unsubscribe link for a forum.

Parameters
object$forumthe forum. Fields used are $forum->id and $forum->forcesubscribe.
object$contextthe context object for this forum.
array$messagestext used for the link in its various states (subscribed, unsubscribed, forcesubscribed or cantsubscribe). Any strings not passed in are taken from the $defaultmessages array at the top of the function.
bool$cantaccessagroup
bool$unused1
bool$backtoindex
array$unused2
Return values
string

◆ forum_get_subscriptionmode_options()

forum_get_subscriptionmode_options ( )

List the options for forum subscription modes.

This is used by the settings page and by the mod_form page.

Return values
array

◆ forum_get_user_digest_options()

forum_get_user_digest_options ( $user = null)

Retrieve the list of available user digest options.

Parameters
stdClass$userThe user object. This defaults to the global $USER object.
Return values
arrayThe mapping of values to digest options.

◆ forum_get_user_involved_discussions()

object forum_get_user_involved_discussions ( $forumid,
$userid )

Get all the discussions user participated in.

@global object @uses CONTEXT_MODULE

Parameters
int$forumid
int$userid
Return values
arrayArray or false

◆ forum_get_user_maildigest_bulk()

forum_get_user_maildigest_bulk ( $digests,
$user,
$forumid )

Determine the maildigest setting for the specified user against the specified forum.

Parameters
Array$digestsAn array of forums and user digest settings.
stdClass$userThe user object containing the id and maildigest default.
int$forumidThe ID of the forum to check.
Return values
intThe calculated maildigest setting for this user and forum.

◆ forum_get_user_posted_mailnow()

forum_get_user_posted_mailnow ( int $did,
int $userid )

Returns true if user posted with mailnow in given discussion.

Parameters
int$didDiscussion id
int$useridUser id
Return values
bool

◆ forum_get_user_posted_time()

object forum_get_user_posted_time ( $did,
$userid )

Returns creation time of the first user's post in given discussion $DB.

Parameters
int$didDiscussion id
int$useridUser id
Return values
int|boolpost creation time stamp or return false

◆ forum_get_user_posts()

object forum_get_user_posts ( $forumid,
$userid )

Get all the posts for a user in a forum suitable for forum_print_post.

@global object @uses CONTEXT_MODULE

Return values
array

◆ forum_get_view_actions()

forum_get_view_actions ( )

List the actions that correspond to a view of this module.

This is used by the participation report.

Note: This is not used by new logging system. Event with crud = 'r' and edulevel = LEVEL_PARTICIPATING will be considered as view action.

Return values
array

◆ forum_go_back_to()

object forum_go_back_to ( $default)
Parameters
string | moodle_url$default
Return values
string

◆ forum_grade_item_delete()

forum_grade_item_delete ( $forum)

Delete grade item for given forum.

Parameters
stdClass$forumForum object

◆ forum_grade_item_update()

forum_grade_item_update ( $forum,
$ratings = null,
$forumgrades = null )

Create/update grade items for given forum.

Parameters
stdClass$forumForum object with extra cmidnumber
mixed$gradesOptional array/object of grade(s); 'reset' means reset grades in gradebook

◆ forum_grading_areas_list()

forum_grading_areas_list ( )

Lists all gradable areas for the advanced grading methods gramework.

Return values
array('string'=>'string')An array with area names as keys and descriptions as values

◆ forum_instance_created()

forum_instance_created ( $context,
$forum )

Handle changes following the creation of a forum instance.

This function is typically called by the course_module_created observer.

Parameters
object$contextthe forum context
stdClass$forumThe forum object
Return values
void

◆ forum_is_author_hidden()

forum_is_author_hidden ( $post,
$forum )

Checks whether the author's name and picture for a given post should be hidden or not.

Parameters
object$postThe forum post.
object$forumThe forum object.
Return values
bool
Exceptions
coding_exception

◆ forum_is_cutoff_date_reached()

forum_is_cutoff_date_reached ( $forum)

Determine whether the specified forum's cutoff date is reached.

Parameters
stdClass$forumThe forum
Return values
bool

◆ forum_is_due_date_reached()

forum_is_due_date_reached ( $forum)

Determine whether the specified forum's due date is reached.

Parameters
stdClass$forumThe forum
Return values
bool

◆ forum_is_user_group_discussion()

forum_is_user_group_discussion ( cm_info $cm,
$discussiongroupid )

Returns whether the discussion group is visible by the current user or not.

Since
Moodle 2.8, 2.7.1, 2.6.4
Parameters
cm_info$cmThe discussion course module
int$discussiongroupidThe discussion groupid
Return values
bool

◆ forum_move_attachments()

object forum_move_attachments ( $discussion,
$forumfrom,
$forumto )

Given a discussion object that is being moved to $forumto, this function checks all posts in that discussion for attachments, and if any are found, these are moved to the new forum directory.

Parameters
object$discussion
int$forumfromsource forum id
int$forumtotarget forum id
Return values
boolsuccess

◆ forum_page_type_list()

forum_page_type_list ( $pagetype,
$parentcontext,
$currentcontext )

Return a list of page types.

Parameters
string$pagetypecurrent page type
stdClass$parentcontextBlock's parent context
stdClass$currentcontextCurrent context of block

◆ forum_pluginfile()

forum_pluginfile ( $course,
$cm,
$context,
$filearea,
$args,
$forcedownload,
array $options = array() )

Serves the forum attachments.

Implements needed access control ;-)

Parameters
stdClass$coursecourse object
stdClass$cmcourse module object
stdClass$contextcontext object
string$fileareafile area
array$argsextra arguments
bool$forcedownloadwhether or not force download
array$optionsadditional options affecting the file serving
Return values
boolfalse if file not found, does not return if found - justsend the file

◆ forum_post_is_visible_privately()

forum_post_is_visible_privately ( $post,
$cm )

Check whether the forum post is a private reply visible to this user.

Parameters
stdClass$postThe post to check.
cm_info$cmThe context module instance.
Return values
boolWhether the post is visible in terms of private reply configuration.

◆ forum_post_subscription()

forum_post_subscription ( $fromform,
$forum,
$discussion )

Given a new post, subscribes or unsubscribes as appropriate.

Returns some text which describes what happened.

Parameters
object$fromformThe submitted form
stdClass$forumThe forum record
stdClass$discussionThe forum discussion record
Return values
string

◆ forum_print_attachments()

object forum_print_attachments ( $post,
$cm,
$type )

Returns attachments as formated text/html optionally with separate images.

@global object @global object

Parameters
object$post
object$cm
string$typehtml/text/separateimages
Return values
mixedstring or array of (html text withouth images and image HTML)

◆ forum_print_mode_form()

forum_print_mode_form ( $id,
$mode,
$forumtype = '' )

Print the drop down that allows the user to select how they want to have the discussion displayed.

Parameters
int$idforum id if $forumtype is 'single', discussion id for any other forum type
mixed$modeforum layout mode
string$forumtypeoptional

◆ forum_print_overview()

forum_print_overview ( )
Deprecated
since Moodle 3.3, when the block_course_overview block was removed.

◆ forum_print_recent_activity()

object forum_print_recent_activity ( $course,
$viewfullnames,
$timestart )

Given a course and a date, prints a summary of all the new messages posted in the course since that date.

@global object @global object @uses CONTEXT_MODULE @uses VISIBLEGROUPS

Parameters
object$course
bool$viewfullnamescapability
int$timestart
Return values
boolsuccess

◆ forum_print_recent_mod_activity()

forum_print_recent_mod_activity ( $activity,
$courseid,
$detail,
$modnames,
$viewfullnames )

Outputs the forum post indicated by $activity.

Parameters
object$activitythe activity object the forum resides in
int$courseidthe id of the course the forum resides in
bool$detailnot used, but required for compatibilty with other modules
int$modnamesnot used, but required for compatibilty with other modules
bool$viewfullnamesnot used, but required for compatibilty with other modules

◆ forum_rating_permissions()

forum_rating_permissions ( $contextid,
$component,
$ratingarea )

Return rating related permissions.

Parameters
string$optionsthe context id
Return values
arrayan associative array of the user's rating permissions

◆ forum_rating_validate()

forum_rating_validate ( $params)

Validates a submitted rating.

Parameters
array$paramssubmitted data context => object the context in which the rated items exists [required] component => The component for this module - should always be mod_forum [required] ratingarea => object the context in which the rated items exists [required]

itemid => int the ID of the object being rated [required] scaleid => int the scale from which the user can select a rating. Used for bounds checking. [required] rating => int the submitted rating [required] rateduserid => int the id of the user whose items have been rated. NOT the user who submitted the ratings. 0 to update all. [required] aggregation => int the aggregation method to apply when calculating grades ie RATING_AGGREGATE_AVERAGE [required]

Return values
booleantrue if the rating is valid. Will throw rating_exception if not

◆ forum_refresh_events()

forum_refresh_events ( int $courseid,
stdClass $instance,
stdClass $cm )

This callback will check the provided instance of this module and make sure there are up-to-date events created for it.

Parameters
int$courseidNot used.
stdClass$instanceForum module instance.
stdClass$cmCourse module object.

◆ forum_reset_course_form_defaults()

forum_reset_course_form_defaults ( $course)

Course reset form defaults.

Return values
array

◆ forum_reset_course_form_definition()

forum_reset_course_form_definition ( & $mform)

Called by course/reset.php.

Parameters
MoodleQuickForm$mformform passed by reference

◆ forum_reset_gradebook()

object forum_reset_gradebook ( $courseid,
$type = '' )

Removes all grades from gradebook.

@global object

Parameters
int$courseid
string$typeoptional

◆ forum_reset_userdata()

object forum_reset_userdata ( $data)

This function is used by the reset_course_userdata function in moodlelib.

This function will remove all posts from the specified forum and clean up any related data.

@global object

Parameters
$datathe data submitted from the reset course.
Return values
arraystatus array

◆ forum_scale_used_anywhere()

forum_scale_used_anywhere ( int $scaleid)

Checks if scale is being used by any instance of forum.

This is used to find out if scale used anywhere.

Parameters
$scaleidint
Return values
booleanTrue if the scale is used by any forum

◆ forum_search_form()

object forum_search_form ( $course,
$search = '' )
Parameters
object$course
string$search
Return values
string

◆ forum_search_posts()

object forum_search_posts ( $searchterms,
$courseid,
$limitfrom,
$limitnum,
& $totalcount,
$extrasql = '' )

Returns a list of posts found using an array of search terms.

@global object @global object

Parameters
array$searchtermsarray of search terms, e.g. word +word -word
int$courseidif 0, we search through the whole site
int$limitfrom
int$limitnum
int&$totalcount
string$extrasql
Return values
array|boolArray of posts found or false

◆ forum_set_user_maildigest()

forum_set_user_maildigest ( $forum,
$maildigest,
$user = null )

Set the per-forum maildigest option for the specified user.

Parameters
stdClass$forumThe forum to set the option for.
int$maildigestThe maildigest option.
stdClass$userThe user object. This defaults to the global $USER object.
Exceptions
invalid_digest_settingthrown if an invalid maildigest option is provided.

◆ forum_supports()

forum_supports ( $feature)

Indicates API features that the forum supports.

@uses FEATURE_GROUPS @uses FEATURE_GROUPINGS @uses FEATURE_MOD_INTRO @uses FEATURE_COMPLETION_TRACKS_VIEWS @uses FEATURE_COMPLETION_HAS_RULES @uses FEATURE_GRADE_HAS_GRADE @uses FEATURE_GRADE_OUTCOMES

Parameters
string$feature
Return values
mixedTrue if module supports feature, false if not, null if doesn't know or string for the module purpose.

◆ forum_tp_add_read_record()

object forum_tp_add_read_record ( $userid,
$postid )

Mark post as read.

@global object

Parameters
int$userid
int$postid

◆ forum_tp_can_track_forums()

object forum_tp_can_track_forums ( $forum = false,
$user = false )

Determine if a user can track forums and optionally a particular forum.

Checks the site settings, the user settings and the forum settings (if requested).

@global object @global object

Parameters
mixed$forumThe forum object to test, or the int id (optional).
mixed$useridThe user object to check for (optional).
Return values
boolean

◆ forum_tp_clean_read_records()

object forum_tp_clean_read_records ( )

Clean old records from the forum_read table.

@global object

Return values
void

◆ forum_tp_count_forum_unread_posts()

object forum_tp_count_forum_unread_posts ( $cm,
$course,
$resetreadcache = false )

Returns the count of records for the provided user and forum and [optionally] group.

@global object @global object

Parameters
object$cm
object$course
bool$resetreadcacheoptional, true to reset the function static $readcache var
Return values
int

◆ forum_tp_delete_read_records()

object forum_tp_delete_read_records ( $userid = -1,
$postid = -1,
$discussionid = -1,
$forumid = -1 )

Deletes read records for the specified index.

At least one parameter must be specified.

Parameters
int$userid
int$postid
int$discussionid
int$forumid
Return values
bool

◆ forum_tp_get_course_unread_posts()

object forum_tp_get_course_unread_posts ( $userid,
$courseid )

Returns the count of records for the provided user and course.

Please note that group access is ignored!

@global object

Parameters
int$userid
int$courseid
Return values
array

◆ forum_tp_get_untracked_forums()

object forum_tp_get_untracked_forums ( $userid,
$courseid )

Get a list of forums not tracked by the user.

@global object

Parameters
int$useridThe id of the user to use.
int$courseidThe id of the course being checked.
Return values
mixedAn array indexed by forum id, or false.

◆ forum_tp_is_post_old()

object forum_tp_is_post_old ( $post,
$time = null )
Parameters
object$post
int$timeDefautls to time()

◆ forum_tp_is_post_read()

object forum_tp_is_post_read ( $userid,
$post )
Parameters
int$userid
object$post

◆ forum_tp_is_tracked()

object forum_tp_is_tracked ( $forum,
$user = false )

Tells whether a specific forum is tracked by the user.

A user can optionally be specified. If not specified, the current user is assumed.

@global object @global object

Parameters
mixed$forumIf int, the id of the forum being checked; if object, the forum object
int$useridThe id of the user being checked (optional).
Return values
boolean

◆ forum_tp_mark_discussion_read()

object forum_tp_mark_discussion_read ( $user,
$discussionid )

Marks a whole discussion as read, for a given user.

@global object

Parameters
object$user
int$discussionid
Return values
bool

◆ forum_tp_mark_forum_read()

object forum_tp_mark_forum_read ( $user,
$forumid,
$groupid = false )

Marks a whole forum as read, for a given user.

@global object

Parameters
object$user
int$forumid
int | bool$groupid
Return values
bool

◆ forum_tp_mark_post_read()

forum_tp_mark_post_read ( $userid,
$post,
$unused = null )

If its an old post, do nothing.

If the record exists, the maintenance will clear it up later.

Parameters
int$useridThe ID of the user to mark posts read for.
object$postThe post record for the post to mark as read.
mixed$unused
Return values
bool

◆ forum_tp_mark_posts_read()

object forum_tp_mark_posts_read ( $user,
$postids )

Mark posts as read.

@global object

Parameters
object$userobject
array$postidsarray of post ids
Return values
booleansuccess

◆ forum_tp_start_tracking()

object forum_tp_start_tracking ( $forumid,
$userid = false )

@global object

Parameters
int$forumid
int$userid

◆ forum_tp_stop_tracking()

object forum_tp_stop_tracking ( $forumid,
$userid = false )

@global object

Parameters
int$forumid
int$userid

◆ forum_trigger_content_uploaded_event()

forum_trigger_content_uploaded_event ( $post,
$cm,
$name )

Sends post content to plagiarism plugin.

Parameters
object$postForum post object
object$cmCourse-module
string$name
Return values
bool

◆ forum_trigger_post_updated_event()

forum_trigger_post_updated_event ( $post,
$discussion,
$context,
$forum )

Trigger post updated event.

Parameters
object$postforum post object
object$discussiondiscussion object
object$contextforum context object
object$forumforum object
Since
Moodle 3.8
Return values
void

◆ forum_update_calendar()

forum_update_calendar ( $forum,
$cmid )

Update the calendar entries for this forum activity.

Parameters
stdClass$forumthe row from the database table forum.
int$cmidThe coursemodule id
Return values
bool

◆ forum_update_grades()

forum_update_grades ( $forum,
$userid = 0 )

Update activity grades.

Parameters
object$forum
int$useridspecific user only, 0 means all

◆ forum_update_instance()

object forum_update_instance ( $forum,
$mform )

Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will update an existing instance with new data.

Parameters
object$forumforum instance (with magic quotes)
Return values
boolsuccess

◆ forum_update_post()

forum_update_post ( $newpost,
$mform,
$unused = null )

Update a post.

Parameters
stdClass$newpostThe post to update
mixed$mformThe submitted form
string$unused
Return values
bool

◆ forum_user_can_post()

object forum_user_can_post ( $forum,
$discussion,
$user = NULL,
$cm = NULL,
$course = NULL,
$context = NULL )

This function checks whether the user can reply to posts in a forum discussion.

Use forum_user_can_post_discussion() to check whether the user can start discussions.

@global object @uses DEBUG_DEVELOPER @uses CONTEXT_MODULE @uses VISIBLEGROUPS

Parameters
object$forumforum object
object$discussion
object$user
object$cm
object$course
object$context
Return values
bool

◆ forum_user_can_post_discussion()

object forum_user_can_post_discussion ( $forum,
$currentgroup = null,
$unused = -1,
$cm = NULL,
$context = NULL )
Parameters
object$forum
object$currentgroup
int$unused
object$cm
object$context
Return values
bool

◆ forum_user_can_reply_privately()

forum_user_can_reply_privately ( \context_module $context,
stdClass $parent )

Check whether the user can reply privately to the parent post.

Parameters
context_module$context
stdClass$parent
Return values
bool

◆ forum_user_can_see_discussion()

object forum_user_can_see_discussion ( $forum,
$discussion,
$context,
$user = NULL )

@global object @uses DEBUG_DEVELOPER

Parameters
object$forum
object$discussion
object$context
object$user
Return values
bool

◆ forum_user_can_see_group_discussion()

forum_user_can_see_group_discussion ( $discussion,
$cm,
$context )

Check to ensure a user can view a group discussion.

Parameters
object$discussion
object$cm
object$context
Return values
booleanreturns true if they can view post, false otherwise

◆ forum_user_can_see_post()

forum_user_can_see_post ( $forum,
$discussion,
$post,
$user = null,
$cm = null,
$checkdeleted = true )

Check whether a user can see the specified post.

Parameters
stdClass$forumThe forum to chcek
stdClass$discussionThe discussion the post is in
stdClass$postThe post in question
stdClass$userThe user to test - if not specified, the current user is checked.
stdClass$cmThe Course Module that the forum is in (required).
bool$checkdeletedWhether to check the deleted flag on the post.
Return values
bool

◆ forum_user_can_see_timed_discussion()

forum_user_can_see_timed_discussion ( $discussion,
$user,
$context )

Check to ensure a user can view a timed discussion.

Parameters
object$discussion
object$user
object$context
Return values
booleanreturns true if they can view post, false otherwise

◆ forum_user_complete()

object forum_user_complete ( $course,
$user,
$mod,
$forum )

@global object

Parameters
object$coure
object$user
object$mod
object$forum

◆ forum_user_has_posted()

object forum_user_has_posted ( $forumid,
$did,
$userid )

@global object

Parameters
int$forumid
int$did
int$userid
Return values
bool

◆ forum_user_has_posted_discussion()

forum_user_has_posted_discussion ( $forumid,
$userid,
$groupid = null )

Returns true if user created new discussion already.

Parameters
int$forumidThe forum to check for postings
int$useridThe user to check for postings
int$groupidThe group to restrict the check to
Return values
bool

◆ forum_user_outline()

forum_user_outline ( $course,
$user,
$mod,
$forum )
Parameters
object$course
object$user
object$modTODO this is not used in this function, refactor
object$forum
Return values
objectA standard object with 2 variables: info (number of posts for this user) and time (last modified)

◆ forum_view()

forum_view ( $forum,
$course,
$cm,
$context )

Mark the activity completed (if required) and trigger the course_module_viewed event.

Parameters
stdClass$forumforum object
stdClass$coursecourse object
stdClass$cmcourse module object
stdClass$contextcontext object
Since
Moodle 2.9

◆ mod_forum_core_calendar_event_action_shows_item_count()

mod_forum_core_calendar_event_action_shows_item_count ( calendar_event $event,
$itemcount = 0 )

Callback function that determines whether an action event should be showing its item count based on the event type and the item count.

Parameters
calendar_event$eventThe calendar event.
int$itemcountThe item count associated with the action event.
Return values
bool

◆ mod_forum_core_calendar_event_timestart_updated()

mod_forum_core_calendar_event_timestart_updated ( \calendar_event $event,
stdClass $forum )

This function will update the forum module according to the event that has been modified.

It will set the timeclose value of the forum instance according to the type of event provided.

Exceptions
moodle_exception
Parameters
calendar_event$event
stdClass$forumThe module instance to get the range from

◆ mod_forum_core_calendar_get_event_action_string()

mod_forum_core_calendar_get_event_action_string ( string $eventtype)

Callback to fetch the activity event type lang string.

Parameters
string$eventtypeThe event type.
Return values
lang_stringThe event type lang string.

◆ mod_forum_core_calendar_get_valid_event_timestart_range()

mod_forum_core_calendar_get_valid_event_timestart_range ( \calendar_event $event,
stdClass $forum )

This function calculates the minimum and maximum cutoff values for the timestart of the given event.

It will return an array with two values, the first being the minimum cutoff value and the second being the maximum cutoff value. Either or both values can be null, which indicates there is no minimum or maximum, respectively.

If a cutoff is required then the function must return an array containing the cutoff timestamp and error string to display to the user if the cutoff value is violated.

A minimum and maximum cutoff return value will look like: [ [1505704373, 'The date must be after this date'], [1506741172, 'The date must be before this date'] ]

Parameters
calendar_event$eventThe calendar event to get the time range for
stdClass$forumThe module instance to get the range from
Return values
arrayReturns an array with min and max date.

◆ mod_forum_core_calendar_provide_event_action()

mod_forum_core_calendar_provide_event_action ( calendar_event $event,
core_calendar\action_factory $factory,
int $userid = 0 )

This function receives a calendar event and returns the action associated with it, or null if there is none.

This is used by block_myoverview in order to display the event appropriately. If null is returned then the event is not displayed on the block.

Parameters
calendar_event$event
core_calendar\action_factory$factory
int$useridUser id to use for all capability checks, etc. Set to 0 for current user (default).
Return values
core_calendar\local\event\entities\action_interface|null

◆ mod_forum_count_all_discussions()

mod_forum_count_all_discussions ( \mod_forum\local\entities\forum $forum,
stdClass $user,
?int $groupid )

Get a count of all discussions in a forum.

Parameters
mod_forum\local\entities\forum$forumThe forum entity
stdClass$userThe user to render for
int$groupidThe group to render
Return values
intThe number of discussions in a forum

◆ mod_forum_get_completion_active_rule_descriptions()

mod_forum_get_completion_active_rule_descriptions ( $cm)

Callback which returns human-readable strings describing the active completion custom rules for the module instance.

Parameters
cm_info | stdClass$cmobject with fields ->completion and ->customdata['customcompletionrules']
Return values
array\$descriptionsthe array of descriptions for the custom rules.

◆ mod_forum_get_discussion_summaries()

mod_forum_get_discussion_summaries ( \mod_forum\local\entities\forum $forum,
stdClass $user,
?int $groupid,
?int $sortorder,
?int $pageno = 0,
?int $pagesize = 0 )

Fetch the data used to display the discussions on the current page.

Parameters
mod_forum\local\entities\forum$forumThe forum entity
stdClass$userThe user to render for
int[] | null$groupidThe group to render
int | null$sortorderThe sort order to use when selecting the discussions in the list
int | null$pagenoThe zero-indexed page number to use
int | null$pagesizeThe number of discussions to show on the page
Return values
arrayThe data to use for display

◆ mod_forum_get_fontawesome_icon_map()

mod_forum_get_fontawesome_icon_map ( )

Get icon mapping for font-awesome.

Return values
array

◆ mod_forum_get_groups_from_groupid()

mod_forum_get_groups_from_groupid ( \mod_forum\local\entities\forum $forum,
stdClass $user,
?int $groupid )

Get the list of groups to show based on the current user and requested groupid.

Parameters
mod_forum\local\entities\forum$forumThe forum entity
stdClass$userThe user viewing
int$groupidThe groupid requested
Return values
arrayThe list of groups to show

◆ mod_forum_get_tagged_posts()

mod_forum_get_tagged_posts ( $tag,
$exclusivemode = false,
$fromctx = 0,
$ctx = 0,
$rec = 1,
$page = 0 )

Returns forum posts tagged with a specified tag.

This is a callback used by the tag area mod_forum/forum_posts to search for forum posts tagged with a specific tag.

Parameters
core_tag_tag$tag
bool$exclusivemodeif set to true it means that no other entities tagged with this tag are displayed on the page and the per-page limit may be bigger
int$fromctxcontext id where the link was displayed, may be used by callbacks to display items in the same context first
int$ctxcontext id where to search for records
bool$recsearch in subcontexts as well
int$page0-based number of page being displayed
Return values
core_tag\output\tagindex

◆ mod_forum_inplace_editable()

mod_forum_inplace_editable ( $itemtype,
$itemid,
$newvalue )

Manage inplace editable saves.

Parameters
string$itemtypeThe type of item.
int$itemidThe ID of the item.
mixed$newvalueThe new value
Return values
string

◆ mod_forum_myprofile_navigation()

mod_forum_myprofile_navigation ( core_user\output\myprofile\tree $tree,
$user,
$iscurrentuser,
$course )

Add nodes to myprofile page.

Parameters
core_user\output\myprofile\tree$treeTree object
stdClass$useruser object
bool$iscurrentuser
stdClass$courseCourse object
Return values
bool

◆ mod_forum_rating_can_see_item_ratings()

mod_forum_rating_can_see_item_ratings ( $params)

Can the current user see ratings for a given itemid?

Parameters
array$paramssubmitted data contextid => int contextid [required] component => The component for this module - should always be mod_forum [required] ratingarea => object the context in which the rated items exists [required] itemid => int the ID of the object being rated [required] scaleid => int scale id [optional]
Return values
bool
Exceptions
coding_exception
rating_exception

◆ mod_forum_user_preferences()

mod_forum_user_preferences ( )

Return a list of all the user preferences used by mod_forum.

Return values
array

Variable Documentation

◆ FORUM_EVENT_TYPE_DUE

const FORUM_EVENT_TYPE_DUE 'due'

Library of functions for forum outside of the core api.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

◆ FORUM_MODE_FLATOLDEST

const FORUM_MODE_FLATOLDEST 1

Include required files.

CONSTANTS ///////////////////////////////////////////////////////////

◆ FORUM_TRACKING_FORCED

const FORUM_TRACKING_FORCED 2

FORUM_TRACKING_FORCED - Tracking is on, regardless of user setting.

Treated as FORUM_TRACKING_OPTIONAL if $CFG->forum_allowforcedreadtracking is off.