ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCalendarScheduleFilterTimings Class Reference

Calendar schedule filter for individual timings. More...

+ Inheritance diagram for ilCalendarScheduleFilterTimings:
+ Collaboration diagram for ilCalendarScheduleFilterTimings:

Public Member Functions

 __construct (int $a_usr_id)
 
 getLogger ()
 
 filterCategories (array $a_cats)
 Filter categories All categories are show no filtering (support for individual folder appointments) More...
 
 modifyEvent (ilCalendarEntry $a_event)
 modify event => return false for not presenting event More...
 
 addCustomEvents (ilDate $start, ilDate $end, array $a_categories)
 Add custom events: relative timings, modified timings @inheritDoc. More...
 
 filterCategories (array $a_cats)
 
 modifyEvent (ilCalendarEntry $a_event)
 Modifies event properties. More...
 
 addCustomEvents (ilDate $start, ilDate $end, array $a_categories)
 Add (return) an array of custom ilCalendarEntry's. More...
 

Protected Member Functions

 findCalendarEntriesForItem (int $category_id, int $item_ref_id)
 
 isCourseCategory (int $a_category_id)
 
 enabledCourseTimings (int $a_course_ref)
 

Protected Attributes

const CAL_TIMING_START = 1
 
const CAL_TIMING_END = 2
 

Private Attributes

int $user_id = 0
 
ilLogger $logger
 

Detailed Description

Calendar schedule filter for individual timings.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e \

Definition at line 25 of file class.ilCalendarScheduleFilterTimings.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarScheduleFilterTimings::__construct ( int  $a_usr_id)

@noinspection PhpUndefinedMethodInspection

Definition at line 34 of file class.ilCalendarScheduleFilterTimings.php.

35 {
36 global $DIC;
37
38 $this->user_id = $a_usr_id;
40 $this->logger = $DIC->logger()->crs();
41 }
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomEvents()

ilCalendarScheduleFilterTimings::addCustomEvents ( ilDate  $start,
ilDate  $end,
array  $a_categories 
)

Add custom events: relative timings, modified timings @inheritDoc.

Implements ilCalendarScheduleFilter.

Definition at line 136 of file class.ilCalendarScheduleFilterTimings.php.

136 : array
137 {
138 // @fixme
139 // @todo categories can appear more than once
140 $a_categories = array_unique($a_categories);
141
142 $all_events = [];
143 foreach ($a_categories as $cat_id) {
144 $category = $this->isCourseCategory($cat_id);
145 if (!$category) {
146 continue;
147 }
148 $course_obj_id = $category->getObjId();
149 $ref_ids = ilObject::_getAllReferences($course_obj_id);
150 $course_ref_id = end($ref_ids);
151 $course_timing_mode = ilObjCourse::lookupTimingMode($course_obj_id);
152 if (!$this->enabledCourseTimings($course_ref_id)) {
153 continue;
154 }
155 $active = ilObjectActivation::getTimingsItems($course_ref_id);
156 foreach ($active as $item) {
157 if ($item['timing_type'] != ilObjectActivation::TIMINGS_PRESETTING) {
158 $this->getLogger()->debug('timings not active for: ' . $item['ref_id']);
159 continue;
160 }
161 if (
162 !$item['changeable'] &&
164 ) {
165 $this->getLogger()->debug('Not creating new event since item is unchangeable and absolute');
166 continue;
167 }
168
169 $user_data = new ilTimingUser($item['ref_id'], $this->user_id);
170 if (!$user_data->isScheduled()) {
171 $this->getLogger()->debug('No scheduled timings for user');
172 continue;
173 }
174 if (
175 ilDateTime::_within($user_data->getStart(), $start, $end) or
176 ilDateTime::_within($user_data->getEnd(), $start, $end)
177 ) {
178 $entries = $this->findCalendarEntriesForItem($category->getCategoryID(), $item['ref_id']);
179
180 $this->logger->dump($item);
181 $this->logger->debug('Number of found entries is: ' . count($entries));
182
183 foreach ($entries as $entry) {
184 if ($entry->getContextId() == ilObjCourse::CAL_COURSE_TIMING_START) {
185 $entry->setStart(new ilDate($user_data->getStart()->get(IL_CAL_DATE), IL_CAL_DATE));
186 $entry->setEnd(new ilDate($user_data->getStart()->get(IL_CAL_DATE), IL_CAL_DATE));
187 }
188 if ($entry->getContextId() == ilObjCourse::CAL_COURSE_TIMING_END) {
189 $entry->setStart(new ilDate($user_data->getEnd()->get(IL_CAL_DATE), IL_CAL_DATE));
190 $entry->setEnd(new ilDate($user_data->getEnd()->get(IL_CAL_DATE), IL_CAL_DATE));
191 }
192 $all_events[] = $entry;
193 }
194 }
195 }
196 }
197 return $all_events;
198 }
const IL_CAL_DATE
findCalendarEntriesForItem(int $category_id, int $item_ref_id)
static _within(ilDateTime $dt, ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check whether an date is within a date duration given by start and end.
Class for single dates.
static lookupTimingMode(int $a_obj_id)
const int CAL_COURSE_TIMING_START
const int CAL_COURSE_TIMING_END
static getTimingsItems(int $container_ref_id)
Get (sub) item data for timings view (no session material, no side blocks)
static _getAllReferences(int $id)
get all reference ids for object ID
TableGUI class for timings administration.

References ilObject\_getAllReferences(), ilDateTime\_within(), ilObjCourse\CAL_COURSE_TIMING_END, ilObjCourse\CAL_COURSE_TIMING_START, enabledCourseTimings(), findCalendarEntriesForItem(), getLogger(), ilObjectActivation\getTimingsItems(), IL_CAL_DATE, ilCourseConstants\IL_CRS_VIEW_TIMING_ABSOLUTE, isCourseCategory(), ILIAS\Repository\logger(), ilObjCourse\lookupTimingMode(), and ilObjectActivation\TIMINGS_PRESETTING.

+ Here is the call graph for this function:

◆ enabledCourseTimings()

ilCalendarScheduleFilterTimings::enabledCourseTimings ( int  $a_course_ref)
protected

Definition at line 238 of file class.ilCalendarScheduleFilterTimings.php.

238 : bool
239 {
241 $this->getLogger()->debug('Parent course has other view mode than timings. course ref_id = ' . $a_course_ref);
242 return false;
243 }
244 return true;
245 }
static _lookupViewMode(int $a_id)
static _lookupObjId(int $ref_id)

References ilObject\_lookupObjId(), ilObjCourse\_lookupViewMode(), getLogger(), and ilContainer\VIEW_TIMING.

Referenced by addCustomEvents(), and modifyEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterCategories()

ilCalendarScheduleFilterTimings::filterCategories ( array  $a_cats)

Filter categories All categories are show no filtering (support for individual folder appointments)

Parameters
int[]$a_cats
Returns
int[]

Implements ilCalendarScheduleFilter.

Definition at line 54 of file class.ilCalendarScheduleFilterTimings.php.

54 : array
55 {
56 return $a_cats;
57 }

◆ findCalendarEntriesForItem()

ilCalendarScheduleFilterTimings::findCalendarEntriesForItem ( int  $category_id,
int  $item_ref_id 
)
protected
Returns
\ilCalendarEntry[]

Definition at line 203 of file class.ilCalendarScheduleFilterTimings.php.

203 : array
204 {
206 $entries = [];
207 foreach ($app_ids as $app_id) {
208 $entry = new ilCalendarEntry($app_id);
209
210 if (
211 (
212 $entry->getContextId() == ilObjCourse::CAL_COURSE_TIMING_START ||
213 $entry->getContextId() == ilObjCourse::CAL_COURSE_TIMING_END
214 ) &&
215 $entry->getContextInfo() == $item_ref_id
216 ) {
217 $entries[] = $entry;
218 }
219 }
220 return $entries;
221 }
static _getAssignedAppointments(array $a_cat_id)
Get assigned apointments.
Model for a calendar entry.

References ilCalendarCategoryAssignments\_getAssignedAppointments(), ilObjCourse\CAL_COURSE_TIMING_END, and ilObjCourse\CAL_COURSE_TIMING_START.

Referenced by addCustomEvents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLogger()

ilCalendarScheduleFilterTimings::getLogger ( )

Definition at line 43 of file class.ilCalendarScheduleFilterTimings.php.

43 : ilLogger
44 {
45 return $this->logger;
46 }
Component logger with individual log levels by component id.

References $logger.

Referenced by addCustomEvents(), enabledCourseTimings(), isCourseCategory(), and modifyEvent().

+ Here is the caller graph for this function:

◆ isCourseCategory()

ilCalendarScheduleFilterTimings::isCourseCategory ( int  $a_category_id)
protected

Definition at line 223 of file class.ilCalendarScheduleFilterTimings.php.

224 {
225 $category = ilCalendarCategory::getInstanceByCategoryId($a_category_id);
226
227 if ($category->getType() != ilCalendarCategory::TYPE_OBJ) {
228 $this->getLogger()->debug('No object calendar => not modifying event.');
229 return null;
230 }
231 if ($category->getObjType() != 'crs') {
232 $this->getLogger()->debug('Category object type is != crs => not modifying event');
233 return null;
234 }
235 return $category;
236 }
Stores calendar categories.
static getInstanceByCategoryId(int $a_cat_id)

References ilCalendarCategory\getInstanceByCategoryId(), getLogger(), and ilCalendarCategory\TYPE_OBJ.

Referenced by addCustomEvents(), and modifyEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modifyEvent()

ilCalendarScheduleFilterTimings::modifyEvent ( ilCalendarEntry  $a_event)

modify event => return false for not presenting event

Implements ilCalendarScheduleFilter.

Definition at line 62 of file class.ilCalendarScheduleFilterTimings.php.

63 {
64 $this->getLogger()->debug('Modifying events for timings');
65 if (!$a_event->isAutoGenerated()) {
66 $this->getLogger()->debug($a_event->getTitle() . ' is not autogenerated => no modification');
67 return $a_event;
68 }
69
70 if (
73 ) {
74 $this->getLogger()->debug('Non Timing event: unmodified');
75 return $a_event;
76 }
77
78 // check course calendar
80 $category = $this->isCourseCategory($cat_id);
81 if (!$category) {
82 // no course category
83 return $a_event;
84 }
85
86 // check absolute timings
87 // category object type is folder
88 $obj_id = $category->getObjId();
89 $ref_ids = ilObject::_getAllReferences($obj_id);
90 $ref_id = end($ref_ids);
92 // relative timings => always modify event
93 $this->getLogger()->debug('Filtering event since mode is relative timing: ' . $a_event->getPresentationTitle(true));
94 return null;
95 }
96
97 // timings enabled?
98 if (!$this->enabledCourseTimings($ref_id)) {
99 return null;
100 }
101
102 // check context info
103 if (!$a_event->getContextInfo()) {
104 $this->getLogger()->warning('Missing context info');
105 return null;
106 }
107
108 $item_ref_id = (int) $a_event->getContextInfo();
109 $timing_item = ilObjectActivation::getItem($item_ref_id);
110 if ($timing_item['timing_type'] != ilObjectActivation::TIMINGS_PRESETTING) {
111 $this->getLogger()->debug('Delete event with disabled timing settings');
112 return null;
113 }
114
115 if ($timing_item['changeable']) {
116 // check if scheduled
117 $user_data = new ilTimingUser($item_ref_id, $this->user_id);
118 if ($user_data->isScheduled()) {
119 $this->getLogger()->debug('Filtering event since item is scheduled by user: ' . $a_event->getPresentationTitle(true));
120 return null;
121 }
122 }
123
124 // valid event => refresh title
125 $this->getLogger()->debug('Valid timings event. Update title');
126 $a_event->setTitle(
128 );
129 return $a_event;
130 }
getPresentationTitle(bool $a_shorten=true)
setTitle(string $a_title)
static getItem(int $ref_id)
static _lookupTitle(int $obj_id)
$ref_id
Definition: ltiauth.php:66

References $ref_id, ilObject\_getAllReferences(), ilCalendarCategoryAssignments\_lookupCategory(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObjCourse\CAL_COURSE_TIMING_END, ilObjCourse\CAL_COURSE_TIMING_START, enabledCourseTimings(), ilCalendarEntry\getContextId(), ilCalendarEntry\getContextInfo(), ilCalendarEntry\getEntryId(), ilObjectActivation\getItem(), getLogger(), ilCalendarEntry\getPresentationTitle(), ilCalendarEntry\getTitle(), ilCourseConstants\IL_CRS_VIEW_TIMING_RELATIVE, ILIAS\Repository\int(), ilCalendarEntry\isAutoGenerated(), isCourseCategory(), ilObjCourse\lookupTimingMode(), ilCalendarEntry\setTitle(), and ilObjectActivation\TIMINGS_PRESETTING.

+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilLogger ilCalendarScheduleFilterTimings::$logger
private

Definition at line 32 of file class.ilCalendarScheduleFilterTimings.php.

Referenced by getLogger().

◆ $user_id

int ilCalendarScheduleFilterTimings::$user_id = 0
private

Definition at line 30 of file class.ilCalendarScheduleFilterTimings.php.

◆ CAL_TIMING_END

const ilCalendarScheduleFilterTimings::CAL_TIMING_END = 2
protected

Definition at line 28 of file class.ilCalendarScheduleFilterTimings.php.

◆ CAL_TIMING_START

const ilCalendarScheduleFilterTimings::CAL_TIMING_START = 1
protected

Definition at line 27 of file class.ilCalendarScheduleFilterTimings.php.


The documentation for this class was generated from the following file: