diff options
author | emkael <emkael@tlen.pl> | 2016-03-16 23:20:41 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-03-16 23:20:41 +0100 |
commit | 519ae86377ce9462099c3d025ed4d2fda90774c5 (patch) | |
tree | d753efc5d65dd38029e6e46de0dae6e593ce688b /app/php/components | |
parent | c4c6d266817907c7587753ee9115a77e17f4cf4d (diff) |
* user selection operations factored out to a facade
Diffstat (limited to 'app/php/components')
-rw-r--r-- | app/php/components/UserSelection.php | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/app/php/components/UserSelection.php b/app/php/components/UserSelection.php index 7b10b40..6ae68e4 100644 --- a/app/php/components/UserSelection.php +++ b/app/php/components/UserSelection.php @@ -1,7 +1,6 @@ <?php -Prado::using('Application.dto.CalendarGroupDTO'); -Prado::using('Application.model.UserPreference'); +Prado::using('Application.facades.CalendarFacade'); class UserSelection extends TTemplateControl { @@ -28,40 +27,11 @@ class UserSelection extends TTemplateControl { public function removeFromSelection($sender, $param) { if (!$this->UserToDisplay->IsGuest) { - $preferenceRecord = UserPreference::finder()->find( - '_user = ? AND _calendar = ?', - $this->UserToDisplay->DbRecord->ID, - $param->CommandParameter - ); - $preferenceRecord->delete(); } } private function _getUserSelection(DbUser $user) { - $calendars = $user->getCalendarPreference(); - if ($calendars) { - $categories = Category::finder()->findAllByPks( - array_unique( - array_map( - function($calendar) { - return $calendar->CategoryID; - }, - $calendars - ) - ) - ); - $categories = array_map( - function($category) use($calendars) { - $dto = new CalendarGroupDTO(); - $dto->loadRecord($category, $calendars); - return $dto; - }, - $categories - ); - usort($categories, ['CalendarGroupDTO', '__compare']); - return $categories; - } - return []; + return CalendarFacade::getInstance()->getPreferenceList($user); } } |