ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 
 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)
 

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.

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

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:22
+ 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.

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

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

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

◆ countActivePosts()

ilForumTopic::countActivePosts ( bool  $ignoreRoot = false)

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

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

277  : int
278  {
279  $res = $this->db->queryF(
280  '
281  SELECT COUNT(*) cnt
282  FROM frm_posts
283  INNER JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
284  WHERE (pos_status = %s
285  OR (pos_status = %s AND pos_display_user_id = %s))
286  AND pos_thr_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
287  ['integer', 'integer', 'integer', 'integer'],
288  ['1', '0', $this->user->getId(), $this->id]
289  );
290 
291  $row = $this->db->fetchAssoc($res);
292  if (is_array($row)) {
293  return (int) $row['cnt'];
294  }
295 
296  return 0;
297  }
$res
Definition: ltiservices.php:66
$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 257 of file class.ilForumTopic.php.

References $res.

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

◆ disableNotification()

ilForumTopic::disableNotification ( int  $a_user_id)

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

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

◆ enableNotification()

ilForumTopic::enableNotification ( int  $a_user_id)

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

References isNotificationEnabled().

Referenced by ilForum\generateThread().

759  : void
760  {
761  if ($this->id && $a_user_id && !$this->isNotificationEnabled($a_user_id)) {
762  $nextId = $this->db->nextId('frm_notification');
763  $this->db->manipulateF(
764  '
765  INSERT INTO frm_notification
766  ( notification_id,
767  user_id,
768  thread_id
769  )
770  VALUES(%s, %s, %s)',
771  ['integer', 'integer', 'integer'],
772  [$nextId, $a_user_id, $this->id]
773  );
774  }
775  }
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 392 of file class.ilForumTopic.php.

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

Referenced by movePosts().

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

◆ getAverageRating()

ilForumTopic::getAverageRating ( )

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

References $average_rating.

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

◆ getChangeDate()

ilForumTopic::getChangeDate ( )

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

References $changedate.

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

◆ getCreateDate()

ilForumTopic::getCreateDate ( )

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

References $createdate.

Referenced by ilForum\generateThread().

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

◆ getDisplayUserId()

ilForumTopic::getDisplayUserId ( )

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

References $display_user_id.

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

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

◆ getFirstVisiblePostId()

ilForumTopic::getFirstVisiblePostId ( )

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

References $res, and null.

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

◆ getFirstVisiblePostNode()

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

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

References $post, and $res.

Referenced by updateThreadTitle().

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

◆ getForumId()

ilForumTopic::getForumId ( )

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

References $forum_id.

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

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

◆ getFrmObjId()

ilForumTopic::getFrmObjId ( )

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

References $frm_obj_id.

Referenced by getNestedSetPostChildren().

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

◆ getId()

ilForumTopic::getId ( )

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

References $id.

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

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

◆ getImportName()

ilForumTopic::getImportName ( )

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

References $import_name.

Referenced by ilObjForumGUI\getThreadProperties().

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

◆ getLastActivePost()

ilForumTopic::getLastActivePost ( )

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

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

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

◆ getLastPost()

ilForumTopic::getLastPost ( )

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

References $res, and null.

Referenced by ilObjForumGUI\getThreadProperties().

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

◆ getLastPostForThreadOverview()

ilForumTopic::getLastPostForThreadOverview ( )

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

References $last_post.

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

◆ getLastPostString()

ilForumTopic::getLastPostString ( )

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

References $last_post_string.

Referenced by updateMergedThread().

940  : ?string
941  {
943  }
+ Here is the caller graph for this function:

◆ getNestedSetPostChildren()

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

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

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

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

◆ getNumPosts()

ilForumTopic::getNumPosts ( )

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

References $num_posts.

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

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

◆ getNumUnreadPosts()

ilForumTopic::getNumUnreadPosts ( )

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

References $num_unread_posts.

Referenced by ilObjForumGUI\getThreadProperties().

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

◆ getOrderDirection()

ilForumTopic::getOrderDirection ( )

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

References $orderDirection.

Referenced by getPostTree().

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

◆ getOrderField()

ilForumTopic::getOrderField ( )

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

References $orderField.

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

◆ getPostRootId()

ilForumTopic::getPostRootId ( )

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

References $res, and null.

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  }
$res
Definition: ltiservices.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getPostRootNode()

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

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

References $post, and $res.

Referenced by ilObjForumGUI\toggleExplorerNodeStateObject().

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

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

◆ getSubject()

ilForumTopic::getSubject ( )

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

References $subject.

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

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

◆ getThrAuthorId()

ilForumTopic::getThrAuthorId ( )

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

References $thr_author_id.

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

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

◆ getUserAlias()

ilForumTopic::getUserAlias ( )

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

References $user_alias.

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

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

◆ getVisits()

ilForumTopic::getVisits ( )

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

