Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
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\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 |
| |
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_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. | |
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 () | |
object | forum_get_completion_state ($course, $cm, $userid, $type) |
Obtains the automatic completion state for this forum based on any conditions in forum settings. | |
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. | |
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 () | |
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. | |
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_update_subscriptions_button ($courseid, $forumid) |
Prints the editing button on subscribers page. | |
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 = 2023041800 | |
$tagareas | |
$tasks | |
$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')) | |
$plugin | version = 2023042401 |
forum_activity_actionbar | ( | ?forum_entity | $forum, |
$groupid, | |||
stdClass | $course, | ||
string | $search = '' ) |
Retrieve HTML for the page action.
forum_entity | null | $forum | The forum entity. |
mixed | $groupid | false if groups not used, int if groups used, 0 means all groups |
stdClass | $course | The course object. |
string | $search | The search string. |
string | rendered HTML string. |
object forum_add_attachment | ( | $post, | |
$forum, | |||
$cm, | |||
$mform = null, | |||
$unused = null ) |
If successful, this function returns the name of the file.
object | $post | is a full post record, including course and forum |
object | $forum | |
object | $cm | |
mixed | $mform | |
string | $unused |
bool |
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.
object | $post | |
mixed | $mform | |
string | $unused | |
int | $userid |
object |
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.
stdClass | $forum | add forum instance |
mod_forum_mod_form | $mform |
int | intance id |
forum_add_new_post | ( | $post, | |
$mform, | |||
$unused = null ) |
Add a new post in an existing discussion.
stdClass | $post | The post data |
mixed | $mform | The submitted form |
string | $unused |
int |
forum_can_create_attachment | ( | $forum, | |
$context ) |
Check if the user can create attachments in a forum.
stdClass | $forum | forum object |
stdClass | $context | context object |
bool | true if the user can create attachments, false otherwise |
object forum_change_discussionid | ( | $postid, | |
$discussionid ) |
recursively sets the discussion field to $discussionid on $postid and all its children used when pruning a post
int | $postid | |
int | $discussionid |
bool |
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.
stdClass | $thresholdwarning | the warning information returned from the function 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.
int | stdClass | $forum | the forum id or the forum object |
stdClass | $cm | the course module |
stdClass|bool | returns an object with the warning information, else returns false if no warning is required. |
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.
cm_info | $cm | course module data |
int | $from | the time to check updates from |
array | $filter | if we need to check only specific updates |
stdClass | an object with the different type of areas indicating if they were updated or not |
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.
cm_info | $cm | Course-module object |
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.
int | $forumid | |
string | $forumsort | |
int | $limit | |
int | $page | |
int | $perpage | |
boolean | $canseeprivatereplies | Whether the current user can see private replies. |
array |
object forum_count_discussions | ( | $forum, | |
$cm, | |||
$course ) |
@global object @global object
object | $forum | |
object | $cm | |
object | $course |
mixed |
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.
@global object
int | $forumid | |
int | $userid |
stdClass|false | collection of counts or false |
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 | $discussion | Discussion to delete |
bool | $fulldelete | True when deleting entire forum |
object | $course | Course |
object | $cm | Course-module |
object | $forum | Forum |
bool |
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.
int | $id | forum instance id |
bool | success |
object forum_delete_post | ( | $post, | |
$children, | |||
$course, | |||
$cm, | |||
$forum, | |||
$skipcompletion = false ) |
Deletes a single forum post.
object | $post | Forum post object |
mixed | $children | Whether 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 | $course | Course |
object | $cm | Course-module |
object | $forum | Forum |
bool | $skipcompletion | True to skip updating completion state if it would otherwise be updated, i.e. when deleting entire forum anyway. |
bool |
forum_discussion_is_locked | ( | $forum, | |
$discussion ) |
Determine whether the specified discussion is time-locked.
stdClass | $forum | The forum that the discussion belongs to |
stdClass | $discussion | The discussion to test |
bool |
forum_discussion_pin | ( | $modcontext, | |
$forum, | |||
$discussion ) |
Set the discussion to pinned and trigger the discussion pinned event.
stdClass | $modcontext | module context object |
stdClass | $forum | forum object |
stdClass | $discussion | discussion object |
forum_discussion_unpin | ( | $modcontext, | |
$forum, | |||
$discussion ) |
Set discussion to unpinned and trigger the discussion unpin event.
stdClass | $modcontext | module context object |
stdClass | $forum | forum object |
stdClass | $discussion | discussion object |
object forum_discussion_update_last_post | ( | $discussionid | ) |
Sets the last post for a given discussion.
@global object
into | $discussionid |
bool|int |
forum_discussion_view | ( | $modcontext, | |
$forum, | |||
$discussion ) |
Trigger the discussion viewed event.
stdClass | $modcontext | module context object |
stdClass | $forum | forum object |
stdClass | $discussion | discussion object |
object forum_discussions_user_has_posted_in | ( | $forumid, | |
$userid ) |
@global object
int | $forumid | |
int | $userid |
array |
forum_extend_settings_navigation | ( | settings_navigation | $settingsnav, |
navigation_node | $forumnode ) |
Adds module specific settings to the settings block.
settings_navigation | $settings | The settings navigation object |
navigation_node | $forumnode | The node to add module settings to |
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.
int | $discussionid | The Discussion to fetch. |
string | $sort | The sorting to apply. |
bool | $tracking | Whether the user tracks this forum. |
array | The posts in the discussion. |
forum_get_child_posts | ( | ) |
object forum_get_completion_state | ( | $course, | |
$cm, | |||
$userid, | |||
$type ) |
Obtains the automatic completion state for this forum based on any conditions in forum settings.
@global object
object | $course | Course |
object | $cm | Course-module |
int | $userid | User ID |
bool | $type | Type of comparison (or/and; can be used as return value if no conditions) |
bool | True if completed, false if not. (If no conditions, then return value depends on comparison type) |
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.
int | $forumid | The ID of the forum |
context_module | $context | The current context. |
context_module | The context determined |
object forum_get_course_forum | ( | $courseid, | |
$type ) |
@global object
int | $courseid | |
string | $type |
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.
stdClass | $coursemodule | The coursemodule object (record). |
cached_cm_info | An object on information that the courses will know about (most noticeably, an icon). |
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
stdClass | $user | The user who's posts we are looking for |
bool | $discussionsonly | If true only look for discussions started by the user |
bool | $includecontexts | If set to trye contexts for the courses will be preloaded |
int | $limitfrom | The offset of records to return |
int | $limitnum | The number of records to return |
array | An array of courses |
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.
bool | $desc | True for DESC, False for ASC. |
string | $compare | The field in the SQL to compare to normally sort by. |
string | $prefix | The prefix being used for the discussion table. |
bool | $pinned | sort pinned posts to the top |
string |
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.
object | $cm | The CM record. |
object | $discussion | The discussion record. |
object | $forum | The forum instance record. |
array | That 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_subscription_icon | ( | $forum, | |
$discussionid, | |||
$returnurl = null, | |||
$includetext = false ) |
Return the markup for the discussion subscription toggling icon.
stdClass | $forum | The forum object. |
int | $discussionid | The discussion to create an icon for. |
string | The generated markup. |
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.
string | The generated markup |
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
object | $cm | |
string | $forumsort | |
bool | $fullpost | |
int | $unused | |
int | $limit | |
bool | $userlastmodified | |
int | $page | |
int | $perpage | |
int | $groupid | if groups enabled, get discussions for this group overriding the current group. Use FORUM_POSTS_ALL_USER_GROUPS for all the user groups |
int | $updatedsince | retrieve only discussions updated since the given time |
array |
object forum_get_discussions_count | ( | $cm | ) |
@global object @global object @uses CONEXT_MODULE @uses VISIBLEGROUPS
object | $cm |
array |
object forum_get_discussions_unread | ( | $cm | ) |
@global object @global object @uses CONTEXT_MODULE @uses VISIBLEGROUPS
object | $cm |
array |
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
int | $postid | The ID of the forum post we are notifying the user about |
int | $usertoid | The ID of the user being notified |
string | A unique message-id |
forum_get_extra_capabilities | ( | ) |
Returns all other caps used in module.
array |
forum_get_file_areas | ( | $course, | |
$cm, | |||
$context ) |
Lists all browsable file areas.
stdClass | $course | course object |
stdClass | $cm | course module object |
stdClass | $context | context object |
array |
forum_get_file_info | ( | $browser, | |
$areas, | |||
$course, | |||
$cm, | |||
$context, | |||
$filearea, | |||
$itemid, | |||
$filepath, | |||
$filename ) |
File browsing support for forum module.
stdClass | $browser | file browser object |
stdClass | $areas | file areas |
stdClass | $course | course object |
stdClass | $cm | course module |
stdClass | $context | context module |
string | $filearea | file area |
int | $itemid | item ID |
string | $filepath | file path |
string | $filename | file name |
file_info | instance or null if not found |
object forum_get_firstpost_from_discussion | ( | $discussionid | ) |
Given a discussion id, return the first post from the discussion.
@global object
int | $dicsussionid |
array |
forum_get_forcesubscribed | ( | $forum | ) |
forum_get_forum_types | ( | ) |
Returns array of forum types chooseable on the forum editing form.
array |
forum_get_forum_types_all | ( | ) |
Returns array of all forum layout modes.
array |
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
stdClass | $user | |
array | $courseids | An array of courseids to search or if not provided all courses the user has posted within |
bool | $discussionsonly | If true then only forums where the user has started a discussion will be returned. |
int | $limitfrom | The offset of records to return |
int | $limitnum | The number of records to return |
array | An array of forums the user has posted within in the provided courses |
forum_get_layout_modes | ( | bool | $useexperimentalui = false | ) |
Returns array of forum layout modes.
bool | $useexperimentalui | use experimental layout modes or not |
array |
forum_get_open_modes | ( | ) |
forum_get_optional_subscribed_forums | ( | ) |
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.
array |
object forum_get_post_from_log | ( | $log | ) |
Given a log entry, return the forum post details for it.
@global object
object | $log |
array|null |
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
int | $postid |
mixed | array of posts or false |
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
stdClass | $user | The user whose posts we want to get |
array | $courses | The courses to search |
bool | $musthaveaccess | If set to true errors will be thrown if the user cannot access one or more of the courses to search |
bool | $discussionsonly | If set to true only discussion starting posts will be returned. |
int | $limitfrom | The offset of records to return |
int | $limitnum | The number of records to return |
stdClass | An 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_ratings | ( | ) |
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
int | $userid | |
int | $courseid | if 0, we look for forums throughout the whole site. |
array | of forum objects, or false if no matches Forum objects have the following attributes: id, type, course, cmid, cmvisible, cmgroupmode, accessallgroups, viewhiddentimedposts |
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.
@global object @global object @global object
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.
object | $forum | the forum. Fields used are $forum->id and $forum->forcesubscribe. |
object | $context | the context object for this forum. |
array | $messages | text 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 |
string |
forum_get_subscribed_forums | ( | ) |
forum_get_subscriptionmode_options | ( | ) |
List the options for forum subscription modes.
This is used by the settings page and by the mod_form page.
array |
forum_get_tracking_link | ( | ) |
forum_get_user_digest_options | ( | $user = null | ) |
Retrieve the list of available user digest options.
stdClass | $user | The user object. This defaults to the global $USER object. |
array | The mapping of values to 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.
@global object @uses CONTEXT_MODULE
int | $forumid | |
int | $userid |
array | Array or false |
forum_get_user_maildigest_bulk | ( | $digests, | |
$user, | |||
$forumid ) |
Determine the maildigest setting for the specified user against the specified forum.
Array | $digests | An array of forums and user digest settings. |
stdClass | $user | The user object containing the id and maildigest default. |
int | $forumid | The ID of the forum to check. |
int | The calculated maildigest setting for this user and forum. |
object forum_get_user_posted_time | ( | $did, | |
$userid ) |
Returns creation time of the first user's post in given discussion $DB.
int | $did | Discussion id |
int | $userid | User id |
int|bool | post creation time stamp or return false |
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
array |
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.
array |
object forum_go_back_to | ( | $default | ) |
string | moodle_url | $default |
string |
forum_grade_item_delete | ( | $forum | ) |
Delete grade item for given forum.
stdClass | $forum | Forum object |
forum_grade_item_update | ( | $forum, | |
$ratings = null, | |||
$forumgrades = null ) |
Create/update grade items for given forum.
stdClass | $forum | Forum object with extra cmidnumber |
mixed | $grades | Optional array/object of grade(s); 'reset' means reset grades in gradebook |
forum_grading_areas_list | ( | ) |
Lists all gradable areas for the advanced grading methods gramework.
array('string'=>'string') | An array with area names as keys and descriptions as values |
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.
object | $context | the forum context |
stdClass | $forum | The forum object |
void |
forum_is_author_hidden | ( | $post, | |
$forum ) |
Checks whether the author's name and picture for a given post should be hidden or not.
object | $post | The forum post. |
object | $forum | The forum object. |
bool |
coding_exception |
forum_is_cutoff_date_reached | ( | $forum | ) |
Determine whether the specified forum's cutoff date is reached.
stdClass | $forum | The forum |
bool |
forum_is_due_date_reached | ( | $forum | ) |
Determine whether the specified forum's due date is reached.
stdClass | $forum | The forum |
bool |
forum_is_forcesubscribed | ( | $forum | ) |
Determine whether the forum is force subscribed.
forum_is_subscribed | ( | ) |
forum_is_user_group_discussion | ( | cm_info | $cm, |
$discussiongroupid ) |
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.
object | $discussion | |
int | $forumfrom | source forum id |
int | $forumto | target forum id |
bool | success |
forum_page_type_list | ( | $pagetype, | |
$parentcontext, | |||
$currentcontext ) |
Return a list of page types.
string | $pagetype | current page type |
stdClass | $parentcontext | Block's parent context |
stdClass | $currentcontext | Current context of block |
forum_pluginfile | ( | $course, | |
$cm, | |||
$context, | |||
$filearea, | |||
$args, | |||
$forcedownload, | |||
array | $options = array() ) |
Serves the forum attachments.
Implements needed access control ;-)
stdClass | $course | course object |
stdClass | $cm | course module object |
stdClass | $context | context object |
string | $filearea | file area |
array | $args | extra arguments |
bool | $forcedownload | whether or not force download |
array | $options | additional options affecting the file serving |
bool | false if file not found, does not return if found - justsend the file |
forum_post_is_visible_privately | ( | $post, | |
$cm ) |
Check whether the forum post is a private reply visible to this user.
stdClass | $post | The post to check. |
cm_info | $cm | The context module instance. |
bool | Whether the post is visible in terms of private reply configuration. |
forum_post_nesting_cache | ( | ) |
forum_post_subscription | ( | $fromform, | |
$forum, | |||
$discussion ) |
Given a new post, subscribes or unsubscribes as appropriate.
Returns some text which describes what happened.
object | $fromform | The submitted form |
stdClass | $forum | The forum record |
stdClass | $discussion | The forum discussion record |
string |
object forum_print_attachments | ( | $post, | |
$cm, | |||
$type ) |
Returns attachments as formated text/html optionally with separate images.
@global object @global object
object | $post | |
object | $cm | |
string | $type | html/text/separateimages |
mixed | string or array of (html text withouth images and image HTML) |
forum_print_discussion | ( | ) |
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.
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()
@global object
object | $post | The post object (passed by reference for speed). |
object | $forum | The forum object. |
int | $group | Current group. |
string | $datestring | Format to use for the dates. |
boolean | $cantrack | Is tracking enabled for this forum. |
boolean | $forumtracked | Is the user tracking this forum. |
boolean | $canviewparticipants | True if user has the viewparticipants permission for this course |
boolean | $canviewhiddentimedposts | True if user has the viewhiddentimedposts permission for this forum |
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.
int | $id | forum id if $forumtype is 'single', discussion id for any other forum type |
mixed | $mode | forum layout mode |
string | $forumtype | optional |
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.
@global object @global object @uses CONTEXT_MODULE @uses VISIBLEGROUPS
object | $course | |
bool | $viewfullnames | capability |
int | $timestart |
bool | success |
forum_print_recent_mod_activity | ( | $activity, | |
$courseid, | |||
$detail, | |||
$modnames, | |||
$viewfullnames ) |
Outputs the forum post indicated by $activity.
object | $activity | the activity object the forum resides in |
int | $courseid | the id of the course the forum resides in |
bool | $detail | not used, but required for compatibilty with other modules |
int | $modnames | not used, but required for compatibilty with other modules |
bool | $viewfullnames | not used, but required for compatibilty with other modules |
forum_rating_permissions | ( | $contextid, | |
$component, | |||
$ratingarea ) |
Return rating related permissions.
string | $options | the context id |
array | an associative array of the user's rating permissions |
forum_rating_validate | ( | $params | ) |
Validates a submitted rating.
array | $params | submitted 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]
boolean | true if the rating is valid. Will throw rating_exception if not |
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.
int | $courseid | Not used. |
stdClass | $instance | Forum module instance. |
stdClass | $cm | Course module object. |
forum_reset_course_form_defaults | ( | $course | ) |
Course reset form defaults.
array |
forum_reset_course_form_definition | ( | & | $mform | ) |
Called by course/reset.php.
MoodleQuickForm | $mform | form passed by reference |
object forum_reset_gradebook | ( | $courseid, | |
$type = '' ) |
Removes all grades from gradebook.
@global object
int | $courseid | |
string | $type | optional |
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
$data | the data submitted from the reset course. |
array | status array |
forum_rss_delete_file | ( | $forum | ) |
Given a forum object, deletes all cached RSS files associated with it.
stdClass | $forum |
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.
stdClass | $forum | the forum object |
string | $sql | the SQL used to retrieve the contents from the database |
array | $params | the SQL parameters used |
object | $context | the context this forum relates to |
bool|string | false 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, | |
$cm, | |||
$newsince = 0 ) |
Generates the SQL query used to get the Discussion details from the forum table of the database.
stdClass | $forum | the forum object |
stdClass | $cm | Course Module object |
int | $newsince | check for items since this epoch timestamp |
string | the SQL query to be 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.
stdClass | $forum | the forum object |
stdClass | $cm | Course Module object |
int | $newsince | check for items since this epoch timestamp |
string | the SQL query to be 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.
stdClass | $context | the context |
array | $args | the arguments received in the url |
string | the full path to the cached RSS feed directory. Null if there is a problem. |
forum_rss_get_group_sql | ( | $cm, | |
$groupmode, | |||
$currentgroup, | |||
$modcontext = null ) |
Retrieve the correct SQL snippet for group-only forums.
stdClass | $cm | Course Module object |
int | $groupmode | the mode in which the forum's groups are operating |
bool | $currentgroup | true if the user is from the a group enabled on the forum |
stdClass | $modcontext | The context instance of the forum module |
string | SQL Query for group details of the forum |
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.
stdClass | $forum | the forum object |
stdClass | $cm | Course Module object |
int | $time | check for items since this epoch timestamp |
string | the SQL query to be used to get the Discussion/Post details from the forum table of the database |
forum_rss_newstuff | ( | $forum, | |
$cm, | |||
$time ) |
If there is new stuff in the forum since $time this returns true Otherwise it returns false.
stdClass | $forum | the forum object |
stdClass | $cm | Course Module object |
int | $time | check for items since this epoch timestamp |
bool | True for new items |
forum_scale_used | ( | ) |
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.
$scaleid | int |
boolean | True if the scale is used by any forum |
object forum_search_form | ( | $course, | |
$search = '' ) |
object | $course | |
string | $search |
string |
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
array | $searchterms | array of search terms, e.g. word +word -word |
int | $courseid | if 0, we search through the whole site |
int | $limitfrom | |
int | $limitnum | |
int | &$totalcount | |
string | $extrasql |
array|bool | Array of posts found or false |
forum_set_user_maildigest | ( | $forum, | |
$maildigest, | |||
$user = null ) |
Set the per-forum maildigest option for the specified user.
stdClass | $forum | The forum to set the option for. |
int | $maildigest | The maildigest option. |
stdClass | $user | The user object. This defaults to the global $USER object. |
invalid_digest_setting | thrown if an invalid maildigest option is provided. |
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.
@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
string | $feature |
mixed | True if module supports feature, false if not, null if doesn't know or string for the module purpose. |
object forum_tp_add_read_record | ( | $userid, | |
$postid ) |
Mark post as read.
@global object
int | $userid | |
int | $postid |
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
mixed | $forum | The forum object to test, or the int id (optional). |
mixed | $userid | The user object to check for (optional). |
boolean |
object forum_tp_clean_read_records | ( | ) |
Clean old records from the forum_read table.
@global object
void |
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.
@global object @global object
object | $cm | |
object | $course | |
bool | $resetreadcache | optional, true to reset the function static $readcache var |
int |
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.
int | $userid | |
int | $postid | |
int | $discussionid | |
int | $forumid |
bool |
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
int | $userid | |
int | $courseid |
array |
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.
@global object
int | $userid | The id of the user to use. |
int | $courseid | The id of the course being checked. |
mixed | An array indexed by forum id, or false. |
object forum_tp_is_post_old | ( | $post, | |
$time = null ) |
object | $post | |
int | $time | Defautls to time() |
object forum_tp_is_post_read | ( | $userid, | |
$post ) |
int | $userid | |
object | $post |
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
mixed | $forum | If int, the id of the forum being checked; if object, the forum object |
int | $userid | The id of the user being checked (optional). |
boolean |
object forum_tp_mark_discussion_read | ( | $user, | |
$discussionid ) |
Marks a whole discussion as read, for a given user.
@global object
object | $user | |
int | $discussionid |
bool |
object forum_tp_mark_forum_read | ( | $user, | |
$forumid, | |||
$groupid = false ) |
Marks a whole forum as read, for a given user.
@global object
object | $user | |
int | $forumid | |
int | bool | $groupid |
bool |
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.
int | $userid | The ID of the user to mark posts read for. |
object | $post | The post record for the post to mark as read. |
mixed | $unused |
bool |
object forum_tp_mark_posts_read | ( | $user, | |
$postids ) |
Mark posts as read.
@global object
object | $user | object |
array | $postids | array of post ids |
boolean | success |
object forum_tp_start_tracking | ( | $forumid, | |
$userid = false ) |
@global object
int | $forumid | |
int | $userid |
object forum_tp_stop_tracking | ( | $forumid, | |
$userid = false ) |
@global object
int | $forumid | |
int | $userid |
forum_trigger_content_uploaded_event | ( | $post, | |
$cm, | |||
$name ) |
Sends post content to plagiarism plugin.
object | $post | Forum post object |
object | $cm | Course-module |
string | $name |
bool |
forum_trigger_post_updated_event | ( | $post, | |
$discussion, | |||
$context, | |||
$forum ) |
Trigger post updated event.
object | $post | forum post object |
object | $discussion | discussion object |
object | $context | forum context object |
object | $forum | forum object |
void |
forum_unsubscribe | ( | ) |
forum_update_calendar | ( | $forum, | |
$cmid ) |
Update the calendar entries for this forum activity.
stdClass | $forum | the row from the database table forum. |
int | $cmid | The coursemodule id |
bool |
forum_update_grades | ( | $forum, | |
$userid = 0 ) |
Update activity grades.
object | $forum | |
int | $userid | specific user only, 0 means all |
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.
object | $forum | forum instance (with magic quotes) |
bool | success |
forum_update_post | ( | $newpost, | |
$mform, | |||
$unused = null ) |
Update a post.
stdClass | $newpost | The post to update |
mixed | $mform | The submitted form |
string | $unused |
bool |
object forum_update_subscriptions_button | ( | $courseid, | |
$forumid ) |
Prints the editing button on subscribers page.
@global object
int | $courseid | |
int | $forumid |
string |
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
object | $forum | forum object |
object | $discussion | |
object | $user | |
object | $cm | |
object | $course | |
object | $context |
bool |
object forum_user_can_post_discussion | ( | $forum, | |
$currentgroup = null, | |||
$unused = -1, | |||
$cm = NULL, | |||
$context = NULL ) |
object | $forum | |
object | $currentgroup | |
int | $unused | |
object | $cm | |
object | $context |
bool |
forum_user_can_reply_privately | ( | \context_module | $context, |
stdClass | $parent ) |
Check whether the user can reply privately to the parent post.
context_module | $context | |
stdClass | $parent |
bool |
object forum_user_can_see_discussion | ( | $forum, | |
$discussion, | |||
$context, | |||
$user = NULL ) |
@global object @uses DEBUG_DEVELOPER
object | $forum | |
object | $discussion | |
object | $context | |
object | $user |
bool |
forum_user_can_see_group_discussion | ( | $discussion, | |
$cm, | |||
$context ) |
Check to ensure a user can view a group discussion.
object | $discussion | |
object | $cm | |
object | $context |
boolean | returns true if they can view post, false otherwise |
forum_user_can_see_post | ( | $forum, | |
$discussion, | |||
$post, | |||
$user = null, | |||
$cm = null, | |||
$checkdeleted = true ) |
Check whether a user can see the specified post.
stdClass | $forum | The forum to chcek |
stdClass | $discussion | The discussion the post is in |
stdClass | $post | The post in question |
stdClass | $user | The user to test - if not specified, the current user is checked. |
stdClass | $cm | The Course Module that the forum is in (required). |
bool | $checkdeleted | Whether to check the deleted flag on the post. |
bool |
forum_user_can_see_timed_discussion | ( | $discussion, | |
$user, | |||
$context ) |
Check to ensure a user can view a timed discussion.
object | $discussion | |
object | $user | |
object | $context |
boolean | returns true if they can view post, false otherwise |
forum_user_can_view_post | ( | ) |
object forum_user_complete | ( | $course, | |
$user, | |||
$mod, | |||
$forum ) |
@global object
object | $coure | |
object | $user | |
object | $mod | |
object | $forum |
forum_user_enrolled | ( | ) |
object forum_user_has_posted | ( | $forumid, | |
$did, | |||
$userid ) |
@global object
int | $forumid | |
int | $did | |
int | $userid |
bool |
forum_user_has_posted_discussion | ( | $forumid, | |
$userid, | |||
$groupid = null ) |
Returns true if user created new discussion already.
int | $forumid | The forum to check for postings |
int | $userid | The user to check for postings |
int | $groupid | The group to restrict the check to |
bool |
forum_user_outline | ( | $course, | |
$user, | |||
$mod, | |||
$forum ) |
object | $course | |
object | $user | |
object | $mod | TODO this is not used in this function, refactor |
object | $forum |
object | A standard object with 2 variables: info (number of posts for this user) and time (last modified) |
forum_view | ( | $forum, | |
$course, | |||
$cm, | |||
$context ) |
Mark the activity completed (if required) and trigger the course_module_viewed event.
stdClass | $forum | forum object |
stdClass | $course | course object |
stdClass | $cm | course module object |
stdClass | $context | context object |
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.
calendar_event | $event | The calendar event. |
int | $itemcount | The item count associated with the action event. |
bool |
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.
moodle_exception |
calendar_event | $event | |
stdClass | $forum | The module instance to get the range from |
mod_forum_core_calendar_get_event_action_string | ( | string | $eventtype | ) |
Callback to fetch the activity event type lang string.
string | $eventtype | The event type. |
lang_string | The 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.
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'] ]
calendar_event | $event | The calendar event to get the time range for |
stdClass | $forum | The module instance to get the range from |
array | Returns an array with min and max date. |
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.
calendar_event | $event | |
core_calendar\action_factory | $factory | |
int | $userid | User id to use for all capability checks, etc. Set to 0 for current user (default). |
core_calendar\local\event\entities\action_interface|null |
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\local\entities\forum | $forum | The forum entity |
stdClass | $user | The user to render for |
int | $groupid | The group to render |
int | The number of 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.
cm_info | stdClass | $cm | object with fields ->completion and ->customdata['customcompletionrules'] |
array\$descriptions | the array of descriptions for the custom rules. |
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\local\entities\forum | $forum | The forum entity |
stdClass | $user | The user to render for |
int[] | null | $groupid | The group to render |
int | null | $sortorder | The sort order to use when selecting the discussions in the list |
int | null | $pageno | The zero-indexed page number to use |
int | null | $pagesize | The number of discussions to show on the page |
array | The data to use for display |
mod_forum_get_fontawesome_icon_map | ( | ) |
Get icon mapping for font-awesome.
array |
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\local\entities\forum | $forum | The forum entity |
stdClass | $user | The user viewing |
int | $groupid | The groupid requested |
array | The list of groups to show |
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.
core_tag_tag | $tag | |
bool | $exclusivemode | if 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 | $fromctx | context id where the link was displayed, may be used by callbacks to display items in the same context first |
int | $ctx | context id where to search for records |
bool | $rec | search in subcontexts as well |
int | $page | 0-based number of page being displayed |
core_tag\output\tagindex |
mod_forum_inplace_editable | ( | $itemtype, | |
$itemid, | |||
$newvalue ) |
Manage inplace editable saves.
string | $itemtype | The type of item. |
int | $itemid | The ID of the item. |
mixed | $newvalue | The new value |
string |
mod_forum_myprofile_navigation | ( | core_user\output\myprofile\tree | $tree, |
$user, | |||
$iscurrentuser, | |||
$course ) |
Add nodes to myprofile page.
core_user\output\myprofile\tree | $tree | Tree object |
stdClass | $user | user object |
bool | $iscurrentuser | |
stdClass | $course | Course object |
bool |
mod_forum_rating_can_see_item_ratings | ( | $params | ) |
Can the current user see ratings for a given itemid?
array | $params | submitted 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] |
bool |
coding_exception | |
rating_exception |
mod_forum_user_preferences | ( | ) |
Return a list of all the user preferences used by mod_forum.
array |
$definitions |
$handlers |
$logs |
$messageproviders |
$observers |
$tagareas |
$tasks |
const FORUM_MODE_FLATOLDEST 1 |
Include required files.
CONSTANTS ///////////////////////////////////////////////////////////
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.
const FORUM_TRACKING_ON 2 |
FORUM_TRACKING_ON - deprecated alias for FORUM_TRACKING_FORCED.