150 $this->cdata = trim($this->cdata);
151 $property = strtolower($this->entity) .
'Array';
153 if (!property_exists($this, $property)) {
157 $propertyValue = &$this->{$property};
161 $query_num_posts =
"SELECT COUNT(pos_pk) cnt FROM frm_posts WHERE pos_top_fk = " . $this->db->quote(
162 $this->lastHandledForumId,
165 $res_pos = $this->db->query($query_num_posts);
166 $data_pos = $this->db->fetchAssoc($res_pos);
167 $num_posts = (
int) $data_pos[
'cnt'];
169 $query_num_threads =
"SELECT COUNT(thr_pk) cnt FROM frm_threads WHERE thr_top_fk = " . $this->db->quote(
170 $this->lastHandledForumId,
173 $res_thr = $this->db->query($query_num_threads);
174 $data_thr = $this->db->fetchAssoc($res_thr);
175 $num_threads = (
int) $data_thr[
'cnt'];
178 if ($this->lastHandledPostId !== 0) {
179 $update_str = implode(
'#', [
180 (
string) $this->lastHandledForumId,
181 (
string) $this->lastHandledThreadId,
182 (
string) $this->lastHandledPostId
186 $this->db->manipulateF(
188 SET top_last_post = %s, 190 top_num_threads = %s, 192 WHERE top_frm_fk = %s",
193 [
'text',
'integer',
'integer',
'integer',
'integer'],
194 [$update_str, $num_posts, $num_threads, $this->frm_last_mapped_top_usr_id, $this->forum_obj_id]
228 case 'ThreadRatings':
232 case 'PostingActivation':
236 case 'PresetSubject':
244 case 'NotificationType':
248 case 'NotificationEvents':
252 case 'ForceNotification':
256 case 'ToggleNotification':
287 case 'isAuthorModerator':
293 if ($this->entity ===
'forum' && $this->forumArray !== []) {
297 $this->forum->createSettings();
300 (
int) ($this->forumArray[
'UserId'] ?? 0),
303 $this->frm_last_mapped_top_usr_id = $forum_array[
'usr_id'];
306 (
int) ($this->forumArray[
'UpdateUserId'] ?? 0),
314 $this->forum->setDescription(
ilUtil::stripSlashes((
string) ($this->forumArray[
"Description"] ??
'')));
315 $this->forum->update();
316 $this->forum->updateModificationUserId($update_forum_array[
'usr_id']);
320 $newObjProp->setAnonymisation((
bool) ($this->forumArray[
'Pseudonyms'] ??
false));
321 $newObjProp->setStatisticsStatus((
bool) ($this->forumArray[
'Statistics'] ??
false));
322 $newObjProp->setIsThreadRatingEnabled((
bool) ($this->forumArray[
'ThreadRatings'] ??
false));
323 $newObjProp->setPostActivation((
bool) ($this->forumArray[
'PostingActivation'] ??
false));
324 $newObjProp->setPresetSubject((
bool) ($this->forumArray[
'PresetSubject'] ??
false));
325 $newObjProp->setAddReSubject((
bool) ($this->forumArray[
'PresetRe'] ??
false));
326 $newObjProp->setNotificationType(
327 NotificationType::tryFrom(
328 $this->forumArray[
'NotificationType'] ?? NotificationType::ALL_USERS->value
329 ) ?? NotificationType::ALL_USERS
331 $newObjProp->setInterestedEvents((
int) ($this->forumArray[
'NotificationEvents'] ?? 0));
332 $newObjProp->setAdminForceNoti((
bool) ($this->forumArray[
'ForceNotification'] ??
false));
333 $newObjProp->setUserToggleNoti((
bool) ($this->forumArray[
'ToggleNotification'] ??
false));
334 $newObjProp->setFileUploadAllowed((
bool) ($this->forumArray[
'FileUpload'] ??
false));
335 $newObjProp->setMarkModeratorPosts((
bool) ($this->forumArray[
'MarkModeratorPosts'] ??
false));
336 $newObjProp->update();
339 $this->forum_obj_id = $newObjProp->getObjId();
340 $this->mapping[
'frm'][$this->forumArray[
'Id']] =
$id;
341 $this->lastHandledForumId =
$id;
343 $this->importMapping->addMapping(
346 'frm:' . $this->forumArray[
'ObjId'],
347 'frm:' . $this->forum->getId()
350 if ($this->last_handled_style_id) {
352 $this->last_handled_style_id = null;
355 $this->forumArray = [];
361 if ($this->lastHandledPostId !== 0) {
362 $update_str = implode(
'#', [
363 (
string) $this->lastHandledForumId,
364 (
string) $this->lastHandledThreadId,
365 (
string) $this->lastHandledPostId
369 $this->db->manipulateF(
370 "UPDATE frm_threads SET thr_last_post = %s WHERE thr_pk = %s",
372 [$update_str, $this->lastHandledThreadId]
388 case 'MarkModeratorPosts':
395 if ($this->entity ===
'thread' && $this->lastHandledForumId && $this->threadArray !== []) {
397 $this->forumThread->setId((
int) ($this->threadArray[
'Id'] ?? 0));
398 $this->forumThread->setForumId($this->lastHandledForumId);
399 $this->forumThread->setSubject(
ilUtil::stripSlashes((
string) ($this->threadArray[
'Subject'] ??
'')));
400 $this->forumThread->setSticky((
bool) ($this->threadArray[
'Sticky'] ??
false));
401 $this->forumThread->setClosed((
bool) ($this->threadArray[
'Closed'] ??
false));
403 $this->forumThread->setImportName(
404 isset($this->threadArray[
'ImportName']) ?
408 $this->forumThread->setCreateDate($this->threadArray[
'CreateDate']);
409 $this->forumThread->setChangeDate($this->threadArray[
'UpdateDate']);
412 (
int) ($this->threadArray[
'UserId'] ?? 0),
416 $this->forumThread->setDisplayUserId($usr_data[
'usr_id']);
417 $this->forumThread->setUserAlias($usr_data[
'usr_alias']);
420 $this->threadArray[
'AuthorId'] = $this->threadArray[
'UserId'];
424 (
int) ($this->threadArray[
'AuthorId'] ?? 0)
426 $this->forumThread->setThrAuthorId($author_id_data[
'usr_id']);
428 $this->forumThread->insert();
430 $this->mapping[
'thr'][$this->threadArray[
'Id']] = $this->forumThread->getId();
431 $this->lastHandledThreadId = $this->forumThread->getId();
432 $this->threadArray = [];
443 case 'CensorshipMessage':
479 $this->entity ===
'post' &&
480 $this->lastHandledForumId &&
481 $this->postArray !== [] &&
482 $this->forumThread &&
483 $this->lastHandledThreadId
486 $this->forumPost->setThread($this->forumThread);
488 $this->forumPost->setId((
int) $this->postArray[
'Id']);
489 $this->forumPost->setCensorship((
bool) ($this->postArray[
'Censorship'] ??
false));
490 $this->forumPost->setCensorshipComment(
493 $this->forumPost->setNotification((
bool) ($this->postArray[
'Notification'] ??
false));
494 $this->forumPost->setStatus((
bool) ($this->postArray[
'Status'] ??
false));
496 $this->forumPost->setMessage($purifier->purify((
string) ($this->postArray[
'Message'] ??
'')));
497 $this->forumPost->setSubject(
ilUtil::stripSlashes((
string) ($this->postArray[
'Subject'] ??
'')));
498 $this->forumPost->setLft((
int) $this->postArray[
'Lft']);
499 $this->forumPost->setRgt((
int) $this->postArray[
'Rgt']);
500 $this->forumPost->setDepth((
int) $this->postArray[
'Depth']);
501 $this->forumPost->setParentId((
int) $this->postArray[
'ParentId']);
502 $this->forumPost->setThreadId($this->lastHandledThreadId);
503 $this->forumPost->setForumId($this->lastHandledForumId);
505 $this->forumPost->setImportName(
506 isset($this->postArray[
'ImportName']) ?
510 $this->forumPost->setCreateDate($this->postArray[
'CreateDate']);
511 $this->forumPost->setChangeDate($this->postArray[
'UpdateDate']);
514 (
int) ($this->postArray[
'UserId'] ?? 0),
518 (
int) ($this->postArray[
'UpdateUserId'] ?? 0)
520 $this->forumPost->setDisplayUserId($usr_data[
'usr_id']);
521 $this->forumPost->setUserAlias($usr_data[
'usr_alias']);
522 $this->forumPost->setUpdateUserId($update_usr_data[
'usr_id']);
525 $this->postArray[
'AuthorId'] = $this->postArray[
'UserId'];
528 (
int) ($this->postArray[
'AuthorId'] ?? 0)
530 $this->forumPost->setPosAuthorId((
int) $author_id_data[
'usr_id']);
532 if (isset($this->postArray[
'isAuthorModerator']) && strtoupper($this->postArray[
'isAuthorModerator']) ===
'NULL') {
533 $this->forumPost->setIsAuthorModerator(
false);
535 $this->forumPost->setIsAuthorModerator((
bool) $this->postArray[
'isAuthorModerator']);
538 $this->forumPost->insert();
540 if (isset($this->postArray[
'ParentId'], $this->mapping[
'pos'][$this->postArray[
'ParentId']])) {
541 $parentId = (
int) $this->mapping[
'pos'][$this->postArray[
'ParentId']];
546 $postTreeNodeId = $this->db->nextId(
'frm_posts_tree');
547 $this->db->insert(
'frm_posts_tree', [
548 'fpt_pk' => [
'integer', $postTreeNodeId],
549 'thr_fk' => [
'integer', $this->lastHandledThreadId],
550 'pos_fk' => [
'integer', $this->forumPost->getId()],
551 'parent_pos' => [
'integer', $parentId],
552 'lft' => [
'integer', $this->postArray[
'Lft']],
553 'rgt' => [
'integer', $this->postArray[
'Rgt']],
554 'depth' => [
'integer', $this->postArray[
'Depth']],
555 'fpt_date' => [
'timestamp', date(
'Y-m-d H:i:s')]
558 $this->mapping[
'pos'][($this->postArray[
'Id'] ?? 0)] = $this->forumPost->getId();
559 $this->lastHandledPostId = $this->forumPost->getId();
561 $media_objects_found =
false;
562 foreach ($this->mediaObjects as $mob_attr) {
564 if (is_file($importfile)) {
566 basename($importfile),
572 $this->forumPost->setMessage(
575 "src=\"" . $mob_attr[
"label"] .
"\"",
576 "src=\"" . preg_replace(
577 "/(il)_[\d]+_(mob)_([\d]+)/",
582 "src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $mob->getId() .
"\"",
583 $this->forumPost->getMessage()
586 $media_objects_found =
true;
590 if ($media_objects_found) {
591 $this->forumPost->update();
593 $this->postArray = [];
605 $import_path = $this->contentArray[
'content'];
606 if ($import_path !==
'') {
608 $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)
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