ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTimingAccepted.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 
40  function ilTimingAccepted($crs_id,$a_usr_id)
41  {
42  global $ilErr,$ilDB,$lng,$tree;
43 
44  $this->ilErr =& $ilErr;
45  $this->db =& $ilDB;
46  $this->lng =& $lng;
47 
48  $this->crs_id = $crs_id;
49  $this->user_id = $a_usr_id;
50 
51  $this->__read();
52  }
53 
54  function getUserId()
55  {
56  return $this->user_id;
57  }
58  function getCourseId()
59  {
60  return $this->crs_id;
61  }
62  function accept($a_status)
63  {
64  $this->accepted = $a_status;
65  }
66  function isAccepted()
67  {
68  return $this->accepted ? true : false;
69  }
70  function setRemark($a_remark)
71  {
72  $this->remark = $a_remark;
73  }
74  function getRemark()
75  {
76  return $this->remark;
77  }
78  function setVisible($a_visible)
79  {
80  $this->visible = $a_visible;
81  }
82  function isVisible()
83  {
84  return $this->visible ? true : false;
85  }
86 
87  function update()
88  {
90  $this->create();
91  return true;
92  }
93 
94  function create()
95  {
96  global $ilDB;
97 
98  $query = "INSERT INTO crs_timings_usr_accept ".
99  "SET crs_id = ".$ilDB->quote($this->getCourseId()).", ".
100  "usr_id = ".$ilDB->quote($this->getUserId()).", ".
101  "visible = ".$ilDB->quote($this->isVisible()).", ".
102  "accept = ".$ilDB->quote($this->isAccepted()).", ".
103  "remark = ".$ilDB->quote($this->getRemark())." ";
104  $this->db->query($query);
105  }
106 
107  function delete()
108  {
109  return ilTimingAccepted::_delete($this->getCourseId(),$this->getUserId());
110  }
111 
112  function _delete($a_crs_id,$a_usr_id)
113  {
114  global $ilDB;
115 
116  $query = "DELETE FROM crs_timings_usr_accept ".
117  "WHERE crs_id = ".$ilDB->quote($a_crs_id)." ".
118  "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
119  $ilDB->query($query);
120  }
121 
122  function _deleteByCourse($a_crs_id)
123  {
124  global $ilDB;
125 
126  $query = "DELETE FROM crs_timings_usr_accept ".
127  "WHERE crs_id = ".$ilDB->quote($a_crs_id)." ";
128  $ilDB->query($query);
129  }
130 
131  function _deleteByUser($a_usr_id)
132  {
133  global $ilDB;
134 
135  $query = "DELETE FROM crs_timings_usr_accept ".
136  "WHERE usr_id = ".$ilDB->quote($a_usr_id)."";
137  $ilDB->query($query);
138  }
139 
140  function __read()
141  {
142  global $ilDB;
143 
144  $query = "SELECT * FROM crs_timings_usr_accept ".
145  "WHERE crs_id = ".$ilDB->quote($this->getCourseId())." ".
146  "AND usr_id = ".$this->getUserId()."";
147  $res = $this->db->query($query);
148  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
149  {
150  $this->setVisible($row->visible);
151  $this->setRemark($row->remark);
152  $this->accept($row->accept);
153  }
154  return true;
155  }
156 }
157 ?>