diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index f7d378f287ea0..3880c78e41ed2 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -1,5 +1,4 @@ . + + /** - * Code to update a user preference in response to an ajax call. You should not - * send requests to this script directly. Instead use the set_user_preference + * Code to update a user preference in response to an ajax call. + * + * You should not send requests to this script directly. Instead use the set_user_preference * function in javascript_static.js. * - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * @package moodlecore + * @package core_preference + * @category preference + * @copyright Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License */ require_once(dirname(__FILE__) . '/../../config.php'); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 9d249dd498fac..2a55f7300f8e8 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1,5 +1,4 @@ preference property - * @param int $cachelifetime cache life time on the current page (ins seconds) - * @return void + * @package core + * @category preference + * @access public + * @param stdClass $user User object. Preferences are preloaded into 'preference' property + * @param int $cachelifetime Cache life time on the current page (in seconds) + * @throws coding_exception + * @return null */ function check_user_preferences_loaded(stdClass $user, $cachelifetime = 120) { global $DB; @@ -1608,13 +1611,14 @@ function check_user_preferences_loaded(stdClass $user, $cachelifetime = 120) { } /** - * Called from set/delete_user_preferences, so that the prefs can + * Called from set/unset_user_preferences, so that the prefs can * be correctly reloaded in different sessions. * * NOTE: internal function, do not call from other code. * - * @param integer $userid the user whose prefs were changed. - * @return void + * @package core + * @access private + * @param integer $userid the user whose prefs were changed. */ function mark_user_preferences_changed($userid) { global $CFG; @@ -1630,13 +1634,17 @@ function mark_user_preferences_changed($userid) { /** * Sets a preference for the specified user. * - * If user object submitted, 'preference' property contains the preferences cache. + * If a $user object is submitted it's 'preference' property is used for the preferences cache. * - * @param string $name The key to set as preference for the specified user - * @param string $value The value to set for the $name key in the specified user's record, - * null means delete current value - * @param stdClass|int $user A moodle user object or id, null means current user - * @return bool always true or exception + * @package core + * @category preference + * @access public + * @param string $name The key to set as preference for the specified user + * @param string $value The value to set for the $name key in the specified user's + * record, null means delete current value. + * @param stdClass|int|null $user A moodle user object or id, null means current user + * @throws coding_exception + * @return bool Always true or exception */ function set_user_preference($name, $value, $user = null) { global $USER, $DB; @@ -1703,11 +1711,14 @@ function set_user_preference($name, $value, $user = null) { /** * Sets a whole array of preferences for the current user * - * If user object submitted, 'preference' property contains the preferences cache. + * If a $user object is submitted it's 'preference' property is used for the preferences cache. * - * @param array $prefarray An array of key/value pairs to be set - * @param stdClass|int $user A moodle user object or id, null means current user - * @return bool always true or exception + * @package core + * @category preference + * @access public + * @param array $prefarray An array of key/value pairs to be set + * @param stdClass|int|null $user A moodle user object or id, null means current user + * @return bool Always true or exception */ function set_user_preferences(array $prefarray, $user = null) { foreach ($prefarray as $name => $value) { @@ -1719,11 +1730,15 @@ function set_user_preferences(array $prefarray, $user = null) { /** * Unsets a preference completely by deleting it from the database * - * If user object submitted, 'preference' property contains the preferences cache. + * If a $user object is submitted it's 'preference' property is used for the preferences cache. * - * @param string $name The key to unset as preference for the specified user - * @param stdClass|int $user A moodle user object or id, null means current user - * @return bool always true or exception + * @package core + * @category preference + * @access public + * @param string $name The key to unset as preference for the specified user + * @param stdClass|int|null $user A moodle user object or id, null means current user + * @throws coding_exception + * @return bool Always true or exception */ function unset_user_preference($name, $user = null) { global $USER, $DB; @@ -1773,12 +1788,17 @@ function unset_user_preference($name, $user = null) { * none is found, then the optional value $default is returned, * otherwise NULL. * - * If user object submitted, 'preference' property contains the preferences cache. - * - * @param string $name Name of the key to use in finding a preference value - * @param mixed $default Value to be returned if the $name key is not set in the user preferences - * @param stdClass|int $user A moodle user object or id, null means current user - * @return mixed string value or default + * If a $user object is submitted it's 'preference' property is used for the preferences cache. + * + * @package core + * @category preference + * @access public + * @param string $name Name of the key to use in finding a preference value + * @param mixed|null $default Value to be returned if the $name key is not set in the user preferences + * @param stdClass|int|null $user A moodle user object or id, null means current user + * @throws coding_exception + * @return string|mixed|null A string containing the value of a single preference. An + * array with all of the preferences or null */ function get_user_preferences($name = null, $default = null, $user = null) { global $USER;