142 $this->cdata = trim($this->cdata);
143 $property = strtolower($this->entity) .
'Array';
145 if (!property_exists($this, $property)) {
149 $propertyValue = &$this->{$property};
153 $query_num_posts =
"SELECT COUNT(pos_pk) cnt FROM frm_posts WHERE pos_top_fk = " . $this->db->quote(
154 $this->lastHandledForumId,
157 $res_pos = $this->db->query($query_num_posts);
158 $data_pos = $this->db->fetchAssoc($res_pos);
159 $num_posts = (
int) $data_pos[
'cnt'];
161 $query_num_threads =
"SELECT COUNT(thr_pk) cnt FROM frm_threads WHERE thr_top_fk = " . $this->db->quote(
162 $this->lastHandledForumId,
165 $res_thr = $this->db->query($query_num_threads);
166 $data_thr = $this->db->fetchAssoc($res_thr);
167 $num_threads = (
int) $data_thr[
'cnt'];
170 if ($this->lastHandledPostId !== 0) {
171 $update_str = implode(
'#', [
172 (
string) $this->lastHandledForumId,
173 (
string) $this->lastHandledThreadId,
174 (
string) $this->lastHandledPostId
178 $this->db->manipulateF(
180 SET top_last_post = %s, 182 top_num_threads = %s, 184 WHERE top_frm_fk = %s",
185 [
'text',
'integer',
'integer',
'integer',
'integer'],
186 [$update_str, $num_posts, $num_threads, $this->frm_last_mapped_top_usr_id, $this->forum_obj_id]
224 case 'ThreadRatings':
228 case 'PostingActivation':
232 case 'PresetSubject':
240 case 'NotificationType':
244 case 'NotificationEvents':
248 case 'ForceNotification':
252 case 'ToggleNotification':
283 case 'isAuthorModerator':
289 if ($this->entity ===
'forum' && $this->forumArray !== []) {
293 $this->forum->createSettings();
296 (
int) ($this->forumArray[
'UserId'] ?? 0),
299 $this->frm_last_mapped_top_usr_id = $forum_array[
'usr_id'];
302 (
int) ($this->forumArray[
'UpdateUserId'] ?? 0),
310 $this->forum->setDescription(
ilUtil::stripSlashes((
string) ($this->forumArray[
"Description"] ??
'')));
311 $this->forum->update();
312 $this->forum->updateMoficationUserId($update_forum_array[
'usr_id']);
316 $newObjProp->setAnonymisation((
bool) ($this->forumArray[
'Pseudonyms'] ??
false));
317 $newObjProp->setStatisticsStatus((
bool) ($this->forumArray[
'Statistics'] ??
false));
318 $newObjProp->setIsThreadRatingEnabled((
bool) ($this->forumArray[
'ThreadRatings'] ??
false));
319 $newObjProp->setPostActivation((
bool) ($this->forumArray[
'PostingActivation'] ??
false));
320 $newObjProp->setPresetSubject((
bool) ($this->forumArray[
'PresetSubject'] ??
false));
321 $newObjProp->setAddReSubject((
bool) ($this->forumArray[
'PresetRe'] ??
false));
322 $newObjProp->setNotificationType((
string) ($this->forumArray[
'NotificationType'] ?:
'all_users'));
323 $newObjProp->setInterestedEvents((
int) ($this->forumArray[
'NotificationEvents'] ?? 0));
324 $newObjProp->setAdminForceNoti((
bool) ($this->forumArray[
'ForceNotification'] ??
false));
325 $newObjProp->setUserToggleNoti((
bool) ($this->forumArray[
'ToggleNotification'] ??
false));
326 $newObjProp->setFileUploadAllowed((
bool) ($this->forumArray[
'FileUpload'] ??
false));
328 $newObjProp->setMarkModeratorPosts((
bool) ($this->forumArray[
'MarkModeratorPosts'] ??
false));
329 $newObjProp->update();
332 $this->forum_obj_id = $newObjProp->getObjId();
333 $this->mapping[
'frm'][$this->forumArray[
'Id']] =
$id;
334 $this->lastHandledForumId =
$id;
336 $this->importMapping->addMapping(
339 'frm:' . $this->forumArray[
'ObjId'],
340 'frm:' . $this->forum->getId()
343 $this->forumArray = [];
349 if ($this->lastHandledPostId !== 0) {
350 $update_str = implode(
'#', [
351 (
string) $this->lastHandledForumId,
352 (
string) $this->lastHandledThreadId,
353 (
string) $this->lastHandledPostId
357 $this->db->manipulateF(
358 "UPDATE frm_threads SET thr_last_post = %s WHERE thr_pk = %s",
360 [$update_str, $this->lastHandledThreadId]
376 case 'OrderSequenceIndex':
384 case 'MarkModeratorPosts':
391 if ($this->entity ===
'thread' && $this->lastHandledForumId && $this->threadArray !== []) {
393 $this->forumThread->setId((
int) ($this->threadArray[
'Id'] ?? 0));
394 $this->forumThread->setForumId($this->lastHandledForumId);
395 $this->forumThread->setSubject(
ilUtil::stripSlashes((
string) ($this->threadArray[
'Subject'] ??
'')));
396 $this->forumThread->setSticky((
bool) ($this->threadArray[
'Sticky'] ??
false));
397 $this->forumThread->setOrderSequenceIndex((
int) ($this->threadArray[
'OrderSequenceIndex'] ?? 0));
398 $this->forumThread->setClosed((
bool) ($this->threadArray[
'Closed'] ??
false));
400 $this->forumThread->setImportName(
401 isset($this->threadArray[
'ImportName']) ?
405 $this->forumThread->setCreateDate($this->threadArray[
'CreateDate']);
406 $this->forumThread->setChangeDate($this->threadArray[
'UpdateDate']);
409 (
int) ($this->threadArray[
'UserId'] ?? 0),
413 $this->forumThread->setDisplayUserId($usr_data[
'usr_id']);
414 $this->forumThread->setUserAlias($usr_data[
'usr_alias']);
417 $this->threadArray[
'AuthorId'] = $this->threadArray[
'UserId'];
421 (
int) ($this->threadArray[
'AuthorId'] ?? 0)
423 $this->forumThread->setThrAuthorId($author_id_data[
'usr_id']);
425 $this->forumThread->insert();
427 $this->mapping[
'thr'][$this->threadArray[
'Id']] = $this->forumThread->getId();
428 $this->lastHandledThreadId = $this->forumThread->getId();
429 $this->threadArray = [];
440 case 'CensorshipMessage':
476 $this->entity ===
'post' &&
477 $this->lastHandledForumId &&
478 $this->postArray !== [] &&
479 $this->forumThread &&
480 $this->lastHandledThreadId
483 $this->forumPost->setThread($this->forumThread);
485 $this->forumPost->setId((
int) $this->postArray[
'Id']);
486 $this->forumPost->setCensorship((
bool) ($this->postArray[
'Censorship'] ??
false));
487 $this->forumPost->setCensorshipComment(
490 $this->forumPost->setNotification((
bool) ($this->postArray[
'Notification'] ??
false));
491 $this->forumPost->setStatus((
bool) ($this->postArray[
'Status'] ??
false));
493 $this->forumPost->setMessage($purifier->purify((
string) ($this->postArray[
'Message'] ??
'')));
494 $this->forumPost->setSubject(
ilUtil::stripSlashes((
string) ($this->postArray[
'Subject'] ??
'')));
495 $this->forumPost->setLft((
int) $this->postArray[
'Lft']);
496 $this->forumPost->setRgt((
int) $this->postArray[
'Rgt']);
497 $this->forumPost->setDepth((
int) $this->postArray[
'Depth']);
498 $this->forumPost->setParentId((
int) $this->postArray[
'ParentId']);
499 $this->forumPost->setThreadId($this->lastHandledThreadId);
500 $this->forumPost->setForumId($this->lastHandledForumId);
502 $this->forumPost->setImportName(
503 isset($this->postArray[
'ImportName']) ?
507 $this->forumPost->setCreateDate($this->postArray[
'CreateDate']);
508 $this->forumPost->setChangeDate($this->postArray[
'UpdateDate']);
511 (
int) ($this->postArray[
'UserId'] ?? 0),
515 (
int) ($this->postArray[
'UpdateUserId'] ?? 0)
517 $this->forumPost->setDisplayUserId($usr_data[
'usr_id']);
518 $this->forumPost->setUserAlias($usr_data[
'usr_alias']);
519 $this->forumPost->setUpdateUserId($update_usr_data[
'usr_id']);
522 $this->postArray[
'AuthorId'] = $this->postArray[
'UserId'];
525 (
int) ($this->postArray[
'AuthorId'] ?? 0)
527 $this->forumPost->setPosAuthorId((
int) $author_id_data[
'usr_id']);
529 if (isset($this->postArray[
'isAuthorModerator']) && $this->postArray[
'isAuthorModerator'] ===
'NULL') {
530 $this->forumPost->setIsAuthorModerator(
false);
532 $this->forumPost->setIsAuthorModerator((
bool) $this->postArray[
'isAuthorModerator']);
535 $this->forumPost->insert();
537 if (isset($this->postArray[
'ParentId'], $this->mapping[
'pos'][$this->postArray[
'ParentId']])) {
538 $parentId = (
int) $this->mapping[
'pos'][$this->postArray[
'ParentId']];
543 $postTreeNodeId = $this->db->nextId(
'frm_posts_tree');
544 $this->db->insert(
'frm_posts_tree', [
545 'fpt_pk' => [
'integer', $postTreeNodeId],
546 'thr_fk' => [
'integer', $this->lastHandledThreadId],
547 'pos_fk' => [
'integer', $this->forumPost->getId()],
548 'parent_pos' => [
'integer', $parentId],
549 'lft' => [
'integer', $this->postArray[
'Lft']],
550 'rgt' => [
'integer', $this->postArray[
'Rgt']],
551 'depth' => [
'integer', $this->postArray[
'Depth']],
552 'fpt_date' => [
'timestamp', date(
'Y-m-d H:i:s')]
555 $this->mapping[
'pos'][($this->postArray[
'Id'] ?? 0)] = $this->forumPost->getId();
556 $this->lastHandledPostId = $this->forumPost->getId();
558 $media_objects_found =
false;
559 foreach ($this->mediaObjects as $mob_attr) {
561 if (is_file($importfile)) {
563 basename($importfile),
569 $this->forumPost->setMessage(
572 "src=\"" . $mob_attr[
"label"] .
"\"",
573 "src=\"" . preg_replace(
574 "/(il)_[\d]+_(mob)_([\d]+)/",
579 "src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $mob->getId() .
"\"",
580 $this->forumPost->getMessage()
583 $media_objects_found =
true;
587 if ($media_objects_found) {
588 $this->forumPost->update();
590 $this->postArray = [];
602 $importPath = $this->contentArray[
'content'];
604 if ($importPath !==
'') {
607 $newFilename = preg_replace(
609 $this->forum->getId() .
"_" . $this->lastHandledPostId .
"$1",
610 basename($importPath)
612 $path = $filedata->getForumPath();
613 $newPath = $path .
'/' . $newFilename;
614 @copy($importPath, $newPath);
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)
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
static getInstanceByType(string $type)
const THREAD_SORTING_DEFAULT
This class handles all operations on files for the forum object.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins