diff options
author | emkael <emkael@tlen.pl> | 2016-05-06 15:40:50 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-05-06 15:40:50 +0200 |
commit | a43e887c380fc414121792658136a34051526b6a (patch) | |
tree | 1816ec713671d02dd3d24e92c2f4675f7deab30d /app/php/controls | |
parent | 5bfe174b5907440a4f08bd45fd9c384ab5c58037 (diff) |
* DbUser refactored to use a facade
Diffstat (limited to 'app/php/controls')
-rw-r--r-- | app/php/controls/AddToFilter.tpl | 2 | ||||
-rw-r--r-- | app/php/controls/PasswordChange.php | 8 | ||||
-rw-r--r-- | app/php/controls/RegistrationForm.php | 14 | ||||
-rw-r--r-- | app/php/controls/TimezoneSelect.php | 9 |
4 files changed, 20 insertions, 13 deletions
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 @@ <com:TActiveCheckBox ID="Box" OnCheckedChanged="setUserPreference" CssClass="addToFilterBox"> <prop:Enabled><%= !$this->UserToManage->IsGuest %></prop:Enabled> - <prop:Checked><%= $this->User->isCalendarPreferred($this->getCalendar()->ID) %></prop:Checked> + <prop:Checked><%= $this->Facade->isCalendarPreferred($this->UserToManage, $this->getCalendar()->ID) %></prop:Checked> <prop:ToolTip><%= $this->UserToManage->IsGuest ? 'log in to manage your selections' : '' %></prop:ToolTip> </com:TActiveCheckBox> <com:TLabel ForControl="Box"> 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() { |