private function lookup_users(&$req, $assigner) { // move all usable identification data to email, firstName, lastName if (isset($req["name"])) { self::apply_user_parts($req, Text::split_name($req["name"])); } if (isset($req["user"]) && strpos($req["user"], " ") === false) { if (!get($req, "email")) { $req["email"] = $req["user"]; } } else { if (isset($req["user"])) { self::apply_user_parts($req, Text::split_name($req["user"], true)); } } // extract email, first, last $first = get($req, "firstName"); $last = get($req, "lastName"); $email = trim((string) get($req, "email")); $lemail = strtolower($email); $special = null; if ($lemail) { $special = $lemail; } else { if (!$first && $last && strpos(trim($last), " ") === false) { $special = trim(strtolower($last)); } } $xspecial = $special; if ($special === "all") { $special = "any"; } // check missing contact if (!$first && !$last && !$lemail) { if ($assigner->allow_special_contact("missing", $req, $this->astate)) { return array(null); } else { return $this->error("User missing."); } } // check special: "none", "any", "pc", "me", PC tag, "external" if ($special === "none" || $special === "any") { if (!$assigner->allow_special_contact($special, $req, $this->astate)) { return $this->error("User “{$xspecial}” not allowed here."); } return array((object) array("roles" => 0, "contactId" => null, "email" => $special, "sorter" => "")); } if ($special && !$first && (!$lemail || !$last)) { $ret = ContactSearch::make_special($special, $this->contact->contactId); if ($ret->ids !== false) { return $ret->contacts(); } } if (($special === "ext" || $special === "external") && $assigner->contact_set($req, $this->astate) === "reviewers") { $ret = array(); foreach ($this->reviewer_set() as $u) { if (!$u->is_pc_member()) { $ret[] = $u; } } return $ret; } // check for precise email match on existing contact (common case) if ($lemail && ($contact = $this->cmap->lookup_lemail($lemail))) { return array($contact); } // check PC list $cset = $assigner->contact_set($req, $this->astate); if ($cset === "pc") { $cset = pcMembers(); } else { if ($cset === "reviewers") { $cset = $this->reviewer_set(); } } if ($cset) { $text = ""; if ($first && $last) { $text = "{$last}, {$first}"; } else { if ($first || $last) { $text = "{$last}{$first}"; } } if ($email) { $text .= " <{$email}>"; } $ret = ContactSearch::make_cset($text, $this->contact->cid, $cset); if (count($ret->ids) == 1) { return $ret->contacts(); } else { if (count($ret->ids) == 0) { $this->error("No user matches “" . self::req_user_html($req) . "”."); } else { $this->error("“" . self::req_user_html($req) . "” matches more than one user, use a full email address to disambiguate."); } } return false; } // create contact if (!$email) { return $this->error("Missing email address"); } $contact = $this->cmap->make_email($email); if ($contact->contactId < 0) { if (!validate_email($email)) { return $this->error("Email address “" . htmlspecialchars($email) . "” is invalid."); } if (!isset($contact->firstName) && get($req, "firstName")) { $contact->firstName = $req["firstName"]; } if (!isset($contact->lastName) && get($req, "lastName")) { $contact->lastName = $req["lastName"]; } } return array($contact); }