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