ILIAS  release_8 Revision v8.24
class.ilObjEmployeeTalk.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
24
25final class ilObjEmployeeTalk extends ilObject
26{
27 public const TYPE = 'etal';
28
32 private static int $root_ref_id = -1;
36 private static int $root_id = -1;
37
41 private $repository;
42
46 private $data;
47
52 public function __construct(int $a_id = 0, bool $a_call_by_reference = true)
53 {
54 $this->setType(self::TYPE);
55
56 $this->repository = new IliasDBEmployeeTalkRepository($GLOBALS['DIC']->database());
57 $datetime = new ilDateTime(1, IL_CAL_UNIX);
58 $this->data = new EmployeeTalk(
59 -1,
60 $datetime,
61 $datetime,
62 false,
63 '',
64 '',
65 -1,
66 false,
67 false,
68 0
69 );
70
71 parent::__construct($a_id, $a_call_by_reference);
72 }
73
74 public function read(): void
75 {
76 parent::read();
77 $this->data = $this->repository->findByObjectId($this->getId());
78 }
79
80 public function create(): int
81 {
82 $this->setOfflineStatus(true);
83 parent::create();
84
85 $this->data->setObjectId($this->getId());
86 $this->repository->create($this->data);
87
89 $app->setTitle($this->getTitle());
90 $app->setSubtitle('');
91 $app->setFullday($this->data->isAllDay());
92 $app->setTranslationType(ilCalendarEntry::TRANSLATION_NONE);
93 $app->setDescription($this->getLongDescription());
94 $app->setStart($this->data->getStartDate());
95 $app->setEnd($this->data->getEndDate());
96 $app->setLocation($this->data->getLocation());
97 $apps[] = $app;
98
102 $container = $GLOBALS['DIC'];
103
104 $container->event()->raise(
105 'Modules/EmployeeTalk',
106 'create',
107 ['object' => $this,
108 'obj_id' => $this->getId(),
109 'appointments' => $apps
110 ]
111 );
112
113 return $this->getId();
114 }
115
116
117
118 public function update(): bool
119 {
120 parent::update();
121 $this->repository->update($this->data);
122
124 $app->setTitle($this->getTitle());
125 $app->setSubtitle($this->getParent()->getTitle());
126 $app->setFullday($this->data->isAllDay());
127 $app->setTranslationType(ilCalendarEntry::TRANSLATION_NONE);
128 $app->setDescription($this->getLongDescription());
129 $app->setStart($this->data->getStartDate());
130 $app->setEnd($this->data->getEndDate());
131 $app->setLocation($this->data->getLocation());
132 $apps[] = $app;
133
137 $container = $GLOBALS['DIC'];
138
139 $container->event()->raise(
140 'Modules/EmployeeTalk',
141 'update',
142 ['object' => $this,
143 'obj_id' => $this->getId(),
144 'appointments' => $apps
145 ]
146 );
147
148 return true;
149 }
150
154 public static function getRootOrgRefId(): int
155 {
157
158 return self::$root_ref_id;
159 }
160
164 public static function getRootOrgId(): int
165 {
167
168 return self::$root_id;
169 }
170
171 private static function loadRootOrgRefIdAndId(): void
172 {
173 if (self::$root_ref_id === -1 || self::$root_id === -1) {
174 global $DIC;
175 $ilDB = $DIC['ilDB'];
176 $q = "SELECT o.obj_id, r.ref_id FROM object_data o
177 INNER JOIN object_reference r ON r.obj_id = o.obj_id
178 WHERE title = " . $ilDB->quote('__TalkTemplateAdministration', 'text') . "";
179 $set = $ilDB->query($q);
180 $res = $ilDB->fetchAssoc($set);
181 self::$root_id = (int) $res["obj_id"];
182 self::$root_ref_id = (int) $res["ref_id"];
183 }
184 }
185
187 {
188 return new ilObjEmployeeTalkSeries($this->tree->getParentId($this->getRefId()), true);
189 }
190
197 public static function _exists(int $a_id, bool $a_reference = false, ?string $type = null): bool
198 {
199 return parent::_exists($a_id, $a_reference, "etal");
200 }
201
207 public function delete(): bool
208 {
212 $container = $GLOBALS['DIC'];
213
214 $container->event()->raise(
215 'Modules/EmployeeTalk',
216 'delete',
217 [
218 'object' => $this,
219 'obj_id' => $this->getId(),
220 'appointments' => []
221 ]
222 );
223
224 $parent_series = $this->getParent();
225
226 $this->repository->delete($this->getData());
227
228 $trashed_node_data = $this->tree->getNodeData(
229 $this->getRefId(),
230 (-1) * $this->getRefId()
231 );
232 $node_data = $this->tree->getNodeData($this->getRefId());
233
234 $result = parent::delete();
235
236 if ((int) ($trashed_node_data['child'] ?? 0) === $this->getRefId()) {
237 $this->tree->deleteNode(
238 (-1) * $this->getRefId(),
239 $this->getRefId()
240 );
241 } elseif ((int) ($node_data['child'] ?? 0) === $this->getRefId()) {
242 $this->tree->deleteNode(
243 $node_data['tree'],
244 $this->getRefId()
245 );
246 }
247
248 if (!$parent_series->hasChildren()) {
249 $parent_series->delete();
250 }
251
252 return $result;
253 }
254
258 public function getData(): EmployeeTalk
259 {
260 return clone $this->data;
261 }
262
268 {
269 $this->data = clone $data;
270 return $this;
271 }
272
273 public function cloneObject(int $target_id, int $copy_id = 0, bool $omit_tree = false): ilObjEmployeeTalk
274 {
278 $talkClone = parent::cloneObject($target_id, $copy_id, $omit_tree);
279 $data = $this->getData()->setObjectId($talkClone->getId());
280 $this->repository->update($data);
281 $talkClone->setData($data);
282
283 return $talkClone;
284 }
285}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
const IL_CAL_UNIX
Apointment templates are used for automatic generated apointments.
@classDescription Date and time handling
static _exists(int $a_id, bool $a_reference=false, ?string $type=null)
__construct(int $a_id=0, bool $a_call_by_reference=true)
setData(EmployeeTalk $data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setType(string $type)
getLongDescription()
get object long description (stored in object_description)
setOfflineStatus(bool $status)
create()
note: title, description and type should be set when this function is called
string $type
$app
Definition: cli.php:39
global $DIC
Definition: feed.php:28
$target_id
Definition: goto.php:52
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$container
@noRector
Definition: wac.php:14