154 : void
155 {
156 $this->cdata = trim($this->cdata);
157 $property = strtolower($this->entity) . 'Array';
158
159 if (!property_exists($this, $property)) {
160 return;
161 }
162
163 $propertyValue = &$this->{$property};
164
165 switch ($a_name) {
166 case 'Forum':
167 $query_num_posts = 'SELECT COUNT(pos_pk) cnt FROM frm_posts WHERE pos_top_fk = ' . $this->db->quote(
168 $this->lastHandledForumId,
169 'integer'
170 );
171 $res_pos = $this->db->query($query_num_posts);
172 $data_pos = $this->db->fetchAssoc($res_pos);
173 $num_posts = (
int) $data_pos[
'cnt'];
174
175 $query_num_threads = 'SELECT COUNT(thr_pk) cnt FROM frm_threads WHERE thr_top_fk = ' . $this->db->quote(
176 $this->lastHandledForumId,
177 'integer'
178 );
179 $res_thr = $this->db->query($query_num_threads);
180 $data_thr = $this->db->fetchAssoc($res_thr);
181 $num_threads = (
int) $data_thr[
'cnt'];
182
183 $update_str = null;
184 if ($this->lastHandledPostId !== 0) {
185 $update_str = implode('#', [
186 (string) $this->lastHandledForumId,
187 (string) $this->lastHandledThreadId,
188 (string) $this->lastHandledPostId
189 ]);
190 }
191
192 $this->db->manipulateF(
193 'UPDATE frm_data
194 SET top_last_post = %s,
195 top_num_posts = %s,
196 top_num_threads = %s,
197 top_usr_id = %s
198 WHERE top_frm_fk = %s',
199 ['text', 'integer', 'integer', 'integer', 'integer'],
200 [$update_str, $num_posts, $num_threads, $this->frm_last_mapped_top_usr_id, $this->forum_obj_id]
201 );
202
204 break;
205
206 case 'Id':
208 break;
209
210 case 'ObjId':
212 break;
213
214 case 'Title':
216 break;
217
218 case 'Description':
220 break;
221
222 case 'DefaultView':
224 break;
225
226 case 'Pseudonyms':
228 break;
229
230 case 'Statistics':
232 break;
233
234 case 'ThreadRatings':
236 break;
237
238 case 'PostingActivation':
240 break;
241
242 case 'PresetSubject':
244 break;
245
246 case 'PresetRe':
248 break;
249
250 case 'NotificationType':
252 break;
253
254 case 'NotificationEvents':
256 break;
257
258 case 'ForceNotification':
260 break;
261
262 case 'ToggleNotification':
264 break;
265
266 case 'LastPost':
268 break;
269
270 case 'Moderator':
272 break;
273
274 case 'CreateDate':
276 break;
277
278 case 'UpdateDate':
280 break;
281
282 case 'FileUpload':
284 break;
285
286 case 'UpdateUserId':
288 break;
289
290 case 'AuthorId':
292 break;
293 case 'isAuthorModerator':
295 break;
296
297 case 'UserId':
299 if ($this->entity === 'forum' && $this->forumArray !== []) {
301
302
303 $this->forum->createSettings();
304
306 (int) ($this->forumArray['UserId'] ?? 0),
307 ''
308 );
309 $this->frm_last_mapped_top_usr_id = $forum_array['usr_id'];
310
312 (int) ($this->forumArray['UpdateUserId'] ?? 0),
313 ''
314 );
315
316
317
318
320 $this->forum->setDescription(
322 );
323 $this->forum->update();
324 $this->forum->updateModificationUserId($update_forum_array['usr_id']);
325
327 $newObjProp->setDefaultView(
329 );
330 $newObjProp->setAnonymisation((bool) ($this->forumArray['Pseudonyms'] ?? false));
331 $newObjProp->setStatisticsStatus((bool) ($this->forumArray['Statistics'] ?? false));
332 $newObjProp->setIsThreadRatingEnabled((bool) ($this->forumArray['ThreadRatings'] ?? false));
333 $newObjProp->setPostActivation((bool) ($this->forumArray['PostingActivation'] ?? false));
334 $newObjProp->setPresetSubject((bool) ($this->forumArray['PresetSubject'] ?? false));
335 $newObjProp->setAddReSubject((bool) ($this->forumArray['PresetRe'] ?? false));
336 $newObjProp->setNotificationType(
337 NotificationType::tryFrom(
338 $this->forumArray['NotificationType'] ?? NotificationType::ALL_USERS->value
339 ) ?? NotificationType::ALL_USERS
340 );
341 $newObjProp->setInterestedEvents((int) ($this->forumArray['NotificationEvents'] ?? 0));
342 $newObjProp->setAdminForceNoti((bool) ($this->forumArray['ForceNotification'] ?? false));
343 $newObjProp->setUserToggleNoti((bool) ($this->forumArray['ToggleNotification'] ?? false));
344 $newObjProp->setFileUploadAllowed((bool) ($this->forumArray['FileUpload'] ?? false));
345 $newObjProp->setMarkModeratorPosts((bool) ($this->forumArray['MarkModeratorPosts'] ?? false));
346 $newObjProp->update();
347
349 $this->forum_obj_id = $newObjProp->getObjId();
350 $this->mapping[
'frm'][$this->forumArray[
'Id']] =
$id;
351 $this->lastHandledForumId =
$id;
352
353 $this->importMapping->addMapping(
354 'components/ILIAS/COPage',
355 'pg',
356 'frm:' . $this->forumArray['ObjId'],
357 'frm:' . $this->forum->getId()
358 );
359
360 if ($this->last_handled_style_id) {
362 $this->last_handled_style_id = null;
363 }
364
365 $this->forumArray = [];
366 }
367 break;
368
369 case 'Thread':
370 $update_str = null;
371 if ($this->lastHandledPostId !== 0) {
372 $update_str = implode('#', [
373 (string) $this->lastHandledForumId,
374 (string) $this->lastHandledThreadId,
375 (string) $this->lastHandledPostId
376 ]);
377 }
378
379 $this->db->manipulateF(
380 'UPDATE frm_threads SET thr_last_post = %s WHERE thr_pk = %s',
381 ['text', 'integer'],
382 [$update_str, $this->lastHandledThreadId]
383 );
384 break;
385
386 case 'Subject':
388 break;
389
390 case 'Alias':
392 break;
393
394 case 'Sticky':
396 break;
397
398 case 'MarkModeratorPosts':
400 break;
401
402 case 'Closed':
404
405 if ($this->entity === 'thread' && $this->lastHandledForumId && $this->threadArray !== []) {
407 $this->forumThread->setId((int) ($this->threadArray['Id'] ?? 0));
408 $this->forumThread->setForumId($this->lastHandledForumId);
409 $this->forumThread->setSubject(
411 );
412 $this->forumThread->setSticky((bool) ($this->threadArray['Sticky'] ?? false));
413 $this->forumThread->setClosed((bool) ($this->threadArray['Closed'] ?? false));
414
415 $this->forumThread->setImportName(
416 isset($this->threadArray['ImportName']) ?
418 null
419 );
420 $this->forumThread->setCreateDate($this->threadArray['CreateDate']);
421 $this->forumThread->setChangeDate($this->threadArray['UpdateDate']);
422
424 (int) ($this->threadArray['UserId'] ?? 0),
426 );
427
428 $this->forumThread->setDisplayUserId($usr_data['usr_id']);
429 $this->forumThread->setUserAlias($usr_data['usr_alias']);
430
432 $this->threadArray['AuthorId'] = $this->threadArray['UserId'];
433 }
434
436 (int) ($this->threadArray['AuthorId'] ?? 0)
437 );
438 $this->forumThread->setThrAuthorId($author_id_data['usr_id']);
439
440 $this->forumThread->insert();
441
442 $this->mapping['thr'][$this->threadArray['Id']] = $this->forumThread->getId();
443 $this->lastHandledThreadId = $this->forumThread->getId();
444 $this->threadArray = [];
445 }
446 break;
447
448 case 'Post':
449 break;
450
451 case 'Censorship':
453 break;
454
455 case 'CensorshipMessage':
457 break;
458
459 case 'Notification':
461 break;
462
463 case 'ImportName':
465 break;
466
467 case 'Status':
469 break;
470
471 case 'Message':
473 break;
474
475 case 'Lft':
477 break;
478
479 case 'Rgt':
481 break;
482
483 case 'Depth':
485 break;
486
487 case 'ParentId':
489
490 if (
491 $this->entity === 'post' &&
492 $this->lastHandledForumId &&
493 $this->postArray !== [] &&
494 $this->forumThread &&
495 $this->lastHandledThreadId
496 ) {
498 $this->forumPost->setThread($this->forumThread);
499
500 $this->forumPost->setId((int) $this->postArray['Id']);
501 $this->forumPost->setCensorship((bool) ($this->postArray['Censorship'] ?? false));
502 $this->forumPost->setCensorshipComment(
504 );
505 $this->forumPost->setNotification((bool) ($this->postArray['Notification'] ?? false));
506 $this->forumPost->setStatus((bool) ($this->postArray['Status'] ?? false));
508 $this->forumPost->setMessage($purifier->purify((string) ($this->postArray['Message'] ?? '')));
509 $this->forumPost->setSubject(
ilUtil::stripSlashes((
string) ($this->postArray[
'Subject'] ??
'')));
510 $this->forumPost->setLft((int) $this->postArray['Lft']);
511 $this->forumPost->setRgt((int) $this->postArray['Rgt']);
512 $this->forumPost->setDepth((int) $this->postArray['Depth']);
513 $this->forumPost->setParentId((int) $this->postArray['ParentId']);
514 $this->forumPost->setThreadId($this->lastHandledThreadId);
515 $this->forumPost->setForumId($this->lastHandledForumId);
516
517 $this->forumPost->setImportName(
518 isset($this->postArray['ImportName']) ?
520 null
521 );
522 $this->forumPost->setCreateDate($this->postArray['CreateDate']);
523 $this->forumPost->setChangeDate($this->postArray['UpdateDate']);
524
526 (int) ($this->postArray['UserId'] ?? 0),
528 );
530 (int) ($this->postArray['UpdateUserId'] ?? 0)
531 );
532 $this->forumPost->setDisplayUserId($usr_data['usr_id']);
533 $this->forumPost->setUserAlias($usr_data['usr_alias']);
534 $this->forumPost->setUpdateUserId($update_usr_data['usr_id']);
535
537 $this->postArray['AuthorId'] = $this->postArray['UserId'];
538 }
540 (int) ($this->postArray['AuthorId'] ?? 0)
541 );
542 $this->forumPost->setPosAuthorId((int) $author_id_data['usr_id']);
543
544 if (isset($this->postArray['isAuthorModerator']) && strtoupper($this->postArray['isAuthorModerator']) === 'NULL') {
545 $this->forumPost->setIsAuthorModerator(false);
546 } else {
547 $this->forumPost->setIsAuthorModerator((bool) $this->postArray['isAuthorModerator']);
548 }
549
550 $this->forumPost->insert();
551
552 if (isset($this->postArray['ParentId'], $this->mapping['pos'][$this->postArray['ParentId']])) {
553 $parentId = (
int) $this->mapping[
'pos'][$this->postArray[
'ParentId']];
554 } else {
555 $parentId = 0;
556 }
557
558 $postTreeNodeId = $this->db->nextId('frm_posts_tree');
559 $this->db->insert('frm_posts_tree', [
560 'fpt_pk' => ['integer', $postTreeNodeId],
561 'thr_fk' => ['integer', $this->lastHandledThreadId],
562 'pos_fk' => ['integer', $this->forumPost->getId()],
563 'parent_pos' => ['integer', $parentId],
564 'lft' => ['integer', $this->postArray['Lft']],
565 'rgt' => ['integer', $this->postArray['Rgt']],
566 'depth' => ['integer', $this->postArray['Depth']],
567 'fpt_date' => ['timestamp', date('Y-m-d H:i:s')]
568 ]);
569
570 $this->mapping['pos'][($this->postArray['Id'] ?? 0)] = $this->forumPost->getId();
571 $this->lastHandledPostId = $this->forumPost->getId();
572
573 $media_objects_found = false;
574 foreach ($this->mediaObjects as $mob_attr) {
576 if (is_file($importfile)) {
578 basename($importfile),
579 $importfile,
580 false
581 );
583
584 $this->forumPost->setMessage(
585 str_replace(
586 [
587 'src="' . $mob_attr['label'] . '"',
588 'src="' . preg_replace(
589 "/(il)_[\d]+_(mob)_([\d]+)/",
590 '$1_0_$2_$3',
591 $mob_attr['label']
592 ) . '"'
593 ],
594 'src="' .
'il_' .
IL_INST_ID .
'_mob_' . $mob->getId() .
'"',
595 $this->forumPost->getMessage()
596 )
597 );
598 $media_objects_found = true;
599 }
600 }
601
602 if ($media_objects_found) {
603 $this->forumPost->update();
604 }
605 $this->postArray = [];
606 }
607
608 break;
609
610 case 'Content':
612 break;
613
614 case 'Attachment':
615 $filedata =
new ilFileDataForum($this->forum->getId(), $this->lastHandledPostId);
616
617 $import_path = $this->contentArray['content'];
618 if ($import_path !== '') {
620 $filedata->importPath($import_path, (int) $this->lastHandledPostId);
621 }
622 break;
623 }
624
625 $this->cdata = '';
626 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static getInstance(int $a_obj_id=0)
int $last_handled_style_id
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="")