ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
45 public function __construct($crs_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->crs_id = $crs_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 getCourseId()
64 {
65 return $this->crs_id;
66 }
67 function accept($a_status)
68 {
69 $this->accepted = $a_status;
70 }
71 function isAccepted()
72 {
73 return $this->accepted ? true : false;
74 }
75 function setRemark($a_remark)
76 {
77 $this->remark = $a_remark;
78 }
79 function getRemark()
80 {
81 return $this->remark;
82 }
83 function setVisible($a_visible)
84 {
85 $this->visible = $a_visible;
86 }
87 function isVisible()
88 {
89 return $this->visible ? true : false;
90 }
91
92 function update()
93 {
95 $this->create();
96 return true;
97 }
98
99 function create()
100 {
101 global $ilDB;
102
103 $query = "INSERT INTO crs_timings_usr_accept (crs_id,usr_id,visible,accept,remark) ".
104 "VALUES( ".
105 $ilDB->quote($this->getCourseId() ,'integer').", ".
106 $ilDB->quote($this->getUserId() ,'integer').", ".
107 $ilDB->quote($this->isVisible() ,'integer').", ".
108 $ilDB->quote($this->isAccepted() ,'integer').", ".
109 $ilDB->quote($this->getRemark() ,'text')." ".
110 ")";
111 $res = $ilDB->manipulate($query);
112 }
113
114 function delete()
115 {
116 return ilTimingAccepted::_delete($this->getCourseId(),$this->getUserId());
117 }
118
119 function _delete($a_crs_id,$a_usr_id)
120 {
121 global $ilDB;
122
123 $query = "DELETE FROM crs_timings_usr_accept ".
124 "WHERE crs_id = ".$ilDB->quote($a_crs_id ,'integer')." ".
125 "AND usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
126 $res = $ilDB->manipulate($query);
127 }
128
129 function _deleteByCourse($a_crs_id)
130 {
131 global $ilDB;
132
133 $query = "DELETE FROM crs_timings_usr_accept ".
134 "WHERE crs_id = ".$ilDB->quote($a_crs_id ,'integer')." ";
135 $res = $ilDB->manipulate($query);
136 }
137
138 public static function _deleteByUser($a_usr_id)
139 {
140 global $ilDB;
141
142 $query = "DELETE FROM crs_timings_usr_accept ".
143 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')."";
144 $res = $ilDB->manipulate($query);
145 }
146
147 function __read()
148 {
149 global $ilDB;
150
151 $query = "SELECT * FROM crs_timings_usr_accept ".
152 "WHERE crs_id = ".$ilDB->quote($this->getCourseId() ,'integer')." ".
153 "AND usr_id = ".$ilDB->quote($this->getUserId() ,'integer')."";
154 $res = $this->db->query($query);
155 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
156 {
157 $this->setVisible($row->visible);
158 $this->setRemark($row->remark);
159 $this->accept($row->accept);
160 }
161 return true;
162 }
163}
164?>
An exception for terminatinating execution or to throw for unit testing.
class ilTimingAccepted
static _deleteByUser($a_usr_id)
_delete($a_crs_id, $a_usr_id)
__construct($crs_id, $a_usr_id)
Constructor.