154 $this->cdata = trim($this->cdata);
155 $property = strtolower($this->entity) .
'Array';
157 if (!property_exists($this, $property)) {
161 $propertyValue = &$this->{$property};
165 $query_num_posts =
'SELECT COUNT(pos_pk) cnt FROM frm_posts WHERE pos_top_fk = ' . $this->db->quote(
166 $this->lastHandledForumId,
169 $res_pos = $this->db->query($query_num_posts);
170 $data_pos = $this->db->fetchAssoc($res_pos);
171 $num_posts = (
int) $data_pos[
'cnt'];
173 $query_num_threads =
'SELECT COUNT(thr_pk) cnt FROM frm_threads WHERE thr_top_fk = ' . $this->db->quote(
174 $this->lastHandledForumId,
177 $res_thr = $this->db->query($query_num_threads);
178 $data_thr = $this->db->fetchAssoc($res_thr);
179 $num_threads = (
int) $data_thr[
'cnt'];
182 if ($this->lastHandledPostId !== 0) {
183 $update_str = implode(
'#', [
184 (
string) $this->lastHandledForumId,
185 (
string) $this->lastHandledThreadId,
186 (
string) $this->lastHandledPostId
190 $this->db->manipulateF(
192 SET top_last_post = %s, 194 top_num_threads = %s, 196 WHERE top_frm_fk = %s',
197 [
'text',
'integer',
'integer',
'integer',
'integer'],
198 [$update_str, $num_posts, $num_threads, $this->frm_last_mapped_top_usr_id, $this->forum_obj_id]
232 case 'ThreadRatings':
236 case 'PostingActivation':
240 case 'PresetSubject':
248 case 'NotificationType':
252 case 'NotificationEvents':
256 case 'ForceNotification':
260 case 'ToggleNotification':
291 case 'isAuthorModerator':
297 if ($this->entity ===
'forum' && $this->forumArray !== []) {
301 $this->forum->createSettings();
304 (
int) ($this->forumArray[
'UserId'] ?? 0),
307 $this->frm_last_mapped_top_usr_id = $forum_array[
'usr_id'];
310 (
int) ($this->forumArray[
'UpdateUserId'] ?? 0),
318 $this->forum->setDescription(
321 $this->forum->update();
322 $this->forum->updateModificationUserId($update_forum_array[
'usr_id']);
325 $newObjProp->setDefaultView(
328 $newObjProp->setAnonymisation((
bool) ($this->forumArray[
'Pseudonyms'] ??
false));
329 $newObjProp->setStatisticsStatus((
bool) ($this->forumArray[
'Statistics'] ??
false));
330 $newObjProp->setIsThreadRatingEnabled((
bool) ($this->forumArray[
'ThreadRatings'] ??
false));
331 $newObjProp->setPostActivation((
bool) ($this->forumArray[
'PostingActivation'] ??
false));
332 $newObjProp->setPresetSubject((
bool) ($this->forumArray[
'PresetSubject'] ??
false));
333 $newObjProp->setAddReSubject((
bool) ($this->forumArray[
'PresetRe'] ??
false));
334 $newObjProp->setNotificationType((
string) ($this->forumArray[
'NotificationType'] ?:
'all_users'));
335 $newObjProp->setInterestedEvents((
int) ($this->forumArray[
'NotificationEvents'] ?? 0));
336 $newObjProp->setAdminForceNoti((
bool) ($this->forumArray[
'ForceNotification'] ??
false));
337 $newObjProp->setUserToggleNoti((
bool) ($this->forumArray[
'ToggleNotification'] ??
false));
338 $newObjProp->setFileUploadAllowed((
bool) ($this->forumArray[
'FileUpload'] ??
false));
339 $newObjProp->setMarkModeratorPosts((
bool) ($this->forumArray[
'MarkModeratorPosts'] ??
false));
340 $newObjProp->update();
343 $this->forum_obj_id = $newObjProp->getObjId();
344 $this->mapping[
'frm'][$this->forumArray[
'Id']] =
$id;
345 $this->lastHandledForumId =
$id;
347 $this->importMapping->addMapping(
348 'components/ILIAS/COPage',
350 'frm:' . $this->forumArray[
'ObjId'],
351 'frm:' . $this->forum->getId()
354 if ($this->last_handled_style_id) {
356 $this->last_handled_style_id =
null;
359 $this->forumArray = [];
365 if ($this->lastHandledPostId !== 0) {
366 $update_str = implode(
'#', [
367 (
string) $this->lastHandledForumId,
368 (
string) $this->lastHandledThreadId,
369 (
string) $this->lastHandledPostId
373 $this->db->manipulateF(
374 'UPDATE frm_threads SET thr_last_post = %s WHERE thr_pk = %s',
376 [$update_str, $this->lastHandledThreadId]
392 case 'MarkModeratorPosts':
399 if ($this->entity ===
'thread' && $this->lastHandledForumId && $this->threadArray !== []) {
401 $this->forumThread->setId((
int) ($this->threadArray[
'Id'] ?? 0));
402 $this->forumThread->setForumId($this->lastHandledForumId);
403 $this->forumThread->setSubject(
406 $this->forumThread->setSticky((
bool) ($this->threadArray[
'Sticky'] ??
false));
407 $this->forumThread->setClosed((
bool) ($this->threadArray[
'Closed'] ??
false));
409 $this->forumThread->setImportName(
410 isset($this->threadArray[
'ImportName']) ?
414 $this->forumThread->setCreateDate($this->threadArray[
'CreateDate']);
415 $this->forumThread->setChangeDate($this->threadArray[
'UpdateDate']);
418 (
int) ($this->threadArray[
'UserId'] ?? 0),
422 $this->forumThread->setDisplayUserId($usr_data[
'usr_id']);
423 $this->forumThread->setUserAlias($usr_data[
'usr_alias']);
426 $this->threadArray[
'AuthorId'] = $this->threadArray[
'UserId'];
430 (
int) ($this->threadArray[
'AuthorId'] ?? 0)
432 $this->forumThread->setThrAuthorId($author_id_data[
'usr_id']);
434 $this->forumThread->insert();
436 $this->mapping[
'thr'][$this->threadArray[
'Id']] = $this->forumThread->getId();
437 $this->lastHandledThreadId = $this->forumThread->getId();
438 $this->threadArray = [];
449 case 'CensorshipMessage':
485 $this->entity ===
'post' &&
486 $this->lastHandledForumId &&
487 $this->postArray !== [] &&
488 $this->forumThread &&
489 $this->lastHandledThreadId
492 $this->forumPost->setThread($this->forumThread);
494 $this->forumPost->setId((
int) $this->postArray[
'Id']);
495 $this->forumPost->setCensorship((
bool) ($this->postArray[
'Censorship'] ??
false));
496 $this->forumPost->setCensorshipComment(
499 $this->forumPost->setNotification((
bool) ($this->postArray[
'Notification'] ??
false));
500 $this->forumPost->setStatus((
bool) ($this->postArray[
'Status'] ??
false));
502 $this->forumPost->setMessage($purifier->purify((
string) ($this->postArray[
'Message'] ??
'')));
503 $this->forumPost->setSubject(
ilUtil::stripSlashes((
string) ($this->postArray[
'Subject'] ??
'')));
504 $this->forumPost->setLft((
int) $this->postArray[
'Lft']);
505 $this->forumPost->setRgt((
int) $this->postArray[
'Rgt']);
506 $this->forumPost->setDepth((
int) $this->postArray[
'Depth']);
507 $this->forumPost->setParentId((
int) $this->postArray[
'ParentId']);
508 $this->forumPost->setThreadId($this->lastHandledThreadId);
509 $this->forumPost->setForumId($this->lastHandledForumId);
511 $this->forumPost->setImportName(
512 isset($this->postArray[
'ImportName']) ?
516 $this->forumPost->setCreateDate($this->postArray[
'CreateDate']);
517 $this->forumPost->setChangeDate($this->postArray[
'UpdateDate']);
520 (
int) ($this->postArray[
'UserId'] ?? 0),
524 (
int) ($this->postArray[
'UpdateUserId'] ?? 0)
526 $this->forumPost->setDisplayUserId($usr_data[
'usr_id']);
527 $this->forumPost->setUserAlias($usr_data[
'usr_alias']);
528 $this->forumPost->setUpdateUserId($update_usr_data[
'usr_id']);
531 $this->postArray[
'AuthorId'] = $this->postArray[
'UserId'];
534 (
int) ($this->postArray[
'AuthorId'] ?? 0)
536 $this->forumPost->setPosAuthorId((
int) $author_id_data[
'usr_id']);
538 if (isset($this->postArray[
'isAuthorModerator']) && strtoupper($this->postArray[
'isAuthorModerator']) ===
'NULL') {
539 $this->forumPost->setIsAuthorModerator(
false);
541 $this->forumPost->setIsAuthorModerator((
bool) $this->postArray[
'isAuthorModerator']);
544 $this->forumPost->insert();
546 if (isset($this->postArray[
'ParentId'], $this->mapping[
'pos'][$this->postArray[
'ParentId']])) {
547 $parentId = (
int) $this->mapping[
'pos'][$this->postArray[
'ParentId']];
552 $postTreeNodeId = $this->db->nextId(
'frm_posts_tree');
553 $this->db->insert(
'frm_posts_tree', [
554 'fpt_pk' => [
'integer', $postTreeNodeId],
555 'thr_fk' => [
'integer', $this->lastHandledThreadId],
556 'pos_fk' => [
'integer', $this->forumPost->getId()],
557 'parent_pos' => [
'integer', $parentId],
558 'lft' => [
'integer', $this->postArray[
'Lft']],
559 'rgt' => [
'integer', $this->postArray[
'Rgt']],
560 'depth' => [
'integer', $this->postArray[
'Depth']],
561 'fpt_date' => [
'timestamp', date(
'Y-m-d H:i:s')]
564 $this->mapping[
'pos'][($this->postArray[
'Id'] ?? 0)] = $this->forumPost->getId();
565 $this->lastHandledPostId = $this->forumPost->getId();
567 $media_objects_found =
false;
568 foreach ($this->mediaObjects as $mob_attr) {
570 if (is_file($importfile)) {
572 basename($importfile),
578 $this->forumPost->setMessage(
581 'src="' . $mob_attr[
'label'] .
'"',
582 'src="' . preg_replace(
583 "/(il)_[\d]+_(mob)_([\d]+)/",
588 'src="' .
'il_' .
IL_INST_ID .
'_mob_' . $mob->getId() .
'"',
589 $this->forumPost->getMessage()
592 $media_objects_found =
true;
596 if ($media_objects_found) {
597 $this->forumPost->update();
599 $this->postArray = [];
611 $import_path = $this->contentArray[
'content'];
612 if ($import_path !==
'') {
614 $filedata->
importPath($import_path, (
int) $this->lastHandledPostId);
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
getUserIdAndAlias(int $imp_usr_id, string $imp_usr_alias='')
static getInstance(int $a_obj_id=0)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
int $last_handled_style_id
importPath(string $path_to_file, int $posting_id)
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
static getInstanceByType(string $type)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins