get_user_preferences() Fixed regression so that it returns single value when required

This commit is contained in:
moodler 2008-11-25 02:30:27 +00:00
parent cfe208fda5
commit 469337539f

View file

@ -1109,7 +1109,7 @@ function unset_user_preference($name, $otheruserid=NULL) {
function get_user_preferences($name=NULL, $default=NULL, $otheruserid=NULL) { function get_user_preferences($name=NULL, $default=NULL, $otheruserid=NULL) {
global $USER, $DB; global $USER, $DB;
if (empty($otheruserid)){ if (empty($otheruserid) || (!empty($USER->id) && ($USER->id == $otheruserid))){
check_user_preferences_loaded(); check_user_preferences_loaded();
if (empty($name)) { if (empty($name)) {
@ -1123,7 +1123,7 @@ function get_user_preferences($name=NULL, $default=NULL, $otheruserid=NULL) {
} else { } else {
if (empty($name)) { if (empty($name)) {
return $DB->get_records_menu('user_preferences', array('userid'=>$otheruserid), '', 'name,value'); // All values return $DB->get_records_menu('user_preferences', array('userid'=>$otheruserid), '', 'name,value'); // All values
} else if ($value = $DB->get_record('user_preferences', array('userid'=>$otheruserid, 'name'=>$name))) { } else if ($value = $DB->get_field('user_preferences', 'value', array('userid'=>$otheruserid, 'name'=>$name))) {
return $value; // The single value return $value; // The single value
} else { } else {
return $default; // Default value (or NULL) return $default; // Default value (or NULL)