ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjEmployeeTalk.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
25final class ilObjEmployeeTalk extends ilObject
26{
27 public const string 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
58 $this->data = new EmployeeTalk(
59 -1,
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 parent::create();
83
84 $this->data->setObjectId($this->getId());
85 $this->repository->create($this->data);
86
87 $app = new ilCalendarAppointmentTemplate($this->getId());
88 $app->setTitle($this->getTitle());
89 $app->setSubtitle('');
90 $app->setFullday($this->data->isAllDay());
91 $app->setTranslationType(ilCalendarEntry::TRANSLATION_NONE);
92 $app->setDescription($this->getLongDescription());
93 $app->setStart($this->data->getStartDate());
94 $app->setEnd($this->data->getEndDate());
95 $app->setLocation($this->data->getLocation());
96 $apps[] = $app;
97
101 $container = $GLOBALS['DIC'];
102
103 $container->event()->raise(
104 'components/ILIAS/EmployeeTalk',
105 'create',
106 ['object' => $this,
107 'obj_id' => $this->getId(),
108 'appointments' => $apps
109 ]
110 );
111
112 return $this->getId();
113 }
114
115
116
117 public function update(): bool
118 {
119 parent::update();
120 $this->repository->update($this->data);
121
122 $app = new ilCalendarAppointmentTemplate($this->getParent()->getId());
123 $app->setTitle($this->getTitle());
124 $app->setSubtitle($this->getParent()->getTitle());
125 $app->setFullday($this->data->isAllDay());
126 $app->setTranslationType(ilCalendarEntry::TRANSLATION_NONE);
127 $app->setDescription($this->getLongDescription());
128 $app->setStart($this->data->getStartDate());
129 $app->setEnd($this->data->getEndDate());
130 $app->setLocation($this->data->getLocation());
131 $apps[] = $app;
132
136 $container = $GLOBALS['DIC'];
137
138 $container->event()->raise(
139 'components/ILIAS/EmployeeTalk',
140 'update',
141 ['object' => $this,
142 'obj_id' => $this->getId(),
143 'appointments' => $apps
144 ]
145 );
146
147 return true;
148 }
149
153 public static function getRootOrgRefId(): int
154 {
156
157 return self::$root_ref_id;
158 }
159
163 public static function getRootOrgId(): int
164 {
166
167 return self::$root_id;
168 }
169
170 private static function loadRootOrgRefIdAndId(): void
171 {
172 if (self::$root_ref_id === -1 || self::$root_id === -1) {
173 global $DIC;
174 $ilDB = $DIC['ilDB'];
175 $q = "SELECT o.obj_id, r.ref_id FROM object_data o
176 INNER JOIN object_reference r ON r.obj_id = o.obj_id
177 WHERE title = " . $ilDB->quote('__TalkTemplateAdministration', 'text');
178 $set = $ilDB->query($q);
179 $res = $ilDB->fetchAssoc($set);
180 self::$root_id = (int) $res["obj_id"];
181 self::$root_ref_id = (int) $res["ref_id"];
182 }
183 }
184
186 {
187 return new ilObjEmployeeTalkSeries($this->tree->getParentId($this->getRefId()), true);
188 }
189
190 public static function _exists(int $id, bool $reference = false, ?string $type = null): bool
191 {
192 return parent::_exists($id, $reference, "etal");
193 }
194
200 public function delete(): bool
201 {
205 $container = $GLOBALS['DIC'];
206
207 $container->event()->raise(
208 'components/ILIAS/EmployeeTalk',
209 'delete',
210 [
211 'object' => $this,
212 'obj_id' => $this->getId(),
213 'appointments' => []
214 ]
215 );
216
217 $parent_series = $this->getParent();
218
219 $this->repository->delete($this->getData());
220
221 $result = parent::delete();
222
223 if (!$parent_series->hasChildren()) {
224 $parent_series->delete();
225 }
226
227 return $result;
228 }
229
233 public function getData(): EmployeeTalk
234 {
235 return clone $this->data;
236 }
237
243 {
244 $this->data = clone $data;
245 return $this;
246 }
247
248 public function cloneObject(int $target_id, int $copy_id = 0, bool $omit_tree = false): ilObjEmployeeTalk
249 {
253 $talkClone = parent::cloneObject($target_id, $copy_id, $omit_tree);
254 $data = $this->getData()->setObjectId($talkClone->getId());
255 $this->repository->update($data);
256 $talkClone->setData($data);
257
258 return $talkClone;
259 }
260}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$datetime
const IL_CAL_UNIX
Apointment templates are used for automatic generated apointments.
@classDescription Date and time handling
__construct(int $a_id=0, bool $a_call_by_reference=true)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
setData(EmployeeTalk $data)
Class ilObject Basic functions for all objects.
setType(string $type)
getLongDescription()
get object long description (stored in object_description)
create()
note: title, description and type should be set when this function is called
string $type
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23
$container
@noRector
Definition: wac.php:37
$GLOBALS["DIC"]
Definition: wac.php:54