public function removePermission(Permission $permission) { $DBH = Application::getDatabaseHandler(); $STH = $DBH->prepare('DELETE FROM ' . DBConfig::table(DBConfig::GROUP_PERMISSIONS) . ' WHERE id_g=:idg && id_p=:idp LIMIT 1'); $STH->bindValue(':idp', $permission->getId(), PDO::PARAM_INT); $STH->bindValue(':idg', $this->id, PDO::PARAM_INT); $STH->execute(); }
/** * Sets database tables prefix when DBConfig class is used * @param $prefix * @deprecated */ public function setDbPrefix($prefix) { DBConfig::setDBPrefix($prefix); }
public function login($login, $password) { $db = $this->serviceManager->get('PDO'); $userDao = $this->serviceManager->getDao('UserDao'); $user = $userDao->getByLogin($login); if ($this->isLoggedIn($user->getId())) { return false; } if (Authorization::validatePassword($password, $user->getPasswordHash())) { if (!$user->getStatus()) { return false; } else { $this->user = $user; $timeout = time() + $this->loginTimeOut; $_SESSION['loginTimeOut'] = $timeout; $STH = $db->prepare("UPDATE " . DBConfig::table(DBConfig::AUTHORIZATION) . " SET id_u=:id_u, timeout=:to, url=:url WHERE id_auth=:id_a LIMIT 1;"); $STH->bindValue(':id_a', $this->authId, PDO::PARAM_INT); $STH->bindValue(':id_u', $this->user->getId(), PDO::PARAM_INT); $STH->bindValue(':to', $timeout, PDO::PARAM_INT); $STH->bindValue(':url', $_SERVER['REQUEST_URI'], PDO::PARAM_STR); return $STH->execute() ? true : false; } } else { return false; } }
/** * @param DBRecord $group * @throws \InvalidArgumentException * @return PDOStatement */ protected function prepareUpdateStatement(DBRecord $group) { if (!$group instanceof Group) { throw new InvalidArgumentException("Argument must be instance of " . __NAMESPACE__ . " class!"); } $conn = $this->getConnection(); $stmt = $conn->prepare('UPDATE ' . DBConfig::table(DBConfig::GROUPS) . ' SET name=:n, description=:d WHERE id=:id;'); $stmt->bindValue(':id', $group->getId(), PDO::PARAM_INT); $stmt->bindValue(':n', $group->getName(), PDO::PARAM_STR); $stmt->bindValue(':d', $group->getDescription(), PDO::PARAM_STR); return $stmt; }
/** * @param DBRecord $record * @throws InvalidArgumentException * @return PDOStatement */ protected function prepareUpdateStatement(DBRecord $record) { if (!$record instanceof Role) { throw new InvalidArgumentException("Object must be instance of Role class!"); } $conn = $this->getConnection(); $stmt = $conn->prepare('UPDATE ' . DBConfig::table(DBConfig::USERS) . ' SET login=:login, email=:email, activated=:status, firstname=:fn, surname=:sn WHERE id_u=:id;'); $stmt->bindValue(':id', $record->getId(), PDO::PARAM_INT); $stmt->bindValue(':login', $record->getLogin(), PDO::PARAM_STR); $stmt->bindValue(':email', $record->getEmail(), PDO::PARAM_STR); $stmt->bindValue(':status', $record->getStatus(), PDO::PARAM_INT); $stmt->bindValue(':fn', $record->getFirstname(), PDO::PARAM_STR); $stmt->bindValue(':sn', $record->getSurname(), PDO::PARAM_STR); return $stmt; }