diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /lib/models/Contact.php | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/models/Contact.php')
| -rw-r--r-- | lib/models/Contact.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/models/Contact.php b/lib/models/Contact.php new file mode 100644 index 0000000..bea5b95 --- /dev/null +++ b/lib/models/Contact.php @@ -0,0 +1,51 @@ +<?php + +/** + * Contact.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); + } +} |
