ILIAS  Release_4_4_x_branch Revision 61816
 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 (crs_id,usr_id,visible,accept,remark) ".
99  "VALUES( ".
100  $ilDB->quote($this->getCourseId() ,'integer').", ".
101  $ilDB->quote($this->getUserId() ,'integer').", ".
102  $ilDB->quote($this->isVisible() ,'integer').", ".
103  $ilDB->quote($this->isAccepted() ,'integer').", ".
104  $ilDB->quote($this->getRemark() ,'text')." ".
105  ")";
106  $res = $ilDB->manipulate($query);
107  }
108 
109  function delete()
110  {
111  return ilTimingAccepted::_delete($this->getCourseId(),$this->getUserId());
112  }
113 
114  function _delete($a_crs_id,$a_usr_id)
115  {
116  global $ilDB;
117 
118  $query = "DELETE FROM crs_timings_usr_accept ".
119  "WHERE crs_id = ".$ilDB->quote($a_crs_id ,'integer')." ".
120  "AND usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
121  $res = $ilDB->manipulate($query);
122  }
123 
124  function _deleteByCourse($a_crs_id)
125  {
126  global $ilDB;
127 
128  $query = "DELETE FROM crs_timings_usr_accept ".
129  "WHERE crs_id = ".$ilDB->quote($a_crs_id ,'integer')." ";
130  $res = $ilDB->manipulate($query);
131  }
132 
133  function _deleteByUser($a_usr_id)
134  {
135  global $ilDB;
136 
137  $query = "DELETE FROM crs_timings_usr_accept ".
138  "WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')."";
139  $res = $ilDB->manipulate($query);
140  }
141 
142  function __read()
143  {
144  global $ilDB;
145 
146  $query = "SELECT * FROM crs_timings_usr_accept ".
147  "WHERE crs_id = ".$ilDB->quote($this->getCourseId() ,'integer')." ".
148  "AND usr_id = ".$ilDB->quote($this->getUserId() ,'integer')."";
149  $res = $this->db->query($query);
150  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
151  {
152  $this->setVisible($row->visible);
153  $this->setRemark($row->remark);
154  $this->accept($row->accept);
155  }
156  return true;
157  }
158 }
159 ?>