160 : void
161 {
162 $this->cdata = trim($this->cdata);
163 $property = strtolower($this->entity) . 'Array';
164
165 if (!property_exists($this, $property)) {
166 return;
167 }
168
169 $propertyValue = &$this->{$property};
170
171 switch ($a_name) {
172 case 'Forum':
173 $query_num_posts = 'SELECT COUNT(pos_pk) cnt FROM frm_posts WHERE pos_top_fk = ' . $this->db->quote(
174 $this->lastHandledForumId,
175 'integer'
176 );
177 $res_pos = $this->db->query($query_num_posts);
178 $data_pos = $this->db->fetchAssoc($res_pos);
179 $num_posts = (
int) $data_pos[
'cnt'];
180
181 $query_num_threads = 'SELECT COUNT(thr_pk) cnt FROM frm_threads WHERE thr_top_fk = ' . $this->db->quote(
182 $this->lastHandledForumId,
183 'integer'
184 );
185 $res_thr = $this->db->query($query_num_threads);
186 $data_thr = $this->db->fetchAssoc($res_thr);
187 $num_threads = (
int) $data_thr[
'cnt'];
188
189 $update_str = null;
190 if ($this->lastHandledPostId !== 0) {
191 $update_str = implode('#', [
192 (string) $this->lastHandledForumId,
193 (string) $this->lastHandledThreadId,
194 (string) $this->lastHandledPostId
195 ]);
196 }
197
198 $this->db->manipulateF(
199 'UPDATE frm_data
200 SET top_last_post = %s,
201 top_num_posts = %s,
202 top_num_threads = %s,
203 top_usr_id = %s
204 WHERE top_frm_fk = %s',
205 ['text', 'integer', 'integer', 'integer', 'integer'],
206 [$update_str, $num_posts, $num_threads, $this->frm_last_mapped_top_usr_id, $this->forum_obj_id]
207 );
208
210 break;
211
212 case 'Id':
214 break;
215
216 case 'ObjId':
218 break;
219
220 case 'Title':
222 break;
223
224 case 'Description':
226 break;
227
228 case 'DefaultView':
230 break;
231
232 case 'Pseudonyms':
234 break;
235
236 case 'Statistics':
238 break;
239
240 case 'ThreadRatings':
242 break;
243
244 case 'PostingActivation':
246 break;
247
248 case 'PresetSubject':
250 break;
251
252 case 'PresetRe':
254 break;
255
256 case 'NotificationType':
258 break;
259
260 case 'NotificationEvents':
262 break;
263
264 case 'ForceNotification':
266 break;
267
268 case 'ToggleNotification':
270 break;
271
272 case 'LastPost':
274 break;
275
276 case 'Moderator':
278 break;
279
280 case 'CreateDate':
282 break;
283
284 case 'UpdateDate':
286 break;
287
288 case 'FileUpload':
290 break;
291
292 case 'UpdateUserId':
294 break;
295
296 case 'AuthorId':
298 break;
299 case 'isAuthorModerator':
301 break;
302
303 case 'UserId':
305 if ($this->entity === 'forum' && $this->forumArray !== []) {
307
308
309 $this->forum->createSettings();
310
312 (int) ($this->forumArray['UserId'] ?? 0),
313 ''
314 );
315 $this->frm_last_mapped_top_usr_id = $forum_array['usr_id'];
316
318 (int) ($this->forumArray['UpdateUserId'] ?? 0),
319 ''
320 );
321
322
323
324
326 $this->forum->setDescription(
328 );
329 $this->forum->update();
330 $this->forum->updateModificationUserId($update_forum_array['usr_id']);
331
333 $newObjProp->setDefaultView(
335 );
336 $newObjProp->setAnonymisation((bool) ($this->forumArray['Pseudonyms'] ?? false));
337 $newObjProp->setStatisticsStatus((bool) ($this->forumArray['Statistics'] ?? false));
338 $newObjProp->setIsThreadRatingEnabled((bool) ($this->forumArray['ThreadRatings'] ?? false));
339 $newObjProp->setPostActivation((bool) ($this->forumArray['PostingActivation'] ?? false));
340 $newObjProp->setPresetSubject((bool) ($this->forumArray['PresetSubject'] ?? false));
341 $newObjProp->setAddReSubject((bool) ($this->forumArray['PresetRe'] ?? false));
342 $newObjProp->setNotificationType(
343 NotificationType::tryFrom(
344 $this->forumArray['NotificationType'] ?? NotificationType::ALL_USERS->value
345 ) ?? NotificationType::ALL_USERS
346 );
347 $newObjProp->setInterestedEvents((int) ($this->forumArray['NotificationEvents'] ?? 0));
348 $newObjProp->setAdminForceNoti((bool) ($this->forumArray['ForceNotification'] ?? false));
349 $newObjProp->setUserToggleNoti((bool) ($this->forumArray['ToggleNotification'] ?? false));
350 $newObjProp->setFileUploadAllowed((bool) ($this->forumArray['FileUpload'] ?? false));
351 $newObjProp->setMarkModeratorPosts((bool) ($this->forumArray['MarkModeratorPosts'] ?? false));
352 $newObjProp->update();
353
355 $this->forum_obj_id = $newObjProp->getObjId();
356 $this->mapping[
'frm'][$this->forumArray[
'Id']] =
$id;
357 $this->lastHandledForumId =
$id;
358
359 $this->importMapping->addMapping(
360 'components/ILIAS/COPage',
361 'pg',
362 'frm:' . $this->forumArray['ObjId'],
363 'frm:' . $this->forum->getId()
364 );
365
366 if ($this->last_handled_style_id) {
368 $this->last_handled_style_id = null;
369 }
370
371 $this->forumArray = [];
372 }
373 break;
374
375 case 'Thread':
376 $update_str = null;
377 if ($this->lastHandledPostId !== 0) {
378 $update_str = implode('#', [
379 (string) $this->lastHandledForumId,
380 (string) $this->lastHandledThreadId,
381 (string) $this->lastHandledPostId
382 ]);
383 }
384
385 $this->db->manipulateF(
386 'UPDATE frm_threads SET thr_last_post = %s WHERE thr_pk = %s',
387 ['text', 'integer'],
388 [$update_str, $this->lastHandledThreadId]
389 );
390 break;
391
392 case 'Subject':
394 break;
395
396 case 'Alias':
398 break;
399
400 case 'Sticky':
402 break;
403
404 case 'MarkModeratorPosts':
406 break;
407
408 case 'Closed':
410
411 if ($this->entity === 'thread' && $this->lastHandledForumId && $this->threadArray !== []) {
413 $this->forumThread->setId((int) $this->threadArray['Id']);
414 $this->forumThread->setForumId($this->lastHandledForumId);
415 $this->forumThread->setSubject(
417 );
418 $this->forumThread->setSticky((bool) ($this->threadArray['Sticky'] ?? false));
419 $this->forumThread->setClosed((bool) ($this->threadArray['Closed'] ?? false));
420
421 $this->forumThread->setImportName(
422 isset($this->threadArray['ImportName']) ?
424 null
425 );
426 $this->forumThread->setCreateDate($this->threadArray['CreateDate']);
427 $this->forumThread->setChangeDate($this->threadArray['UpdateDate']);
428
430 (int) ($this->threadArray['UserId'] ?? 0),
432 );
433
434 $this->forumThread->setDisplayUserId($usr_data['usr_id']);
435 $this->forumThread->setUserAlias($usr_data['usr_alias']);
436
438 $this->threadArray['AuthorId'] = $this->threadArray['UserId'];
439 }
440
442 (int) ($this->threadArray['AuthorId'] ?? 0)
443 );
444 $this->forumThread->setThrAuthorId($author_id_data['usr_id']);
445
446 $this->forumThread->insert();
447
448 $this->mapping['thr'][$this->threadArray['Id']] = $this->forumThread->getId();
449 $this->lastHandledThreadId = $this->forumThread->getId();
450 $this->threadArray = [];
451 }
452 break;
453
454 case 'Post':
455 break;
456
457 case 'Censorship':
459 break;
460
461 case 'CensorshipMessage':
463 break;
464
465 case 'Notification':
467 break;
468
469 case 'ImportName':
471 break;
472
473 case 'Status':
475 break;
476
477 case 'Message':
479 break;
480
481 case 'Lft':
483 break;
484
485 case 'Rgt':
487 break;
488
489 case 'Depth':
491 break;
492
493 case 'ParentId':
495
496 if (
497 $this->entity === 'post' &&
498 $this->lastHandledForumId &&
499 $this->postArray !== [] &&
500 $this->forumThread &&
501 $this->lastHandledThreadId
502 ) {
504 $this->forumPost->setThread($this->forumThread);
505
506 $this->forumPost->setId((int) $this->postArray['Id']);
507 $this->forumPost->setCensorship((bool) ($this->postArray['Censorship'] ?? false));
508 $this->forumPost->setCensorshipComment(
510 );
511 $this->forumPost->setNotification((bool) ($this->postArray['Notification'] ?? false));
512 $this->forumPost->setStatus((bool) ($this->postArray['Status'] ?? false));
514 $this->forumPost->setMessage($purifier->purify((string) ($this->postArray['Message'] ?? '')));
515 $this->forumPost->setSubject(
ilUtil::stripSlashes((
string) ($this->postArray[
'Subject'] ??
'')));
516 $this->forumPost->setLft((int) $this->postArray['Lft']);
517 $this->forumPost->setRgt((int) $this->postArray['Rgt']);
518 $this->forumPost->setDepth((int) $this->postArray['Depth']);
519 $this->forumPost->setParentId((int) $this->postArray['ParentId']);
520 $this->forumPost->setThreadId($this->lastHandledThreadId);
521 $this->forumPost->setForumId($this->lastHandledForumId);
522
523 $this->forumPost->setImportName(
524 isset($this->postArray['ImportName']) ?
526 null
527 );
528 $this->forumPost->setCreateDate($this->postArray['CreateDate']);
529 $this->forumPost->setChangeDate($this->postArray['UpdateDate']);
530
532 (int) ($this->postArray['UserId'] ?? 0),
534 );
536 (int) ($this->postArray['UpdateUserId'] ?? 0)
537 );
538 $this->forumPost->setDisplayUserId($usr_data['usr_id']);
539 $this->forumPost->setUserAlias($usr_data['usr_alias']);
540 $this->forumPost->setUpdateUserId($update_usr_data['usr_id']);
541
543 $this->postArray['AuthorId'] = $this->postArray['UserId'];
544 }
546 (int) ($this->postArray['AuthorId'] ?? 0)
547 );
548 $this->forumPost->setPosAuthorId((int) $author_id_data['usr_id']);
549
550 if (isset($this->postArray['isAuthorModerator']) && strtoupper($this->postArray['isAuthorModerator']) === 'NULL') {
551 $this->forumPost->setIsAuthorModerator(false);
552 } else {
553 $this->forumPost->setIsAuthorModerator((bool) $this->postArray['isAuthorModerator']);
554 }
555
556 $this->forumPost->insert();
557
558 if (isset($this->postArray['ParentId'], $this->mapping['pos'][$this->postArray['ParentId']])) {
559 $parent_id = (
int) $this->mapping[
'pos'][$this->postArray[
'ParentId']];
560 } else {
561 $parent_id = 0;
562 }
563
564 if ($parent_id === 0 && (int) $this->postArray['Lft'] > 1) {
566 (int) $this->postArray['Lft'],
567 (int) $this->postArray['Rgt']
568 );
569 }
570
571 $postTreeNodeId = $this->db->nextId('frm_posts_tree');
572 $this->db->insert('frm_posts_tree', [
573 'fpt_pk' => ['integer', $postTreeNodeId],
574 'thr_fk' => ['integer', $this->lastHandledThreadId],
575 'pos_fk' => ['integer', $this->forumPost->getId()],
576 'parent_pos' => ['integer', $parent_id],
577 'lft' => ['integer', $this->postArray['Lft']],
578 'rgt' => ['integer', $this->postArray['Rgt']],
579 'depth' => ['integer', $this->postArray['Depth']],
580 'fpt_date' => ['timestamp', date('Y-m-d H:i:s')]
581 ]);
582
583 $this->mapping['pos'][$this->postArray['Id']] = $this->forumPost->getId();
584 $this->post_tree_structure[] = [
585 'id' => (
int) $this->postArray[
'Id'],
586 'lft' => (int) $this->postArray['Lft'],
587 'rgt' => (
int) $this->postArray[
'Rgt'],
588 'new_id' => $this->forumPost->getId()
589 ];
590 $this->lastHandledPostId = $this->forumPost->getId();
591
592 $media_objects_found = false;
593 foreach ($this->mediaObjects as $mob_attr) {
595 if (is_file($importfile)) {
597 basename($importfile),
598 $importfile,
599 false
600 );
602
603 $this->forumPost->setMessage(
604 str_replace(
605 [
606 'src="' . $mob_attr['label'] . '"',
607 'src="' . preg_replace(
608 "/(il)_[\d]+_(mob)_([\d]+)/",
609 '$1_0_$2_$3',
610 $mob_attr['label']
611 ) . '"'
612 ],
613 'src="' .
'il_' .
IL_INST_ID .
'_mob_' . $mob->getId() .
'"',
614 $this->forumPost->getMessage()
615 )
616 );
617 $media_objects_found = true;
618 }
619 }
620
621 if ($media_objects_found) {
622 $this->forumPost->update();
623 }
624 $this->postArray = [];
625 }
626
627 break;
628
629 case 'Content':
631 break;
632
633 case 'Attachment':
634 $filedata =
new ilFileDataForum($this->forum->getId(), $this->lastHandledPostId);
635
636 $import_path = $this->contentArray['content'];
637 if ($import_path !== '') {
639 $filedata->importPath($import_path, (int) $this->lastHandledPostId);
640 }
641 break;
642 }
643
644 $this->cdata = '';
645 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static getInstance(int $a_obj_id=0)
int $last_handled_style_id
determineParentFromNestedSet(int $lft, int $rgt)
Find the closest parent using Nested Set values in memory.
getUserIdAndAlias(int $imp_usr_id, string $imp_usr_alias='')
static getInstanceByType(string $type)
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")