ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSessionAppointment Class Reference

class ilSessionAppointment More...

+ Inheritance diagram for ilSessionAppointment:
+ Collaboration diagram for ilSessionAppointment:

Public Member Functions

 __construct ($a_appointment_id=null)
 Consructor. More...
 
 isFullday ()
 is fullday More...
 
 getStart ()
 get start More...
 
 setStart ($a_start)
 set start More...
 
 getEnd ()
 get end More...
 
 setEnd ($a_end)
 set end More...
 
 setAppointmentId ($a_appointment_id)
 
 getAppointmentId ()
 
 setSessionId ($a_session_id)
 
 getSessionId ()
 
 setStartingTime ($a_starting_time)
 
 getStartingTime ()
 
 setEndingTime ($a_ending_time)
 
 getEndingTime ()
 
 toggleFullTime ($a_status)
 
 enabledFullTime ()
 
 formatTime ()
 
 _timeToString ($start, $end)
 
 appointmentToString ()
 
 cloneObject ($new_id)
 clone appointment More...
 
 create ()
 
 update ()
 
 delete ()
 
 validate ()
 
 __read ()
 
 isFullday ()
 is fullday More...
 

Static Public Member Functions

static _lookupAppointment ($a_obj_id)
 lookup appointment More...
 
static lookupNextSessionByCourse ($a_ref_id)
 @access public More...
 
static lookupLastSessionByCourse ($a_ref_id)
 @access public More...
 
static _appointmentToString ($start, $end, $fulltime)
 
static _delete ($a_appointment_id)
 
static _deleteBySession ($a_event_id)
 
static _readAppointmentsBySession ($a_event_id)
 
 getStart ()
 Interface method get start. More...
 
 getEnd ()
 Interface method get end. More...
 

Data Fields

 $ilErr
 
 $ilDB
 
 $tree
 
 $lng
 
 $starting_time = null
 
 $ending_time = null
 

Protected Attributes

 $start = null
 
 $end = null
 

Detailed Description

class ilSessionAppointment

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 15 of file class.ilSessionAppointment.php.

Constructor & Destructor Documentation

◆ __construct()

ilSessionAppointment::__construct (   $a_appointment_id = null)

Consructor.

Parameters
int$a_appointment_id

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

33 {
34 global $ilErr,$ilDB,$lng,$tree;
35
36 $this->ilErr = $ilErr;
37 $this->db = $ilDB;
38 $this->lng = $lng;
39
40 $this->appointment_id = $a_appointment_id;
41 $this->__read();
42 }

References $ilDB, $ilErr, $lng, $tree, and __read().

+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilSessionAppointment::__read ( )

Definition at line 413 of file class.ilSessionAppointment.php.

414 {
415 global $ilDB;
416
417 if (!$this->getAppointmentId()) {
418 return null;
419 }
420
421 $query = "SELECT * FROM event_appointment " .
422 "WHERE appointment_id = " . $ilDB->quote($this->getAppointmentId(), 'integer') . " ";
423 $res = $this->db->query($query);
424 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
425 $this->setSessionId($row->event_id);
426 $this->toggleFullTime($row->fulltime);
427
428 if ($this->isFullday()) {
429 $this->start = new ilDate($row->e_start, IL_CAL_DATETIME);
430 $this->end = new ilDate($row->e_end, IL_CAL_DATETIME);
431 } else {
432 $this->start = new ilDateTime($row->e_start, IL_CAL_DATETIME, 'UTC');
433 $this->end = new ilDateTime($row->e_end, IL_CAL_DATETIME, 'UTC');
434 }
435 $this->starting_time = $this->start->getUnixTime();
436 $this->ending_time = $this->end->getUnixTime();
437 }
438 return true;
439 }
const IL_CAL_DATETIME
@classDescription Date and time handling
Class for single dates.
$query
foreach($_POST as $key=> $value) $res

References $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, getAppointmentId(), IL_CAL_DATETIME, isFullday(), setSessionId(), and toggleFullTime().

Referenced by __construct().

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

◆ _appointmentToString()

static ilSessionAppointment::_appointmentToString (   $start,
  $end,
  $fulltime 
)
static

Definition at line 281 of file class.ilSessionAppointment.php.

