ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjectCustomUserFieldHistory.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
13  private $obj_id = 0;
14  private $user_id = 0;
15  private $update_user = 0;
16  private $editing_time = null;
17 
23  public function __construct($a_obj_id, $a_user_id)
24  {
25  $this->obj_id = $a_obj_id;
26  $this->user_id = $a_user_id;
27  $this->read();
28  }
29 
36  public static function lookupEntriesByObjectId($a_obj_id)
37  {
38  global $ilDB;
39 
40  $query = 'SELECT * FROM obj_user_data_hist '.
41  'WHERE obj_id = '.$ilDB->quote($a_obj_id,'integer');
42  $res = $ilDB->query($query);
43 
44  $users = array();
45  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
46  {
47  $users[$row->usr_id]['update_user'] = $row->update_user;
48  $users[$row->usr_id]['editing_time'] = new ilDateTime($row->editing_time,IL_CAL_DATETIME, ilTimeZone::UTC);
49  }
50  return $users;
51  }
52 
57  public function setUpdateUser($a_id)
58  {
59  $this->update_user = $a_id;
60  }
61 
66  public function getUpdateUser()
67  {
68  return $this->update_user;
69  }
70 
75  public function setEditingTime(ilDateTime $dt)
76  {
77  $this->editing_time = $dt;
78  }
79 
84  public function getEditingTime()
85  {
86  return $this->editing_time;
87  }
88 
92  public function save()
93  {
94  global $ilDB;
95 
96  $this->delete();
97 
98  $query = 'INSERT INTO obj_user_data_hist (obj_id, usr_id, update_user, editing_time) '.
99  'VALUES( '.
100  $ilDB->quote($this->obj_id,'integer').', '.
101  $ilDB->quote($this->user_id,'integer').', '.
102  $ilDB->quote($this->getUpdateUser(),'integer').', '.
103  $ilDB->quote($this->getEditingTime()->get(IL_CAL_DATETIME,'', ilTimeZone::UTC)).' '.
104  ')';
105  $ilDB->manipulate($query);
106  }
107 
111  public function delete()
112  {
113  global $ilDB;
114 
115  $query = 'DELETE FROM obj_user_data_hist '.
116  'WHERE obj_id = '.$ilDB->quote($this->obj_id,'integer').' '.
117  'AND usr_id = '.$ilDB->quote($this->user_id,'integer');
118  $ilDB->manipulate($query);
119  }
120 
125  protected function read()
126  {
127  global $ilDB;
128 
129  $query = 'SELECT * FROM obj_user_data_hist '.
130  'WHERE obj_id = '.$ilDB->quote($this->obj_id,'integer').' '.
131  'AND usr_id = '.$ilDB->quote($this->user_id,'integer');
132  $res = $ilDB->query($query);
133  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
134  {
135  $this->setEditingTime(new ilDateTime($row->editing_time,IL_CAL_DATETIME, ilTimeZone::UTC));
136  $this->setUpdateUser($row->update_user);
137  }
138  }
139 }
140 
141 ?>
const IL_CAL_DATETIME
Editing history for object custom user fields.
setEditingTime(ilDateTime $dt)
Set editing time.
__construct($a_obj_id, $a_user_id)
Constructor.
Date and time handling
Create styles array
The data for the language used.
global $ilDB
static lookupEntriesByObjectId($a_obj_id)
Get entries by obj_id type $ilDB.