ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 
 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 = ''
 
 $posts = array()
 
 $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 $ilDB, and read().

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

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

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1283  {
1284  global $ilDB;
1285 
1286  $res = $ilDB->queryF('SELECT thr_date FROM frm_threads WHERE thr_pk = %s',
1287  array('integer'), array((int)$thread_id));
1288 
1289  $row = $ilDB->fetchAssoc($res);
1290 
1291  return $row['thr_date'] ? $row['thr_date'] : '0000-00-00 00:00:00';
1292  }
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 1122 of file class.ilForumTopic.php.

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

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1123  {
1124  global $ilDB;
1125 
1126  $res = $ilDB->queryf('
1127  SELECT thr_subject
1128  FROM frm_threads
1129  WHERE thr_pk = %s',
1130  array('integer'), array($a_topic_id));
1131  $row = $ilDB->fetchObject($res);
1132 
1133  if(is_object($row))
1134  {
1135  return $row->thr_subject;
1136  }
1137 
1138  return '';
1139  }
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 916 of file class.ilForumTopic.php.

References array.

917  {
918  if ($this->id && !$this->is_closed)
919  {
920  $statement = $this->db->manipulateF('
921  UPDATE frm_threads
922  SET is_closed = %s
923  WHERE thr_pk = %s',
924  array('integer', 'integer'),
925  array('1', $this->id));
926 
927  $this->is_closed = 1;
928 
929  return true;
930  }
931 
932  return false;
933  }
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 317 of file class.ilForumTopic.php.

References $id, $ilUser, $res, array, and ilDBConstants\FETCHMODE_ASSOC.

318  {
319  global $ilUser;
320 
321  $res = $this->db->queryf('
322  SELECT COUNT(*) cnt
323  FROM frm_posts
324  WHERE (pos_status = %s
325  OR (pos_status = %s AND pos_display_user_id = %s))
326  AND pos_thr_fk = %s',
327  array('integer', 'integer', 'integer', 'integer'), array('1', '0', $ilUser->getId(), $this->id));
328 
329  $rec = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
330 
331  return $rec['cnt'];
332  }
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.

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

References $res, array, and ilDBConstants\FETCHMODE_ASSOC.

298  {
299  $res = $this->db->queryf('
300  SELECT COUNT(*) cnt
301  FROM frm_posts
302  WHERE pos_thr_fk = %s',
303  array('integer'), array($this->id));
304 
305  $rec = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
306 
307  return $rec['cnt'];
308  }
Create styles array
The data for the language used.

◆ deleteByThreadId()

static ilForumTopic::deleteByThreadId (   $thr_id)
static

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

References $ilDB, and array.

Referenced by ilForum\mergeThreads().

1270  {
1271  global $ilDB;
1272 
1273  $ilDB->manipulateF('DELETE FROM frm_threads WHERE thr_pk = %s',
1274  array('integer'), array($thr_id));
1275  }
Create styles array
The data for the language used.
global $ilDB
+ 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 843 of file class.ilForumTopic.php.

References array.

844  {
845  if ($this->id && $a_user_id)
846  {
847  $statement = $this->db->manipulateF('
848  DELETE FROM frm_notification
849  WHERE user_id = %s
850  AND thread_id = %s',
851  array('integer', 'integer'),
852  array($a_user_id, $this->id));
853 
854  return false;
855  }
856 
857  return false;
858  }
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 812 of file class.ilForumTopic.php.

References array, and isNotificationEnabled().

Referenced by ilForum\generateThread().

813  {
814  if ($this->id && $a_user_id)
815  {
816  if (!$this->isNotificationEnabled($a_user_id))
817  {
818  $nextId = $this->db->nextId('frm_notification');
819  $statement = $this->db->manipulateF('
820  INSERT INTO frm_notification
821  ( notification_id,
822  user_id,
823  thread_id
824  )
825  VALUES(%s, %s, %s)',
826  array('integer', 'integer', 'integer'),
827  array($nextId, $a_user_id, $this->id));
828 
829  return true;
830  }
831  return false;
832  }
833 
834  return false;
835  }
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 413 of file class.ilForumTopic.php.

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

Referenced by movePosts().

