ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilForumXMLParser.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
28  public static array $style_map = [];
29 
30  private string $entity = '';
31  private array $mapping = [
32  'frm' => [],
33  'thr' => [],
34  'pos' => []
35  ];
36  private readonly ilDBInterface $db;
37  private readonly ilObjUser $aobject;
40  private ?string $importDirectory = null;
41  private ?string $schema_version = null;
42  private string $cdata = '';
43 
44  private ?ilForumTopic $forumThread = null;
45  private ?ilForumPost $forumPost = null;
46  private ?int $forum_obj_id = null;
47  private ?int $frm_last_mapped_top_usr_id = null;
48  private ?int $lastHandledForumId = null;
49  private ?int $lastHandledThreadId = null;
50  private ?int $lastHandledPostId = null;
51  private ?int $last_handled_style_id = null;
52  private array $forumArray = [];
53  private array $postArray = [];
54  private array $threadArray = [];
55  private array $contentArray = [
56  'content' => ''
57  ];
58  private array $user_id_mapping = [];
59  private array $mediaObjects = [];
60 
61  protected \ILIAS\Style\Content\DomainService $content_style_domain;
62 
63  public function __construct(
64  private readonly ilObjForum $forum,
65  string $a_xml_data,
66  private readonly ilImportMapping $importMapping
67  ) {
68  global $DIC;
69 
70  $this->db = $DIC->database();
71  $this->aobject = new ilObjUser(ANONYMOUS_USER_ID);
72 
74 
75  $this->content_style_domain = $DIC
76  ->contentStyle()
77  ->domain();
78 
79  $this->setXMLContent('<?xml version="1.0" encoding="utf-8"?>' . $a_xml_data);
80  }
81 
82  public function setImportDirectory(?string $a_val): void
83  {
84  $this->importDirectory = $a_val;
85  }
86 
87  public function getImportDirectory(): ?string
88  {
90  }
91 
92  public function getSchemaVersion(): ?string
93  {
94  return $this->schema_version;
95  }
96 
97  public function setSchemaVersion(?string $schema_version): void
98  {
99  $this->schema_version = $schema_version;
100  }
101 
102  public function setHandlers($a_xml_parser): void
103  {
104  xml_set_object($a_xml_parser, $this);
105  xml_set_element_handler(
106  $a_xml_parser,
107  function (XMLParser $a_xml_parser, string $a_name, array $a_attribs): void {
108  $this->handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
109  },
110  function (XMLParser $a_xml_parser, string $a_name): void {
111  $this->handlerEndTag($a_xml_parser, $a_name);
112  }
113  );
114  xml_set_character_data_handler($a_xml_parser, function (XMLParser $a_xml_parser, string $a_data): void {
115  $this->handlerCharacterData($a_xml_parser, $a_data);
116  });
117  }
118 
119  public function handlerBeginTag(XMLParser $a_xml_parser, string $a_name, array $a_attribs): void
120  {
121  switch ($a_name) {
122  case 'Forum':
123  $this->entity = 'forum';
124  $this->forumArray = [];
125  break;
126 
127  case 'Thread':
128  $this->entity = 'thread';
129  $this->threadArray = [];
130  break;
131 
132  case 'Post':
133  $this->entity = 'post';
134  $this->postArray = [];
135  $this->mediaObjects = [];
136  break;
137 
138  case 'Content':
139  $this->entity = 'content';
140  $this->contentArray = [
141  'content' => ''
142  ];
143  break;
144 
145  case 'MediaObject':
146  $this->mediaObjects[] = $a_attribs;
147  break;
148  }
149 
150  if (isset($a_attribs['Style'])) {
151  $this->last_handled_style_id = (int) $a_attribs['Style'];
152  }
153  }
154 
155  public function handlerEndTag(XMLParser $a_xml_parser, string $a_name): void
156  {
157  $this->cdata = trim($this->cdata);
158  $property = strtolower($this->entity) . 'Array';
159 
160  if (!property_exists($this, $property)) {
161  return;
162  }
163 
164  $propertyValue = &$this->{$property};
165 
166  switch ($a_name) {
167  case 'Forum':
168  $query_num_posts = 'SELECT COUNT(pos_pk) cnt FROM frm_posts WHERE pos_top_fk = ' . $this->db->quote(
169  $this->lastHandledForumId,
170  'integer'
171  );
172  $res_pos = $this->db->query($query_num_posts);
173  $data_pos = $this->db->fetchAssoc($res_pos);
174  $num_posts = (int) $data_pos['cnt'];
175 
176  $query_num_threads = 'SELECT COUNT(thr_pk) cnt FROM frm_threads WHERE thr_top_fk = ' . $this->db->quote(
177  $this->lastHandledForumId,
178  'integer'
179  );
180  $res_thr = $this->db->query($query_num_threads);
181  $data_thr = $this->db->fetchAssoc($res_thr);
182  $num_threads = (int) $data_thr['cnt'];
183 
184  $update_str = null;
185  if ($this->lastHandledPostId !== 0) {
186  $update_str = implode('#', [
187  (string) $this->lastHandledForumId,
188  (string) $this->lastHandledThreadId,
189  (string) $this->lastHandledPostId
190  ]);
191  }
192 
193  $this->db->manipulateF(
194  'UPDATE frm_data
195  SET top_last_post = %s,
196  top_num_posts = %s,
197  top_num_threads = %s,
198  top_usr_id = %s
199  WHERE top_frm_fk = %s',
200  ['text', 'integer', 'integer', 'integer', 'integer'],
201  [$update_str, $num_posts, $num_threads, $this->frm_last_mapped_top_usr_id, $this->forum_obj_id]
202  );
203 
204  ilLPStatusWrapper::_refreshStatus($this->forum->getId());
205  break;
206 
207  case 'Id':
208  $propertyValue['Id'] = $this->cdata;
209  break;
210 
211  case 'ObjId':
212  $propertyValue['ObjId'] = $this->cdata;
213  break;
214 
215  case 'Title':
216  $propertyValue['Title'] = $this->cdata;
217  break;
218 
219  case 'Description':
220  $propertyValue['Description'] = $this->cdata;
221  break;
222 
223  case 'DefaultView':
224  $propertyValue['DefaultView'] = $this->cdata;
225  break;
226 
227  case 'Pseudonyms':
228  $propertyValue['Pseudonyms'] = $this->cdata;
229  break;
230 
231  case 'Statistics':
232  $propertyValue['Statistics'] = $this->cdata;
233  break;
234 
235  case 'ThreadRatings':
236  $propertyValue['ThreadRatings'] = $this->cdata;
237  break;
238 
239  case 'PostingActivation':
240  $propertyValue['PostingActivation'] = $this->cdata;
241  break;
242 
243  case 'PresetSubject':
244  $propertyValue['PresetSubject'] = $this->cdata;
245  break;
246 
247  case 'PresetRe':
248  $propertyValue['PresetRe'] = $this->cdata;
249  break;
250 
251  case 'NotificationType':
252  $propertyValue['NotificationType'] = $this->cdata;
253  break;
254 
255  case 'NotificationEvents':
256  $propertyValue['NotificationEvents'] = $this->cdata;
257  break;
258 
259  case 'ForceNotification':
260  $propertyValue['ForceNotification'] = $this->cdata;
261  break;
262 
263  case 'ToggleNotification':
264  $propertyValue['ToggleNotification'] = $this->cdata;
265  break;
266 
267  case 'LastPost':
268  $propertyValue['LastPost'] = $this->cdata;
269  break;
270 
271  case 'Moderator':
272  $propertyValue['Moderator'] = $this->cdata;
273  break;
274 
275  case 'CreateDate':
276  $propertyValue['CreateDate'] = $this->cdata;
277  break;
278 
279  case 'UpdateDate':
280  $propertyValue['UpdateDate'] = $this->cdata;
281  break;
282 
283  case 'FileUpload':
284  $propertyValue['FileUpload'] = $this->cdata;
285  break;
286 
287  case 'UpdateUserId':
288  $propertyValue['UpdateUserId'] = $this->cdata;
289  break;
290 
291  case 'AuthorId':
292  $propertyValue['AuthorId'] = $this->cdata;
293  break;
294  case 'isAuthorModerator':
295  $propertyValue['isAuthorModerator'] = $this->cdata;
296  break;
297 
298  case 'UserId':
299  $propertyValue['UserId'] = $this->cdata;
300  if ($this->entity === 'forum' && $this->forumArray !== []) {
302  // createSettings accesses superglobal $_GET array, which can cause problems
303  // with public_notifications of block settings
304  $this->forum->createSettings();
305 
306  $forum_array = $this->getUserIdAndAlias(
307  (int) ($this->forumArray['UserId'] ?? 0),
308  ''
309  );
310  $this->frm_last_mapped_top_usr_id = $forum_array['usr_id'];
311 
312  $update_forum_array = $this->getUserIdAndAlias(
313  (int) ($this->forumArray['UpdateUserId'] ?? 0),
314  ''
315  );
316  // Store old user id
317  // Manipulate user object
318  // changed smeyer 28.7.16: the session id is not manipulated
319  // anymore. Instead the user is passwd ilObjForum::update()
320  $this->forum->setTitle(ilUtil::stripSlashes((string) ($this->forumArray['Title'] ?? '')));
321  $this->forum->setDescription(
322  ilUtil::stripSlashes((string) ($this->forumArray['Description'] ?? ''))
323  );
324  $this->forum->update();
325  $this->forum->updateModificationUserId($update_forum_array['usr_id']);
326 
327  $newObjProp = ilForumProperties::getInstance($this->forum->getId());
328  $newObjProp->setDefaultView(
329  (int) ($this->forumArray['DefaultView'] ?? ilForumProperties::VIEW_TREE)
330  );
331  $newObjProp->setAnonymisation((bool) ($this->forumArray['Pseudonyms'] ?? false));
332  $newObjProp->setStatisticsStatus((bool) ($this->forumArray['Statistics'] ?? false));
333  $newObjProp->setIsThreadRatingEnabled((bool) ($this->forumArray['ThreadRatings'] ?? false));
334  $newObjProp->setPostActivation((bool) ($this->forumArray['PostingActivation'] ?? false));
335  $newObjProp->setPresetSubject((bool) ($this->forumArray['PresetSubject'] ?? false));
336  $newObjProp->setAddReSubject((bool) ($this->forumArray['PresetRe'] ?? false));
337  $newObjProp->setNotificationType(
338  NotificationType::tryFrom(
339  $this->forumArray['NotificationType'] ?? NotificationType::ALL_USERS->value
340  ) ?? NotificationType::ALL_USERS
341  );
342  $newObjProp->setInterestedEvents((int) ($this->forumArray['NotificationEvents'] ?? 0));
343  $newObjProp->setAdminForceNoti((bool) ($this->forumArray['ForceNotification'] ?? false));
344  $newObjProp->setUserToggleNoti((bool) ($this->forumArray['ToggleNotification'] ?? false));
345  $newObjProp->setFileUploadAllowed((bool) ($this->forumArray['FileUpload'] ?? false));
346  $newObjProp->setMarkModeratorPosts((bool) ($this->forumArray['MarkModeratorPosts'] ?? false));
347  $newObjProp->update();
348 
349  $id = $this->getNewForumPk();
350  $this->forum_obj_id = $newObjProp->getObjId();
351  $this->mapping['frm'][$this->forumArray['Id']] = $id;
352  $this->lastHandledForumId = $id;
353 
354  $this->importMapping->addMapping(
355  'components/ILIAS/COPage',
356  'pg',
357  'frm:' . $this->forumArray['ObjId'],
358  'frm:' . $this->forum->getId()
359  );
360 
361  if ($this->last_handled_style_id) {
362  self::$style_map[$this->last_handled_style_id][] = $newObjProp->getObjId();
363  $this->last_handled_style_id = null;
364  }
365 
366  $this->forumArray = [];
367  }
368  break;
369 
370  case 'Thread':
371  $update_str = null;
372  if ($this->lastHandledPostId !== 0) {
373  $update_str = implode('#', [
374  (string) $this->lastHandledForumId,
375  (string) $this->lastHandledThreadId,
376  (string) $this->lastHandledPostId
377  ]);
378  }
379 
380  $this->db->manipulateF(
381  'UPDATE frm_threads SET thr_last_post = %s WHERE thr_pk = %s',
382  ['text', 'integer'],
383  [$update_str, $this->lastHandledThreadId]
384  );
385  break;
386 
387  case 'Subject':
388  $propertyValue['Subject'] = $this->cdata;
389  break;
390 
391  case 'Alias':
392  $propertyValue['Alias'] = $this->cdata;
393  break;
394 
395  case 'Sticky':
396  $propertyValue['Sticky'] = $this->cdata;
397  break;
398 
399  case 'MarkModeratorPosts':
400  $propertyValue['MarkModeratorPosts'] = $this->cdata;
401  break;
402 
403  case 'Closed':
404  $propertyValue['Closed'] = $this->cdata;
405 
406  if ($this->entity === 'thread' && $this->lastHandledForumId && $this->threadArray !== []) {
407  $this->forumThread = new ilForumTopic();
408  $this->forumThread->setId((int) ($this->threadArray['Id'] ?? 0));
409  $this->forumThread->setForumId($this->lastHandledForumId);
410  $this->forumThread->setSubject(
411  ilUtil::stripSlashes((string) ($this->threadArray['Subject'] ?? ''))
412  );
413  $this->forumThread->setSticky((bool) ($this->threadArray['Sticky'] ?? false));
414  $this->forumThread->setClosed((bool) ($this->threadArray['Closed'] ?? false));
415 
416  $this->forumThread->setImportName(
417  isset($this->threadArray['ImportName']) ?
418  ilUtil::stripSlashes($this->threadArray['ImportName']) :
419  null
420  );
421  $this->forumThread->setCreateDate($this->threadArray['CreateDate']);
422  $this->forumThread->setChangeDate($this->threadArray['UpdateDate']);
423 
424  $usr_data = $this->getUserIdAndAlias(
425  (int) ($this->threadArray['UserId'] ?? 0),
426  ilUtil::stripSlashes((string) ($this->threadArray['Alias'] ?? ''))
427  );
428 
429  $this->forumThread->setDisplayUserId($usr_data['usr_id']);
430  $this->forumThread->setUserAlias($usr_data['usr_alias']);
431 
432  if (version_compare($this->getSchemaVersion(), '4.5.0', '<=')) {
433  $this->threadArray['AuthorId'] = $this->threadArray['UserId'];
434  }
435 
436  $author_id_data = $this->getUserIdAndAlias(
437  (int) ($this->threadArray['AuthorId'] ?? 0)
438  );
439  $this->forumThread->setThrAuthorId($author_id_data['usr_id']);
440 
441  $this->forumThread->insert();
442 
443  $this->mapping['thr'][$this->threadArray['Id']] = $this->forumThread->getId();
444  $this->lastHandledThreadId = $this->forumThread->getId();
445  $this->threadArray = [];
446  }
447  break;
448 
449  case 'Post':
450  break;
451 
452  case 'Censorship':
453  $propertyValue['Censorship'] = $this->cdata;
454  break;
455 
456  case 'CensorshipMessage':
457  $propertyValue['CensorshipMessage'] = $this->cdata;
458  break;
459 
460  case 'Notification':
461  $propertyValue['Notification'] = $this->cdata;
462  break;
463 
464  case 'ImportName':
465  $propertyValue['ImportName'] = $this->cdata;
466  break;
467 
468  case 'Status':
469  $propertyValue['Status'] = $this->cdata;
470  break;
471 
472  case 'Message':
473  $propertyValue['Message'] = $this->cdata;
474  break;
475 
476  case 'Lft':
477  $propertyValue['Lft'] = $this->cdata;
478  break;
479 
480  case 'Rgt':
481  $propertyValue['Rgt'] = $this->cdata;
482  break;
483 
484  case 'Depth':
485  $propertyValue['Depth'] = $this->cdata;
486  break;
487 
488  case 'ParentId':
489  $propertyValue['ParentId'] = $this->cdata;
490 
491  if (
492  $this->entity === 'post' &&
493  $this->lastHandledForumId &&
494  $this->postArray !== [] &&
495  $this->forumThread &&
496  $this->lastHandledThreadId
497  ) {
498  $this->forumPost = new ilForumPost();
499  $this->forumPost->setThread($this->forumThread);
500 
501  $this->forumPost->setId((int) $this->postArray['Id']);
502  $this->forumPost->setCensorship((bool) ($this->postArray['Censorship'] ?? false));
503  $this->forumPost->setCensorshipComment(
504  ilUtil::stripSlashes((string) ($this->postArray['CensorshipMessage'] ?? ''))
505  );
506  $this->forumPost->setNotification((bool) ($this->postArray['Notification'] ?? false));
507  $this->forumPost->setStatus((bool) ($this->postArray['Status'] ?? false));
508  $purifier = ilHtmlPurifierFactory::getInstanceByType('frm_post');
509  $this->forumPost->setMessage($purifier->purify((string) ($this->postArray['Message'] ?? '')));
510  $this->forumPost->setSubject(ilUtil::stripSlashes((string) ($this->postArray['Subject'] ?? '')));
511  $this->forumPost->setLft((int) $this->postArray['Lft']);
512  $this->forumPost->setRgt((int) $this->postArray['Rgt']);
513  $this->forumPost->setDepth((int) $this->postArray['Depth']);
514  $this->forumPost->setParentId((int) $this->postArray['ParentId']);
515  $this->forumPost->setThreadId($this->lastHandledThreadId);
516  $this->forumPost->setForumId($this->lastHandledForumId);
517 
518  $this->forumPost->setImportName(
519  isset($this->postArray['ImportName']) ?
520  ilUtil::stripSlashes($this->postArray['ImportName']) :
521  null
522  );
523  $this->forumPost->setCreateDate($this->postArray['CreateDate']);
524  $this->forumPost->setChangeDate($this->postArray['UpdateDate']);
525 
526  $usr_data = $this->getUserIdAndAlias(
527  (int) ($this->postArray['UserId'] ?? 0),
528  ilUtil::stripSlashes((string) ($this->postArray['Alias'] ?? ''))
529  );
530  $update_usr_data = $this->getUserIdAndAlias(
531  (int) ($this->postArray['UpdateUserId'] ?? 0)
532  );
533  $this->forumPost->setDisplayUserId($usr_data['usr_id']);
534  $this->forumPost->setUserAlias($usr_data['usr_alias']);
535  $this->forumPost->setUpdateUserId($update_usr_data['usr_id']);
536 
537  if (version_compare($this->getSchemaVersion(), '4.5.0', '<=')) {
538  $this->postArray['AuthorId'] = $this->postArray['UserId'];
539  }
540  $author_id_data = $this->getUserIdAndAlias(
541  (int) ($this->postArray['AuthorId'] ?? 0)
542  );
543  $this->forumPost->setPosAuthorId((int) $author_id_data['usr_id']);
544 
545  if (isset($this->postArray['isAuthorModerator']) && strtoupper($this->postArray['isAuthorModerator']) === 'NULL') {
546  $this->forumPost->setIsAuthorModerator(false);
547  } else {
548  $this->forumPost->setIsAuthorModerator((bool) $this->postArray['isAuthorModerator']);
549  }
550 
551  $this->forumPost->insert();
552 
553  if (isset($this->postArray['ParentId'], $this->mapping['pos'][$this->postArray['ParentId']])) {
554  $parentId = (int) $this->mapping['pos'][$this->postArray['ParentId']];
555  } else {
556  $parentId = 0;
557  }
558 
559  $postTreeNodeId = $this->db->nextId('frm_posts_tree');
560  $this->db->insert('frm_posts_tree', [
561  'fpt_pk' => ['integer', $postTreeNodeId],
562  'thr_fk' => ['integer', $this->lastHandledThreadId],
563  'pos_fk' => ['integer', $this->forumPost->getId()],
564  'parent_pos' => ['integer', $parentId],
565  'lft' => ['integer', $this->postArray['Lft']],
566  'rgt' => ['integer', $this->postArray['Rgt']],
567  'depth' => ['integer', $this->postArray['Depth']],
568  'fpt_date' => ['timestamp', date('Y-m-d H:i:s')]
569  ]);
570 
571  $this->mapping['pos'][($this->postArray['Id'] ?? 0)] = $this->forumPost->getId();
572  $this->lastHandledPostId = $this->forumPost->getId();
573 
574  $media_objects_found = false;
575  foreach ($this->mediaObjects as $mob_attr) {
576  $importfile = $this->getImportDirectory() . '/' . $mob_attr['uri'];
577  if (is_file($importfile)) {
579  basename($importfile),
580  $importfile,
581  false
582  );
583  ilObjMediaObject::_saveUsage($mob->getId(), 'frm:html', $this->forumPost->getId());
584 
585  $this->forumPost->setMessage(
586  str_replace(
587  [
588  'src="' . $mob_attr['label'] . '"',
589  'src="' . preg_replace(
590  "/(il)_[\d]+_(mob)_([\d]+)/",
591  '$1_0_$2_$3',
592  $mob_attr['label']
593  ) . '"'
594  ],
595  'src="' . 'il_' . IL_INST_ID . '_mob_' . $mob->getId() . '"',
596  $this->forumPost->getMessage()
597  )
598  );
599  $media_objects_found = true;
600  }
601  }
602 
603  if ($media_objects_found) {
604  $this->forumPost->update();
605  }
606  $this->postArray = [];
607  }
608 
609  break;
610 
611  case 'Content':
612  $propertyValue['content'] = $this->cdata;
613  break;
614 
615  case 'Attachment':
616  $filedata = new ilFileDataForum($this->forum->getId(), $this->lastHandledPostId);
617 
618  $import_path = $this->contentArray['content'];
619  if ($import_path !== '') {
620  $import_path = $this->getImportDirectory() . '/' . $import_path;
621  $filedata->importPath($import_path, (int) $this->lastHandledPostId);
622  }
623  break;
624  }
625 
626  $this->cdata = '';
627  }
628 
632  private function getIdAndAliasArray(int $imp_usr_id, string $param = 'import'): array
633  {
634  $where = '';
635  $select = 'SELECT od.obj_id, ud.login FROM object_data od INNER JOIN usr_data ud ON od.obj_id = ud.usr_id';
636  if ($param === 'import') {
637  $where = ' WHERE od.import_id = ' . $this->db->quote(
638  'il_' . $this->import_install_id . '_usr_' . $imp_usr_id,
639  'text'
640  );
641  }
642 
643  if ($param === 'user') {
644  $where = ' WHERE ud.usr_id = ' . $this->db->quote(
645  $imp_usr_id,
646  'integer'
647  );
648  }
649 
650  $query = $this->db->query($select . $where);
651 
652  while ($res = $this->db->fetchAssoc($query)) {
653  break;
654  }
655 
656  if ($res) {
657  return [
658  'usr_id' => (int) $res['obj_id'],
659  'usr_alias' => (string) $res['login']
660  ];
661  }
662 
663  return [];
664  }
665 
669  private function getAnonymousArray(): array
670  {
671  return [
672  'usr_id' => $this->aobject->getId(),
673  'usr_alias' => $this->aobject->getLogin()
674  ];
675  }
676 
680  private function getUserIdAndAlias(int $imp_usr_id, string $imp_usr_alias = ''): array
681  {
682  if ($imp_usr_id <= 0) {
683  return [
684  'usr_id' => $imp_usr_id,
685  'usr_alias' => $imp_usr_alias
686  ];
687  }
688 
689  if ($this->import_install_id != IL_INST_ID && IL_INST_ID > 0) {
690  // Different installations
691  if (isset($this->user_id_mapping[$imp_usr_id])) {
692  return $this->user_id_mapping[$imp_usr_id];
693  }
694 
695  $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
696  if ($res !== []) {
697  $this->user_id_mapping[$imp_usr_id] = $res;
698 
699  return $res;
700  }
701 
702  $return_value = $this->getAnonymousArray();
703  $this->user_id_mapping[$imp_usr_id] = $return_value;
704 
705  return $return_value;
706  }
707 
708  if ($this->import_install_id == IL_INST_ID && IL_INST_ID == 0) {
709  // Eventually different installations. We cannot determine it.
710  if (isset($this->user_id_mapping[$imp_usr_id])) {
711  return $this->user_id_mapping[$imp_usr_id];
712  }
713 
714  $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
715  if ($res !== []) {
716  $this->user_id_mapping[$imp_usr_id] = $res;
717 
718  return $res;
719  }
720 
721  if (isset($this->user_id_mapping[$imp_usr_id])) {
722  return $this->user_id_mapping[$imp_usr_id];
723  }
724 
725  $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
726  if ($res !== []) {
727  $this->user_id_mapping[$imp_usr_id] = $res;
728 
729  return $res;
730  }
731 
732  $return_value = $this->getAnonymousArray();
733  $this->user_id_mapping[$imp_usr_id] = $return_value;
734 
735  return $return_value;
736  }
737 
738  if (isset($this->user_id_mapping[$imp_usr_id])) {
739  return $this->user_id_mapping[$imp_usr_id];
740  }
741 
742  $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
743  if ($res !== []) {
744  $this->user_id_mapping[$imp_usr_id] = $res;
745 
746  return $res;
747  }
748 
749  $return_value = $this->getAnonymousArray();
750  $this->user_id_mapping[$imp_usr_id] = $return_value;
751 
752  return $return_value;
753  }
754 
755  public function setImportInstallId($id): void
756  {
757  $this->import_install_id = $id;
758  }
759 
760  private function getNewForumPk(): int
761  {
762  $query = 'SELECT top_pk FROM frm_data WHERE top_frm_fk = ' . $this->db->quote(
763  $this->forum->getId(),
764  'integer'
765  );
766  $res = $this->db->query($query);
767  $data = $this->db->fetchAssoc($res);
768 
769  return (int) $data['top_pk'];
770  }
771 
772  public function handlerCharacterData(XMLParser $a_xml_parser, string $a_data): void
773  {
774  if ($a_data !== "\n") {
775  // Replace multiple tabs with one space
776  $a_data = preg_replace("/\t+/", ' ', $a_data);
777 
778  $this->cdata .= $a_data;
779  }
780  }
781 }
$res
Definition: ltiservices.php:69
const IL_INST_ID
Definition: constants.php:40
const ANONYMOUS_USER_ID
Definition: constants.php:27
ILIAS Style Content DomainService $content_style_domain
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
setSchemaVersion(?string $schema_version)
array readonly ilDBInterface $db
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.
getUserIdAndAlias(int $imp_usr_id, string $imp_usr_alias='')
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getIdAndAliasArray(int $imp_usr_id, string $param='import')
static getInstance(int $a_obj_id=0)
readonly ilObjUser $aobject
$param
Definition: xapitoken.php:44
global $DIC
Definition: shib_login.php:25
importPath(string $path_to_file, int $posting_id)
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
handlerEndTag(XMLParser $a_xml_parser, string $a_name)
static getInstanceByType(string $type)
handlerBeginTag(XMLParser $a_xml_parser, string $a_name, array $a_attribs)
static _saveTempFileAsMediaObject(string $name, string $tmp_name, bool $upload=true)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
__construct(Container $dic, ilPlugin $plugin)
__construct(private readonly ilObjForum $forum, string $a_xml_data, private readonly ilImportMapping $importMapping)
setXMLContent(string $a_xml_content)
setImportDirectory(?string $a_val)
handlerCharacterData(XMLParser $a_xml_parser, string $a_data)