Bugfixes for my recent checkin

This commit is contained in:
moodler
2004-09-23 04:15:19 +00:00
parent a3f1f815a9
commit 6eb3e776fc
4 changed files with 27 additions and 6 deletions
+23 -1
View File
@@ -152,7 +152,7 @@ function reload_user_preferences() {
* @todo Add a better description and include usage examples.
* @param string $name The key to set as preference for the specified user
* @param string $value The value to set forthe $name key in the specified user's record
* @param object $user A moodle user object
* @param integer $userid A moodle user ID
* @todo Add inline links to $USER and user functions in above line.
* @return boolean
*/
@@ -189,9 +189,30 @@ function set_user_preference($name, $value, $userid=NULL) {
}
}
/**
* Unsets a preference completely by deleting it from the database
* Optionally, can set a preference for a different user id
* @uses $USER
* @param string $name The key to unset as preference for the specified user
* @param integer $userid A moodle user ID
* @return boolean
*/
function unset_user_preference($name, $userid=NULL) {
global $USER;
if (empty($userid)){
$userid = $USER->id;
}
return delete_records('user_preferences', 'userid', $userid, 'name', $name);
}
/**
* Sets a whole array of preferences for the current user
* @param array $prefarray An array of key/value pairs to be set
* @param integer $userid A moodle user ID
* @return boolean
*/
function set_user_preferences($prefarray, $userid=NULL) {
@@ -225,6 +246,7 @@ function set_user_preferences($prefarray, $userid=NULL) {
* otherwise NULL.
* @param string $name Name of the key to use in finding a preference value
* @param string $default Value to be returned if the $name key is not set in the user preferences
* @param integer $userid A moodle user ID
* @uses $USER
* @return string
*/
+1 -1
View File
@@ -55,7 +55,7 @@
}
// register success changing password
set_user_preference('auth_forcepasswordchange', false);
unset_user_preference('auth_forcepasswordchange');
$USER = $user;
$USER->loggedin = true;
+1 -1
View File
@@ -66,7 +66,7 @@ if (isadmin()) {
}
echo "<tr>";
echo '<td align=right><p>'.get_string('forcepasswordchange').':</td>';
echo '<td><input type="checkbox" name="forcepasswordchange "'.$checked.' /> '.get_string('forcepasswordchangehelp').'</td>';
echo '<td><input type="checkbox" name="forcepasswordchange" '.$checked.' /> '.get_string('forcepasswordchangehelp').'</td>';
echo "</tr>";
}
+2 -3
View File
@@ -90,7 +90,6 @@
$user = $usernew;
} else {
$db->debug = true;
$timenow = time();
if (!$usernew->picture = save_profile_image($user->id,$um,'users')) {
@@ -120,10 +119,10 @@
}
}
// store forcepasswordchange in user's preferences
if (isset($usernew->forcepasswordchange)){
if (!empty($usernew->forcepasswordchange)){
set_user_preference('auth_forcepasswordchange', 1, $user->id);
} else {
set_user_preference('auth_forcepasswordchange', 0, $user->id);
unset_user_preference('auth_forcepasswordchange', $user->id);
}
} else {
if (isset($usernew->newpassword)) {