ILIAS  release_7 Revision v7.30-3-g800a261c036
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 public $ilErr;
37 public $ilDB;
38 public $lng;
39
45 public function __construct($crs_id, $a_usr_id)
46 {
47 global $DIC;
48
49 $ilErr = $DIC['ilErr'];
50 $ilDB = $DIC['ilDB'];
51 $lng = $DIC['lng'];
52 $tree = $DIC['tree'];
53
54 $this->ilErr = &$ilErr;
55 $this->db = &$ilDB;
56 $this->lng = &$lng;
57
58 $this->crs_id = $crs_id;
59 $this->user_id = $a_usr_id;
60
61 $this->__read();
62 }
63
64 public function getUserId()
65 {
66 return $this->user_id;
67 }
68 public function getCourseId()
69 {
70 return $this->crs_id;
71 }
72 public function accept($a_status)
73 {
74 $this->accepted = $a_status;
75 }
76 public function isAccepted()
77 {
78 return $this->accepted ? true : false;
79 }
80 public function setRemark($a_remark)
81 {
82 $this->remark = $a_remark;
83 }
84 public function getRemark()
85 {
86 return $this->remark;
87 }
88 public function setVisible($a_visible)
89 {
90 $this->visible = $a_visible;
91 }
92 public function isVisible()
93 {
94 return $this->visible ? true : false;
95 }
96
97 public function update()
98 {
100 $this->create();
101 return true;
102 }
103
104 public function create()
105 {
106 global $DIC;
107
108 $ilDB = $DIC['ilDB'];
109
110 $query = "INSERT INTO crs_timings_usr_accept (crs_id,usr_id,visible,accept,remark) " .
111 "VALUES( " .
112 $ilDB->quote($this->getCourseId(), 'integer') . ", " .
113 $ilDB->quote($this->getUserId(), 'integer') . ", " .
114 $ilDB->quote($this->isVisible(), 'integer') . ", " .
115 $ilDB->quote($this->isAccepted(), 'integer') . ", " .
116 $ilDB->quote($this->getRemark(), 'text') . " " .
117 ")";
118 $res = $ilDB->manipulate($query);
119 }
120
121 public function delete()
122 {
123 return ilTimingAccepted::_delete($this->getCourseId(), $this->getUserId());
124 }
125
126 public function _delete($a_crs_id, $a_usr_id)
127 {
128 global $DIC;
129
130 $ilDB = $DIC['ilDB'];
131
132 $query = "DELETE FROM crs_timings_usr_accept " .
133 "WHERE crs_id = " . $ilDB->quote($a_crs_id, 'integer') . " " .
134 "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
135 $res = $ilDB->manipulate($query);
136 }
137
138 public function _deleteByCourse($a_crs_id)
139 {
140 global $DIC;
141
142 $ilDB = $DIC['ilDB'];
143
144 $query = "DELETE FROM crs_timings_usr_accept " .
145 "WHERE crs_id = " . $ilDB->quote($a_crs_id, 'integer') . " ";
146 $res = $ilDB->manipulate($query);
147 }
148
149 public static function _deleteByUser($a_usr_id)
150 {
151 global $DIC;
152
153 $ilDB = $DIC['ilDB'];
154
155 $query = "DELETE FROM crs_timings_usr_accept " .
156 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . "";
157 $res = $ilDB->manipulate($query);
158 }
159
160 public function __read()
161 {
162 global $DIC;
163
164 $ilDB = $DIC['ilDB'];
165
166 $query = "SELECT * FROM crs_timings_usr_accept " .
167 "WHERE crs_id = " . $ilDB->quote($this->getCourseId(), 'integer') . " " .
168 "AND usr_id = " . $ilDB->quote($this->getUserId(), 'integer') . "";
169 $res = $this->db->query($query);
170 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
171 $this->setVisible($row->visible);
172 $this->setRemark($row->remark);
173 $this->accept($row->accept);
174 }
175 return true;
176 }
177}
An exception for terminatinating execution or to throw for unit testing.
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
class ilTimingAccepted
static _deleteByUser($a_usr_id)
_delete($a_crs_id, $a_usr_id)
__construct($crs_id, $a_usr_id)
Constructor.
global $DIC
Definition: goto.php:24
$query
foreach($_POST as $key=> $value) $res