web: tweaks to last commit

This commit is contained in:
David Anderson 2014-04-24 09:54:13 -07:00
parent 278f3fd370
commit 3b4a604498
2 changed files with 12 additions and 1 deletions

View File

@ -135,6 +135,17 @@ class BoincUser {
$email_addr = BoincDb::escape_string($email_addr);
return self::lookup("email_addr='$email_addr'");
}
static function lookup_name($name) {
$name = BoincDb::escape_string($name);
$users = BoincUser::enum("name='$name'");
switch (sizeof($users)) {
case 1:
return $users[0];
case 0:
return null;
}
return -1;
}
static function count($clause) {
$db = BoincDb::get();
return $db->count('user', $clause);

View File

@ -205,7 +205,7 @@ function do_send($logged_in_user) {
pm_form($replyto, $userid, tra("Could not find user with id %1", $userid));
}
} else {
$user = BoincUser:lookup_name($username);
$user = BoincUser::lookup_name($username);
if ($user == null) {
pm_form($replyto, $userid, tra("Could not find user with username %1", $username));
} elseif ($user == -1) { // Non-unique username