diff --git a/admin/user_editor_window.php b/admin/user_editor_window.php index 7fbd8418..b6d3e600 100644 --- a/admin/user_editor_window.php +++ b/admin/user_editor_window.php @@ -102,6 +102,11 @@ echo mysql_error(); * so we'll never add a judge/committee role to a student */ user_create($type, $username, $u); } + } else { + //undelete them? + mysql_query("UPDATE users SET deleted='no' WHERE id='$r->id'"); + //then load them? + $u = user_load($r->id); } } else { $u = user_create($type, $username); diff --git a/user.inc.php b/user.inc.php index bba9bc71..1c885e66 100644 --- a/user.inc.php +++ b/user.inc.php @@ -211,6 +211,9 @@ function user_load($user, $uid = false) /* Turn the type into an array, because there could be more than one */ $ts = explode(',', $ret['types']); + //ts could be FALSE, so check it, and switch to an empty array if it is + if(!$ts) $ts=array(); + $ret['types'] = $ts; /* Now we can use in_array('judge', $ret['types']) ; */ /* Convenience */ @@ -465,9 +468,11 @@ function user_save(&$u) if($u['password'] != $u['orig']['password']) user_set_password($u['id'], $u['password']); - /* Save types */ - foreach($u['types'] as $t) { - call_user_func("user_save_$t", $u); + if(count($u['types'])) { + /* Save types */ + foreach($u['types'] as $t) { + call_user_func("user_save_$t", $u); + } } /* Should we do this? */