ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilForumXMLParser Class Reference
+ Inheritance diagram for ilForumXMLParser:
+ Collaboration diagram for ilForumXMLParser:

Public Member Functions

 __construct (private readonly ilObjForum $forum, string $a_xml_data, private readonly 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 readonly ilDBInterface $db
 
readonly 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 readonly ilObjForum  $forum,
string  $a_xml_data,
private readonly ilImportMapping  $importMapping 
)

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ANONYMOUS_USER_ID, and ilSaxParser\setXMLContent().

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  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: shib_login.php:25
__construct(Container $dic, ilPlugin $plugin)
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 669 of file class.ilForumXMLParser.php.

Referenced by getUserIdAndAlias().

669  : array
670  {
671  return [
672  'usr_id' => $this->aobject->getId(),
673  'usr_alias' => $this->aobject->getLogin()
674  ];
675  }
+ 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 632 of file class.ilForumXMLParser.php.

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

Referenced by getUserIdAndAlias().

632  : 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  }
$res
Definition: ltiservices.php:69
$param
Definition: xapitoken.php:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImportDirectory()

ilForumXMLParser::getImportDirectory ( )

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

References $importDirectory.

Referenced by handlerEndTag().

87  : ?string
88  {
90  }
+ Here is the caller graph for this function:

◆ getNewForumPk()

ilForumXMLParser::getNewForumPk ( )
private

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

References $data, and $res.

Referenced by handlerEndTag().

760  : 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  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ getSchemaVersion()

ilForumXMLParser::getSchemaVersion ( )

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

References $schema_version.

Referenced by handlerEndTag().

92  : ?string
93  {
94  return $this->schema_version;
95  }
+ 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 680 of file class.ilForumXMLParser.php.

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

Referenced by handlerEndTag().

680  : 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  }
$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 119 of file class.ilForumXMLParser.php.

References ILIAS\Repository\int().

Referenced by setHandlers().

119  : 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  }
+ 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 772 of file class.ilForumXMLParser.php.

Referenced by setHandlers().

772  : 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  }
+ Here is the caller graph for this function:

◆ handlerEndTag()

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

Definition at line 155 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().

155  : 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  }
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)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ 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 102 of file class.ilForumXMLParser.php.

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

102  : 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  }
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 82 of file class.ilForumXMLParser.php.

82  : void
83  {
84  $this->importDirectory = $a_val;
85  }

◆ setImportInstallId()

ilForumXMLParser::setImportInstallId (   $id)

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

References $id.

755  : void
756  {
757  $this->import_install_id = $id;
758  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24

◆ setSchemaVersion()

ilForumXMLParser::setSchemaVersion ( ?string  $schema_version)

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

References $schema_version.

97  : void
98  {
99  $this->schema_version = $schema_version;
100  }

Field Documentation

◆ $aobject

readonly 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 readonly 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: