summaryrefslogtreecommitdiff
path: root/app/frontend/controls/AddToFilter.php
blob: 0cc56fc199feff27982b1703c7cd60391b84133c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

Prado::using('System.Web.UI.ActiveControls.TActiveCheckBox');

Prado::using('Application.user.DbUser');

class AddToFilter extends UrlBasedCalendarControl {

    public function setDescription($val) {
        $this->setViewState('Description', TPropertyValue::ensureString($val));
    }

    public function getDescription() {
        return $this->getViewState('Description');
    }

    public function setUserPreference($sender, $param) {
        $user = $this->getUserToManage();
        if ($user && !$user->IsGuest) {
            if ($sender->Checked) {
                $this->getFacade()->addToPreference($user, $this->getCalendar()->ID);
            } else {
                $this->getFacade()->removeFromPreference($user, $this->getCalendar()->ID);
            }
            $this->Page->CallbackClient->jQuery($this->Box, 'removeAttr', 'disabled');
        }
    }

    public function getUserToManage() {
        return $this->getControlState('user');
    }

    public function setUserToManage(DbUser $user) {
        $this->setControlState('user', $user);
    }

    public function getPradoScriptDependencies() {
        return ['jquery'];
    }

}

?>