/** * Returns an singleton instance of this class * * @param object $config * @param object $args * @return */ public static function getInstance() { if (self::$instance == null) { self::$instance = new CarwashManager(); } return self::$instance; }
/** * Validates user credentials * * @return TRUE - if validation passed, and FALSE - otherwise */ public function validate($uniqueId = false) { if (empty($uniqueId)) { $uniqueId = $this->getUniqueId(); } $validatedUser = CarwashManager::getInstance()->validate($this->getId(), $uniqueId); if (!isset($validatedUser)) { return false; } return true; }
public function service() { $carwashManager = CarwashManager::getInstance(); $title = $this->secure($_REQUEST['title']); $login = $this->secure($_REQUEST['login']); $password = $this->secure($_REQUEST['password']); if ($_REQUEST['carwash_id'] > 0) { $carwash_id = intval($_REQUEST['carwash_id']); $carwashManager->editCarwash($carwash_id, $title, $login, $password); } else { $carwashManager->addCarwash($title, $login, $password); } $this->redirect('admin/carwashes'); }
public function service() { $login = $this->secure($_REQUEST['login']); $password = $this->secure($_REQUEST['password']); $carwashManager = CarwashManager::getInstance(); $carwashDto = $carwashManager->getByLoginPassword($login, $password); if ($carwashDto) { $user = new CarwashUser($carwashDto->getId()); $user->setUniqueId($carwashDto->getHash()); $this->sessionManager->setUser($user, true, true); } else { $_SESSION['error_message'] = 'Wrong Login/Password!'; $this->redirect('login'); } $this->redirect('devices'); }
public function load() { $carwashManager = CarwashManager::getInstance(); $devicesManager = DevicesManager::getInstance(); $devicesDtos = $devicesManager->selectAll(); $devicesDtosMappedById = $devicesManager->mapDtosById($devicesDtos); $carwashDevicesManager = CarwashDevicesManager::getInstance(); $carwashDtos = $carwashManager->selectAll(); $this->addParam('carwashDtos', $carwashDtos); $carwashDeviceIdsArray = array(); foreach ($carwashDtos as $carwashDto) { $carwashId = $carwashDto->getId(); $carwashDeviceIdsArray[$carwashId] = $carwashDevicesManager->getCarwashDevicesIdsArray($carwashId); } $this->addParam("carwashDeviceIdsArray", $carwashDeviceIdsArray); $this->addParam("allDevicesMappedById", $devicesDtosMappedById); }
public function service() { $password = $this->secure($_REQUEST['password']); $newPassword = $this->secure($_REQUEST['new_password']); $repeatNewPassword = $this->secure($_REQUEST['repeat_new_password']); $carwashDto = $this->getCustomer(); if ($carwashDto->getPassword() != $password) { $_SESSION['error_message'] = "Wrong Password!"; $this->redirect("changepass"); } if ($newPassword !== $repeatNewPassword) { $_SESSION['error_message'] = "Repeat Password does not match!"; $this->redirect("changepass"); } $carwashManager = CarwashManager::getInstance(); $carwashDto->setPassword($newPassword); $carwashManager->updateByPk($carwashDto); $_SESSION['success_message'] = "Password successfullt changed"; $this->redirect("changepass"); }
public function getCustomer() { if (!$this->customer) { if ($this->getUserLevel() != UserGroups::$GUEST) { $userId = $this->getUserId(); if ($this->getUserLevel() == UserGroups::$ADMIN) { $adminsManager = AdminsManager::getInstance(); $this->customer = $adminsManager->selectByPK($userId); } else { if ($this->getUserLevel() == UserGroups::$CARWASH) { $carwashManager = CarwashManager::getInstance(); $this->customer = $carwashManager->selectByPK($userId); } } } } return $this->customer; }