private function searchUser(User $from, $userId) { if ($userId == '') { return null; } if ($userId == $from->getId()) { return $from; } $form = (new Form())->import([UserDAO::ID => $userId])->addRule(UserDAO::ID, Rules::isUserOnline(), $from->getLang()->getPhrase('UserIsNotOnline')); if (!$form->validate()) { RespondError::make($from, $form->getErrors()); DI::get()->getLogger()->warn("Trying to find userId = {$userId} for private message but not found", [__CLASS__]); return false; } $recipient = $form->getResult(UserDAO::ID); /* @var $recipient User */ return $recipient; }