Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
mod_forum

Namespaces

namespace  mod_forum
  
 
namespace  mod_forum\analytics\indicator
  
 
namespace  mod_forum\completion
  
 
namespace  mod_forum\event
  
 
namespace  mod_forum\form
  
 
namespace  mod_forum\grades
  
 
namespace  mod_forum\h5p
  
 
namespace  mod_forum\local
  
 
namespace  mod_forum\local\builders
  
 
namespace  mod_forum\local\data_mappers\legacy
  
 
namespace  mod_forum\local\entities
  
 
namespace  mod_forum\local\exporters
  
 
namespace  mod_forum\local\factories
  
 
namespace  mod_forum\local\managers
  
 
namespace  mod_forum\local\renderers
  
 
namespace  mod_forum\local\vaults
  
 
namespace  mod_forum\local\vaults\preprocessors
  
 
namespace  mod_forum\message\inbound
  
 
namespace  mod_forum\output
  
 
namespace  mod_forum\output\courseformat
  
 
namespace  mod_forum\output\email
  
 
namespace  mod_forum\output\emaildigestbasic
  
 
namespace  mod_forum\output\emaildigestfull
  
 
namespace  mod_forum\plugininfo
  
 
namespace  mod_forum\privacy
  
 
namespace  mod_forum\search
  
 
namespace  mod_forum\task
  
 

Classes

class  backup_forum_activity_structure_step
 Define all the backup steps that will be used by the backup_forum_activity_task. More...
 
class  backup_forum_activity_task
 Provides the steps to perform one complete backup of the Forum instance. More...
 
class  behat_mod_forum
 Forum-related steps definitions. More...
 
class  behat_mod_forum_generator
 
class  forum_file_info_container
 Class representing the virtual node with all itemids in the file browser. More...
 
class  forum_portfolio_caller
 
class  mod_forum\analytics\indicator\activity_base
 Activity base class. More...
 
class  mod_forum\analytics\indicator\cognitive_depth
 Cognitive depth indicator - forum. More...
 
class  mod_forum\analytics\indicator\social_breadth
 Social breadth indicator - forum. More...
 
class  mod_forum\completion\custom_completion
 
class  mod_forum\dates
 Class for fetching the important dates in mod_forum for a given module instance and a user. More...
 
class  mod_forum\event\assessable_uploaded
 
class  mod_forum\event\course_module_instance_list_viewed
 The mod_forum instance list viewed event class. More...
 
class  mod_forum\event\course_module_viewed
 The mod_forum course module viewed event class. More...
 
class  mod_forum\event\discussion_lock_updated
 
class  mod_forum\event\discussion_moved
 
class  mod_forum\event\discussion_pinned
 The mod_forum discussion pinned event. More...
 
class  mod_forum\event\discussion_unpinned
 The mod_forum discussion unpinned event. More...
 
class  mod_forum\event\discussion_viewed
 The mod_forum discussion viewed event class. More...
 
class  mod_forum\event\readtracking_disabled
 
class  mod_forum\event\readtracking_enabled
 
class  mod_forum\event\subscription_created
 
class  mod_forum\event\subscription_deleted
 
class  mod_forum\event\subscription_mode_updated
 
class  mod_forum\event\user_report_viewed
 
class  mod_forum\form\export_form
 Export discussion form. More...
 
class  mod_forum\grades\forum_gradeitem
 Grade item storage for mod_forum. More...
 
class  mod_forum\grades\gradeitems
 Grade item mappings for the activity. More...
 
class  mod_forum\h5p\canedit
 
class  mod_forum\local\builders\exported_discussion
 Exported discussion builder class. More...
 
class  mod_forum\local\builders\exported_discussion_summaries
 Exported discussion summaries builder class. More...
 
class  mod_forum\local\builders\exported_posts
 Exported post builder class. More...
 
class  mod_forum\local\container
 Container class. More...
 
class  mod_forum\local\data_mappers\legacy\author
 Convert an author entity into an stdClass. More...
 
class  mod_forum\local\data_mappers\legacy\discussion
 Convert a discussion entity into an stdClass. More...
 
