Skip to content
Snippets Groups Projects
Select Git revision
  • f2d9f928042df613a0785441d6824119e83c7990
  • main default protected
  • biest-00109
  • biest-00520
  • biest-00519
  • biest-00521
  • biest-00525
  • biest-00324
  • biest-00110
  • biest-00104
  • biest-00109b
  • biest-00396
  • biest-00098
  • biest-00230
  • biest-00111
  • demo-va-hauptseite
  • biest-00123
  • 9-anmeldesets-gultigskeitsdauer-von-regeln
  • 5.0
19 results

Resource.class.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.
    Resource.class.php 102.93 KiB
    <?php
    
    /**
     * Resource.class.php - model class for a resource
     *
     * 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      Moritz Strohm <strohm@data-quest.de>
     * @copyright   2017-2019
     * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
     * @category    Stud.IP
     * @package     resources
     * @since       4.5
     *
     * @property string resource_id database column
     * @property string id alias column for resource_id
     * @property string parent_id database column
     * @property string category_id database column
     * @property string level database column
     * @property string name database column
     * @property string description database column
     * @property string requestable database column
     * @property string sort_position database column
     * @property string mkdate database column
     * @property string chdate database column
     * @property SimpleORMapCollection category belongs_to ResourceCategory
     * @property SimpleORMapCollection properties has_many ResourceProperty
     * @property SimpleORMapCollection permissions has_many ResourcePermission
     * @property SimpleORMapCollection bookings has_many ResourceBooking
     * @property SimpleORMapCollection children has_many Resource
     * @property FolderType folder
     */
    
    
    /**
     * The Resource class is the base class of the new
     * Room and Resource management system in Stud.IP.
     * It provides core functionality for handling general resources
     * and can be derived for handling special resources.
     */
    class Resource extends SimpleORMap implements StudipItem
    {
        /**
         * This is a cache for permissions that users have on resources.
         * It is meant to reduce the database requests in cases where the
         * same permission is queried a lot of times.
         */
        protected static $permission_cache;
    
        protected static function configure($config = [])
        {
            $config['db_table'] = 'resources';
    
            $config['belongs_to']['category'] = [
                'class_name'  => 'ResourceCategory',
                'foreign_key' => 'category_id',
                'assoc_func'  => 'find'
            ];
    
            $config['has_many']['properties'] = [
                'class_name'        => 'ResourceProperty',
                'assoc_foreign_key' => 'resource_id',
                'on_delete'         => 'delete',
                'on_store'          => 'store'
            ];
    
            $config['has_many']['permissions'] = [