ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  var $ilErr;
37  var $ilDB;
38  var $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  function getUserId()
60  {
61  return $this->user_id;
62  }
63  function getItemId()
64  {
65  return $this->item_id;
66  }
67 
69  {
70  return $this->start;
71  }
72  function setPlanedStartingTime($a_time)
73  {
74  $this->start = $a_time;
75  }
77  {
78  return $this->end;
79  }
80  function setPlanedEndingTime($a_end)
81  {
82  $this->end = $a_end;
83  }
84 
85  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  {
92  return false;
93  }
94  return true;
95  }
96 
97  function update()
98  {
99  ilTimingPlaned::_delete($this->getItemId(),$this->getUserId());
100  $this->create();
101  return true;
102  }
103 
104  function create()
105  {
106  global $ilDB;
107 
108  $query = "INSERT INTO crs_timings_planed (item_id,usr_id,planed_start,planed_end) ".
109  "VALUES( ".
110  $ilDB->quote($this->getItemId() ,'integer').", ".
111  $ilDB->quote($this->getUserId() ,'integer').", ".
112  $ilDB->quote($this->getPlanedStartingTime() ,'integer').", ".
113  $ilDB->quote($this->getPlanedEndingTime() ,'integer')." ".
114  ")";
115  $res = $ilDB->manipulate($query);
116  }
117 
118  function delete()
119  {
120  return ilTimingPlaned::_delete($this->getItemId(),$this->getUserId());
121  }
122 
123  public static function _delete($a_item_id,$a_usr_id)
124  {
125  global $ilDB;
126 
127  $query = "DELETE FROM crs_timings_planed ".
128  "WHERE item_id = ".$ilDB->quote($a_item_id ,'integer')." ".
129  "AND usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
130  $res = $ilDB->manipulate($query);
131  }
132 
133  // Static
134  public static function _getPlanedTimings($a_usr_id,$a_item_id)
135  {
136  global $ilDB;
137 
138  $query = "SELECT * FROM crs_timings_planed ".
139  "WHERE item_id = ".$ilDB->quote($a_item_id ,'integer')." ".
140  "AND usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
141  $res = $ilDB->query($query);
142  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
143  {
144  $data['planed_start'] = $row->planed_start;
145  $data['planed_end'] = $row->planed_end;
146  }
147  return $data ? $data : array();
148  }
149 
150 
151  static function _getPlanedTimingsByItem($a_item_id)
152  {
153  global $ilDB;
154 
155  $query = "SELECT * FROM crs_timings_planed ".
156  "WHERE item_id = ".$ilDB->quote($a_item_id ,'integer')." ";
157  $res = $ilDB->query($query);
158  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
159  {
160  $data[$row->usr_id]['start'] = $row->planed_start;
161  $data[$row->usr_id]['end'] = $row->planed_end;
162  }
163  return $data ? $data : array();
164  }
165 
166  public static function _deleteByItem($a_item_id)
167  {
168  global $ilDB;
169 
170  $query = "DELETE FROM crs_timings_planed ".
171  "WHERE item_id = ".$ilDB->quote($a_item_id ,'integer')." ";
172  $res = $ilDB->manipulate($query);
173  }
174 
175  public static function _deleteByUser($a_usr_id)
176  {
177  global $ilDB;
178 
179  $query = "DELETE FROM crs_timings_planed ".
180  "WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
181  $res = $ilDB->manipulate($query);
182  }
183 
184  function __read()
185  {
186  global $ilDB;
187 
188  $query = "SELECT * FROM crs_timings_planed ".
189  "WHERE item_id = ".$ilDB->quote($this->getItemId() ,'integer')." ".
190  "AND usr_id = ".$ilDB->quote($this->getUserId() ,'integer')." ";
191  $res = $this->db->query($query);
192  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
193  {
194  $this->setPlanedStartingTime($row->planed_start);
195  $this->setPlanedEndingTime($row->planed_end);
196  }
197  return true;
198  }
199 }
200 ?>
class ilTimingPlaned
__construct($item_id, $a_usr_id)
Constructor.
static getItem($a_ref_id)
Get item data.
static _getPlanedTimingsByItem($a_item_id)
static _deleteByUser($a_usr_id)
static _delete($a_item_id, $a_usr_id)
Create styles array
The data for the language used.
static _getPlanedTimings($a_usr_id, $a_item_id)
setPlanedStartingTime($a_time)
static _deleteByItem($a_item_id)