ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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

@access public

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

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
read()
Reads the data of the current object id from database and loads it into the object.
$DIC
Definition: xapitoken.php:46

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

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

1303 {
1304 global $DIC;
1305 $ilDB = $DIC->database();
1306
1307 $res = $ilDB->queryF(
1308 'SELECT thr_date FROM frm_threads WHERE thr_pk = %s',
1309 array('integer'),
1310 array((int) $thread_id)
1311 );
1312
1313 $row = $ilDB->fetchAssoc($res);
1314
1315 return $row['thr_date'] ? $row['thr_date'] : '0000-00-00 00:00:00';
1316 }
foreach($_POST as $key=> $value) $res
global $ilDB

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

+ 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 @access public

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

1143 {
1144 global $DIC;
1145 $ilDB = $DIC->database();
1146
1147 $res = $ilDB->queryf(
1148 '
1149 SELECT thr_subject
1150 FROM frm_threads
1151 WHERE thr_pk = %s',
1152 array('integer'),
1153 array($a_topic_id)
1154 );
1155 $row = $ilDB->fetchObject($res);
1156
1157 if (is_object($row)) {
1158 return $row->thr_subject;
1159 }
1160
1161 return '';
1162 }

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

+ Here is the caller graph for this function:

◆ assignData()

ilForumTopic::assignData (   $data)
Parameters
$data

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

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 }
setUserNotificationEnabled($user_notification_enabled)
setNumNewPosts($num_new_posts)
setThrAuthorId($thr_author_id)
setChangeDate($a_changedate)
setForumId($a_forum_id)
setNumPosts($a_num_posts)
setSubject($a_subject)
setUserAlias($a_user_alias)
setDisplayUserId($a_user_id)
setAverageRating($average_rating)
setImportName($a_import_name)
setLastPostString($a_last_post)
setCreateDate($a_createdate)
setNumUnreadPosts($num_unread_posts)
$data
Definition: storeScorm.php:23

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

+ 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 @access public

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

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

◆ 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 @access public

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

328 {
329 $res = $this->db->queryf(
330 '
331 SELECT COUNT(*) cnt
332 FROM frm_posts
333 INNER JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
334 WHERE (pos_status = %s
335 OR (pos_status = %s AND pos_display_user_id = %s))
336 AND pos_thr_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
337 array('integer', 'integer', 'integer', 'integer'),
338 array('1', '0', $this->user->getId(), $this->id)
339 );
340
341 $rec = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
342
343 return $rec['cnt'];
344 }

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

+ 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 @access public

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

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

References $res, and ilDBConstants\FETCHMODE_ASSOC.

◆ 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 @access public

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

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

◆ 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 @access public

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

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

References isNotificationEnabled().

Referenced by ilForum\generateThread().

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

◆ getAllPosts()

ilForumTopic::getAllPosts ( )

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

432 {
433 $posts = array();
434
435 if ($this->id) {
436 $res = $this->db->queryf(
437 '
438 SELECT pos_pk
439 FROM frm_posts
440 WHERE pos_thr_fk = %s',
441 array('integer'),
442 array($this->id)
443 );
444
445 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
446 $posts[$row->pos_pk] = $row;
447 }
448 }
449
450 return is_array($posts) ? $posts : array();
451 }

References $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by movePosts().

+ Here is the caller graph for this function:

◆ getAverageRating()

ilForumTopic::getAverageRating ( )
Returns
int

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

981 {
983 }

References $average_rating.

◆ getChangeDate()

ilForumTopic::getChangeDate ( )

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

1050 {
1051 return $this->changedate;
1052 }

References $changedate.

◆ getCreateDate()

ilForumTopic::getCreateDate ( )

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

1038 {
1039 return $this->createdate;
1040 }

References $createdate.

Referenced by ilForum\generateThread().

+ Here is the caller graph for this function:

◆ getDisplayUserId()

ilForumTopic::getDisplayUserId ( )

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

1014 {
1016 }

References $display_user_id.

Referenced by ilForum\generateThread().

+ 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 @access public

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

256 {
257 $res = $this->db->queryf(
258 '
259 SELECT * FROM frm_posts_tree
260 WHERE thr_fk = %s
261 AND parent_pos = %s',
262 array('integer', 'integer'),
263 array($this->id, '1')
264 );
265
266 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
267
268 return $row->pos_fk ? $row->pos_fk : 0;
269 }

References $res, and ilDBConstants\FETCHMODE_OBJECT.

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

353 {
354 $res = $this->db->queryF(
355 '
356 SELECT *
357 FROM frm_posts
358 INNER JOIN frm_posts_tree ON pos_fk = pos_pk
359 WHERE parent_pos = %s
360 AND thr_fk = %s',
361 array('integer', 'integer'),
362 array(0, $this->id)
363 );
364
365 $row = $this->db->fetchAssoc($res);
366
367 $post = new ilForumPost($row['pos_pk'], $isModerator, $preventImplicitRead);
368 $post->assignData($row);
369
370 return $post;
371 }

References $res.

Referenced by updateThreadTitle().

+ Here is the caller graph for this function:

◆ getForumId()

ilForumTopic::getForumId ( )

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

1006 {
1007 return $this->forum_id;
1008 }

References $forum_id.

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

+ Here is the caller graph for this function:

◆ getFrmObjId()

ilForumTopic::getFrmObjId ( )

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

1114 {
1115 return $this->frm_obj_id;
1116 }

References $frm_obj_id.

Referenced by getNestedSetPostChildren().

+ Here is the caller graph for this function:

◆ getId()

ilForumTopic::getId ( )

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

998 {
999 return $this->id;
1000 }

References $id.

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

+ Here is the caller graph for this function:

◆ getImportName()

ilForumTopic::getImportName ( )

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

1058 {
1059 return $this->import_name;
1060 }

References $import_name.

◆ 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 @access public

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

408 {
409 if ($this->id) {
410 $this->db->setLimit(1);
411 $res = $this->db->queryf(
412 '
413 SELECT pos_pk
414 FROM frm_posts
415 WHERE pos_thr_fk = %s
416 AND (pos_status = %s OR
417 (pos_status = %s AND pos_display_user_id = %s))
418 ORDER BY pos_date DESC',
419 array('integer', 'integer', 'integer', 'integer'),
420 array($this->id, '1', '0', $this->user->getId())
421 );
422
423 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
424
425 return new ilForumPost($row->pos_pk);
426 }
427
428 return false;
429 }

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

+ 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 @access public

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

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

References $res, and ilDBConstants\FETCHMODE_OBJECT.

◆ getLastPostForThreadOverview()

ilForumTopic::getLastPostForThreadOverview ( )
Returns
ilForumPost|null

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

1322 {
1323 return $this->last_post;
1324 }

References $last_post.

◆ getLastPostString()

ilForumTopic::getLastPostString ( )

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

1070 {
1072 }

References $last_post_string.

Referenced by updateMergedThread().

+ Here is the caller graph for this function:

◆ getModeratorRight()

ilForumTopic::getModeratorRight ( )

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

1110 {
1111 return $this->is_moderator;
1112 }

References $is_moderator.

◆ getNestedSetPostChildren()

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

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

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

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

+ Here is the call graph for this function:

◆ getNumNewPosts()

ilForumTopic::getNumNewPosts ( )
Returns
int

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

1209 {
1210 return $this->num_new_posts;
1211 }

◆ getNumPosts()

ilForumTopic::getNumPosts ( )
Returns
int

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

1191 {
1192 return $this->num_posts;
1193 }

References $num_posts.

Referenced by updateMergedThread().

+ Here is the caller graph for this function:

◆ getNumUnreadPosts()

ilForumTopic::getNumUnreadPosts ( )
Returns
int

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

1227 {
1228 return $this->num_unread_posts;
1229 }

◆ getOrderDirection()

ilForumTopic::getOrderDirection ( )

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

1260 {
1261 return $this->orderDirection;
1262 }

References $orderDirection.

Referenced by getPostTree().

+ Here is the caller graph for this function:

◆ getOrderField()

ilForumTopic::getOrderField ( )

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

1102 {
1103 return $this->orderField;
1104 }

References $orderField.

◆ 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 @access public

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

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

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

+ Here is the call graph for this function:

◆ getSorting()

ilForumTopic::getSorting ( )

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

1281 {
1282 return $this->thread_sorting;
1283 }

◆ getSubject()

ilForumTopic::getSubject ( )

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

1030 {
1031 return $this->subject;
1032 }

References $subject.

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

+ Here is the caller graph for this function:

◆ getThrAuthorId()

ilForumTopic::getThrAuthorId ( )
Returns
int

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

1130 {
1131 return $this->thr_author_id;
1132 }

References $thr_author_id.

Referenced by ilForum\generateThread().

+ Here is the caller graph for this function:

◆ getUserAlias()

ilForumTopic::getUserAlias ( )

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

1022 {
1023 return $this->user_alias;
1024 }

References $user_alias.

Referenced by ilForum\generateThread().

+ Here is the caller graph for this function:

◆ getUserNotificationEnabled()

ilForumTopic::getUserNotificationEnabled ( )
Returns
boolean

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

1245 {
1246 return $this->user_notification_enabled;
1247 }

◆ getVisits()

ilForumTopic::getVisits ( )

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

1078 {
1079 return $this->visits;
1080 }

References $visits.

Referenced by updateMergedThread().

+ 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 @access public

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

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 }

Referenced by ilForum\generateThread().

+ Here is the caller graph for this function:

◆ isClosed()

ilForumTopic::isClosed ( )

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

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

◆ 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 @access public

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

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

References $result.

Referenced by enableNotification().

+ Here is the caller graph for this function:

◆ isSticky()

ilForumTopic::isSticky ( )

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

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

◆ lookupForumIdByTopicId()

static ilForumTopic::lookupForumIdByTopicId (   $a_topic_id)
static

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

1265 {
1266 global $DIC;
1267 $ilDB = $DIC->database();
1268
1269 $res = $ilDB->queryF(
1270 'SELECT thr_top_fk FROM frm_threads WHERE thr_pk = %s',
1271 array('integer'),
1272 array($a_topic_id)
1273 );
1274
1275 $row = $ilDB->fetchAssoc($res);
1276
1277 return $row['thr_top_fk'];
1278 }

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

+ 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 @access public

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

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

◆ 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 @access public

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

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

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

+ 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

@access private

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

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 }

References $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct(), and reload().

+ 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 @access public

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

245 {
246 return $this->read();
247 }

References read().

+ 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 @access public

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

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

◆ setAverageRating()

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

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

989 {
990 $this->average_rating = $average_rating;
991 }

References $average_rating.

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setChangeDate()

ilForumTopic::setChangeDate (   $a_changedate)

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

1042 {
1043 if ($a_changedate == '0000-00-00 00:00:00') {
1044 $this->changedate = null;
1045 } else {
1046 $this->changedate = $a_changedate;
1047 }
1048 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setClosed()

ilForumTopic::setClosed (   $a_closed)

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

1090 {
1091 $this->is_closed = $a_closed;
1092 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setCreateDate()

ilForumTopic::setCreateDate (   $a_createdate)

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

1034 {
1035 $this->createdate = $a_createdate;
1036 }

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

+ Here is the caller graph for this function:

◆ setDisplayUserId()

ilForumTopic::setDisplayUserId (   $a_user_id)

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

1010 {
1011 $this->display_user_id = $a_user_id;
1012 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setForumId()

ilForumTopic::setForumId (   $a_forum_id)

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

1002 {
1003 $this->forum_id = $a_forum_id;
1004 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setId()

ilForumTopic::setId (   $a_id)

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

994 {
995 $this->id = $a_id;
996 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setImportName()

ilForumTopic::setImportName (   $a_import_name)

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

1054 {
1055 $this->import_name = $a_import_name;
1056 }

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

+ Here is the caller graph for this function:

◆ setLastPostForThreadOverview()

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

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

1330 {
1331 $this->last_post = $post;
1332 }

◆ setLastPostString()

ilForumTopic::setLastPostString (   $a_last_post)

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

1062 {
1063 if ($a_last_post == '') {
1064 $a_last_post = null;
1065 }
1066
1067 $this->last_post_string = $a_last_post;
1068 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setModeratorRight()

ilForumTopic::setModeratorRight (   $bool)

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

1106 {
1107 $this->is_moderator = $bool;
1108 }

◆ setNumNewPosts()

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

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

1200 {
1201 $this->num_new_posts = $num_new_posts;
1202 return $this;
1203 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setNumPosts()

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

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

1182 {
1183 $this->num_posts = $a_num_posts;
1184 return $this;
1185 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setNumUnreadPosts()

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

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

1218 {
1219 $this->num_unread_posts = $num_unread_posts;
1220 return $this;
1221 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setOrderDirection()

ilForumTopic::setOrderDirection (   $direction)

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

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

◆ setOrderField()

ilForumTopic::setOrderField (   $a_order_field)

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

1098 {
1099 $this->orderField = $a_order_field;
1100 }

◆ setSticky()

ilForumTopic::setSticky (   $a_sticky)

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

1082 {
1083 $this->is_sticky = $a_sticky;
1084 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setSubject()

ilForumTopic::setSubject (   $a_subject)

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

1026 {
1027 $this->subject = $a_subject;
1028 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setThrAuthorId()

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

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

1122 {
1123 $this->thr_author_id = $thr_author_id;
1124 }

References $thr_author_id.

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setUserAlias()

ilForumTopic::setUserAlias (   $a_user_alias)

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

1018 {
1019 $this->user_alias = $a_user_alias;
1020 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setUserNotificationEnabled()

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

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

1236 {
1237 $this->user_notification_enabled = $user_notification_enabled;
1238 return $this;
1239 }

Referenced by assignData().

+ Here is the caller graph for this function:

◆ setVisits()

ilForumTopic::setVisits (   $a_visits)

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

1074 {
1075 $this->visits = $a_visits;
1076 }

Referenced by assignData().

+ 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 @access public

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

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

◆ update()

ilForumTopic::update ( )

Updates an existing topic.

Returns
bool true in case of success, false in case of failure @access 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 1284 of file class.ilForumTopic.php.

1285 {
1286 $this->db->update(
1287 'frm_threads',
1288 array(
1289 'thr_num_posts' => array('integer', $this->getNumPosts()),
1290 'visits' => array('integer', $this->getVisits()),
1291 'thr_last_post' => array('text', $this->getLastPostString()),
1292 'thr_subject' => array('text', $this->getSubject())
1293 ),
1294 array('thr_pk' => array('integer', $this->getId()))
1295 );
1296 }

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

+ Here is the call graph for this function:

◆ updateThreadTitle()

ilForumTopic::updateThreadTitle ( )

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

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

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

+ Here is the call graph for this function:

◆ updateVisits()

ilForumTopic::updateVisits ( )

Updates the visit counter of the current topic.

@access public

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

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

References $_SESSION, and $id.

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 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: