From 89dcb99da2f6993f86d6e2430eb23ed4a1664d8d Mon Sep 17 00:00:00 2001 From: dhawes Date: Sat, 25 Sep 2004 05:29:21 +0000 Subject: [PATCH] More phpdoc work --- lib/datalib.php | 57 +++-- lib/moodlelib.php | 55 +++-- lib/weblib.php | 596 ++++++++++++++++++++++++++++------------------ 3 files changed, 435 insertions(+), 273 deletions(-) diff --git a/lib/datalib.php b/lib/datalib.php index 247de497bc..8f962f7729 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -8,7 +8,7 @@ * - moodlelib.php - general-purpose Moodle functions * @author Martin Dougiamas * @version $Id$ - * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package moodlecore */ @@ -124,7 +124,14 @@ function modify_database($sqlfile='', $sqlstring='') { * * @uses $CFG * @uses $db - * @param type description + * @param string $table ? + * @param string $oldfield ? + * @param string $field ? + * @param string $type ? + * @param string $size ? + * @param string $signed ? + * @param string $default ? + * @param string $null ? * @todo Finish documenting this function */ @@ -1072,7 +1079,7 @@ function update_record($table, $dataobject) { * @uses SITEID * @param string $field The first table field to be checked for a given value. * @param string $value The value to match for $field. - * @return array + * @return user A {@link $USER} object. * @todo Finish documenting this function */ */ @@ -1186,7 +1193,7 @@ function get_admin () { * Returns list of all admins * * @uses $CFG - * @return array An associative array of user records. + * @return array An array of {@link $USER} records. * @todo Finish documenting this function */ function get_admins() { @@ -1204,7 +1211,7 @@ function get_admins() { * Returns list of all creators * * @uses $CFG - * @return array An associative array. + * @return array An array of {@link $USER} objects. * @todo Finish documenting this function */ function get_creators() { @@ -1223,7 +1230,7 @@ function get_creators() { * * @uses $CFG * @param int $courseid The course in question. - * @return array|false An associative array representing the user record of the main teacher for the specified course or false if error. + * @return user|false A {@link $USER} record of the main teacher for the specified course or false if error. * @todo Finish documenting this function */ function get_teacher($courseid) { @@ -1248,7 +1255,7 @@ function get_teacher($courseid) { * * @uses $CFG * @param int $courseid The course in question. - * @return array|false An associative array with the results from the SQL call or false if error. + * @return array|false An array of {@link $USER} records or false if error. * @todo Finish documenting this function */ function get_recent_enrolments($courseid, $timestart) { @@ -1286,7 +1293,7 @@ function get_recent_enrolments($courseid, $timestart) { * @param string $search ? * @param string $fields A comma separated list of fields to be returned from the chosen table. * @param string $exceptions ? - * @return array An associative array with the users requested. + * @return array An array of {@link $USER} records. * @todo Finish documenting this function */ function get_course_students($courseid, $sort='s.timeaccess', $dir='', $page=0, $recordsperpage=99999, @@ -1441,7 +1448,7 @@ function count_course_students($course, $search='', $firstinitial='', $lastiniti * @param int $courseid The course in question. * @param string $sort ? * @param string $exceptions ? - * @return array An associative array with the results from the SQL call. + * @return array An array of {@link $USER} records. * @todo Finish documenting this function */ function get_course_teachers($courseid, $sort='t.authority ASC', $exceptions='') { @@ -1471,7 +1478,7 @@ function get_course_teachers($courseid, $sort='t.authority ASC', $exceptions='') * @param string $sort ? * @param string $exceptions ? * @param string $fields A comma separated list of fields to be returned from the chosen table. - * @return array An associative array. + * @return array An array of {@link $USER} records. * @todo Finish documenting this function */ function get_course_users($courseid, $sort='timeaccess DESC', $exceptions='', $fields='') { @@ -1504,7 +1511,7 @@ function get_course_users($courseid, $sort='timeaccess DESC', $exceptions='', $f * @param string $searchtext ? * @param string $sort ? * @param string $exceptions ? - * @return array An associative array. + * @return array An array of {@link $USER} records. * @todo Finish documenting this function */ */ @@ -1584,7 +1591,7 @@ function search_users($courseid, $groupid, $searchtext, $sort='', $exceptions='' * @uses SITEID * @deprecated Use {@link get_course_users()} instead. * @param string $fields A comma separated list of fields to be returned from the chosen table. - * @return array|false An associative array with the results from the SQL call or false if error. + * @return array|false An array of {@link $USER} records or false if error. * @todo Finish documenting this function. The return type need to be better defined. */ function get_site_users($sort='u.lastaccess DESC', $fields='*', $exceptions='') { @@ -1607,7 +1614,7 @@ function get_site_users($sort='u.lastaccess DESC', $fields='*', $exceptions='') * @param string $page ? * @param string $recordsperpage ? * @param string $fields A comma separated list of fields to be returned from the chosen table. - * @return array|false|int An associative array with the results from the SQL call unless get is true in which case the integer count of the records found is returned. False is returned if an error is encountered. + * @return array|false|int An array of {@link $USER} records unless get is false in which case the integer count of the records found is returned. False is returned if an error is encountered. * @todo Finish documenting this function. The return type needs to be better defined. */ function get_users($get=true, $search='', $confirmed=false, $exceptions='', $sort='firstname ASC', @@ -1680,7 +1687,7 @@ function get_users($get=true, $search='', $confirmed=false, $exceptions='', $sor * @param string $search ? * @param string $firstinitial ? * @param string $lastinitial ? - * @return array + * @return array An array of {@link $USER} records * @todo Finish documenting this function */ @@ -1738,7 +1745,7 @@ function get_users_listing($sort='lastaccess', $dir='ASC', $page=0, $recordsperp * longdesc * * @uses $CFG - * @return array + * @return array An array of {@link $USER} records * @todo Finish documenting this function */ function get_users_confirmed() { @@ -1759,7 +1766,7 @@ function get_users_confirmed() { * * @uses $CFG * @param string $cutofftime ? - * @return array + * @return array An array of {@link $USER} records * @todo Finish documenting this function */ function get_users_unconfirmed($cutofftime=2000000000) { @@ -1779,7 +1786,7 @@ function get_users_unconfirmed($cutofftime=2000000000) { * * @uses $CFG * @param string $cutofftime ? - * @return array + * @return array An array of {@link $USER} records * @todo Finish documenting this function */ function get_users_longtimenosee($cutofftime) { @@ -1796,7 +1803,7 @@ function get_users_longtimenosee($cutofftime) { * list of all groups in the course. * * @uses $CFG - * @param int $courseid The course in question. + * @param int $courseid The id of the course in question. * @param int $userid The id of the user in question as found in the 'user' table 'id' field. * @return array * @todo Finish documenting this function @@ -1910,8 +1917,8 @@ function user_group($courseid, $userid) { /** * Returns $course object of the top-level site. * - * @return array - * @todo Finish documenting this function. Is $course an 'object(course)' or an associative 'array(course)' or simply an 'array'? + * @return course A {@link $COURSE} object for the site + * @todo Finish documenting this function. */ function get_site () { @@ -1930,7 +1937,7 @@ function get_site () { * @param int $categoryid ? * @param string $sort ? * @param string $fields A comma separated list of fields to be returned from the chosen table. - * @return array + * @return array An array of {@link $COURSE} records * @todo Finish documenting this function */ function get_courses($categoryid='all', $sort='c.sortorder ASC', $fields='c.*') { @@ -1994,7 +2001,7 @@ function get_courses($categoryid='all', $sort='c.sortorder ASC', $fields='c.*') * @param int $totalcount Passed by reference. ? * @param int $limitfrom ? * @param int $limitnum ? - * @return array + * @return array An array of {@link $COURSE} records * @todo Finish documenting this function */ function get_courses_page($categoryid='all', $sort='c.sortorder ASC', $fields='c.*', @@ -2062,7 +2069,7 @@ function get_courses_page($categoryid='all', $sort='c.sortorder ASC', $fields='c * @uses $CFG * @param int $userid ? * @param string $sort ? - * @return array + * @return array An array of {@link $COURSE} records * @todo Finish documenting this function */ function get_my_courses($userid, $sort='visible DESC,sortorder ASC') { @@ -2111,7 +2118,7 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC') { * @param int $page ? * @param int $recordsperpage ? * @param int $totalcount Passed in by reference. ? - * @return array + * @return array An array of {@link $COURSE} records * @todo Finish documenting this function */ function get_courses_search($searchterms, $sort='fullname ASC', $page=0, $recordsperpage=50, &$totalcount) { @@ -2477,7 +2484,7 @@ function instance_is_visible($moduletype, $module) { * @uses $db * @uses $REMOTE_ADDR * @uses SITEID - * @param int $course The course id + * @param int $courseid The course id * @param string $module The module name - e.g. forum, journal, resource, course, user etc * @param string $action View, edit, post (often but not always the same as the file.php) * @param string $url The file and parameters used to see the results of the action diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 8059536847..3e956c4da2 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -24,7 +24,7 @@ /////////////////////////////////////////////////////////////////////////// /** - * Moodle main library + * moodlelib.php - Moodle main library * * Main library file of miscellaneous general-purpose Moodle functions. * Other main libraries: @@ -32,7 +32,7 @@ * - datalib.php - functions that access the database * @author Martin Dougiamas * @version $Id$ - * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package moodlecore */ /// CONSTANTS ///////////////////////////////////////////////////////////// @@ -89,7 +89,7 @@ function optional_variable(&$var, $default=0) { /** * Set a key in global configuration * - * Set a key/value pair in both this session's $CFG global variable + * Set a key/value pair in both this session's {@link $CFG} global variable * and in the 'config' database table for future sessions. * * @param string $name the key to set @@ -302,7 +302,7 @@ function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0, * * @param int $totalsecs ? * @param array $str ? - * @retunr string + * @return string * @todo Finish documenting this function */ function format_time($totalsecs, $str=NULL) { @@ -531,7 +531,7 @@ function get_user_timezone($tz = 99) { * whether they are "logged in" or allowed to be in a particular course. * If not, then it redirects them to the site login or course enrolment. * $autologinguest determines whether visitors should automatically be - * logged in as guests provide $CFG->autologinguests is set to 1 + * logged in as guests provide {@link $CFG}->autologinguests is set to 1 * * @uses $CFG * @uses $SESSION @@ -667,7 +667,7 @@ function update_user_login_times() { /** * Determines if a user has completed setting up their account. * - * @param array $user A user object to test for the existance of a valid name and email + * @param user $user A {@link $USER} object to test for the existance of a valid name and email * @return boolean */ function user_not_fully_set_up($user) { @@ -711,7 +711,10 @@ function reset_login_count() { /** * check_for_restricted_user * - * @param type description + * @uses $CFG + * @uses $USER + * @param string $username ? + * @param string $redirect ? * @todo Finish documenting this function */ function check_for_restricted_user($username=NULL, $redirect='') { @@ -738,7 +741,10 @@ function check_for_restricted_user($username=NULL, $redirect='') { * * @uses $USER * @param int $userid The id of the user as is found in the 'user' table + * @staticvar array $admin ? + * @staticvar array $nonadmins ? * @return boolean + * @todo Complete documentation for this function */ function isadmin($userid=0) { global $USER; @@ -916,7 +922,7 @@ function isguest($userid=0) { * * @uses $USER * @param int $courseid The id of the course being tested - * @param array $user A user object. If null then the currently logged in user is used. + * @param user $user A {@link $USER} object. If null then the currently logged in user is used. * @return boolean */ function isediting($courseid, $user=NULL) { @@ -1071,7 +1077,7 @@ function get_user_fieldnames() { * @param string $username New user's username to add to record * @param string $password New user's password to add to record * @param string $auth Form of authentication required - * @return array + * @return user A {@link $USER} object * @todo Outline auth types and provide code example */ function create_user_record($username, $password, $auth='') { @@ -1117,7 +1123,7 @@ function create_user_record($username, $password, $auth='') { * * @uses $CFG * @param string $username New user's username to add to record - * @return array + * @return user A {@link $USER} object */ function update_user_record($username) { global $CFG; @@ -1141,7 +1147,7 @@ function update_user_record($username) { * Retrieve the guest user object * * @uses $CFG - * @return array + * @return user A {@link $USER} object */ function guest_user() { global $CFG; @@ -1167,7 +1173,7 @@ function guest_user() { * @uses $CFG * @param string $username User's username * @param string $password User's password - * @return array + * @return user|flase A {@link $USER} object or false if error */ function authenticate_user_login($username, $password) { @@ -1812,8 +1818,8 @@ function mygroupid($courseid) { * what the current default groupmode is: * NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS * - * @param array $course A course object - * @param array $cm A course module object + * @param course $course A {@link $COURSE} object + * @param array? $cm A course module object * @return int A group mode (NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS) */ function groupmode($course, $cm=null) { @@ -1876,11 +1882,11 @@ function get_current_group($courseid, $full=false) { * that to reset the current group for the user. * * @uses VISIBLEGROUPS - * @param array $course A course object + * @param course $course A {@link $COURSE} object * @param int $groupmode Either NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS * @param int $groupid Will try to use this optional parameter to * reset the current group for the user - * @retunr int|false Returns the current group id or false if error. + * @return int|false Returns the current group id or false if error. * @todo Finish documenting this function */ function get_and_set_current_group($course, $groupmode, $groupid=-1) { @@ -1927,7 +1933,7 @@ function get_and_set_current_group($course, $groupmode, $groupid=-1) { * * @uses SEPARATEGROUPS * @uses VISIBLEGROUPS - * @param array $course A course object + * @param course $course A {@link $COURSE} object * @param int $groupmode Either NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS * @param string $urlroot ? * @todo Finish documenting this function @@ -1973,8 +1979,8 @@ function setup_and_print_groups($course, $groupmode, $urlroot) { * @uses $CFG * @uses $_SERVER * @uses SITEID - * @param array $user a user record as an object - * @param array $from a user record as an object + * @param user $user A {@link $USER} object + * @param user $from A {@link $USER} object * @param string $subject plain text subject line of the email * @param string $messagetext plain text version of the message * @param string $messagehtml complete html version of the message (optional) @@ -2099,7 +2105,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml='', $a * Resets specified user's password and send the new password to the user via email. * * @uses $CFG - * @param array $user An associative array representing a user object + * @param user $user A {@link $USER} object * @return boolean|string Returns "true" if mail was sent OK, "emailstop" if email * was blocked by user and "false" if there was another sort of error. */ @@ -2135,7 +2141,7 @@ function reset_password_and_mail($user) { * Send email to specified user with confirmation text and activation link. * * @uses $CFG - * @param array $user An associative array representing a user object + * @param user $user A {@link $USER} object * @return boolean|string Returns "true" if mail was sent OK, "emailstop" if email * was blocked by user and "false" if there was another sort of error. */ @@ -2164,7 +2170,7 @@ function reset_password_and_mail($user) { * send_password_change_confirmation_email. * * @uses $CFG - * @param array $user An associative array representing a user object + * @param user $user A {@link $USER} object * @return boolean|string Returns "true" if mail was sent OK, "emailstop" if email * was blocked by user and "false" if there was another sort of error. * @todo Finish documenting this function @@ -2595,6 +2601,10 @@ function get_real_size($size=0) { * * @param string $size ? * @return string + * @staticvar string $gb Localized string for size in gigabytes + * @staticvar string $mb Localized string for size in megabytes + * @staticvar string $kb Localized string for size in kilobytes + * @staticvar string $b Localized string for size in bytes * @todo Finish documenting this function. Verify return type. */ function display_size($size) { @@ -2787,6 +2797,7 @@ function get_string($identifier, $module='', $a=NULL) { * @param string $langfile ? * @param string $destination ? * @return string|false ? + * @staticvar array $strings Localized strings * @todo Finish documenting this function. */ function get_string_from_file($identifier, $langfile, $destination) { diff --git a/lib/weblib.php b/lib/weblib.php index 560d87a876..aa332914c9 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -34,7 +34,7 @@ * - moodlelib.php - general-purpose Moodle functions. * @author Martin Dougiamas * @version $Id$ - * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package moodlecore */ @@ -75,7 +75,6 @@ define('FORMAT_MARKDOWN', '4'); // Markdown-formatted text http://daringfireba $ALLOWED_TAGS = '