ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 

Static Public Member Functions

static _lookupAppointment ($a_obj_id)
 lookup appointment More...
 
static lookupNextSessionByCourse ($a_ref_id)
 public More...
 
static lookupLastSessionByCourse ($a_ref_id)
 public More...
 
static _appointmentToString ($start, $end, $fulltime)
 
static _delete ($a_appointment_id)
 
static _deleteBySession ($a_event_id)
 
static _readAppointmentsBySession ($a_event_id)
 

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.

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

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  }
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilSessionAppointment::__read ( )

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

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

Referenced by __construct().

429  {
430  global $ilDB;
431 
432  if(!$this->getAppointmentId())
433  {
434  return null;
435  }
436 
437  $query = "SELECT * FROM event_appointment ".
438  "WHERE appointment_id = ".$ilDB->quote($this->getAppointmentId() ,'integer')." ";
439  $res = $this->db->query($query);
440  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
441  {
442  $this->setSessionId($row->event_id);
443  $this->toggleFullTime($row->fulltime);
444 
445  if($this->isFullday())
446  {
447  $this->start = new ilDate($row->e_start,IL_CAL_DATETIME);
448  $this->end = new ilDate($row->e_end,IL_CAL_DATETIME);
449  }
450  else
451  {
452  $this->start = new ilDateTime($row->e_start,IL_CAL_DATETIME,'UTC');
453  $this->end = new ilDateTime($row->e_end,IL_CAL_DATETIME,'UTC');
454  }
455  $this->starting_time = $this->start->getUnixTime();
456  $this->ending_time = $this->end->getUnixTime();
457  }
458  return true;
459  }
const IL_CAL_DATETIME
Class for single dates.
Date and time handling
+ 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 291 of file class.ilSessionAppointment.php.

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().

292  {
293  global $lng;
294 
295  if($fulltime)
296  {
299  #new ilDate($end,IL_CAL_UNIX)).' ('.$lng->txt('event_full_time_info').')';
300  new ilDate($end,IL_CAL_UNIX));
301  }
302  else
303  {
307  }
308  }
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
const IL_CAL_UNIX
Class for single dates.
Date and time handling
+ 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 379 of file class.ilSessionAppointment.php.

References $ilDB, $query, and $res.

Referenced by delete().

380  {
381  global $ilDB;
382 
383  $query = "DELETE FROM event_appointment ".
384  "WHERE appointment_id = ".$ilDB->quote($a_appointment_id ,'integer')." ";
385  $res = $ilDB->manipulate($query);
386 
387  return true;
388  }
+ Here is the caller graph for this function:

◆ _deleteBySession()

static ilSessionAppointment::_deleteBySession (   $a_event_id)
static

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

References $ilDB, $query, and $res.

Referenced by ilObjSession\delete().

391  {
392  global $ilDB;
393 
394  $query = "DELETE FROM event_appointment ".
395  "WHERE event_id = ".$ilDB->quote($a_event_id ,'integer')." ";
396  $res = $ilDB->manipulate($query);
397 
398  return true;
399  }
+ Here is the caller graph for this function:

◆ _lookupAppointment()

static ilSessionAppointment::_lookupAppointment (   $a_obj_id)
static

lookup appointment

public

Parameters
intobj_id

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

References $ilDB, $info, $query, $res, $row, array, 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().

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  {
60  $info['fullday'] = $row->fulltime;
61 
62  $date = new ilDateTime($row->e_start,IL_CAL_DATETIME,'UTC');
63  $info['start'] = $date->getUnixTime();
64  $date = new ilDateTime($row->e_end,IL_CAL_DATETIME,'UTC');
65  $info['end'] = $date->getUnixTime();
66 
67  return $info;
68  }
69  return array();
70  }
const IL_CAL_DATETIME
$info
Definition: example_052.php:80
Date and time handling
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ _readAppointmentsBySession()

static ilSessionAppointment::_readAppointmentsBySession (   $a_event_id)
static

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

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

Referenced by ilObjSession\initAppointments().

402  {
403  global $ilDB;
404 
405  $query = "SELECT * FROM event_appointment ".
406  "WHERE event_id = ".$ilDB->quote($a_event_id ,'integer')." ".
407  "ORDER BY starting_time";
408 
409  $res = $ilDB->query($query);
410  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
411  {
412  $appointments[] = new ilSessionAppointment($row->appointment_id);
413  }
414  return is_array($appointments) ? $appointments : array();
415  }
Create styles array
The data for the language used.
class ilSessionAppointment
+ Here is the caller graph for this function:

◆ _timeToString()

ilSessionAppointment::_timeToString (   $start,
  $end 
)

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

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

Referenced by formatTime().

282  {
283  global $ilUser,$lng;
284 
285  $start = date($this->lng->txt('lang_timeformat_no_sec'),$start);
286  $end = date($this->lng->txt('lang_timeformat_no_sec'),$end);
287 
288  return $start.' - '. $end;
289  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$ilUser
Definition: imgupload.php:18
+ Here is the caller graph for this function:

◆ appointmentToString()

ilSessionAppointment::appointmentToString ( )

◆ cloneObject()

ilSessionAppointment::cloneObject (   $new_id)

clone appointment

public

Parameters

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

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

323  {
324  $new_app = new ilSessionAppointment();
325  $new_app->setSessionId($new_id);
326  $new_app->setStartingTime($this->getStartingTime());
327  $new_app->setEndingTime($this->getEndingTime());
328  $new_app->toggleFullTime($this->isFullday());
329  $new_app->create();
330  return $new_app;
331  }
class ilSessionAppointment
+ Here is the call graph for this function:

◆ create()

ilSessionAppointment::create ( )

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

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

334  {
335  global $ilDB;
336 
337  if(!$this->getSessionId())
338  {
339  return false;
340  }
341  $next_id = $ilDB->nextId('event_appointment');
342  $query = "INSERT INTO event_appointment (appointment_id,event_id,e_start,e_end,fulltime) ".
343  "VALUES( ".
344  $ilDB->quote($next_id,'integer').", ".
345  $ilDB->quote($this->getSessionId() ,'integer').", ".
346  $ilDB->quote($this->getStart()->get(IL_CAL_DATETIME,'','UTC') ,'timestamp').", ".
347  $ilDB->quote($this->getEnd()->get(IL_CAL_DATETIME,'','UTC') ,'timestamp').", ".
348  $ilDB->quote($this->enabledFullTime() ,'integer')." ".
349  ")";
350  $this->appointment_id = $next_id;
351  $res = $ilDB->manipulate($query);
352 
353  return true;
354  }
const IL_CAL_DATETIME
+ Here is the call graph for this function:

◆ delete()

ilSessionAppointment::delete ( )

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

References _delete(), and getAppointmentId().

375  {
377  }
static _delete($a_appointment_id)
+ Here is the call graph for this function:

◆ enabledFullTime()

ilSessionAppointment::enabledFullTime ( )

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

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

272  {
273  return $this->fulltime;
274  }
+ Here is the caller graph for this function:

◆ formatTime()

ilSessionAppointment::formatTime ( )

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

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

+ Here is the call graph for this function:

◆ getAppointmentId()

ilSessionAppointment::getAppointmentId ( )

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

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

233  {
234  return $this->appointment_id;
235  }
+ Here is the caller graph for this function:

◆ getEnd()

ilSessionAppointment::getEnd ( )

get end

public

Returns
ilDateTime

Implements ilDatePeriod.

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

References date, and IL_CAL_DATETIME.

Referenced by create(), and update().

212  {
213  return $this->end ? $this->end : $this->end = new ilDateTime(date('Y-m-d').' 16:00:00',IL_CAL_DATETIME);
214  }
const IL_CAL_DATETIME
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Date and time handling
+ Here is the caller graph for this function:

◆ getEndingTime()

ilSessionAppointment::getEndingTime ( )

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

References date, and time.

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

263  {
264  return isset($this->ending_time) ? $this->ending_time : mktime(16,0,0,date('n',time()),date('d',time()),date('Y',time()));
265  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ getSessionId()

ilSessionAppointment::getSessionId ( )

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

Referenced by create(), and update().

242  {
243  return $this->session_id;
244  }
+ Here is the caller graph for this function:

◆ getStart()

ilSessionAppointment::getStart ( )

get start

public

Parameters

Implements ilDatePeriod.

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

References date, and IL_CAL_DATETIME.

Referenced by create(), and update().

190  {
191  return $this->start ? $this->start : $this->start = new ilDateTime(date('Y-m-d').' 08:00:00',IL_CAL_DATETIME);
192  }
const IL_CAL_DATETIME
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Date and time handling
+ Here is the caller graph for this function:

◆ getStartingTime()

ilSessionAppointment::getStartingTime ( )

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

References date, and time.

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

253  {
254  return isset($this->starting_time) ? $this->starting_time : mktime(8,0,0,date('n',time()),date('d',time()),date('Y',time()));
255  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ isFullday()

ilSessionAppointment::isFullday ( )

is fullday

public

Parameters

Implements ilDatePeriod.

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

References enabledFullTime().

Referenced by __read(), and cloneObject().

178  {
179  return $this->enabledFullTime();
180  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupLastSessionByCourse()

static ilSessionAppointment::lookupLastSessionByCourse (   $a_ref_id)
static

public

Parameters

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

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

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

143  {
144  global $tree,$ilDB;
145 
146  $sessions = $tree->getChildsByType($a_ref_id,'sess');
147  $obj_ids = array();
148  foreach($sessions as $tree_data)
149  {
150  $obj_ids[] = $tree_data['obj_id'];
151  }
152  if(!count($obj_ids))
153  {
154  return false;
155  }
156  $query = "SELECT event_id FROM event_appointment ".
157  "WHERE e_start < ".$ilDB->now()." ".
158  "AND ".$ilDB->in('event_id',$obj_ids,false,'integer')." ".
159  "ORDER BY e_start DESC ";
160  $ilDB->setLimit(1);
161  $res = $ilDB->query($query);
162  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
163  {
164  $event_id = $row->event_id;
165  }
166  return isset($event_id) ? $event_id : 0;
167  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ lookupNextSessionByCourse()

static ilSessionAppointment::lookupNextSessionByCourse (   $a_ref_id)
static

public

Parameters

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

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

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

81  {
82  global $tree,$ilDB;
83 
84 
85  $sessions = $tree->getChildsByType($a_ref_id,'sess');
86  $obj_ids = array();
87  foreach($sessions as $tree_data)
88  {
89  $obj_ids[] = $tree_data['obj_id'];
90  }
91  if(!count($obj_ids))
92  {
93  return false;
94  }
95 
96  // Try to read the next sessions within the next 24 hours
97  $now = new ilDate(time(),IL_CAL_UNIX);
98  $tomorrow = clone $now;
99  $tomorrow->increment(IL_CAL_DAY,2);
100 
101  $query = "SELECT event_id FROM event_appointment ".
102  "WHERE e_start > ".$ilDB->quote($now->get(IL_CAL_DATE,'timestamp')).' '.
103  "AND e_start < ".$ilDB->quote($tomorrow->get(IL_CAL_DATE,'timestamp')).' '.
104  "AND ".$ilDB->in('event_id',$obj_ids,false,'integer').' '.
105  "ORDER BY e_start ";
106 
107  $event_ids = array();
108 
109  $res = $ilDB->query($query);
110  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
111  {
112  $event_ids[] = $row->event_id;
113  }
114 
115  if(count($event_ids))
116  {
117  return $event_ids;
118  }
119 
120  // Alternativ: get next event.
121  $query = "SELECT event_id FROM event_appointment ".
122  "WHERE e_start > ".$ilDB->now()." ".
123  "AND ".$ilDB->in('event_id',$obj_ids,false,'integer')." ".
124  "ORDER BY e_start ";
125  $ilDB->setLimit(1);
126  $res = $ilDB->query($query);
127  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
128  {
129  $event_id = $row->event_id;
130  }
131  return isset($event_id) ? array($event_id) : array();
132  }
const IL_CAL_UNIX
const IL_CAL_DAY
Class for single dates.
Create styles array
The data for the language used.
const IL_CAL_DATE
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ setAppointmentId()

ilSessionAppointment::setAppointmentId (   $a_appointment_id)

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

229  {
230  $this->appointment_id = $a_appointment_id;
231  }

◆ setEnd()

ilSessionAppointment::setEnd (   $a_end)

set end

public

Parameters
object$dateilDateTime
Returns

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

224  {
225  $this->end = $a_end;
226  }

◆ setEndingTime()

ilSessionAppointment::setEndingTime (   $a_ending_time)

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

References IL_CAL_UNIX.

258  {
259  $this->ending_time = $a_ending_time;
260  $this->end = new ilDateTime($this->ending_time,IL_CAL_UNIX);
261  }
const IL_CAL_UNIX
Date and time handling

◆ setSessionId()

ilSessionAppointment::setSessionId (   $a_session_id)

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

Referenced by __read().

238  {
239  $this->session_id = $a_session_id;
240  }
+ Here is the caller graph for this function:

◆ setStart()

ilSessionAppointment::setStart (   $a_start)

set start

public

Parameters
object$datailDateTime

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

201  {
202  $this->start = $a_start;
203  }

◆ setStartingTime()

ilSessionAppointment::setStartingTime (   $a_starting_time)

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

References IL_CAL_UNIX.

247  {
248  $this->starting_time = $a_starting_time;
249  $this->start = new ilDateTime($this->starting_time,IL_CAL_UNIX);
250 
251  }
const IL_CAL_UNIX
Date and time handling

◆ toggleFullTime()

ilSessionAppointment::toggleFullTime (   $a_status)

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

Referenced by __read().

268  {
269  $this->fulltime = $a_status;
270  }
+ Here is the caller graph for this function:

◆ update()

ilSessionAppointment::update ( )

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

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

357  {
358  global $ilDB;
359 
360  if(!$this->getSessionId())
361  {
362  return false;
363  }
364  $query = "UPDATE event_appointment ".
365  "SET event_id = ".$ilDB->quote($this->getSessionId() ,'integer').", ".
366  "e_start = ".$ilDB->quote($this->getStart()->get(IL_CAL_DATETIME,'','UTC') ,'timestamp').", ".
367  "e_end = ".$ilDB->quote($this->getEnd()->get(IL_CAL_DATETIME,'','UTC'), 'timestamp').", ".
368  "fulltime = ".$ilDB->quote($this->enabledFullTime() ,'integer')." ".
369  "WHERE appointment_id = ".$ilDB->quote($this->getAppointmentId() ,'integer')." ";
370  $res = $ilDB->manipulate($query);
371  return true;
372  }
const IL_CAL_DATETIME
+ Here is the call graph for this function:

◆ validate()

ilSessionAppointment::validate ( )

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

418  {
419  if($this->starting_time > $this->ending_time)
420  {
421  $this->ilErr->appendMessage($this->lng->txt('event_etime_smaller_stime'));
422  return false;
423  }
424  return true;
425  }

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: