ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ()
 Fetches and returns the number of posts for the given user id. More...
 
 countActivePosts ()
 Fetches and returns the number of active posts for the given user id. More...
 
 getFirstPostNode ()
 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 ()
 
 getLastPostForThreadOverview ()
 
 setLastPostForThreadOverview (ilForumPost $post)
 
 getSorting ()
 
 updateMergedThread ()
 

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 deleteByThreadId ($thr_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 12 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 73 of file class.ilForumTopic.php.

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

74  {
75  global $DIC;
76 
77  $this->is_moderator = $a_is_moderator;
78  $this->db = $DIC->database();
79  $this->user = $DIC->user();
80  $this->id = $a_id;
81 
82  if (!$preventImplicitRead) {
83  $this->read();
84  }
85  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
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 1332 of file class.ilForumTopic.php.

References $DIC, $ilDB, $res, $row, and array.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1333  {
1334  global $DIC;
1335  $ilDB = $DIC->database();
1336 
1337  $res = $ilDB->queryF(
1338  'SELECT thr_date FROM frm_threads WHERE thr_pk = %s',
1339  array('integer'),
1340  array((int) $thread_id)
1341  );
1342 
1343  $row = $ilDB->fetchAssoc($res);
1344 
1345  return $row['thr_date'] ? $row['thr_date'] : '0000-00-00 00:00:00';
1346  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
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 1155 of file class.ilForumTopic.php.

References $DIC, $ilDB, $res, $row, and array.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1156  {
1157  global $DIC;
1158  $ilDB = $DIC->database();
1159 
1160  $res = $ilDB->queryf(
1161  '
1162  SELECT thr_subject
1163  FROM frm_threads
1164  WHERE thr_pk = %s',
1165  array('integer'),
1166  array($a_topic_id)
1167  );
1168  $row = $ilDB->fetchObject($res);
1169 
1170  if (is_object($row)) {
1171  return $row->thr_subject;
1172  }
1173 
1174  return '';
1175  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ assignData()

ilForumTopic::assignData (   $data)
Parameters
$data

Definition at line 90 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().

91  {
92  $this->setId((int) $data['thr_pk']);
93  $this->setForumId((int) $data['thr_top_fk']);
94  $this->setSubject($data['thr_subject']);
95  $this->setDisplayUserId((int) $data['thr_display_user_id']);
96  $this->setUserAlias($data['thr_usr_alias']);
97  $this->setLastPostString($data['last_post_string']);
98  $this->setCreateDate($data['thr_date']);
99  $this->setChangeDate($data['thr_update']);
100  $this->setVisits((int) $data['visits']);
101  $this->setImportName($data['import_name']);
102  $this->setSticky((int) $data['is_sticky']);
103  $this->setClosed((int) $data['is_closed']);
104  $this->setAverageRating($data['avg_rating']);
105  $this->setThrAuthorId($data['thr_author_id']);
106 
107  // Aggregated values
108  $this->setNumPosts((int) $data['num_posts']);
109  $this->setNumUnreadPosts((int) $data['num_unread_posts']);
110  $this->setNumNewPosts((int) $data['num_new_posts']);
111  $this->setUserNotificationEnabled((bool) $data['usr_notification_is_enabled']);
112  }
setSubject($a_subject)
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 944 of file class.ilForumTopic.php.

References array.

945  {
946  if ($this->id && !$this->is_closed) {
947  $this->db->manipulateF(
948  '
949  UPDATE frm_threads
950  SET is_closed = %s
951  WHERE thr_pk = %s',
952  array('integer', 'integer'),
953  array('1', $this->id)
954  );
955 
956  $this->is_closed = 1;
957 
958  return true;
959  }
960 
961  return false;
962  }
Create styles array
The data for the language used.

◆ countActivePosts()

ilForumTopic::countActivePosts ( )

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

Parameters
integer$a_user_iduser id
Returns
integer number of active posts public

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

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

328  {
329  $res = $this->db->queryf(
330  '
331  SELECT COUNT(*) cnt
332  FROM frm_posts
333  WHERE (pos_status = %s
334  OR (pos_status = %s AND pos_display_user_id = %s))
335  AND pos_thr_fk = %s',
336  array('integer', 'integer', 'integer', 'integer'),
337  array('1', '0', $this->user->getId(), $this->id)
338  );
339 
340  $rec = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
341 
342  return $rec['cnt'];
343  }
user()
Definition: user.php:4
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ countPosts()

ilForumTopic::countPosts ( )

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

References $res, array, and ilDBConstants\FETCHMODE_ASSOC.

305  {
306  $res = $this->db->queryf(
307  '
308  SELECT COUNT(*) cnt
309  FROM frm_posts
310  WHERE pos_thr_fk = %s',
311  array('integer'),
312  array($this->id)
313  );
314 
315  $rec = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
316 
317  return $rec['cnt'];
318  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.

◆ deleteByThreadId()

static ilForumTopic::deleteByThreadId (   $thr_id)
static

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

References $DIC, and array.

Referenced by ilForum\mergeThreads().

1318  {
1319  global $DIC;
1320  $DIC->database()->manipulateF(
1321  'DELETE FROM frm_threads WHERE thr_pk = %s',
1322  array('integer'),
1323  array($thr_id)
1324  );
1325  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

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

References array.

869  {
870  if ($this->id && $a_user_id) {
871  $this->db->manipulateF(
872  '
873  DELETE FROM frm_notification
874  WHERE user_id = %s
875  AND thread_id = %s',
876  array('integer', 'integer'),
877  array($a_user_id, $this->id)
878  );
879 
880  return false;
881  }
882 
883  return false;
884  }
Create styles array
The data for the language used.

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

References array, and isNotificationEnabled().

Referenced by ilForum\generateThread().

838  {
839  if ($this->id && $a_user_id) {
840  if (!$this->isNotificationEnabled($a_user_id)) {
841  $nextId = $this->db->nextId('frm_notification');
842  $this->db->manipulateF(
843  '
844  INSERT INTO frm_notification
845  ( notification_id,
846  user_id,
847  thread_id
848  )
849  VALUES(%s, %s, %s)',
850  array('integer', 'integer', 'integer'),
851  array($nextId, $a_user_id, $this->id)
852  );
853 
854  return true;
855  }
856  return false;
857  }
858 
859  return false;
860  }
isNotificationEnabled($a_user_id)
Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (resul...
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllPosts()

ilForumTopic::getAllPosts ( )

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

References $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by movePosts().

428  {
429  $posts = array();
430 
431  if ($this->id) {
432  $res = $this->db->queryf(
433  '
434  SELECT pos_pk
435  FROM frm_posts
436  WHERE pos_thr_fk = %s',
437  array('integer'),
438  array($this->id)
439  );
440 
441  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
442  $posts[$row->pos_pk] = $row;
443  }
444  }
445 
446  return is_array($posts) ? $posts : array();
447  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getAverageRating()

ilForumTopic::getAverageRating ( )
Returns
int

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

References $average_rating.

994  {
995  return $this->average_rating;
996  }

◆ getChangeDate()

ilForumTopic::getChangeDate ( )

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

References $changedate.

1063  {
1064  return $this->changedate;
1065  }

◆ getCreateDate()

ilForumTopic::getCreateDate ( )

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

References $createdate.

Referenced by ilForum\generateThread().

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

◆ getDisplayUserId()

ilForumTopic::getDisplayUserId ( )

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

References $display_user_id.

Referenced by ilForum\generateThread().

1027  {
1028  return $this->display_user_id;
1029  }
+ 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 256 of file class.ilForumTopic.php.

References $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

257  {
258  $res = $this->db->queryf(
259  '
260  SELECT * FROM frm_posts_tree
261  WHERE thr_fk = %s
262  AND parent_pos = %s',
263  array('integer', 'integer'),
264  array($this->id, '1')
265  );
266 
268 
269  return $row->pos_fk ? $row->pos_fk : 0;
270  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.

◆ getFirstPostNode()

ilForumTopic::getFirstPostNode ( )

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

Returns
ilForumPost object of a post public

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

References $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

352  {
353  $res = $this->db->queryf(
354  '
355  SELECT pos_pk
356  FROM frm_posts
357  INNER JOIN frm_posts_tree ON pos_fk = pos_pk
358  WHERE parent_pos = %s
359  AND thr_fk = %s',
360  array('integer', 'integer'),
361  array('0', $this->id)
362  );
363 
365 
366  return new ilForumPost($row->pos_pk);
367  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.

◆ getForumId()

ilForumTopic::getForumId ( )

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

References $forum_id.

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

1019  {
1020  return $this->forum_id;
1021  }
+ Here is the caller graph for this function:

◆ getFrmObjId()

ilForumTopic::getFrmObjId ( )

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

References $frm_obj_id.

Referenced by getNestedSetPostChildren().

1127  {
1128  return $this->frm_obj_id;
1129  }
+ Here is the caller graph for this function:

◆ getId()

ilForumTopic::getId ( )

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

References $id.

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

1011  {
1012  return $this->id;
1013  }
+ Here is the caller graph for this function:

◆ getImportName()

ilForumTopic::getImportName ( )

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

References $import_name.

1071  {
1072  return $this->import_name;
1073  }

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

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

404  {
405  if ($this->id) {
406  $this->db->setLimit(1);
407  $res = $this->db->queryf(
408  '
409  SELECT pos_pk
410  FROM frm_posts
411  WHERE pos_thr_fk = %s
412  AND (pos_status = %s OR
413  (pos_status = %s AND pos_display_user_id = %s))
414  ORDER BY pos_date DESC',
415  array('integer', 'integer', 'integer', 'integer'),
416  array($this->id, '1', '0', $this->user->getId())
417  );
418 
420 
421  return new ilForumPost($row->pos_pk);
422  }
423 
424  return false;
425  }
user()
Definition: user.php:4
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ 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 375 of file class.ilForumTopic.php.

References $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

376  {
377  if ($this->id) {
378  $this->db->setLimit(1);
379  $res = $this->db->queryf(
380  '
381  SELECT pos_pk
382  FROM frm_posts
383  WHERE pos_thr_fk = %s
384  ORDER BY pos_date DESC',
385  array('integer'),
386  array($this->id)
387  );
388 
390 
391  return new ilForumPost($row->pos_pk);
392  }
393 
394  return false;
395  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.

◆ getLastPostForThreadOverview()

ilForumTopic::getLastPostForThreadOverview ( )

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

References $last_post.

1274  {
1275  return $this->last_post;
1276  }

◆ getLastPostString()

ilForumTopic::getLastPostString ( )

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

References $last_post_string.

Referenced by updateMergedThread().

1083  {
1084  return $this->last_post_string;
1085  }
+ Here is the caller graph for this function:

◆ getModeratorRight()

ilForumTopic::getModeratorRight ( )

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

References $is_moderator.

1123  {
1124  return $this->is_moderator;
1125  }

◆ getNestedSetPostChildren()

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

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

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

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

◆ getNumNewPosts()

ilForumTopic::getNumNewPosts ( )
Returns
int

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

1218  {
1219  return $this->num_new_posts;
1220  }

◆ getNumPosts()

ilForumTopic::getNumPosts ( )
Returns
int

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

References $num_posts.

Referenced by updateMergedThread().

1200  {
1201  return $this->num_posts;
1202  }
+ Here is the caller graph for this function:

◆ getNumUnreadPosts()

ilForumTopic::getNumUnreadPosts ( )
Returns
int

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

1236  {
1237  return $this->num_unread_posts;
1238  }

◆ getOrderDirection()

ilForumTopic::getOrderDirection ( )

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

References $orderDirection.

Referenced by getPostTree().

1269  {
1270  return $this->orderDirection;
1271  }
+ Here is the caller graph for this function:

◆ getOrderField()

ilForumTopic::getOrderField ( )

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

References $orderField.

1115  {
1116  return $this->orderField;
1117  }

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

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

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

◆ getSorting()

ilForumTopic::getSorting ( )

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

1300  {
1301  return $this->thread_sorting;
1302  }

◆ getSubject()

ilForumTopic::getSubject ( )

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

References $subject.

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

1043  {
1044  return $this->subject;
1045  }
+ Here is the caller graph for this function:

◆ getThrAuthorId()

ilForumTopic::getThrAuthorId ( )
Returns
int

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

References $thr_author_id.

Referenced by ilForum\generateThread().

1143  {
1144  return $this->thr_author_id;
1145  }
+ Here is the caller graph for this function:

◆ getUserAlias()

ilForumTopic::getUserAlias ( )

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

References $user_alias.

Referenced by ilForum\generateThread().

1035  {
1036  return $this->user_alias;
1037  }
+ Here is the caller graph for this function:

◆ getUserNotificationEnabled()

ilForumTopic::getUserNotificationEnabled ( )
Returns
boolean

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

1254  {
1255  return $this->user_notification_enabled;
1256  }

◆ getVisits()

ilForumTopic::getVisits ( )

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

References $visits.

Referenced by updateMergedThread().

1091  {
1092  return $this->visits;
1093  }
+ 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 120 of file class.ilForumTopic.php.

References array.

Referenced by ilForum\generateThread().

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

◆ isClosed()

ilForumTopic::isClosed ( )

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

1107  {
1108  return $this->is_closed == 1 ? true : false;
1109  }

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

References $result, and array.

Referenced by enableNotification().

811  {
812  if ($this->id && $a_user_id) {
813  $result = $this->db->queryf(
814  '
815  SELECT COUNT(notification_id) cnt FROM frm_notification
816  WHERE user_id = %s AND thread_id = %s',
817  array('integer', 'integer'),
818  array($a_user_id, $this->id)
819  );
820 
821  while ($record = $this->db->fetchAssoc($result)) {
822  return (bool) $record['cnt'];
823  }
824 
825  return false;
826  }
827 
828  return false;
829  }
$result
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ isSticky()

ilForumTopic::isSticky ( )

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

1099  {
1100  return $this->is_sticky == 1 ? true : false;
1101  }

◆ lookupForumIdByTopicId()

static ilForumTopic::lookupForumIdByTopicId (   $a_topic_id)
static

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

References $DIC, $ilDB, $res, $row, and array.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1284  {
1285  global $DIC;
1286  $ilDB = $DIC->database();
1287 
1288  $res = $ilDB->queryF(
1289  'SELECT thr_top_fk FROM frm_threads WHERE thr_pk = %s',
1290  array('integer'),
1291  array($a_topic_id)
1292  );
1293 
1294  $row = $ilDB->fetchAssoc($res);
1295 
1296  return $row['thr_top_fk'];
1297  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
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 892 of file class.ilForumTopic.php.

References array.

893  {
894  if ($this->id && !$this->is_sticky) {
895  $this->db->manipulateF(
896  '
897  UPDATE frm_threads
898  SET is_sticky = %s
899  WHERE thr_pk = %s',
900  array('integer', 'integer'),
901  array('1', $this->id)
902  );
903 
904  $this->is_sticky = 1;
905 
906  return true;
907  }
908 
909  return false;
910  }
Create styles array
The data for the language used.

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

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

555  {
556  if ($this->id) {
557  $nodes = $this->getAllPosts();
558  if (is_array($nodes)) {
559  $postsMoved = array();
560  // Move attachments
561  try {
562  foreach ($nodes as $node) {
563  $file_obj = new ilFileDataForum((int) $old_obj_id, (int) $node->pos_pk);
564  $moved = $file_obj->moveFilesOfPost((int) $new_obj_id);
565 
566  if (true === $moved) {
567  $postsMoved[] = array(
568  'from' => $old_obj_id,
569  'to' => $new_obj_id,
570  'position_id' => (int) $node->pos_pk
571  );
572  }
573 
574  unset($file_obj);
575  }
576  } catch (\ilFileUtilsException $exception) {
577  foreach ($postsMoved as $postedInformation) {
578  $file_obj = new ilFileDataForum($postedInformation['to'], $postedInformation['position_id']);
579  $file_obj->moveFilesOfPost($postedInformation['from']);
580  }
581 
582  throw $exception;
583  }
584  }
585 
586  $current_id = $this->id;
587 
588  $ilAtomQuery = $this->db->buildAtomQuery();
589  $ilAtomQuery->addTableLock('frm_user_read');
590  $ilAtomQuery->addTableLock('frm_thread_access');
591 
592  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) use ($new_obj_id, $current_id) {
593  $ilDB->manipulateF(
594  '
595  DELETE FROM frm_user_read
596  WHERE obj_id = %s AND thread_id =%s',
597  array('integer', 'integer'),
598  array($new_obj_id, $current_id)
599  );
600 
601  $ilDB->manipulateF(
602  '
603  UPDATE frm_user_read
604  SET obj_id = %s
605  WHERE thread_id = %s',
606  array('integer', 'integer'),
607  array($new_obj_id, $current_id)
608  );
609 
610  $ilDB->manipulateF(
611  '
612  DELETE FROM frm_thread_access
613  WHERE obj_id = %s AND thread_id =%s',
614  array('integer', 'integer'),
615  array($new_obj_id, $current_id)
616  );
617 
618  $ilDB->manipulateF(
619  '
620  UPDATE frm_thread_access
621  SET obj_id = %s
622  WHERE thread_id =%s',
623  array('integer', 'integer'),
624  array($new_obj_id, $current_id)
625  );
626  });
627 
628  $ilAtomQuery->run();
629 
630  $this->db->manipulateF(
631  '
632  UPDATE frm_posts
633  SET pos_top_fk = %s
634  WHERE pos_thr_fk = %s',
635  array('integer', 'integer'),
636  array($new_pk, $this->id)
637  );
638 
639  // update all related news
640  $posts = $this->db->queryf(
641  '
642  SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
643  array('integer'),
644  array($this->id)
645  );
646 
647  $old_obj_id = ilForum::_lookupObjIdForForumId($old_pk);
648 
649  $new_obj_id = ilForum::_lookupObjIdForForumId($new_pk);
650 
651  while ($post = $posts->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
652  include_once("./Services/News/classes/class.ilNewsItem.php");
654  $old_obj_id,
655  "frm",
656  $post["pos_pk"],
657  "pos"
658  );
659  $news_item = new ilNewsItem($news_id);
660  $news_item->setContextObjId($new_obj_id);
661  $news_item->update();
662  //echo "<br>-".$post["pos_pk"]."-".$old_obj_id."-".$new_obj_id."-";
663  }
664 
665  return count($nodes);
666  }
667 
668  return 0;
669  }
static _lookupObjIdForForumId($a_for_id)
Interface ilDBInterface.
$post
Definition: post.php:34
Create styles array
The data for the language used.
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 197 of file class.ilForumTopic.php.

References $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct(), and reload().

198  {
199  if ($this->id) {
200  $res = $this->db->queryf(
201  '
202  SELECT frm_threads.*, top_frm_fk frm_obj_id
203  FROM frm_threads
204  INNER JOIN frm_data ON top_pk = thr_top_fk
205  WHERE thr_pk = %s',
206  array('integer'),
207  array($this->id)
208  );
209 
211 
212  if (is_object($row)) {
213  $this->thr_pk = $row->pos_pk; // thr_pk = pos_pk ??!??!
214  $this->forum_id = $row->thr_top_fk;
215  $this->display_user_id = $row->thr_display_user_id;
216  $this->user_alias = $row->thr_usr_alias;
217  $this->subject = html_entity_decode($row->thr_subject);
218  $this->createdate = $row->thr_date;
219  $this->changedate = $row->thr_update;
220  $this->import_name = $row->import_name;
221  $this->num_posts = $row->thr_num_posts;
222  $this->last_post_string = $row->thr_last_post;
223  $this->visits = $row->visits;
224  $this->is_sticky = $row->is_sticky;
225  $this->is_closed = $row->is_closed;
226  $this->frm_obj_id = $row->frm_obj_id;
227  $this->average_rating = $row->avg_rating;
228  $this->thr_author_id = $row->thr_author_id;
229 
230  return true;
231  }
232  $this->id = 0;
233  return false;
234  }
235 
236  return false;
237  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ 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 245 of file class.ilForumTopic.php.

References read().

246  {
247  return $this->read();
248  }
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 970 of file class.ilForumTopic.php.

References array.

971  {
972  if ($this->id && $this->is_closed) {
973  $this->db->manipulateF(
974  '
975  UPDATE frm_threads
976  SET is_closed = %s
977  WHERE thr_pk = %s',
978  array('integer', 'integer'),
979  array('0', $this->id)
980  );
981 
982  $this->is_closed = 0;
983 
984  return true;
985  }
986 
987  return false;
988  }
Create styles array
The data for the language used.

◆ setAverageRating()

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

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

References $average_rating.

Referenced by assignData().

1002  {
1003  $this->average_rating = $average_rating;
1004  }
+ Here is the caller graph for this function:

◆ setChangeDate()

ilForumTopic::setChangeDate (   $a_changedate)

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

Referenced by assignData().

1055  {
1056  if ($a_changedate == '0000-00-00 00:00:00') {
1057  $this->changedate = null;
1058  } else {
1059  $this->changedate = $a_changedate;
1060  }
1061  }
+ Here is the caller graph for this function:

◆ setClosed()

ilForumTopic::setClosed (   $a_closed)

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

Referenced by assignData().

1103  {
1104  $this->is_closed = $a_closed;
1105  }
+ Here is the caller graph for this function:

◆ setCreateDate()

ilForumTopic::setCreateDate (   $a_createdate)

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

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

1047  {
1048  $this->createdate = $a_createdate;
1049  }
+ Here is the caller graph for this function:

◆ setDisplayUserId()

ilForumTopic::setDisplayUserId (   $a_user_id)

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

Referenced by assignData().

1023  {
1024  $this->display_user_id = $a_user_id;
1025  }
+ Here is the caller graph for this function:

◆ setForumId()

ilForumTopic::setForumId (   $a_forum_id)

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

Referenced by assignData().

1015  {
1016  $this->forum_id = $a_forum_id;
1017  }
+ Here is the caller graph for this function:

◆ setId()

ilForumTopic::setId (   $a_id)

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

Referenced by assignData().

1007  {
1008  $this->id = $a_id;
1009  }
+ Here is the caller graph for this function:

◆ setImportName()

ilForumTopic::setImportName (   $a_import_name)

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

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

1067  {
1068  $this->import_name = $a_import_name;
1069  }
+ Here is the caller graph for this function:

◆ setLastPostForThreadOverview()

ilForumTopic::setLastPostForThreadOverview ( ilForumPost  $post)

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

References $post.

1279  {
1280  $this->last_post = $post;
1281  }
$post
Definition: post.php:34

◆ setLastPostString()

ilForumTopic::setLastPostString (   $a_last_post)

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

Referenced by assignData().

1075  {
1076  if ($a_last_post == '') {
1077  $a_last_post = null;
1078  }
1079 
1080  $this->last_post_string = $a_last_post;
1081  }
+ Here is the caller graph for this function:

◆ setModeratorRight()

ilForumTopic::setModeratorRight (   $bool)

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

1119  {
1120  $this->is_moderator = $bool;
1121  }

◆ setNumNewPosts()

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

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

Referenced by assignData().

1209  {
1210  $this->num_new_posts = $num_new_posts;
1211  return $this;
1212  }
+ Here is the caller graph for this function:

◆ setNumPosts()

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

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

Referenced by assignData().

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

◆ setNumUnreadPosts()

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

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

Referenced by assignData().

1227  {
1228  $this->num_unread_posts = $num_unread_posts;
1229  return $this;
1230  }
+ Here is the caller graph for this function:

◆ setOrderDirection()

ilForumTopic::setOrderDirection (   $direction)

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

1259  {
1260  if (!in_array(strtoupper($direction), self::$possibleOrderDirections)) {
1261  $direction = current(self::$possibleOrderDirections);
1262  }
1263 
1264  $this->orderDirection = $direction;
1265  return $this;
1266  }

◆ setOrderField()

ilForumTopic::setOrderField (   $a_order_field)

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

1111  {
1112  $this->orderField = $a_order_field;
1113  }

◆ setSticky()

ilForumTopic::setSticky (   $a_sticky)

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

Referenced by assignData().

1095  {
1096  $this->is_sticky = $a_sticky;
1097  }
+ Here is the caller graph for this function:

◆ setSubject()

ilForumTopic::setSubject (   $a_subject)

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

Referenced by assignData().

1039  {
1040  $this->subject = $a_subject;
1041  }
+ Here is the caller graph for this function:

◆ setThrAuthorId()

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

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

References $thr_author_id.

Referenced by assignData().

1135  {
1136  $this->thr_author_id = $thr_author_id;
1137  }
+ Here is the caller graph for this function:

◆ setUserAlias()

ilForumTopic::setUserAlias (   $a_user_alias)

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

Referenced by assignData().

1031  {
1032  $this->user_alias = $a_user_alias;
1033  }
+ Here is the caller graph for this function:

◆ setUserNotificationEnabled()

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

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

Referenced by assignData().

1245  {
1246  $this->user_notification_enabled = $user_notification_enabled;
1247  return $this;
1248  }
+ Here is the caller graph for this function:

◆ setVisits()

ilForumTopic::setVisits (   $a_visits)

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

Referenced by assignData().

1087  {
1088  $this->visits = $a_visits;
1089  }
+ 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 918 of file class.ilForumTopic.php.

References array.

919  {
920  if ($this->id && $this->is_sticky) {
921  $this->db->manipulateF(
922  '
923  UPDATE frm_threads
924  SET is_sticky = %s
925  WHERE thr_pk = %s',
926  array('integer', 'integer'),
927  array('0', $this->id)
928  );
929 
930  $this->is_sticky = 0;
931 
932  return true;
933  }
934 
935  return false;
936  }
Create styles array
The data for the language used.

◆ update()

ilForumTopic::update ( )

Updates an existing topic.

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

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

References array, and date.

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

◆ updateMergedThread()

ilForumTopic::updateMergedThread ( )

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

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

1304  {
1305  $this->db->update(
1306  'frm_threads',
1307  array(
1308  'thr_num_posts' => array('integer', $this->getNumPosts()),
1309  'visits' => array('integer', $this->getVisits()),
1310  'thr_last_post' => array('text', $this->getLastPostString()),
1311  'thr_subject' => array('text', $this->getSubject())
1312  ),
1313  array('thr_pk' => array('integer', $this->getId()))
1314  );
1315  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ updateThreadTitle()

ilForumTopic::updateThreadTitle ( )

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

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

1178  {
1179  $this->db->update(
1180  'frm_threads',
1181  array('thr_subject' => array('text',$this->getSubject())),
1182  array('thr_pk'=> array('integer', $this->getId()))
1183  );
1184  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ updateVisits()

ilForumTopic::updateVisits ( )

Updates the visit counter of the current topic.

public

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

References $_SESSION, $id, array, and time.

278  {
279  $checkTime = time() - (60 * 60);
280 
281  if ($_SESSION['frm_visit_frm_threads_' . $this->id] < $checkTime) {
282  $_SESSION['frm_visit_frm_threads_' . $this->id] = time();
283 
284  $this->db->manipulateF(
285  '
286  UPDATE frm_threads
287  SET visits = visits + 1
288  WHERE thr_pk = %s',
289  array('integer'),
290  array($this->id)
291  );
292  }
293 
294  return true;
295  }
$_SESSION["AccountId"]
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

Field Documentation

◆ $average_rating

ilForumTopic::$average_rating = 0
private

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

Referenced by getAverageRating(), and setAverageRating().

◆ $changedate

ilForumTopic::$changedate = null
private

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

Referenced by getChangeDate().

◆ $createdate

ilForumTopic::$createdate = null
private

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

Referenced by getCreateDate().

◆ $db

ilForumTopic::$db = null
private

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

◆ $display_user_id

ilForumTopic::$display_user_id = 0
private

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

Referenced by getDisplayUserId().

◆ $forum_id

ilForumTopic::$forum_id = 0
private

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

Referenced by getForumId().

◆ $frm_obj_id

ilForumTopic::$frm_obj_id = 0
private

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

Referenced by getFrmObjId().

◆ $id

ilForumTopic::$id = 0
private

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

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

◆ $import_name

ilForumTopic::$import_name = ''
private

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

Referenced by getImportName().

◆ $is_closed

ilForumTopic::$is_closed = 0
private

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

◆ $is_moderator

ilForumTopic::$is_moderator = false
private

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

Referenced by getModeratorRight().

◆ $is_sticky

ilForumTopic::$is_sticky = 0
private

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

◆ $last_post

ilForumTopic::$last_post = null
private

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

Referenced by getLastPostForThreadOverview().

◆ $last_post_string

ilForumTopic::$last_post_string = ''
private

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

Referenced by getLastPostString().

◆ $num_posts

ilForumTopic::$num_posts = 0
private

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

Referenced by getNumPosts().

◆ $orderDirection

ilForumTopic::$orderDirection = 'DESC'
private

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

Referenced by getOrderDirection().

◆ $orderField

ilForumTopic::$orderField = ''
private

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

Referenced by getOrderField().

◆ $possibleOrderDirections

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

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

◆ $subject

ilForumTopic::$subject = ''
private

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

Referenced by getSubject().

◆ $thr_author_id

ilForumTopic::$thr_author_id = 0
private

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

Referenced by getThrAuthorId(), and setThrAuthorId().

◆ $user_alias

ilForumTopic::$user_alias = ''
private

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

Referenced by getUserAlias().

◆ $visits

ilForumTopic::$visits = 0
private

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

Referenced by getVisits().


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