ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 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
 __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 4 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 36 of file class.ilForumXMLParser.php.

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

37  {
38  global $DIC;
39 
41  $this->forum = $forum;
42  $this->setXMLContent('<?xml version="1.0" encoding="utf-8"?>' . $a_xml_data);
43  $this->aobject = new ilObjUser(ANONYMOUS_USER_ID);
44  $this->db = $DIC->database();
45  }
const ANONYMOUS_USER_ID
Definition: constants.php:25
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
setXMLContent($a_xml_content)
+ Here is the call graph for this function:

Member Function Documentation

◆ getAnonymousArray()

ilForumXMLParser::getAnonymousArray ( )
private

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

Referenced by getUserIdAndAlias().

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

◆ getIdAndAliasArray()

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

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

References $param, $query, and $res.

Referenced by getUserIdAndAlias().

572  {
573  $select = 'SELECT od.obj_id, ud.login
574  FROM object_data od
575  INNER JOIN usr_data ud
576  ON od.obj_id = ud.usr_id';
577 
578  if ($param == 'import') {
579  $where = ' WHERE od.import_id = ' . $this->db->quote(
580  'il_' . $this->import_install_id . '_usr_' . $imp_usr_id,
581  'text'
582  );
583  }
584 
585  if ($param == 'user') {
586  $where = ' WHERE ud.usr_id = ' . $this->db->quote(
587  $imp_usr_id,
588  'integer'
589  );
590  }
591 
592  $query = $this->db->query($select . $where);
593 
594  while ($res = $this->db->fetchAssoc($query)) {
595  break;
596  }
597 
598  if ($res) {
599  return array(
600  'usr_id' => $res['obj_id'],
601  'usr_alias' => $res['login']
602  );
603  } else {
604  return false;
605  }
606  }
foreach($_POST as $key=> $value) $res
$param
Definition: xapitoken.php:29
$query
+ 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 703 of file class.ilForumXMLParser.php.

References $data, $query, and $res.

Referenced by handlerEndTag().

704  {
705  $query = "SELECT top_pk FROM frm_data
706  WHERE top_frm_fk = " . $this->db->quote(
707  $this->forum->getId(),
708  'integer'
709  );
710  $res = $this->db->query($query);
711  $data = $this->db->fetchAssoc($res);
712 
713  return $data['top_pk'];
714  }
$data
Definition: storeScorm.php:23
foreach($_POST as $key=> $value) $res
$query
+ 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 617 of file class.ilForumXMLParser.php.

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

Referenced by handlerEndTag().

618  {
619  if ((int) $imp_usr_id > 0) {
620  $newUsrId = -1;
621 
622  if ($this->import_install_id != IL_INST_ID && IL_INST_ID > 0) {
623  // Different installations
624  if ($this->user_id_mapping[$imp_usr_id]) {
625  return $this->user_id_mapping[$imp_usr_id];
626  } else {
627  $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
628 
629  if ($res) {
630  $this->user_id_mapping[$imp_usr_id] = $res;
631 
632  return $res;
633  } else {
634  $return_value = $this->getAnonymousArray();
635  $this->user_id_mapping[$imp_usr_id] = $return_value;
636 
637  return $return_value;
638  }
639  }
640  } elseif ($this->import_install_id == IL_INST_ID && IL_INST_ID == 0) {
641  // Eventually different installations. We cannot determine it.
642  if ($this->user_id_mapping[$imp_usr_id]) {
643  return $this->user_id_mapping[$imp_usr_id];
644  } else {
645  $res = $this->getIdAndAliasArray($imp_usr_id, 'import');
646 
647  if ($res) {
648  $this->user_id_mapping[$imp_usr_id] = $res;
649 
650  return $res;
651  } else {
652  // Same installation
653  if ($this->user_id_mapping[$imp_usr_id]) {
654  return $this->user_id_mapping[$imp_usr_id];
655  } else {
656  $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
657 
658  if ($res) {
659  $this->user_id_mapping[$imp_usr_id] = $res;
660 
661  return $res;
662  } else {
663  $return_value = $this->getAnonymousArray();
664  $this->user_id_mapping[$imp_usr_id] = $return_value;
665 
666  return $return_value;
667  }
668  }
669  }
670  }
671  } else {
672  // Same installation
673  if ($this->user_id_mapping[$imp_usr_id]) {
674  return $this->user_id_mapping[$imp_usr_id];
675  } else {
676  $res = $this->getIdAndAliasArray($imp_usr_id, 'user');
677 
678  if ($res) {
679  $this->user_id_mapping[$imp_usr_id] = $res;
680 
681  return $res;
682  } else {
683  $return_value = $this->getAnonymousArray();
684  $this->user_id_mapping[$imp_usr_id] = $return_value;
685 
686  return $return_value;
687  }
688  }
689  }
690  } else {
691  return array(
692  'usr_id' => $imp_usr_id,
693  'usr_alias' => $imp_usr_alias
694  );
695  }
696  }
const IL_INST_ID
Definition: constants.php:38
getIdAndAliasArray($imp_usr_id, $param='import')
foreach($_POST as $key=> $value) $res
+ 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  case 'Forum':
107  $this->entity = 'forum';
108  $this->forumArray = array();
109  break;
110 
111  case 'Thread':
112  $this->entity = 'thread';
113  $this->threadArray = array();
114  break;
115 
116  case 'Post':
117  $this->mediaObjects = array();
118  $this->entity = 'post';
119  $this->postArray = array();
120  break;
121 
122  case 'Content':
123  $this->entity = 'content';
124  $this->contentArray = array();
125  break;
126 
127  case 'MediaObject':
128  $this->mediaObjects[] = $a_attribs;
129  break;
130  }
131  }

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

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

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

