ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilNewsSubscription.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 
34 {
41  public static function _subscribe($a_ref_id, $a_user_id)
42  {
43  global $ilDB;
44 
45  $query = "REPLACE INTO il_news_subscription (ref_id, user_id) VALUES (".
46  $ilDB->quote($a_ref_id).", ".
47  $ilDB->quote($a_user_id).")";
48  $ilDB->query($query);
49  }
50 
57  public static function _unsubscribe($a_ref_id, $a_user_id)
58  {
59  global $ilDB;
60 
61  $query = "DELETE FROM il_news_subscription WHERE ref_id = ".
62  $ilDB->quote($a_ref_id)." AND user_id = ".
63  $ilDB->quote($a_user_id);
64  $ilDB->query($query);
65  }
66 
74  public static function _hasSubscribed($a_ref_id, $a_user_id)
75  {
76  global $ilDB;
77 
78  $query = "SELECT * FROM il_news_subscription WHERE ref_id = ".
79  $ilDB->quote($a_ref_id)." AND user_id = ".
80  $ilDB->quote($a_user_id);
81  $set = $ilDB->query($query);
82  if ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
83  {
84  return true;
85  }
86  else
87  {
88  return false;
89  }
90  }
91 
99  public static function _getSubscriptionsOfUser($a_user_id)
100  {
101  global $ilDB;
102 
103  $query = "SELECT * FROM il_news_subscription WHERE user_id = ".
104  $ilDB->quote($a_user_id);
105  $set = $ilDB->query($query);
106  $ref_ids = array();
107  while ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
108  {
109  $ref_ids[] = $rec["ref_id"];
110  }
111 
112  return $ref_ids;
113  }
114 }
115 ?>