-<?php // $Id$
-
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package mod-forum
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/** Include required files */
require_once($CFG->libdir.'/filelib.php');
require_once($CFG->libdir.'/eventslib.php');
require_once($CFG->libdir.'/portfoliolib.php');
* (defined by the form in mod_form.php) this function
* will create a new instance and return the id number
* of the new instance.
+ *
+ * @global object
+ * @global object
* @param object $forum add forum instance (with magic quotes)
* @return int intance id
*/
* 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.
+ *
+ * @global object
* @param object $forum forum instance (with magic quotes)
* @return bool success
*/
* Given an ID of an instance of this module,
* this function will permanently delete the instance
* and any data that depends on it.
- * @param int forum instance id
+ *
+ * @global object
+ * @param int $id forum instance id
* @return bool success
*/
function forum_delete_instance($id) {
/**
* Indicates API features that the forum supports.
*
+ * @uses FEATURE_GROUPS
+ * @uses FEATURE_GROUPINGS
+ * @uses FEATURE_GROUPMEMBERSONLY
+ * @uses FEATURE_MOD_INTRO
+ * @uses FEATURE_COMPLETION_TRACKS_VIEWS
+ * @uses FEATURE_COMPLETION_HAS_RULES
+ * @uses FEATURE_GRADE_HAS_GRADE
+ * @uses FEATURE_GRADE_OUTCOMES
* @param string $feature
* @return mixed True if yes (some features may use other values)
*/
* Obtains the automatic completion state for this forum based on any conditions
* in forum settings.
*
+ * @global object
+ * @global object
* @param object $course Course
* @param object $cm Course-module
* @param int $userid User ID
* Function to be run periodically according to the moodle cron
* Finds all posts that have yet to be mailed out, and mails them
* out to all subscribers
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @uses CONTEXT_MODULE
+ * @uses CONTEXT_COURSE
+ * @uses SITEID
+ * @uses FORMAT_PLAIN
* @return void
*/
function forum_cron() {
/**
* Builds and returns the body of the email notification in plain text.
*
+ * @global object
+ * @global object
+ * @uses CONTEXT_MODULE
* @param object $course
+ * @param object $cm
* @param object $forum
* @param object $discussion
* @param object $post
/**
* Builds and returns the body of the email notification in html format.
*
+ * @global object
* @param object $course
+ * @param object $cm
* @param object $forum
* @param object $discussion
* @param object $post
/**
- *
+ * @global object
+ * @global object
+ * @param object $coure
+ * @param object $user
+ * @param object $mod
+ * @param object $forum
*/
function forum_user_complete($course, $user, $mod, $forum) {
global $CFG,$USER;
/**
- *
+ * @global object
+ * @global object
+ * @global object
+ * @param array $courses
+ * @param array $htmlarray
*/
function forum_print_overview($courses,&$htmlarray) {
global $USER, $CFG, $DB;
/**
* 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
+ * @global object
+ * @uses CONTEXT_MODULE
+ * @uses VISIBLEGROUPS
* @param object $course
* @param bool $viewfullnames capability
* @param int $timestart
/**
* Return grade for given user or all users.
*
- * @param int $forumid id of forum
+ * @global object
+ * @global object
+ * @param object $forum
* @param int $userid optional user id, 0 means all users
* @return array array of grades, false if none
*/
/**
* Update activity grades
*
+ * @global object
+ * @global object
* @param object $forum
* @param int $userid specific user only, 0 means all
* @param boolean $nullifnone return null if grade does not exist
/**
* Update all grades in gradebook.
+ * @global object
*/
function forum_upgrade_grades() {
global $DB;
/**
* Create/update grade item for given forum
*
+ * @global object
+ * @uses GRADE_TYPE_NONE
+ * @uses GRADE_TYPE_VALUE
+ * @uses GRADE_TYPE_SCALE
* @param object $forum object with extra cmidnumber
- * @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
+ * @param mixed $grades optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return int 0 if ok
*/
function forum_grade_item_update($forum, $grades=NULL) {
/**
* Delete grade item for given forum
*
+ * @global object
* @param object $forum object
* @return object grade_item
*/
/**
* Returns the users with data in one forum
* (users with records in forum_subscriptions, forum_posts and forum_ratings, students)
+ *
+ * @global object
+ * @global object
* @param int $forumid
* @return mixed array or false if none
*/
/**
* This function returns if a scale is being used by one forum
+ *
+ * @global object
* @param int $forumid
* @param int $scaleid negative number
* @return bool
* Checks if scale is being used by any instance of forum
*
* This is used to find out if scale used anywhere
+ *
+ * @global object
* @param $scaleid int
* @return boolean True if the scale is used by any forum
*/
/**
* Gets a post with all info ready for forum_print_post
* Most of these joins are just to get the forum id
+ *
+ * @global object
+ * @global object
* @param int $postid
* @return mixed array of posts or false
*/
* Gets posts with all info ready for forum_print_post
* We pass forumid in because we always know it so no need to make a
* complicated join to find it out.
+ *
+ * @global object
+ * @global object
* @return mixed array of posts or false
*/
function forum_get_discussion_posts($discussion, $sort, $forumid) {
/**
* Gets all posts in discussion including top parent.
+ *
+ * @global object
+ * @global object
+ * @global object
* @param int $discussionid
* @param string $sort
* @param bool $tracking does user track the forum?
* Gets posts with all info ready for forum_print_post
* We pass forumid in because we always know it so no need to make a
* complicated join to find it out.
+ *
+ * @global object
+ * @global object
+ * @param int $parent
+ * @param int $forumid
+ * @return array
*/
function forum_get_child_posts($parent, $forumid) {
global $CFG, $DB;
/**
* An array of forum objects that the user is allowed to read/search through.
- * @param $userid
- * @param $courseid - if 0, we look for forums throughout the whole site.
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @param int $userid
+ * @param int $courseid if 0, we look for forums throughout the whole site.
* @return array of forum objects, or false if no matches
* Forum objects have the following attributes:
* id, type, course, cmid, cmvisible, cmgroupmode, accessallgroups,
/**
* Returns a list of posts found using an array of search terms.
- * @param $searchterms - array of search terms, e.g. word +word -word
- * @param $courseid - if 0, we search through the whole site
- * @param $page
- * @param $recordsperpage=50
- * @param &$totalcount
- * @param $extrasql
- * @return array of posts found
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @param array $searchterms array of search terms, e.g. word +word -word
+ * @param int $courseid if 0, we search through the whole site
+ * @param int $limitfrom
+ * @param int $limitnum
+ * @param int &$totalcount
+ * @param string $extrasql
+ * @return array|bool Array of posts found or false
*/
function forum_search_posts($searchterms, $courseid=0, $limitfrom=0, $limitnum=50,
&$totalcount, $extrasql='') {
/**
* Returns a list of ratings for all posts in discussion
+ *
+ * @global object
+ * @global object
* @param object $discussion
* @return array of ratings or false
*/
/**
* Returns a list of ratings for one specific user for all posts in discussion
- * @global object $CFG
- * @global object $DB
+ * @global object
+ * @global object
* @param object $discussions the discussions for which we return all ratings
* @param int $userid the user for who we return all ratings
- * @return object
+ * @return array
*/
function forum_get_all_user_ratings($userid, $discussions) {
global $CFG, $DB;
/**
* Returns a list of ratings for a particular post - sorted.
+ *
+ * @global object
+ * @global object
* @param int $postid
* @param string $sort
- * @return array of ratings or false
+ * @return array Array of ratings or false
*/
function forum_get_ratings($postid, $sort="u.firstname ASC") {
global $CFG, $DB;
/**
* Returns a list of all new posts that have not been mailed yet
- * @param int $starttime - posts created after this time
- * @param int $endtime - posts created before this
- * @param int $now - used for timed discussions only
+ *
+ * @global object
+ * @global object
+ * @param int $starttime posts created after this time
+ * @param int $endtime posts created before this
+ * @param int $now used for timed discussions only
+ * @return array
*/
function forum_get_unmailed_posts($starttime, $endtime, $now=null) {
global $CFG, $DB;
/**
* Marks posts before a certain time as being mailed already
+ *
+ * @global object
+ * @global object
+ * @param int $endtime
+ * @param int $now Defaults to time()
+ * @return bool
*/
function forum_mark_old_posts_as_mailed($endtime, $now=null) {
global $CFG, $DB;
/**
* Get all the posts for a user in a forum suitable for forum_print_post
+ *
+ * @global object
+ * @global object
+ * @uses CONTEXT_MODULE
+ * @return array
*/
function forum_get_user_posts($forumid, $userid) {
global $CFG, $DB;
/**
* Get all the discussions user participated in
+ *
+ * @global object
+ * @global object
+ * @uses CONTEXT_MODULE
* @param int $forumid
* @param int $userid
- * @return array or false
+ * @return array Array or false
*/
function forum_get_user_involved_discussions($forumid, $userid) {
global $CFG, $DB;
/**
* Get all the posts for a user in a forum suitable for forum_print_post
+ *
+ * @global object
+ * @global object
* @param int $forumid
* @param int $userid
* @return array of counts or false
/**
* Given a log entry, return the forum post details for it.
+ *
+ * @global object
+ * @global object
+ * @param object $log
+ * @return array|null
*/
function forum_get_post_from_log($log) {
global $CFG, $DB;
/**
* Given a discussion id, return the first post from the discussion
+ *
+ * @global object
+ * @global object
+ * @param int $dicsussionid
+ * @return array
*/
function forum_get_firstpost_from_discussion($discussionid) {
global $CFG, $DB;
/**
* Returns an array of counts of replies to each discussion
+ *
+ * @global object
+ * @global object
+ * @param int $forumid
+ * @param string $forumsort
+ * @param int $limit
+ * @param int $page
+ * @param int $perpage
+ * @return array
*/
function forum_count_discussion_replies($forumid, $forumsort="", $limit=-1, $page=-1, $perpage=0) {
global $CFG, $DB;
}
}
+/**
+ * @global object
+ * @global object
+ * @global object
+ * @staticvar array $cache
+ * @param object $forum
+ * @param object $cm
+ * @param object $course
+ * @return mixed
+ */
function forum_count_discussions($forum, $cm, $course) {
global $CFG, $DB, $USER;
/**
* How many unrated posts are in the given discussion for a given user?
+ *
+ * @global object
+ * @global object
+ * @param int $discussionid
+ * @param int $userid
+ * @return mixed
*/
function forum_count_unrated_posts($discussionid, $userid) {
global $CFG, $DB;
/**
* Get all discussions in a forum
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @uses CONTEXT_MODULE
+ * @uses VISIBLEGROUPS
+ * @param object $cm
+ * @param string $forumsort
+ * @param bool $fullpost
+ * @param int $unused
+ * @param int $limit
+ * @param bool $userlastmodified
+ * @param int $page
+ * @param int $perpage
+ * @return array
*/
function forum_get_discussions($cm, $forumsort="d.timemodified DESC", $fullpost=true, $unused=-1, $limit=-1, $userlastmodified=false, $page=-1, $perpage=0) {
global $CFG, $DB, $USER;
return $DB->get_records_sql($sql, $params, $limitfrom, $limitnum);
}
+/**
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @uses CONTEXT_MODULE
+ * @uses VISIBLEGROUPS
+ * @param object $cm
+ * @return array
+ */
function forum_get_discussions_unread($cm) {
global $CFG, $DB, $USER;
}
}
+/**
+ * @global object
+ * @global object
+ * @global object
+ * @uses CONEXT_MODULE
+ * @uses VISIBLEGROUPS
+ * @param object $cm
+ * @return array
+ */
function forum_get_discussions_count($cm) {
global $CFG, $DB, $USER;
/**
* Get all discussions started by a particular user in a course (or group)
* This function no longer used ...
+ *
+ * @todo Remove this function if no longer used
+ * @global object
+ * @global object
+ * @param int $courseid
+ * @param int $userid
+ * @param int $groupid
+ * @return array
*/
function forum_get_user_discussions($courseid, $userid, $groupid=0) {
global $CFG, $DB;
/**
* Returns list of user objects that are subscribed to this forum
*
+ * @global object
+ * @global object
* @param object $course the course
* @param forum $forum the forum
* @param integer $groupid group id, or 0 for all.
// OTHER FUNCTIONS ///////////////////////////////////////////////////////////
+/**
+ * @global object
+ * @global object
+ * @param int $courseid
+ * @param string $type
+ */
function forum_get_course_forum($courseid, $type) {
// How to set up special 1-per-course forums
global $CFG, $DB;
/**
-* Given the data about a posting, builds up the HTML to display it and
-* returns the HTML in a string. This is designed for sending via HTML email.
-*/
+ * Given the data about a posting, builds up the HTML to display it and
+ * returns the HTML in a string. This is designed for sending via HTML email.
+ *
+ * @global object
+ * @param object $course
+ * @param object $cm
+ * @param object $forum
+ * @param object $discussion
+ * @param object $post
+ * @param object $userform
+ * @param object $userto
+ * @param bool $ownpost
+ * @param bool $reply
+ * @param bool $link
+ * @param bool $rate
+ * @param string $footer
+ * @return string
+ */
function forum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfrom, $userto,
$ownpost=false, $reply=false, $link=false, $rate=false, $footer="") {
/**
* Print a forum post
*
+ * @global object
+ * @global object
+ * @uses FORUM_MODE_THREADED
+ * @uses PORTFOLIO_FORMAT_PLAINHTML
+ * @uses PORTFOLIO_FORMAT_FILE
+ * @uses PORTFOLIO_FORMAT_RICHHTML
+ * @uses PORTFOLIO_ADD_TEXT_LINK
+ * @uses CONTEXT_MODULE
* @param object $post The post to print.
- * @param integer $courseid The course this post belongs to.
+ * @param object $discussion
+ * @param object $forum
+ * @param object $cm
+ * @param object $course
* @param boolean $ownpost Whether this post belongs to the current user.
* @param boolean $reply Whether to print a 'reply' link at the bottom of the message.
* @param boolean $link Just print a shortened version of the post as a link to the full post.
* the current user can't see this post, if this argument is true
* (the default) then print a dummy 'you can't see this post' post.
* If false, don't output anything at all.
+ * @param bool|null $istracked
*/
function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost=false, $reply=false, $link=false,
$ratings=NULL, $footer="", $highlight="", $post_read=null, $dummyifcantsee=true, $istracked=null) {
* happen to be combined for efficiency in the $post parameter by the function
* that calls this one: forum_print_latest_discussions()
*
+ * @global object
+ * @global object
* @param object $post The post object (passed by reference for speed).
* @param object $forum The forum object.
* @param int $group Current group.
* Given a post object that we already know has a long message
* this function truncates the message nicely to the first
* sane place between $CFG->forum_longpost and $CFG->forum_shortpost
+ *
+ * @global object
+ * @param string $message
+ * @return string
*/
function forum_shorten_post($message) {
* Print the multiple ratings on a post given to the current user by others.
* Forumid prevents the double lookup of the forumid in discussion to determine the aggregate type
* Scale is an array of ratings
+ *
+ * @uses FORUM_AGGREGATE_AVG
+ * @uses FORUM_AGGREGATE_COUNT
+ * @uses FORUM_AGGREGATE_MAX
+ * @uses FORUM_AGGREGATE_MIN
+ * @uses FORUM_AGGREGATE_SUM
+ * @param int $postid
+ * @param array $scale
+ * @param int $aggregatetype
+ * @param bool $link
+ * @param array $ratings
+ * @param bool $return
+ * @return string|void
*/
function forum_print_ratings($postid, $scale, $aggregatetype, $link=true, $ratings=null, $return=false) {
/**
* Return the mean rating of a post given to the current user by others.
- * Scale is an array of possible ratings in the scale
- * Ratings is an optional simple array of actual ratings (just integers)
- * Forumid is the forum id field needed - passing it avoids a double query of lookup up the discusion and then the forum id to get the aggregate type
+ *
+ * @global object
+ * @param int $postid
+ * @param array $scal Scale is an array of possible ratings in the scale
+ * @param array $ratings Ratings is an optional simple array of actual ratings (just integers)
+ * @return string
*/
function forum_get_ratings_mean($postid, $scale, $ratings=NULL) {
global $DB;
* and $scale looks like Array( 1 => 'poor', 2 => 'weak', 3 => 'good' )
* In case of no ratings done yet, we have nothing to display.
*
+ * @global object
* @param int $postid
* @param array $scale Possible ratings in the scale - the end of the scale is the highest or max grade
* @param array $ratings An optional simple array of actual ratings (just integers)
+ * @return string
*/
function forum_get_ratings_count($postid, $scale, $ratings=NULL) {
global $DB;
/**
* Return the max rating of a post given to the current user by others.
- * Scale is an array of possible ratings in the scale
- * Ratings is an optional simple array of actual ratings (just integers)
+ *
+ * @global object
+ * @param int $postid
+ * @param array $scale Scale is an array of possible ratings in the scale
+ * @param array $ratings Ratings is an optional simple array of actual ratings (just integers)
*/
function forum_get_ratings_max($postid, $scale, $ratings=NULL) {
/**
* Return the min rating of a post given to the current user by others.
- * Scale is an array of possible ratings in the scale
- * Ratings is an optional simple array of actual ratings (just integers)
+ *
+ * @global object
+ * @param int postid
+ * @param array $scale Scale is an array of possible ratings in the scale
+ * @param array $ratings Ratings is an optional simple array of actual ratings (just integers)
+ * @return string
*/
function forum_get_ratings_min($postid, $scale, $ratings=NULL) {
global $DB;
/**
* Return the sum or total of ratings of a post given to the current user by others.
- * Scale is an array of possible ratings in the scale
- * Ratings is an optional simple array of actual ratings (just integers)
+ *
+ * @global object
+ * @param int $postid
+ * @param array $scale Scale is an array of possible ratings in the scale
+ * @param array $ratings Ratings is an optional simple array of actual ratings (just integers)
+ * @return string
*/
function forum_get_ratings_sum($postid, $scale, $ratings=NULL) {
global $DB;
/**
* Return a summary of post ratings given to the current user by others.
- * Scale is an array of possible ratings in the scale
- * Ratings is an optional simple array of actual ratings (just integers)
+ *
+ * @global object
+ * @param int $postid
+ * @param array $scale Scale is an array of possible ratings in the scale
+ * @param array $ratings Ratings is an optional simple array of actual ratings (just integers)
+ * @return string
*/
function forum_get_ratings_summary($postid, $scale, $ratings=NULL) {
global $DB;
/**
* Print the menu of ratings as part of a larger form.
* If the post has already been - set that value.
- * Scale is an array of ratings
+ *
+ * @global object
+ * @param int $postid
+ * @param int $userid
+ * @param array $scale is an array of ratings
+ * @param int $myrating
*/
function forum_print_rating_menu($postid, $userid, $scale, $myrating=NULL) {
/**
* Print the drop down that allows the user to select how they want to have
* the discussion displayed.
- * @param $id - forum id if $forumtype is 'single',
+ *
+ * @param int $id forum id if $forumtype is 'single',
* discussion id for any other forum type
- * @param $mode - forum layout mode
- * @param $forumtype - optional
+ * @param mixed $mode forum layout mode
+ * @param string $forumtype optional
*/
function forum_print_mode_form($id, $mode, $forumtype='') {
if ($forumtype == 'single') {
}
/**
- *
+ * @global object
+ * @param object $course
+ * @param string $search
+ * @return string
*/
function forum_search_form($course, $search='') {
global $CFG;
/**
- *
+ * @global object
+ * @global object
*/
function forum_set_return() {
global $CFG, $SESSION;
/**
- *
+ * @global object
+ * @param string $default
+ * @return string
*/
function forum_go_back_to($default) {
global $SESSION;
* for attachments, and if any are found, these are
* moved to the new forum directory.
*
- * @param $discussion object
+ * @global object
+ * @param object $discussion
* @param int $forumfrom source forum id
* @param int $forumto target forum id
* @return bool success
/**
* Returns attachments as formated text/html optionally with separate images
+ *
+ * @global object
+ * @global object
+ * @global object
* @param object $post
* @param object $cm
- * @param string type - html/text/separateimages
+ * @param string $type html/text/separateimages
* @return mixed string or array of (html text withouth images and image HTML)
*/
function forum_print_attachments($post, $cm, $type) {
/**
* Lists all browsable file areas
+ *
+ * @param object $course
+ * @param object $cm
+ * @param object $context
+ * @return array
*/
function forum_get_file_areas($course, $cm, $context) {
$areas = array();
/**
* Serves the forum attachments. Implements needed access control ;-)
+ *
+ * @param object $course
+ * @param object $cminfo
+ * @param object $context
+ * @param string $filearea
+ * @param array $args
+ * @return bool
*/
function forum_pluginfile($course, $cminfo, $context, $filearea, $args) {
global $CFG, $DB;
/**
* If successful, this function returns the name of the file
- * @param $post is a full post record, including course and forum
- * @param $newfile is a full upload array from $_FILES
- * @param $message is a string to hold the messages.
+ *
+ * @global object
+ * @param object $post is a full post record, including course and forum
+ * @param object $forum
+ * @param object $cm
+ * @param mixed $mform
+ * @param string $message
+ * @return bool
*/
function forum_add_attachment($post, $forum, $cm, $mform=null, &$message=null) {
global $DB;
/**
* Add a new post in an existing discussion.
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @param object $post
+ * @param mixed $mform
+ * @param string $message
+ * @return int
*/
function forum_add_new_post($post, $mform, &$message) {
global $USER, $CFG, $DB;
/**
* Update a post
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @param object $post
+ * @param mixed $mform
+ * @param string $message
+ * @return bool
*/
function forum_update_post($post, $mform, &$message) {
global $USER, $CFG, $DB;
/**
* Given an object containing all the necessary data,
* create a new discussion and return the id
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @param object $post
+ * @param mixed $mform
+ * @param string $message
+ * @return object
*/
function forum_add_discussion($discussion, $mform=null, &$message=null) {
global $USER, $CFG, $DB;
/**
* Deletes a discussion and handles all associated cleanup.
+ *
+ * @global object
* @param object $discussion Discussion to delete
* @param bool $fulldelete True when deleting entire forum
* @param object $course Course
* @param object $cm Course-module
* @param object $forum Forum
+ * @return bool
*/
function forum_delete_discussion($discussion, $fulldelete, $course, $cm, $forum) {
global $DB;
/**
* Deletes a single forum post.
+ *
+ * @global object
* @param object $post Forum post object
* @param mixed $children Whether to delete children. If false, returns false
* if there are any children (without deleting the post). If true,
* @param object $forum Forum
* @param bool $skipcompletion True to skip updating completion state if it
* would otherwise be updated, i.e. when deleting entire forum anyway.
+ * @return bool
*/
function forum_delete_post($post, $children, $course, $cm, $forum, $skipcompletion=false) {
global $DB;
}
/**
- *
+ * @global object
+ * @param object $post
+ * @param bool $children
+ * @return int
*/
function forum_count_replies($post, $children=true) {
global $DB;
/**
- *
+ * @global object
+ * @param int $forumid
+ * @param mixed $value
+ * @return bool
*/
function forum_forcesubscribe($forumid, $value=1) {
global $DB;
}
/**
- *
+ * @global object
+ * @param object $forum
+ * @return bool
*/
function forum_is_forcesubscribed($forum) {
global $DB;
}
/**
- *
+ * @global object
+ * @param int $userid
+ * @param object $forum
+ * @return bool
*/
function forum_is_subscribed($userid, $forum) {
global $DB;
/**
* Adds user to the subscriber list
+ *
+ * @global object
+ * @param int $userid
+ * @param int $forumid
*/
function forum_subscribe($userid, $forumid) {
global $DB;
/**
* Removes user from the subscriber list
+ *
+ * @global object
+ * @param int $userid
+ * @param int $forumid
*/
function forum_unsubscribe($userid, $forumid) {
global $DB;
/**
* Given a new post, subscribes or unsubscribes as appropriate.
* Returns some text which describes what happened.
+ *
+ * @global objec
+ * @param object $post
+ * @param object $forum
*/
function forum_post_subscription($post, $forum) {
/**
* Generate and return the subscribe or unsubscribe link for a forum.
+ *
+ * @global object
+ * @global object
* @param object $forum the forum. Fields used are $forum->id and $forum->forcesubscribe.
* @param object $context the context object for this forum.
* @param 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.
- * @param
+ * @param bool $cantaccessagroup
+ * @param bool $fakelink
+ * @param bool $backtoindex
+ * @param array $subscribed_forums
+ * @return string
*/
function forum_get_subscribe_link($forum, $context, $messages = array(), $cantaccessagroup = false, $fakelink=true, $backtoindex=false, $subscribed_forums=null) {
global $CFG, $USER;
/**
* Generate and return the track or no track link for a forum.
+ *
+ * @global object
+ * @global object
* @param object $forum the forum. Fields used are $forum->id and $forum->forcesubscribe.
+ * @param array $messages
+ * @param bool $fakelink
+ * @return string
*/
function forum_get_tracking_link($forum, $messages=array(), $fakelink=true) {
global $CFG, $USER;
/**
* Returns true if user created new discussion already
+ *
+ * @global object
+ * @global object
* @param int $forumid
* @param int $userid
* @return bool
}
/**
- *
+ * @global object
+ * @global object
+ * @param int $forumid
+ * @param int $userid
+ * @return array
*/
function forum_discussions_user_has_posted_in($forumid, $userid) {
global $CFG, $DB;
}
/**
- *
+ * @global object
+ * @global object
+ * @param int $forumid
+ * @param int $did
+ * @param int $userid
+ * @return bool
*/
function forum_user_has_posted($forumid, $did, $userid) {
global $DB;
}
/**
- *
+ * @global object
+ * @param object $forum
+ * @param object $currentgroup
+ * @param int $unused
+ * @param object $cm
+ * @param object $context
+ * @return bool
*/
function forum_user_can_post_discussion($forum, $currentgroup=null, $unused=-1, $cm=NULL, $context=NULL) {
// $forum is an object
* 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.
- * @param $forum - forum object
- * @param $user - user object
+ *
+ * @global object
+ * @global object
+ * @uses DEBUG_DEVELOPER
+ * @uses CONTEXT_MODULE
+ * @uses VISIBLEGROUPS
+ * @param object $forum forum object
+ * @param object $discussion
+ * @param object $user
+ * @param object $cm
+ * @param object $course
+ * @param object $context
+ * @return bool
*/
function forum_user_can_post($forum, $discussion, $user=NULL, $cm=NULL, $course=NULL, $context=NULL) {
global $USER, $DB;
}
-//checks to see if a user can view a particular post
+/**
+ * checks to see if a user can view a particular post
+ *
+ * @global object
+ * @global object
+ * @uses CONTEXT_MODULE
+ * @uses SEPARATEGROUPS
+ * @param object $post
+ * @param object $course
+ * @param object $cm
+ * @param object $forum
+ * @param object $discussion
+ * @param object $user
+ */
function forum_user_can_view_post($post, $course, $cm, $forum, $discussion, $user=NULL){
global $CFG, $USER;
/**
- *
+ * @global object
+ * @global object
+ * @uses DEBUG_DEVELOPER
+ * @param object $forum
+ * @param object $discussion
+ * @param object $context
+ * @param object $user
+ * @return bool
*/
function forum_user_can_see_discussion($forum, $discussion, $context, $user=NULL) {
global $USER, $DB;
/**
- *
+ * @global object
+ * @global object
+ * @param object $forum
+ * @param object $discussion
+ * @param object $post
+ * @param object $user
+ * @param object $cm
+ * @return bool
*/
function forum_user_can_see_post($forum, $discussion, $post, $user=NULL, $cm=NULL) {
global $USER, $DB;
/**
* Prints the discussion view screen for a forum.
*
+ * @global object
+ * @global object
* @param object $course The current course object.
* @param object $forum Forum to be printed.
* @param int $maxdiscussions .
* @param int $groupmode Group mode of the forum (optional).
* @param void $unused (originally current group)
* @param int $page Page mode, page to display (optional).
- * @param int perpage The maximum number of discussions per page(optional)
+ * @param int $perpage The maximum number of discussions per page(optional)
*
*/
function forum_print_latest_discussions($course, $forum, $maxdiscussions=-1, $displayformat='plain', $sort='',
/**
- *
+ * @global object
+ * @global object
+ * @uses CONTEXT_MODULE
+ * @uses FORUM_MODE_FLATNEWEST
+ * @uses FORUM_MODE_FLATOLDEST
+ * @uses FORUM_MODE_THREADED
+ * @uses FORUM_MODE_NESTED
+ * @param object $course
+ * @param object $cm
+ * @param object $forum
+ * @param object $discussion
+ * @param object $post
+ * @param object $mode
+ * @param mixed $canreply
+ * @param bool $cancreate
*/
function forum_print_discussion($course, $cm, $forum, $discussion, $post, $mode, $canreply=NULL, $canrate=false) {
/**
- *
+ * @global object
+ * @global object
+ * @uses FORUM_MODE_FLATNEWEST
+ * @param object $course
+ * @param object $cm
+ * @param object $forum
+ * @param object $discussion
+ * @param object $post
+ * @param object $mode
+ * @param object $ratings
+ * @param bool $reply
+ * @param bool $forumtracked
+ * @param array $posts
*/
function forum_print_posts_flat($course, &$cm, $forum, $discussion, $post, $mode, $ratings, $reply, $forumtracked, $posts) {
global $USER, $CFG;
/**
- * TODO document
+ * @todo Document this function
+ *
+ * @global object
+ * @global object
+ * @uses CONTEXT_MODULE
*/
function forum_print_posts_threaded($course, &$cm, $forum, $discussion, $parent, $depth, $ratings, $reply, $forumtracked, $posts) {
global $USER, $CFG;
}
/**
- *
+ * @todo Document this function
+ * @global object
+ * @global object
*/
function forum_print_posts_nested($course, &$cm, $forum, $discussion, $parent, $ratings, $reply, $forumtracked, $posts) {
global $USER, $CFG;
/**
* Returns all forum posts since a given time in specified forum.
+ *
+ * @todo Document this functions args
+ * @global object
+ * @global object
+ * @global object
+ * @global object
*/
function forum_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0) {
global $CFG, $COURSE, $USER, $DB;
}
/**
- *
+ * @todo Document this function
+ * @global object
*/
function forum_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames) {
global $CFG;
/**
* recursively sets the discussion field to $discussionid on $postid and all its children
* used when pruning a post
+ *
+ * @global object
+ * @param int $postid
+ * @param int $discussionid
+ * @return bool
*/
function forum_change_discussionid($postid, $discussionid) {
global $DB;
/**
* Prints the editing button on subscribers page
+ *
+ * @global object
+ * @global object
+ * @param int $courseid
+ * @param int $forumid
+ * @return string
*/
function forum_update_subscriptions_button($courseid, $forumid) {
global $CFG, $USER;
"<input type=\"submit\" value=\"$string\" /></form>";
}
-/*
+/**
* This function gets run whenever a role is assigned to a user in a context
*
* @param integer $userid
* @param object $context
+ * @param itn $roleid
* @return bool
*/
function forum_role_assign($userid, $context, $roleid) {
/**
* Add subscriptions for new users
+ *
+ * @global object
+ * @uses CONTEXT_SYSTEM
+ * @uses CONTEXT_COURSE
+ * @uses CONTEXT_COURSECAT
+ * @uses FORUM_INITIALSUBSCRIBE
+ * @param int $userid
+ * @param object $context
+ * @return bool
*/
function forum_add_user_default_subscriptions($userid, $context) {
global $DB;
/**
* Remove subscriptions for a user in a context
+ *
+ * @global object
+ * @global object
+ * @uses CONTEXT_SYSTEM
+ * @uses CONTEXT_COURSECAT
+ * @uses CONTEXT_COURSE
+ * @uses CONTEXT_MODULE
+ * @param int $userid
+ * @param object $context
+ * @return bool
*/
function forum_remove_user_subscriptions($userid, $context) {
/**
* Remove post tracking for a user in a context
+ *
+ * @global object
+ * @global object
+ * @uses CONTEXT_SYSTEM
+ * @uses CONTEXT_COURSECAT
+ * @uses CONTEXT_COURSE
+ * @uses CONTEXT_MODULE
+ * @param int $userid
+ * @param object $context
+ * @return bool
*/
function forum_remove_user_tracking($userid, $context) {
/**
* Mark posts as read.
+ *
+ * @global object
+ * @global object
* @param object $user object
* @param array $postids array of post ids
* @return boolean success
/**
* Mark post as read.
+ * @global object
+ * @global object
+ * @param int $userid
+ * @param int $postid
*/
function forum_tp_add_read_record($userid, $postid) {
global $CFG, $DB;
/**
* Returns all records in the 'forum_read' table matching the passed keys, indexed
* by userid.
+ *
+ * @global object
+ * @param int $userid
+ * @param int $postid
+ * @param int $discussionid
+ * @param int $forumid
+ * @return array
*/
function forum_tp_get_read_records($userid=-1, $postid=-1, $discussionid=-1, $forumid=-1) {
global $DB;
/**
* Returns all read records for the provided user and discussion, indexed by postid.
+ *
+ * @global object
+ * @param inti $userid
+ * @param int $discussionid
*/
function forum_tp_get_discussion_read_records($userid, $discussionid) {
global $DB;
/**
* If its an old post, do nothing. If the record exists, the maintenance will clear it up later.
+ *
+ * @return bool
*/
function forum_tp_mark_post_read($userid, $post, $forumid) {
if (!forum_tp_is_post_old($post)) {
/**
* Marks a whole forum as read, for a given user
+ *
+ * @global object
+ * @global object
+ * @param object $user
+ * @param int $forumid
+ * @param int|bool $groupid
+ * @return bool
*/
function forum_tp_mark_forum_read($user, $forumid, $groupid=false) {
global $CFG, $DB;
/**
* Marks a whole discussion as read, for a given user
+ *
+ * @global object
+ * @global object
+ * @param object $user
+ * @param int $discussionid
+ * @return bool
*/
function forum_tp_mark_discussion_read($user, $discussionid) {
global $CFG, $DB;
}
/**
- *
+ * @global object
+ * @param int $userid
+ * @param object $post
*/
function forum_tp_is_post_read($userid, $post) {
global $DB;
}
/**
- *
+ * @global object
+ * @param object $post
+ * @param int $time Defautls to time()
*/
function forum_tp_is_post_old($post, $time=null) {
global $CFG;
/**
* Returns the count of records for the provided user and discussion.
+ *
+ * @global object
+ * @global object
+ * @param int $userid
+ * @param int $discussionid
+ * @return bool
*/
function forum_tp_count_discussion_read_records($userid, $discussionid) {
global $CFG, $DB;
/**
* Returns the count of records for the provided user and discussion.
+ *
+ * @global object
+ * @global object
+ * @param int $userid
+ * @param int $discussionid
+ * @return int
*/
function forum_tp_count_discussion_unread_posts($userid, $discussionid) {
global $CFG, $DB;
/**
* Returns the count of posts for the provided forum and [optionally] group.
+ * @global object
+ * @global object
+ * @param int $forumid
+ * @param int|bool $groupid
+ * @return int
*/
function forum_tp_count_forum_posts($forumid, $groupid=false) {
global $CFG, $DB;
/**
* Returns the count of records for the provided user and forum and [optionally] group.
+ * @global object
+ * @global object
+ * @param int $userid
+ * @param int $forumid
+ * @param int|bool $groupid
+ * @return int
*/
function forum_tp_count_forum_read_records($userid, $forumid, $groupid=false) {
global $CFG, $DB;
/**
* Returns the count of records for the provided user and course.
* Please note that group access is ignored!
+ *
+ * @global object
+ * @global object
+ * @param int $userid
+ * @param int $courseid
+ * @return array
*/
function forum_tp_get_course_unread_posts($userid, $courseid) {
global $CFG, $DB;
/**
* Returns the count of records for the provided user and forum and [optionally] group.
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @param object $cm
+ * @param object $course
+ * @return int
*/
function forum_tp_count_forum_unread_posts($cm, $course) {
global $CFG, $USER, $DB;
/**
* Deletes read records for the specified index. At least one parameter must be specified.
+ *
+ * @global object
+ * @param int $userid
+ * @param int $postid
+ * @param int $discussionid
+ * @param int $forumid
+ * @return bool
*/
function forum_tp_delete_read_records($userid=-1, $postid=-1, $discussionid=-1, $forumid=-1) {
global $DB;
/**
* Get a list of forums not tracked by the user.
*
+ * @global object
+ * @global object
* @param int $userid The id of the user to use.
* @param int $courseid The id of the course being checked.
* @return mixed An array indexed by forum id, or false.
* Checks the site settings, the user settings and the forum settings (if
* requested).
*
+ * @global object
+ * @global object
+ * @global object
* @param mixed $forum The forum object to test, or the int id (optional).
* @param mixed $userid The user object to check for (optional).
* @return boolean
* 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
+ * @global object
* @param mixed $forum If int, the id of the forum being checked; if object, the forum object
* @param int $userid The id of the user being checked (optional).
* @return boolean
}
/**
- *
+ * @global object
+ * @global object
+ * @param int $forumid
+ * @param int $userid
*/
function forum_tp_start_tracking($forumid, $userid=false) {
global $USER, $DB;
}
/**
- *
+ * @global object
+ * @global object
+ * @param int $forumid
+ * @param int $userid
*/
function forum_tp_stop_tracking($forumid, $userid=false) {
global $USER, $DB;
/**
* Clean old records from the forum_read table.
+ * @global object
+ * @global object
+ * @return void
*/
function forum_tp_clean_read_records() {
global $CFG, $DB;
/**
* Sets the last post for a given discussion
+ *
+ * @global object
+ * @global object
+ * @param into $discussionid
+ * @return bool|int
**/
function forum_discussion_update_last_post($discussionid) {
global $CFG, $DB;
/**
- *
+ * @return array
*/
function forum_get_view_actions() {
return array('view discussion','search','forum','forums','subscribers');
}
/**
- *
+ * @return array
*/
function forum_get_post_actions() {
return array('add discussion','add post','delete discussion','delete post','move discussion','prune post','update post');
/**
* this function returns all the separate forum ids, given a courseid
+ *
+ * @global object
+ * @global object
* @param int $courseid
* @return array
*/
}
/**
- *
+ * @global object
+ * @global object
+ * @global object
+ * @param object $forum
+ * @param object $cm
+ * @return bool
*/
function forum_check_throttling($forum, $cm=null) {
global $USER, $CFG, $DB;
/**
* Removes all grades from gradebook
+ *
+ * @global object
+ * @global object
* @param int $courseid
- * @param string optional type
+ * @param string $type optional
*/
function forum_reset_gradebook($courseid, $type='') {
global $CFG, $DB;
* 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
+ * @global object
* @param $data the data submitted from the reset course.
* @return array status array
*/
/**
* Called by course/reset.php
+ *
* @param $mform form passed by reference
*/
function forum_reset_course_form_definition(&$mform) {
/**
* Course reset form defaults.
+ * @return array
*/
function forum_reset_course_form_defaults($course) {
return array('reset_forum_all'=>1, 'reset_forum_subscriptions'=>0, 'reset_forum_track_prefs'=>0, 'reset_forum_ratings'=>1);
/**
* Converts a forum to use the Roles System
- * @param $forum - a forum object with the same attributes as a record
+ *
+ * @global object
+ * @global object
+ * @param object $forum a forum object with the same attributes as a record
* from the forum database table
- * @param $forummodid - the id of the forum module, from the modules table
- * @param $teacherroles - array of roles that have moodle/legacy:teacher
- * @param $studentroles - array of roles that have moodle/legacy:student
- * @param $guestroles - array of roles that have moodle/legacy:guest
- * @param $cmid - the course_module id for this forum instance
- * @return boolean - forum was converted or not
+ * @param int $forummodid the id of the forum module, from the modules table
+ * @param array $teacherroles array of roles that have moodle/legacy:teacher
+ * @param array $studentroles array of roles that have moodle/legacy:student
+ * @param array $guestroles array of roles that have moodle/legacy:guest
+ * @param int $cmid the course_module id for this forum instance
+ * @return boolean forum was converted or not
*/
function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(),
$studentroles=array(), $guestroles=array(), $cmid=NULL) {
/**
* Returns array of forum aggregate types
+ *
+ * @return array
*/
function forum_get_aggregate_types() {
return array (FORUM_AGGREGATE_NONE => get_string('aggregatenone', 'forum'),
/**
* Returns array of forum layout modes
+ *
+ * @return array
*/
function forum_get_layout_modes() {
return array (FORUM_MODE_FLATOLDEST => get_string('modeflatoldestfirst', 'forum'),
/**
* Returns array of forum types
+ *
+ * @return array
*/
function forum_get_forum_types() {
return array ('general' => get_string('generalforum', 'forum'),
/**
* Returns array of all forum layout modes
+ *
+ * @return array
*/
function forum_get_forum_types_all() {
return array ('news' => get_string('namenews','forum'),
/**
* Returns array of forum open modes
+ *
+ * @return array
*/
function forum_get_open_modes() {
return array ('2' => get_string('openmode2', 'forum'),
/**
* Returns all other caps used in module
+ *
+ * @return array
*/
function forum_get_extra_capabilities() {
return array('moodle/site:accessallgroups', 'moodle/site:viewfullnames', 'moodle/site:trustcontent');
}
+/**
+ * @package mod-forum
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class forum_portfolio_caller extends portfolio_module_caller_base {
protected $postid;
private $discussion;
private $posts;
private $keyedfiles;
-
+ /**
+ * @return array
+ */
public static function expected_callbackargs() {
return array(
'postid' => false,
'attachment' => false,
);
}
-
+ /**
+ * @param array $callbackargs
+ */
function __construct($callbackargs) {
parent::__construct($callbackargs);
if (!$this->postid && !$this->discussionid) {
throw new portfolio_caller_exception('mustprovidediscussionorpost', 'forum');
}
}
-
+ /**
+ * @global object
+ */
public function load_data() {
global $DB;
$this->supportedformats = array(PORTFOLIO_FORMAT_PLAINHTML);
}
}
-
+ /**
+ * @global object
+ * @return string
+ */
function get_return_url() {
global $CFG;
return $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $this->discussion->id;
}
-
+ /**
+ * @global object
+ * @return array
+ */
function get_navigation() {
global $CFG;
);
return array($navlinks, $this->cm);
}
-
+ /**
+ * @global object
+ * @global object
+ * @uses PORTFOLIO_FORMAT_RICH
+ * @return mixed
+ */
function prepare_package() {
global $CFG, $SESSION;
// either a whole discussion
$post = $this->prepare_post($this->post);
$this->get('exporter')->write_new_file($post, 'post.html', $manifest);
}
-
+ /**
+ * @param array $files
+ * @param bool $justone
+ * @return bool|void
+ */
private function copy_files($files, $justone=false) {
if (empty($files)) {
return;
}
}
/**
- * this is a very cut down version of what is in forum_make_mail_post
- */
+ * this is a very cut down version of what is in forum_make_mail_post
+ *
+ * @global object
+ * @param int $post
+ * @return string
+ */
private function prepare_post($post) {
global $DB;
static $users;
return $output;
}
-
+ /**
+ * @return string
+ */
function get_sha1() {
$filesha = '';
try {
}
return $filetime;
}
-
+ /**
+ * @uses CONTEXT_MODULE
+ * @return bool
+ */
function check_permissions() {
$context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
if ($this->post) {
}
return has_capability('mod/forum:exportdiscussion', $context);
}
-
+ /**
+ * @return string
+ */
public static function display_name() {
return get_string('modulename', 'forum');
}