Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Functions | Variables
lib.php File Reference

Functions

object forum_add_attachment ($post, $forum, $cm, $mform=null, $unused=null)
 If successful, this function returns the name of the file. More...
 
 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. More...
 
 forum_add_instance ($forum, $mform=null)
 STANDARD FUNCTIONS ///////////////////////////////////////////////////////////. More...
 
 forum_add_new_post ($post, $mform, $unused=null)
 Add a new post in an existing discussion. More...
 
 forum_can_create_attachment ($forum, $context)
 Check if the user can create attachments in a forum. More...
 
object forum_change_discussionid ($postid, $discussionid)
 recursively sets the discussion field to $discussionid on $postid and all its children used when pruning a post More...
 
 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. More...
 
 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. More...
 
 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. More...
 
 forum_cm_info_view (cm_info $cm)
 Adds information about unread messages, that is only required for the course view page (and similar), to the course-module object. More...
 
 forum_count_discussion_replies ($forumid, $forumsort="", $limit=-1, $page=-1, $perpage=0, $canseeprivatereplies=false)
 Returns an array of counts of replies to each discussion. More...
 
object forum_count_discussions ($forum, $cm, $course)
 @global object @global object @staticvar array $cache More...
 
object forum_count_user_posts ($forumid, $userid)
 Get all the posts for a user in a forum suitable for forum_print_post. More...
 
object forum_delete_discussion ($discussion, $fulldelete, $course, $cm, $forum)
 Deletes a discussion and handles all associated cleanup. More...
 
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. More...
 
object forum_delete_post ($post, $children, $course, $cm, $forum, $skipcompletion=false)
 Deletes a single forum post. More...
 
 forum_discussion_is_locked ($forum, $discussion)
 Determine whether the specified discussion is time-locked. More...
 
 forum_discussion_pin ($modcontext, $forum, $discussion)
 Set the discussion to pinned and trigger the discussion pinned event. More...
 
 forum_discussion_unpin ($modcontext, $forum, $discussion)
 Set discussion to unpinned and trigger the discussion unpin event. More...
 
object forum_discussion_update_last_post ($discussionid)
 Sets the last post for a given discussion. More...
 
 forum_discussion_view ($modcontext, $forum, $discussion)
 Trigger the discussion viewed event. More...
 
object forum_discussions_user_has_posted_in ($forumid, $userid)
 @global object More...
 
 forum_extend_settings_navigation (settings_navigation $settingsnav, navigation_node $forumnode)
 Adds module specific settings to the settings block. More...
 
 forum_filter_user_groups_discussions ()
 
 forum_get_all_discussion_posts ($discussionid, $sort, $tracking=false)
 Gets all posts in discussion including top parent. More...
 
object forum_get_completion_state ($course, $cm, $userid, $type)
 Obtains the automatic completion state for this forum based on any conditions in forum settings. More...
 
 forum_get_context ($forumid, $context=null)
 Determine the current context if one was not already specified. More...
 
object forum_get_course_forum ($courseid, $type)
 @global object More...
 
 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). More...
 
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. More...
 
 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. More...
 
 forum_get_discussion_neighbours ($cm, $discussion, $forum)
 Gets the neighbours (previous and next) of a discussion. More...
 
 forum_get_discussion_subscription_icon ($forum, $discussionid, $returnurl=null, $includetext=false)
 Return the markup for the discussion subscription toggling icon. More...
 
 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. More...
 
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. More...
 
object forum_get_discussions_count ($cm)
 @global object @global object @uses CONEXT_MODULE @uses VISIBLEGROUPS More...
 
object forum_get_discussions_unread ($cm)
 @global object @global object @uses CONTEXT_MODULE @uses VISIBLEGROUPS More...
 
 forum_get_email_message_id ($postid, $usertoid)
 Create a message-id string to use in the custom headers of forum notification emails. More...
 
 forum_get_extra_capabilities ()
 Returns all other caps used in module. More...
 
 forum_get_file_areas ($course, $cm, $context)
 
 forum_get_file_info ($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename)
 
object forum_get_firstpost_from_discussion ($discussionid)
 Given a discussion id, return the first post from the discussion. More...
 
 forum_get_forum_types ()
 Returns array of forum types chooseable on the forum editing form. More...
 
 forum_get_forum_types_all ()
 Returns array of all forum layout modes. More...
 
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. More...
 
 forum_get_layout_modes (bool $useexperimentalui=false)
 Returns array of forum layout modes. More...
 
 forum_get_post_actions ()
 List the actions that correspond to a post of this module. More...
 
object forum_get_post_from_log ($log)
 Given a log entry, return the forum post details for it. More...
 
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. More...
 
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. More...
 
object forum_get_readable_forums ($userid, $courseid=0)
 An array of forum objects that the user is allowed to read/search through. More...
 
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. More...
 
 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. More...
 
 forum_get_subscriptionmode_options ()
 List the options for forum subscription modes. More...
 
 forum_get_user_digest_options ($user=null)
 Retrieve the list of available user digest options. More...
 
object forum_get_user_involved_discussions ($forumid, $userid)
 Get all the discussions user participated in. More...
 
 forum_get_user_maildigest_bulk ($digests, $user, $forumid)
 Determine the maildigest setting for the specified user against the specified forum. More...
 
object forum_get_user_posted_time ($did, $userid)
 Returns creation time of the first user's post in given discussion $DB. More...
 
object forum_get_user_posts ($forumid, $userid)
 Get all the posts for a user in a forum suitable for forum_print_post. More...
 
 forum_get_view_actions ()
 List the actions that correspond to a view of this module. More...
 
object forum_go_back_to ($default)
 
 forum_grade_item_delete ($forum)
 Delete grade item for given forum. More...
 
 forum_grade_item_update ($forum, $ratings=null, $forumgrades=null)
 Create/update grade items for given forum. More...
 
 forum_grading_areas_list ()
 Lists all gradable areas for the advanced grading methods gramework. More...
 
 forum_instance_created ($context, $forum)
 Handle changes following the creation of a forum instance. More...
 
 forum_is_author_hidden ($post, $forum)
 Checks whether the author's name and picture for a given post should be hidden or not. More...
 
 forum_is_cutoff_date_reached ($forum)
 Determine whether the specified forum's cutoff date is reached. More...
 
 forum_is_due_date_reached ($forum)
 Determine whether the specified forum's due date is reached. More...
 
 forum_is_user_group_discussion (cm_info $cm, $discussiongroupid)
 Returns whether the discussion group is visible by the current user or not. More...
 
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. More...
 
 forum_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types. More...
 
 forum_pluginfile ($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array())
 
 forum_post_is_visible_privately ($post, $cm)
 Check whether the forum post is a private reply visible to this user. More...
 
 forum_post_subscription ($fromform, $forum, $discussion)
 Given a new post, subscribes or unsubscribes as appropriate. More...
 
object forum_print_attachments ($post, $cm, $type)
 Returns attachments as formated text/html optionally with separate images. More...
 
object forum_print_discussion_header (&$post, $forum, $group=-1, $datestring="", $cantrack=true, $forumtracked=true, $canviewparticipants=true, $modcontext=null, $canviewhiddentimedposts=false)
 This function prints the overview of a discussion in the forum listing. More...
 
 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. More...
 
 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. More...
 
 forum_print_recent_mod_activity ($activity, $courseid, $detail, $modnames, $viewfullnames)
 Outputs the forum post indicated by $activity. More...
 
 forum_rating_permissions ($contextid, $component, $ratingarea)
 Return rating related permissions. More...
 
 forum_rating_validate ($params)
 Validates a submitted rating. More...
 
 forum_reset_course_form_defaults ($course)
 Course reset form defaults. More...
 
 forum_reset_course_form_definition (&$mform)
 Called by course/reset.php. More...
 
object forum_reset_gradebook ($courseid, $type='')
 Removes all grades from gradebook. More...
 
object forum_reset_userdata ($data)
 This function is used by the reset_course_userdata function in moodlelib. More...
 
 forum_scale_used_anywhere (int $scaleid)
 Checks if scale is being used by any instance of forum. More...
 
object forum_search_form ($course, $search='')
 
object forum_search_posts ($searchterms, $courseid=0, $limitfrom=0, $limitnum=50, &$totalcount, $extrasql='')
 Returns a list of posts found using an array of search terms. More...
 
object forum_set_return ()
 @global object
 
 forum_set_user_maildigest ($forum, $maildigest, $user=null)
 Set the per-forum maildigest option for the specified user. More...
 
 forum_supports ($feature)
 Indicates API features that the forum supports. More...
 
object forum_tp_add_read_record ($userid, $postid)
 Mark post as read. More...
 
object forum_tp_can_track_forums ($forum=false, $user=false)
 Determine if a user can track forums and optionally a particular forum. More...
 
object forum_tp_clean_read_records ()
 Clean old records from the forum_read table. More...
 
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. More...
 
object forum_tp_delete_read_records ($userid=-1, $postid=-1, $discussionid=-1, $forumid=-1)
 Deletes read records for the specified index. More...
 
object forum_tp_get_course_unread_posts ($userid, $courseid)
 Returns the count of records for the provided user and course. More...
 
object forum_tp_get_untracked_forums ($userid, $courseid)
 Get a list of forums not tracked by the user. More...
 
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. More...
 
object forum_tp_mark_discussion_read ($user, $discussionid)
 Marks a whole discussion as read, for a given user. More...
 
object forum_tp_mark_forum_read ($user, $forumid, $groupid=false)
 Marks a whole forum as read, for a given user. More...
 
 forum_tp_mark_post_read ($userid, $post, $unused=null)
 If its an old post, do nothing. More...
 
object forum_tp_mark_posts_read ($user, $postids)
 Mark posts as read. More...
 
object forum_tp_start_tracking ($forumid, $userid=false)
 @global object More...
 
object forum_tp_stop_tracking ($forumid, $userid=false)
 @global object More...
 
 forum_trigger_content_uploaded_event ($post, $cm, $name)
 Sends post content to plagiarism plugin. More...
 
 forum_trigger_post_updated_event ($post, $discussion, $context, $forum)
 Trigger post updated event. More...
 
 forum_update_grades ($forum, $userid=0)
 Update activity grades. More...
 
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. More...
 
 forum_update_post ($newpost, $mform, $unused=null)
 Update a post. More...
 
object forum_update_subscriptions_button ($courseid, $forumid)
 Prints the editing button on subscribers page. More...
 
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. More...
 
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. More...
 
object forum_user_can_see_discussion ($forum, $discussion, $context, $user=NULL)
 @global object @uses DEBUG_DEVELOPER More...
 
 forum_user_can_see_group_discussion ($discussion, $cm, $context)
 Check to ensure a user can view a group discussion. More...
 
 forum_user_can_see_post ($forum, $discussion, $post, $user=null, $cm=null, $checkdeleted=true)
 Check whether a user can see the specified post. More...
 
 forum_user_can_see_timed_discussion ($discussion, $user, $context)
 Check to ensure a user can view a timed discussion. More...
 
object forum_user_complete ($course, $user, $mod, $forum)
 @global object More...
 
object forum_user_has_posted ($forumid, $did, $userid)
 @global object More...
 
 forum_user_has_posted_discussion ($forumid, $userid, $groupid=null)
 Returns true if user created new discussion already. More...
 
 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. More...
 
 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. More...
 
 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. More...
 
 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. More...
 
 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. More...
 
 mod_forum_count_all_discussions (\mod_forum\local\entities\forum $forum, stdClass $user, ?int $groupid)
 Get a count of all discussions in a forum. More...
 
 mod_forum_get_completion_active_rule_descriptions ($cm)
 Callback which returns human-readable strings describing the active completion custom rules for the module instance. More...
 
 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. More...
 
 mod_forum_get_fontawesome_icon_map ()
 Get icon mapping for font-awesome. More...
 
 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. More...
 
 mod_forum_inplace_editable ($itemtype, $itemid, $newvalue)
 Manage inplace editable saves. More...
 
 mod_forum_myprofile_navigation (core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course)
 Add nodes to myprofile page. More...
 
 mod_forum_rating_can_see_item_ratings ($params)
 Can the current user see ratings for a given itemid? More...
 
 mod_forum_user_preferences ()
 Return a list of all the user preferences used by mod_forum. More...
 

Variables

const FORUM_CHOOSESUBSCRIBE 0
 
const FORUM_DISALLOWSUBSCRIBE 3
 
const FORUM_DISCUSSION_PINNED 1
 
const FORUM_DISCUSSION_UNPINNED 0
 
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. More...
 
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. More...
 
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

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