ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilForumXMLParser Class Reference
+ Inheritance diagram for ilForumXMLParser:
+ Collaboration diagram for ilForumXMLParser:

Public Member Functions

 __construct (private ilObjForum $forum, string $a_xml_data, private ilImportMapping $importMapping)
 
 setImportDirectory (?string $a_val)
 
 getImportDirectory ()
 
 getSchemaVersion ()
 
 setSchemaVersion (?string $schema_version)
 
 setHandlers ($a_xml_parser)
 
 handlerBeginTag (XMLParser $a_xml_parser, string $a_name, array $a_attribs)
 
 handlerEndTag (XMLParser $a_xml_parser, string $a_name)
 
 setImportInstallId ($id)
 
 handlerCharacterData (XMLParser $a_xml_parser, string $a_data)
 
- Public Member Functions inherited from ilSaxParser
 __construct (?string $path_to_file='', ?bool $throw_exception=false)
 
 setXMLContent (string $a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 
 setHandlers ($a_xml_parser)
 
 parse ($a_xml_parser, $a_fp=null)
 

Static Public Attributes

static array $style_map = []
 

Protected Attributes

ILIAS Style Content DomainService $content_style_domain
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Private Member Functions

 getIdAndAliasArray (int $imp_usr_id, string $param='import')
 
 getAnonymousArray ()
 
 getUserIdAndAlias (int $imp_usr_id, string $imp_usr_alias='')
 
 getNewForumPk ()
 

Private Attributes

string $entity = ''
 
array $mapping
 
array ilDBInterface $db
 
ilObjUser $aobject
 
 $import_install_id
 
string $importDirectory = null
 
string $schema_version = null
 
string $cdata = ''
 
ilForumTopic $forumThread = null
 
ilForumPost $forumPost = null
 
int $forum_obj_id = null
 
int $frm_last_mapped_top_usr_id = null
 
int $lastHandledForumId = null
 
int $lastHandledThreadId = null
 
int $lastHandledPostId = null
 
int $last_handled_style_id = null
 
array $forumArray = []
 
array $postArray = []
 
array $threadArray = []
 
array $contentArray
 
array $user_id_mapping = []
 
array $mediaObjects = []
 

Additional Inherited Members

- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 
- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 

Detailed Description

Definition at line 23 of file class.ilForumXMLParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumXMLParser::__construct ( private ilObjForum  $forum,
string  $a_xml_data,
private ilImportMapping  $importMapping 
)

Definition at line 63 of file class.ilForumXMLParser.php.

References $DIC, ILIAS\MetaData\Repository\Validation\Data\__construct(), ANONYMOUS_USER_ID, and ilSaxParser\setXMLContent().

64  {
65  global $DIC;
66 
67  $this->db = $DIC->database();
68  $this->aobject = new ilObjUser(ANONYMOUS_USER_ID);
69 
71 
72  $this->content_style_domain = $DIC
73  ->contentStyle()
74  ->domain();
75 
76  $this->setXMLContent('<?xml version="1.0" encoding="utf-8"?>' . $a_xml_data);
77  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
setXMLContent(string $a_xml_content)
+ Here is the call graph for this function:

Member Function Documentation

◆ getAnonymousArray()

ilForumXMLParser::getAnonymousArray ( )
private
Returns
array{usr_id: int, usr_alias: string}

Definition at line 656 of file class.ilForumXMLParser.php.

Referenced by getUserIdAndAlias().

656  : array
657  {
658  return [
659  'usr_id' => $this->aobject->getId(),
660  'usr_alias' => $this->aobject->getLogin()
661  ];
662  }
+ Here is the caller graph for this function:

◆ getIdAndAliasArray()

ilForumXMLParser::getIdAndAliasArray ( int  $imp_usr_id,
string  $param = 'import' 
)
private
Returns
array|array{usr_id: int, usr_alias: string}

Definition at line 619 of file class.ilForumXMLParser.php.

References $param, $res, and ILIAS\Repository\int().

Referenced by getUserIdAndAlias().

619  : array
620  {
621  $where = '';
622  $select = 'SELECT od.obj_id, ud.login FROM object_data od INNER JOIN usr_data ud ON od.obj_id = ud.usr_id';
623  if ($param === 'import') {
624  $where = ' WHERE od.import_id = ' . $this->db->quote(
625  'il_' . $this->import_install_id . '_usr_' . $imp_usr_id,
626  'text'
627  );
628  }
629 
630  if ($param === 'user') {
631  $where = ' WHERE ud.usr_id = ' . $this->db->quote(
632  $imp_usr_id,
633  'integer'
634  );
635  }
636 
637  $query = $this->db->query($select . $where);
638 
639  while ($res = $this->db->fetchAssoc($query)) {
640  break;
641  }
642 
643  if ($res) {
644  return [
645  'usr_id' => (int) $res['obj_id'],
646  'usr_alias' => (string) $res['login']
647  ];
648  }
649 
650  return [];
651  }
$res
Definition: ltiservices.php:69
$param
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImportDirectory()

ilForumXMLParser::getImportDirectory ( )

Definition at line 84 of file class.ilForumXMLParser.php.

References $importDirectory.

Referenced by handlerEndTag().

84  : ?string
85  {
87  }
+ Here is the caller graph for this function:

◆ getNewForumPk()

ilForumXMLParser::getNewForumPk ( )
private

Definition at line 747 of file class.ilForumXMLParser.php.

References $data, and $res.

Referenced by handlerEndTag().

747  : int
748  {
749  $query = "SELECT top_pk FROM frm_data WHERE top_frm_fk = " . $this->db->quote(
750  $this->forum->getId(),
751  'integer'
752  );
753  $res = $this->db->query($query);
754  $data = $this->db->fetchAssoc($res);
755 
756  return (int) $data['top_pk'];
757  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ getSchemaVersion()

ilForumXMLParser::getSchemaVersion ( )

Definition at line 89 of file class.ilForumXMLParser.php.

References $schema_version.

Referenced by handlerEndTag().

89  : ?string
90  {
91  return $this->schema_version;
92  }
+ Here is the caller graph for this function:

◆ getUserIdAndAlias()

ilForumXMLParser::getUserIdAndAlias ( int  $imp_usr_id,
string  $imp_usr_alias = '' 
)
private
Returns
array{usr_id: int, usr_alias: string}

Definition at line 667 of file class.ilForumXMLParser.php.

References $res, getAnonymousArray(), getIdAndAliasArray(), and IL_INST_ID.

Referenced by handlerEndTag().

667  : array
668  {
669  if ($imp_usr_id <= 0) {
670  return [
671  'usr_id' => $imp_usr_id,
672  'usr_alias' => $imp_usr_alias
673  ];
674  }
675 
676  if ($this->import_install_id != IL_INST_ID && IL_INST_ID > 0) {
677  // Different installations
678  if (isset($this->user_id_mapping[$imp_usr_id])) {
679  return $this->user_id_mapping[$imp_usr_id];
680  }
681 
682  $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
683  if ($res !== []) {
684  $this->user_id_mapping[$imp_usr_id] = $res;
685 
686  return $res;
687  }
688 
689  $return_value = $this->getAnonymousArray();
690  $this->user_id_mapping[$imp_usr_id] = $return_value;
691 
692  return $return_value;
693  }
694 
695  if ($this->import_install_id == IL_INST_ID && IL_INST_ID == 0) {
696  // Eventually different installations. We cannot determine it.
697  if (isset($this->user_id_mapping[$imp_usr_id])) {
698  return $this->user_id_mapping[$imp_usr_id];
699  }
700 
701  $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
702  if ($res !== []) {
703  $this->user_id_mapping[$imp_usr_id] = $res;
704 
705  return $res;
706  }
707 
708  if (isset($this->user_id_mapping[$imp_usr_id])) {
709  return $this->user_id_mapping[$imp_usr_id];
710  }
711 
712  $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
713  if ($res !== []) {
714  $this->user_id_mapping[$imp_usr_id] = $res;
715 
716  return $res;
717  }
718 
719  $return_value = $this->getAnonymousArray();
720  $this->user_id_mapping[$imp_usr_id] = $return_value;
721 
722  return $return_value;
723  }
724 
725  if (isset($this->user_id_mapping[$imp_usr_id])) {
726  return $this->user_id_mapping[$imp_usr_id];
727  }
728 
729  $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
730  if ($res !== []) {
731  $this->user_id_mapping[$imp_usr_id] = $res;
732 
733  return $res;
734  }
735 
736  $return_value = $this->getAnonymousArray();
737  $this->user_id_mapping[$imp_usr_id] = $return_value;
738 
739  return $return_value;
740  }
$res
Definition: ltiservices.php:69
const IL_INST_ID
Definition: constants.php:40
getIdAndAliasArray(int $imp_usr_id, string $param='import')
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlerBeginTag()

ilForumXMLParser::handlerBeginTag ( XMLParser  $a_xml_parser,
string  $a_name,
array  $a_attribs 
)

Definition at line 112 of file class.ilForumXMLParser.php.

References ILIAS\Repository\int().

Referenced by setHandlers().

112  : void
113  {
114  switch ($a_name) {
115  case 'Forum':
116  $this->entity = 'forum';
117  $this->forumArray = [];
118  break;
119 
120  case 'Thread':
121  $this->entity = 'thread';
122  $this->threadArray = [];
123  break;
124 
125  case 'Post':
126  $this->entity = 'post';
127  $this->postArray = [];
128  $this->mediaObjects = [];
129  break;
130 
131  case 'Content':
132  $this->entity = 'content';
133  $this->contentArray = [
134  'content' => ''
135  ];
136  break;
137 
138  case 'MediaObject':
139  $this->mediaObjects[] = $a_attribs;
140  break;
141  }
142 
143  if (isset($a_attribs['Style'])) {
144  $this->last_handled_style_id = (int) $a_attribs['Style'];
145  }
146  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlerCharacterData()

ilForumXMLParser::handlerCharacterData ( XMLParser  $a_xml_parser,
string  $a_data 
)

Definition at line 759 of file class.ilForumXMLParser.php.

Referenced by setHandlers().

759  : void
760  {
761  if ($a_data !== "\n") {
762  // Replace multiple tabs with one space
763  $a_data = preg_replace("/\t+/", " ", $a_data);
764 
765  $this->cdata .= $a_data;
766  }
767  }
+ Here is the caller graph for this function:

◆ handlerEndTag()

ilForumXMLParser::handlerEndTag ( XMLParser  $a_xml_parser,
string  $a_name 
)

Definition at line 148 of file class.ilForumXMLParser.php.

References $cdata, $id, $last_handled_style_id, $lastHandledPostId, ilLPStatusWrapper\_refreshStatus(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), getImportDirectory(), ilForumProperties\getInstance(), ilHtmlPurifierFactory\getInstanceByType(), getNewForumPk(), getSchemaVersion(), getUserIdAndAlias(), IL_INST_ID, ilFileDataForum\importPath(), ILIAS\Repository\int(), ilUtil\stripSlashes(), and ilForumProperties\VIEW_TREE.

Referenced by setHandlers().

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

◆ setHandlers()

ilForumXMLParser::setHandlers (   $a_xml_parser)

Definition at line 99 of file class.ilForumXMLParser.php.

References handlerBeginTag(), handlerCharacterData(), and handlerEndTag().

99  : void
100  {
101  xml_set_object($a_xml_parser, $this);
102  xml_set_element_handler($a_xml_parser, function (XMLParser $a_xml_parser, string $a_name, array $a_attribs): void {
103  $this->handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
104  }, function (XMLParser $a_xml_parser, string $a_name): void {
105  $this->handlerEndTag($a_xml_parser, $a_name);
106  });
107  xml_set_character_data_handler($a_xml_parser, function (XMLParser $a_xml_parser, string $a_data): void {
108  $this->handlerCharacterData($a_xml_parser, $a_data);
109  });
110  }
handlerEndTag(XMLParser $a_xml_parser, string $a_name)
handlerBeginTag(XMLParser $a_xml_parser, string $a_name, array $a_attribs)
handlerCharacterData(XMLParser $a_xml_parser, string $a_data)
+ Here is the call graph for this function:

◆ setImportDirectory()

ilForumXMLParser::setImportDirectory ( ?string  $a_val)

Definition at line 79 of file class.ilForumXMLParser.php.

79  : void
80  {
81  $this->importDirectory = $a_val;
82  }

◆ setImportInstallId()

ilForumXMLParser::setImportInstallId (   $id)

Definition at line 742 of file class.ilForumXMLParser.php.

References $id.

742  : void
743  {
744  $this->import_install_id = $id;
745  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ setSchemaVersion()

ilForumXMLParser::setSchemaVersion ( ?string  $schema_version)

Definition at line 94 of file class.ilForumXMLParser.php.

References $schema_version.

94  : void
95  {
96  $this->schema_version = $schema_version;
97  }

Field Documentation

◆ $aobject

ilObjUser ilForumXMLParser::$aobject
private

Definition at line 37 of file class.ilForumXMLParser.php.

◆ $cdata

string ilForumXMLParser::$cdata = ''
private

Definition at line 42 of file class.ilForumXMLParser.php.

Referenced by handlerEndTag().

◆ $content_style_domain

ILIAS Style Content DomainService ilForumXMLParser::$content_style_domain
protected

Definition at line 61 of file class.ilForumXMLParser.php.

◆ $contentArray

array ilForumXMLParser::$contentArray
private
Initial value:
= [
'content' => ''
]

Definition at line 55 of file class.ilForumXMLParser.php.

◆ $db

array ilDBInterface ilForumXMLParser::$db
private
Initial value:
=> [],
'pos' => []
]

Definition at line 33 of file class.ilForumXMLParser.php.

◆ $entity

string ilForumXMLParser::$entity = ''
private

Definition at line 30 of file class.ilForumXMLParser.php.

◆ $forum_obj_id

int ilForumXMLParser::$forum_obj_id = null
private

Definition at line 46 of file class.ilForumXMLParser.php.

◆ $forumArray

array ilForumXMLParser::$forumArray = []
private

Definition at line 52 of file class.ilForumXMLParser.php.

◆ $forumPost

ilForumPost ilForumXMLParser::$forumPost = null
private

Definition at line 45 of file class.ilForumXMLParser.php.

◆ $forumThread

ilForumTopic ilForumXMLParser::$forumThread = null
private

Definition at line 44 of file class.ilForumXMLParser.php.

◆ $frm_last_mapped_top_usr_id

int ilForumXMLParser::$frm_last_mapped_top_usr_id = null
private

Definition at line 47 of file class.ilForumXMLParser.php.

◆ $import_install_id

ilForumXMLParser::$import_install_id
private

Definition at line 39 of file class.ilForumXMLParser.php.

◆ $importDirectory

string ilForumXMLParser::$importDirectory = null
private

Definition at line 40 of file class.ilForumXMLParser.php.

Referenced by getImportDirectory().

◆ $last_handled_style_id

int ilForumXMLParser::$last_handled_style_id = null
private

Definition at line 51 of file class.ilForumXMLParser.php.

Referenced by handlerEndTag().

◆ $lastHandledForumId

int ilForumXMLParser::$lastHandledForumId = null
private

Definition at line 48 of file class.ilForumXMLParser.php.

◆ $lastHandledPostId

int ilForumXMLParser::$lastHandledPostId = null
private

Definition at line 50 of file class.ilForumXMLParser.php.

Referenced by handlerEndTag().

◆ $lastHandledThreadId

int ilForumXMLParser::$lastHandledThreadId = null
private

Definition at line 49 of file class.ilForumXMLParser.php.

◆ $mapping

array ilForumXMLParser::$mapping
private
Initial value:
= [
'frm' => []

Definition at line 31 of file class.ilForumXMLParser.php.

◆ $mediaObjects

array ilForumXMLParser::$mediaObjects = []
private

Definition at line 59 of file class.ilForumXMLParser.php.

◆ $postArray

array ilForumXMLParser::$postArray = []
private

Definition at line 53 of file class.ilForumXMLParser.php.

◆ $schema_version

string ilForumXMLParser::$schema_version = null
private

Definition at line 41 of file class.ilForumXMLParser.php.

Referenced by getSchemaVersion(), and setSchemaVersion().

◆ $style_map

array ilForumXMLParser::$style_map = []
static

Definition at line 28 of file class.ilForumXMLParser.php.

Referenced by ilForumImporter\finalProcessing().

◆ $threadArray

array ilForumXMLParser::$threadArray = []
private

Definition at line 54 of file class.ilForumXMLParser.php.

◆ $user_id_mapping

array ilForumXMLParser::$user_id_mapping = []
private

Definition at line 58 of file class.ilForumXMLParser.php.


The documentation for this class was generated from the following file: