ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $users[$row->usr_id]['update_user'] = $row->update_user;
47 $users[$row->usr_id]['editing_time'] = new ilDateTime($row->editing_time, IL_CAL_DATETIME, ilTimeZone::UTC);
48 }
49 return $users;
50 }
51
56 public function setUpdateUser($a_id)
57 {
58 $this->update_user = $a_id;
59 }
60
65 public function getUpdateUser()
66 {
67 return $this->update_user;
68 }
69
74 public function setEditingTime(ilDateTime $dt)
75 {
76 $this->editing_time = $dt;
77 }
78
83 public function getEditingTime()
84 {
86 }
87
91 public function save()
92 {
93 global $ilDB;
94
95 $this->delete();
96
97 $query = 'INSERT INTO obj_user_data_hist (obj_id, usr_id, update_user, editing_time) ' .
98 'VALUES( ' .
99 $ilDB->quote($this->obj_id, 'integer') . ', ' .
100 $ilDB->quote($this->user_id, 'integer') . ', ' .
101 $ilDB->quote($this->getUpdateUser(), 'integer') . ', ' .
102 $ilDB->quote($this->getEditingTime()->get(IL_CAL_DATETIME, '', ilTimeZone::UTC)) . ' ' .
103 ')';
104 $ilDB->manipulate($query);
105 }
106
110 public function delete()
111 {
112 global $ilDB;
113
114 $query = 'DELETE FROM obj_user_data_hist ' .
115 'WHERE obj_id = ' . $ilDB->quote($this->obj_id, 'integer') . ' ' .
116 'AND usr_id = ' . $ilDB->quote($this->user_id, 'integer');
117 $ilDB->manipulate($query);
118 }
119
124 protected function read()
125 {
126 global $ilDB;
127
128 $query = 'SELECT * FROM obj_user_data_hist ' .
129 'WHERE obj_id = ' . $ilDB->quote($this->obj_id, 'integer') . ' ' .
130 'AND usr_id = ' . $ilDB->quote($this->user_id, 'integer');
131 $res = $ilDB->query($query);
132 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
133 $this->setEditingTime(new ilDateTime($row->editing_time, IL_CAL_DATETIME, ilTimeZone::UTC));
134 $this->setUpdateUser($row->update_user);
135 }
136 }
137}
$users
Definition: authpage.php:44
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
@classDescription Date and time handling
Editing history for object custom user fields.
static lookupEntriesByObjectId($a_obj_id)
Get entries by obj_id @global type $ilDB.
__construct($a_obj_id, $a_user_id)
Constructor.
setEditingTime(ilDateTime $dt)
Set editing time.
$query
foreach($_POST as $key=> $value) $res
global $ilDB