ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $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  public function getUserId()
60  {
61  return $this->user_id;
62  }
63  public function getCourseId()
64  {
65  return $this->crs_id;
66  }
67  public function accept($a_status)
68  {
69  $this->accepted = $a_status;
70  }
71  public function isAccepted()
72  {
73  return $this->accepted ? true : false;
74  }
75  public function setRemark($a_remark)
76  {
77  $this->remark = $a_remark;
78  }
79  public function getRemark()
80  {
81  return $this->remark;
82  }
83  public function setVisible($a_visible)
84  {
85  $this->visible = $a_visible;
86  }
87  public function isVisible()
88  {
89  return $this->visible ? true : false;
90  }
91 
92  public function update()
93  {
95  $this->create();
96  return true;
97  }
98 
99  public 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  public function delete()
115  {
116  return ilTimingAccepted::_delete($this->getCourseId(), $this->getUserId());
117  }
118 
119  public 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  public 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  public 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  $this->setVisible($row->visible);
157  $this->setRemark($row->remark);
158  $this->accept($row->accept);
159  }
160  return true;
161  }
162 }
__construct($crs_id, $a_usr_id)
Constructor.
static _deleteByUser($a_usr_id)
foreach($_POST as $key=> $value) $res
_delete($a_crs_id, $a_usr_id)
$query
class ilTimingAccepted