Skip to content
Snippets Groups Projects
Select Git revision
  • 8554b74bb2cc62bda4bdeb8ba6b081fde5f619ce
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

ForumFavorite.php

Blame
  • Forked from Stud.IP / Stud.IP
    2176 commits behind the upstream repository.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ForumFavorite.php 1.25 KiB
    <?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]);        
        }
    }