public loadByEmail ( string $email, $accountId = null ) : Scalr_Account_User | ||
string | The email of the user | |
return | Scalr_Account_User |
public function loadByEmail($email, $accountId = null)
{
if ($accountId) {
$info = $this->db->GetRow("SELECT * FROM account_users WHERE `email` = ? AND account_id = ? LIMIT 1", [$email, $accountId]);
} else {
$info = $this->db->GetRow("SELECT * FROM account_users WHERE `email` = ? LIMIT 1", [$email]);
}
return !$info ? false : $this->loadBy($info);
}
protected function getUserInfoByAccountId($accountId) { if (!isset($this->accountsCache[$accountId])) { if ($accountId) { try { $acc = new \Scalr_Account(); $acc->loadById($accountId); $this->accountsCache[$accountId] = array('id' => $acc->getOwner()->id, 'email' => $acc->getOwner()->getEmail()); } catch (\Exception $e) { $this->console->error($e->getMessage()); return array('id' => 0, 'email' => ''); } } else { $user = new \Scalr_Account_User(); $user->loadByEmail('admin', 0); $this->accountsCache[$accountId] = array('id' => $user->id, 'email' => $user->getEmail()); } } return $this->accountsCache[$accountId]; }