ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilForumTopic Class Reference
+ Collaboration diagram for ilForumTopic:

Public Member Functions

 __construct (private int $id=0, private bool $is_moderator=false, bool $preventImplicitRead=false)
 Returns an object of a forum topic. More...
 
 assignData (array $data)
 
 insert ()
 
 update ()
 
 reload ()
 
 getPostRootId ()
 
 getFirstVisiblePostId ()
 
 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)
 

Static Protected Attributes

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

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
 
ilDBInterface $db
 
int $thr_author_id = 0
 
float $average_rating = 0.0
 
string $orderDirection = 'DESC'
 
ilObjUser $user
 
int $num_unread_posts = 0
 
bool $user_notification_enabled = false
 

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 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 58 of file class.ilForumTopic.php.

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

62  {
63  global $DIC;
64  $this->db = $DIC->database();
65  $this->user = $DIC->user();
66 
67  if (!$preventImplicitRead) {
68  $this->read();
69  }
70  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ assignData()

ilForumTopic::assignData ( array  $data)

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

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

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

◆ close()

ilForumTopic::close ( )

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

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

◆ countActivePosts()

ilForumTopic::countActivePosts ( bool  $ignoreRoot = false)

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

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

276  : int
277  {
278  $res = $this->db->queryF(
279  '
280  SELECT COUNT(*) cnt
281  FROM frm_posts
282  INNER JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
283  WHERE (pos_status = %s
284  OR (pos_status = %s AND pos_display_user_id = %s))
285  AND pos_thr_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
286  ['integer', 'integer', 'integer', 'integer'],
287  ['1', '0', $this->user->getId(), $this->id]
288  );
289 
290  $row = $this->db->fetchAssoc($res);
291  if (is_array($row)) {
292  return (int) $row['cnt'];
293  }
294 
295  return 0;
296  }
$res
Definition: ltiservices.php:69
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ countPosts()

ilForumTopic::countPosts ( bool  $ignoreRoot = false)

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

References $res.

256  : int
257  {
258  $res = $this->db->queryF(
259  '
260  SELECT COUNT(*) cnt
261  FROM frm_posts
262  INNER JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
263  WHERE pos_thr_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
264  ['integer'],
265  [$this->id]
266  );
267 
268  $row = $this->db->fetchAssoc($res);
269  if (is_array($row)) {
270  return (int) $row['cnt'];
271  }
272 
273  return 0;
274  }
$res
Definition: ltiservices.php:69

◆ disableNotification()

ilForumTopic::disableNotification ( int  $a_user_id)

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

776  : void
777  {
778  if ($this->id && $a_user_id) {
779  $this->db->manipulateF(
780  'DELETE FROM frm_notification WHERE user_id = %s AND thread_id = %s',
781  ['integer', 'integer'],
782  [$a_user_id, $this->id]
783  );
784  }
785  }

◆ enableNotification()

ilForumTopic::enableNotification ( int  $a_user_id)

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

References isNotificationEnabled().

Referenced by ilForum\generateThread().

758  : void
759  {
760  if ($this->id && $a_user_id && !$this->isNotificationEnabled($a_user_id)) {
761  $nextId = $this->db->nextId('frm_notification');
762  $this->db->manipulateF(
763  '
764  INSERT INTO frm_notification
765  ( notification_id,
766  user_id,
767  thread_id
768  )
769  VALUES(%s, %s, %s)',
770  ['integer', 'integer', 'integer'],
771  [$nextId, $a_user_id, $this->id]
772  );
773  }
774  }
isNotificationEnabled(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllPostIds()

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

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

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

Referenced by movePosts().

391  : array
392  {
393  $posts = [];
394 
395  if ($this->id !== 0) {
396  $res = $this->db->queryF('SELECT pos_pk FROM frm_posts WHERE pos_thr_fk = %s', ['integer'], [$this->id]);
397 
398  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
399  $posts[(int) $row->pos_pk] = (int) $row->pos_pk;
400  }
401  }
402 
403  return $posts;
404  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAverageRating()

ilForumTopic::getAverageRating ( )

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

References $average_rating.

844  : float
845  {
846  return $this->average_rating;
847  }

◆ getChangeDate()

ilForumTopic::getChangeDate ( )

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

References $changedate.

919  : ?string
920  {
921  return $this->changedate;
922  }

◆ getCreateDate()

ilForumTopic::getCreateDate ( )

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

References $createdate.

Referenced by ilForum\generateThread().

909  : ?string
910  {
911  return $this->createdate;
912  }
+ Here is the caller graph for this function:

◆ getDisplayUserId()

ilForumTopic::getDisplayUserId ( )

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

References $display_user_id.

Referenced by ilForum\generateThread(), and ilObjForumGUI\getThreadProperties().

879  : int
880  {
881  return $this->display_user_id;
882  }
+ Here is the caller graph for this function:

◆ getFirstVisiblePostId()

ilForumTopic::getFirstVisiblePostId ( )

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

References $res.

226  : int
227  {
228  $this->db->setLimit(1);
229  $res = $this->db->queryF(
230  'SELECT pos_fk FROM frm_posts_tree WHERE thr_fk = %s AND parent_pos != %s AND depth = %s ORDER BY rgt DESC',
231  ['integer', 'integer', 'integer'],
232  [$this->id, 0, 2]
233  );
234 
235  if (($row = $this->db->fetchObject($res)) !== null) {
236  return (int) $row->pos_fk ?: 0;
237  }
238  return 0;
239  }
$res
Definition: ltiservices.php:69

◆ getFirstVisiblePostNode()

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

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

References $post, and $res.

Referenced by updateThreadTitle().

322  : ilForumPost
323  {
324  $this->db->setLimit(1);
325  $res = $this->db->queryF(
326  '
327  SELECT *
328  FROM frm_posts
329  INNER JOIN frm_posts_tree ON pos_fk = pos_pk
330  WHERE parent_pos != %s
331  AND thr_fk = %s
332  AND depth = %s
333  ORDER BY rgt DESC',
334  ['integer', 'integer', 'integer'],
335  [0, $this->id, 2]
336  );
337 
338  if ($row = $this->db->fetchAssoc($res)) {
339  $post = new ilForumPost((int) $row['pos_pk'], $isModerator, $preventImplicitRead);
340  $post->assignData($row);
341  return $post;
342  }
343 
344  throw new OutOfBoundsException(sprintf('Could not find first posting by id: %s', $this->id));
345  }
$res
Definition: ltiservices.php:69
$post
Definition: ltitoken.php:49
+ Here is the caller graph for this function:

◆ getForumId()

ilForumTopic::getForumId ( )

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

References $forum_id.

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

869  : int
870  {
871  return $this->forum_id;
872  }
+ Here is the caller graph for this function:

◆ getFrmObjId()

ilForumTopic::getFrmObjId ( )

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

References $frm_obj_id.

Referenced by getNestedSetPostChildren().

984  : int
985  {
986  return $this->frm_obj_id;
987  }
+ Here is the caller graph for this function:

◆ getId()

ilForumTopic::getId ( )

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

References $id.

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

859  : int
860  {
861  return $this->id;
862  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ getImportName()

ilForumTopic::getImportName ( )

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

References $import_name.

Referenced by ilObjForumGUI\getThreadProperties().

929  : ?string
930  {
931  return $this->import_name;
932  }
+ Here is the caller graph for this function:

◆ getLastActivePost()

ilForumTopic::getLastActivePost ( )

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

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

365  : ilForumPost
366  {
367  if ($this->id !== 0) {
368  $this->db->setLimit(1);
369  $res = $this->db->queryF(
370  '
371  SELECT pos_pk
372  FROM frm_posts
373  WHERE pos_thr_fk = %s
374  AND (pos_status = %s OR (pos_status = %s AND pos_display_user_id = %s))
375  ORDER BY pos_date DESC',
376  ['integer', 'integer', 'integer', 'integer'],
377  [$this->id, '1', '0', $this->user->getId()]
378  );
379 
380  if (($row = $this->db->fetchObject($res)) !== null) {
381  return new ilForumPost((int) $row->pos_pk);
382  }
383  }
384 
385  throw new OutOfBoundsException(sprintf('Could not find last active posting by id: %s', $this->id));
386  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ getLastPost()

ilForumTopic::getLastPost ( )

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

References $res.

Referenced by ilObjForumGUI\getThreadProperties().

347  : ilForumPost
348  {
349  if ($this->id !== 0) {
350  $this->db->setLimit(1);
351  $res = $this->db->queryF(
352  'SELECT pos_pk FROM frm_posts WHERE pos_thr_fk = %s ORDER BY pos_date DESC',
353  ['integer'],
354  [$this->id]
355  );
356 
357  if (($row = $this->db->fetchObject($res)) !== null) {
358  return new ilForumPost((int) $row->pos_pk);
359  }
360  }
361 
362  throw new OutOfBoundsException(sprintf('Could not find last posting by id: %s', $this->id));
363  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ getLastPostForThreadOverview()

ilForumTopic::getLastPostForThreadOverview ( )

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

References $last_post.

1131  : ?ilForumPost
1132  {
1133  return $this->last_post;
1134  }
ilForumPost $last_post

◆ getLastPostString()

ilForumTopic::getLastPostString ( )

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

References $last_post_string.

Referenced by updateMergedThread().

939  : ?string
940  {
942  }
+ Here is the caller graph for this function:

◆ getNestedSetPostChildren()

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

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

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

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

◆ getNumPosts()

ilForumTopic::getNumPosts ( )

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

References $num_posts.

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

1039  : int
1040  {
1041  return $this->num_posts;
1042  }
+ Here is the caller graph for this function:

◆ getNumUnreadPosts()

ilForumTopic::getNumUnreadPosts ( )

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

References $num_unread_posts.

Referenced by ilObjForumGUI\getThreadProperties().

1050  : int
1051  {
1052  return $this->num_unread_posts;
1053  }
+ Here is the caller graph for this function:

◆ getOrderDirection()

ilForumTopic::getOrderDirection ( )

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

References $orderDirection.

Referenced by getPostTree().

1076  : string
1077  {
1078  return $this->orderDirection;
1079  }
+ Here is the caller graph for this function:

◆ getOrderField()

ilForumTopic::getOrderField ( )

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

References $orderField.

979  : string
980  {
981  return $this->orderField;
982  }

◆ getPostRootId()

ilForumTopic::getPostRootId ( )

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

References $res.

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

◆ getPostRootNode()

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

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

References $post, and $res.

Referenced by ilObjForumGUI\toggleExplorerNodeStateObject().

298  : ilForumPost
299  {
300  $this->db->setLimit(1);
301  $res = $this->db->queryF(
302  '
303  SELECT *
304  FROM frm_posts
305  INNER JOIN frm_posts_tree ON pos_fk = pos_pk
306  WHERE parent_pos = %s
307  AND thr_fk = %s
308  ORDER BY rgt DESC',
309  ['integer', 'integer'],
310  [0, $this->id]
311  );
312 
313  if ($row = $this->db->fetchAssoc($res)) {
314  $post = new ilForumPost((int) $row['pos_pk'], $isModerator, $preventImplicitRead);
315  $post->assignData($row);
316  return $post;
317  }
318 
319  throw new OutOfBoundsException(sprintf('Could not find first posting by id: %s', $this->id));
320  }
$res
Definition: ltiservices.php:69
$post
Definition: ltitoken.php:49
+ 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 412 of file class.ilForumTopic.php.

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

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

◆ getSubject()

ilForumTopic::getSubject ( )

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

References $subject.

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

899  : string
900  {
901  return $this->subject;
902  }
+ Here is the caller graph for this function:

◆ getThrAuthorId()

ilForumTopic::getThrAuthorId ( )

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

References $thr_author_id.

Referenced by ilForum\generateThread(), and ilObjForumGUI\getThreadProperties().

994  : int
995  {
996  return $this->thr_author_id;
997  }
+ Here is the caller graph for this function:

◆ getUserAlias()

ilForumTopic::getUserAlias ( )

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

References $user_alias.

Referenced by ilForum\generateThread(), and ilObjForumGUI\getThreadProperties().

889  : ?string
890  {
891  return $this->user_alias;
892  }
+ Here is the caller graph for this function:

◆ getVisits()

ilForumTopic::getVisits ( )

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

References $visits.

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

949  : int
950  {
951  return $this->visits;
952  }
+ Here is the caller graph for this function:

◆ insert()

ilForumTopic::insert ( )

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

Referenced by ilForum\generateThread().

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

◆ isClosed()

ilForumTopic::isClosed ( )

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

References $is_closed.

Referenced by ilObjForumGUI\getOpenCloseActionForThread().

969  : bool
970  {
971  return $this->is_closed;
972  }
+ Here is the caller graph for this function:

◆ isNotificationEnabled()

ilForumTopic::isNotificationEnabled ( int  $a_user_id)

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

Referenced by enableNotification().

739  : bool
740  {
741  if ($this->id && $a_user_id) {
742  $result = $this->db->queryF(
743  'SELECT COUNT(notification_id) cnt FROM frm_notification WHERE user_id = %s AND thread_id = %s',
744  ['integer', 'integer'],
745  [$a_user_id, $this->id]
746  );
747 
748  if ($row = $this->db->fetchAssoc($result)) {
749  return (int) $row['cnt'] > 0;
750  }
751 
752  return false;
753  }
754 
755  return false;
756  }
+ Here is the caller graph for this function:

◆ isSticky()

ilForumTopic::isSticky ( )

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

References $is_sticky.

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

959  : bool
960  {
961  return $this->is_sticky;
962  }
+ Here is the caller graph for this function:

◆ isUserNotificationEnabled()

ilForumTopic::isUserNotificationEnabled ( )

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

References $user_notification_enabled.

1061  : bool
1062  {
1064  }
bool $user_notification_enabled

◆ lookupCreationDate()

static ilForumTopic::lookupCreationDate ( int  $thread_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1111  : ?string
1112  {
1113  global $DIC;
1114  $ilDB = $DIC->database();
1115 
1116  $res = $ilDB->queryF(
1117  'SELECT thr_date FROM frm_threads WHERE thr_pk = %s',
1118  ['integer'],
1119  [$thread_id]
1120  );
1121 
1122  $date = null;
1123  $row = $ilDB->fetchAssoc($res);
1124  if (is_array($row)) {
1125  $date = $row['thr_date'];
1126  }
1127 
1128  return $date;
1129  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ lookupForumIdByTopicId()

static ilForumTopic::lookupForumIdByTopicId ( int  $a_topic_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1081  : int
1082  {
1083  global $DIC;
1084  $ilDB = $DIC->database();
1085 
1086  $res = $ilDB->queryF(
1087  'SELECT thr_top_fk FROM frm_threads WHERE thr_pk = %s',
1088  ['integer'],
1089  [$a_topic_id]
1090  );
1091 
1092  $row = $ilDB->fetchAssoc($res);
1093 
1094  return (int) $row['thr_top_fk'];
1095  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ lookupTitle()

static ilForumTopic::lookupTitle ( int  $a_topic_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

999  : string
1000  {
1001  global $DIC;
1002  $ilDB = $DIC->database();
1003 
1004  $res = $ilDB->queryF(
1005  'SELECT thr_subject FROM frm_threads WHERE thr_pk = %s',
1006  ['integer'],
1007  [$a_topic_id]
1008  );
1009 
1010  if ($row = $ilDB->fetchObject($res)) {
1011  return (string) $row->thr_subject;
1012  }
1013 
1014  return '';
1015  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ makeSticky()

ilForumTopic::makeSticky ( )

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

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

◆ 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 501 of file class.ilForumTopic.php.

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

501  : int
502  {
503  if ($this->id === 0) {
504  return 0;
505  }
506 
507  $post_ids = $this->getAllPostIds();
508  $postsMoved = [];
509  try {
510  foreach ($post_ids as $post_id) {
511  $file_obj = new ilFileDataForum($old_obj_id, $post_id);
512  $moved = $file_obj->moveFilesOfPost($new_obj_id);
513 
514  if ($moved) {
515  $postsMoved[] = [
516  'from' => $old_obj_id,
517  'to' => $new_obj_id,
518  'position_id' => $post_id
519  ];
520  }
521 
522  unset($file_obj);
523  }
524  } catch (ilFileUtilsException $exception) {
525  foreach ($postsMoved as $postedInformation) {
526  $file_obj = new ilFileDataForum($postedInformation['to'], $postedInformation['position_id']);
527  $file_obj->moveFilesOfPost($postedInformation['from']);
528  }
529 
530  throw $exception;
531  }
532 
533  $current_id = $this->id;
534 
535  $ilAtomQuery = $this->db->buildAtomQuery();
536  $ilAtomQuery->addTableLock('frm_user_read');
537 
538  $ilAtomQuery->addQueryCallable(static function (ilDBInterface $ilDB) use ($new_obj_id, $current_id): void {
539  $ilDB->manipulateF(
540  'DELETE FROM frm_user_read WHERE obj_id = %s AND thread_id =%s',
541  ['integer', 'integer'],
542  [$new_obj_id, $current_id]
543  );
544 
545  $ilDB->manipulateF(
546  'UPDATE frm_user_read SET obj_id = %s WHERE thread_id = %s',
547  ['integer', 'integer'],
548  [$new_obj_id, $current_id]
549  );
550  });
551 
552  $ilAtomQuery->run();
553 
554  $this->db->manipulateF(
555  'UPDATE frm_posts SET pos_top_fk = %s WHERE pos_thr_fk = %s',
556  ['integer', 'integer'],
557  [$new_pk, $this->id]
558  );
559 
560  $res = $this->db->queryF(
561  'SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
562  ['integer'],
563  [$this->id]
564  );
565 
566  $old_obj_id = ilForum::_lookupObjIdForForumId($old_pk);
567  $new_obj_id = ilForum::_lookupObjIdForForumId($new_pk);
568 
569  while ($post = $this->db->fetchAssoc($res)) {
571  $old_obj_id,
572  'frm',
573  (int) $post['pos_pk'],
574  'pos'
575  );
576  $news_item = new ilNewsItem($news_id);
577  $news_item->setContextObjId($new_obj_id);
578  $news_item->update();
579  }
580 
581  return count($post_ids);
582  }
$res
Definition: ltiservices.php:69
manipulateF(string $query, array $types, array $values)
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.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$post
Definition: ltitoken.php:49
+ Here is the call graph for this function:

◆ read()

ilForumTopic::read ( )
private

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

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

Referenced by __construct(), and reload().

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

◆ reload()

ilForumTopic::reload ( )

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

References read().

206  : bool
207  {
208  return $this->read();
209  }
+ Here is the call graph for this function:

◆ reopen()

ilForumTopic::reopen ( )

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

831  : void
832  {
833  if ($this->id && $this->is_closed) {
834  $this->db->manipulateF(
835  'UPDATE frm_threads SET is_closed = %s WHERE thr_pk = %s',
836  ['integer', 'integer'],
837  [0, $this->id]
838  );
839 
840  $this->is_closed = false;
841  }
842  }

◆ setAverageRating()

ilForumTopic::setAverageRating ( float  $average_rating)

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

References $average_rating.

Referenced by assignData().

849  : void
850  {
851  $this->average_rating = $average_rating;
852  }
+ Here is the caller graph for this function:

◆ setChangeDate()

ilForumTopic::setChangeDate ( ?string  $a_changedate)

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

Referenced by assignData().

914  : void
915  {
916  $this->changedate = $a_changedate;
917  }
+ Here is the caller graph for this function:

◆ setClosed()

ilForumTopic::setClosed ( bool  $a_closed)

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

Referenced by assignData().

964  : void
965  {
966  $this->is_closed = $a_closed;
967  }
+ Here is the caller graph for this function:

◆ setCreateDate()

ilForumTopic::setCreateDate ( ?string  $a_createdate)

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

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

904  : void
905  {
906  $this->createdate = $a_createdate;
907  }
+ Here is the caller graph for this function:

◆ setDisplayUserId()

ilForumTopic::setDisplayUserId ( int  $a_user_id)

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

Referenced by assignData().

874  : void
875  {
876  $this->display_user_id = $a_user_id;
877  }
+ Here is the caller graph for this function:

◆ setForumId()

ilForumTopic::setForumId ( int  $a_forum_id)

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

Referenced by assignData().

864  : void
865  {
866  $this->forum_id = $a_forum_id;
867  }
+ Here is the caller graph for this function:

◆ setId()

ilForumTopic::setId ( int  $a_id)

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

Referenced by assignData().

854  : void
855  {
856  $this->id = $a_id;
857  }
+ Here is the caller graph for this function:

◆ setImportName()

ilForumTopic::setImportName ( ?string  $a_import_name)

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

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

924  : void
925  {
926  $this->import_name = $a_import_name;
927  }
+ Here is the caller graph for this function:

◆ setLastPostForThreadOverview()

ilForumTopic::setLastPostForThreadOverview ( ilForumPost  $post)

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

References $post.

1136  : void
1137  {
1138  $this->last_post = $post;
1139  }
$post
Definition: ltitoken.php:49

◆ setLastPostString()

ilForumTopic::setLastPostString ( ?string  $a_last_post)

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

Referenced by assignData().

934  : void
935  {
936  $this->last_post_string = $a_last_post;
937  }
+ Here is the caller graph for this function:

◆ setNumPosts()

ilForumTopic::setNumPosts ( int  $a_num_posts)

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

Referenced by assignData().

1033  : ilForumTopic
1034  {
1035  $this->num_posts = $a_num_posts;
1036  return $this;
1037  }
+ Here is the caller graph for this function:

◆ setNumUnreadPosts()

ilForumTopic::setNumUnreadPosts ( int  $num_unread_posts)

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

References $num_unread_posts.

Referenced by assignData().

1044  : ilForumTopic
1045  {
1046  $this->num_unread_posts = $num_unread_posts;
1047  return $this;
1048  }
+ Here is the caller graph for this function:

◆ setOrderDirection()

ilForumTopic::setOrderDirection ( string  $direction)

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

1066  : ilForumTopic
1067  {
1068  if (!in_array(strtoupper($direction), self::$possibleOrderDirections, true)) {
1069  $direction = current(self::$possibleOrderDirections);
1070  }
1071 
1072  $this->orderDirection = $direction;
1073  return $this;
1074  }

◆ setOrderField()

ilForumTopic::setOrderField ( string  $a_order_field)

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

974  : void
975  {
976  $this->orderField = $a_order_field;
977  }

◆ setSticky()

ilForumTopic::setSticky ( bool  $a_sticky)

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

Referenced by assignData().

954  : void
955  {
956  $this->is_sticky = $a_sticky;
957  }
+ Here is the caller graph for this function:

◆ setSubject()

ilForumTopic::setSubject ( string  $a_subject)

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

Referenced by assignData().

894  : void
895  {
896  $this->subject = $a_subject;
897  }
+ Here is the caller graph for this function:

◆ setThrAuthorId()

ilForumTopic::setThrAuthorId ( int  $thr_author_id)

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

References $thr_author_id.

Referenced by assignData().

989  : void
990  {
991  $this->thr_author_id = $thr_author_id;
992  }
+ Here is the caller graph for this function:

◆ setUserAlias()

ilForumTopic::setUserAlias ( ?string  $a_user_alias)

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

Referenced by assignData().

884  : void
885  {
886  $this->user_alias = $a_user_alias;
887  }
+ Here is the caller graph for this function:

◆ setUserNotificationEnabled()

ilForumTopic::setUserNotificationEnabled ( bool  $status)

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

Referenced by assignData().

1055  : ilForumTopic
1056  {
1057  $this->user_notification_enabled = $status;
1058  return $this;
1059  }
+ Here is the caller graph for this function:

◆ setVisits()

ilForumTopic::setVisits ( int  $a_visits)

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

Referenced by assignData().

944  : void
945  {
946  $this->visits = $a_visits;
947  }
+ Here is the caller graph for this function:

◆ unmakeSticky()

ilForumTopic::unmakeSticky ( )

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

803  : bool
804  {
805  if ($this->id && $this->is_sticky) {
806  $this->db->manipulateF(
807  'UPDATE frm_threads SET is_sticky = %s WHERE thr_pk = %s',
808  ['integer', 'integer'],
809  [0, $this->id]
810  );
811 
812  $this->is_sticky = false;
813  return true;
814  }
815 
816  return false;
817  }

◆ update()

ilForumTopic::update ( )

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

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

◆ updateMergedThread()

ilForumTopic::updateMergedThread ( )

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

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

1097  : void
1098  {
1099  $this->db->update(
1100  'frm_threads',
1101  [
1102  'thr_num_posts' => ['integer', $this->getNumPosts()],
1103  'visits' => ['integer', $this->getVisits()],
1104  'thr_last_post' => ['text', $this->getLastPostString()],
1105  'thr_subject' => ['text', $this->getSubject()]
1106  ],
1107  ['thr_pk' => ['integer', $this->getId()]]
1108  );
1109  }
+ Here is the call graph for this function:

◆ updateThreadTitle()

ilForumTopic::updateThreadTitle ( )

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

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

1017  : void
1018  {
1019  $this->db->update(
1020  'frm_threads',
1021  ['thr_subject' => ['text', $this->getSubject()]],
1022  ['thr_pk' => ['integer', $this->getId()]]
1023  );
1024 
1025  try {
1026  $first_node = $this->getFirstVisiblePostNode();
1027  $first_node->setSubject($this->getSubject());
1028  $first_node->update();
1029  } catch (OutOfBoundsException) {
1030  }
1031  }
getFirstVisiblePostNode(bool $isModerator=false, bool $preventImplicitRead=false)
+ Here is the call graph for this function:

◆ updateVisits()

ilForumTopic::updateVisits ( )

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

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

241  : void
242  {
243  $checkTime = time() - (60 * 60);
244 
245  if (ilSession::get('frm_visit_frm_threads_' . $this->id) < $checkTime) {
246  ilSession::set('frm_visit_frm_threads_' . $this->id, time());
247 
248  $this->db->manipulateF(
249  'UPDATE frm_threads SET visits = visits + 1 WHERE thr_pk = %s',
250  ['integer'],
251  [$this->id]
252  );
253  }
254  }
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

Field Documentation

◆ $average_rating

float ilForumTopic::$average_rating = 0.0
private

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

Referenced by getAverageRating(), and setAverageRating().

◆ $changedate

string ilForumTopic::$changedate = null
private

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

Referenced by getChangeDate().

◆ $createdate

string ilForumTopic::$createdate = null
private

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

Referenced by getCreateDate().

◆ $db

ilDBInterface ilForumTopic::$db
private

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

◆ $display_user_id

int ilForumTopic::$display_user_id = 0
private

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

Referenced by getDisplayUserId().

◆ $forum_id

int ilForumTopic::$forum_id = 0
private

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

Referenced by getForumId().

◆ $frm_obj_id

int ilForumTopic::$frm_obj_id = 0
private

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

Referenced by getFrmObjId().

◆ $import_name

string ilForumTopic::$import_name = null
private

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

Referenced by getImportName().

◆ $is_closed

bool ilForumTopic::$is_closed = false
private

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

Referenced by isClosed().

◆ $is_sticky

bool ilForumTopic::$is_sticky = false
private

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

Referenced by isSticky().

◆ $last_post

ilForumPost ilForumTopic::$last_post = null
private

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

Referenced by getLastPostForThreadOverview().

◆ $last_post_string

string ilForumTopic::$last_post_string = null
private

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

Referenced by getLastPostString().

◆ $num_posts

int ilForumTopic::$num_posts = 0
private

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

Referenced by getNumPosts().

◆ $num_unread_posts

int ilForumTopic::$num_unread_posts = 0
private

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

Referenced by getNumUnreadPosts(), and setNumUnreadPosts().

◆ $orderDirection

string ilForumTopic::$orderDirection = 'DESC'
private

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

Referenced by getOrderDirection().

◆ $orderField

string ilForumTopic::$orderField = ''
private

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

Referenced by getOrderField().

◆ $possibleOrderDirections

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

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

◆ $subject

string ilForumTopic::$subject = ''
private

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

Referenced by getSubject().

◆ $thr_author_id

int ilForumTopic::$thr_author_id = 0
private

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

Referenced by getThrAuthorId(), and setThrAuthorId().

◆ $user

ilObjUser ilForumTopic::$user
private

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

◆ $user_alias

string ilForumTopic::$user_alias = null
private

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

Referenced by getUserAlias().

◆ $user_notification_enabled

bool ilForumTopic::$user_notification_enabled = false
private

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

Referenced by isUserNotificationEnabled().

◆ $visits

int ilForumTopic::$visits = 0
private

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

Referenced by getVisits().


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