References ilHtmlPurifierFactory\_getInstanceByType(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), ilFileDataForum\getForumPath(), getImportDirectory(), ilForumProperties\getInstance(), getNewForumPk(), getSchemaVersion(), getUserIdAndAlias(), IL_INST_ID, ilUtil\stripSlashes(), and ilForumProperties\VIEW_TREE.

140  {
141  $this->cdata = trim($this->cdata);
142  $arrayname = strtolower($this->entity) . 'Array';
143  $x = &$this->$arrayname;
144 
145  switch ($a_name) {
146  case 'Forum':
147  $query_num_posts = "SELECT COUNT(pos_pk) cnt
148  FROM frm_posts
149  WHERE pos_top_fk = " . $this->db->quote(
150  $this->lastHandledForumId,
151  'integer'
152  );
153 
154  $res_pos = $this->db->query($query_num_posts);
155  $data_pos = $this->db->fetchAssoc($res_pos);
156  $num_posts = $data_pos['cnt'];
157 
158  $query_num_threads = "SELECT COUNT(thr_pk) cnt
159  FROM frm_threads
160  WHERE thr_top_fk = " . $this->db->quote(
161  $this->lastHandledForumId,
162  'integer'
163  );
164 
165  $res_thr = $this->db->query($query_num_threads);
166  $data_thr = $this->db->fetchAssoc($res_thr);
167  $num_threads = $data_thr['cnt'];
168 
169  $update_str = "$this->lastHandledForumId#$this->lastHandledThreadId#$this->lastHandledPostId";
170  $this->db->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) {
273  // createSettings accesses superglobal $_GET array, which can cause problems
274  // with public_notifications of block settings
275  $this->forum->createSettings();
276 
277  $forum_array = $this->getUserIdAndAlias(
278  $this->forumArray['UserId'],
279  ''
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  );
288  // Store old user id
289  // Manipulate user object
290  // changed smeyer 28.7.16: the session id is not manipulated
291  // anymore. Instead the user is passwd ilObjForum::update()
292  $this->forum->setTitle(ilUtil::stripSlashes((string) ($this->forumArray["Title"] ?? '')));
293  $this->forum->setDescription(ilUtil::stripSlashes((string) ($this->forumArray["Description"] ?? '')));
294  $this->forum->update($update_forum_array['usr_id']);
295 
296  $newObjProp = ilForumProperties::getInstance($this->forum->getId());
297  $newObjProp->setDefaultView((int) ($this->forumArray['DefaultView'] ?? ilForumProperties::VIEW_TREE));
298  $newObjProp->setAnonymisation((bool) ($this->forumArray['Pseudonyms'] ?? false));
299  $newObjProp->setStatisticsStatus((bool) ($this->forumArray['Statistics'] ?? false));
300  $newObjProp->setIsThreadRatingEnabled((bool) ($this->forumArray['ThreadRatings'] ?? false));
301  $newObjProp->setPostActivation((bool) ($this->forumArray['PostingActivation'] ?? false));
302  $newObjProp->setPresetSubject((bool) ($this->forumArray['PresetSubject'] ?? false));
303  $newObjProp->setAddReSubject((bool) ($this->forumArray['PresetRe'] ?? false));
304  $newObjProp->setNotificationType((string) ($this->forumArray['NotificationType'] ?: 'all_users'));
305  $newObjProp->setAdminForceNoti((bool) ($this->forumArray['ForceNotification'] ?? false));
306  $newObjProp->setUserToggleNoti((bool) ($this->forumArray['ToggleNotification'] ?? false));
307  $newObjProp->setFileUploadAllowed((bool) ($this->forumArray['FileUpload'] ?? false));
308  $newObjProp->setThreadSorting((int) ($this->forumArray['Sorting'] ?? 0));
309  $newObjProp->setMarkModeratorPosts((bool) ($this->forumArray['MarkModeratorPosts'] ?? false));
310  $newObjProp->update();
311 
312  $id = $this->getNewForumPk();
313  $this->forum_obj_id = $newObjProp->getObjId();
314  $this->mapping['frm'][$this->forumArray['Id']] = $id;
315  $this->lastHandledForumId = $id;
316 
317  unset($this->forumArray);
318  }
319 
320  break;
321 
322  case 'Thread':
323  $update_str = "$this->lastHandledForumId#$this->lastHandledThreadId#$this->lastHandledPostId";
324  $this->db->manipulateF(
325  "UPDATE frm_threads
326  SET thr_last_post = %s
327  WHERE thr_pk = %s",
328  array('text', 'integer'),
329  array($update_str, $this->lastHandledThreadId)
330  );
331  break;
332 
333  case 'Subject':
334  $x['Subject'] = $this->cdata;
335  break;
336 
337  case 'Alias':
338  $x['Alias'] = $this->cdata;
339  break;
340 
341  case 'Sticky':
342  $x['Sticky'] = $this->cdata;
343  break;
344 
345  case 'Sorting':
346  $x['Sorting'] = $this->cdata;
347  break;
348 
349  case 'MarkModeratorPosts':
350  $x['MarkModeratorPosts'] = $this->cdata;
351  break;
352 
353  case 'Closed':
354  $x['Closed'] = $this->cdata;
355 
356  if ($this->entity == 'thread' && $this->threadArray) {
357  $this->forumThread = new ilForumTopic();
358  $this->forumThread->setId((int) ($this->threadArray['Id'] ?? 0));
359  $this->forumThread->setForumId($this->lastHandledForumId);
360  $this->forumThread->setSubject(ilUtil::stripSlashes((string) ($this->threadArray['Subject'] ?? '')));
361  $this->forumThread->setSticky((bool) ($this->threadArray['Sticky'] ?? false));
362  $this->forumThread->setClosed((bool) ($this->threadArray['Closed'] ?? false));
363  $this->forumThread->setImportName(
364  isset($this->threadArray['ImportName']) ?
365  ilUtil::stripSlashes($this->threadArray['ImportName']) :
366  null
367  );
368  $this->forumThread->setCreateDate($this->threadArray['CreateDate']);
369  $this->forumThread->setChangeDate($this->threadArray['UpdateDate']);
370 
371  $usr_data = $this->getUserIdAndAlias(
372  (int) ($this->threadArray['UserId'] ?? 0),
373  ilUtil::stripSlashes((string) ($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  $this->threadArray['AuthorId'] = $this->threadArray['UserId'];
381  }
382 
383  $author_id_data = $this->getUserIdAndAlias(
384  (int) ($this->threadArray['AuthorId'] ?? 0)
385  );
386  $this->forumThread->setThrAuthorId($author_id_data['usr_id']);
387 
388  $this->forumThread->insert();
389 
390  $this->mapping['thr'][$this->threadArray['Id']] = $this->forumThread->getId();
391  $this->lastHandledThreadId = $this->forumThread->getId();
392 
393  unset($this->threadArray);
394  }
395 
396  break;
397 
398  case 'Post':
399  break;
400 
401  case 'Censorship':
402  $x['Censorship'] = $this->cdata;
403  break;
404 
405  case 'CensorshipMessage':
406  $x['CensorshipMessage'] = $this->cdata;
407  break;
408 
409  case 'Notification':
410  $x['Notification'] = $this->cdata;
411  break;
412 
413  case 'ImportName':
414  $x['ImportName'] = $this->cdata;
415  break;
416 
417  case 'Status':
418  $x['Status'] = $this->cdata;
419  break;
420 
421  case 'Message':
422  $x['Message'] = $this->cdata;
423  break;
424 
425  case 'Lft':
426  $x['Lft'] = $this->cdata;
427  break;
428 
429  case 'Rgt':
430  $x['Rgt'] = $this->cdata;
431  break;
432 
433  case 'Depth':
434  $x['Depth'] = $this->cdata;
435  break;
436 
437  case 'ParentId':
438  $x['ParentId'] = $this->cdata;
439 
440  if ($this->entity == 'post' && $this->postArray) {
441  $this->forumPost = new ilForumPost();
442  $this->forumPost->setThread($this->forumThread);
443  $this->forumPost->setId((int) $this->postArray['Id']);
444  $this->forumPost->setCensorship((bool) ($this->postArray['Censorship'] ?? false));
445  $this->forumPost->setCensorshipComment(
446  ilUtil::stripSlashes((string) ($this->postArray['CensorshipMessage'] ?? ''))
447  );
448  $this->forumPost->setNotification((bool) ($this->postArray['Notification'] ?? false));
449  $this->forumPost->setStatus((bool) ($this->postArray['Status'] ?? false));
450  $purifier = ilHtmlPurifierFactory::_getInstanceByType('frm_post');
451  $this->forumPost->setMessage($purifier->purify((string) ($this->postArray['Message'] ?? '')));
452  $this->forumPost->setSubject(ilUtil::stripSlashes((string) ($this->postArray['Subject'] ?? '')));
453  $this->forumPost->setLft((int) $this->postArray['Lft']);
454  $this->forumPost->setRgt((int) $this->postArray['Rgt']);
455  $this->forumPost->setDepth((int) $this->postArray['Depth']);
456  $this->forumPost->setParentId((int) $this->postArray['ParentId']);
457  $this->forumPost->setThreadId($this->lastHandledThreadId);
458  $this->forumPost->setForumId($this->lastHandledForumId);
459 
460  $this->forumPost->setImportName(
461  isset($this->postArray['ImportName']) ?
462  ilUtil::stripSlashes($this->postArray['ImportName']) :
463  null
464  );
465  $this->forumPost->setCreateDate($this->postArray['CreateDate']);
466  $this->forumPost->setChangeDate($this->postArray['UpdateDate']);
467 
468  $usr_data = $this->getUserIdAndAlias(
469  (int) ($this->postArray['UserId'] ?? 0),
470  ilUtil::stripSlashes((string) ($this->postArray['Alias'] ?? ''))
471  );
472  $update_usr_data = $this->getUserIdAndAlias(
473  (int) ($this->postArray['UpdateUserId'] ?? 0)
474  );
475  $this->forumPost->setDisplayUserId($usr_data['usr_id']);
476  $this->forumPost->setUserAlias($usr_data['usr_alias']);
477  $this->forumPost->setUpdateUserId($update_usr_data['usr_id']);
478 
479  if (version_compare($this->getSchemaVersion(), '4.5.0', '<=')) {
480  $this->postArray['AuthorId'] = $this->postArray['UserId'];
481  }
482  $author_id_data = $this->getUserIdAndAlias(
483  (int) ($this->postArray['AuthorId'] ?? 0)
484  );
485  $this->forumPost->setPosAuthorId((int) $author_id_data['usr_id']);
486 
487  if ($this->postArray['isAuthorModerator'] === 'NULL') {
488  $this->forumPost->setIsAuthorModerator(null);
489  } else {
490  $this->forumPost->setIsAuthorModerator((int) $this->postArray['isAuthorModerator']);
491  }
492 
493  $this->forumPost->insert();
494 
495  if (isset($this->postArray['ParentId'], $this->mapping['pos'][$this->postArray['ParentId']])) {
496  $parentId = (int) $this->mapping['pos'][$this->postArray['ParentId']];
497  } else {
498  $parentId = 0;
499  }
500 
501  $postTreeNodeId = $this->db->nextId('frm_posts_tree');
502  $this->db->insert('frm_posts_tree', array(
503  'fpt_pk' => array('integer', $postTreeNodeId),
504  'thr_fk' => array('integer', $this->lastHandledThreadId),
505  'pos_fk' => array('integer', $this->forumPost->getId()),
506  'parent_pos' => array('integer', $parentId),
507  'lft' => array('integer', $this->postArray['Lft']),
508  'rgt' => array('integer', $this->postArray['Rgt']),
509  'depth' => array('integer', $this->postArray['Depth']),
510  'fpt_date' => array('timestamp', date('Y-m-d H:i:s'))
511  ));
512 
513  $this->mapping['pos'][$this->postArray['Id']] = $this->forumPost->getId();
514  $this->lastHandledPostId = $this->forumPost->getId();
515 
516  $media_objects_found = false;
517  foreach ($this->mediaObjects as $mob_attr) {
518  $importfile = $this->getImportDirectory() . '/' . $mob_attr['uri'];
519  if (file_exists($importfile)) {
520  $mob = ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, false);
521  ilObjMediaObject::_saveUsage($mob->getId(), "frm:html", $this->forumPost->getId());
522 
523  $this->forumPost->setMessage(
524  str_replace(
525  array(
526  "src=\"" . $mob_attr["label"] . "\"",
527  "src=\"" . preg_replace("/(il)_[\d]+_(mob)_([\d]+)/", "$1_0_$2_$3", $mob_attr["label"]) . "\""
528  ),
529  "src=\"" . "il_" . IL_INST_ID . "_mob_" . $mob->getId() . "\"",
530  $this->forumPost->getMessage()
531  )
532  );
533  $media_objects_found = true;
534  }
535  }
536 
537  if ($media_objects_found) {
538  $this->forumPost->update();
539  }
540 
541  unset($this->postArray);
542  }
543 
544  break;
545 
546  case 'Content':
547  $x['content'] = $this->cdata;
548  break;
549 
550  case 'Attachment':
551  $filedata = new ilFileDataForum($this->forum->getId(), $this->lastHandledPostId);
552 
553  $importPath = $this->contentArray['content'];
554 
555  if (strlen($importPath)) {
556  $importPath = $this->getImportDirectory() . '/' . $importPath;
557 
558  $newFilename = preg_replace("/^\d+_\d+(_.*)/ims", $this->forum->getId() . "_" . $this->lastHandledPostId . "$1", basename($importPath));
559  $path = $filedata->getForumPath();
560  $newPath = $path . '/' . $newFilename;
561  @copy($importPath, $newPath);
562  }
563  break;
564  }
565 
566  $this->cdata = '';
567 
568  return;
569  }
getImportDirectory()
Get import directory.
const IL_INST_ID
Definition: constants.php:38
getUserIdAndAlias($imp_usr_id, $imp_usr_alias='')
static _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)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
This class handles all operations on files for the forum object.
static _getInstanceByType(string $type)
Factory method for creating purifier instances.
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.
getForumPath()
get forum path public
+ 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 698 of file class.ilForumXMLParser.php.

699  {
700  $this->import_install_id = $id;
701  }

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

References ilSaxParser\startParsing().

739  {
740  $this->startParsing();
741  return $this->result > 0;
742  }
startParsing()
stores xml data in array
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilForumXMLParser::$db
private

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

◆ $entity

ilForumXMLParser::$entity
private

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

◆ $forum

ilForumXMLParser::$forum
private

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

Referenced by __construct().

◆ $import_install_id

ilForumXMLParser::$import_install_id = null
private

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

◆ $mapping

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

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

◆ $mediaObjects

ilForumXMLParser::$mediaObjects = array()
protected

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

◆ $schema_version

ilForumXMLParser::$schema_version = null
protected

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

Referenced by getSchemaVersion(), and setSchemaVersion().

◆ $user_id_mapping

ilForumXMLParser::$user_id_mapping = array()
private

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


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