ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
 ilSaxParser ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object 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 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
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
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...
 
 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...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. 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()
 

Additional Inherited Members

- 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 public

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

References $forum, and ilSaxParser\setXMLContent().

40  {
41  parent::__construct();
42  $this->forum = $forum;
43  $this->setXMLContent('<?xml version="1.0" encoding="utf-8"?>'.$a_xml_data);
44  $this->aobject = new ilObjUser(ANONYMOUS_USER_ID);
45  }
setXMLContent($a_xml_content)
+ Here is the call graph for this function:

Member Function Documentation

◆ getAnonymousArray()

ilForumXMLParser::getAnonymousArray ( )
private

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

Referenced by getUserIdAndAlias().

621  {
622  return array(
623  'usr_id' => $this->aobject->getId(),
624  'usr_alias' => $this->aobject->getLogin()
625  );
626  }
+ Here is the caller graph for this function:

◆ getIdAndAliasArray()

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

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

References $ilDB, $query, and $res.

Referenced by getUserIdAndAlias().

578  {
579  global $ilDB;
580 
581  $select = 'SELECT od.obj_id, ud.login
582  FROM object_data od
583  INNER JOIN usr_data ud
584  ON od.obj_id = ud.usr_id';
585 
586  if($param == 'import')
587  {
588  $where = ' WHERE od.import_id = '.$ilDB->quote(
589  'il_'.$this->import_install_id.'_usr_'.$imp_usr_id, 'text'
590  );
591  }
592 
593  if($param == 'user')
594  {
595  $where = ' WHERE ud.usr_id = '.$ilDB->quote(
596  $imp_usr_id, 'integer'
597  );
598  }
599 
600  $query = $ilDB->query($select.$where);
601 
602  while( $res = $ilDB->fetchAssoc($query) )
603  {
604  break;
605  }
606 
607  if($res)
608  {
609  return array(
610  'usr_id' => $res['obj_id'],
611  'usr_alias' => $res['login']
612  );
613  }
614  else
615  {
616  return false;
617  }
618  }
global $ilDB
+ Here is the caller graph for this function:

◆ getImportDirectory()

ilForumXMLParser::getImportDirectory ( )

Get import directory.

Returns
string import directory

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

Referenced by handlerEndTag().

63  {
64  return $this->importDirectory;
65  }
+ Here is the caller graph for this function:

◆ getNewForumPk()

ilForumXMLParser::getNewForumPk ( )
private

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

References $data, $ilDB, $query, and $res.

Referenced by handlerEndTag().

750  {
751  global $ilDB;
752 
753  $query = "SELECT top_pk FROM frm_data
754  WHERE top_frm_fk = ".$ilDB->quote(
755  $this->forum->getId(), 'integer');
756  $res = $ilDB->query($query);
757  $data = $ilDB->fetchAssoc($res);
758 
759  return $data['top_pk'];
760  }
$data
global $ilDB
+ Here is the caller graph for this function:

◆ getSchemaVersion()

ilForumXMLParser::getSchemaVersion ( )
Returns
null|string

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

References $schema_version.

Referenced by handlerEndTag().

71  {
72  return $this->schema_version;
73  }
+ Here is the caller graph for this function:

◆ getUserIdAndAlias()

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

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

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

Referenced by handlerEndTag().

630  {
631  global $ilDB;
632 
633  if( (int)$imp_usr_id > 0 )
634  {
635  $newUsrId = -1;
636 
637  if( $this->import_install_id != IL_INST_ID && IL_INST_ID > 0 )
638  {
639  // Different installations
640  if( $this->user_id_mapping[$imp_usr_id] )
641  {
642  return $this->user_id_mapping[$imp_usr_id];
643  }
644  else
645  {
646  $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
647 
648  if($res)
649  {
650  $this->user_id_mapping[$imp_usr_id] = $res;
651 
652  return $res;
653  }
654  else
655  {
656  $return_value = $this->getAnonymousArray();
657  $this->user_id_mapping[$imp_usr_id] = $return_value;
658 
659  return $return_value;
660  }
661  }
662  }
663  else if( $this->import_install_id == IL_INST_ID && IL_INST_ID == 0 )
664  {
665  // Eventually different installations. We cannot determine it.
666  if( $this->user_id_mapping[$imp_usr_id] )
667  {
668  return $this->user_id_mapping[$imp_usr_id];
669  }
670  else
671  {
672  $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
673 
674  if($res)
675  {
676  $this->user_id_mapping[$imp_usr_id] = $res;
677 
678  return $res;
679  }
680  else
681  {
682  // Same installation
683  if( $this->user_id_mapping[$imp_usr_id] )
684  {
685  return $this->user_id_mapping[$imp_usr_id];
686  }
687  else
688  {
689  $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
690 
691  if($res)
692  {
693  $this->user_id_mapping[$imp_usr_id] = $res;
694 
695  return $res;
696  }
697  else
698  {
699  $return_value = $this->getAnonymousArray();
700  $this->user_id_mapping[$imp_usr_id] = $return_value;
701 
702  return $return_value;
703  }
704  }
705  }
706  }
707  }
708  else
709  {
710  // Same installation
711  if( $this->user_id_mapping[$imp_usr_id] )
712  {
713  return $this->user_id_mapping[$imp_usr_id];
714  }
715  else
716  {
717  $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
718 
719  if($res)
720  {
721  $this->user_id_mapping[$imp_usr_id] = $res;
722 
723  return $res;
724  }
725  else
726  {
727  $return_value = $this->getAnonymousArray();
728  $this->user_id_mapping[$imp_usr_id] = $return_value;
729 
730  return $return_value;
731  }
732  }
733  }
734  }
735  else
736  {
737  return array(
738  'usr_id' => $imp_usr_id,
739  'usr_alias' => $imp_usr_alias
740  );
741  }
742  }
getIdAndAliasArray($imp_usr_id, $param='import')
global $ilDB
+ 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 103 of file class.ilForumXMLParser.php.

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

◆ 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 768 of file class.ilForumXMLParser.php.

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

◆ 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 140 of file class.ilForumXMLParser.php.

References $_SESSION, $ilDB, $ilUser, $path, $x, ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), getImportDirectory(), ilForumProperties\getInstance(), getNewForumPk(), getSchemaVersion(), and getUserIdAndAlias().

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

◆ setHandlers()

ilForumXMLParser::setHandlers (   $a_xml_parser)

set event handlers

Parameters
resourcereference to the xml parser private

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

90  {
91  xml_set_object($a_xml_parser, $this);
92  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
93  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
94  }

◆ setImportDirectory()

ilForumXMLParser::setImportDirectory (   $a_val)

Set import directory.

Parameters
stringimport directory

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

53  {
54  $this->importDirectory = $a_val;
55  }

◆ setImportInstallId()

ilForumXMLParser::setImportInstallId (   $id)

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

745  {
746  $this->import_install_id = $id;
747  }

◆ setSchemaVersion()

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

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

References $schema_version.

79  {
80  $this->schema_version = $schema_version;
81  }

◆ start()

ilForumXMLParser::start ( )

starts parsing an changes object by side effect.

Returns
boolean true, if no errors happend.

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

References ilSaxParser\startParsing().

786  {
787  $this->startParsing();
788  return $this->result > 0;
789  }
startParsing()
stores xml data in array
+ Here is the call graph for this function:

Field Documentation

◆ $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: