ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilForumTopic Class Reference
+ Collaboration diagram for ilForumTopic:

Public Member Functions

 __construct ($a_id=0, $a_is_moderator=false, $preventImplicitRead=false)
 Constructor. More...
 
 assignData ($data)
 
 insert ()
 Inserts the object data into database. More...
 
 update ()
 Updates an existing topic. More...
 
 reload ()
 Calls the private method read() to load the topic data from database into the object. More...
 
 getFirstPostId ()
 Fetches the primary key of the first post node of the current topic from database and returns it. More...
 
 updateVisits ()
 Updates the visit counter of the current topic. More...
 
 countPosts ()
 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, $expandedNodes=array())
 
 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 = '0000-00-00 00:00:00'
 
 $changedate = '0000-00-00 00:00:00'
 
 $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 1281 of file class.ilForumTopic.php.

References $ilDB, $res, and $row.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

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

References $ilDB, $res, and $row.

Referenced by ilObjForumGUI\afterSave(), ilObjForumGUI\confirmMergeThreadsObject(), and ilObjForumGUI\getThreadEditingForm().

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

916  {
917  if ($this->id && !$this->is_closed)
918  {
919  $statement = $this->db->manipulateF('
920  UPDATE frm_threads
921  SET is_closed = %s
922  WHERE thr_pk = %s',
923  array('integer', 'integer'),
924  array('1', $this->id));
925 
926  $this->is_closed = 1;
927 
928  return true;
929  }
930 
931  return false;
932  }

◆ 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, and DB_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(DB_FETCHMODE_ASSOC);
330 
331  return $rec['cnt'];
332  }
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
global $ilUser
Definition: imgupload.php:15

◆ 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, and DB_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(DB_FETCHMODE_ASSOC);
306 
307  return $rec['cnt'];
308  }
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10

◆ deleteByThreadId()

static ilForumTopic::deleteByThreadId (   $thr_id)
static

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

References $ilDB.

Referenced by ilForum\mergeThreads().

1269  {
1270  global $ilDB;
1271 
1272  $ilDB->manipulateF('DELETE FROM frm_threads WHERE thr_pk = %s',
1273  array('integer'), array($thr_id));
1274  }
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 842 of file class.ilForumTopic.php.

843  {
844  if ($this->id && $a_user_id)
845  {
846  $statement = $this->db->manipulateF('
847  DELETE FROM frm_notification
848  WHERE user_id = %s
849  AND thread_id = %s',
850  array('integer', 'integer'),
851  array($a_user_id, $this->id));
852 
853  return false;
854  }
855 
856  return false;
857  }

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

References isNotificationEnabled().

812  {
813  if ($this->id && $a_user_id)
814  {
815  if (!$this->isNotificationEnabled($a_user_id))
816  {
817  $nextId = $this->db->nextId('frm_notification');
818  $statement = $this->db->manipulateF('
819  INSERT INTO frm_notification
820  ( notification_id,
821  user_id,
822  thread_id
823  )
824  VALUES(%s, %s, %s)',
825  array('integer', 'integer', 'integer'),
826  array($nextId, $a_user_id, $this->id));
827 
828  return true;
829  }
830  return false;
831  }
832 
833  return false;
834  }
isNotificationEnabled($a_user_id)
Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (resul...
+ Here is the call graph for this function:

◆ getAllPosts()

ilForumTopic::getAllPosts ( )

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

References $posts, $res, $row, and DB_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(DB_FETCHMODE_OBJECT))
427  {
428  $posts[$row->pos_pk] = $row;
429  }
430  }
431 
432  return is_array($posts) ? $posts : array();
433  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ getAverageRating()

ilForumTopic::getAverageRating ( )
Returns
int

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

References $average_rating.

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

◆ getChangeDate()

ilForumTopic::getChangeDate ( )

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

References $changedate.

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

◆ getCreateDate()

ilForumTopic::getCreateDate ( )

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

References $createdate.

1020  {
1021  return $this->createdate;
1022  }

◆ getDisplayUserId()

ilForumTopic::getDisplayUserId ( )

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

References $display_user_id.

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

996  {
997  return $this->display_user_id;
998  }
+ 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, and DB_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 
262  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
263 
264  return $row->pos_fk ? $row->pos_fk : 0;
265  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

◆ 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, and DB_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 
351  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
352 
353  return new ilForumPost($row->pos_pk);
354  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

◆ getForumId()

ilForumTopic::getForumId ( )

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

References $forum_id.

988  {
989  return $this->forum_id;
990  }

◆ getFrmObjId()

ilForumTopic::getFrmObjId ( )

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

References $frm_obj_id.

Referenced by getNestedSetPostChildren().

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

◆ getId()

ilForumTopic::getId ( )

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

References $id.

Referenced by ilForumTopicTableGUI\initMergeThreadsTable(), updateMergedThread(), and updateThreadTitle().

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

◆ getImportName()

ilForumTopic::getImportName ( )

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

References $import_name.

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

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

◆ 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, and DB_FETCHMODE_OBJECT.

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

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 
405  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
406 
407  return new ilForumPost($row->pos_pk);
408  }
409 
410  return false;
411  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilUser
Definition: imgupload.php:15
+ Here is the caller graph for this function:

◆ getLastPost()

ilForumTopic::getLastPost ( )

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

Returns
ilForumPost object of the last post public

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

References $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

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 
374  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
375 
376  return new ilForumPost($row->pos_pk);
377  }
378 
379  return false;
380  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ getLastPostString()

ilForumTopic::getLastPostString ( )

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

References $last_post_string.

Referenced by updateMergedThread().

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

◆ getModeratorRight()

ilForumTopic::getModeratorRight ( )

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

References $is_moderator.

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

◆ getNestedSetPostChildren()

ilForumTopic::getNestedSetPostChildren (   $pos_id = null,
  $expandedNodes = array() 
)

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

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

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

◆ getNumNewPosts()

ilForumTopic::getNumNewPosts ( )
Returns
int

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

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

1182  {
1183  return $this->num_new_posts;
1184  }
+ Here is the caller graph for this function:

◆ getNumPosts()

ilForumTopic::getNumPosts ( )
Returns
int

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

References $num_posts.

Referenced by ilForumTopicTableGUI\initMergeThreadsTable(), and updateMergedThread().

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

◆ getNumUnreadPosts()

ilForumTopic::getNumUnreadPosts ( )
Returns
int

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

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

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

◆ getOrderDirection()

ilForumTopic::getOrderDirection ( )

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

References $orderDirection.

Referenced by getPostTree().

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

◆ getOrderField()

ilForumTopic::getOrderField ( )

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

References $orderField.

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

◆ 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, 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  }
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:

◆ getSorting()

ilForumTopic::getSorting ( )

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

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

◆ getSubject()

ilForumTopic::getSubject ( )

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

References $subject.

Referenced by ilForumTopicTableGUI\initMergeThreadsTable(), updateMergedThread(), and updateThreadTitle().

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

◆ getThrAuthorId()

ilForumTopic::getThrAuthorId ( )
Returns
int

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

References $thr_author_id.

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

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

◆ getUserAlias()

ilForumTopic::getUserAlias ( )

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

References $user_alias.

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

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

◆ getUserNotificationEnabled()

ilForumTopic::getUserNotificationEnabled ( )
Returns
boolean

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

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

1218  {
1219  return $this->user_notification_enabled;
1220  }
+ Here is the caller graph for this function:

◆ getVisits()

ilForumTopic::getVisits ( )

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

References $visits.

Referenced by ilForumTopicTableGUI\initMergeThreadsTable(), and updateMergedThread().

1057  {
1058  return $this->visits;
1059  }
+ 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.

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  }

◆ isClosed()

ilForumTopic::isClosed ( )

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

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

1073  {
1074  return $this->is_closed == 1 ? true : false;
1075  }
+ Here is the caller graph for this function:

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

References $result.

Referenced by enableNotification().

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

◆ isSticky()

ilForumTopic::isSticky ( )

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

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

1065  {
1066  return $this->is_sticky == 1 ? true : false;
1067  }
+ Here is the caller graph for this function:

◆ lookupForumIdByTopicId()

static ilForumTopic::lookupForumIdByTopicId (   $a_topic_id)
static

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

References $ilDB, $res, and $row.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

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

866  {
867  if ($this->id && !$this->is_sticky)
868  {
869  $statement = $this->db->manipulateF('
870  UPDATE frm_threads
871  SET is_sticky = %s
872  WHERE thr_pk = %s',
873  array('integer', 'integer'),
874  array('1', $this->id));
875 
876  $this->is_sticky = 1;
877 
878  return true;
879  }
880 
881  return false;
882  }

◆ 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 $ilDB, $posts, ilForum\_lookupObjIdForForumId(), DB_FETCHMODE_ASSOC, getAllPosts(), ilNewsItem\getFirstNewsIdForContext(), and ilDB\LOCK_WRITE.

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  $this->db->lockTables(
569  array(
570  0 => array('name' => 'frm_user_read', 'type' => ilDB::LOCK_WRITE),
571  1 => array('name' => 'frm_thread_access', 'type' => ilDB::LOCK_WRITE)
572  )
573  );
574 
575  $this->db->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, $this->id));
580 
581  $this->db->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, $this->id));
587 
588  $this->db->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, $this->id));
593 
594  $this->db->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, $this->id));
600 
601  $this->db->unlockTables();
602 
603  $this->db->manipulateF('
604  UPDATE frm_posts
605  SET pos_top_fk = %s
606  WHERE pos_thr_fk = %s',
607  array('integer', 'integer'),
608  array($new_pk, $this->id));
609 
610  // update all related news
611  $posts = $ilDB->queryf('
612  SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
613  array('integer'), array($this->id));
614 
615  $old_obj_id = ilForum::_lookupObjIdForForumId($old_pk);
616 
617  $new_obj_id = ilForum::_lookupObjIdForForumId($new_pk);
618 
619  while($post = $posts->fetchRow(DB_FETCHMODE_ASSOC))
620  {
621  include_once("./Services/News/classes/class.ilNewsItem.php");
622  $news_id = ilNewsItem::getFirstNewsIdForContext($old_obj_id,
623  "frm", $post["pos_pk"], "pos");
624  $news_item = new ilNewsItem($news_id);
625  $news_item->setContextObjId($new_obj_id);
626  $news_item->update();
627  //echo "<br>-".$post["pos_pk"]."-".$old_obj_id."-".$new_obj_id."-";
628  }
629 
630  return count($nodes);
631  }
632 
633  return 0;
634  }
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.
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
const LOCK_WRITE
Definition: class.ilDB.php:30
This class handles all operations on files for the forum object.
global $ilDB
+ 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, and DB_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 
207  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
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  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ 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 940 of file class.ilForumTopic.php.

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

◆ setAverageRating()

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

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

References $average_rating.

Referenced by assignData().

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

◆ setChangeDate()

ilForumTopic::setChangeDate (   $a_changedate)

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

Referenced by assignData().

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

◆ setClosed()

ilForumTopic::setClosed (   $a_closed)

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

Referenced by assignData().

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

◆ setCreateDate()

ilForumTopic::setCreateDate (   $a_createdate)

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

Referenced by assignData().

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

◆ setDisplayUserId()

ilForumTopic::setDisplayUserId (   $a_user_id)

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

Referenced by assignData().

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

◆ setForumId()

ilForumTopic::setForumId (   $a_forum_id)

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

Referenced by assignData().

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

◆ setId()

ilForumTopic::setId (   $a_id)

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

Referenced by assignData().

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

◆ setImportName()

ilForumTopic::setImportName (   $a_import_name)

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

Referenced by assignData().

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

◆ setLastPostString()

ilForumTopic::setLastPostString (   $a_last_post)

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

Referenced by assignData().

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

◆ setModeratorRight()

ilForumTopic::setModeratorRight (   $bool)

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

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

◆ setNumNewPosts()

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

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

Referenced by assignData().

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

◆ setNumPosts()

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

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

Referenced by assignData().

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

◆ setNumUnreadPosts()

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

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

Referenced by assignData().

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

◆ setOrderDirection()

ilForumTopic::setOrderDirection (   $direction)

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

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

◆ setOrderField()

ilForumTopic::setOrderField (   $a_order_field)

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

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

◆ setSticky()

ilForumTopic::setSticky (   $a_sticky)

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

Referenced by assignData().

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

◆ setSubject()

ilForumTopic::setSubject (   $a_subject)

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

Referenced by assignData().

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

◆ setThrAuthorId()

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

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

References $thr_author_id.

Referenced by assignData().

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

◆ setUserAlias()

ilForumTopic::setUserAlias (   $a_user_alias)

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

Referenced by assignData().

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

◆ setUserNotificationEnabled()

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

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

Referenced by assignData().

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

◆ setVisits()

ilForumTopic::setVisits (   $a_visits)

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

Referenced by assignData().

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

891  {
892  if ($this->id && $this->is_sticky)
893  {
894  $statement = $this->db->manipulateF('
895  UPDATE frm_threads
896  SET is_sticky = %s
897  WHERE thr_pk = %s',
898  array('integer', 'integer'),
899  array('0', $this->id));
900 
901  $this->is_sticky = 0;
902 
903  return true;
904  }
905 
906  return false;
907  }

◆ update()

ilForumTopic::update ( )

Updates an existing topic.

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

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

159  {
160  if ($this->id)
161  {
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  }

◆ updateMergedThread()

ilForumTopic::updateMergedThread ( )

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

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

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

◆ updateThreadTitle()

ilForumTopic::updateThreadTitle ( )

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

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

1141  {
1142  global $ilDB;
1143 
1144  $ilDB->update('frm_threads',
1145  array('thr_subject' => array('text',$this->getSubject())),
1146  array('thr_pk'=> array('integer', $this->getId()))
1147  );
1148  }
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.

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  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']

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 = '0000-00-00 00:00:00'
private

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

Referenced by getChangeDate().

◆ $createdate

ilForumTopic::$createdate = '0000-00-00 00:00:00'
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(), and getId().

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