ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilForumTopic Class Reference
+ Collaboration diagram for ilForumTopic:

Public Member Functions

 __construct (private int $id=0, private readonly bool $is_moderator=false, bool $preventImplicitRead=false)
 Returns an object of a forum topic. More...
 
 assignData (array $data)
 
 insert ()
 
 update ()
 
 reload ()
 
 getPostRootId ()
 
 updateVisits ()
 
 countPosts (bool $ignoreRoot=false)
 
 countActivePosts (bool $ignoreRoot=false)
 
 getPostRootNode (bool $isModerator=false, bool $preventImplicitRead=false)
 
 getFirstVisiblePostNode (bool $isModerator=false, bool $preventImplicitRead=false)
 
 getLastPost ()
 
 getLastActivePost ()
 
 getAllPostIds ()
 
 getPostTree (ilForumPost $a_post_node)
 Fetches and returns an array of posts from the post tree, starting with the node object passed by the first paramter. More...
 
 movePosts (int $old_obj_id, int $old_pk, int $new_obj_id, int $new_pk)
 Moves all posts within the current thread to a new forum. More...
 
 getNestedSetPostChildren (?int $pos_id=null, ?int $num_levels=null)
 
 isNotificationEnabled (int $a_user_id)
 
 enableNotification (int $a_user_id)
 
 disableNotification (int $a_user_id)
 
 makeSticky ()
 
 unmakeSticky ()
 
 close ()
 
 reopen ()
 
 getAverageRating ()
 
 setAverageRating (float $average_rating)
 
 setId (int $a_id)
 
 getId ()
 
 setForumId (int $a_forum_id)
 
 getForumId ()
 
 setDisplayUserId (int $a_user_id)
 
 getDisplayUserId ()
 
 setUserAlias (?string $a_user_alias)
 
 getUserAlias ()
 
 setSubject (string $a_subject)
 
 getSubject ()
 
 setCreateDate (?string $a_createdate)
 
 getCreateDate ()
 
 setChangeDate (?string $a_changedate)
 
 getChangeDate ()
 
 setImportName (?string $a_import_name)
 
 getImportName ()
 
 setLastPostString (?string $a_last_post)
 
 getLastPostString ()
 
 setVisits (int $a_visits)
 
 getVisits ()
 
 setSticky (bool $a_sticky)
 
 isSticky ()
 
 setClosed (bool $a_closed)
 
 isClosed ()
 
 setOrderField (string $a_order_field)
 
 getOrderField ()
 
 getFrmObjId ()
 
 setThrAuthorId (int $thr_author_id)
 
 getThrAuthorId ()
 
 updateThreadTitle ()
 
 setNumPosts (int $a_num_posts)
 
 getNumPosts ()
 
 setNumUnreadPosts (int $num_unread_posts)
 
 getNumUnreadPosts ()
 
 setUserNotificationEnabled (bool $status)
 
 isUserNotificationEnabled ()
 
 setOrderDirection (string $direction)
 
 getOrderDirection ()
 
 updateMergedThread ()
 
 getLastPostForThreadOverview ()
 
 setLastPostForThreadOverview (ilForumPost $post)
 

Static Public Member Functions

static lookupTitle (int $a_topic_id)
 
static lookupForumIdByTopicId (int $a_topic_id)
 
static lookupCreationDate (int $thread_id)
 

Private Member Functions

 read ()
 

Private Attributes

int $forum_id = 0
 
int $frm_obj_id = 0
 
int $display_user_id = 0
 
string $user_alias = null
 
string $subject = ''
 
string $createdate = null
 
string $changedate = null
 
int $num_posts = 0
 
string $last_post_string = null
 
int $visits = 0
 
string $import_name = null
 
bool $is_sticky = false
 
bool $is_closed = false
 
string $orderField = ''
 
ilForumPost $last_post = null
 
readonly ilDBInterface $db
 
int $thr_author_id = 0
 
float $average_rating = 0.0
 
string $orderDirection = 'DESC'
 
readonly ilObjUser $user
 
int $num_unread_posts = 0
 
bool $user_notification_enabled = false
 

Static Private Attributes

static array $possibleOrderDirections = ['ASC', 'DESC']
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de \

Definition at line 25 of file class.ilForumTopic.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumTopic::__construct ( private int  $id = 0,
private readonly bool  $is_moderator = false,
bool  $preventImplicitRead = false 
)

Returns an object of a forum topic.

The constructor calls the private method read() to load the topic data from database into the object.

Parameters
int$idprimary key of a forum topic (optional)
bool$is_moderatormoderator-status of the current user (optional)
bool$preventImplicitReadPrevents the implicit database query if an id was passed

Definition at line 59 of file class.ilForumTopic.php.

63 {
64 global $DIC;
65 $this->db = $DIC->database();
66 $this->user = $DIC->user();
67
68 if (!$preventImplicitRead) {
69 $this->read();
70 }
71 }
global $DIC
Definition: shib_login.php:26

References $DIC, read(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ assignData()

ilForumTopic::assignData ( array  $data)

Definition at line 73 of file class.ilForumTopic.php.

73 : void
74 {
75 $this->setId((int) $data['thr_pk']);
76 $this->setForumId((int) $data['thr_top_fk']);
77 $this->setSubject($data['thr_subject']);
78 $this->setDisplayUserId((int) $data['thr_display_user_id']);
79 $this->setUserAlias($data['thr_usr_alias']);
80 $this->setLastPostString($data['thr_last_post']);
81 $this->setCreateDate($data['thr_date']);
82 $this->setChangeDate($data['thr_update']);
83 $this->setVisits((int) $data['visits']);
84 $this->setImportName($data['import_name']);
85 $this->setSticky((bool) $data['is_sticky']);
86 $this->setClosed((bool) $data['is_closed']);
87 $this->setAverageRating(isset($data['avg_rating']) ? (float) $data['avg_rating'] : 0);
88 $this->setThrAuthorId((int) $data['thr_author_id']);
89
90 // Aggregated values
91 if (isset($data['num_posts'])) {
92 $this->setNumPosts((int) $data['num_posts']);
93 }
94 if (isset($data['num_unread_posts'])) {
95 $this->setNumUnreadPosts((int) $data['num_unread_posts']);
96 }
97 if (isset($data['usr_notification_is_enabled'])) {
98 $this->setUserNotificationEnabled((bool) $data['usr_notification_is_enabled']);
99 }
100 }
setDisplayUserId(int $a_user_id)
setLastPostString(?string $a_last_post)
setSticky(bool $a_sticky)
setChangeDate(?string $a_changedate)
setNumUnreadPosts(int $num_unread_posts)
setAverageRating(float $average_rating)
setClosed(bool $a_closed)
setUserAlias(?string $a_user_alias)
setCreateDate(?string $a_createdate)
setThrAuthorId(int $thr_author_id)
setSubject(string $a_subject)
setImportName(?string $a_import_name)
setForumId(int $a_forum_id)
setUserNotificationEnabled(bool $status)
setVisits(int $a_visits)
setNumPosts(int $a_num_posts)

References $data, setAverageRating(), setChangeDate(), setClosed(), setCreateDate(), setDisplayUserId(), setForumId(), setId(), setImportName(), setLastPostString(), setNumPosts(), setNumUnreadPosts(), setSticky(), setSubject(), setThrAuthorId(), setUserAlias(), setUserNotificationEnabled(), and setVisits().

+ Here is the call graph for this function:

◆ close()

ilForumTopic::close ( )

Definition at line 805 of file class.ilForumTopic.php.

805 : void
806 {
807 if ($this->id && !$this->is_closed) {
808 $this->db->manipulateF(
809 'UPDATE frm_threads SET is_closed = %s WHERE thr_pk = %s',
810 ['integer', 'integer'],
811 [1, $this->id]
812 );
813 $this->is_closed = true;
814 }
815 }

◆ countActivePosts()

ilForumTopic::countActivePosts ( bool  $ignoreRoot = false)

Definition at line 262 of file class.ilForumTopic.php.

262 : int
263 {
264 $res = $this->db->queryF(
265 '
266 SELECT COUNT(*) cnt
267 FROM frm_posts
268 INNER JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
269 WHERE (pos_status = %s
270 OR (pos_status = %s AND pos_display_user_id = %s))
271 AND pos_thr_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
272 ['integer', 'integer', 'integer', 'integer'],
273 ['1', '0', $this->user->getId(), $this->id]
274 );
275
276 $row = $this->db->fetchAssoc($res);
277 if (is_array($row)) {
278 return (int) $row['cnt'];
279 }
280
281 return 0;
282 }
$res
Definition: ltiservices.php:69

References $res, and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ countPosts()

ilForumTopic::countPosts ( bool  $ignoreRoot = false)

Definition at line 242 of file class.ilForumTopic.php.

242 : int
243 {
244 $res = $this->db->queryF(
245 '
246 SELECT COUNT(*) cnt
247 FROM frm_posts
248 INNER JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
249 WHERE pos_thr_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
250 ['integer'],
251 [$this->id]
252 );
253
254 $row = $this->db->fetchAssoc($res);
255 if (is_array($row)) {
256 return (int) $row['cnt'];
257 }
258
259 return 0;
260 }

References $res.

◆ disableNotification()

ilForumTopic::disableNotification ( int  $a_user_id)

Definition at line 762 of file class.ilForumTopic.php.

762 : void
763 {
764 if ($this->id && $a_user_id) {
765 $this->db->manipulateF(
766 'DELETE FROM frm_notification WHERE user_id = %s AND thread_id = %s',
767 ['integer', 'integer'],
768 [$a_user_id, $this->id]
769 );
770 }
771 }

◆ enableNotification()

ilForumTopic::enableNotification ( int  $a_user_id)

Definition at line 744 of file class.ilForumTopic.php.

744 : void
745 {
746 if ($this->id && $a_user_id && !$this->isNotificationEnabled($a_user_id)) {
747 $nextId = $this->db->nextId('frm_notification');
748 $this->db->manipulateF(
749 '
750 INSERT INTO frm_notification
751 ( notification_id,
752 user_id,
753 thread_id
754 )
755 VALUES(%s, %s, %s)',
756 ['integer', 'integer', 'integer'],
757 [$nextId, $a_user_id, $this->id]
758 );
759 }
760 }
isNotificationEnabled(int $a_user_id)

References isNotificationEnabled().

+ Here is the call graph for this function:

◆ getAllPostIds()

ilForumTopic::getAllPostIds ( )
Returns
array<int, int>

Definition at line 377 of file class.ilForumTopic.php.

377 : array
378 {
379 $posts = [];
380
381 if ($this->id !== 0) {
382 $res = $this->db->queryF('SELECT pos_pk FROM frm_posts WHERE pos_thr_fk = %s', ['integer'], [$this->id]);
383
384 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
385 $posts[(int) $row->pos_pk] = (int) $row->pos_pk;
386 }
387 }
388
389 return $posts;
390 }

References $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by movePosts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAverageRating()

ilForumTopic::getAverageRating ( )

Definition at line 830 of file class.ilForumTopic.php.

830 : float
831 {
833 }

References $average_rating.

◆ getChangeDate()

ilForumTopic::getChangeDate ( )

Definition at line 905 of file class.ilForumTopic.php.

905 : ?string
906 {
907 return $this->changedate;
908 }

References $changedate.

◆ getCreateDate()

ilForumTopic::getCreateDate ( )

Definition at line 895 of file class.ilForumTopic.php.

895 : ?string
896 {
897 return $this->createdate;
898 }

References $createdate.

◆ getDisplayUserId()

ilForumTopic::getDisplayUserId ( )

Definition at line 865 of file class.ilForumTopic.php.

865 : int
866 {
868 }

References $display_user_id.

Referenced by ilObjForumGUI\getThreadProperties().

+ Here is the caller graph for this function:

◆ getFirstVisiblePostNode()

ilForumTopic::getFirstVisiblePostNode ( bool  $isModerator = false,
bool  $preventImplicitRead = false 
)

Definition at line 308 of file class.ilForumTopic.php.

309 {
310 $this->db->setLimit(1);
311 $res = $this->db->queryF(
312 '
313 SELECT *
314 FROM frm_posts
315 INNER JOIN frm_posts_tree ON pos_fk = pos_pk
316 WHERE parent_pos != %s
317 AND thr_fk = %s
318 AND depth = %s
319 ORDER BY rgt DESC',
320 ['integer', 'integer', 'integer'],
321 [0, $this->id, 2]
322 );
323
324 if ($row = $this->db->fetchAssoc($res)) {
325 $post = new ilForumPost((int) $row['pos_pk'], $isModerator, $preventImplicitRead);
326 $post->assignData($row);
327 return $post;
328 }
329
330 throw new OutOfBoundsException(sprintf('Could not find first posting by id: %s', $this->id));
331 }
$post
Definition: ltitoken.php:46

References $post, and $res.

◆ getForumId()

ilForumTopic::getForumId ( )

Definition at line 855 of file class.ilForumTopic.php.

855 : int
856 {
857 return $this->forum_id;
858 }

References $forum_id.

Referenced by ilForumExportGUI\ensureThreadBelongsToForum(), and ilObjForumGUI\ensureThreadBelongsToForum().

+ Here is the caller graph for this function:

◆ getFrmObjId()

ilForumTopic::getFrmObjId ( )

Definition at line 970 of file class.ilForumTopic.php.

970 : int
971 {
972 return $this->frm_obj_id;
973 }

References $frm_obj_id.

Referenced by getNestedSetPostChildren().

+ Here is the caller graph for this function:

◆ getId()

ilForumTopic::getId ( )

Definition at line 845 of file class.ilForumTopic.php.

845 : int
846 {
847 return $this->id;
848 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

Referenced by ilObjForumGUI\getActionsForThreadOverview(), ilObjForumGUI\getEditTitleModal(), ilObjForumGUI\getOpenCloseActionForThread(), ilObjForumGUI\getStickyActionForThread(), ilObjForumGUI\getThreadProperties(), updateMergedThread(), and updateThreadTitle().

+ Here is the caller graph for this function:

◆ getImportName()

ilForumTopic::getImportName ( )

Definition at line 915 of file class.ilForumTopic.php.

915 : ?string
916 {
917 return $this->import_name;
918 }

References $import_name.

Referenced by ilObjForumGUI\getThreadProperties().

+ Here is the caller graph for this function:

◆ getLastActivePost()

ilForumTopic::getLastActivePost ( )

Definition at line 351 of file class.ilForumTopic.php.

352 {
353 if ($this->id !== 0) {
354 $this->db->setLimit(1);
355 $res = $this->db->queryF(
356 '
357 SELECT pos_pk
358 FROM frm_posts
359 WHERE pos_thr_fk = %s
360 AND (pos_status = %s OR (pos_status = %s AND pos_display_user_id = %s))
361 ORDER BY pos_date DESC',
362 ['integer', 'integer', 'integer', 'integer'],
363 [$this->id, '1', '0', $this->user->getId()]
364 );
365
366 if (($row = $this->db->fetchObject($res)) !== null) {
367 return new ilForumPost((int) $row->pos_pk);
368 }
369 }
370
371 throw new OutOfBoundsException(sprintf('Could not find last active posting by id: %s', $this->id));
372 }

References $res, and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ getLastPost()

ilForumTopic::getLastPost ( )

Definition at line 333 of file class.ilForumTopic.php.

334 {
335 if ($this->id !== 0) {
336 $this->db->setLimit(1);
337 $res = $this->db->queryF(
338 'SELECT pos_pk FROM frm_posts WHERE pos_thr_fk = %s ORDER BY pos_date DESC',
339 ['integer'],
340 [$this->id]
341 );
342
343 if (($row = $this->db->fetchObject($res)) !== null) {
344 return new ilForumPost((int) $row->pos_pk);
345 }
346 }
347
348 throw new OutOfBoundsException(sprintf('Could not find last posting by id: %s', $this->id));
349 }

References $res.

Referenced by ilObjForumGUI\getThreadProperties().

+ Here is the caller graph for this function:

◆ getLastPostForThreadOverview()

ilForumTopic::getLastPostForThreadOverview ( )

Definition at line 1117 of file class.ilForumTopic.php.

1117 : ?ilForumPost
1118 {
1119 return $this->last_post;
1120 }
ilForumPost $last_post

References $last_post.

◆ getLastPostString()

ilForumTopic::getLastPostString ( )

Definition at line 925 of file class.ilForumTopic.php.

925 : ?string
926 {
928 }

References $last_post_string.

Referenced by updateMergedThread().

+ Here is the caller graph for this function:

◆ getNestedSetPostChildren()

ilForumTopic::getNestedSetPostChildren ( ?int  $pos_id = null,
?int  $num_levels = null 
)

Definition at line 570 of file class.ilForumTopic.php.

570 : array
571 {
572 $data = null;
573 $objProperties = ilForumProperties::getInstance($this->getFrmObjId());
574 $is_post_activation_enabled = $objProperties->isPostActivationEnabled();
575
576 if ($pos_id !== null) {
577 $res = $this->db->queryF(
578 "
579 SELECT lft, rgt, depth
580 FROM frm_posts_tree
581 WHERE pos_fk = %s
582 AND thr_fk = %s",
583 ['integer', 'integer'],
584 [$pos_id, $this->id]
585 );
586
587 $data = $this->db->fetchAssoc($res);
588 }
589
590 $query = '
591 SELECT fpt.depth,
592 fpt.rgt,
593 fpt.parent_pos,
594 fp.pos_pk,
595 fp.pos_subject,
596 fp.pos_usr_alias,
597 fp.pos_date,
598 fp.pos_update,
599 fp.pos_status,
600 fp.pos_display_user_id,
601 fp.pos_usr_alias,
602 fp.import_name,
603 fp.pos_author_id,
604 fp.is_author_moderator,
605 fur.post_id,
606 (CASE
607 WHEN fur.post_id IS NULL ' .
608 ($this->user->getId() === ANONYMOUS_USER_ID ? ' AND 1 = 2 ' : '') . '
609 THEN 0
610 ELSE 1
611 END) post_read,
612 COUNT(fpt2.pos_fk) children
613
614 FROM frm_posts_tree fpt
615
616 INNER JOIN frm_posts fp
617 ON fp.pos_pk = fpt.pos_fk
618
619 LEFT JOIN frm_posts_tree fpt2
620 ON fpt2.lft BETWEEN fpt.lft AND fpt.rgt
621 AND fpt.thr_fk = fpt2.thr_fk
622 AND fpt.pos_fk != fpt2.pos_fk ';
623
624 $query .= '
625 LEFT JOIN frm_user_read fur
626 ON fur.thread_id = fp.pos_thr_fk
627 AND fur.post_id = fp.pos_pk
628 AND fur.usr_id = ' . $this->db->quote($this->user->getId(), 'integer') . '
629
630 LEFT JOIN usr_data ud
631 ON ud.usr_id = fp.pos_display_user_id
632
633 WHERE fpt.thr_fk = ' . $this->db->quote($this->id, 'integer');
634
635 if ($data) {
636 $query .= ' AND fpt.lft > ' . $this->db->quote($data['lft'], 'integer') .
637 ' AND fpt.lft < ' . $this->db->quote($data['rgt'], 'integer') . ' ';
638 }
639 if ($is_post_activation_enabled && !$this->is_moderator) {
640 $query .= ' AND (fp.pos_status = 1 OR fp.pos_status = 0 AND fp.pos_display_user_id = ' . $this->db->quote(
641 $this->user->getId(),
642 'integer'
643 ) . ') ';
644 }
645
646 if ($data && is_numeric($num_levels)) {
647 $query .= ' AND fpt.depth <= ' . $this->db->quote((int) $data['depth'] + $num_levels, 'integer') . ' ';
648 }
649
650 $query .= ' GROUP BY fpt.depth,
651 fpt.rgt,
652 fpt.parent_pos,
653 fp.pos_pk,
654 fp.pos_subject,
655 fp.pos_usr_alias,
656 fp.pos_date,
657 fp.pos_update,
658 fp.pos_status,
659 fp.pos_display_user_id,
660 fp.pos_usr_alias,
661 fp.import_name,
662 fp.pos_author_id,
663 fp.is_author_moderator,
664 fur.post_id
665 ORDER BY fpt.rgt DESC
666 ';
667
668 $queryCounter = '
669 SELECT pos_fk
670 FROM frm_posts_tree fpt
671 INNER JOIN frm_posts fp
672 ON fp.pos_pk = fpt.pos_fk
673 WHERE fpt.thr_fk = ' . $this->db->quote($this->id, 'integer');
674
675 if ($is_post_activation_enabled && !$this->is_moderator) {
676 $queryCounter .= ' AND (fp.pos_status = 1 OR fp.pos_status = 0 AND fp.pos_display_user_id = ' . $this->db->quote(
677 $this->user->getId(),
678 'integer'
679 ) . ') ';
680 }
681 $queryCounter .= ' ORDER BY fpt.rgt DESC';
682
683 $resCounter = $this->db->query($queryCounter);
684 $counter = [];
685 $i = 0;
686 while ($row = $this->db->fetchAssoc($resCounter)) {
687 $counter[(int) $row['pos_fk']] = $i++;
688 }
689
690 $res = $this->db->query($query);
691 $children = [];
692 $usr_ids = [];
693 while ($row = $this->db->fetchAssoc($res)) {
694 if ((int) $row['pos_display_user_id'] !== 0) {
695 $usr_ids[] = (int) $row['pos_display_user_id'];
696 }
697
698 $row['counter'] = $counter[$row['pos_pk']];
699 $casted_row = [];
700 $casted_row['depth'] = (int) $row['depth'];
701 $casted_row['rgt'] = (int) $row['rgt'];
702 $casted_row['parent_pos'] = (int) $row['parent_pos'];
703 $casted_row['pos_pk'] = (int) $row['pos_pk'];
704 $casted_row['pos_subject'] = (string) $row['pos_subject'];
705 $casted_row['pos_usr_alias'] = (string) $row['pos_usr_alias'];
706 $casted_row['pos_date'] = (string) $row['pos_date'];
707 $casted_row['pos_update'] = (string) $row['pos_update'];
708 $casted_row['pos_status'] = (int) $row['pos_status'];
709 $casted_row['pos_display_user_id'] = (int) $row['pos_display_user_id'];
710 $casted_row['import_name'] = (string) $row['import_name'];
711 $casted_row['pos_author_id'] = (int) $row['pos_author_id'];
712 $casted_row['is_author_moderator'] = (int) $row['is_author_moderator'];
713 $casted_row['post_id'] = (int) $row['post_id'];
714 $casted_row['post_read'] = (int) $row['post_read'];
715 $casted_row['children'] = (int) $row['children'];
716
717 $children[] = $casted_row;
718 }
719
721
722 return $children;
723 }
static getInstance(int $a_obj_id=0)
const ANONYMOUS_USER_ID
Definition: constants.php:27
$counter

References $counter, $data, $res, ANONYMOUS_USER_ID, getFrmObjId(), ilForumProperties\getInstance(), ILIAS\Repository\int(), ilForumAuthorInformationCache\preloadUserObjects(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ getNumPosts()

ilForumTopic::getNumPosts ( )

Definition at line 1025 of file class.ilForumTopic.php.

1025 : int
1026 {
1027 return $this->num_posts;
1028 }

References $num_posts.

Referenced by ilObjForumGUI\getThreadProperties(), and updateMergedThread().

+ Here is the caller graph for this function:

◆ getNumUnreadPosts()

ilForumTopic::getNumUnreadPosts ( )

Definition at line 1036 of file class.ilForumTopic.php.

1036 : int
1037 {
1039 }

References $num_unread_posts.

Referenced by ilObjForumGUI\getThreadProperties().

+ Here is the caller graph for this function:

◆ getOrderDirection()

ilForumTopic::getOrderDirection ( )

Definition at line 1062 of file class.ilForumTopic.php.

1062 : string
1063 {
1064 return $this->orderDirection;
1065 }

References $orderDirection.

Referenced by getPostTree().

+ Here is the caller graph for this function:

◆ getOrderField()

ilForumTopic::getOrderField ( )

Definition at line 965 of file class.ilForumTopic.php.

965 : string
966 {
967 return $this->orderField;
968 }

References $orderField.

◆ getPostRootId()

ilForumTopic::getPostRootId ( )

Definition at line 212 of file class.ilForumTopic.php.

212 : int
213 {
214 $this->db->setLimit(1);
215 $res = $this->db->queryF(
216 'SELECT pos_fk FROM frm_posts_tree WHERE thr_fk = %s AND parent_pos = %s AND depth = %s ORDER BY rgt DESC',
217 ['integer', 'integer', 'integer'],
218 [$this->id, 0, 1]
219 );
220
221 if (($row = $this->db->fetchObject($res)) !== null) {
222 return (int) $row->pos_fk ?: 0;
223 }
224 return 0;
225 }

References $res.

◆ getPostRootNode()

ilForumTopic::getPostRootNode ( bool  $isModerator = false,
bool  $preventImplicitRead = false 
)

Definition at line 284 of file class.ilForumTopic.php.

285 {
286 $this->db->setLimit(1);
287 $res = $this->db->queryF(
288 '
289 SELECT *
290 FROM frm_posts
291 INNER JOIN frm_posts_tree ON pos_fk = pos_pk
292 WHERE parent_pos = %s
293 AND thr_fk = %s
294 ORDER BY rgt DESC',
295 ['integer', 'integer'],
296 [0, $this->id]
297 );
298
299 if ($row = $this->db->fetchAssoc($res)) {
300 $post = new ilForumPost((int) $row['pos_pk'], $isModerator, $preventImplicitRead);
301 $post->assignData($row);
302 return $post;
303 }
304
305 throw new OutOfBoundsException(sprintf('Could not find first posting by id: %s', $this->id));
306 }

References $post, and $res.

Referenced by updateThreadTitle().

+ Here is the caller graph for this function:

◆ getPostTree()

ilForumTopic::getPostTree ( ilForumPost  $a_post_node)

Fetches and returns an array of posts from the post tree, starting with the node object passed by the first paramter.

Parameters
ilForumPost$a_post_nodenode-object of a post
Returns
ilForumPost[] Array of post objects

Definition at line 398 of file class.ilForumTopic.php.

398 : array
399 {
400 $posts = [];
401 $data = [];
402 $data_types = [];
403
404 if ($a_post_node->getLft() > 1) {
405 $dummy_root_condition = 'lft >= %s AND lft < %s';
406 } else {
407 $dummy_root_condition = 'lft > %s AND lft < %s';
408 }
409
410 $query = '
411 SELECT is_author_moderator, pos_author_id, pos_pk, fpt_date, rgt, pos_top_fk, pos_thr_fk,
412 pos_display_user_id, pos_usr_alias, pos_subject,
413 pos_status, pos_message, pos_date, pos_update, rcid,
414 update_user, pos_cens, pos_cens_com, notify,
415 import_name, fpt_pk, parent_pos, lft, depth,
416 (CASE
417 WHEN fur.post_id IS NULL ' .
418 ($this->user->getId() === ANONYMOUS_USER_ID ? ' AND 1 = 2 ' : '') . '
419 THEN 0
420 ELSE 1
421 END) post_read,
422 firstname, lastname, title, login
423
424 FROM frm_posts_tree
425
426 INNER JOIN frm_posts
427 ON pos_fk = pos_pk
428
429 LEFT JOIN usr_data
430 ON pos_display_user_id = usr_id
431
432 LEFT JOIN frm_user_read fur
433 ON fur.thread_id = pos_thr_fk
434 AND fur.post_id = pos_pk
435 AND fur.usr_id = %s
436
437 WHERE ' . $dummy_root_condition . '
438 AND thr_fk = %s';
439 $data_types[] = 'integer';
440 $data_types[] = 'integer';
441 $data_types[] = 'integer';
442 $data_types[] = 'integer';
443 $data[] = $this->user->getId();
444 $data[] = $a_post_node->getLft();
445 $data[] = $a_post_node->getRgt();
446 $data[] = $a_post_node->getThreadId();
447
448 if ($this->orderField !== '') {
449 $query .= " ORDER BY " . $this->orderField . " " . $this->getOrderDirection();
450 }
451
452 $res = $this->db->queryF($query, $data_types, $data);
453
454 $usr_ids = [];
455 while ($row = $this->db->fetchAssoc($res)) {
456 $post = new ilForumPost((int) $row['pos_pk'], false, true);
457 $post->assignData($row);
458
459 if (!$this->is_moderator && !$post->isActivated() && $post->getPosAuthorId() !== $this->user->getId()) {
460 continue;
461 }
462
463 if ((int) $row['pos_display_user_id'] !== 0) {
464 $usr_ids[(int) $row['pos_display_user_id']] = (int) $row['pos_display_user_id'];
465 }
466 if ((int) $row['update_user'] !== 0) {
467 $usr_ids[(int) $row['update_user']] = (int) $row['update_user'];
468 }
469
470 $posts[] = $post;
471 }
472
474
475 return $posts;
476 }

References $data, $post, $res, ANONYMOUS_USER_ID, ilForumPost\getLft(), getOrderDirection(), ilForumPost\getRgt(), ilForumPost\getThreadId(), ILIAS\Repository\int(), ilForumAuthorInformationCache\preloadUserObjects(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ getSubject()

ilForumTopic::getSubject ( )

Definition at line 885 of file class.ilForumTopic.php.

885 : string
886 {
887 return $this->subject;
888 }

References $subject.

Referenced by ilObjForumGUI\getEditTitleModal(), updateMergedThread(), and updateThreadTitle().

+ Here is the caller graph for this function:

◆ getThrAuthorId()

ilForumTopic::getThrAuthorId ( )

Definition at line 980 of file class.ilForumTopic.php.

980 : int
981 {
983 }

References $thr_author_id.

Referenced by ilObjForumGUI\getThreadProperties().

+ Here is the caller graph for this function:

◆ getUserAlias()

ilForumTopic::getUserAlias ( )

Definition at line 875 of file class.ilForumTopic.php.

875 : ?string
876 {
877 return $this->user_alias;
878 }

References $user_alias.

Referenced by ilObjForumGUI\getThreadProperties().

+ Here is the caller graph for this function:

◆ getVisits()

ilForumTopic::getVisits ( )

Definition at line 935 of file class.ilForumTopic.php.

935 : int
936 {
937 return $this->visits;
938 }

References $visits.

Referenced by ilObjForumGUI\getThreadProperties(), and updateMergedThread().

+ Here is the caller graph for this function:

◆ insert()

ilForumTopic::insert ( )

Definition at line 102 of file class.ilForumTopic.php.

102 : bool
103 {
104 if ($this->forum_id !== 0) {
105 $nextId = $this->db->nextId('frm_threads');
106
107 $this->db->insert(
108 'frm_threads',
109 [
110 'thr_pk' => ['integer', $nextId],
111 'thr_top_fk' => ['integer', $this->forum_id],
112 'thr_subject' => ['text', $this->subject],
113 'thr_display_user_id' => ['integer', $this->display_user_id],
114 'thr_usr_alias' => ['text', $this->user_alias],
115 'thr_num_posts' => ['integer', $this->num_posts],
116 'thr_last_post' => ['text', $this->last_post_string],
117 'thr_date' => ['timestamp', $this->createdate],
118 'thr_update' => ['timestamp', null],
119 'import_name' => ['text', $this->import_name],
120 'is_sticky' => ['integer', (int) $this->is_sticky],
121 'is_closed' => ['integer', (int) $this->is_closed],
122 'avg_rating' => ['text', (string) $this->average_rating],
123 'thr_author_id' => ['integer', $this->thr_author_id]
124 ]
125 );
126
127 $this->id = $nextId;
128
129 return true;
130 }
131
132 return false;
133 }

◆ isClosed()

ilForumTopic::isClosed ( )

Definition at line 955 of file class.ilForumTopic.php.

955 : bool
956 {
957 return $this->is_closed;
958 }

References $is_closed.

Referenced by ilObjForumGUI\getOpenCloseActionForThread().

+ Here is the caller graph for this function:

◆ isNotificationEnabled()

ilForumTopic::isNotificationEnabled ( int  $a_user_id)

Definition at line 725 of file class.ilForumTopic.php.

725 : bool
726 {
727 if ($this->id && $a_user_id) {
728 $result = $this->db->queryF(
729 'SELECT COUNT(notification_id) cnt FROM frm_notification WHERE user_id = %s AND thread_id = %s',
730 ['integer', 'integer'],
731 [$a_user_id, $this->id]
732 );
733
734 if ($row = $this->db->fetchAssoc($result)) {
735 return (int) $row['cnt'] > 0;
736 }
737
738 return false;
739 }
740
741 return false;
742 }

Referenced by enableNotification().

+ Here is the caller graph for this function:

◆ isSticky()

ilForumTopic::isSticky ( )

Definition at line 945 of file class.ilForumTopic.php.

945 : bool
946 {
947 return $this->is_sticky;
948 }

References $is_sticky.

Referenced by ilObjForumGUI\getStickyActionForThread(), and ilObjForumGUI\getThreadProperties().

+ Here is the caller graph for this function:

◆ isUserNotificationEnabled()

ilForumTopic::isUserNotificationEnabled ( )

Definition at line 1047 of file class.ilForumTopic.php.

1047 : bool
1048 {
1050 }
bool $user_notification_enabled

References $user_notification_enabled.

◆ lookupCreationDate()

static ilForumTopic::lookupCreationDate ( int  $thread_id)
static

Definition at line 1097 of file class.ilForumTopic.php.

1097 : ?string
1098 {
1099 global $DIC;
1100 $ilDB = $DIC->database();
1101
1102 $res = $ilDB->queryF(
1103 'SELECT thr_date FROM frm_threads WHERE thr_pk = %s',
1104 ['integer'],
1105 [$thread_id]
1106 );
1107
1108 $date = null;
1109 $row = $ilDB->fetchAssoc($res);
1110 if (is_array($row)) {
1111 $date = $row['thr_date'];
1112 }
1113
1114 return $date;
1115 }

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

+ Here is the caller graph for this function:

◆ lookupForumIdByTopicId()

static ilForumTopic::lookupForumIdByTopicId ( int  $a_topic_id)
static

Definition at line 1067 of file class.ilForumTopic.php.

1067 : int
1068 {
1069 global $DIC;
1070 $ilDB = $DIC->database();
1071
1072 $res = $ilDB->queryF(
1073 'SELECT thr_top_fk FROM frm_threads WHERE thr_pk = %s',
1074 ['integer'],
1075 [$a_topic_id]
1076 );
1077
1078 $row = $ilDB->fetchAssoc($res);
1079
1080 return (int) $row['thr_top_fk'];
1081 }

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

+ Here is the caller graph for this function:

◆ lookupTitle()

static ilForumTopic::lookupTitle ( int  $a_topic_id)
static

Definition at line 985 of file class.ilForumTopic.php.

985 : string
986 {
987 global $DIC;
988 $ilDB = $DIC->database();
989
990 $res = $ilDB->queryF(
991 'SELECT thr_subject FROM frm_threads WHERE thr_pk = %s',
992 ['integer'],
993 [$a_topic_id]
994 );
995
996 if ($row = $ilDB->fetchObject($res)) {
997 return (string) $row->thr_subject;
998 }
999
1000 return '';
1001 }

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

+ Here is the caller graph for this function:

◆ makeSticky()

ilForumTopic::makeSticky ( )

Definition at line 773 of file class.ilForumTopic.php.

773 : bool
774 {
775 if ($this->id && !$this->is_sticky) {
776 $this->db->manipulateF(
777 'UPDATE frm_threads SET is_sticky = %s WHERE thr_pk = %s',
778 ['integer', 'integer'],
779 [1, $this->id]
780 );
781
782 $this->is_sticky = true;
783 return true;
784 }
785
786 return false;
787 }

◆ movePosts()

ilForumTopic::movePosts ( int  $old_obj_id,
int  $old_pk,
int  $new_obj_id,
int  $new_pk 
)

Moves all posts within the current thread to a new forum.

Parameters
int$old_obj_idobject id of the current forum
int$old_pkprimary key of old forum
int$new_obj_idobject id of the new forum
int$new_pkprimary key of new forum
Returns
int Number of afffected rows by updating posts
Exceptions
ilFileUtilsException

Definition at line 487 of file class.ilForumTopic.php.

487 : int
488 {
489 if ($this->id === 0) {
490 return 0;
491 }
492
493 $post_ids = $this->getAllPostIds();
494 $postsMoved = [];
495 try {
496 foreach ($post_ids as $post_id) {
497 $file_obj = new ilFileDataForum($old_obj_id, $post_id);
498 $moved = $file_obj->moveFilesOfPost($new_obj_id);
499
500 if ($moved) {
501 $postsMoved[] = [
502 'from' => $old_obj_id,
503 'to' => $new_obj_id,
504 'position_id' => $post_id
505 ];
506 }
507
508 unset($file_obj);
509 }
510 } catch (ilFileUtilsException $exception) {
511 foreach ($postsMoved as $postedInformation) {
512 $file_obj = new ilFileDataForum($postedInformation['to'], $postedInformation['position_id']);
513 $file_obj->moveFilesOfPost($postedInformation['from']);
514 }
515
516 throw $exception;
517 }
518
519 $current_id = $this->id;
520
521 $ilAtomQuery = $this->db->buildAtomQuery();
522 $ilAtomQuery->addTableLock('frm_user_read');
523
524 $ilAtomQuery->addQueryCallable(static function (ilDBInterface $ilDB) use ($new_obj_id, $current_id): void {
525 $ilDB->manipulateF(
526 'DELETE FROM frm_user_read WHERE obj_id = %s AND thread_id =%s',
527 ['integer', 'integer'],
528 [$new_obj_id, $current_id]
529 );
530
531 $ilDB->manipulateF(
532 'UPDATE frm_user_read SET obj_id = %s WHERE thread_id = %s',
533 ['integer', 'integer'],
534 [$new_obj_id, $current_id]
535 );
536 });
537
538 $ilAtomQuery->run();
539
540 $this->db->manipulateF(
541 'UPDATE frm_posts SET pos_top_fk = %s WHERE pos_thr_fk = %s',
542 ['integer', 'integer'],
543 [$new_pk, $this->id]
544 );
545
546 $res = $this->db->queryF(
547 'SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
548 ['integer'],
549 [$this->id]
550 );
551
552 $old_obj_id = ilForum::_lookupObjIdForForumId($old_pk);
553 $new_obj_id = ilForum::_lookupObjIdForForumId($new_pk);
554
555 while ($post = $this->db->fetchAssoc($res)) {
557 $old_obj_id,
558 'frm',
559 (int) $post['pos_pk'],
560 'pos'
561 );
562 $news_item = new ilNewsItem($news_id);
563 $news_item->setContextObjId($new_obj_id);
564 $news_item->update();
565 }
566
567 return count($post_ids);
568 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjIdForForumId(int $a_for_id)
A news item can be created by different sources.
static getFirstNewsIdForContext(int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
Interface ilDBInterface.

References $id, $ilDB, $post, $res, ilForum\_lookupObjIdForForumId(), getAllPostIds(), and ilNewsItem\getFirstNewsIdForContext().

+ Here is the call graph for this function:

◆ read()

ilForumTopic::read ( )
private

Definition at line 166 of file class.ilForumTopic.php.

166 : bool
167 {
168 if ($this->id !== 0) {
169 $res = $this->db->queryF(
170 '
171 SELECT frm_threads.*, top_frm_fk frm_obj_id
172 FROM frm_threads
173 INNER JOIN frm_data ON top_pk = thr_top_fk
174 WHERE thr_pk = %s',
175 ['integer'],
176 [$this->id]
177 );
178
179 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
180
181 if (is_object($row)) {
182 $this->forum_id = (int) $row->thr_top_fk;
183 $this->display_user_id = (int) $row->thr_display_user_id;
184 $this->user_alias = $row->thr_usr_alias;
185 $this->subject = html_entity_decode((string) $row->thr_subject);
186 $this->createdate = $row->thr_date;
187 $this->changedate = $row->thr_update;
188 $this->import_name = $row->import_name;
189 $this->num_posts = (int) $row->thr_num_posts;
190 $this->last_post_string = $row->thr_last_post;
191 $this->visits = (int) $row->visits;
192 $this->is_sticky = (bool) $row->is_sticky;
193 $this->is_closed = (bool) $row->is_closed;
194 $this->frm_obj_id = (int) $row->frm_obj_id;
195 $this->average_rating = (float) $row->avg_rating;
196 $this->thr_author_id = (int) $row->thr_author_id;
197
198 return true;
199 }
200 $this->id = 0;
201 return false;
202 }
203
204 return false;
205 }

References $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by __construct(), and reload().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reload()

ilForumTopic::reload ( )

Definition at line 207 of file class.ilForumTopic.php.

207 : bool
208 {
209 return $this->read();
210 }

References read().

+ Here is the call graph for this function:

◆ reopen()

ilForumTopic::reopen ( )

Definition at line 817 of file class.ilForumTopic.php.

817 : void
818 {
819 if ($this->id && $this->is_closed) {
820 $this->db->manipulateF(
821 'UPDATE frm_threads SET is_closed = %s WHERE thr_pk = %s',
822 ['integer', 'integer'],
823 [0, $this->id]
824 );
825
826 $this->is_closed = false;
827 }
828 }

◆ setAverageRating()

ilForumTopic::setAverageRating ( float  $average_rating)

Definition at line 835 of file class.ilForumTopic.php.

835 : void
836 {
837 $this->average_rating = $average_rating;
838 }

References $average_rating.

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setChangeDate()

ilForumTopic::setChangeDate ( ?string  $a_changedate)

Definition at line 900 of file class.ilForumTopic.php.

900 : void
901 {
902 $this->changedate = $a_changedate;
903 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setClosed()

ilForumTopic::setClosed ( bool  $a_closed)

Definition at line 950 of file class.ilForumTopic.php.

950 : void
951 {
952 $this->is_closed = $a_closed;
953 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setCreateDate()

ilForumTopic::setCreateDate ( ?string  $a_createdate)

Definition at line 890 of file class.ilForumTopic.php.

890 : void
891 {
892 $this->createdate = $a_createdate;
893 }

Referenced by assignData(), and ilForum\generateThread().

+ Here is the caller graph for this function:

◆ setDisplayUserId()

ilForumTopic::setDisplayUserId ( int  $a_user_id)

Definition at line 860 of file class.ilForumTopic.php.

860 : void
861 {
862 $this->display_user_id = $a_user_id;
863 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setForumId()

ilForumTopic::setForumId ( int  $a_forum_id)

Definition at line 850 of file class.ilForumTopic.php.

850 : void
851 {
852 $this->forum_id = $a_forum_id;
853 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setId()

ilForumTopic::setId ( int  $a_id)

Definition at line 840 of file class.ilForumTopic.php.

840 : void
841 {
842 $this->id = $a_id;
843 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setImportName()

ilForumTopic::setImportName ( ?string  $a_import_name)

Definition at line 910 of file class.ilForumTopic.php.

910 : void
911 {
912 $this->import_name = $a_import_name;
913 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setLastPostForThreadOverview()

ilForumTopic::setLastPostForThreadOverview ( ilForumPost  $post)

Definition at line 1122 of file class.ilForumTopic.php.

1122 : void
1123 {
1124 $this->last_post = $post;
1125 }

References $post.

◆ setLastPostString()

ilForumTopic::setLastPostString ( ?string  $a_last_post)

Definition at line 920 of file class.ilForumTopic.php.

920 : void
921 {
922 $this->last_post_string = $a_last_post;
923 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setNumPosts()

ilForumTopic::setNumPosts ( int  $a_num_posts)

Definition at line 1019 of file class.ilForumTopic.php.

1019 : ilForumTopic
1020 {
1021 $this->num_posts = $a_num_posts;
1022 return $this;
1023 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setNumUnreadPosts()

ilForumTopic::setNumUnreadPosts ( int  $num_unread_posts)

Definition at line 1030 of file class.ilForumTopic.php.

1030 : ilForumTopic
1031 {
1032 $this->num_unread_posts = $num_unread_posts;
1033 return $this;
1034 }

References $num_unread_posts.

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setOrderDirection()

ilForumTopic::setOrderDirection ( string  $direction)

Definition at line 1052 of file class.ilForumTopic.php.

1052 : ilForumTopic
1053 {
1054 if (!in_array(strtoupper($direction), self::$possibleOrderDirections, true)) {
1055 $direction = current(self::$possibleOrderDirections);
1056 }
1057
1058 $this->orderDirection = $direction;
1059 return $this;
1060 }

◆ setOrderField()

ilForumTopic::setOrderField ( string  $a_order_field)

Definition at line 960 of file class.ilForumTopic.php.

960 : void
961 {
962 $this->orderField = $a_order_field;
963 }

◆ setSticky()

ilForumTopic::setSticky ( bool  $a_sticky)

Definition at line 940 of file class.ilForumTopic.php.

940 : void
941 {
942 $this->is_sticky = $a_sticky;
943 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setSubject()

ilForumTopic::setSubject ( string  $a_subject)

Definition at line 880 of file class.ilForumTopic.php.

880 : void
881 {
882 $this->subject = $a_subject;
883 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setThrAuthorId()

ilForumTopic::setThrAuthorId ( int  $thr_author_id)

Definition at line 975 of file class.ilForumTopic.php.

975 : void
976 {
977 $this->thr_author_id = $thr_author_id;
978 }

References $thr_author_id.

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setUserAlias()

ilForumTopic::setUserAlias ( ?string  $a_user_alias)

Definition at line 870 of file class.ilForumTopic.php.

870 : void
871 {
872 $this->user_alias = $a_user_alias;
873 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setUserNotificationEnabled()

ilForumTopic::setUserNotificationEnabled ( bool  $status)

Definition at line 1041 of file class.ilForumTopic.php.

1041 : ilForumTopic
1042 {
1043 $this->user_notification_enabled = $status;
1044 return $this;
1045 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setVisits()

ilForumTopic::setVisits ( int  $a_visits)

Definition at line 930 of file class.ilForumTopic.php.

930 : void
931 {
932 $this->visits = $a_visits;
933 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ unmakeSticky()

ilForumTopic::unmakeSticky ( )

Definition at line 789 of file class.ilForumTopic.php.

789 : bool
790 {
791 if ($this->id && $this->is_sticky) {
792 $this->db->manipulateF(
793 'UPDATE frm_threads SET is_sticky = %s WHERE thr_pk = %s',
794 ['integer', 'integer'],
795 [0, $this->id]
796 );
797
798 $this->is_sticky = false;
799 return true;
800 }
801
802 return false;
803 }

◆ update()

ilForumTopic::update ( )

Definition at line 135 of file class.ilForumTopic.php.

135 : bool
136 {
137 if ($this->id !== 0) {
138 $this->db->manipulateF(
139 '
140 UPDATE frm_threads
141 SET thr_top_fk = %s,
142 thr_subject = %s,
143 thr_update = %s,
144 thr_num_posts = %s,
145 thr_last_post = %s,
146 avg_rating = %s
147 WHERE thr_pk = %s',
148 ['integer', 'text', 'timestamp', 'integer', 'text', 'text', 'integer'],
149 [
150 $this->forum_id,
151 $this->subject,
152 date('Y-m-d H:i:s'),
153 $this->num_posts,
154 $this->last_post_string,
155 (string) $this->average_rating,
156 $this->id
157 ]
158 );
159
160 return true;
161 }
162
163 return false;
164 }

◆ updateMergedThread()

ilForumTopic::updateMergedThread ( )

Definition at line 1083 of file class.ilForumTopic.php.

1083 : void
1084 {
1085 $this->db->update(
1086 'frm_threads',
1087 [
1088 'thr_num_posts' => ['integer', $this->getNumPosts()],
1089 'visits' => ['integer', $this->getVisits()],
1090 'thr_last_post' => ['text', $this->getLastPostString()],
1091 'thr_subject' => ['text', $this->getSubject()]
1092 ],
1093 ['thr_pk' => ['integer', $this->getId()]]
1094 );
1095 }

References getId(), getLastPostString(), getNumPosts(), getSubject(), and getVisits().

+ Here is the call graph for this function:

◆ updateThreadTitle()

ilForumTopic::updateThreadTitle ( )

Definition at line 1003 of file class.ilForumTopic.php.

1003 : void
1004 {
1005 $this->db->update(
1006 'frm_threads',
1007 ['thr_subject' => ['text', $this->getSubject()]],
1008 ['thr_pk' => ['integer', $this->getId()]]
1009 );
1010
1011 try {
1012 $first_node = $this->getPostRootNode();
1013 $first_node->setSubject($this->getSubject());
1014 $first_node->update();
1015 } catch (OutOfBoundsException) {
1016 }
1017 }
getPostRootNode(bool $isModerator=false, bool $preventImplicitRead=false)

References getId(), getPostRootNode(), and getSubject().

+ Here is the call graph for this function:

◆ updateVisits()

ilForumTopic::updateVisits ( )

Definition at line 227 of file class.ilForumTopic.php.

227 : void
228 {
229 $checkTime = time() - (60 * 60);
230
231 if (ilSession::get('frm_visit_frm_threads_' . $this->id) < $checkTime) {
232 ilSession::set('frm_visit_frm_threads_' . $this->id, time());
233
234 $this->db->manipulateF(
235 'UPDATE frm_threads SET visits = visits + 1 WHERE thr_pk = %s',
236 ['integer'],
237 [$this->id]
238 );
239 }
240 }
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.

References ilSession\get(), and ilSession\set().

+ Here is the call graph for this function:

Field Documentation

◆ $average_rating

float ilForumTopic::$average_rating = 0.0
private

Definition at line 46 of file class.ilForumTopic.php.

Referenced by getAverageRating(), and setAverageRating().

◆ $changedate

string ilForumTopic::$changedate = null
private

Definition at line 35 of file class.ilForumTopic.php.

Referenced by getChangeDate().

◆ $createdate

string ilForumTopic::$createdate = null
private

Definition at line 34 of file class.ilForumTopic.php.

Referenced by getCreateDate().

◆ $db

readonly ilDBInterface ilForumTopic::$db
private

Definition at line 44 of file class.ilForumTopic.php.

◆ $display_user_id

int ilForumTopic::$display_user_id = 0
private

Definition at line 31 of file class.ilForumTopic.php.

Referenced by getDisplayUserId().

◆ $forum_id

int ilForumTopic::$forum_id = 0
private

Definition at line 29 of file class.ilForumTopic.php.

Referenced by getForumId().

◆ $frm_obj_id

int ilForumTopic::$frm_obj_id = 0
private

Definition at line 30 of file class.ilForumTopic.php.

Referenced by getFrmObjId().

◆ $import_name

string ilForumTopic::$import_name = null
private

Definition at line 39 of file class.ilForumTopic.php.

Referenced by getImportName().

◆ $is_closed

bool ilForumTopic::$is_closed = false
private

Definition at line 41 of file class.ilForumTopic.php.

Referenced by isClosed().

◆ $is_sticky

bool ilForumTopic::$is_sticky = false
private

Definition at line 40 of file class.ilForumTopic.php.

Referenced by isSticky().

◆ $last_post

ilForumPost ilForumTopic::$last_post = null
private

Definition at line 43 of file class.ilForumTopic.php.

Referenced by getLastPostForThreadOverview().

◆ $last_post_string

string ilForumTopic::$last_post_string = null
private

Definition at line 37 of file class.ilForumTopic.php.

Referenced by getLastPostString().

◆ $num_posts

int ilForumTopic::$num_posts = 0
private

Definition at line 36 of file class.ilForumTopic.php.

Referenced by getNumPosts().

◆ $num_unread_posts

int ilForumTopic::$num_unread_posts = 0
private

Definition at line 49 of file class.ilForumTopic.php.

Referenced by getNumUnreadPosts(), and setNumUnreadPosts().

◆ $orderDirection

string ilForumTopic::$orderDirection = 'DESC'
private

Definition at line 47 of file class.ilForumTopic.php.

Referenced by getOrderDirection().

◆ $orderField

string ilForumTopic::$orderField = ''
private

Definition at line 42 of file class.ilForumTopic.php.

Referenced by getOrderField().

◆ $possibleOrderDirections

array ilForumTopic::$possibleOrderDirections = ['ASC', 'DESC']
staticprivate

Definition at line 27 of file class.ilForumTopic.php.

◆ $subject

string ilForumTopic::$subject = ''
private

Definition at line 33 of file class.ilForumTopic.php.

Referenced by getSubject().

◆ $thr_author_id

int ilForumTopic::$thr_author_id = 0
private

Definition at line 45 of file class.ilForumTopic.php.

Referenced by getThrAuthorId(), and setThrAuthorId().

◆ $user

readonly ilObjUser ilForumTopic::$user
private

Definition at line 48 of file class.ilForumTopic.php.

◆ $user_alias

string ilForumTopic::$user_alias = null
private

Definition at line 32 of file class.ilForumTopic.php.

Referenced by getUserAlias().

◆ $user_notification_enabled

bool ilForumTopic::$user_notification_enabled = false
private

Definition at line 50 of file class.ilForumTopic.php.

Referenced by isUserNotificationEnabled().

◆ $visits

int ilForumTopic::$visits = 0
private

Definition at line 38 of file class.ilForumTopic.php.

Referenced by getVisits().


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