ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTimingUser Class Reference

TableGUI class for timings administration. More...

+ Collaboration diagram for ilTimingUser:

Public Member Functions

 __construct ($a_ref_id, $a_usr_id)
 Constructor. More...
 
 getUserId ()
 get user id More...
 
 getRefId ()
 Get ref_id. More...
 
 isScheduled ()
 Check if an entry exists for user. More...
 
 getStart ()
 Use to set start date. More...
 
 getEnd ()
 Use to set date. More...
 
 create ()
 Create new entry. More...
 
 update ()
 Update type $ilDB. More...
 
 delete ()
 Delete entry type $ilDB. More...
 
 read ()
 Read from db. More...
 

Private Attributes

 $ref_id = 0
 
 $usr_id = 0
 
 $start = null
 
 $end = null
 
 $is_scheduled = false
 

Detailed Description

TableGUI class for timings administration.

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

Definition at line 12 of file class.ilTimingUser.php.

Constructor & Destructor Documentation

◆ __construct()

ilTimingUser::__construct (   $a_ref_id,
  $a_usr_id 
)

Constructor.

Parameters
type$a_ref_id
type$a_usr_id

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

References IL_CAL_UNIX, and read().

27  {
28  $this->ref_id = $a_ref_id;
29  $this->usr_id = $a_usr_id;
30 
31  $this->start = new ilDateTime(0, IL_CAL_UNIX);
32  $this->end = new ilDateTime(0, IL_CAL_UNIX);
33 
34  $this->read();
35  }
const IL_CAL_UNIX
read()
Read from db.
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilTimingUser::create ( )

Create new entry.

Definition at line 84 of file class.ilTimingUser.php.

References $DIC, $ilDB, $query, getEnd(), getRefId(), getStart(), getUserId(), IL_CAL_UNIX, isScheduled(), and update().

Referenced by update().

85  {
86  global $DIC;
87 
88  $ilDB = $DIC->database();
89 
90  if ($this->isScheduled()) {
91  return $this->update();
92  }
93 
94  $query = 'INSERT INTO crs_timings_user (ref_id, usr_id, sstart, ssend ) VALUES ( ' .
95  $ilDB->quote($this->getRefId(), 'integer') . ', ' .
96  $ilDB->quote($this->getUserId(), 'integer') . ', ' .
97  $ilDB->quote($this->getStart()->get(IL_CAL_UNIX, 'integer')) . ', ' .
98  $ilDB->quote($this->getEnd()->get(IL_CAL_UNIX, 'integer')) . ' ' .
99  ')';
100  $ilDB->manipulate($query);
101 
102  $this->is_scheduled = true;
103  }
isScheduled()
Check if an entry exists for user.
getStart()
Use to set start date.
const IL_CAL_UNIX
getUserId()
get user id
$query
getEnd()
Use to set date.
global $ilDB
$DIC
Definition: xapitoken.php:46
update()
Update type $ilDB.
getRefId()
Get ref_id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilTimingUser::delete ( )

Delete entry type $ilDB.

Definition at line 131 of file class.ilTimingUser.php.

References $DIC, $ilDB, $query, getRefId(), and getUserId().

132  {
133  global $DIC;
134 
135  $ilDB = $DIC->database();
136 
137  $query = 'DELETE FROM crs_timings_user ' . ' ' .
138  'WHERE ref_id = ' . $ilDB->quote($this->getRefId(), 'integer') . ' ' .
139  'AND usr_id = ' . $ilDB->quote($this->getUserId(), 'integer');
140  $ilDB->manipulate($query);
141 
142  $this->is_scheduled = false;
143  }
getUserId()
get user id
$query
global $ilDB
$DIC
Definition: xapitoken.php:46
getRefId()
Get ref_id.
+ Here is the call graph for this function:

◆ getEnd()

ilTimingUser::getEnd ( )

Use to set date.

Returns
ilDateTime

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

References $end.

Referenced by create(), and update().

77  {
78  return $this->end;
79  }
+ Here is the caller graph for this function:

◆ getRefId()

ilTimingUser::getRefId ( )

Get ref_id.

Returns
type

Definition at line 50 of file class.ilTimingUser.php.

References $ref_id.

Referenced by create(), delete(), read(), and update().

