summaryrefslogtreecommitdiff
path: root/app/frontend/controls/ViewPreference.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/frontend/controls/ViewPreference.php')
-rw-r--r--app/frontend/controls/ViewPreference.php38
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
+ );
+ }
+
+}
+
+?>