findAllByPks( array_map( function($calendar) { return $calendar->CategoryID; }, $calendars ) ); } public function getPreferenceList(DbUser $user) { $calendars = $user->getCalendarPreference(); if ($calendars) { $categories = array_map( function($category) use($calendars) { $dto = new CalendarGroupDTO(); $dto->loadRecord($category, $calendars); return $dto; }, $this->_getCategoriesForCalendars($calendars) ); usort($categories, ['CalendarGroupDTO', '__compare']); return $categories; } return []; } public function removeFromPreference(DbUser $user, $calendarID) { if (!$user->IsGuest) { $preferenceRecord = UserPreference::finder()->find( '_user = ? AND _calendar = ?', $user->DbRecord->ID, $calendarID ); $preferenceRecord->delete(); } } } ?>