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

Contact.class.php

  • Forked from Stud.IP / Stud.IP
    1756 commits behind the upstream repository.
    David Siegfried's avatar
    David Siegfried authored
    Closes #3839
    
    Merge request studip/studip!2708
    a489ba55
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Contact.class.php 1.59 KiB
    <?php
    
    /**
     * Contact.class.php - model class for table contact
     *
     * @author      <mlunzena@uos.de>
     * @license GPL 2 or later
     *
     * @property array $id alias for pk
     * @property string $owner_id database column
     * @property string $user_id database column
     * @property string $calendar_permissions database column
     *     An enum with the possible values "", "READ" and "WRITE".
     *     The empty string specifies that no calendar permissions are granted.
     * @property User $owner belongs_to User
     * @property User $friend belongs_to User
     * @property string $mkdate database column
     * @property string $chdate database column
     */
    class Contact extends SimpleORMap
    {
        protected static function configure($config = [])
        {
            $config['db_table'] = 'contact';
    
            $config['belongs_to']['owner'] = [
                'class_name' => User::class,
                'foreign_key' => 'owner_id'
            ];
            $config['belongs_to']['friend'] = [
                'class_name' => User::class,
                'foreign_key' => 'user_id'
            ];
    
            $config['has_many']['groups'] = [
                'class_name'        => ContactGroupItem::class,
                'assoc_func'        => 'findByContact',
                'foreign_key'       => function ($me) {
                    return [$me];
                },
                'assoc_foreign_key' => function ($item, $params) {
                    //Nothing else here. But this has to be present
                    //so that storing a new contact works.
                 },
                'on_store'          => 'store',
                'on_delete'         => 'delete'
            ];
    
            parent::configure($config);
        }
    }