ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilTimingPlaned.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
35{
36 public $ilErr;
37 public $ilDB;
38 public $lng;
39
45 public function __construct($item_id, $a_usr_id)
46 {
47 global $DIC;
48
49 $ilErr = $DIC['ilErr'];
50 $ilDB = $DIC['ilDB'];
51 $lng = $DIC['lng'];
52 $tree = $DIC['tree'];
53
54 $this->ilErr = &$ilErr;
55 $this->db = &$ilDB;
56 $this->lng = &$lng;
57
58 $this->item_id = $item_id;
59 $this->user_id = $a_usr_id;
60
61 $this->__read();
62 }
63
64 public function getUserId()
65 {
66 return $this->user_id;
67 }
68 public function getItemId()
69 {
70 return $this->item_id;
71 }
72
73 public function getPlanedStartingTime()
74 {
75 return $this->start;
76 }
77 public function setPlanedStartingTime($a_time)
78 {
79 $this->start = $a_time;
80 }
81 public function getPlanedEndingTime()
82 {
83 return $this->end;
84 }
85 public function setPlanedEndingTime($a_end)
86 {
87 $this->end = $a_end;
88 }
89
90 public function validate()
91 {
92 include_once './Services/Object/classes/class.ilObjectActivation.php';
93 $item = ilObjectActivation::getItem($this->getItemId());
94 return true;
95 }
96
97 public function update()
98 {
100 $this->create();
101 return true;
102 }
103
104 public function create()
105 {
106 global $DIC;
107
108 $ilDB = $DIC['ilDB'];
109
110 $query = "INSERT INTO crs_timings_planed (item_id,usr_id,planed_start,planed_end) " .
111 "VALUES( " .
112 $ilDB->quote($this->getItemId(), 'integer') . ", " .
113 $ilDB->quote($this->getUserId(), 'integer') . ", " .
114 $ilDB->quote($this->getPlanedStartingTime(), 'integer') . ", " .
115 $ilDB->quote($this->getPlanedEndingTime(), 'integer') . " " .
116 ")";
117 $res = $ilDB->manipulate($query);
118 }
119
120 public function delete()
121 {
122 return ilTimingPlaned::_delete($this->getItemId(), $this->getUserId());
123 }
124
125 public static function _delete($a_item_id, $a_usr_id)
126 {
127 global $DIC;
128
129 $ilDB = $DIC['ilDB'];
130
131 $query = "DELETE FROM crs_timings_planed " .
132 "WHERE item_id = " . $ilDB->quote($a_item_id, 'integer') . " " .
133 "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
134 $res = $ilDB->manipulate($query);
135 }
136
137 // Static
138 public static function _getPlanedTimings($a_usr_id, $a_item_id)
139 {
140 global $DIC;
141
142 $ilDB = $DIC['ilDB'];
143
144 $query = "SELECT * FROM crs_timings_planed " .
145 "WHERE item_id = " . $ilDB->quote($a_item_id, 'integer') . " " .
146 "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
147 $res = $ilDB->query($query);
148 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
149 $data['planed_start'] = $row->planed_start;
150 $data['planed_end'] = $row->planed_end;
151 }
152 return $data ? $data : array();
153 }
154
155
156 public static function _getPlanedTimingsByItem($a_item_id)
157 {
158 global $DIC;
159
160 $ilDB = $DIC['ilDB'];
161
162 $query = "SELECT * FROM crs_timings_planed " .
163 "WHERE item_id = " . $ilDB->quote($a_item_id, 'integer') . " ";
164 $res = $ilDB->query($query);
165 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
166 $data[$row->usr_id]['start'] = $row->planed_start;
167 $data[$row->usr_id]['end'] = $row->planed_end;
168 }
169 return $data ? $data : array();
170 }
171
172 public static function _deleteByItem($a_item_id)
173 {
174 global $DIC;
175
176 $ilDB = $DIC['ilDB'];
177
178 $query = "DELETE FROM crs_timings_planed " .
179 "WHERE item_id = " . $ilDB->quote($a_item_id, 'integer') . " ";
180 $res = $ilDB->manipulate($query);
181 }
182
183 public static function _deleteByUser($a_usr_id)
184 {
185 global $DIC;
186
187 $ilDB = $DIC['ilDB'];
188
189 $query = "DELETE FROM crs_timings_planed " .
190 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
191 $res = $ilDB->manipulate($query);
192 }
193
194 public function __read()
195 {
196 global $DIC;
197
198 $ilDB = $DIC['ilDB'];
199
200 $query = "SELECT * FROM crs_timings_planed " .
201 "WHERE item_id = " . $ilDB->quote($this->getItemId(), 'integer') . " " .
202 "AND usr_id = " . $ilDB->quote($this->getUserId(), 'integer') . " ";
203 $res = $this->db->query($query);
204 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
205 $this->setPlanedStartingTime($row->planed_start);
206 $this->setPlanedEndingTime($row->planed_end);
207 }
208 return true;
209 }
210}
An exception for terminatinating execution or to throw for unit testing.
static getItem($a_ref_id)
Get item data.
class ilTimingPlaned
static _getPlanedTimingsByItem($a_item_id)
static _getPlanedTimings($a_usr_id, $a_item_id)
static _deleteByItem($a_item_id)
static _delete($a_item_id, $a_usr_id)
setPlanedStartingTime($a_time)
__construct($item_id, $a_usr_id)
Constructor.
static _deleteByUser($a_usr_id)
$query
foreach($_POST as $key=> $value) $res
$data
Definition: storeScorm.php:23
$DIC
Definition: xapitoken.php:46