public function loadByLogin($username, $password, $groups = array()) { // Load user from database by given login data $sql = new SqlManager(); if (count($groups) > 0) { $in = $sql->arrayToInString($groups, true); $sql->setQuery("\n\t\t\t\tSELECT user.id, user.password FROM user\n\t\t\t\tJOIN meta ON (meta.name = 'usergroup' AND meta.value IN (" . $in . "))\n\t\t\t\tJOIN assortment ON (assortment.type = 'usergroup' AND assortment.id = meta.value)\n\t\t\t\tWHERE username = '******'\n\t\t\t\t"); } else { $sql->setQuery("SELECT id, password FROM user WHERE username = '******'"); } $sql->bindParam("{{username}}", $username); $user = $sql->result(); if (isset($user['id']) && isset($user['password']) && Crypt::checkHash($password, $user['password'])) { $this->load($user['id']); } }