ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLinkCheckNotify.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 
32 {
33  var $db = null;
34 
35 
37  {
38  $this->db =& $db;
39  }
40 
41  function setUserId($a_usr_id)
42  {
43  $this->usr_id = $a_usr_id;
44  }
45  function getUserId()
46  {
47  return $this->usr_id;
48  }
49  function setObjId($a_obj_id)
50  {
51  $this->obj_id = $a_obj_id;
52  }
53  function getObjId()
54  {
55  return $this->obj_id;
56  }
57 
58  function addNotifier()
59  {
60  global $ilDB;
61 
62  $this->deleteNotifier();
63 
64  $query = "INSERT INTO link_check_report ".
65  "SET obj_id = ".$ilDB->quote($this->getObjId()).", ".
66  "usr_id = ".$ilDB->quote($this->getUserId())."";
67 
68  $this->db->query($query);
69 
70  return true;
71  }
72 
73  function deleteNotifier()
74  {
75  global $ilDB;
76 
77  $query = "DELETE FROM link_check_report ".
78  "WHERE obj_id = ".$ilDB->quote($this->getObjId())." ".
79  "AND usr_id = ".$ilDB->quote($this->getUserId())." ";
80 
81  $this->db->query($query);
82 
83  return true;
84  }
85 
86  /* Static */
87  function _getNotifyStatus($a_usr_id,$a_obj_id)
88  {
89  global $ilDB;
90 
91  $query = "SELECT * FROM link_check_report ".
92  "WHERE obj_id = ".$ilDB->quote($a_obj_id)." ".
93  "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
94 
95  $res = $ilDB->query($query);
96 
97  return $res->numRows() ? true : false;
98  }
99 
100  function _deleteUser($a_usr_id)
101  {
102  global $ilDB;
103 
104  $query = "DELETE FROM link_check_report ".
105  "WHERE usr_id = ".$ilDB->quote($a_usr_id)." ";
106 
107  $ilDB->query($query);
108 
109  return true;
110  }
111 
112  function _deleteObject($a_obj_id)
113  {
114  global $ilDB;
115 
116  $query = "DELETE FROM link_check_report ".
117  "WHERE obj_id = ".$ilDB->quote($a_obj_id)." ";
118 
119  $ilDB->query($query);
120 
121  return true;
122  }
123 
124  function _getNotifiers($a_obj_id)
125  {
126  global $ilDB;
127 
128  $query = "SELECT * FROM link_check_report ".
129  "WHERE obj_id = ".$ilDB->quote($a_obj_id)." ";
130 
131  $res = $ilDB->query($query);
132  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
133  {
134  $usr_ids[] = $row->usr_id;
135  }
136 
137  return $usr_ids ? $usr_ids : array();
138  }
139 
141  {
142  global $ilDB;
143 
144  $query = "SELECT * FROM link_check_report ";
145 
146  $res = $db->query($query);
147  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
148  {
149  $usr_ids[$row->usr_id][] = $row->obj_id;
150  }
151 
152  return $usr_ids ? $usr_ids : array();
153  }
154 }
155 ?>