ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 605 of file class.ilForumXMLParser.php.

Referenced by getUserIdAndAlias().

606  {
607  return array(
608  'usr_id' => $this->aobject->getId(),
609  'usr_alias' => $this->aobject->getLogin()
610  );
611  }
+ Here is the caller graph for this function:

◆ getIdAndAliasArray()

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

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

References $ilDB, $query, and $res.

Referenced by getUserIdAndAlias().

563  {
564  global $ilDB;
565 
566  $select = 'SELECT od.obj_id, ud.login
567  FROM object_data od
568  INNER JOIN usr_data ud
569  ON od.obj_id = ud.usr_id';
570 
571  if($param == 'import')
572  {
573  $where = ' WHERE od.import_id = '.$ilDB->quote(
574  'il_'.$this->import_install_id.'_usr_'.$imp_usr_id, 'text'
575  );
576  }
577 
578  if($param == 'user')
579  {
580  $where = ' WHERE ud.usr_id = '.$ilDB->quote(
581  $imp_usr_id, 'integer'
582  );
583  }
584 
585  $query = $ilDB->query($select.$where);
586 
587  while( $res = $ilDB->fetchAssoc($query) )
588  {
589  break;
590  }
591 
592  if($res)
593  {
594  return array(
595  'usr_id' => $res['obj_id'],
596  'usr_alias' => $res['login']
597  );
598  }
599  else
600  {
601  return false;
602  }
603  }
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 734 of file class.ilForumXMLParser.php.

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

Referenced by handlerEndTag().

735  {
736  global $ilDB;
737 
738  $query = "SELECT top_pk FROM frm_data
739  WHERE top_frm_fk = ".$ilDB->quote(
740  $this->forum->getId(), 'integer');
741  $res = $ilDB->query($query);
742  $data = $ilDB->fetchAssoc($res);
743 
744  return $data['top_pk'];
745  }
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 614 of file class.ilForumXMLParser.php.

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

Referenced by handlerEndTag().

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

754  {
755  if($a_data != "\n")
756  {
757  // Replace multiple tabs with one space
758  $a_data = preg_replace("/\t+/"," ",$a_data);
759 
760  $this->cdata .= $a_data;
761  }
762  }

◆ 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, 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 'UpdateUserId':
255  $x['UpdateUserId'] = $this->cdata;
256  break;
257 
258  case 'AuthorId':
259  $x['AuthorId'] = $this->cdata;
260  break;
261  case 'isAuthorModerator':
262  $x['isAuthorModerator'] = $this->cdata;
263  break;
264 
265  case 'UserId':
266  $x['UserId'] = $this->cdata;
267  if( $this->entity == 'forum' && $this->forumArray )
268  {
270  // createSettings accesses superglobal $_GET array, which can cause problems
271  // with public_notifications of block settings
272  $this->forum->createSettings();
273 
274  $forum_array = $this->getUserIdAndAlias(
275  $this->forumArray['UserId'], ''
276  );
277 
278  $this->frm_last_mapped_top_usr_id = $forum_array['usr_id'];
279 
280  $update_forum_array = $this->getUserIdAndAlias(
281  $this->forumArray['UpdateUserId'], ''
282  );
283  // Store old user id
284  $oldUsrId = $_SESSION["AccountId"];
285  // Manipulate user object
286  $_SESSION["AccountId"] = $update_forum_array['usr_id'];
287  $this->forum->setTitle($this->forumArray["Title"]);
288  $this->forum->setDescription($this->forumArray["Description"]);
289  $this->forum->update();
290  // Restore old user id
291  $_SESSION["AccountId"] = $oldUsrId;
292 
293  // create frm_settings
294  $newObjProp = ilForumProperties::getInstance($this->forum->getId());
295  $newObjProp->setDefaultView((int)$this->forumArray['DefaultView']);
296  $newObjProp->setAnonymisation((int)$this->forumArray['Pseudonyms']);
297  $newObjProp->setStatisticsStatus((int)$this->forumArray['Statistics']);
298  $newObjProp->setIsThreadRatingEnabled((int)$this->forumArray['ThreadRatings']);
299  $newObjProp->setPostActivation((int)$this->forumArray['PostingActivation']);
300  $newObjProp->setPresetSubject((int)$this->forumArray['PresetSubject']);
301  $newObjProp->setAddReSubject((int)$this->forumArray['PresetRe']);
302  $newObjProp->setNotificationType($this->forumArray['NotificationType'] ? $this->forumArray['NotificationType'] : 'all_users');
303  $newObjProp->setAdminForceNoti((int)$this->forumArray['ForceNotification']);
304  $newObjProp->setUserToggleNoti((int)$this->forumArray['ToggleNotification']);
305  $newObjProp->update();
306 
307  $id = $this->getNewForumPk();
308  $this->forum_obj_id = $newObjProp->getObjId();
309  $this->mapping['frm'][$this->forumArray['Id']] = $id;
310  $this->lastHandledForumId = $id;
311 
312  unset($this->forumArray);
313  }
314 
315  break;
316 
317  case 'Thread':
318  $update_str = "$this->lastHandledForumId#$this->lastHandledThreadId#$this->lastHandledPostId";
319  $ilDB->manipulateF(
320  "UPDATE frm_threads
321  SET thr_last_post = %s
322  WHERE thr_pk = %s",
323  array('text', 'integer'),
324  array($update_str, $this->lastHandledThreadId)
325  );
326  break;
327 
328  case 'Subject':
329  $x['Subject'] = $this->cdata;
330  break;
331 
332  case 'Alias':
333  $x['Alias'] = $this->cdata;
334  break;
335 
336  case 'Sticky':
337  $x['Sticky'] = $this->cdata;
338  break;
339 
340  case 'Closed':
341  $x['Closed'] = $this->cdata;
342 
343  if($this->entity == 'thread' && $this->threadArray)
344  {
345  require_once 'Modules/Forum/classes/class.ilForumTopic.php';
346 
347  $this->forumThread = new ilForumTopic();
348  $this->forumThread->setId($this->threadArray['Id']);
349  $this->forumThread->setForumId( $this->lastHandledForumId );
350  $this->forumThread->setSubject($this->threadArray['Subject']);
351  $this->forumThread->setSticky($this->threadArray['Sticky']);
352  $this->forumThread->setClosed($this->threadArray['Closed']);
353  $this->forumThread->setCreateDate($this->threadArray['CreateDate']);
354  $this->forumThread->setChangeDate($this->threadArray['UpdateDate']);
355  $this->forumThread->setImportName($this->threadArray['ImportName']);
356 
357  $usr_data = $this->getUserIdAndAlias(
358  $this->threadArray['UserId'], $this->threadArray['Alias']
359  );
360 
361  $this->forumThread->setDisplayUserId($usr_data['usr_id']);
362  $this->forumThread->setUserAlias($usr_data['usr_alias']);
363 
364  if(version_compare($this->getSchemaVersion(), '4.5.0', '<='))
365  {
366  $this->threadArray['AuthorId'] = $this->threadArray['UserId'];
367  }
368 
369  $author_id_data = $this->getUserIdAndAlias(
370  $this->threadArray['AuthorId']
371  );
372  $this->forumThread->setThrAuthorId((int)$author_id_data['usr_id']);
373 
374  $this->forumThread->insert();
375 
376  $this->mapping['thr'][$this->threadArray['Id']] = $this->forumThread->getId();
377  $this->lastHandledThreadId = $this->forumThread->getId();
378 
379  unset($this->threadArray);
380  }
381 
382  break;
383 
384  case 'Post':
385  break;
386 
387  case 'Censorship':
388  $x['Censorship'] = $this->cdata;
389  break;
390 
391  case 'CensorshipMessage':
392  $x['CensorshipMessage'] = $this->cdata;
393  break;
394 
395  case 'Notification':
396  $x['Notification'] = $this->cdata;
397  break;
398 
399  case 'ImportName':
400  $x['ImportName'] = $this->cdata;
401  break;
402 
403  case 'Status':
404  $x['Status'] = $this->cdata;
405  break;
406 
407  case 'Message':
408  $x['Message'] = $this->cdata;
409  break;
410 
411  case 'Lft':
412  $x['Lft'] = $this->cdata;
413  break;
414 
415  case 'Rgt':
416  $x['Rgt'] = $this->cdata;
417  break;
418 
419  case 'Depth':
420  $x['Depth'] = $this->cdata;
421  break;
422 
423  case 'ParentId':
424  $x['ParentId'] = $this->cdata;
425 
426  if($this->entity == 'post' && $this->postArray)
427  {
428  require_once 'Modules/Forum/classes/class.ilForumPost.php';
429 
430  $this->forumPost = new ilForumPost();
431  $this->forumPost->setId($this->postArray['Id']);
432  $this->forumPost->setCensorship($this->postArray['Censorship']);
433  $this->forumPost->setCensorshipComment($this->postArray['CensorshipMessage']);
434  $this->forumPost->setNotification($this->postArray['Notification']);
435  $this->forumPost->setImportName($this->postArray['ImportName']);
436  $this->forumPost->setStatus($this->postArray['Status']);
437  $this->forumPost->setMessage($this->postArray['Message']);
438  $this->forumPost->setSubject($this->postArray['Subject']);
439  $this->forumPost->setLft($this->postArray['Lft']);
440  $this->forumPost->setRgt($this->postArray['Rgt']);
441  $this->forumPost->setDepth($this->postArray['Depth']);
442  $this->forumPost->setParentId($this->postArray['ParentId']);
443  $this->forumPost->setThread($this->forumThread);
444  $this->forumPost->setThreadId($this->lastHandledThreadId);
445  $this->forumPost->setForumId($this->lastHandledForumId);
446  $this->forumPost->setCreateDate($this->postArray['CreateDate']);
447  $this->forumPost->setChangeDate($this->postArray['UpdateDate']);
448 
449  $usr_data = $this->getUserIdAndAlias(
450  $this->postArray['UserId'], $this->postArray['Alias']
451  );
452  $update_usr_data = $this->getUserIdAndAlias(
453  $this->postArray['UpdateUserId']
454  );
455  $this->forumPost->setDisplayUserId($usr_data['usr_id']);
456  $this->forumPost->setUserAlias($usr_data['usr_alias']);
457  $this->forumPost->setUpdateUserId($update_usr_data['usr_id']);
458 
459  if(version_compare($this->getSchemaVersion(), '4.5.0', '<='))
460  {
461  $this->postArray['AuthorId'] = $this->postArray['UserId'];
462  }
463  $author_id_data = $this->getUserIdAndAlias(
464  $this->postArray['AuthorId']
465  );
466  $this->forumPost->setPosAuthorId((int)$author_id_data['usr_id']);
467 
468  if($this->postArray['isAuthorModerator'] === 'NULL')
469  {
470  $this->forumPost->setIsAuthorModerator(NULL);
471  }
472  else
473  {
474  $this->forumPost->setIsAuthorModerator((int)$this->postArray['isAuthorModerator']);
475  }
476 
477  $this->forumPost->insert();
478 
479  if($this->mapping['pos'][$this->postArray['ParentId']])
480  {
481  $parentId = $this->mapping['pos'][$this->postArray['ParentId']];
482  }
483  else
484  {
485  $parentId = 0;
486  }
487 
488  $postTreeNodeId = $ilDB->nextId('frm_posts_tree');
489  $ilDB->insert('frm_posts_tree', array(
490  'fpt_pk' => array('integer', $postTreeNodeId),
491  'thr_fk' => array('integer', $this->lastHandledThreadId),
492  'pos_fk' => array('integer', $this->forumPost->getId()),
493  'parent_pos' => array('integer', $parentId),
494  'lft' => array('integer', $this->postArray['Lft']),
495  'rgt' => array('integer', $this->postArray['Rgt']),
496  'depth' => array('integer', $this->postArray['Depth']),
497  'fpt_date' => array('timestamp', date('Y-m-d H:i:s'))
498  ));
499 
500  $this->mapping['pos'][$this->postArray['Id']] = $this->forumPost->getId();
501  $this->lastHandledPostId = $this->forumPost->getId();
502 
503  $media_objects_found = false;
504  foreach($this->mediaObjects as $mob_attr)
505  {
506  $importfile = $this->getImportDirectory().'/'.$mob_attr['uri'];
507  if(file_exists($importfile))
508  {
509  $mob = ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, false);
510  ilObjMediaObject::_saveUsage($mob->getId(), "frm:html", $this->forumPost->getId());
511 
512  $this->forumPost->setMessage(
513  str_replace(
514  array(
515  "src=\"" . $mob_attr["label"] . "\"",
516  "src=\"" . preg_replace("/(il)_[\d]+_(mob)_([\d]+)/", "$1_0_$2_$3", $mob_attr["label"]) . "\""
517  ),
518  "src=\"" . "il_" . IL_INST_ID . "_mob_" . $mob->getId() . "\"",
519  $this->forumPost->getMessage()
520  )
521  );
522  $media_objects_found = true;
523  }
524  }
525 
526  if($media_objects_found)
527  {
528  $this->forumPost->update();
529  }
530 
531  unset($this->postArray);
532  }
533 
534  break;
535 
536  case 'Content':
537  $x['content'] = $this->cdata;
538  break;
539 
540  case 'Attachment':
541  $filedata = new ilFileDataForum($this->forum->getId(), $this->lastHandledPostId);
542 
543  $importPath = $this->contentArray['content'];
544 
545  if( strlen($importPath) )
546  {
547  $importPath = $this->getImportDirectory().'/'.$importPath;
548 
549  $newFilename = preg_replace("/^\d+_\d+(_.*)/ims", $this->forum->getId()."_".$this->lastHandledPostId."$1", basename($importPath));
550  $path = $filedata->getForumPath();
551  $newPath = $path.'/'.$newFilename;
552  @copy($importPath, $newPath);
553  }
554  break;
555  }
556 
557  $this->cdata = '';
558 
559  return;
560  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
getImportDirectory()
Get import directory.
getUserIdAndAlias($imp_usr_id, $imp_usr_alias='')
& _saveTempFileAsMediaObject($name, $tmp_name, $upload=TRUE)
Create new media object and update page in db and return new media object.
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.
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 729 of file class.ilForumXMLParser.php.

730  {
731  $this->import_install_id = $id;
732  }

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

References ilSaxParser\startParsing().

771  {
772  $this->startParsing();
773  return $this->result > 0;
774  }
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: