ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilNewsSubscription.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
14{
21 public static function _subscribe($a_ref_id, $a_user_id)
22 {
23 global $DIC;
24
25 $ilDB = $DIC->database();
26
27 $ilDB->manipulate("DELETE FROM il_news_subscription WHERE " .
28 " ref_id = " . $ilDB->quote($a_ref_id, "integer") . " " .
29 " AND user_id = " . $ilDB->quote($a_user_id, "integer"));
30 $ilDB->manipulate("INSERT INTO il_news_subscription (ref_id, user_id) VALUES (" .
31 $ilDB->quote($a_ref_id, "integer") . ", " .
32 $ilDB->quote($a_user_id, "integer") . ")");
33 }
34
41 public static function _unsubscribe($a_ref_id, $a_user_id)
42 {
43 global $DIC;
44
45 $ilDB = $DIC->database();
46
47 $ilDB->manipulate("DELETE FROM il_news_subscription WHERE ref_id = " .
48 $ilDB->quote($a_ref_id, "integer") . " AND user_id = " .
49 $ilDB->quote($a_user_id, "integer"));
50 }
51
59 public static function _hasSubscribed($a_ref_id, $a_user_id)
60 {
61 global $DIC;
62
63 $ilDB = $DIC->database();
64
65 $query = "SELECT * FROM il_news_subscription WHERE ref_id = " .
66 $ilDB->quote($a_ref_id, "integer") . " AND user_id = " .
67 $ilDB->quote($a_user_id, "integer");
68 $set = $ilDB->query($query);
69 if ($rec = $ilDB->fetchAssoc($set)) {
70 return true;
71 } else {
72 return false;
73 }
74 }
75
83 public static function _getSubscriptionsOfUser($a_user_id)
84 {
85 global $DIC;
86
87 $ilDB = $DIC->database();
88
89 $query = "SELECT * FROM il_news_subscription WHERE user_id = " .
90 $ilDB->quote($a_user_id, "integer");
91 $set = $ilDB->query($query);
92 $ref_ids = array();
93 while ($rec = $ilDB->fetchAssoc($set)) {
94 $ref_ids[] = $rec["ref_id"];
95 }
96
97 return $ref_ids;
98 }
99}
An exception for terminatinating execution or to throw for unit testing.
This class handles news subscriptions of users.
static _subscribe($a_ref_id, $a_user_id)
Subscribe a user to an object (ref id).
static _hasSubscribed($a_ref_id, $a_user_id)
Check whether user has subscribed to an object.
static _getSubscriptionsOfUser($a_user_id)
Get subscriptions of user.
static _unsubscribe($a_ref_id, $a_user_id)
Unsubscribe a user from an object (ref id).
$query
global $DIC
Definition: saml.php:7
global $ilDB