From a43e887c380fc414121792658136a34051526b6a Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 May 2016 15:40:50 +0200 Subject: * DbUser refactored to use a facade --- app/php/controls/AddToFilter.tpl | 2 +- app/php/controls/PasswordChange.php | 8 +++++--- app/php/controls/RegistrationForm.php | 14 +++++++------- app/php/controls/TimezoneSelect.php | 9 +++++++-- 4 files changed, 20 insertions(+), 13 deletions(-) (limited to 'app/php/controls') diff --git a/app/php/controls/AddToFilter.tpl b/app/php/controls/AddToFilter.tpl index 0c38584..5b63be8 100644 --- a/app/php/controls/AddToFilter.tpl +++ b/app/php/controls/AddToFilter.tpl @@ -1,6 +1,6 @@ <%= !$this->UserToManage->IsGuest %> - <%= $this->User->isCalendarPreferred($this->getCalendar()->ID) %> + <%= $this->Facade->isCalendarPreferred($this->UserToManage, $this->getCalendar()->ID) %> <%= $this->UserToManage->IsGuest ? 'log in to manage your selections' : '' %> diff --git a/app/php/controls/PasswordChange.php b/app/php/controls/PasswordChange.php index 7c177a6..0f0300c 100644 --- a/app/php/controls/PasswordChange.php +++ b/app/php/controls/PasswordChange.php @@ -3,6 +3,7 @@ Prado::using('Application.web.FacadeTemplateControl'); Prado::using('Application.user.DbUser'); +Prado::using('Application.facades.UserFacade'); class PasswordChange extends FacadeTemplateControl { @@ -20,15 +21,16 @@ class PasswordChange extends FacadeTemplateControl { } public function checkPassword($sender, $param) { - $param->IsValid = DbUser::verifyPassword( - $this->Password->Text, $this->UserToChange->getPassword() + $param->IsValid = $this->getFacade()->verifyUserPassword( + $this->Password->Text, $this->UserToChange ); } public function changePassword($sender, $param) { $this->SuccessMessage->Visible = FALSE; if ($this->Page->IsValid) { - $this->UserToChange->changePassword( + $this->getFacade()->changePassword( + $this->UserToChange, $this->NewPassword->Text ); $this->SuccessMessage->Visible = TRUE; diff --git a/app/php/controls/RegistrationForm.php b/app/php/controls/RegistrationForm.php index d88fb95..46494e3 100644 --- a/app/php/controls/RegistrationForm.php +++ b/app/php/controls/RegistrationForm.php @@ -2,21 +2,21 @@ Prado::using('Application.web.FacadeTemplateControl'); -Prado::using('Application.model.User'); +Prado::using('Application.facades.UserFacade'); class RegistrationForm extends FacadeTemplateControl { public function checkUsername($sender, $param) { - $param->IsValid = !User::finder()->countByLogin($this->Login->SafeText); + $param->IsValid = $this->getFacade()->checkForUsername($this->Login->SafeText); } public function registerUser($sender, $param) { if ($this->Page->IsValid) { - $newUser = new User(); - $newUser->Login = $this->Login->SafeText; - $newUser->Password = DbUser::generatePassword($this->Password->Text); - $newUser->IsAdmin = $this->Admin->Checked; - $newUser->save(); + $this->getFacade()->registerUser( + $this->Login->SafeText, + $this->Password->Text, + $this->Admin->Checked + ); $this->Response->redirect( $this->Service->constructUrl(NULL) ); diff --git a/app/php/controls/TimezoneSelect.php b/app/php/controls/TimezoneSelect.php index 31ba15d..7ef30cb 100644 --- a/app/php/controls/TimezoneSelect.php +++ b/app/php/controls/TimezoneSelect.php @@ -3,6 +3,8 @@ Prado::using('Application.web.FacadeTemplateControl'); Prado::using('Application.user.DbUser'); +Prado::using('Application.facades.UserFacade'); + Prado::using('Application.dto.TimezoneDTO'); class TimezoneSelect extends FacadeTemplateControl { @@ -27,12 +29,15 @@ class TimezoneSelect extends FacadeTemplateControl { $this->Timezones->DataTextField = 'Label'; $this->Timezones->dataBind(); $this->Timezones->setSelectedValue( - $this->UserToChange->getTimezonePreference()->Name + $this->getFacade()->getTimezonePreference($this->UserToChange)->Name ); } public function saveTimezone($sender, $param) { - $this->UserToChange->setTimezonePreference($this->Timezones->SelectedValue); + $this->getFacade()->setTimezonePreference( + $this->UserToChange, + $this->Timezones->SelectedValue + ); } private function _getTimezones() { -- cgit v1.2.3