ILIAS  release_8 Revision v8.24
class.ilOrgUnitUserAssignment.php
Go to the documentation of this file.
1<?php
20
26{
27 public static function returnDbTableName(): string
28 {
29 return 'il_orgu_ua';
30 }
31
41 protected ?int $id = 0;
48 protected int $user_id = 0;
55 protected int $position_id = 0;
62 protected int $orgu_id = 0;
63
65 {
66 $inst = self::where(array(
67 'user_id' => $user_id,
68 'position_id' => $position_id,
69 'orgu_id' => $orgu_id
70 ))->first();
71 if (!$inst) {
72 $inst = new self();
73 $inst->setPositionId($position_id);
74 $inst->setUserId($user_id);
75 $inst->setOrguId($orgu_id);
76 $inst->create();
77 }
78
79 return $inst;
80 }
81
82 protected function raiseEvent(string $event): void
83 {
84 global $DIC;
85
86 if (!$DIC->offsetExists('ilAppEventHandler')) {
87 return;
88 }
89 $ilAppEventHandler = $DIC['ilAppEventHandler'];
90 $ilAppEventHandler->raise('Modules/OrgUnit', $event, array(
91 'obj_id' => $this->getOrguId(),
92 'usr_id' => $this->getUserId(),
93 'position_id' => $this->getPositionId()
94 ));
95 }
96
97 public function create(): void
98 {
99 $this->raiseEvent('assignUserToPosition');
100 parent::create();
101 }
102
103 public function delete(): void
104 {
105 $this->raiseEvent('deassignUserFromPosition');
106 parent::delete();
107 }
108
109 public function getId(): ?int
110 {
111 return $this->id;
112 }
113
114 public function setId(?int $id): void
115 {
116 $this->id = $id;
117 }
118
119 public function getUserId(): int
120 {
121 return $this->user_id;
122 }
123
124 public function setUserId(int $user_id)
125 {
126 $this->user_id = $user_id;
127 }
128
129 public function getPositionId(): int
130 {
131 return $this->position_id;
132 }
133
134 public function setPositionId(int $position_id)
135 {
136 $this->position_id = $position_id;
137 }
138
139 public function getOrguId(): int
140 {
141 return $this->orgu_id;
142 }
143
144 public function setOrguId(int $orgu_id): void
145 {
146 $this->orgu_id = $orgu_id;
147 }
148}
Class ActiveRecord.
static where($where, $operator=null)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
Class ilOrgUnitUserAssignment.
static findOrCreateAssignment(int $user_id, int $position_id, int $orgu_id)
global $DIC
Definition: feed.php:28