ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilForumXMLParser Class Reference
+ Inheritance diagram for ilForumXMLParser:
+ Collaboration diagram for ilForumXMLParser:

Public Member Functions

 __construct ($forum, $a_xml_data)
 Constructor. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 getSchemaVersion ()
 
 setSchemaVersion ($schema_version)
 
 setHandlers ($a_xml_parser)
 set event handlers More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 setImportInstallId ($id)
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
 start ()
 starts parsing an changes object by side effect. More...
 
- Public Member Functions inherited from ilSaxParser
 __construct ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object @access public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Protected Attributes

 $mediaObjects = array()
 
 $schema_version = null
 

Private Member Functions

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

Private Attributes

 $forum
 
 $entity
 
 $mapping
 
 $import_install_id = null
 
 $user_id_mapping = array()
 
 $db
 

Additional Inherited Members

- Static Public Member Functions inherited from PEAR
static & getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilForumXMLParser::__construct (   $forum,
  $a_xml_data 
)

Constructor.

Parameters
ilObjForum$forumexisting forum object
string$a_xml_filexml data @access public

Reimplemented from ilSaxParser.

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

41 {
42 global $DIC;
43
44 parent::__construct();
45 $this->forum = $forum;
46 $this->setXMLContent('<?xml version="1.0" encoding="utf-8"?>' . $a_xml_data);
47 $this->aobject = new ilObjUser(ANONYMOUS_USER_ID);
48 $this->db = $DIC->database();
49 }
setXMLContent($a_xml_content)
global $DIC
Definition: saml.php:7

References $DIC, $forum, and ilSaxParser\setXMLContent().

+ Here is the call graph for this function:

Member Function Documentation

◆ getAnonymousArray()

ilForumXMLParser::getAnonymousArray ( )
private

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

606 {
607 return array(
608 'usr_id' => $this->aobject->getId(),
609 'usr_alias' => $this->aobject->getLogin()
610 );
611 }

Referenced by getUserIdAndAlias().

+ Here is the caller graph for this function:

◆ getIdAndAliasArray()

ilForumXMLParser::getIdAndAliasArray (   $imp_usr_id,
  $param = 'import' 
)
private

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

569 {
570 $select = 'SELECT od.obj_id, ud.login
571 FROM object_data od
572 INNER JOIN usr_data ud
573 ON od.obj_id = ud.usr_id';
574
575 if ($param == 'import') {
576 $where = ' WHERE od.import_id = ' . $this->db->quote(
577 'il_' . $this->import_install_id . '_usr_' . $imp_usr_id,
578 'text'
579 );
580 }
581
582 if ($param == 'user') {
583 $where = ' WHERE ud.usr_id = ' . $this->db->quote(
584 $imp_usr_id,
585 'integer'
586 );
587 }
588
589 $query = $this->db->query($select . $where);
590
591 while ($res = $this->db->fetchAssoc($query)) {
592 break;
593 }
594
595 if ($res) {
596 return array(
597 'usr_id' => $res['obj_id'],
598 'usr_alias' => $res['login']
599 );
600 } else {
601 return false;
602 }
603 }
$query
foreach($_POST as $key=> $value) $res

References $query, and $res.

Referenced by getUserIdAndAlias().

+ Here is the caller graph for this function:

◆ getImportDirectory()

ilForumXMLParser::getImportDirectory ( )

Get import directory.

Returns
string import directory

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

67 {
68 return $this->importDirectory;
69 }

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getNewForumPk()

ilForumXMLParser::getNewForumPk ( )
private

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

701 {
702 $query = "SELECT top_pk FROM frm_data
703 WHERE top_frm_fk = " . $this->db->quote(
704 $this->forum->getId(),
705 'integer'
706 );
707 $res = $this->db->query($query);
708 $data = $this->db->fetchAssoc($res);
709
710 return $data['top_pk'];
711 }

References $data, $query, and $res.

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getSchemaVersion()

ilForumXMLParser::getSchemaVersion ( )
Returns
null|string

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

References $schema_version.

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getUserIdAndAlias()

ilForumXMLParser::getUserIdAndAlias (   $imp_usr_id,
  $imp_usr_alias = '' 
)
private

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

615 {
616 if ((int) $imp_usr_id > 0) {
617 $newUsrId = -1;
618
619 if ($this->import_install_id != IL_INST_ID && IL_INST_ID > 0) {
620 // Different installations
621 if ($this->user_id_mapping[$imp_usr_id]) {
622 return $this->user_id_mapping[$imp_usr_id];
623 } else {
624 $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
625
626 if ($res) {
627 $this->user_id_mapping[$imp_usr_id] = $res;
628
629 return $res;
630 } else {
631 $return_value = $this->getAnonymousArray();
632 $this->user_id_mapping[$imp_usr_id] = $return_value;
633
634 return $return_value;
635 }
636 }
637 } elseif ($this->import_install_id == IL_INST_ID && IL_INST_ID == 0) {
638 // Eventually different installations. We cannot determine it.
639 if ($this->user_id_mapping[$imp_usr_id]) {
640 return $this->user_id_mapping[$imp_usr_id];
641 } else {
642 $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
643
644 if ($res) {
645 $this->user_id_mapping[$imp_usr_id] = $res;
646
647 return $res;
648 } else {
649 // Same installation
650 if ($this->user_id_mapping[$imp_usr_id]) {
651 return $this->user_id_mapping[$imp_usr_id];
652 } else {
653 $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
654
655 if ($res) {
656 $this->user_id_mapping[$imp_usr_id] = $res;
657
658 return $res;
659 } else {
660 $return_value = $this->getAnonymousArray();
661 $this->user_id_mapping[$imp_usr_id] = $return_value;
662
663 return $return_value;
664 }
665 }
666 }
667 }
668 } else {
669 // Same installation
670 if ($this->user_id_mapping[$imp_usr_id]) {
671 return $this->user_id_mapping[$imp_usr_id];
672 } else {
673 $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
674
675 if ($res) {
676 $this->user_id_mapping[$imp_usr_id] = $res;
677
678 return $res;
679 } else {
680 $return_value = $this->getAnonymousArray();
681 $this->user_id_mapping[$imp_usr_id] = $return_value;
682
683 return $return_value;
684 }
685 }
686 }
687 } else {
688 return array(
689 'usr_id' => $imp_usr_id,
690 'usr_alias' => $imp_usr_alias
691 );
692 }
693 }
getIdAndAliasArray($imp_usr_id, $param='import')

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

Referenced by handlerEndTag().

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

◆ handlerBeginTag()

ilForumXMLParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name
array$a_attribselement attributes array

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

108 {
109 switch ($a_name) {
110 case 'Forum':
111 $this->entity = 'forum';
112 $this->forumArray = array();
113 break;
114
115 case 'Thread':
116 $this->entity = 'thread';
117 $this->threadArray = array();
118 break;
119
120 case 'Post':
121 $this->mediaObjects = array();
122 $this->entity = 'post';
123 $this->postArray = array();
124 break;
125
126 case 'Content':
127 $this->entity = 'content';
128 $this->contentArray = array();
129 break;
130
131 case 'MediaObject':
132 $this->mediaObjects[] = $a_attribs;
133 break;
134 }
135 }

◆ handlerCharacterData()

ilForumXMLParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Parameters
resource$a_xml_parserxml parser
string$a_datacharacter data

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

720 {
721 if ($a_data != "\n") {
722 // Replace multiple tabs with one space
723 $a_data = preg_replace("/\t+/", " ", $a_data);
724
725 $this->cdata .= $a_data;
726 }
727 }

◆ handlerEndTag()

ilForumXMLParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name

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

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

References $id, $path, $x, ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), date, getImportDirectory(), ilForumProperties\getInstance(), getNewForumPk(), getSchemaVersion(), and getUserIdAndAlias().

+ Here is the call graph for this function:

◆ setHandlers()

ilForumXMLParser::setHandlers (   $a_xml_parser)

set event handlers

Parameters
resourcereference to the xml parser @access private

Reimplemented from ilSaxParser.

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

94 {
95 xml_set_object($a_xml_parser, $this);
96 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
97 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
98 }

◆ setImportDirectory()

ilForumXMLParser::setImportDirectory (   $a_val)

Set import directory.

Parameters
stringimport directory

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

57 {
58 $this->importDirectory = $a_val;
59 }

◆ setImportInstallId()

ilForumXMLParser::setImportInstallId (   $id)

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

696 {
697 $this->import_install_id = $id;
698 }

References $id.

◆ setSchemaVersion()

ilForumXMLParser::setSchemaVersion (   $schema_version)
Parameters
null | string$schema_version

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

83 {
84 $this->schema_version = $schema_version;
85 }

References $schema_version.

◆ start()

ilForumXMLParser::start ( )

starts parsing an changes object by side effect.

Returns
boolean true, if no errors happend.

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

736 {
737 $this->startParsing();
738 return $this->result > 0;
739 }
startParsing()
stores xml data in array

References ilSaxParser\startParsing().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilForumXMLParser::$db
private

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

◆ $entity

ilForumXMLParser::$entity
private

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

◆ $forum

ilForumXMLParser::$forum
private

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

Referenced by __construct().

◆ $import_install_id

ilForumXMLParser::$import_install_id = null
private

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

◆ $mapping

ilForumXMLParser::$mapping
private
Initial value:
= array(
'frm' => array(),
'thr' => array(),
'pos' => array()
)

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

◆ $mediaObjects

ilForumXMLParser::$mediaObjects = array()
protected

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

◆ $schema_version

ilForumXMLParser::$schema_version = null
protected

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

Referenced by getSchemaVersion(), and setSchemaVersion().

◆ $user_id_mapping

ilForumXMLParser::$user_id_mapping = array()
private

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


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