blob: 9ffebf5923d42ce46d6f8219cea026fbc3cadb23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<?php
/**
* ForumFavorite.php - Add and remove favorite postings
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* @author Till Glöggler <tgloeggl@uos.de>
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL version 3
* @category Stud.IP
*/
class ForumFavorite {
/**
* Set the topic denoted by the passed id as favorite for the
* currently logged in user
*
* @param string $topic_id
*/
static function set($topic_id) {
$stmt = DBManager::get()->prepare("REPLACE INTO
forum_favorites (topic_id, user_id)
VALUES (?, ?)");
$stmt->execute([$topic_id, $GLOBALS['user']->id]);
}
/**
* Remove the topic denoted by the passed id as favorite for the
* currently logged in user
*
* @param string $topic_id
*/
static function remove($topic_id) {
$stmt = DBManager::get()->prepare("DELETE FROM forum_favorites
WHERE topic_id = ? AND user_id = ?");
$stmt->execute([$topic_id, $GLOBALS['user']->id]);
}
}
|