Skip to content
Snippets Groups Projects
Select Git revision
  • a3da1483a9e689846179159355badfec8073dbec
  • 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

CoursesetModel.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    BlubberThread.php 41.13 KiB
    <?php
    /**
     * BlubberThread
     * Model class for BlubberThreads
     *
     * 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 2 of
     * the License, or (at your option) any later version.
     *
     * @author      Rasmus Fuhse <fuhse@data-quest.de>
     * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
     * @category    Stud.IP
     * @since       4.5
     */
    
    class BlubberThread extends SimpleORMap implements PrivacyObject
    {
        /**
         * Configures this model.
         *
         * @param array $config Configuration array
         */
        protected static function configure($config = [])
        {
            $config['db_table'] = 'blubber_threads';
    
            $config['has_many']['comments'] = [
                'class_name' => BlubberComment::class,
                'on_store'   => 'store',
                'on_delete'  => 'delete',
                'order_by'   => 'ORDER BY mkdate ASC'
            ];
            $config['has_many']['mentions'] = [
                'class_name' => BlubberMention::class,
                'on_store'   => 'store',
                'on_delete'  => 'delete',
            ];
            $config['belongs_to']['user'] = [
                'class_name'        => User::class,
                'foreign_key'       => 'user_id',
                'assoc_foreign_key' => 'user_id',
            ];
    
            $config['serialized_fields']['metadata'] = 'JSONArrayObject';
    
            parent::configure($config);
        }
    
        public static $mention_thread_id = null;
        protected $last_visit = null;
    
        /**
         * Pre-Markup rule. Recognizes mentions in blubber as @username or @"Firstname lastname"
         * and turns them into usual studip-links. The mentioned person is notified by
         * sending a message to him/her as a side-effect.
         * @param StudipTransformFormat $markup
         * @param array $matches
         * @return string
         */
        public static function mention($markup, $matches)
        {
            $mention = $matches[1];
            $thread = self::find(self::$mention_thread_id);
            $username = stripslashes(mb_substr($mention, 1));
            if ($username[0] !== '"') {
                $user = User::findByUsername($username);
            } else {
                $name = mb_substr($username, 1, -1); // Strip quotes
                $user = User::findOneBySQL("CONCAT(Vorname, ' ', Nachname) = ?", [$name]);