ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilErr,$ilDB,$lng,$tree;
48
49 $this->ilErr =&$ilErr;
50 $this->db =&$ilDB;
51 $this->lng =&$lng;
52
53 $this->item_id = $item_id;
54 $this->user_id = $a_usr_id;
55
56 $this->__read();
57 }
58
59 public function getUserId()
60 {
61 return $this->user_id;
62 }
63 public function getItemId()
64 {
65 return $this->item_id;
66 }
67
68 public function getPlanedStartingTime()
69 {
70 return $this->start;
71 }
72 public function setPlanedStartingTime($a_time)
73 {
74 $this->start = $a_time;
75 }
76 public function getPlanedEndingTime()
77 {
78 return $this->end;
79 }
80 public function setPlanedEndingTime($a_end)
81 {
82 $this->end = $a_end;
83 }
84
85 public function validate()
86 {
87 include_once './Services/Object/classes/class.ilObjectActivation.php';
88 $item = ilObjectActivation::getItem($this->getItemId());
89 // #9326
90 if ($this->getPlanedEndingTime() > $item['latest_end']) {
91 return false;
92 }
93 return true;
94 }
95
96 public function update()
97 {
99 $this->create();
100 return true;
101 }
102
103 public function create()
104 {
105 global $ilDB;
106
107 $query = "INSERT INTO crs_timings_planed (item_id,usr_id,planed_start,planed_end) " .
108 "VALUES( " .
109 $ilDB->quote($this->getItemId(), 'integer') . ", " .
110 $ilDB->quote($this->getUserId(), 'integer') . ", " .
111 $ilDB->quote($this->getPlanedStartingTime(), 'integer') . ", " .
112 $ilDB->quote($this->getPlanedEndingTime(), 'integer') . " " .
113 ")";
114 $res = $ilDB->manipulate($query);
115 }
116
117 public function delete()
118 {
119 return ilTimingPlaned::_delete($this->getItemId(), $this->getUserId());
120 }
121
122 public static function _delete($a_item_id, $a_usr_id)
123 {
124 global $ilDB;
125
126 $query = "DELETE FROM crs_timings_planed " .
127 "WHERE item_id = " . $ilDB->quote($a_item_id, 'integer') . " " .
128 "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
129 $res = $ilDB->manipulate($query);
130 }
131
132 // Static
133 public static function _getPlanedTimings($a_usr_id, $a_item_id)
134 {
135 global $ilDB;
136
137 $query = "SELECT * FROM crs_timings_planed " .
138 "WHERE item_id = " . $ilDB->quote($a_item_id, 'integer') . " " .
139 "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
140 $res = $ilDB->query($query);
141 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
142 $data['planed_start'] = $row->planed_start;
143 $data['planed_end'] = $row->planed_end;
144 }
145 return $data ? $data : array();
146 }
147
148
149 public static function _getPlanedTimingsByItem($a_item_id)
150 {
151 global $ilDB;
152
153 $query = "SELECT * FROM crs_timings_planed " .
154 "WHERE item_id = " . $ilDB->quote($a_item_id, 'integer') . " ";
155 $res = $ilDB->query($query);
156 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
157 $data[$row->usr_id]['start'] = $row->planed_start;
158 $data[$row->usr_id]['end'] = $row->planed_end;
159 }
160 return $data ? $data : array();
161 }
162
163 public static function _deleteByItem($a_item_id)
164 {
165 global $ilDB;
166
167 $query = "DELETE FROM crs_timings_planed " .
168 "WHERE item_id = " . $ilDB->quote($a_item_id, 'integer') . " ";
169 $res = $ilDB->manipulate($query);
170 }
171
172 public static function _deleteByUser($a_usr_id)
173 {
174 global $ilDB;
175
176 $query = "DELETE FROM crs_timings_planed " .
177 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
178 $res = $ilDB->manipulate($query);
179 }
180
181 public function __read()
182 {
183 global $ilDB;
184
185 $query = "SELECT * FROM crs_timings_planed " .
186 "WHERE item_id = " . $ilDB->quote($this->getItemId(), 'integer') . " " .
187 "AND usr_id = " . $ilDB->quote($this->getUserId(), 'integer') . " ";
188 $res = $this->db->query($query);
189 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
190 $this->setPlanedStartingTime($row->planed_start);
191 $this->setPlanedEndingTime($row->planed_end);
192 }
193 return true;
194 }
195}
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)
$end
Definition: saml1-acs.php:18
$query
foreach($_POST as $key=> $value) $res