414  {
415  $posts = array();
416 
417  if($this->id)
418  {
419  $res = $this->db->queryf('
420  SELECT pos_pk
421  FROM frm_posts
422  WHERE pos_thr_fk = %s',
423  array('integer'),
424  array($this->id));
425 
426  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
427  {
428  $posts[$row->pos_pk] = $row;
429  }
430  }
431 
432  return is_array($posts) ? $posts : array();
433  }
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 963 of file class.ilForumTopic.php.

References $average_rating.

964  {
965  return $this->average_rating;
966  }

◆ getChangeDate()

ilForumTopic::getChangeDate ( )

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

References $changedate.

1032  {
1033  return $this->changedate;
1034  }

◆ getCreateDate()

ilForumTopic::getCreateDate ( )

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

References $createdate.

Referenced by ilForum\generateThread().

1021  {
1022  return $this->createdate;
1023  }
+ Here is the caller graph for this function:

◆ getDisplayUserId()

ilForumTopic::getDisplayUserId ( )

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

References $display_user_id.

Referenced by ilForum\generateThread().

997  {
998  return $this->display_user_id;
999  }
+ 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 254 of file class.ilForumTopic.php.

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

255  {
256  $res = $this->db->queryf('
257  SELECT * FROM frm_posts_tree
258  WHERE thr_fk = %s
259  AND parent_pos = %s',
260  array('integer', 'integer'), array($this->id, '1'));
261 
263 
264  return $row->pos_fk ? $row->pos_fk : 0;
265  }
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 340 of file class.ilForumTopic.php.

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

341  {
342  $res = $this->db->queryf('
343  SELECT pos_pk
344  FROM frm_posts
345  INNER JOIN frm_posts_tree ON pos_fk = pos_pk
346  WHERE parent_pos = %s
347  AND thr_fk = %s',
348  array('integer', 'integer'),
349  array('0', $this->id));
350 
352 
353  return new ilForumPost($row->pos_pk);
354  }
Create styles array
The data for the language used.

◆ getForumId()

ilForumTopic::getForumId ( )

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

References $forum_id.

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

989  {
990  return $this->forum_id;
991  }
+ Here is the caller graph for this function:

◆ getFrmObjId()

ilForumTopic::getFrmObjId ( )

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

References $frm_obj_id.

Referenced by getNestedSetPostChildren().

1094  {
1095  return $this->frm_obj_id;
1096  }
+ Here is the caller graph for this function:

◆ getId()

ilForumTopic::getId ( )

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

References $id.

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

981  {
982  return $this->id;
983  }
+ Here is the caller graph for this function:

◆ getImportName()

ilForumTopic::getImportName ( )

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

References $import_name.

1040  {
1041  return $this->import_name;
1042  }

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

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

389  {
390  global $ilUser;
391 
392  if ($this->id)
393  {
394  $this->db->setLimit(1);
395  $res = $this->db->queryf('
396  SELECT pos_pk
397  FROM frm_posts
398  WHERE pos_thr_fk = %s
399  AND (pos_status = %s OR
400  (pos_status = %s AND pos_display_user_id = %s))
401  ORDER BY pos_date DESC',
402  array('integer', 'integer', 'integer', 'integer'),
403  array($this->id, '1', '0', $ilUser->getId()));
404 
406 
407  return new ilForumPost($row->pos_pk);
408  }
409 
410  return false;
411  }
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.

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

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

363  {
364  if ($this->id)
365  {
366  $this->db->setLimit(1);
367  $res = $this->db->queryf('
368  SELECT pos_pk
369  FROM frm_posts
370  WHERE pos_thr_fk = %s
371  ORDER BY pos_date DESC',
372  array('integer'), array($this->id));
373 
375 
376  return new ilForumPost($row->pos_pk);
377  }
378 
379  return false;
380  }
Create styles array
The data for the language used.

◆ getLastPostString()

ilForumTopic::getLastPostString ( )

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

References $last_post_string.

Referenced by updateMergedThread().

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

◆ getModeratorRight()

ilForumTopic::getModeratorRight ( )

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

References $is_moderator.

1090  {
1091  return $this->is_moderator;
1092  }