282 {
283 global $lng;
284
285 if ($fulltime) {
288 #new ilDate($end,IL_CAL_UNIX)).' ('.$lng->txt('event_full_time_info').')';
290 );
291 } else {
295 );
296 }
297 }
const IL_CAL_UNIX
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.

References $end, $lng, $start, ilDatePresentation\formatPeriod(), and IL_CAL_UNIX.

Referenced by ilCourseContentGUI\__renderItem(), ilCourseContentGUI\__renderUserItem(), appointmentToString(), ilCourseContentGUI\editTimings(), ilRepositoryExplorerGUI\getNodeContent(), ilObjSessionListGUI\getTitle(), and ilObjectCopySelectionTableGUI\parseSource().

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

◆ _delete()

static ilSessionAppointment::_delete (   $a_appointment_id)
static

Definition at line 366 of file class.ilSessionAppointment.php.

367 {
368 global $ilDB;
369
370 $query = "DELETE FROM event_appointment " .
371 "WHERE appointment_id = " . $ilDB->quote($a_appointment_id, 'integer') . " ";
372 $res = $ilDB->manipulate($query);
373
374 return true;
375 }

References $ilDB, $query, and $res.

Referenced by delete().

+ Here is the caller graph for this function:

◆ _deleteBySession()

static ilSessionAppointment::_deleteBySession (   $a_event_id)
static

Definition at line 377 of file class.ilSessionAppointment.php.

378 {
379 global $ilDB;
380
381 $query = "DELETE FROM event_appointment " .
382 "WHERE event_id = " . $ilDB->quote($a_event_id, 'integer') . " ";
383 $res = $ilDB->manipulate($query);
384
385 return true;
386 }

References $ilDB, $query, and $res.

Referenced by ilObjSession\delete().

+ Here is the caller graph for this function:

◆ _lookupAppointment()

static ilSessionAppointment::_lookupAppointment (   $a_obj_id)
static

lookup appointment

@access public

Parameters
intobj_id

Definition at line 51 of file class.ilSessionAppointment.php.

52 {
53 global $ilDB;
54
55 $query = "SELECT * FROM event_appointment " .
56 "WHERE event_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
57 $res = $ilDB->query($query);
58 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
59 $info['fullday'] = $row->fulltime;
60
61 $date = new ilDateTime($row->e_start, IL_CAL_DATETIME, 'UTC');
62 $info['start'] = $date->getUnixTime();
63 $date = new ilDateTime($row->e_end, IL_CAL_DATETIME, 'UTC');
64 $info['end'] = $date->getUnixTime();
65
66 return $info;
67 }
68 return array();
69 }
$info
Definition: index.php:5

References $ilDB, $info, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and IL_CAL_DATETIME.

Referenced by ilCourseContentGUI\__renderItem(), ilCourseContentGUI\__renderUserItem(), ilLPStatusEvent\_getStatusInfo(), ilObjectActivation\addAdditionalSubItemInformation(), ilLPStatusEvent\determineStatus(), ilCourseContentGUI\editTimings(), ilObjSessionListGUI\getAppointmentInfo(), ilRepositoryExplorerGUI\getNodeContent(), and ilObjectCopySelectionTableGUI\parseSource().

+ Here is the caller graph for this function:

◆ _readAppointmentsBySession()

static ilSessionAppointment::_readAppointmentsBySession (   $a_event_id)
static

Definition at line 388 of file class.ilSessionAppointment.php.

389 {
390 global $ilDB;
391
392 $query = "SELECT * FROM event_appointment " .
393 "WHERE event_id = " . $ilDB->quote($a_event_id, 'integer') . " " .
394 "ORDER BY starting_time";
395
396 $res = $ilDB->query($query);
397 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
398 $appointments[] = new ilSessionAppointment($row->appointment_id);
399 }
400 return is_array($appointments) ? $appointments : array();
401 }
class ilSessionAppointment

References $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilObjSession\initAppointments().

+ Here is the caller graph for this function:

◆ _timeToString()

ilSessionAppointment::_timeToString (   $start,
  $end 
)

Definition at line 271 of file class.ilSessionAppointment.php.

272 {
273 global $ilUser,$lng;
274
275 $start = date($this->lng->txt('lang_timeformat_no_sec'), $start);
276 $end = date($this->lng->txt('lang_timeformat_no_sec'), $end);
277
278 return $start . ' - ' . $end;
279 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$ilUser
Definition: imgupload.php:18

References $end, $ilUser, $lng, $start, and date.

Referenced by formatTime().

+ Here is the caller graph for this function:

◆ appointmentToString()

ilSessionAppointment::appointmentToString ( )

◆ cloneObject()

ilSessionAppointment::cloneObject (   $new_id)

clone appointment

@access public

Parameters

return

Definition at line 311 of file class.ilSessionAppointment.php.

312 {
313 $new_app = new ilSessionAppointment();
314 $new_app->setSessionId($new_id);
315 $new_app->setStartingTime($this->getStartingTime());
316 $new_app->setEndingTime($this->getEndingTime());
317 $new_app->toggleFullTime($this->isFullday());
318 $new_app->create();
319 return $new_app;
320 }

References getEndingTime(), getStartingTime(), and isFullday().

+ Here is the call graph for this function:

◆ create()

ilSessionAppointment::create ( )

Definition at line 322 of file class.ilSessionAppointment.php.

323 {
324 global $ilDB;
325
326 if (!$this->getSessionId()) {
327 return false;
328 }
329 $next_id = $ilDB->nextId('event_appointment');
330 $query = "INSERT INTO event_appointment (appointment_id,event_id,e_start,e_end,fulltime) " .
331 "VALUES( " .
332 $ilDB->quote($next_id, 'integer') . ", " .
333 $ilDB->quote($this->getSessionId(), 'integer') . ", " .
334 $ilDB->quote($this->getStart()->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp') . ", " .
335 $ilDB->quote($this->getEnd()->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp') . ", " .
336 $ilDB->quote($this->enabledFullTime(), 'integer') . " " .
337 ")";
338 $this->appointment_id = $next_id;
339 $res = $ilDB->manipulate($query);
340
341 return true;
342 }

References $ilDB, $query, $res, enabledFullTime(), getEnd(), getSessionId(), getStart(), and IL_CAL_DATETIME.

+ Here is the call graph for this function:

◆ delete()

ilSessionAppointment::delete ( )

Definition at line 361 of file class.ilSessionAppointment.php.

362 {
364 }
static _delete($a_appointment_id)

References _delete(), and getAppointmentId().

+ Here is the call graph for this function:

◆ enabledFullTime()

ilSessionAppointment::enabledFullTime ( )

Definition at line 261 of file class.ilSessionAppointment.php.

262 {
263 return $this->fulltime;
264 }

Referenced by appointmentToString(), create(), isFullday(), and update().

+ Here is the caller graph for this function:

◆ formatTime()

ilSessionAppointment::formatTime ( )

Definition at line 266 of file class.ilSessionAppointment.php.

267 {
269 }

References _timeToString(), getEndingTime(), and getStartingTime().

+ Here is the call graph for this function:

◆ getAppointmentId()

ilSessionAppointment::getAppointmentId ( )

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

224 {
225 return $this->appointment_id;
226 }

Referenced by __read(), delete(), and update().

+ Here is the caller graph for this function:

◆ getEnd()

ilSessionAppointment::getEnd ( )

get end

@access public

Returns
ilDateTime

Implements ilDatePeriod.

Definition at line 202 of file class.ilSessionAppointment.php.

203 {
204 return $this->end ? $this->end : $this->end = new ilDateTime(date('Y-m-d') . ' 16:00:00', IL_CAL_DATETIME);
205 }

References date, and IL_CAL_DATETIME.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getEndingTime()

ilSessionAppointment::getEndingTime ( )

Definition at line 252 of file class.ilSessionAppointment.php.

253 {
254 return isset($this->ending_time) ? $this->ending_time : mktime(16, 0, 0, date('n', time()), date('d', time()), date('Y', time()));
255 }

References date.

Referenced by appointmentToString(), cloneObject(), and formatTime().

+ Here is the caller graph for this function:

◆ getSessionId()

ilSessionAppointment::getSessionId ( )

Definition at line 232 of file class.ilSessionAppointment.php.

233 {
234 return $this->session_id;
235 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getStart()

ilSessionAppointment::getStart ( )

get start

@access public

Parameters

return ilDateTime

Implements ilDatePeriod.

Definition at line 180 of file class.ilSessionAppointment.php.

181 {
182 return $this->start ? $this->start : $this->start = new ilDateTime(date('Y-m-d') . ' 08:00:00', IL_CAL_DATETIME);
183 }

References date, and IL_CAL_DATETIME.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getStartingTime()

ilSessionAppointment::getStartingTime ( )

Definition at line 242 of file class.ilSessionAppointment.php.

243 {
244 return isset($this->starting_time) ? $this->starting_time : mktime(8, 0, 0, date('n', time()), date('d', time()), date('Y', time()));
245 }

References date.

Referenced by appointmentToString(), cloneObject(), and formatTime().

+ Here is the caller graph for this function:

◆ isFullday()

ilSessionAppointment::isFullday ( )

is fullday

@access public

Parameters

return

Implements ilDatePeriod.

Definition at line 168 of file class.ilSessionAppointment.php.

169 {
170 return $this->enabledFullTime();
171 }

References enabledFullTime().

Referenced by __read(), and cloneObject().

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

◆ lookupLastSessionByCourse()

static ilSessionAppointment::lookupLastSessionByCourse (   $a_ref_id)
static

@access public

Parameters

return

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

137 {
138 global $tree,$ilDB;
139
140 $sessions = $tree->getChildsByType($a_ref_id, 'sess');
141 $obj_ids = array();
142 foreach ($sessions as $tree_data) {
143 $obj_ids[] = $tree_data['obj_id'];
144 }
145 if (!count($obj_ids)) {
146 return false;
147 }
148 $query = "SELECT event_id FROM event_appointment " .
149 "WHERE e_start < " . $ilDB->now() . " " .
150 "AND " . $ilDB->in('event_id', $obj_ids, false, 'integer') . " " .
151 "ORDER BY e_start DESC ";
152 $ilDB->setLimit(1);
153 $res = $ilDB->query($query);
154 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
155 $event_id = $row->event_id;
156 }
157 return isset($event_id) ? $event_id : 0;
158 }

References $ilDB, $query, $res, $row, $tree, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilContainerByTypeContentGUI\initDetails(), ilContainerSessionsContentGUI\initDetails(), and ilContainerSimpleContentGUI\initDetails().

+ Here is the caller graph for this function:

◆ lookupNextSessionByCourse()

static ilSessionAppointment::lookupNextSessionByCourse (   $a_ref_id)
static

@access public

Parameters

return array

Definition at line 79 of file class.ilSessionAppointment.php.

80 {
81 global $tree,$ilDB;
82
83
84 $sessions = $tree->getChildsByType($a_ref_id, 'sess');
85 $obj_ids = array();
86 foreach ($sessions as $tree_data) {
87 $obj_ids[] = $tree_data['obj_id'];
88 }
89 if (!count($obj_ids)) {
90 return false;
91 }
92
93 // Try to read the next sessions within the next 24 hours
94 $now = new ilDate(time(), IL_CAL_UNIX);
95 $tomorrow = clone $now;
96 $tomorrow->increment(IL_CAL_DAY, 2);
97
98 $query = "SELECT event_id FROM event_appointment " .
99 "WHERE e_start > " . $ilDB->quote($now->get(IL_CAL_DATE, 'timestamp')) . ' ' .
100 "AND e_start < " . $ilDB->quote($tomorrow->get(IL_CAL_DATE, 'timestamp')) . ' ' .
101 "AND " . $ilDB->in('event_id', $obj_ids, false, 'integer') . ' ' .
102 "ORDER BY e_start ";
103
104 $event_ids = array();
105
106 $res = $ilDB->query($query);
107 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
108 $event_ids[] = $row->event_id;
109 }
110
111 if (count($event_ids)) {
112 return $event_ids;
113 }
114
115 // Alternativ: get next event.
116 $query = "SELECT event_id FROM event_appointment " .
117 "WHERE e_start > " . $ilDB->now() . " " .
118 "AND " . $ilDB->in('event_id', $obj_ids, false, 'integer') . " " .
119 "ORDER BY e_start ";
120 $ilDB->setLimit(1);
121 $res = $ilDB->query($query);
122 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
123 $event_id = $row->event_id;
124 }
125 return isset($event_id) ? array($event_id) : array();
126 }
const IL_CAL_DATE
const IL_CAL_DAY

References $ilDB, $query, $res, $row, $tree, ilDBConstants\FETCHMODE_OBJECT, IL_CAL_DATE, IL_CAL_DAY, and IL_CAL_UNIX.

Referenced by ilContainerByTypeContentGUI\initDetails(), ilContainerSessionsContentGUI\initDetails(), and ilContainerSimpleContentGUI\initDetails().

+ Here is the caller graph for this function:

◆ setAppointmentId()

ilSessionAppointment::setAppointmentId (   $a_appointment_id)

Definition at line 219 of file class.ilSessionAppointment.php.

220 {
221 $this->appointment_id = $a_appointment_id;
222 }

◆ setEnd()

ilSessionAppointment::setEnd (   $a_end)

set end

@access public

Parameters
object$dateilDateTime
Returns

Definition at line 214 of file class.ilSessionAppointment.php.

215 {
216 $this->end = $a_end;
217 }

◆ setEndingTime()

ilSessionAppointment::setEndingTime (   $a_ending_time)

Definition at line 247 of file class.ilSessionAppointment.php.

248 {
249 $this->ending_time = $a_ending_time;
250 $this->end = new ilDateTime($this->ending_time, IL_CAL_UNIX);
251 }

References IL_CAL_UNIX.

◆ setSessionId()

ilSessionAppointment::setSessionId (   $a_session_id)

Definition at line 228 of file class.ilSessionAppointment.php.

229 {
230 $this->session_id = $a_session_id;
231 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setStart()

ilSessionAppointment::setStart (   $a_start)

set start

@access public

Parameters
object$datailDateTime

Definition at line 191 of file class.ilSessionAppointment.php.

192 {
193 $this->start = $a_start;
194 }

◆ setStartingTime()

ilSessionAppointment::setStartingTime (   $a_starting_time)

Definition at line 237 of file class.ilSessionAppointment.php.

238 {
239 $this->starting_time = $a_starting_time;
240 $this->start = new ilDateTime($this->starting_time, IL_CAL_UNIX);
241 }

References IL_CAL_UNIX.

◆ toggleFullTime()

ilSessionAppointment::toggleFullTime (   $a_status)

Definition at line 257 of file class.ilSessionAppointment.php.

258 {
259 $this->fulltime = $a_status;
260 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ update()

ilSessionAppointment::update ( )

Definition at line 344 of file class.ilSessionAppointment.php.

345 {
346 global $ilDB;
347
348 if (!$this->getSessionId()) {
349 return false;
350 }
351 $query = "UPDATE event_appointment " .
352 "SET event_id = " . $ilDB->quote($this->getSessionId(), 'integer') . ", " .
353 "e_start = " . $ilDB->quote($this->getStart()->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp') . ", " .
354 "e_end = " . $ilDB->quote($this->getEnd()->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp') . ", " .
355 "fulltime = " . $ilDB->quote($this->enabledFullTime(), 'integer') . " " .
356 "WHERE appointment_id = " . $ilDB->quote($this->getAppointmentId(), 'integer') . " ";
357 $res = $ilDB->manipulate($query);
358 return true;
359 }

References $ilDB, $query, $res, enabledFullTime(), getAppointmentId(), getEnd(), getSessionId(), getStart(), and IL_CAL_DATETIME.

+ Here is the call graph for this function:

◆ validate()

ilSessionAppointment::validate ( )

Definition at line 403 of file class.ilSessionAppointment.php.

404 {
405 if ($this->starting_time > $this->ending_time) {
406 $this->ilErr->appendMessage($this->lng->txt('event_etime_smaller_stime'));
407 return false;
408 }
409 return true;
410 }

Field Documentation

◆ $end

ilSessionAppointment::$end = null
protected

Definition at line 23 of file class.ilSessionAppointment.php.

Referenced by _appointmentToString(), and _timeToString().

◆ $ending_time

ilSessionAppointment::$ending_time = null

Definition at line 26 of file class.ilSessionAppointment.php.

◆ $ilDB

◆ $ilErr

ilSessionAppointment::$ilErr

Definition at line 17 of file class.ilSessionAppointment.php.

Referenced by __construct().

◆ $lng

ilSessionAppointment::$lng

Definition at line 20 of file class.ilSessionAppointment.php.

Referenced by __construct(), _appointmentToString(), and _timeToString().

◆ $start

ilSessionAppointment::$start = null
protected

Definition at line 22 of file class.ilSessionAppointment.php.

Referenced by _appointmentToString(), and _timeToString().

◆ $starting_time

ilSessionAppointment::$starting_time = null

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

◆ $tree

ilSessionAppointment::$tree

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