References $visits.

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

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

◆ insert()

ilForumTopic::insert ( )

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

References null.

Referenced by ilForum\generateThread().

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ isClosed()

ilForumTopic::isClosed ( )

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

References $is_closed.

Referenced by ilObjForumGUI\getOpenCloseActionForThread().

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

◆ isNotificationEnabled()

ilForumTopic::isNotificationEnabled ( int  $a_user_id)

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

Referenced by enableNotification().

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

◆ isSticky()

ilForumTopic::isSticky ( )

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

References $is_sticky.

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

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

◆ isUserNotificationEnabled()

ilForumTopic::isUserNotificationEnabled ( )

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

References $user_notification_enabled.

1062  : bool
1063  {
1065  }
bool $user_notification_enabled

◆ lookupCreationDate()

static ilForumTopic::lookupCreationDate ( int  $thread_id)
static

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

References $DIC, $ilDB, $res, and null.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

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

◆ lookupForumIdByTopicId()

static ilForumTopic::lookupForumIdByTopicId ( int  $a_topic_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

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

◆ lookupTitle()

static ilForumTopic::lookupTitle ( int  $a_topic_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

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

◆ makeSticky()

ilForumTopic::makeSticky ( )

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

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

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

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

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

◆ read()

ilForumTopic::read ( )
private

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

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

Referenced by __construct(), and reload().

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  }
$res
Definition: ltiservices.php:66
+ 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.

References read().

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

◆ reopen()

ilForumTopic::reopen ( )

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

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

◆ setAverageRating()

ilForumTopic::setAverageRating ( float  $average_rating)

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

References $average_rating.

Referenced by assignData().

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

◆ setChangeDate()

ilForumTopic::setChangeDate ( ?string  $a_changedate)

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

Referenced by assignData().

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

◆ setClosed()

ilForumTopic::setClosed ( bool  $a_closed)

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

Referenced by assignData().

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

◆ setCreateDate()

ilForumTopic::setCreateDate ( ?string  $a_createdate)

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

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

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

◆ setDisplayUserId()

ilForumTopic::setDisplayUserId ( int  $a_user_id)

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

Referenced by assignData().

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

◆ setForumId()

ilForumTopic::setForumId ( int  $a_forum_id)

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

Referenced by assignData().

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

◆ setId()

ilForumTopic::setId ( int  $a_id)

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

Referenced by assignData().

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

◆ setImportName()

ilForumTopic::setImportName ( ?string  $a_import_name)

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

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

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

◆ setLastPostForThreadOverview()

ilForumTopic::setLastPostForThreadOverview ( ilForumPost  $post)

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

References $post.

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

◆ setLastPostString()

ilForumTopic::setLastPostString ( ?string  $a_last_post)

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

Referenced by assignData().

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

◆ setNumPosts()

ilForumTopic::setNumPosts ( int  $a_num_posts)

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

Referenced by assignData().

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

◆ setNumUnreadPosts()

ilForumTopic::setNumUnreadPosts ( int  $num_unread_posts)

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

References $num_unread_posts.

Referenced by assignData().

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

◆ setOrderDirection()

ilForumTopic::setOrderDirection ( string  $direction)

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

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

◆ setOrderField()

ilForumTopic::setOrderField ( string  $a_order_field)

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

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

◆ setSticky()

ilForumTopic::setSticky ( bool  $a_sticky)

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

Referenced by assignData().

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

◆ setSubject()

ilForumTopic::setSubject ( string  $a_subject)

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

Referenced by assignData().

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

◆ setThrAuthorId()

ilForumTopic::setThrAuthorId ( int  $thr_author_id)

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

References $thr_author_id.

Referenced by assignData().

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

◆ setUserAlias()

ilForumTopic::setUserAlias ( ?string  $a_user_alias)

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

Referenced by assignData().

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

◆ setUserNotificationEnabled()

ilForumTopic::setUserNotificationEnabled ( bool  $status)

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

Referenced by assignData().

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

◆ setVisits()

ilForumTopic::setVisits ( int  $a_visits)

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

Referenced by assignData().

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

◆ unmakeSticky()

ilForumTopic::unmakeSticky ( )

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

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

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

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

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

◆ updateThreadTitle()

ilForumTopic::updateThreadTitle ( )

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

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

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

◆ updateVisits()

ilForumTopic::updateVisits ( )

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

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

242  : void
243  {
244  $checkTime = time() - (60 * 60);
245 
246  if (ilSession::get('frm_visit_frm_threads_' . $this->id) < $checkTime) {
247  ilSession::set('frm_visit_frm_threads_' . $this->id, time());
248 
249  $this->db->manipulateF(
250  'UPDATE frm_threads SET visits = visits + 1 WHERE thr_pk = %s',
251  ['integer'],
252  [$this->id]
253  );
254  }
255  }
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 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: