diff options
Diffstat (limited to 'app/frontend/controls')
-rw-r--r-- | app/frontend/controls/ViewPreference.php | 38 | ||||
-rw-r--r-- | app/frontend/controls/ViewPreference.tpl | 4 |
2 files changed, 42 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 + ); + } + +} + +?> diff --git a/app/frontend/controls/ViewPreference.tpl b/app/frontend/controls/ViewPreference.tpl new file mode 100644 index 0000000..43b056d --- /dev/null +++ b/app/frontend/controls/ViewPreference.tpl @@ -0,0 +1,4 @@ +<com:TActiveCheckBox OnCheckedChanged="savePreference"> + <prop:Checked><%= $this->Facade->getGroupedViewPreference($this->UserToChange) %></prop:Checked> + <prop:Text><%[ group events in calendar view ]%></prop:Text> +</com:TActiveCheckBox> |