ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSessionAppointment Class Reference

class ilSessionAppointment More...

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

Public Member Functions

 ilSessionAppointment ($a_appointment_id=null)
 
 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 ()
 
 _delete ($a_appointment_id)
 
 _deleteBySession ($a_event_id)
 
 _readAppointmentsBySession ($a_event_id)
 
 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)
 

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.

Member Function Documentation

◆ __read()

ilSessionAppointment::__read ( )

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

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

Referenced by ilSessionAppointment().

425  {
426  global $ilDB;
427 
428  if(!$this->getAppointmentId())
429  {
430  return null;
431  }
432 
433  $query = "SELECT * FROM event_appointment ".
434  "WHERE appointment_id = ".$ilDB->quote($this->getAppointmentId() ,'integer')." ";
435  $res = $this->db->query($query);
436  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
437  {
438  $this->setSessionId($row->event_id);
439  $this->toggleFullTime($row->fulltime);
440 
441  if($this->isFullday())
442  {
443  $this->start = new ilDate($row->e_start,IL_CAL_DATETIME);
444  $this->end = new ilDate($row->e_end,IL_CAL_DATETIME);
445  }
446  else
447  {
448  $this->start = new ilDateTime($row->e_start,IL_CAL_DATETIME,'UTC');
449  $this->end = new ilDateTime($row->e_end,IL_CAL_DATETIME,'UTC');
450  }
451  $this->starting_time = $this->start->getUnixTime();
452  $this->ending_time = $this->end->getUnixTime();
453  }
454  return true;
455  }
const IL_CAL_DATETIME
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
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 287 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().

288  {
289  global $lng;
290 
291  if($fulltime)
292  {
295  #new ilDate($end,IL_CAL_UNIX)).' ('.$lng->txt('event_full_time_info').')';
296  new ilDate($end,IL_CAL_UNIX));
297  }
298  else
299  {
303  }
304  }
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()

ilSessionAppointment::_delete (   $a_appointment_id)

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

References $ilDB, $query, and $res.

Referenced by delete().

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

◆ _deleteBySession()

ilSessionAppointment::_deleteBySession (   $a_event_id)

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

References $ilDB, $query, and $res.

Referenced by ilObjSession\delete().

387  {
388  global $ilDB;
389 
390  $query = "DELETE FROM event_appointment ".
391  "WHERE event_id = ".$ilDB->quote($a_event_id ,'integer')." ";
392  $res = $ilDB->manipulate($query);
393 
394  return true;
395  }
+ 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 47 of file class.ilSessionAppointment.php.

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

48  {
49  global $ilDB;
50 
51  $query = "SELECT * FROM event_appointment ".
52  "WHERE event_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
53  $res = $ilDB->query($query);
54  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
55  {
56  $info['fullday'] = $row->fulltime;
57 
58  $date = new ilDateTime($row->e_start,IL_CAL_DATETIME,'UTC');
59  $info['start'] = $date->getUnixTime();
60  $date = new ilDateTime($row->e_end,IL_CAL_DATETIME,'UTC');
61  $info['end'] = $date->getUnixTime();
62 
63  return $info;
64  }
65  return array();
66  }
const IL_CAL_DATETIME
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
Date and time handling
+ Here is the caller graph for this function:

◆ _readAppointmentsBySession()

ilSessionAppointment::_readAppointmentsBySession (   $a_event_id)

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

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, and ilSessionAppointment().

Referenced by ilObjSession\initAppointments().

398  {
399  global $ilDB;
400 
401  $query = "SELECT * FROM event_appointment ".
402  "WHERE event_id = ".$ilDB->quote($a_event_id ,'integer')." ".
403  "ORDER BY starting_time";
404 
405  $res = $ilDB->query($query);
406  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
407  {
408  $appointments[] =& new ilSessionAppointment($row->appointment_id);
409  }
410  return is_array($appointments) ? $appointments : array();
411  }
ilSessionAppointment($a_appointment_id=null)
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _timeToString()

ilSessionAppointment::_timeToString (   $start,
  $end 
)

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

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

Referenced by formatTime().

278  {
279  global $ilUser,$lng;
280 
281  $start = date($this->lng->txt('lang_timeformat_no_sec'),$start);
282  $end = date($this->lng->txt('lang_timeformat_no_sec'),$end);
283 
284  return $start.' - '. $end;
285  }
global $ilUser
Definition: imgupload.php:15
+ Here is the caller graph for this function:

◆ appointmentToString()

ilSessionAppointment::appointmentToString ( )

◆ cloneObject()

ilSessionAppointment::cloneObject (   $new_id)

clone appointment

public

Parameters

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

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

319  {
320  $new_app = new ilSessionAppointment();
321  $new_app->setSessionId($new_id);
322  $new_app->setStartingTime($this->getStartingTime());
323  $new_app->setEndingTime($this->getEndingTime());
324  $new_app->toggleFullTime($this->isFullday());
325  $new_app->create();
326  return $new_app;
327  }
ilSessionAppointment($a_appointment_id=null)
+ Here is the call graph for this function:

◆ create()

ilSessionAppointment::create ( )

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

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

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

◆ delete()

ilSessionAppointment::delete ( )

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

References _delete(), and getAppointmentId().

+ Here is the call graph for this function:

◆ enabledFullTime()

ilSessionAppointment::enabledFullTime ( )

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

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

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

◆ formatTime()

ilSessionAppointment::formatTime ( )

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

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

+ Here is the call graph for this function:

◆ getAppointmentId()

ilSessionAppointment::getAppointmentId ( )

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

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

229  {
230  return $this->appointment_id;
231  }
+ Here is the caller graph for this function:

◆ getEnd()

ilSessionAppointment::getEnd ( )

get end

public

Returns
ilDateTime

Implements ilDatePeriod.

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

References IL_CAL_DATETIME.

Referenced by create(), and update().

208  {
209  return $this->end ? $this->end : $this->end = new ilDateTime(date('Y-m-d').' 16:00:00',IL_CAL_DATETIME);
210  }
const IL_CAL_DATETIME
Date and time handling
+ Here is the caller graph for this function:

◆ getEndingTime()

ilSessionAppointment::getEndingTime ( )

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

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

259  {
260  return isset($this->ending_time) ? $this->ending_time : mktime(16,0,0,date('n',time()),date('d',time()),date('Y',time()));
261  }
+ Here is the caller graph for this function:

◆ getSessionId()

ilSessionAppointment::getSessionId ( )

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

Referenced by create(), and update().

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

◆ getStart()

ilSessionAppointment::getStart ( )

get start

public

Parameters

Implements ilDatePeriod.

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

References IL_CAL_DATETIME.

Referenced by create(), and update().

186  {
187  return $this->start ? $this->start : $this->start = new ilDateTime(date('Y-m-d').' 08:00:00',IL_CAL_DATETIME);
188  }
const IL_CAL_DATETIME
Date and time handling
+ Here is the caller graph for this function:

◆ getStartingTime()

ilSessionAppointment::getStartingTime ( )

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

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

249  {
250  return isset($this->starting_time) ? $this->starting_time : mktime(8,0,0,date('n',time()),date('d',time()),date('Y',time()));
251  }
+ Here is the caller graph for this function:

◆ ilSessionAppointment()

ilSessionAppointment::ilSessionAppointment (   $a_appointment_id = null)

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

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

Referenced by _readAppointmentsBySession(), and cloneObject().

29  {
30  global $ilErr,$ilDB,$lng,$tree;
31 
32  $this->ilErr =& $ilErr;
33  $this->db =& $ilDB;
34  $this->lng =& $lng;
35 
36  $this->appointment_id = $a_appointment_id;
37  $this->__read();
38  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFullday()

ilSessionAppointment::isFullday ( )

is fullday

public

Parameters

Implements ilDatePeriod.

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

References enabledFullTime().

Referenced by __read(), and cloneObject().

174  {
175  return $this->enabledFullTime();
176  }
+ 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 138 of file class.ilSessionAppointment.php.

References $ilDB, $query, $res, $row, $tree, and DB_FETCHMODE_OBJECT.

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

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

◆ lookupNextSessionByCourse()

static ilSessionAppointment::lookupNextSessionByCourse (   $a_ref_id)
static

public

Parameters

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

References $ilDB, $query, $res, $row, $tree, DB_FETCHMODE_OBJECT, IL_CAL_DATE, IL_CAL_DAY, and IL_CAL_UNIX.

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

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

◆ setAppointmentId()

ilSessionAppointment::setAppointmentId (   $a_appointment_id)

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

225  {
226  $this->appointment_id = $a_appointment_id;
227  }

◆ setEnd()

ilSessionAppointment::setEnd (   $a_end)

set end

public

Parameters
object$dateilDateTime
Returns

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

220  {
221  $this->end = $a_end;
222  }

◆ setEndingTime()

ilSessionAppointment::setEndingTime (   $a_ending_time)

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

References IL_CAL_UNIX.

254  {
255  $this->ending_time = $a_ending_time;
256  $this->end = new ilDateTime($this->ending_time,IL_CAL_UNIX);
257  }
const IL_CAL_UNIX
Date and time handling

◆ setSessionId()

ilSessionAppointment::setSessionId (   $a_session_id)

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

Referenced by __read().

234  {
235  $this->session_id = $a_session_id;
236  }
+ Here is the caller graph for this function:

◆ setStart()

ilSessionAppointment::setStart (   $a_start)

set start

public

Parameters
object$datailDateTime

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

197  {
198  $this->start = $a_start;
199  }

◆ setStartingTime()

ilSessionAppointment::setStartingTime (   $a_starting_time)

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

References IL_CAL_UNIX.

243  {
244  $this->starting_time = $a_starting_time;
245  $this->start = new ilDateTime($this->starting_time,IL_CAL_UNIX);
246 
247  }
const IL_CAL_UNIX
Date and time handling

◆ toggleFullTime()

ilSessionAppointment::toggleFullTime (   $a_status)

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

Referenced by __read().

264  {
265  $this->fulltime = $a_status;
266  }
+ Here is the caller graph for this function:

◆ update()

ilSessionAppointment::update ( )

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

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

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

◆ validate()

ilSessionAppointment::validate ( )

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

414  {
415  if($this->starting_time > $this->ending_time)
416  {
417  $this->ilErr->appendMessage($this->lng->txt('event_etime_smaller_stime'));
418  return false;
419  }
420  return true;
421  }

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

◆ $lng

ilSessionAppointment::$lng

◆ $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: