diff options
author | emkael <emkael@tlen.pl> | 2016-06-16 11:49:22 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-06-16 11:50:22 +0200 |
commit | cf41a3ce705fc57c8082d9688cb48d8133d07b8c (patch) | |
tree | 313054888b303a8bcd948c461346d22f8016b78e /app/frontend/controls/ViewPreference.php | |
parent | 7af1ebdd7216f14778bdfa68c39a8e2050413a1f (diff) |
* group view preference views
Diffstat (limited to 'app/frontend/controls/ViewPreference.php')
-rw-r--r-- | app/frontend/controls/ViewPreference.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/frontend/controls/ViewPreference.php b/app/frontend/controls/ViewPreference.php new file mode 100644 index 0000000..8e79951 --- /dev/null +++ b/app/frontend/controls/ViewPreference.php @@ -0,0 +1,38 @@ +<?php + +Prado::using('Application.web.FacadeTemplateControl'); + +Prado::using('Application.user.DbUser'); +Prado::using('Application.facades.UserFacade'); + +Prado::using('System.Web.UI.ActiveControls.TActiveCheckBox'); + +class ViewPreference extends FacadeTemplateControl { + + public function getUserToChange() { + return $this->getControlState('user'); + } + + public function setUserToChange(DbUser $user) { + if (!$this->Page->IsCallBack) { + if ($user->IsGuest) { + throw new TInvalidDataValueException( + Prado::localize( + 'Grouped view preference change impossible for guest user' + ) + ); + } + $this->setControlState('user', $user); + } + } + + public function savePreference($sender, $param) { + $this->getFacade()->setGroupedViewPreference( + $this->UserToChange, + $sender->Checked + ); + } + +} + +?> |