ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
 
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.

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 }
User class.
setXMLContent(string $a_xml_content)
const ANONYMOUS_USER_ID
Definition: constants.php:27
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ 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 668 of file class.ilForumXMLParser.php.

668 : array
669 {
670 return [
671 'usr_id' => $this->aobject->getId(),
672 'usr_alias' => $this->aobject->getLogin()
673 ];
674 }

Referenced by getUserIdAndAlias().

+ 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 631 of file class.ilForumXMLParser.php.

631 : array
632 {
633 $where = '';
634 $select = 'SELECT od.obj_id, ud.login FROM object_data od INNER JOIN usr_data ud ON od.obj_id = ud.usr_id';
635 if ($param === 'import') {
636 $where = ' WHERE od.import_id = ' . $this->db->quote(
637 'il_' . $this->import_install_id . '_usr_' . $imp_usr_id,
638 'text'
639 );
640 }
641
642 if ($param === 'user') {
643 $where = ' WHERE ud.usr_id = ' . $this->db->quote(
644 $imp_usr_id,
645 'integer'
646 );
647 }
648
649 $query = $this->db->query($select . $where);
650
651 while ($res = $this->db->fetchAssoc($query)) {
652 break;
653 }
654
655 if ($res) {
656 return [
657 'usr_id' => (int) $res['obj_id'],
658 'usr_alias' => (string) $res['login']
659 ];
660 }
661
662 return [];
663 }
$res
Definition: ltiservices.php:69
$param
Definition: xapitoken.php:46

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

Referenced by getUserIdAndAlias().

+ 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.

87 : ?string
88 {
90 }

References $importDirectory.

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getNewForumPk()

ilForumXMLParser::getNewForumPk ( )
private

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

759 : int
760 {
761 $query = 'SELECT top_pk FROM frm_data WHERE top_frm_fk = ' . $this->db->quote(
762 $this->forum->getId(),
763 'integer'
764 );
765 $res = $this->db->query($query);
766 $data = $this->db->fetchAssoc($res);
767
768 return (int) $data['top_pk'];
769 }

References $data, and $res.

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getSchemaVersion()

ilForumXMLParser::getSchemaVersion ( )

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

92 : ?string
93 {
95 }

References $schema_version.

Referenced by handlerEndTag().

+ 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 679 of file class.ilForumXMLParser.php.

679 : array
680 {
681 if ($imp_usr_id <= 0) {
682 return [
683 'usr_id' => $imp_usr_id,
684 'usr_alias' => $imp_usr_alias
685 ];
686 }
687
688 if ($this->import_install_id != IL_INST_ID && IL_INST_ID > 0) {
689 // Different installations
690 if (isset($this->user_id_mapping[$imp_usr_id])) {
691 return $this->user_id_mapping[$imp_usr_id];
692 }
693
694 $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
695 if ($res !== []) {
696 $this->user_id_mapping[$imp_usr_id] = $res;
697
698 return $res;
699 }
700
701 $return_value = $this->getAnonymousArray();
702 $this->user_id_mapping[$imp_usr_id] = $return_value;
703
704 return $return_value;
705 }
706
707 if ($this->import_install_id == IL_INST_ID && IL_INST_ID == 0) {
708 // Eventually different installations. We cannot determine it.
709 if (isset($this->user_id_mapping[$imp_usr_id])) {
710 return $this->user_id_mapping[$imp_usr_id];
711 }
712
713 $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
714 if ($res !== []) {
715 $this->user_id_mapping[$imp_usr_id] = $res;
716
717 return $res;
718 }
719
720 if (isset($this->user_id_mapping[$imp_usr_id])) {
721 return $this->user_id_mapping[$imp_usr_id];
722 }
723
724 $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
725 if ($res !== []) {
726 $this->user_id_mapping[$imp_usr_id] = $res;
727
728 return $res;
729 }
730
731 $return_value = $this->getAnonymousArray();
732 $this->user_id_mapping[$imp_usr_id] = $return_value;
733
734 return $return_value;
735 }
736
737 if (isset($this->user_id_mapping[$imp_usr_id])) {
738 return $this->user_id_mapping[$imp_usr_id];
739 }
740
741 $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
742 if ($res !== []) {
743 $this->user_id_mapping[$imp_usr_id] = $res;
744
745 return $res;
746 }
747
748 $return_value = $this->getAnonymousArray();
749 $this->user_id_mapping[$imp_usr_id] = $return_value;
750
751 return $return_value;
752 }
getIdAndAliasArray(int $imp_usr_id, string $param='import')
const IL_INST_ID
Definition: constants.php:40

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

Referenced by handlerEndTag().

+ 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 118 of file class.ilForumXMLParser.php.

118 : void
119 {
120 switch ($a_name) {
121 case 'Forum':
122 $this->entity = 'forum';
123 $this->forumArray = [];
124 break;
125
126 case 'Thread':
127 $this->entity = 'thread';
128 $this->threadArray = [];
129 break;
130
131 case 'Post':
132 $this->entity = 'post';
133 $this->postArray = [];
134 $this->mediaObjects = [];
135 break;
136
137 case 'Content':
138 $this->entity = 'content';
139 $this->contentArray = [
140 'content' => ''
141 ];
142 break;
143
144 case 'MediaObject':
145 $this->mediaObjects[] = $a_attribs;
146 break;
147 }
148
149 if (isset($a_attribs['Style'])) {
150 $this->last_handled_style_id = (int) $a_attribs['Style'];
151 }
152 }

References ILIAS\Repository\int().

Referenced by setHandlers().

+ 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 771 of file class.ilForumXMLParser.php.

771 : void
772 {
773 if ($a_data !== "\n") {
774 // Replace multiple tabs with one space
775 $a_data = preg_replace("/\t+/", ' ', $a_data);
776
777 $this->cdata .= $a_data;
778 }
779 }

Referenced by setHandlers().

+ Here is the caller graph for this function:

◆ handlerEndTag()

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

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

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
203 ilLPStatusWrapper::_refreshStatus($this->forum->getId());
204 break;
205
206 case 'Id':
207 $propertyValue['Id'] = $this->cdata;
208 break;
209
210 case 'ObjId':
211 $propertyValue['ObjId'] = $this->cdata;
212 break;
213
214 case 'Title':
215 $propertyValue['Title'] = $this->cdata;
216 break;
217
218 case 'Description':
219 $propertyValue['Description'] = $this->cdata;
220 break;
221
222 case 'DefaultView':
223 $propertyValue['DefaultView'] = $this->cdata;
224 break;
225
226 case 'Pseudonyms':
227 $propertyValue['Pseudonyms'] = $this->cdata;
228 break;
229
230 case 'Statistics':
231 $propertyValue['Statistics'] = $this->cdata;
232 break;
233
234 case 'ThreadRatings':
235 $propertyValue['ThreadRatings'] = $this->cdata;
236 break;
237
238 case 'PostingActivation':
239 $propertyValue['PostingActivation'] = $this->cdata;
240 break;
241
242 case 'PresetSubject':
243 $propertyValue['PresetSubject'] = $this->cdata;
244 break;
245
246 case 'PresetRe':
247 $propertyValue['PresetRe'] = $this->cdata;
248 break;
249
250 case 'NotificationType':
251 $propertyValue['NotificationType'] = $this->cdata;
252 break;
253
254 case 'NotificationEvents':
255 $propertyValue['NotificationEvents'] = $this->cdata;
256 break;
257
258 case 'ForceNotification':
259 $propertyValue['ForceNotification'] = $this->cdata;
260 break;
261
262 case 'ToggleNotification':
263 $propertyValue['ToggleNotification'] = $this->cdata;
264 break;
265
266 case 'LastPost':
267 $propertyValue['LastPost'] = $this->cdata;
268 break;
269
270 case 'Moderator':
271 $propertyValue['Moderator'] = $this->cdata;
272 break;
273
274 case 'CreateDate':
275 $propertyValue['CreateDate'] = $this->cdata;
276 break;
277
278 case 'UpdateDate':
279 $propertyValue['UpdateDate'] = $this->cdata;
280 break;
281
282 case 'FileUpload':
283 $propertyValue['FileUpload'] = $this->cdata;
284 break;
285
286 case 'UpdateUserId':
287 $propertyValue['UpdateUserId'] = $this->cdata;
288 break;
289
290 case 'AuthorId':
291 $propertyValue['AuthorId'] = $this->cdata;
292 break;
293 case 'isAuthorModerator':
294 $propertyValue['isAuthorModerator'] = $this->cdata;
295 break;
296
297 case 'UserId':
298 $propertyValue['UserId'] = $this->cdata;
299 if ($this->entity === 'forum' && $this->forumArray !== []) {
301 // createSettings accesses superglobal $_GET array, which can cause problems
302 // with public_notifications of block settings
303 $this->forum->createSettings();
304
305 $forum_array = $this->getUserIdAndAlias(
306 (int) ($this->forumArray['UserId'] ?? 0),
307 ''
308 );
309 $this->frm_last_mapped_top_usr_id = $forum_array['usr_id'];
310
311 $update_forum_array = $this->getUserIdAndAlias(
312 (int) ($this->forumArray['UpdateUserId'] ?? 0),
313 ''
314 );
315 // Store old user id
316 // Manipulate user object
317 // changed smeyer 28.7.16: the session id is not manipulated
318 // anymore. Instead the user is passwd ilObjForum::update()
319 $this->forum->setTitle(ilUtil::stripSlashes((string) ($this->forumArray['Title'] ?? '')));
320 $this->forum->setDescription(
321 ilUtil::stripSlashes((string) ($this->forumArray['Description'] ?? ''))
322 );
323 $this->forum->update();
324 $this->forum->updateModificationUserId($update_forum_array['usr_id']);
325
326 $newObjProp = ilForumProperties::getInstance($this->forum->getId());
327 $newObjProp->setDefaultView(
328 (int) ($this->forumArray['DefaultView'] ?? ilForumProperties::VIEW_TREE)
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
348 $id = $this->getNewForumPk();
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) {
361 self::$style_map[$this->last_handled_style_id][] = $newObjProp->getObjId();
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':
387 $propertyValue['Subject'] = $this->cdata;
388 break;
389
390 case 'Alias':
391 $propertyValue['Alias'] = $this->cdata;
392 break;
393
394 case 'Sticky':
395 $propertyValue['Sticky'] = $this->cdata;
396 break;
397
398 case 'MarkModeratorPosts':
399 $propertyValue['MarkModeratorPosts'] = $this->cdata;
400 break;
401
402 case 'Closed':
403 $propertyValue['Closed'] = $this->cdata;
404
405 if ($this->entity === 'thread' && $this->lastHandledForumId && $this->threadArray !== []) {
406 $this->forumThread = new ilForumTopic();
407 $this->forumThread->setId((int) ($this->threadArray['Id'] ?? 0));
408 $this->forumThread->setForumId($this->lastHandledForumId);
409 $this->forumThread->setSubject(
410 ilUtil::stripSlashes((string) ($this->threadArray['Subject'] ?? ''))
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']) ?
417 ilUtil::stripSlashes($this->threadArray['ImportName']) :
418 null
419 );
420 $this->forumThread->setCreateDate($this->threadArray['CreateDate']);
421 $this->forumThread->setChangeDate($this->threadArray['UpdateDate']);
422
423 $usr_data = $this->getUserIdAndAlias(
424 (int) ($this->threadArray['UserId'] ?? 0),
425 ilUtil::stripSlashes((string) ($this->threadArray['Alias'] ?? ''))
426 );
427
428 $this->forumThread->setDisplayUserId($usr_data['usr_id']);
429 $this->forumThread->setUserAlias($usr_data['usr_alias']);
430
431 if (version_compare($this->getSchemaVersion(), '4.5.0', '<=')) {
432 $this->threadArray['AuthorId'] = $this->threadArray['UserId'];
433 }
434
435 $author_id_data = $this->getUserIdAndAlias(
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':
452 $propertyValue['Censorship'] = $this->cdata;
453 break;
454
455 case 'CensorshipMessage':
456 $propertyValue['CensorshipMessage'] = $this->cdata;
457 break;
458
459 case 'Notification':
460 $propertyValue['Notification'] = $this->cdata;
461 break;
462
463 case 'ImportName':
464 $propertyValue['ImportName'] = $this->cdata;
465 break;
466
467 case 'Status':
468 $propertyValue['Status'] = $this->cdata;
469 break;
470
471 case 'Message':
472 $propertyValue['Message'] = $this->cdata;
473 break;
474
475 case 'Lft':
476 $propertyValue['Lft'] = $this->cdata;
477 break;
478
479 case 'Rgt':
480 $propertyValue['Rgt'] = $this->cdata;
481 break;
482
483 case 'Depth':
484 $propertyValue['Depth'] = $this->cdata;
485 break;
486
487 case 'ParentId':
488 $propertyValue['ParentId'] = $this->cdata;
489
490 if (
491 $this->entity === 'post' &&
492 $this->lastHandledForumId &&
493 $this->postArray !== [] &&
494 $this->forumThread &&
495 $this->lastHandledThreadId
496 ) {
497 $this->forumPost = new ilForumPost();
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(
503 ilUtil::stripSlashes((string) ($this->postArray['CensorshipMessage'] ?? ''))
504 );
505 $this->forumPost->setNotification((bool) ($this->postArray['Notification'] ?? false));
506 $this->forumPost->setStatus((bool) ($this->postArray['Status'] ?? false));
507 $purifier = ilHtmlPurifierFactory::getInstanceByType('frm_post');
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']) ?
519 ilUtil::stripSlashes($this->postArray['ImportName']) :
520 null
521 );
522 $this->forumPost->setCreateDate($this->postArray['CreateDate']);
523 $this->forumPost->setChangeDate($this->postArray['UpdateDate']);
524
525 $usr_data = $this->getUserIdAndAlias(
526 (int) ($this->postArray['UserId'] ?? 0),
527 ilUtil::stripSlashes((string) ($this->postArray['Alias'] ?? ''))
528 );
529 $update_usr_data = $this->getUserIdAndAlias(
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
536 if (version_compare($this->getSchemaVersion(), '4.5.0', '<=')) {
537 $this->postArray['AuthorId'] = $this->postArray['UserId'];
538 }
539 $author_id_data = $this->getUserIdAndAlias(
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) {
575 $importfile = $this->getImportDirectory() . '/' . $mob_attr['uri'];
576 if (is_file($importfile)) {
578 basename($importfile),
579 $importfile,
580 false
581 );
582 ilObjMediaObject::_saveUsage($mob->getId(), 'frm:html', $this->forumPost->getId());
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':
611 $propertyValue['content'] = $this->cdata;
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 !== '') {
619 $import_path = $this->getImportDirectory() . '/' . $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
Definition: plugin.php:23
static getInstance(int $a_obj_id=0)
getUserIdAndAlias(int $imp_usr_id, string $imp_usr_alias='')
static getInstanceByType(string $type)
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
static _saveTempFileAsMediaObject(string $name, string $tmp_name, bool $upload=true)
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.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

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

Referenced by setHandlers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

ilForumXMLParser::setHandlers (   $a_xml_parser)
Parameters
XMLParser | resource$a_xml_parser
Returns
void

Reimplemented from ilSaxParser.

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

102 : void
103 {
104 xml_set_element_handler(
105 $a_xml_parser,
106 function (XMLParser $a_xml_parser, string $a_name, array $a_attribs): void {
107 $this->handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
108 },
109 function (XMLParser $a_xml_parser, string $a_name): void {
110 $this->handlerEndTag($a_xml_parser, $a_name);
111 }
112 );
113 xml_set_character_data_handler($a_xml_parser, function (XMLParser $a_xml_parser, string $a_data): void {
114 $this->handlerCharacterData($a_xml_parser, $a_data);
115 });
116 }
handlerCharacterData(XMLParser $a_xml_parser, string $a_data)
handlerBeginTag(XMLParser $a_xml_parser, string $a_name, array $a_attribs)
handlerEndTag(XMLParser $a_xml_parser, string $a_name)

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

+ 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 754 of file class.ilForumXMLParser.php.

754 : void
755 {
756 $this->import_install_id = $id;
757 }

References $id.

◆ setSchemaVersion()

ilForumXMLParser::setSchemaVersion ( ?string  $schema_version)

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

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

References $schema_version.

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

readonly ilDBInterface ilForumXMLParser::$db
private

Definition at line 36 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.

◆ $lastHandledThreadId

int ilForumXMLParser::$lastHandledThreadId = null
private

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

◆ $mapping

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

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: