From 3b4a6044986120c9817b042b2a53732b42b25df3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 24 Apr 2014 09:54:13 -0700 Subject: [PATCH] web: tweaks to last commit --- html/inc/boinc_db.inc | 11 +++++++++++ html/user/pm.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/html/inc/boinc_db.inc b/html/inc/boinc_db.inc index 4b27165ae3..1c471aa109 100644 --- a/html/inc/boinc_db.inc +++ b/html/inc/boinc_db.inc @@ -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); diff --git a/html/user/pm.php b/html/user/pm.php index 026dd36adb..092c91e24f 100644 --- a/html/user/pm.php +++ b/html/user/pm.php @@ -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