◆ getNestedSetPostChildren()

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

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

References $counter, $data, $ilUser, $query, $res, $row, array, getFrmObjId(), and ilForumProperties\getInstance().

638  {
639  global $ilUser;
640 
641  $data = null;
642  $objProperties = ilForumProperties::getInstance($this->getFrmObjId());
643  $is_post_activation_enabled = $objProperties->isPostActivationEnabled();
644 
645  if( $pos_id !== null )
646  {
647  $res = $this->db->queryF("
648  SELECT lft, rgt, depth
649  FROM frm_posts_tree
650  WHERE pos_fk = %s
651  AND thr_fk = %s",
652  array('integer', 'integer'),
653  array($pos_id, $this->id)
654  );
655 
656  $data = $this->db->fetchAssoc($res);
657  }
658 
659  $query = '
660  SELECT fpt.depth,
661  fpt.rgt,
662  fpt.parent_pos,
663  fp.pos_pk,
664  fp.pos_subject,
665  fp.pos_usr_alias,
666  fp.pos_date,
667  fp.pos_update,
668  fp.pos_status,
669  fp.pos_display_user_id,
670  fp.pos_usr_alias,
671  fp.import_name,
672  fp.pos_author_id,
673  fp.is_author_moderator,
674  fur.post_id,
675  (CASE
676  WHEN fur.post_id IS NULL '.
677  ($ilUser->getId() == ANONYMOUS_USER_ID ? ' AND 1 = 2 ' : '').'
678  THEN 0
679  ELSE 1
680  END) post_read,
681  COUNT(fpt2.pos_fk) children
682 
683  FROM frm_posts_tree fpt
684 
685  INNER JOIN frm_posts fp
686  ON fp.pos_pk = fpt.pos_fk
687 
688  LEFT JOIN frm_posts_tree fpt2
689  ON fpt2.lft BETWEEN fpt.lft AND fpt.rgt
690  AND fpt.thr_fk = fpt2.thr_fk
691  AND fpt.pos_fk != fpt2.pos_fk ';
692 
693 
694  $query .= '
695  LEFT JOIN frm_user_read fur
696  ON fur.thread_id = fp.pos_thr_fk
697  AND fur.post_id = fp.pos_pk
698  AND fur.usr_id = '.$this->db->quote($ilUser->getId(), 'integer').'
699 
700  LEFT JOIN usr_data ud
701  ON ud.usr_id = fp.pos_display_user_id
702 
703  WHERE fpt.thr_fk = '.$this->db->quote($this->id, 'integer');
704 
705  if( $data )
706  {
707  $query .= ' AND fpt.lft > '.$this->db->quote($data['lft'], 'integer').
708  ' AND fpt.lft < '.$this->db->quote($data['rgt'], 'integer').' ';
709  }
710  if($is_post_activation_enabled && !$this->is_moderator)
711  {
712  $query .= ' AND (fp.pos_status = 1 OR fp.pos_status = 0 AND fp.pos_display_user_id = ' . $this->db->quote($ilUser->getId(), 'integer') . ') ';
713  }
714 
715  if( $data && is_numeric($levels) )
716  {
717  $query .= ' AND fpt.depth <= '.$this->db->quote($data['depth'] + $levels, 'integer').' ';
718  }
719 
720  $query .= ' GROUP BY fpt.depth,
721  fpt.rgt,
722  fpt.parent_pos,
723  fp.pos_pk,
724  fp.pos_subject,
725  fp.pos_usr_alias,
726  fp.pos_date,
727  fp.pos_update,
728  fp.pos_status,
729  fp.pos_display_user_id,
730  fp.pos_usr_alias,
731  fp.import_name,
732  fp.pos_author_id,
733  fp.is_author_moderator,
734  fur.post_id
735  ORDER BY fpt.rgt DESC
736  ';
737 
738  $queryCounter = '
739  SELECT pos_fk
740  FROM frm_posts_tree fpt
741  INNER JOIN frm_posts fp
742  ON fp.pos_pk = fpt.pos_fk
743  WHERE fpt.thr_fk = '.$this->db->quote($this->id, 'integer');
744 
745  if($is_post_activation_enabled && !$this->is_moderator)
746  {
747  $queryCounter .= ' AND (fp.pos_status = 1 OR fp.pos_status = 0 AND fp.pos_display_user_id = ' . $this->db->quote($ilUser->getId(), 'integer') . ') ';
748  }
749  $queryCounter .= ' ORDER BY fpt.rgt DESC';
750 
751  $resCounter = $this->db->query($queryCounter);
752  $counter = array();
753  $i = 0;
754  while( $row = $this->db->fetchAssoc($resCounter) )
755  {
756  $counter[$row['pos_fk']] = $i++;
757  }
758 
759  $res = $this->db->query($query);
760  $children = array();
761  $usr_ids = array();
762  while( $row = $this->db->fetchAssoc($res) )
763  {
764  if((int)$row['pos_display_user_id'])
765  {
766  $usr_ids[] = (int)$row['pos_display_user_id'];
767  }
768 
769  $row['counter'] = $counter[$row['pos_pk']];
770  $children[] = $row;
771  }
772 
773  require_once 'Modules/Forum/classes/class.ilForumAuthorInformationCache.php';
774  ilForumAuthorInformationCache::preloadUserObjects(array_unique($usr_ids));
775 
776  return $children;
777  }
$counter
static getInstance($a_obj_id=0)
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getNumNewPosts()

ilForumTopic::getNumNewPosts ( )
Returns
int

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

1183  {
1184  return $this->num_new_posts;
1185  }

◆ getNumPosts()

ilForumTopic::getNumPosts ( )
Returns
int

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

References $num_posts.

Referenced by updateMergedThread().

1165  {
1166  return $this->num_posts;
1167  }
+ Here is the caller graph for this function:

◆ getNumUnreadPosts()

ilForumTopic::getNumUnreadPosts ( )
Returns
int

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

1201  {
1202  return $this->num_unread_posts;
1203  }

◆ getOrderDirection()

ilForumTopic::getOrderDirection ( )

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

References $orderDirection.

Referenced by getPostTree().

1235  {
1236  return $this->orderDirection;
1237  }
+ Here is the caller graph for this function:

◆ getOrderField()

ilForumTopic::getOrderField ( )

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

References $orderField.

1082  {
1083  return $this->orderField;
1084  }

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

References $data, $ilUser, $posts, $query, $res, $row, array, ilForumPost\getLft(), getOrderDirection(), ilForumPost\getRgt(), and ilForumPost\getThreadId().

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

◆ getSorting()

ilForumTopic::getSorting ( )

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

1252  {
1253  return $this->thread_sorting;
1254  }

◆ getSubject()

ilForumTopic::getSubject ( )

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

References $subject.

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

1013  {
1014  return $this->subject;
1015  }
+ Here is the caller graph for this function:

◆ getThrAuthorId()

ilForumTopic::getThrAuthorId ( )
Returns
int

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

References $thr_author_id.

Referenced by ilForum\generateThread().

1110  {
1111  return $this->thr_author_id;
1112  }
+ Here is the caller graph for this function:

◆ getUserAlias()

ilForumTopic::getUserAlias ( )

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

References $user_alias.

Referenced by ilForum\generateThread().

1005  {
1006  return $this->user_alias;
1007  }
+ Here is the caller graph for this function:

◆ getUserNotificationEnabled()

ilForumTopic::getUserNotificationEnabled ( )
Returns
boolean

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

1219  {
1220  return $this->user_notification_enabled;
1221  }

◆ getVisits()

ilForumTopic::getVisits ( )

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

References $visits.

Referenced by updateMergedThread().

1058  {
1059  return $this->visits;
1060  }
+ 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  {
124  $nextId = $this->db->nextId('frm_threads');
125 
126  $this->db->insert('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  $this->id = $nextId;
145 
146  return true;
147  }
148 
149  return false;
150  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ isClosed()

ilForumTopic::isClosed ( )

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

1074  {
1075  return $this->is_closed == 1 ? true : false;
1076  }

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

References $result, and array.

Referenced by enableNotification().

786  {
787  if ($this->id && $a_user_id)
788  {
789  $result = $this->db->queryf('
790  SELECT COUNT(notification_id) cnt FROM frm_notification
791  WHERE user_id = %s AND thread_id = %s',
792  array('integer', 'integer'),
793  array($a_user_id, $this->id));
794 
795  while($record = $this->db->fetchAssoc($result))
796  {
797  return (bool)$record['cnt'];
798  }
799 
800  return false;
801  }
802 
803  return false;
804  }
$result
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ isSticky()

ilForumTopic::isSticky ( )

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

1066  {
1067  return $this->is_sticky == 1 ? true : false;
1068  }

◆ lookupForumIdByTopicId()

static ilForumTopic::lookupForumIdByTopicId (   $a_topic_id)
static

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

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

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

1240  {
1241  global $ilDB;
1242 
1243  $res = $ilDB->queryF('SELECT thr_top_fk FROM frm_threads WHERE thr_pk = %s',
1244  array('integer'), array($a_topic_id));
1245 
1246  $row = $ilDB->fetchAssoc($res);
1247 
1248  return $row['thr_top_fk'];
1249  }
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 866 of file class.ilForumTopic.php.

References array.

867  {
868  if ($this->id && !$this->is_sticky)
869  {
870  $statement = $this->db->manipulateF('
871  UPDATE frm_threads
872  SET is_sticky = %s
873  WHERE thr_pk = %s',
874  array('integer', 'integer'),
875  array('1', $this->id));
876 
877  $this->is_sticky = 1;
878 
879  return true;
880  }
881 
882  return false;
883  }
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 550 of file class.ilForumTopic.php.

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

551  {
552  global $ilDB;
553 
554  if ($this->id)
555  {
556  $nodes = $this->getAllPosts();
557  if(is_array($nodes))
558  {
559  // Move attachments
560  foreach($nodes as $node)
561  {
562  $file_obj = new ilFileDataForum((int)$old_obj_id, (int)$node->pos_pk);
563  $file_obj->moveFilesOfPost((int)$new_obj_id);
564  unset($file_obj);
565  }
566  }
567 
568  $current_id = $this->id;
569 
570  $ilAtomQuery = $ilDB->buildAtomQuery();
571  $ilAtomQuery->addTableLock('frm_user_read');
572  $ilAtomQuery->addTableLock('frm_thread_access');
573 
574  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) use ($new_obj_id, $current_id) {
575  $ilDB->manipulateF('
576  DELETE FROM frm_user_read
577  WHERE obj_id = %s AND thread_id =%s',
578  array('integer', 'integer'),
579  array($new_obj_id, $current_id));
580 
581  $ilDB->manipulateF('
582  UPDATE frm_user_read
583  SET obj_id = %s
584  WHERE thread_id = %s',
585  array('integer', 'integer'),
586  array($new_obj_id, $current_id));
587 
588  $ilDB->manipulateF('
589  DELETE FROM frm_thread_access
590  WHERE obj_id = %s AND thread_id =%s',
591  array('integer', 'integer'),
592  array($new_obj_id, $current_id));
593 
594  $ilDB->manipulateF('
595  UPDATE frm_thread_access
596  SET obj_id = %s
597  WHERE thread_id =%s',
598  array('integer', 'integer'),
599  array($new_obj_id, $current_id));
600  });
601 
602  $ilAtomQuery->run();
603 
604  $this->db->manipulateF('
605  UPDATE frm_posts
606  SET pos_top_fk = %s
607  WHERE pos_thr_fk = %s',
608  array('integer', 'integer'),
609  array($new_pk, $this->id));
610 
611  // update all related news
612  $posts = $ilDB->queryf('
613  SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
614  array('integer'), array($this->id));
615 
616  $old_obj_id = ilForum::_lookupObjIdForForumId($old_pk);
617 
618  $new_obj_id = ilForum::_lookupObjIdForForumId($new_pk);
619 
620  while($post = $posts->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
621  {
622  include_once("./Services/News/classes/class.ilNewsItem.php");
623  $news_id = ilNewsItem::getFirstNewsIdForContext($old_obj_id,
624  "frm", $post["pos_pk"], "pos");
625  $news_item = new ilNewsItem($news_id);
626  $news_item->setContextObjId($new_obj_id);
627  $news_item->update();
628  //echo "<br>-".$post["pos_pk"]."-".$old_obj_id."-".$new_obj_id."-";
629  }
630 
631  return count($nodes);
632  }
633 
634  return 0;
635  }
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.
Create styles array
The data for the language used.
This class handles all operations on files for the forum object.
global $ilDB
manipulateF($query, $types, $values)
+ 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 195 of file class.ilForumTopic.php.

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

Referenced by __construct(), and reload().

196  {
197 
198  if ($this->id)
199  {
200  $res = $this->db->queryf('
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'), array($this->id));
206 
208 
209  if (is_object($row))
210  {
211  $this->thr_pk = $row->pos_pk; // thr_pk = pos_pk ??!??!
212  $this->forum_id = $row->thr_top_fk;
213  $this->display_user_id = $row->thr_display_user_id;
214  $this->user_alias = $row->thr_usr_alias;
215  $this->subject = html_entity_decode($row->thr_subject);
216  $this->createdate = $row->thr_date;
217  $this->changedate = $row->thr_update;
218  $this->import_name = $row->import_name;
219  $this->num_posts = $row->thr_num_posts;
220  $this->last_post_string = $row->thr_last_post;
221  $this->visits = $row->visits;
222  $this->is_sticky = $row->is_sticky;
223  $this->is_closed = $row->is_closed;
224  $this->frm_obj_id = $row->frm_obj_id;
225  $this->average_rating = $row->avg_rating;
226  $this->thr_author_id = $row->thr_author_id;
227 
228  return true;
229  }
230  $this->id = 0;
231  return false;
232  }
233 
234  return false;
235  }
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 243 of file class.ilForumTopic.php.

References read().

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

References array.

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

◆ setAverageRating()

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

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

References $average_rating.

Referenced by assignData().

972  {
973  $this->average_rating = $average_rating;
974  }
+ Here is the caller graph for this function:

◆ setChangeDate()

ilForumTopic::setChangeDate (   $a_changedate)

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

Referenced by assignData().

1025  {
1026  if($a_changedate == '0000-00-00 00:00:00')
1027  $this->changedate = NULL;
1028  else
1029  $this->changedate = $a_changedate;
1030  }
+ Here is the caller graph for this function:

◆ setClosed()

ilForumTopic::setClosed (   $a_closed)

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

Referenced by assignData().

1070  {
1071  $this->is_closed = $a_closed;
1072  }
+ Here is the caller graph for this function:

◆ setCreateDate()

ilForumTopic::setCreateDate (   $a_createdate)

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

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

1017  {
1018  $this->createdate = $a_createdate;
1019  }
+ Here is the caller graph for this function:

◆ setDisplayUserId()

ilForumTopic::setDisplayUserId (   $a_user_id)

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

Referenced by assignData().

993  {
994  $this->display_user_id = $a_user_id;
995  }
+ Here is the caller graph for this function:

◆ setForumId()

ilForumTopic::setForumId (   $a_forum_id)

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

Referenced by assignData().

985  {
986  $this->forum_id = $a_forum_id;
987  }
+ Here is the caller graph for this function:

◆ setId()

ilForumTopic::setId (   $a_id)

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

Referenced by assignData().

977  {
978  $this->id = $a_id;
979  }
+ Here is the caller graph for this function:

◆ setImportName()

ilForumTopic::setImportName (   $a_import_name)

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

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

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

◆ setLastPostString()

ilForumTopic::setLastPostString (   $a_last_post)

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

Referenced by assignData().

1044  {
1045  if($a_last_post == '') $a_last_post = NULL;
1046 
1047  $this->last_post_string = $a_last_post;
1048  }
+ Here is the caller graph for this function:

◆ setModeratorRight()

ilForumTopic::setModeratorRight (   $bool)

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

1086  {
1087  $this->is_moderator = $bool;
1088  }

◆ setNumNewPosts()

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

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

Referenced by assignData().

1174  {
1175  $this->num_new_posts = $num_new_posts;
1176  return $this;
1177  }
+ Here is the caller graph for this function:

◆ setNumPosts()

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

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

Referenced by assignData().

1156  {
1157  $this->num_posts = $a_num_posts;
1158  return $this;
1159  }
+ Here is the caller graph for this function:

◆ setNumUnreadPosts()

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

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

Referenced by assignData().

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

◆ setOrderDirection()

ilForumTopic::setOrderDirection (   $direction)

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

1224  {
1225  if(!in_array(strtoupper($direction), self::$possibleOrderDirections))
1226  {
1227  $direction = current(self::$possibleOrderDirections);
1228  }
1229 
1230  $this->orderDirection = $direction;
1231  return $this;
1232  }

◆ setOrderField()

ilForumTopic::setOrderField (   $a_order_field)

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

1078  {
1079  $this->orderField = $a_order_field;
1080  }

◆ setSticky()

ilForumTopic::setSticky (   $a_sticky)

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

Referenced by assignData().

1062  {
1063  $this->is_sticky = $a_sticky;
1064  }
+ Here is the caller graph for this function:

◆ setSubject()

ilForumTopic::setSubject (   $a_subject)

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

Referenced by assignData().

1009  {
1010  $this->subject = $a_subject;
1011  }
+ Here is the caller graph for this function:

◆ setThrAuthorId()

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

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

References $thr_author_id.

Referenced by assignData().

1102  {
1103  $this->thr_author_id = $thr_author_id;
1104  }
+ Here is the caller graph for this function:

◆ setUserAlias()

ilForumTopic::setUserAlias (   $a_user_alias)

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

Referenced by assignData().

1001  {
1002  $this->user_alias = $a_user_alias;
1003  }
+ Here is the caller graph for this function:

◆ setUserNotificationEnabled()

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

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

Referenced by assignData().

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

◆ setVisits()

ilForumTopic::setVisits (   $a_visits)

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

Referenced by assignData().

1054  {
1055  $this->visits = $a_visits;
1056  }
+ 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 891 of file class.ilForumTopic.php.

References array.

892  {
893  if ($this->id && $this->is_sticky)
894  {
895  $statement = $this->db->manipulateF('
896  UPDATE frm_threads
897  SET is_sticky = %s
898  WHERE thr_pk = %s',
899  array('integer', 'integer'),
900  array('0', $this->id));
901 
902  $this->is_sticky = 0;
903 
904  return true;
905  }
906 
907  return false;
908  }
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 158 of file class.ilForumTopic.php.

References array, and date.

159  {
160  if ($this->id)
161  {
162  $statement = $this->db->manipulateF('
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  return true;
183  }
184 
185  return false;
186  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.

◆ updateMergedThread()

ilForumTopic::updateMergedThread ( )

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

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

1256  {
1257  global $ilDB;
1258 
1259  $ilDB->update('frm_threads',
1260  array(
1261  'thr_num_posts' => array('integer', $this->getNumPosts()),
1262  'visits' => array('integer', $this->getVisits()),
1263  'thr_last_post' => array('text', $this->getLastPostString()),
1264  'thr_subject' => array('text', $this->getSubject())
1265  ),
1266  array('thr_pk' => array('integer', $this->getId())));
1267  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ updateThreadTitle()

ilForumTopic::updateThreadTitle ( )

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

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

1142  {
1143  global $ilDB;
1144 
1145  $ilDB->update('frm_threads',
1146  array('thr_subject' => array('text',$this->getSubject())),
1147  array('thr_pk'=> array('integer', $this->getId()))
1148  );
1149  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ updateVisits()

ilForumTopic::updateVisits ( )

Updates the visit counter of the current topic.

public

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

References $_SESSION, array, and time.

273  {
274  $checkTime = time() - (60 * 60);
275 
276  if ($_SESSION['frm_visit_frm_threads_'.$this->id] < $checkTime)
277  {
278  $_SESSION['frm_visit_frm_threads_'.$this->id] = time();
279 
280  $statement = $this->db->manipulateF('
281  UPDATE frm_threads
282  SET visits = visits + 1
283  WHERE thr_pk = %s',
284  array('integer'), array($this->id));
285  }
286 
287  return true;
288  }
$_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(), and movePosts().

◆ $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_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.

◆ $posts

ilForumTopic::$posts = array()
private

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

Referenced by getAllPosts(), getPostTree(), and movePosts().

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