ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilForumTopic Class Reference
+ Collaboration diagram for ilForumTopic:

Public Member Functions

 __construct ($a_id=0, $a_is_moderator=false, $preventImplicitRead=false)
 Constructor. More...
 
 assignData ($data)
 
 insert ()
 Inserts the object data into database. More...
 
 update ()
 Updates an existing topic. More...
 
 reload ()
 Calls the private method read() to load the topic data from database into the object. More...
 
 getFirstPostId ()
 Fetches the primary key of the first post node of the current topic from database and returns it. More...
 
 updateVisits ()
 Updates the visit counter of the current topic. More...
 
 countPosts ($ignoreRoot=false)
 Fetches and returns the number of posts for the given user id. More...
 
 countActivePosts ($ignoreRoot=false)
 Fetches and returns the number of active posts for the given user id. More...
 
 getFirstPostNode ($isModerator=false, $preventImplicitRead=false)
 Fetches and returns an object of the first post in the current topic. More...
 
 getLastPost ()
 Fetches and returns an object of the last post in the current topic. More...
 
 getLastActivePost ()
 Fetches and returns an object of the last active post in the current topic. More...
 
 getAllPosts ()
 
 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 ($old_obj_id, $old_pk, $new_obj_id, $new_pk)
 Moves all posts within the current thread to a new forum. More...
 
 getNestedSetPostChildren ($pos_id=null, $levels=null)
 
 isNotificationEnabled ($a_user_id)
 Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (result == 0). More...
 
 enableNotification ($a_user_id)
 Enable a user's notification about new posts in a thread. More...
 
 disableNotification ($a_user_id)
 Disable a user's notification about new posts in a thread. More...
 
 makeSticky ()
 Sets the current topic sticky. More...
 
 unmakeSticky ()
 Sets the current topic non-sticky. More...
 
 close ()
 Closes the current topic. More...
 
 reopen ()
 Reopens the current topic. More...
 
 getAverageRating ()
 
 setAverageRating ($average_rating)
 
 setId ($a_id)
 
 getId ()
 
 setForumId ($a_forum_id)
 
 getForumId ()
 
 setDisplayUserId ($a_user_id)
 
 getDisplayUserId ()
 
 setUserAlias ($a_user_alias)
 
 getUserAlias ()
 
 setSubject ($a_subject)
 
 getSubject ()
 
 setCreateDate ($a_createdate)
 
 getCreateDate ()
 
 setChangeDate ($a_changedate)
 
 getChangeDate ()
 
 setImportName ($a_import_name)
 
 getImportName ()
 
 setLastPostString ($a_last_post)
 
 getLastPostString ()
 
 setVisits ($a_visits)
 
 getVisits ()
 
 setSticky ($a_sticky)
 
 isSticky ()
 
 setClosed ($a_closed)
 
 isClosed ()
 
 setOrderField ($a_order_field)
 
 getOrderField ()
 
 setModeratorRight ($bool)
 
 getModeratorRight ()
 
 getFrmObjId ()
 
 setThrAuthorId ($thr_author_id)
 
 getThrAuthorId ()
 
 updateThreadTitle ()
 
 setNumPosts ($a_num_posts)
 
 getNumPosts ()
 
 setNumNewPosts ($num_new_posts)
 
 getNumNewPosts ()
 
 setNumUnreadPosts ($num_unread_posts)
 
 getNumUnreadPosts ()
 
 setUserNotificationEnabled ($user_notification_enabled)
 
 getUserNotificationEnabled ()
 
 setOrderDirection ($direction)
 
 getOrderDirection ()
 
 getSorting ()
 
 updateMergedThread ()
 
 getLastPostForThreadOverview ()
 
 setLastPostForThreadOverview (ilForumPost $post)
 

Static Public Member Functions

static _lookupTitle ($a_topic_id)
 Looks up the title/subject of a topic/thread. More...
 
static lookupForumIdByTopicId ($a_topic_id)
 
static _lookupDate ($thread_id)
 

Static Protected Attributes

static $possibleOrderDirections = array('ASC', 'DESC')
 

Private Member Functions

 read ()
 Reads the data of the current object id from database and loads it into the object. More...
 

Private Attributes

 $id = 0
 
 $forum_id = 0
 
 $frm_obj_id = 0
 
 $display_user_id = 0
 
 $user_alias = ''
 
 $subject = ''
 
 $createdate = null
 
 $changedate = null
 
 $num_posts = 0
 
 $last_post_string = ''
 
 $visits = 0
 
 $import_name = ''
 
 $is_sticky = 0
 
 $is_closed = 0
 
 $orderField = ''
 
 $last_post = null
 
 $db = null
 
 $is_moderator = false
 
 $thr_author_id = 0
 
 $average_rating = 0
 
 $orderDirection = 'DESC'
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id:$

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

Constructor & Destructor Documentation

◆ __construct()

ilForumTopic::__construct (   $a_id = 0,
  $a_is_moderator = false,
  $preventImplicitRead = false 
)

Constructor.

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
integer$a_idprimary key of a forum topic (optional)
bool$a_is_moderatormoderator-status of the current user (optional)
bool$preventImplicitReadPrevents the implicit database query if an id was passed

public

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

References $DIC, read(), and user().

73  {
74  global $DIC;
75 
76  $this->is_moderator = $a_is_moderator;
77  $this->db = $DIC->database();
78  $this->user = $DIC->user();
79  $this->id = $a_id;
80 
81  if (!$preventImplicitRead) {
82  $this->read();
83  }
84  }
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24
read()
Reads the data of the current object id from database and loads it into the object.
+ Here is the call graph for this function:

Member Function Documentation

◆ _lookupDate()

static ilForumTopic::_lookupDate (   $thread_id)
static
Parameters
integer$thread_id
Returns
string datetime

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

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1305  {
1306  global $DIC;
1307  $ilDB = $DIC->database();
1308 
1309  $res = $ilDB->queryF(
1310  'SELECT thr_date FROM frm_threads WHERE thr_pk = %s',
1311  array('integer'),
1312  array((int) $thread_id)
1313  );
1314 
1315  $row = $ilDB->fetchAssoc($res);
1316 
1317  return $row['thr_date'] ? $row['thr_date'] : '0000-00-00 00:00:00';
1318  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilForumTopic::_lookupTitle (   $a_topic_id)
static

Looks up the title/subject of a topic/thread.

Parameters
integerid of the topic/thread
Returns
string title/subject of the topic/thread public

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

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1145  {
1146  global $DIC;
1147  $ilDB = $DIC->database();
1148 
1149  $res = $ilDB->queryf(
1150  '
1151  SELECT thr_subject
1152  FROM frm_threads
1153  WHERE thr_pk = %s',
1154  array('integer'),
1155  array($a_topic_id)
1156  );
1157  $row = $ilDB->fetchObject($res);
1158 
1159  if (is_object($row)) {
1160  return $row->thr_subject;
1161  }
1162 
1163  return '';
1164  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ assignData()

ilForumTopic::assignData (   $data)
Parameters
$data

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

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

90  {
91  $this->setId((int) $data['thr_pk']);
92  $this->setForumId((int) $data['thr_top_fk']);
93  $this->setSubject($data['thr_subject']);
94  $this->setDisplayUserId((int) $data['thr_display_user_id']);
95  $this->setUserAlias($data['thr_usr_alias']);
96  $this->setLastPostString($data['last_post_string']);
97  $this->setCreateDate($data['thr_date']);
98  $this->setChangeDate($data['thr_update']);
99  $this->setVisits((int) $data['visits']);
100  $this->setImportName($data['import_name']);
101  $this->setSticky((int) $data['is_sticky']);
102  $this->setClosed((int) $data['is_closed']);
103  $this->setAverageRating($data['avg_rating']);
104  $this->setThrAuthorId($data['thr_author_id']);
105 
106  // Aggregated values
107  $this->setNumPosts((int) $data['num_posts']);
108  $this->setNumUnreadPosts((int) $data['num_unread_posts']);
109  $this->setNumNewPosts((int) $data['num_new_posts']);
110  $this->setUserNotificationEnabled((bool) $data['usr_notification_is_enabled']);
111  }
setSubject($a_subject)
$data
Definition: storeScorm.php:23
setUserNotificationEnabled($user_notification_enabled)
setForumId($a_forum_id)
setAverageRating($average_rating)
setNumNewPosts($num_new_posts)
setNumUnreadPosts($num_unread_posts)
setCreateDate($a_createdate)
setThrAuthorId($thr_author_id)
setDisplayUserId($a_user_id)
setLastPostString($a_last_post)
setChangeDate($a_changedate)
setUserAlias($a_user_alias)
setNumPosts($a_num_posts)
setImportName($a_import_name)
+ Here is the call graph for this function:

◆ close()

ilForumTopic::close ( )

Closes the current topic.

Returns
bool true in case of success, false in case of failure public

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

934  {
935  if ($this->id && !$this->is_closed) {
936  $this->db->manipulateF(
937  '
938  UPDATE frm_threads
939  SET is_closed = %s
940  WHERE thr_pk = %s',
941  array('integer', 'integer'),
942  array('1', $this->id)
943  );
944 
945  $this->is_closed = 1;
946 
947  return true;
948  }
949 
950  return false;
951  }

◆ countActivePosts()

ilForumTopic::countActivePosts (   $ignoreRoot = false)

Fetches and returns the number of active posts for the given user id.

Parameters
bool$ignoreRoot
Returns
integer number of active posts public

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

References $id, $res, ilDBConstants\FETCHMODE_ASSOC, and user().

331  {
332  $res = $this->db->queryf(
333  '
334  SELECT COUNT(*) cnt
335  FROM frm_posts
336  INNER JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
337  WHERE (pos_status = %s
338  OR (pos_status = %s AND pos_display_user_id = %s))
339  AND pos_thr_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
340  array('integer', 'integer', 'integer', 'integer'),
341  array('1', '0', $this->user->getId(), $this->id)
342  );
343 
344  $rec = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
345 
346  return $rec['cnt'];
347  }
user()
Definition: user.php:4
foreach($_POST as $key=> $value) $res
+ Here is the call graph for this function:

◆ countPosts()

ilForumTopic::countPosts (   $ignoreRoot = false)

Fetches and returns the number of posts for the given user id.

Parameters
integer$a_user_iduser id
Returns
integer number of posts public

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

References $res, and ilDBConstants\FETCHMODE_ASSOC.

307  {
308  $res = $this->db->queryf(
309  '
310  SELECT COUNT(*) cnt
311  FROM frm_posts
312  INNER JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
313  WHERE pos_thr_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
314  array('integer'),
315  array($this->id)
316  );
317 
318  $rec = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
319 
320  return $rec['cnt'];
321  }
foreach($_POST as $key=> $value) $res

◆ disableNotification()

ilForumTopic::disableNotification (   $a_user_id)

Disable a user's notification about new posts in a thread.

Parameters
integer$a_user_idid of an user
Returns
bool true in case of success, false in case of failure public

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

858  {
859  if ($this->id && $a_user_id) {
860  $this->db->manipulateF(
861  '
862  DELETE FROM frm_notification
863  WHERE user_id = %s
864  AND thread_id = %s',
865  array('integer', 'integer'),
866  array($a_user_id, $this->id)
867  );
868 
869  return false;
870  }
871 
872  return false;
873  }

◆ enableNotification()

ilForumTopic::enableNotification (   $a_user_id)

Enable a user's notification about new posts in a thread.

Parameters
integer$a_user_idid of an user
Returns
bool true in case of success, false in case of failure public

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

References isNotificationEnabled().

Referenced by ilForum\generateThread().

827  {
828  if ($this->id && $a_user_id) {
829  if (!$this->isNotificationEnabled($a_user_id)) {
830  $nextId = $this->db->nextId('frm_notification');
831  $this->db->manipulateF(
832  '
833  INSERT INTO frm_notification
834  ( notification_id,
835  user_id,
836  thread_id
837  )
838  VALUES(%s, %s, %s)',
839  array('integer', 'integer', 'integer'),
840  array($nextId, $a_user_id, $this->id)
841  );
842 
843  return true;
844  }
845  return false;
846  }
847 
848  return false;
849  }
isNotificationEnabled($a_user_id)
Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (resul...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllPosts()

ilForumTopic::getAllPosts ( )

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

References $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by movePosts().

435  {
436  $posts = array();
437 
438  if ($this->id) {
439  $res = $this->db->queryf(
440  '
441  SELECT pos_pk
442  FROM frm_posts
443  WHERE pos_thr_fk = %s',
444  array('integer'),
445  array($this->id)
446  );
447 
448  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
449  $posts[$row->pos_pk] = $row;
450  }
451  }
452 
453  return is_array($posts) ? $posts : array();
454  }
foreach($_POST as $key=> $value) $res
+ Here is the caller graph for this function:

◆ getAverageRating()

ilForumTopic::getAverageRating ( )
Returns
int

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

References $average_rating.

983  {
984  return $this->average_rating;
985  }

◆ getChangeDate()

ilForumTopic::getChangeDate ( )

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

References $changedate.

1052  {
1053  return $this->changedate;
1054  }

◆ getCreateDate()

ilForumTopic::getCreateDate ( )

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

References $createdate.

Referenced by ilForum\generateThread().

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

◆ getDisplayUserId()

ilForumTopic::getDisplayUserId ( )

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

References $display_user_id.

Referenced by ilForum\generateThread().

1016  {
1017  return $this->display_user_id;
1018  }
+ Here is the caller graph for this function:

◆ getFirstPostId()

ilForumTopic::getFirstPostId ( )

Fetches the primary key of the first post node of the current topic from database and returns it.

Returns
integer primary key of the first post node public

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

References $res, and ilDBConstants\FETCHMODE_OBJECT.

256  {
257  $this->db->setLimit(1);
258  $res = $this->db->queryf(
259  '
260  SELECT * FROM frm_posts_tree
261  WHERE thr_fk = %s
262  AND parent_pos != %s
263  AND depth = %s
264  ORDER BY rgt DESC',
265  array('integer', 'integer', 'integer'),
266  array($this->id, '0', 2)
267  );
268 
269  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
270 
271  return $row->pos_fk ? $row->pos_fk : 0;
272  }
foreach($_POST as $key=> $value) $res

◆ getFirstPostNode()

ilForumTopic::getFirstPostNode (   $isModerator = false,
  $preventImplicitRead = false 
)

Fetches and returns an object of the first post in the current topic.

Parameters
bool$isModerator
bool$preventImplicitRead
Returns
ilForumPost object of a post

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

References $res.

Referenced by updateThreadTitle().

356  {
357  $res = $this->db->queryF(
358  '
359  SELECT *
360  FROM frm_posts
361  INNER JOIN frm_posts_tree ON pos_fk = pos_pk
362  WHERE parent_pos = %s
363  AND thr_fk = %s',
364  array('integer', 'integer'),
365  array(0, $this->id)
366  );
367 
368  $row = $this->db->fetchAssoc($res);
369 
370  $post = new ilForumPost($row['pos_pk'], $isModerator, $preventImplicitRead);
371  $post->assignData($row);
372 
373  return $post;
374  }
foreach($_POST as $key=> $value) $res
+ Here is the caller graph for this function:

◆ getForumId()

ilForumTopic::getForumId ( )

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

References $forum_id.

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

1008  {
1009  return $this->forum_id;
1010  }
+ Here is the caller graph for this function:

◆ getFrmObjId()

ilForumTopic::getFrmObjId ( )

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

References $frm_obj_id.

Referenced by getNestedSetPostChildren().

1116  {
1117  return $this->frm_obj_id;
1118  }
+ Here is the caller graph for this function:

◆ getId()

ilForumTopic::getId ( )

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

References $id.

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

1000  {
1001  return $this->id;
1002  }
+ Here is the caller graph for this function:

◆ getImportName()

ilForumTopic::getImportName ( )

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

References $import_name.

1060  {
1061  return $this->import_name;
1062  }

◆ getLastActivePost()

ilForumTopic::getLastActivePost ( )

Fetches and returns an object of the last active post in the current topic.

Returns
ilForumPost object of the last active post public

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

References $res, ilDBConstants\FETCHMODE_OBJECT, and user().

411  {
412  if ($this->id) {
413  $this->db->setLimit(1);
414  $res = $this->db->queryf(
415  '
416  SELECT pos_pk
417  FROM frm_posts
418  WHERE pos_thr_fk = %s
419  AND (pos_status = %s OR
420  (pos_status = %s AND pos_display_user_id = %s))
421  ORDER BY pos_date DESC',
422  array('integer', 'integer', 'integer', 'integer'),
423  array($this->id, '1', '0', $this->user->getId())
424  );
425 
426  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
427 
428  return new ilForumPost($row->pos_pk);
429  }
430 
431  return false;
432  }
user()
Definition: user.php:4
foreach($_POST as $key=> $value) $res
+ Here is the call graph for this function:

◆ getLastPost()

ilForumTopic::getLastPost ( )

Fetches and returns an object of the last post in the current topic.

Returns
ilForumPost object of the last post public

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

References $res, and ilDBConstants\FETCHMODE_OBJECT.

383  {
384  if ($this->id) {
385  $this->db->setLimit(1);
386  $res = $this->db->queryf(
387  '
388  SELECT pos_pk
389  FROM frm_posts
390  WHERE pos_thr_fk = %s
391  ORDER BY pos_date DESC',
392  array('integer'),
393  array($this->id)
394  );
395 
396  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
397 
398  return new ilForumPost($row->pos_pk);
399  }
400 
401  return false;
402  }
foreach($_POST as $key=> $value) $res

◆ getLastPostForThreadOverview()

ilForumTopic::getLastPostForThreadOverview ( )
Returns
ilForumPost|null

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

References $last_post.

1324  {
1325  return $this->last_post;
1326  }

◆ getLastPostString()

ilForumTopic::getLastPostString ( )

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

References $last_post_string.

Referenced by updateMergedThread().

1072  {
1073  return $this->last_post_string;
1074  }
+ Here is the caller graph for this function:

◆ getModeratorRight()

ilForumTopic::getModeratorRight ( )

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

References $is_moderator.

1112  {
1113  return $this->is_moderator;
1114  }

◆ getNestedSetPostChildren()

ilForumTopic::getNestedSetPostChildren (   $pos_id = null,
  $levels = null 
)

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

References $data, $i, $query, $res, ANONYMOUS_USER_ID, getFrmObjId(), ilForumProperties\getInstance(), ilForumAuthorInformationCache\preloadUserObjects(), and user().

662  {
663  $data = null;
664  $objProperties = ilForumProperties::getInstance($this->getFrmObjId());
665  $is_post_activation_enabled = $objProperties->isPostActivationEnabled();
666 
667  if ($pos_id !== null) {
668  $res = $this->db->queryF(
669  "
670  SELECT lft, rgt, depth
671  FROM frm_posts_tree
672  WHERE pos_fk = %s
673  AND thr_fk = %s",
674  array('integer', 'integer'),
675  array($pos_id, $this->id)
676  );
677 
678  $data = $this->db->fetchAssoc($res);
679  }
680 
681  $query = '
682  SELECT fpt.depth,
683  fpt.rgt,
684  fpt.parent_pos,
685  fp.pos_pk,
686  fp.pos_subject,
687  fp.pos_usr_alias,
688  fp.pos_date,
689  fp.pos_update,
690  fp.pos_status,
691  fp.pos_display_user_id,
692  fp.pos_usr_alias,
693  fp.import_name,
694  fp.pos_author_id,
695  fp.is_author_moderator,
696  fur.post_id,
697  (CASE
698  WHEN fur.post_id IS NULL ' .
699  ($this->user->getId() == ANONYMOUS_USER_ID ? ' AND 1 = 2 ' : '') . '
700  THEN 0
701  ELSE 1
702  END) post_read,
703  COUNT(fpt2.pos_fk) children
704 
705  FROM frm_posts_tree fpt
706 
707  INNER JOIN frm_posts fp
708  ON fp.pos_pk = fpt.pos_fk
709 
710  LEFT JOIN frm_posts_tree fpt2
711  ON fpt2.lft BETWEEN fpt.lft AND fpt.rgt
712  AND fpt.thr_fk = fpt2.thr_fk
713  AND fpt.pos_fk != fpt2.pos_fk ';
714 
715 
716  $query .= '
717  LEFT JOIN frm_user_read fur
718  ON fur.thread_id = fp.pos_thr_fk
719  AND fur.post_id = fp.pos_pk
720  AND fur.usr_id = ' . $this->db->quote($this->user->getId(), 'integer') . '
721 
722  LEFT JOIN usr_data ud
723  ON ud.usr_id = fp.pos_display_user_id
724 
725  WHERE fpt.thr_fk = ' . $this->db->quote($this->id, 'integer');
726 
727  if ($data) {
728  $query .= ' AND fpt.lft > ' . $this->db->quote($data['lft'], 'integer') .
729  ' AND fpt.lft < ' . $this->db->quote($data['rgt'], 'integer') . ' ';
730  }
731  if ($is_post_activation_enabled && !$this->is_moderator) {
732  $query .= ' AND (fp.pos_status = 1 OR fp.pos_status = 0 AND fp.pos_display_user_id = ' . $this->db->quote($this->user->getId(), 'integer') . ') ';
733  }
734 
735  if ($data && is_numeric($levels)) {
736  $query .= ' AND fpt.depth <= ' . $this->db->quote($data['depth'] + $levels, 'integer') . ' ';
737  }
738 
739  $query .= ' GROUP BY fpt.depth,
740  fpt.rgt,
741  fpt.parent_pos,
742  fp.pos_pk,
743  fp.pos_subject,
744  fp.pos_usr_alias,
745  fp.pos_date,
746  fp.pos_update,
747  fp.pos_status,
748  fp.pos_display_user_id,
749  fp.pos_usr_alias,
750  fp.import_name,
751  fp.pos_author_id,
752  fp.is_author_moderator,
753  fur.post_id
754  ORDER BY fpt.rgt DESC
755  ';
756 
757  $queryCounter = '
758  SELECT pos_fk
759  FROM frm_posts_tree fpt
760  INNER JOIN frm_posts fp
761  ON fp.pos_pk = fpt.pos_fk
762  WHERE fpt.thr_fk = ' . $this->db->quote($this->id, 'integer');
763 
764  if ($is_post_activation_enabled && !$this->is_moderator) {
765  $queryCounter .= ' AND (fp.pos_status = 1 OR fp.pos_status = 0 AND fp.pos_display_user_id = ' . $this->db->quote($this->user->getId(), 'integer') . ') ';
766  }
767  $queryCounter .= ' ORDER BY fpt.rgt DESC';
768 
769  $resCounter = $this->db->query($queryCounter);
770  $counter = array();
771  $i = 0;
772  while ($row = $this->db->fetchAssoc($resCounter)) {
773  $counter[$row['pos_fk']] = $i++;
774  }
775 
776  $res = $this->db->query($query);
777  $children = array();
778  $usr_ids = array();
779  while ($row = $this->db->fetchAssoc($res)) {
780  if ((int) $row['pos_display_user_id']) {
781  $usr_ids[] = (int) $row['pos_display_user_id'];
782  }
783 
784  $row['counter'] = $counter[$row['pos_pk']];
785  $children[] = $row;
786  }
787 
789 
790  return $children;
791  }
$data
Definition: storeScorm.php:23
const ANONYMOUS_USER_ID
Definition: constants.php:25
user()
Definition: user.php:4
static getInstance($a_obj_id=0)
foreach($_POST as $key=> $value) $res
$query
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ getNumNewPosts()

ilForumTopic::getNumNewPosts ( )
Returns
int

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

1211  {
1212  return $this->num_new_posts;
1213  }

◆ getNumPosts()

ilForumTopic::getNumPosts ( )
Returns
int

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

References $num_posts.

Referenced by updateMergedThread().

1193  {
1194  return $this->num_posts;
1195  }
+ Here is the caller graph for this function:

◆ getNumUnreadPosts()

ilForumTopic::getNumUnreadPosts ( )
Returns
int

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

1229  {
1230  return $this->num_unread_posts;
1231  }

◆ getOrderDirection()

ilForumTopic::getOrderDirection ( )

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

References $orderDirection.

Referenced by getPostTree().

1262  {
1263  return $this->orderDirection;
1264  }
+ Here is the caller graph for this function:

◆ getOrderField()

ilForumTopic::getOrderField ( )

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

References $orderField.

1104  {
1105  return $this->orderField;
1106  }

◆ 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
array array of post objects public

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

References $data, $query, $res, ANONYMOUS_USER_ID, ilForumPost\getLft(), getOrderDirection(), ilForumPost\getRgt(), ilForumPost\getThreadId(), ilForumAuthorInformationCache\preloadUserObjects(), and user().

465  {
466  $posts = array();
467 
468  $data = array();
469  $data_types = array();
470 
471  $query = '
472  SELECT is_author_moderator, pos_author_id, pos_pk, fpt_date, rgt, pos_top_fk, pos_thr_fk,
473  pos_display_user_id, pos_usr_alias, pos_subject,
474  pos_status, pos_message, pos_date, pos_update,
475  update_user, pos_cens, pos_cens_com, notify,
476  import_name, fpt_pk, parent_pos, lft, depth,
477  (CASE
478  WHEN fur.post_id IS NULL ' .
479  ($this->user->getId() == ANONYMOUS_USER_ID ? ' AND 1 = 2 ' : '') . '
480  THEN 0
481  ELSE 1
482  END) post_read,
483  firstname, lastname, title, login
484 
485  FROM frm_posts_tree
486 
487  INNER JOIN frm_posts
488  ON pos_fk = pos_pk
489 
490  LEFT JOIN usr_data
491  ON pos_display_user_id = usr_id
492 
493  LEFT JOIN frm_user_read fur
494  ON fur.thread_id = pos_thr_fk
495  AND fur.post_id = pos_pk
496  AND fur.usr_id = %s
497 
498  WHERE lft > %s AND lft < %s
499  AND thr_fk = %s';
500 
501  array_push($data_types, 'integer', 'integer', 'integer', 'integer');
502  array_push($data, $this->user->getId(), $a_post_node->getLft(), $a_post_node->getRgt(), $a_post_node->getThreadId());
503 
504  if ($this->orderField != "") {
505  $query .= " ORDER BY " . $this->orderField . " " . $this->getOrderDirection();
506  }
507 
508  $res = $this->db->queryF($query, $data_types, $data);
509 
510  $usr_ids = [];
511  while ($row = $this->db->fetchAssoc($res)) {
512  $post = new ilForumPost($row['pos_pk'], false, true);
513  $post->assignData($row);
514 
515  if (!$this->is_moderator) {
516  if (!$post->isActivated() && $post->getPosAuthorId() != $this->user->getId()) {
517  continue;
518  }
519  }
520 
521  if ((int) $row['pos_display_user_id']) {
522  $usr_ids[(int) $row['pos_display_user_id']] = (int) $row['pos_display_user_id'];
523  }
524  if ((int) $row['update_user']) {
525  $usr_ids[(int) $row['update_user']] = (int) $row['update_user'];
526  }
527 
528  $posts[] = $post;
529  }
530 
532 
533  return $posts;
534  }
$data
Definition: storeScorm.php:23
const ANONYMOUS_USER_ID
Definition: constants.php:25
user()
Definition: user.php:4
foreach($_POST as $key=> $value) $res
$query
+ Here is the call graph for this function:

◆ getSorting()

ilForumTopic::getSorting ( )

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

1283  {
1284  return $this->thread_sorting;
1285  }

◆ getSubject()

ilForumTopic::getSubject ( )

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

References $subject.

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

1032  {
1033  return $this->subject;
1034  }
+ Here is the caller graph for this function:

◆ getThrAuthorId()

ilForumTopic::getThrAuthorId ( )
Returns
int

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

References $thr_author_id.

Referenced by ilForum\generateThread().

1132  {
1133  return $this->thr_author_id;
1134  }
+ Here is the caller graph for this function:

◆ getUserAlias()

ilForumTopic::getUserAlias ( )

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

References $user_alias.

Referenced by ilForum\generateThread().

1024  {
1025  return $this->user_alias;
1026  }
+ Here is the caller graph for this function:

◆ getUserNotificationEnabled()

ilForumTopic::getUserNotificationEnabled ( )
Returns
boolean

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

1247  {
1248  return $this->user_notification_enabled;
1249  }

◆ getVisits()

ilForumTopic::getVisits ( )

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

References $visits.

Referenced by updateMergedThread().

1080  {
1081  return $this->visits;
1082  }
+ Here is the caller graph for this function:

◆ insert()

ilForumTopic::insert ( )

Inserts the object data into database.

Returns
bool true in case of success, false in case of failure public

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

Referenced by ilForum\generateThread().

120  {
121  if ($this->forum_id) {
122  $nextId = $this->db->nextId('frm_threads');
123 
124  $this->db->insert(
125  'frm_threads',
126  array(
127  'thr_pk' => array('integer', $nextId),
128  'thr_top_fk' => array('integer', $this->forum_id),
129  'thr_subject' => array('text', $this->subject),
130  'thr_display_user_id' => array('integer', $this->display_user_id),
131  'thr_usr_alias' => array('text', $this->user_alias),
132  'thr_num_posts' => array('integer', $this->num_posts),
133  'thr_last_post' => array('text', $this->last_post_string),
134  'thr_date' => array('timestamp', $this->createdate),
135  'thr_update' => array('timestamp', null),
136  'import_name' => array('text', $this->import_name),
137  'is_sticky' => array('integer', $this->is_sticky),
138  'is_closed' => array('integer', $this->is_closed),
139  'avg_rating' => array('float', $this->average_rating),
140  'thr_author_id' => array('integer', $this->thr_author_id)
141  )
142  );
143 
144  $this->id = $nextId;
145 
146  return true;
147  }
148 
149  return false;
150  }
+ Here is the caller graph for this function:

◆ isClosed()

ilForumTopic::isClosed ( )

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

1096  {
1097  return $this->is_closed == 1 ? true : false;
1098  }

◆ isNotificationEnabled()

ilForumTopic::isNotificationEnabled (   $a_user_id)

Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (result == 0).

Parameters
integer$a_user_idid of an user
Returns
bool true in case of success, false in case of failure public

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

References $result.

Referenced by enableNotification().

800  {
801  if ($this->id && $a_user_id) {
802  $result = $this->db->queryf(
803  '
804  SELECT COUNT(notification_id) cnt FROM frm_notification
805  WHERE user_id = %s AND thread_id = %s',
806  array('integer', 'integer'),
807  array($a_user_id, $this->id)
808  );
809 
810  while ($record = $this->db->fetchAssoc($result)) {
811  return (bool) $record['cnt'];
812  }
813 
814  return false;
815  }
816 
817  return false;
818  }
$result
+ Here is the caller graph for this function:

◆ isSticky()

ilForumTopic::isSticky ( )

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

1088  {
1089  return $this->is_sticky == 1 ? true : false;
1090  }

◆ lookupForumIdByTopicId()

static ilForumTopic::lookupForumIdByTopicId (   $a_topic_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1267  {
1268  global $DIC;
1269  $ilDB = $DIC->database();
1270 
1271  $res = $ilDB->queryF(
1272  'SELECT thr_top_fk FROM frm_threads WHERE thr_pk = %s',
1273  array('integer'),
1274  array($a_topic_id)
1275  );
1276 
1277  $row = $ilDB->fetchAssoc($res);
1278 
1279  return $row['thr_top_fk'];
1280  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ makeSticky()

ilForumTopic::makeSticky ( )

Sets the current topic sticky.

Returns
bool true in case of success, false in case of failure public

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

882  {
883  if ($this->id && !$this->is_sticky) {
884  $this->db->manipulateF(
885  '
886  UPDATE frm_threads
887  SET is_sticky = %s
888  WHERE thr_pk = %s',
889  array('integer', 'integer'),
890  array('1', $this->id)
891  );
892 
893  $this->is_sticky = 1;
894 
895  return true;
896  }
897 
898  return false;
899  }

◆ movePosts()

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

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

Parameters
integer$old_obj_idobject id of the current forum
integer$old_pkprimary key of old forum
integer$new_obj_idobject id of the new forum
integer$new_pkprimary key of new forum
Returns
integer number of afffected rows by updating posts public

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

References $id, $ilDB, ilForum\_lookupObjIdForForumId(), ilDBConstants\FETCHMODE_ASSOC, getAllPosts(), ilNewsItem\getFirstNewsIdForContext(), and ilDBInterface\manipulateF().

547  {
548  if ($this->id) {
549  $nodes = $this->getAllPosts();
550  if (is_array($nodes)) {
551  $postsMoved = array();
552  // Move attachments
553  try {
554  foreach ($nodes as $node) {
555  $file_obj = new ilFileDataForum((int) $old_obj_id, (int) $node->pos_pk);
556  $moved = $file_obj->moveFilesOfPost((int) $new_obj_id);
557 
558  if (true === $moved) {
559  $postsMoved[] = array(
560  'from' => $old_obj_id,
561  'to' => $new_obj_id,
562  'position_id' => (int) $node->pos_pk
563  );
564  }
565 
566  unset($file_obj);
567  }
568  } catch (\ilFileUtilsException $exception) {
569  foreach ($postsMoved as $postedInformation) {
570  $file_obj = new ilFileDataForum($postedInformation['to'], $postedInformation['position_id']);
571  $file_obj->moveFilesOfPost($postedInformation['from']);
572  }
573 
574  throw $exception;
575  }
576  }
577 
578  $current_id = $this->id;
579 
580  $ilAtomQuery = $this->db->buildAtomQuery();
581  $ilAtomQuery->addTableLock('frm_user_read');
582  $ilAtomQuery->addTableLock('frm_thread_access');
583 
584  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) use ($new_obj_id, $current_id) {
585  $ilDB->manipulateF(
586  '
587  DELETE FROM frm_user_read
588  WHERE obj_id = %s AND thread_id =%s',
589  array('integer', 'integer'),
590  array($new_obj_id, $current_id)
591  );
592 
593  $ilDB->manipulateF(
594  '
595  UPDATE frm_user_read
596  SET obj_id = %s
597  WHERE thread_id = %s',
598  array('integer', 'integer'),
599  array($new_obj_id, $current_id)
600  );
601 
602  $ilDB->manipulateF(
603  '
604  DELETE FROM frm_thread_access
605  WHERE obj_id = %s AND thread_id =%s',
606  array('integer', 'integer'),
607  array($new_obj_id, $current_id)
608  );
609 
610  $ilDB->manipulateF(
611  '
612  UPDATE frm_thread_access
613  SET obj_id = %s
614  WHERE thread_id =%s',
615  array('integer', 'integer'),
616  array($new_obj_id, $current_id)
617  );
618  });
619 
620  $ilAtomQuery->run();
621 
622  $this->db->manipulateF(
623  '
624  UPDATE frm_posts
625  SET pos_top_fk = %s
626  WHERE pos_thr_fk = %s',
627  array('integer', 'integer'),
628  array($new_pk, $this->id)
629  );
630 
631  // update all related news
632  $posts = $this->db->queryf(
633  '
634  SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
635  array('integer'),
636  array($this->id)
637  );
638 
639  $old_obj_id = ilForum::_lookupObjIdForForumId($old_pk);
640 
641  $new_obj_id = ilForum::_lookupObjIdForForumId($new_pk);
642 
643  while ($post = $posts->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
645  $old_obj_id,
646  "frm",
647  $post["pos_pk"],
648  "pos"
649  );
650  $news_item = new ilNewsItem($news_id);
651  $news_item->setContextObjId($new_obj_id);
652  $news_item->update();
653  }
654 
655  return count($nodes);
656  }
657 
658  return 0;
659  }
static _lookupObjIdForForumId($a_for_id)
static getFirstNewsIdForContext( $a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
This class handles all operations on files for the forum object.
global $ilDB
manipulateF($query, $types, $values)
Class to report exception.
+ Here is the call graph for this function:

◆ read()

ilForumTopic::read ( )
private

Reads the data of the current object id from database and loads it into the object.

Returns
bool true in case of success, false in case of failure

private

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

References $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct(), and reload().

197  {
198  if ($this->id) {
199  $res = $this->db->queryf(
200  '
201  SELECT frm_threads.*, top_frm_fk frm_obj_id
202  FROM frm_threads
203  INNER JOIN frm_data ON top_pk = thr_top_fk
204  WHERE thr_pk = %s',
205  array('integer'),
206  array($this->id)
207  );
208 
209  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
210 
211  if (is_object($row)) {
212  $this->thr_pk = $row->pos_pk; // thr_pk = pos_pk ??!??!
213  $this->forum_id = $row->thr_top_fk;
214  $this->display_user_id = $row->thr_display_user_id;
215  $this->user_alias = $row->thr_usr_alias;
216  $this->subject = html_entity_decode($row->thr_subject);
217  $this->createdate = $row->thr_date;
218  $this->changedate = $row->thr_update;
219  $this->import_name = $row->import_name;
220  $this->num_posts = $row->thr_num_posts;
221  $this->last_post_string = $row->thr_last_post;
222  $this->visits = $row->visits;
223  $this->is_sticky = $row->is_sticky;
224  $this->is_closed = $row->is_closed;
225  $this->frm_obj_id = $row->frm_obj_id;
226  $this->average_rating = $row->avg_rating;
227  $this->thr_author_id = $row->thr_author_id;
228 
229  return true;
230  }
231  $this->id = 0;
232  return false;
233  }
234 
235  return false;
236  }
foreach($_POST as $key=> $value) $res
+ Here is the caller graph for this function:

◆ reload()

ilForumTopic::reload ( )

Calls the private method read() to load the topic data from database into the object.

Returns
bool true in case of success, false in case of failure public

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

References read().

245  {
246  return $this->read();
247  }
read()
Reads the data of the current object id from database and loads it into the object.
+ Here is the call graph for this function:

◆ reopen()

ilForumTopic::reopen ( )

Reopens the current topic.

Returns
bool true in case of success, false in case of failure public

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

960  {
961  if ($this->id && $this->is_closed) {
962  $this->db->manipulateF(
963  '
964  UPDATE frm_threads
965  SET is_closed = %s
966  WHERE thr_pk = %s',
967  array('integer', 'integer'),
968  array('0', $this->id)
969  );
970 
971  $this->is_closed = 0;
972 
973  return true;
974  }
975 
976  return false;
977  }

◆ setAverageRating()

ilForumTopic::setAverageRating (   $average_rating)
Parameters
int$average_rating

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

References $average_rating.

Referenced by assignData().

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

◆ setChangeDate()

ilForumTopic::setChangeDate (   $a_changedate)

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

Referenced by assignData().

1044  {
1045  if ($a_changedate == '0000-00-00 00:00:00') {
1046  $this->changedate = null;
1047  } else {
1048  $this->changedate = $a_changedate;
1049  }
1050  }
+ Here is the caller graph for this function:

◆ setClosed()

ilForumTopic::setClosed (   $a_closed)

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

Referenced by assignData().

1092  {
1093  $this->is_closed = $a_closed;
1094  }
+ Here is the caller graph for this function:

◆ setCreateDate()

ilForumTopic::setCreateDate (   $a_createdate)

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

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

1036  {
1037  $this->createdate = $a_createdate;
1038  }
+ Here is the caller graph for this function:

◆ setDisplayUserId()

ilForumTopic::setDisplayUserId (   $a_user_id)

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

Referenced by assignData().

1012  {
1013  $this->display_user_id = $a_user_id;
1014  }
+ Here is the caller graph for this function:

◆ setForumId()

ilForumTopic::setForumId (   $a_forum_id)

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

Referenced by assignData().

1004  {
1005  $this->forum_id = $a_forum_id;
1006  }
+ Here is the caller graph for this function:

◆ setId()

ilForumTopic::setId (   $a_id)

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

Referenced by assignData().

996  {
997  $this->id = $a_id;
998  }
+ Here is the caller graph for this function:

◆ setImportName()

ilForumTopic::setImportName (   $a_import_name)

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

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

1056  {
1057  $this->import_name = $a_import_name;
1058  }
+ Here is the caller graph for this function:

◆ setLastPostForThreadOverview()

ilForumTopic::setLastPostForThreadOverview ( ilForumPost  $post)
Parameters
ilForumPost$post

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

1332  {
1333  $this->last_post = $post;
1334  }

◆ setLastPostString()

ilForumTopic::setLastPostString (   $a_last_post)

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

Referenced by assignData().

1064  {
1065  if ($a_last_post == '') {
1066  $a_last_post = null;
1067  }
1068 
1069  $this->last_post_string = $a_last_post;
1070  }
+ Here is the caller graph for this function:

◆ setModeratorRight()

ilForumTopic::setModeratorRight (   $bool)

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

1108  {
1109  $this->is_moderator = $bool;
1110  }

◆ setNumNewPosts()

ilForumTopic::setNumNewPosts (   $num_new_posts)
Parameters
int$num_new_posts
Returns
ilForumTopic

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

Referenced by assignData().

1202  {
1203  $this->num_new_posts = $num_new_posts;
1204  return $this;
1205  }
+ Here is the caller graph for this function:

◆ setNumPosts()

ilForumTopic::setNumPosts (   $a_num_posts)
Parameters
$a_num_posts
Returns
ilForumTopic

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

Referenced by assignData().

1184  {
1185  $this->num_posts = $a_num_posts;
1186  return $this;
1187  }
+ Here is the caller graph for this function:

◆ setNumUnreadPosts()

ilForumTopic::setNumUnreadPosts (   $num_unread_posts)
Parameters
int$num_unread_posts
Returns
ilForumTopic

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

Referenced by assignData().

1220  {
1221  $this->num_unread_posts = $num_unread_posts;
1222  return $this;
1223  }
+ Here is the caller graph for this function:

◆ setOrderDirection()

ilForumTopic::setOrderDirection (   $direction)

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

1252  {
1253  if (!in_array(strtoupper($direction), self::$possibleOrderDirections)) {
1254  $direction = current(self::$possibleOrderDirections);
1255  }
1256 
1257  $this->orderDirection = $direction;
1258  return $this;
1259  }

◆ setOrderField()

ilForumTopic::setOrderField (   $a_order_field)

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

1100  {
1101  $this->orderField = $a_order_field;
1102  }

◆ setSticky()

ilForumTopic::setSticky (   $a_sticky)

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

Referenced by assignData().

1084  {
1085  $this->is_sticky = $a_sticky;
1086  }
+ Here is the caller graph for this function:

◆ setSubject()

ilForumTopic::setSubject (   $a_subject)

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

Referenced by assignData().

1028  {
1029  $this->subject = $a_subject;
1030  }
+ Here is the caller graph for this function:

◆ setThrAuthorId()

ilForumTopic::setThrAuthorId (   $thr_author_id)
Parameters
int$thr_author_id

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

References $thr_author_id.

Referenced by assignData().

1124  {
1125  $this->thr_author_id = $thr_author_id;
1126  }
+ Here is the caller graph for this function:

◆ setUserAlias()

ilForumTopic::setUserAlias (   $a_user_alias)

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

Referenced by assignData().

1020  {
1021  $this->user_alias = $a_user_alias;
1022  }
+ Here is the caller graph for this function:

◆ setUserNotificationEnabled()

ilForumTopic::setUserNotificationEnabled (   $user_notification_enabled)
Parameters
boolean$user_notification_enabled
Returns
ilForumTopic

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

Referenced by assignData().

1238  {
1239  $this->user_notification_enabled = $user_notification_enabled;
1240  return $this;
1241  }
+ Here is the caller graph for this function:

◆ setVisits()

ilForumTopic::setVisits (   $a_visits)

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

Referenced by assignData().

1076  {
1077  $this->visits = $a_visits;
1078  }
+ Here is the caller graph for this function:

◆ unmakeSticky()

ilForumTopic::unmakeSticky ( )

Sets the current topic non-sticky.

Returns
bool true in case of success, false in case of failure public

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

908  {
909  if ($this->id && $this->is_sticky) {
910  $this->db->manipulateF(
911  '
912  UPDATE frm_threads
913  SET is_sticky = %s
914  WHERE thr_pk = %s',
915  array('integer', 'integer'),
916  array('0', $this->id)
917  );
918 
919  $this->is_sticky = 0;
920 
921  return true;
922  }
923 
924  return false;
925  }

◆ update()

ilForumTopic::update ( )

Updates an existing topic.

Returns
bool true in case of success, false in case of failure public

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

159  {
160  if ($this->id) {
161  $this->db->manipulateF(
162  '
163  UPDATE frm_threads
164  SET thr_top_fk = %s,
165  thr_subject = %s,
166  thr_update = %s,
167  thr_num_posts = %s,
168  thr_last_post = %s,
169  avg_rating = %s
170  WHERE thr_pk = %s',
171  array('integer', 'text','timestamp', 'integer', 'text', 'float', 'integer'),
172  array( $this->forum_id,
173  $this->subject,
174  /* $this->changedate, */
175  date('Y-m-d H:i:s'),
176  $this->num_posts,
177  $this->last_post_string,
178  $this->average_rating,
179  $this->id
180  )
181  );
182 
183  return true;
184  }
185 
186  return false;
187  }

◆ updateMergedThread()

ilForumTopic::updateMergedThread ( )

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

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

1287  {
1288  $this->db->update(
1289  'frm_threads',
1290  array(
1291  'thr_num_posts' => array('integer', $this->getNumPosts()),
1292  'visits' => array('integer', $this->getVisits()),
1293  'thr_last_post' => array('text', $this->getLastPostString()),
1294  'thr_subject' => array('text', $this->getSubject())
1295  ),
1296  array('thr_pk' => array('integer', $this->getId()))
1297  );
1298  }
+ Here is the call graph for this function:

◆ updateThreadTitle()

ilForumTopic::updateThreadTitle ( )

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

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

1167  {
1168  $this->db->update(
1169  'frm_threads',
1170  array('thr_subject' => array('text',$this->getSubject())),
1171  array('thr_pk' => array('integer', $this->getId()))
1172  );
1173 
1174  $first_node = $this->getFirstPostNode();
1175  $first_node->setSubject($this->getSubject());
1176  $first_node->update();
1177  }
getFirstPostNode($isModerator=false, $preventImplicitRead=false)
Fetches and returns an object of the first post in the current topic.
+ Here is the call graph for this function:

◆ updateVisits()

ilForumTopic::updateVisits ( )

Updates the visit counter of the current topic.

public

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

References $_SESSION, and $id.

280  {
281  $checkTime = time() - (60 * 60);
282 
283  if ($_SESSION['frm_visit_frm_threads_' . $this->id] < $checkTime) {
284  $_SESSION['frm_visit_frm_threads_' . $this->id] = time();
285 
286  $this->db->manipulateF(
287  '
288  UPDATE frm_threads
289  SET visits = visits + 1
290  WHERE thr_pk = %s',
291  array('integer'),
292  array($this->id)
293  );
294  }
295 
296  return true;
297  }
$_SESSION["AccountId"]

Field Documentation

◆ $average_rating

ilForumTopic::$average_rating = 0
private

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

Referenced by getAverageRating(), and setAverageRating().

◆ $changedate

ilForumTopic::$changedate = null
private

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

Referenced by getChangeDate().

◆ $createdate

ilForumTopic::$createdate = null
private

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

Referenced by getCreateDate().

◆ $db

ilForumTopic::$db = null
private

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

◆ $display_user_id

ilForumTopic::$display_user_id = 0
private

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

Referenced by getDisplayUserId().

◆ $forum_id

ilForumTopic::$forum_id = 0
private

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

Referenced by getForumId().

◆ $frm_obj_id

ilForumTopic::$frm_obj_id = 0
private

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

Referenced by getFrmObjId().

◆ $id

ilForumTopic::$id = 0
private

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

Referenced by countActivePosts(), getId(), movePosts(), and updateVisits().

◆ $import_name

ilForumTopic::$import_name = ''
private

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

Referenced by getImportName().

◆ $is_closed

ilForumTopic::$is_closed = 0
private

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

◆ $is_moderator

ilForumTopic::$is_moderator = false
private

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

Referenced by getModeratorRight().

◆ $is_sticky

ilForumTopic::$is_sticky = 0
private

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

◆ $last_post

ilForumTopic::$last_post = null
private

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

Referenced by getLastPostForThreadOverview().

◆ $last_post_string

ilForumTopic::$last_post_string = ''
private

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

Referenced by getLastPostString().

◆ $num_posts

ilForumTopic::$num_posts = 0
private

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

Referenced by getNumPosts().

◆ $orderDirection

ilForumTopic::$orderDirection = 'DESC'
private

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

Referenced by getOrderDirection().

◆ $orderField

ilForumTopic::$orderField = ''
private

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

Referenced by getOrderField().

◆ $possibleOrderDirections

ilForumTopic::$possibleOrderDirections = array('ASC', 'DESC')
staticprotected

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

◆ $subject

ilForumTopic::$subject = ''
private

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

Referenced by getSubject().

◆ $thr_author_id

ilForumTopic::$thr_author_id = 0
private

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

Referenced by getThrAuthorId(), and setThrAuthorId().

◆ $user_alias

ilForumTopic::$user_alias = ''
private

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

Referenced by getUserAlias().

◆ $visits

ilForumTopic::$visits = 0
private

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

Referenced by getVisits().


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