156 $this->cdata = trim($this->cdata);
157 $property = strtolower($this->entity) .
'Array';
159 if (!property_exists($this, $property)) {
163 $propertyValue = &$this->{$property};
167 $query_num_posts =
'SELECT COUNT(pos_pk) cnt FROM frm_posts WHERE pos_top_fk = ' . $this->db->quote(
168 $this->lastHandledForumId,
171 $res_pos = $this->db->query($query_num_posts);
172 $data_pos = $this->db->fetchAssoc($res_pos);
173 $num_posts = (
int) $data_pos[
'cnt'];
175 $query_num_threads =
'SELECT COUNT(thr_pk) cnt FROM frm_threads WHERE thr_top_fk = ' . $this->db->quote(
176 $this->lastHandledForumId,
179 $res_thr = $this->db->query($query_num_threads);
180 $data_thr = $this->db->fetchAssoc($res_thr);
181 $num_threads = (
int) $data_thr[
'cnt'];
184 if ($this->lastHandledPostId !== 0) {
185 $update_str = implode(
'#', [
186 (
string) $this->lastHandledForumId,
187 (
string) $this->lastHandledThreadId,
188 (
string) $this->lastHandledPostId
192 $this->db->manipulateF(
194 SET top_last_post = %s, 196 top_num_threads = %s, 198 WHERE top_frm_fk = %s',
199 [
'text',
'integer',
'integer',
'integer',
'integer'],
200 [$update_str, $num_posts, $num_threads, $this->frm_last_mapped_top_usr_id, $this->forum_obj_id]
234 case 'ThreadRatings':
238 case 'PostingActivation':
242 case 'PresetSubject':
250 case 'NotificationType':
254 case 'NotificationEvents':
258 case 'ForceNotification':
262 case 'ToggleNotification':
293 case 'isAuthorModerator':
299 if ($this->entity ===
'forum' && $this->forumArray !== []) {
303 $this->forum->createSettings();
306 (
int) ($this->forumArray[
'UserId'] ?? 0),
309 $this->frm_last_mapped_top_usr_id = $forum_array[
'usr_id'];
312 (
int) ($this->forumArray[
'UpdateUserId'] ?? 0),
320 $this->forum->setDescription(
323 $this->forum->update();
324 $this->forum->updateModificationUserId($update_forum_array[
'usr_id']);
327 $newObjProp->setDefaultView(
330 $newObjProp->setAnonymisation((
bool) ($this->forumArray[
'Pseudonyms'] ??
false));
331 $newObjProp->setStatisticsStatus((
bool) ($this->forumArray[
'Statistics'] ??
false));
332 $newObjProp->setIsThreadRatingEnabled((
bool) ($this->forumArray[
'ThreadRatings'] ??
false));
333 $newObjProp->setPostActivation((
bool) ($this->forumArray[
'PostingActivation'] ??
false));
334 $newObjProp->setPresetSubject((
bool) ($this->forumArray[
'PresetSubject'] ??
false));
335 $newObjProp->setAddReSubject((
bool) ($this->forumArray[
'PresetRe'] ??
false));
336 $newObjProp->setNotificationType(
337 NotificationType::tryFrom(
338 $this->forumArray[
'NotificationType'] ?? NotificationType::ALL_USERS->value
339 ) ?? NotificationType::ALL_USERS
341 $newObjProp->setInterestedEvents((
int) ($this->forumArray[
'NotificationEvents'] ?? 0));
342 $newObjProp->setAdminForceNoti((
bool) ($this->forumArray[
'ForceNotification'] ??
false));
343 $newObjProp->setUserToggleNoti((
bool) ($this->forumArray[
'ToggleNotification'] ??
false));
344 $newObjProp->setFileUploadAllowed((
bool) ($this->forumArray[
'FileUpload'] ??
false));
345 $newObjProp->setMarkModeratorPosts((
bool) ($this->forumArray[
'MarkModeratorPosts'] ??
false));
346 $newObjProp->update();
349 $this->forum_obj_id = $newObjProp->getObjId();
350 $this->mapping[
'frm'][$this->forumArray[
'Id']] =
$id;
351 $this->lastHandledForumId =
$id;
353 $this->importMapping->addMapping(
354 'components/ILIAS/COPage',
356 'frm:' . $this->forumArray[
'ObjId'],
357 'frm:' . $this->forum->getId()
360 if ($this->last_handled_style_id) {
362 $this->last_handled_style_id =
null;
365 $this->forumArray = [];
371 if ($this->lastHandledPostId !== 0) {
372 $update_str = implode(
'#', [
373 (
string) $this->lastHandledForumId,
374 (
string) $this->lastHandledThreadId,
375 (
string) $this->lastHandledPostId
379 $this->db->manipulateF(
380 'UPDATE frm_threads SET thr_last_post = %s WHERE thr_pk = %s',
382 [$update_str, $this->lastHandledThreadId]
398 case 'MarkModeratorPosts':
405 if ($this->entity ===
'thread' && $this->lastHandledForumId && $this->threadArray !== []) {
407 $this->forumThread->setId((
int) ($this->threadArray[
'Id'] ?? 0));
408 $this->forumThread->setForumId($this->lastHandledForumId);
409 $this->forumThread->setSubject(
412 $this->forumThread->setSticky((
bool) ($this->threadArray[
'Sticky'] ??
false));
413 $this->forumThread->setClosed((
bool) ($this->threadArray[
'Closed'] ??
false));
415 $this->forumThread->setImportName(
416 isset($this->threadArray[
'ImportName']) ?
420 $this->forumThread->setCreateDate($this->threadArray[
'CreateDate']);
421 $this->forumThread->setChangeDate($this->threadArray[
'UpdateDate']);
424 (
int) ($this->threadArray[
'UserId'] ?? 0),
428 $this->forumThread->setDisplayUserId($usr_data[
'usr_id']);
429 $this->forumThread->setUserAlias($usr_data[
'usr_alias']);
432 $this->threadArray[
'AuthorId'] = $this->threadArray[
'UserId'];
436 (
int) ($this->threadArray[
'AuthorId'] ?? 0)
438 $this->forumThread->setThrAuthorId($author_id_data[
'usr_id']);
440 $this->forumThread->insert();
442 $this->mapping[
'thr'][$this->threadArray[
'Id']] = $this->forumThread->getId();
443 $this->lastHandledThreadId = $this->forumThread->getId();
444 $this->threadArray = [];
455 case 'CensorshipMessage':
491 $this->entity ===
'post' &&
492 $this->lastHandledForumId &&
493 $this->postArray !== [] &&
494 $this->forumThread &&
495 $this->lastHandledThreadId
498 $this->forumPost->setThread($this->forumThread);
500 $this->forumPost->setId((
int) $this->postArray[
'Id']);
501 $this->forumPost->setCensorship((
bool) ($this->postArray[
'Censorship'] ??
false));
502 $this->forumPost->setCensorshipComment(
505 $this->forumPost->setNotification((
bool) ($this->postArray[
'Notification'] ??
false));
506 $this->forumPost->setStatus((
bool) ($this->postArray[
'Status'] ??
false));
508 $this->forumPost->setMessage($purifier->purify((
string) ($this->postArray[
'Message'] ??
'')));
509 $this->forumPost->setSubject(
ilUtil::stripSlashes((
string) ($this->postArray[
'Subject'] ??
'')));
510 $this->forumPost->setLft((
int) $this->postArray[
'Lft']);
511 $this->forumPost->setRgt((
int) $this->postArray[
'Rgt']);
512 $this->forumPost->setDepth((
int) $this->postArray[
'Depth']);
513 $this->forumPost->setParentId((
int) $this->postArray[
'ParentId']);
514 $this->forumPost->setThreadId($this->lastHandledThreadId);
515 $this->forumPost->setForumId($this->lastHandledForumId);
517 $this->forumPost->setImportName(
518 isset($this->postArray[
'ImportName']) ?
522 $this->forumPost->setCreateDate($this->postArray[
'CreateDate']);
523 $this->forumPost->setChangeDate($this->postArray[
'UpdateDate']);
526 (
int) ($this->postArray[
'UserId'] ?? 0),
530 (
int) ($this->postArray[
'UpdateUserId'] ?? 0)
532 $this->forumPost->setDisplayUserId($usr_data[
'usr_id']);
533 $this->forumPost->setUserAlias($usr_data[
'usr_alias']);
534 $this->forumPost->setUpdateUserId($update_usr_data[
'usr_id']);
537 $this->postArray[
'AuthorId'] = $this->postArray[
'UserId'];
540 (
int) ($this->postArray[
'AuthorId'] ?? 0)
542 $this->forumPost->setPosAuthorId((
int) $author_id_data[
'usr_id']);
544 if (isset($this->postArray[
'isAuthorModerator']) && strtoupper($this->postArray[
'isAuthorModerator']) ===
'NULL') {
545 $this->forumPost->setIsAuthorModerator(
false);
547 $this->forumPost->setIsAuthorModerator((
bool) $this->postArray[
'isAuthorModerator']);
550 $this->forumPost->insert();
552 if (isset($this->postArray[
'ParentId'], $this->mapping[
'pos'][$this->postArray[
'ParentId']])) {
553 $parentId = (
int) $this->mapping[
'pos'][$this->postArray[
'ParentId']];
558 $postTreeNodeId = $this->db->nextId(
'frm_posts_tree');
559 $this->db->insert(
'frm_posts_tree', [
560 'fpt_pk' => [
'integer', $postTreeNodeId],
561 'thr_fk' => [
'integer', $this->lastHandledThreadId],
562 'pos_fk' => [
'integer', $this->forumPost->getId()],
563 'parent_pos' => [
'integer', $parentId],
564 'lft' => [
'integer', $this->postArray[
'Lft']],
565 'rgt' => [
'integer', $this->postArray[
'Rgt']],
566 'depth' => [
'integer', $this->postArray[
'Depth']],
567 'fpt_date' => [
'timestamp', date(
'Y-m-d H:i:s')]
570 $this->mapping[
'pos'][($this->postArray[
'Id'] ?? 0)] = $this->forumPost->getId();
571 $this->lastHandledPostId = $this->forumPost->getId();
573 $media_objects_found =
false;
574 foreach ($this->mediaObjects as $mob_attr) {
576 if (is_file($importfile)) {
578 basename($importfile),
584 $this->forumPost->setMessage(
587 'src="' . $mob_attr[
'label'] .
'"',
588 'src="' . preg_replace(
589 "/(il)_[\d]+_(mob)_([\d]+)/",
594 'src="' .
'il_' .
IL_INST_ID .
'_mob_' . $mob->getId() .
'"',
595 $this->forumPost->getMessage()
598 $media_objects_found =
true;
602 if ($media_objects_found) {
603 $this->forumPost->update();
605 $this->postArray = [];
617 $import_path = $this->contentArray[
'content'];
618 if ($import_path !==
'') {
620 $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