51  {
52  return $this->ref_id;
53  }
+ Here is the caller graph for this function:

◆ getStart()

ilTimingUser::getStart ( )

Use to set start date.

Returns
ilDateTime

Definition at line 67 of file class.ilTimingUser.php.

References $start.

Referenced by ilObjectActivation\addAdditionalSubItemInformation(), create(), and update().

68  {
69  return $this->start;
70  }
+ Here is the caller graph for this function:

◆ getUserId()

ilTimingUser::getUserId ( )

get user id

Returns
type

Definition at line 41 of file class.ilTimingUser.php.

References $usr_id.

Referenced by create(), delete(), read(), and update().

42  {
43  return $this->usr_id;
44  }
+ Here is the caller graph for this function:

◆ isScheduled()

ilTimingUser::isScheduled ( )

Check if an entry exists for user.

Definition at line 58 of file class.ilTimingUser.php.

References $is_scheduled.

Referenced by create(), read(), and update().

59  {
60  return $this->is_scheduled;
61  }
+ Here is the caller graph for this function:

◆ read()

ilTimingUser::read ( )

Read from db.

Definition at line 150 of file class.ilTimingUser.php.

References $DIC, $ilDB, $query, $res, ilDBConstants\FETCHMODE_OBJECT, getRefId(), getUserId(), IL_CAL_UNIX, and isScheduled().

Referenced by __construct().

151  {
152  global $DIC;
153 
154  $ilDB = $DIC->database();
155 
156  $query = 'SELECT * FROM crs_timings_user ' .
157  'WHERE ref_id = ' . $ilDB->quote($this->getRefId(), 'integer') . ' ' .
158  'AND usr_id = ' . $ilDB->quote($this->getUserId(), 'integer');
159  $res = $ilDB->query($query);
160  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
161  $this->is_scheduled = true;
162  $this->start = new ilDateTime($row->sstart, IL_CAL_UNIX);
163  $this->end = new ilDateTime($row->ssend, IL_CAL_UNIX);
164  }
165  return $this->isScheduled();
166  }
isScheduled()
Check if an entry exists for user.
const IL_CAL_UNIX
getUserId()
get user id
foreach($_POST as $key=> $value) $res
$query
global $ilDB
$DIC
Definition: xapitoken.php:46
getRefId()
Get ref_id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilTimingUser::update ( )

Update type $ilDB.

Definition at line 109 of file class.ilTimingUser.php.

References $DIC, $ilDB, $query, create(), getEnd(), getRefId(), getStart(), getUserId(), IL_CAL_UNIX, and isScheduled().

Referenced by create().

110  {
111  global $DIC;
112 
113  $ilDB = $DIC->database();
114 
115  if (!$this->isScheduled()) {
116  return $this->create();
117  }
118 
119  $query = 'UPDATE crs_timings_user ' .
120  'SET sstart = ' . $ilDB->quote($this->getStart()->get(IL_CAL_UNIX, 'integer')) . ', ' .
121  'ssend = ' . $ilDB->quote($this->getEnd()->get(IL_CAL_UNIX, 'integer')) . ' ' .
122  'WHERE ref_id = ' . $ilDB->quote($this->getRefId(), 'integer') . ' ' .
123  'AND usr_id = ' . $ilDB->quote($this->getUserId(), 'integer');
124  $ilDB->manipulate($query);
125  }
isScheduled()
Check if an entry exists for user.
getStart()
Use to set start date.
const IL_CAL_UNIX
getUserId()
get user id
create()
Create new entry.
$query
getEnd()
Use to set date.
global $ilDB
$DIC
Definition: xapitoken.php:46
getRefId()
Get ref_id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $end

ilTimingUser::$end = null
private

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

Referenced by getEnd().

◆ $is_scheduled

ilTimingUser::$is_scheduled = false
private

Definition at line 19 of file class.ilTimingUser.php.

Referenced by isScheduled().

◆ $ref_id

ilTimingUser::$ref_id = 0
private

Definition at line 14 of file class.ilTimingUser.php.

Referenced by getRefId().

◆ $start

ilTimingUser::$start = null
private

Definition at line 16 of file class.ilTimingUser.php.

Referenced by getStart().

◆ $usr_id

ilTimingUser::$usr_id = 0
private

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

Referenced by getUserId().


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