class  mod_forum\local\data_mappers\legacy\forum
 Convert a forum entity into an stdClass. More...
 
class  mod_forum\local\data_mappers\legacy\post
 Convert a post entity into an stdClass. More...
 
class  mod_forum\local\entities\author
 Author class. More...
 
class  mod_forum\local\entities\discussion
 Discussion class. More...
 
class  mod_forum\local\entities\discussion_summary
 Discussion summary class. More...
 
class  mod_forum\local\entities\forum
 Forum class. More...
 
class  mod_forum\local\entities\post
 Post class. More...
 
class  mod_forum\local\entities\post_read_receipt_collection
 Post read receipt collection class. More...
 
class  mod_forum\local\entities\sorter
 Class to sort lists of items. More...
 
class  mod_forum\local\exporters\author
 Author exporter. More...
 
class  mod_forum\local\exporters\discussion
 Discussion exporter class. More...
 
class  mod_forum\local\exporters\discussion_summaries
 Discussion summaries exporter. More...
 
class  mod_forum\local\exporters\discussion_summary
 Discussion summary exporter class. More...
 
class  mod_forum\local\exporters\forum
 Forum class. More...
 
class  mod_forum\local\exporters\group
 Group exporter. More...
 
class  mod_forum\local\exporters\post
 Post exporter class. More...
 
class  mod_forum\local\exporters\posts
 Posts exporter class. More...
 
class  mod_forum\local\factories\builder
 Builder factory to construct any builders for forum. More...
 
class  mod_forum\local\factories\entity
 Entity factory to create the forum entities. More...
 
class  mod_forum\local\factories\exporter
 The exporter factory class used to fetch an instance of the different exporter types. More...
 
class  mod_forum\local\factories\legacy_data_mapper
 Legacy data mapper factory. More...
 
class  mod_forum\local\factories\manager
 Managers factory. More...
 
class  mod_forum\local\factories\renderer
 Renderer factory. More...
 
class  mod_forum\local\factories\url
 A URL factory for the forum. More...
 
class  mod_forum\local\factories\vault
 Vault factory. More...
 
class  mod_forum\local\managers\capability
 Capability manager for the forum. More...
 
class  mod_forum\local\renderers\discussion
 Discussion renderer class. More...
 
class  mod_forum\local\renderers\discussion_list
 The discussion list renderer. More...
 
class  mod_forum\local\renderers\posts
 Posts renderer class. More...
 
class  mod_forum\local\vaults\author
 Author vault class. More...
 
class  mod_forum\local\vaults\db_table_vault
 Abstract class for loading records from the DB. More...
 
class  mod_forum\local\vaults\discussion
 Discussion vault class. More...
 
class  mod_forum\local\vaults\discussion_list
 Discussion list vault. More...
 
class  mod_forum\local\vaults\forum
 Forum vault class. More...
 
class  mod_forum\local\vaults\post
 Post vault class. More...
 
class  mod_forum\local\vaults\post_attachment
 Post attachment vault class. More...
 
class  mod_forum\local\vaults\post_read_receipt_collection
 Post read receipt collection class. More...
 
class  mod_forum\local\vaults\preprocessors\extract_context
 Extract context vault preprocessor. More...
 
class  mod_forum\local\vaults\preprocessors\extract_record
 Extract record vault preprocessor. More...
 
class  mod_forum\local\vaults\preprocessors\extract_user
 Extract user vault preprocessor. More...
 
class  mod_forum\message\inbound\reply_handler
 A Handler to process replies to forum posts. More...
 
class  mod_forum\output\big_search_form
 Big search form class. More...
 
class  mod_forum\output\courseformat\activitybadge
 
class  mod_forum\output\email\renderer
 Forum post renderable. More...
 
class  mod_forum\output\email\renderer_textemail
 Forum post renderable. More...
 
class  mod_forum\output\emaildigestbasic\renderer
 Forum post renderable. More...
 
class  mod_forum\output\emaildigestbasic\renderer_textemail
 Forum post renderable. More...
 
class  mod_forum\output\emaildigestfull\renderer
 Forum post renderable. More...
 
class  mod_forum\output\emaildigestfull\renderer_textemail
 Forum post renderable. More...
 
class  mod_forum\output\forum_actionbar
 
class  mod_forum\output\forum_post
 
class  mod_forum\output\forum_post_email
 Forum post renderable for use in e-mail. More...
 
class  mod_forum\output\quick_search_form
 Quick search form renderable class. More...
 
class  mod_forum\output\subscription_actionbar
 
class  mod_forum\plugininfo\forumreport
 Forum report subplugin info class. More...
 
class  mod_forum\privacy\provider
 Implementation of the privacy subsystem plugin provider for the forum activity module. More...
 
class  mod_forum\search\activity
 Forum activities search area. More...
 
class  mod_forum\search\post
 Forum posts search area. More...
 
class  mod_forum\subscriptions
 Forum subscription manager. More...
 
class  mod_forum\task\cron_task
 The main scheduled task for the forum. More...
 
class  mod_forum\task\send_user_digests
 Adhoc task to send moodle forum digests for the specified user. More...
 
class  mod_forum\task\send_user_notifications
 Adhoc task to send user forum notifications. More...
 
class  mod_forum_existing_subscriber_selector
 User selector control for removing subscribed users. More...
 
class  mod_forum_external
 
class  mod_forum_generator
 
class  mod_forum_mod_form
 
class  mod_forum_observer
 Event observer for mod_forum. More...
 
class  mod_forum_post_form
 Class to post in a forum. More...
 
class  mod_forum_potential_subscriber_selector
 A user selector control for potential subscribers to the selected forum. More...
 
class  mod_forum_prune_form
 Form which displays fields for splitting forum post to a separate threads. More...
 
class  mod_forum_renderer
 A custom renderer class that extends the plugin_renderer_base and is used by the forum module. More...
 
class  mod_forum_subscriber_selector_base
 Abstract class used by forum subscriber selection controls. More...
 
class  moodle1_mod_forum_handler
 Forum conversion handler. More...
 
class  restore_forum_activity_structure_step
 Define all the restore steps that will be used by the restore_forum_activity_task. More...
 
class  restore_forum_activity_task
 forum restore task that provides all the settings and steps to perform one complete restore of the activity More...
 

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_convert_to_roles ()
 
 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
 
 forum_count_replies ()
 
 forum_count_unrated_posts ()
 
object forum_count_user_posts ($forumid, $userid)
 Get all the posts for a user in a forum suitable for forum_print_post.
 
 forum_cron ()
 
 forum_cron_minimise_user_record ()
 
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_forcesubscribe ($forumid, $value=1)
 
 forum_get_all_discussion_posts ($discussionid, $sort, $tracking=false)
 Gets all posts in discussion including top parent.
 
 forum_get_child_posts ()
 
 forum_get_completion_state ()
 
 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_posts ()
 
 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_forcesubscribed ($forum)
 
 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_open_modes ()
 
 forum_get_optional_subscribed_forums ()
 
 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.
 
 forum_get_potential_subscribers ()
 
 forum_get_ratings ()
 
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_subscribed_forums ()
 
 forum_get_subscriptionmode_options ()
 List the options for forum subscription modes.
 
 forum_get_tracking_link ()
 
 forum_get_user_digest_options ($user=null)
 Retrieve the list of available user digest options.
 
 forum_get_user_discussions ()
 
 forum_get_user_grades ()
 
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_forcesubscribed ($forum)
 Determine whether the forum is force subscribed.
 
 forum_is_subscribed ()
 
 forum_is_user_group_discussion (cm_info $cm, $discussiongroupid)
 Returns whether the discussion group is visible by the current user or not.
 
 forum_make_mail_html ()
 
 forum_make_mail_post ()
 
 forum_make_mail_text ()
 
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_nesting_cache ()
 
 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_discussion ()
 
 forum_print_discussion_header ()
 This function prints the overview of a discussion in the forum listing.
 
 forum_print_latest_discussions ()
 
 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 ()
 
 forum_print_post ()
 
 forum_print_post_end ()
 
 forum_print_post_start ()
 
 forum_print_posts_flat ()
 
 forum_print_posts_nested ()
 
 forum_print_posts_threaded ()
 
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_rss_delete_file ($forum)
 Given a forum object, deletes all cached RSS files associated with it.
 
 forum_rss_feed_contents ($forum, $sql, $params, $context)
 This function return the XML rss contents about the forum It returns false if something is wrong.
 
 forum_rss_feed_discussions_sql ($forum, $cm, $newsince=0)
 Generates the SQL query used to get the Discussion details from the forum table of the database.
 
 forum_rss_feed_posts_sql ($forum, $cm, $newsince=0)
 Generates the SQL query used to get the Post details from the forum table of the database.
 
 forum_rss_get_feed ($context, $args)
 Returns the path to the cached rss feed contents.
 
 forum_rss_get_group_sql ($cm, $groupmode, $currentgroup, $modcontext=null)
 Retrieve the correct SQL snippet for group-only forums.
 
 forum_rss_get_sql ($forum, $cm, $time=0)
 Determines which type of SQL query is required, one for posts or one for discussions, and returns the appropriate query.
 
 forum_rss_newstuff ($forum, $cm, $time)
 If there is new stuff in the forum since $time this returns true Otherwise it returns false.
 
 forum_scale_used ()
 
 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_shorten_post ($message)
 
 forum_should_end_post_nesting ()
 
 forum_should_start_post_nesting ()
 
 forum_subscribe ()
 
 forum_subscribed_users ()
 
 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.
 
 forum_tp_count_discussion_read_records ()
 
 forum_tp_count_discussion_unread_posts ()
 
 forum_tp_count_forum_posts ()
 
 forum_tp_count_forum_read_records ()
 
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.
 
 forum_tp_get_discussion_read_records ()
 
 forum_tp_get_read_records ()
 
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_unsubscribe ()
 
 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.
 
 forum_user_can_view_post ()
 
object forum_user_complete ($course, $user, $mod, $forum)
 @global object
 
 forum_user_enrolled ()
 
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.
 
 xmldb_forum_upgrade ($oldversion)
 

Variables

 $capabilities
 
global mod_forum\local\entities::$CFG
 
global mod_forum\local\factories::$CFG
 
global $DB
 
 $definitions
 
 $functions
 
 $handlers
 
 $logs
 
 $messageproviders
 
 $observers
 
 $plugin = 2024041600
 
 $tagareas
 
 $tasks
 
since __pad0__
 
$plugin component = 'mod_forum'
 
const FORUM_CHOOSESUBSCRIBE 0
 
const FORUM_DISALLOWSUBSCRIBE 3
 
const FORUM_DISCUSSION_PINNED 1
 
const FORUM_DISCUSSION_UNPINNED 0
 
const FORUM_EVENT_TYPE_DUE 'due'
 
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_ON 2
 FORUM_TRACKING_ON - deprecated alias for FORUM_TRACKING_FORCED.
 
const FORUM_TRACKING_OPTIONAL 1
 FORUM_TRACKING_OPTIONAL - Tracking is based on user preference.
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
since mdl
 
since reason
 
$plugin version = 2024042200
 

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_convert_to_roles()

forum_convert_to_roles ( )
Deprecated
since Moodle 2.0 MDL-23479 - please do not use this function any more.

◆ 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_replies()

forum_count_replies ( )
Deprecated
since Moodle 3.7

◆ forum_count_unrated_posts()

forum_count_unrated_posts ( )
Deprecated
since Moodle 1.1 - please do not use this function any more.

◆ 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_cron()

forum_cron ( )
Deprecated
since Moodle 3.7

◆ forum_cron_minimise_user_record()

forum_cron_minimise_user_record ( )
Deprecated
since Moodle 3.7

◆ 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_forcesubscribe()

forum_forcesubscribe ( $forumid,
$value = 1 )

◆ 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_child_posts()

forum_get_child_posts ( )
Deprecated
since Moodle 1.9 MDL-13303 - please do not use this function any more.

◆ forum_get_completion_state()

forum_get_completion_state ( )
Deprecated
since Moodle 3.11

◆ 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_posts()

forum_get_discussion_posts ( )
Deprecated
since Moodle 1.9 MDL-13303 - please do not use this function any more.

◆ 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_forcesubscribed()

forum_get_forcesubscribed ( $forum)

◆ 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_open_modes()

forum_get_open_modes ( )
Deprecated
since Moodle 1.7 - please do not use this function any more.

◆ forum_get_optional_subscribed_forums()

forum_get_optional_subscribed_forums ( )

◆ 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_potential_subscribers()

forum_get_potential_subscribers ( )

◆ forum_get_ratings()

forum_get_ratings ( )
Deprecated
since Moodle 2.0 MDL-21657 - please do not use this function any more.

◆ 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_subscribed_forums()

forum_get_subscribed_forums ( )

◆ 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_tracking_link()

forum_get_tracking_link ( )
Deprecated
since Moodle 2.0 MDL-14632 - please do not use this function any more.

◆ 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_discussions()

forum_get_user_discussions ( )
Deprecated
since Moodle 1.5 - please do not use this function any more.

◆ forum_get_user_grades()

forum_get_user_grades ( )
Deprecated
since Moodle 3.8

◆ 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_forcesubscribed()

forum_is_forcesubscribed ( $forum)

Determine whether the forum is force subscribed.

Deprecated
since Moodle 2.8 use mod_forum\subscriptions\is_forcesubscribed() instead

◆ forum_is_subscribed()

forum_is_subscribed ( )

◆ 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_make_mail_html()

forum_make_mail_html ( )

◆ forum_make_mail_post()

forum_make_mail_post ( )

◆ forum_make_mail_text()

forum_make_mail_text ( )

◆ 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_nesting_cache()

forum_post_nesting_cache ( )
Deprecated
since Moodle 3.7

◆ 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_discussion()

forum_print_discussion ( )
Deprecated
since Moodle 3.7

◆ forum_print_discussion_header()

forum_print_discussion_header ( )

This function prints the overview of a discussion in the forum listing.

It needs some discussion information and some post information, these happen to be combined for efficiency in the $post parameter by the function that calls this one: forum_print_latest_discussions()

Deprecated
since Moodle 4.3

◆ forum_print_latest_discussions()

forum_print_latest_discussions ( )
Deprecated
since Moodle 3.7

◆ 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_post()

forum_print_post ( )
Deprecated
since Moodle 3.7

◆ forum_print_post_end()

forum_print_post_end ( )
Deprecated
since Moodle 3.7

◆ forum_print_post_start()

forum_print_post_start ( )
Deprecated
since Moodle 3.7

◆ forum_print_posts_flat()

forum_print_posts_flat ( )
Deprecated
since Moodle 3.7

◆ forum_print_posts_nested()

forum_print_posts_nested ( )
Deprecated
since Moodle 3.7

◆ forum_print_posts_threaded()

forum_print_posts_threaded ( )
Deprecated
since Moodle 3.7

◆ 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_rss_delete_file()

forum_rss_delete_file ( $forum)

Given a forum object, deletes all cached RSS files associated with it.

Parameters
stdClass$forum

◆ forum_rss_feed_contents()

forum_rss_feed_contents ( $forum,
$sql,
$params,
$context )

This function return the XML rss contents about the forum It returns false if something is wrong.

Parameters
stdClass$forumthe forum object
string$sqlthe SQL used to retrieve the contents from the database
array$paramsthe SQL parameters used
object$contextthe context this forum relates to
Return values
bool|stringfalse if the contents is empty, otherwise the contents of the feed is returned

@Todo MDL-31129 implement post attachment handling

◆ forum_rss_feed_discussions_sql()

forum_rss_feed_discussions_sql ( $forum,
$cm,
$newsince = 0 )

Generates the SQL query used to get the Discussion details from the forum table of the database.

Parameters
stdClass$forumthe forum object
stdClass$cmCourse Module object
int$newsincecheck for items since this epoch timestamp
Return values
stringthe SQL query to be used to get the Discussion details from the forum table of the database

◆ forum_rss_feed_posts_sql()

forum_rss_feed_posts_sql ( $forum,
$cm,
$newsince = 0 )

Generates the SQL query used to get the Post details from the forum table of the database.

Parameters
stdClass$forumthe forum object
stdClass$cmCourse Module object
int$newsincecheck for items since this epoch timestamp
Return values
stringthe SQL query to be used to get the Post details from the forum table of the database

◆ forum_rss_get_feed()

forum_rss_get_feed ( $context,
$args )

Returns the path to the cached rss feed contents.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later Creates/updates the cache if necessary.
Parameters
stdClass$contextthe context
array$argsthe arguments received in the url
Return values
stringthe full path to the cached RSS feed directory. Null if there is a problem.

◆ forum_rss_get_group_sql()

forum_rss_get_group_sql ( $cm,
$groupmode,
$currentgroup,
$modcontext = null )

Retrieve the correct SQL snippet for group-only forums.

Parameters
stdClass$cmCourse Module object
int$groupmodethe mode in which the forum's groups are operating
bool$currentgrouptrue if the user is from the a group enabled on the forum
stdClass$modcontextThe context instance of the forum module
Return values
stringSQL Query for group details of the forum

◆ forum_rss_get_sql()

forum_rss_get_sql ( $forum,
$cm,
$time = 0 )

Determines which type of SQL query is required, one for posts or one for discussions, and returns the appropriate query.

Parameters
stdClass$forumthe forum object
stdClass$cmCourse Module object
int$timecheck for items since this epoch timestamp
Return values
stringthe SQL query to be used to get the Discussion/Post details from the forum table of the database

◆ forum_rss_newstuff()

forum_rss_newstuff ( $forum,
$cm,
$time )

If there is new stuff in the forum since $time this returns true Otherwise it returns false.

Parameters
stdClass$forumthe forum object
stdClass$cmCourse Module object
int$timecheck for items since this epoch timestamp
Return values
boolTrue for new items

◆ forum_scale_used()

forum_scale_used ( )
Deprecated
since Moodle 3.8

◆ 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_shorten_post()

forum_shorten_post ( $message)
Deprecated
since Moodle 2.6
See also
shorten_text()

◆ forum_should_end_post_nesting()

forum_should_end_post_nesting ( )
Deprecated
since Moodle 3.7

◆ forum_should_start_post_nesting()

forum_should_start_post_nesting ( )
Deprecated
since Moodle 3.7

◆ forum_subscribe()

forum_subscribe ( )

◆ forum_subscribed_users()

forum_subscribed_users ( )

◆ 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_discussion_read_records()

forum_tp_count_discussion_read_records ( )
Deprecated
since Moodle 1.5 - please do not use this function any more.

◆ forum_tp_count_discussion_unread_posts()

forum_tp_count_discussion_unread_posts ( )
Deprecated
since Moodle 2.0 MDL-14113 - please do not use this function any more.

◆ forum_tp_count_forum_posts()

forum_tp_count_forum_posts ( )
Deprecated
since Moodle 1.6 - please do not use this function any more.

◆ forum_tp_count_forum_read_records()

forum_tp_count_forum_read_records ( )
Deprecated
since Moodle 1.6 - please do not use this function any more.

◆ 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_discussion_read_records()

forum_tp_get_discussion_read_records ( )
Deprecated
since Moodle 2.0 MDL-14113 - please do not use this function any more.

◆ forum_tp_get_read_records()

forum_tp_get_read_records ( )
Deprecated
since Moodle 2.0 MDL-14113 - please do not use this function any more.

◆ 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_unsubscribe()

forum_unsubscribe ( )

◆ 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_can_view_post()

forum_user_can_view_post ( )

◆ forum_user_complete()

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

@global object

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

◆ forum_user_enrolled()

forum_user_enrolled ( )
Deprecated
since Moodle 2.3 MDL-33166 - please do not use this function any more.

◆ 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

◆ $definitions

$definitions
Initial value:
= [
'forum_is_tracked' => [
'mode' => cache_store::MODE_REQUEST,
'simplekeys' => true,
'simpledata' => true,
'staticacceleration' => true
],
'forum_count_discussions' => [
'mode' => cache_store::MODE_REQUEST,
'simplekeys' => true,
'simpledata' => true,
'staticacceleration' => true,
'invalidationevents' => [
'changesinforumdiscussions',
],
],
]

◆ $handlers

$handlers
Initial value:
= array(
array(
'classname' => '\mod_forum\message\inbound\reply_handler',
),
)

◆ $logs

$logs
Initial value:
= array(
array('module' => 'forum', 'action' => 'add', 'mtable' => 'forum', 'field' => 'name'),
array('module' => 'forum', 'action' => 'update', 'mtable' => 'forum', 'field' => 'name'),
array('module' => 'forum', 'action' => 'add discussion', 'mtable' => 'forum_discussions', 'field' => 'name'),
array('module' => 'forum', 'action' => 'add post', 'mtable' => 'forum_posts', 'field' => 'subject'),
array('module' => 'forum', 'action' => 'update post', 'mtable' => 'forum_posts', 'field' => 'subject'),
array('module' => 'forum', 'action' => 'user report', 'mtable' => 'user',
'field' => $DB->sql_concat('firstname', "' '", 'lastname')),
array('module' => 'forum', 'action' => 'move discussion', 'mtable' => 'forum_discussions', 'field' => 'name'),
array('module' => 'forum', 'action' => 'view subscribers', 'mtable' => 'forum', 'field' => 'name'),
array('module' => 'forum', 'action' => 'view discussion', 'mtable' => 'forum_discussions', 'field' => 'name'),
array('module' => 'forum', 'action' => 'view forum', 'mtable' => 'forum', 'field' => 'name'),
array('module' => 'forum', 'action' => 'subscribe', 'mtable' => 'forum', 'field' => 'name'),
array('module' => 'forum', 'action' => 'unsubscribe', 'mtable' => 'forum', 'field' => 'name'),
array('module' => 'forum', 'action' => 'pin discussion', 'mtable' => 'forum_discussions', 'field' => 'name'),
array('module' => 'forum', 'action' => 'unpin discussion', 'mtable' => 'forum_discussions', 'field' => 'name'),
)

◆ $messageproviders

$messageproviders
Initial value:
= array (
'posts' => array(
'defaults' => [
'popup' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
'email' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
'airnotifier' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
],
),
'digests' => [
'defaults' => [
'popup' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
'email' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
],
],
)

◆ $observers

$observers
Initial value:
= array(
array(
'eventname' => '\core\event\user_enrolment_deleted',
'callback' => 'mod_forum_observer::user_enrolment_deleted',
),
array(
'eventname' => '\core\event\role_assigned',
'callback' => 'mod_forum_observer::role_assigned'
),
array(
'eventname' => '\core\event\course_module_created',
'callback' => 'mod_forum_observer::course_module_created',
),
array(
'eventname' => '\core\event\course_created',
'callback' => 'mod_forum_observer::course_created',
),
array(
'eventname' => '\core\event\course_updated',
'callback' => 'mod_forum_observer::course_updated',
),
)
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

◆ $tagareas

$tagareas
Initial value:
= array(
array(
'itemtype' => 'forum_posts',
'component' => 'mod_forum',
'callback' => 'mod_forum_get_tagged_posts',
'callbackfile' => '/mod/forum/locallib.php',
),
)

◆ $tasks

$tasks
Initial value:
= array(
array(
'classname' => 'mod_forum\task\cron_task',
'blocking' => 0,
'minute' => '*',
'hour' => '*',
'day' => '*',
'month' => '*',
'dayofweek' => '*'
)
)

◆ __pad0__

since __pad0__
Deprecated
since Moodle 4.0

◆ 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.

◆ FORUM_TRACKING_ON

const FORUM_TRACKING_ON 2

FORUM_TRACKING_ON - deprecated alias for FORUM_TRACKING_FORCED.

Deprecated
since 2.6