ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilForumTopic Class Reference
+ Collaboration diagram for ilForumTopic:

Public Member Functions

 __construct ($a_id=0, $a_is_moderator=false)
 Constructor.
 insert ()
 Inserts the object data into database.
 update ()
 Updates an existing topic.
 reload ()
 Calls the private method read() to load the topic data from database into the object.
 getFirstPostId ()
 Fetches the primary key of the first post node of the current topic from database and returns it.
 updateVisits ()
 Updates the visit counter of the current topic.
 getLastThreadAccess ($a_user_id)
 Fetches and returns a timestamp of the last topic access.
 countPosts ()
 Fetches and returns the number of posts for the given user id.
 countActivePosts ()
 Fetches and returns the number of active posts for the given user id.
 countReadPosts ($a_user_id)
 Fetches and returns the number of read posts for the given user id.
 countReadActivePosts ($a_user_id)
 Fetches and returns the number of read active posts for the given user id.
 countNewPosts ($a_user_id)
 Fetches and returns the number of new posts for the given user id.
 countNewActivePosts ($a_user_id)
 Fetches and returns the number of new active posts for the given user id.
 getFirstPostNode ()
 Fetches and returns an object of the first post in the current topic.
 getLastPost ()
 Fetches and returns an object of the last post in the current topic.
 getLastActivePost ()
 Fetches and returns an object of the last active post in the current topic.
 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.
 movePosts ($old_obj_id, $old_pk, $new_obj_id, $new_pk)
 Moves all posts within the current thread to a new forum.
 getPostChilds ($a_node_id, $type= '')
 Fetches and returns an array of posts from the post tree, starting with the node id passed by the first paramter.
 isNotificationEnabled ($a_user_id)
 Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (result == 0).
 enableNotification ($a_user_id)
 Enable a user's notification about new posts in a thread.
 disableNotification ($a_user_id)
 Disable a user's notification about new posts in a thread.
 makeSticky ()
 Sets the current topic sticky.
 unmakeSticky ()
 Sets the current topic non-sticky.
 close ()
 Closes the current topic.
 reopen ()
 Reopens the current topic.
 setId ($a_id)
 getId ()
 setForumId ($a_forum_id)
 getForumId ()
 setUserId ($a_user_id)
 getUserId ()
 setUserAlias ($a_user_alias)
 getUserAlias ()
 setSubject ($a_subject)
 getSubject ()
 setCreateDate ($a_createdate)
 getCreateDate ()
 setChangeDate ($a_changedate)
 getChangeDate ()
 setImportName ($a_import_name)
 getImportName ()
 setNumPosts ($a_num_posts)
 getNumPosts ()
 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 ()

Private Member Functions

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

Private Attributes

 $id = 0
 $forum_id = 0
 $frm_obj_id = 0
 $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

Detailed Description

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

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

Constructor & Destructor Documentation

ilForumTopic::__construct (   $a_id = 0,
  $a_is_moderator = 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)

public

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

References read().

{
global $ilDB;
$this->is_moderator = $a_is_moderator;
$this->db = $ilDB;
$this->id = $a_id;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilForumTopic::close ( )

Closes the current topic.

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

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

{
if ($this->id && !$this->is_closed)
{
$query = "UPDATE frm_threads
SET is_closed = '1'
WHERE 1
AND thr_pk = ".$this->db->quote($this->id)." ";
$this->db->query($query);
$this->is_closed = 1;
return true;
}
return false;
}
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 304 of file class.ilForumTopic.php.

References $res, and DB_FETCHMODE_ASSOC.

{
global $ilUser;
$query = "SELECT COUNT(*) AS cnt
FROM frm_posts
WHERE 1
AND (pos_status = '1' OR (pos_status = '0' AND pos_usr_id = ".$this->db->quote($ilUser->getId())."))
AND pos_thr_fk = ".$this->db->quote($this->id)." ";
$res = $this->db->query($query);
$rec = $res->fetchRow(DB_FETCHMODE_ASSOC);
return $rec['cnt'];
}
ilForumTopic::countNewActivePosts (   $a_user_id)

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

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

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

References $res, DB_FETCHMODE_ASSOC, and getLastThreadAccess().

{
global $ilUser;
$timest = $this->getLastThreadAccess($a_user_id);
$query = "SELECT COUNT(pos_pk) AS cnt
FROM frm_posts
LEFT JOIN frm_user_read ON post_id = pos_pk AND usr_id = ".$this->db->quote($a_user_id)."
WHERE 1
AND pos_thr_fk = ".$this->db->quote($this->id)."
AND (pos_date > '".date('Y-m-d H:i:s', $timest)."' OR pos_update > '".date('Y-m-d H:i:s', $timest)."')
AND pos_usr_id != ".$this->db->quote($a_user_id)."
AND (pos_status = '1' OR (pos_status = '0' AND pos_usr_id = ".$this->db->quote($ilUser->getId())."))
AND usr_id IS NULL ";
$res = $this->db->query($query);
$rec = $res->fetchRow(DB_FETCHMODE_ASSOC);
return $rec['cnt'];
}

+ Here is the call graph for this function:

ilForumTopic::countNewPosts (   $a_user_id)

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

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

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

References $res, DB_FETCHMODE_ASSOC, and getLastThreadAccess().

{
$timest = $this->getLastThreadAccess($a_user_id);
$query = "SELECT COUNT(pos_pk) AS cnt
FROM frm_posts
LEFT JOIN frm_user_read ON post_id = pos_pk AND usr_id = ".$this->db->quote($a_user_id)."
WHERE 1
AND pos_thr_fk = ".$this->db->quote($this->id)."
AND (pos_date > '".date('Y-m-d H:i:s', $timest)."' OR pos_update > '".date('Y-m-d H:i:s', $timest)."')
AND pos_usr_id != ".$this->db->quote($a_user_id)."
AND usr_id IS NULL ";
$res = $this->db->query($query);
$rec = $res->fetchRow(DB_FETCHMODE_ASSOC);
return $rec['cnt'];
}

+ Here is the call graph for this function:

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

References $res, and DB_FETCHMODE_ASSOC.

{
$query = "SELECT COUNT(*) AS cnt
FROM frm_posts
WHERE 1
AND pos_thr_fk = ".$this->db->quote($this->id)." ";
$res = $this->db->query($query);
$rec = $res->fetchRow(DB_FETCHMODE_ASSOC);
return $rec['cnt'];
}
ilForumTopic::countReadActivePosts (   $a_user_id)

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

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

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

References $res, and DB_FETCHMODE_ASSOC.

{
global $ilUser;
$query = "SELECT COUNT(*) AS cnt
FROM frm_user_read
INNER JOIN frm_posts ON pos_pk = post_id
WHERE 1
AND usr_id = ".$this->db->quote($a_user_id)."
AND thread_id = ".$this->db->quote($this->id)."
AND (pos_status = '1' OR (pos_status = '0' AND pos_usr_id = ".$this->db->quote($ilUser->getId())."))";
$res = $this->db->query($query);
$rec = $res->fetchRow(DB_FETCHMODE_ASSOC);
return $rec['cnt'];
}
ilForumTopic::countReadPosts (   $a_user_id)

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

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

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

References $res, and DB_FETCHMODE_ASSOC.

{
$query = "SELECT COUNT(*) AS cnt
FROM frm_user_read
INNER JOIN frm_posts ON pos_pk = post_id
WHERE 1
AND usr_id = ".$this->db->quote($a_user_id)."
AND thread_id = ".$this->db->quote($this->id)." ";
$res = $this->db->query($query);
$rec = $res->fetchRow(DB_FETCHMODE_ASSOC);
return $rec['cnt'];
}
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 781 of file class.ilForumTopic.php.

{
if ($this->id && $a_user_id)
{
$query = "DELETE FROM frm_notification
WHERE 1
AND user_id = ".$this->db->quote($a_user_id)."
AND thread_id = ".$this->db->quote($this->id)." ";
$this->db->query($query);
return false;
}
return false;
}
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 755 of file class.ilForumTopic.php.

References isNotificationEnabled().

{
if ($this->id && $a_user_id)
{
if (!$this->isNotificationEnabled($a_user_id))
{
$query = "INSERT INTO frm_notification (user_id, thread_id) VALUES (
".$this->db->quote($a_user_id).", ".$this->db->quote($this->id).")";
$this->db->query($query);
return true;
}
return false;
}
return false;
}

+ Here is the call graph for this function:

ilForumTopic::getAllPosts ( )

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

References $posts, $res, and DB_FETCHMODE_OBJECT.

Referenced by movePosts().

{
$posts = array();
if($this->id)
{
$query = "SELECT pos_pk
FROM frm_posts
WHERE 1
AND pos_thr_fk = ".$this->db->quote($this->id);
$res = $this->db->query($query);
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$posts[$row->pos_pk] = $row;
}
}
return is_array($posts) ? $posts : array();
}

+ Here is the caller graph for this function:

ilForumTopic::getChangeDate ( )

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

References $changedate.

{
}
ilForumTopic::getCreateDate ( )

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

References $createdate.

{
}
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 211 of file class.ilForumTopic.php.

References $res, and DB_FETCHMODE_OBJECT.

{
$query = "SELECT *
FROM frm_posts_tree
WHERE 1
AND thr_fk = ".$this->db->quote($this->id)."
AND parent_pos = '0' ";
$res = $this->db->query($query);
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
return $row->pos_fk ? $row->pos_fk : 0;
}
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 433 of file class.ilForumTopic.php.

References $res, and DB_FETCHMODE_OBJECT.

Referenced by ilForumExportGUI\exportHTML(), and ilForumExportGUI\printThread().

{
$query = "SELECT pos_pk
FROM frm_posts
INNER JOIN frm_posts_tree ON pos_fk = pos_pk
WHERE 1
AND parent_pos = '0'
AND thr_fk = ".$this->db->quote($this->id)." ";
$res = $this->db->query($query);
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
return new ilForumPost($row->pos_pk);
}

+ Here is the caller graph for this function:

ilForumTopic::getForumId ( )

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

References $forum_id.

{
}
ilForumTopic::getFrmObjId ( )

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

References $frm_obj_id.

{
}
ilForumTopic::getId ( )

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

References $id.

Referenced by ilForumExplorer\ilForumExplorer().

{
return $this->id;
}

+ Here is the caller graph for this function:

ilForumTopic::getImportName ( )

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

References $import_name.

{
}
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 482 of file class.ilForumTopic.php.

References $res, and DB_FETCHMODE_OBJECT.

{
global $ilUser;
if ($this->id)
{
$query = "SELECT pos_pk
FROM frm_posts
WHERE 1
AND pos_thr_fk = ".$this->db->quote($this->id)."
AND (pos_status = '1' OR (pos_status = '0' AND pos_usr_id = ".$this->db->quote($ilUser->getId())."))
ORDER BY pos_date DESC
LIMIT 1";
$res = $this->db->query($query);
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
return new ilForumPost($row->pos_pk);
}
return false;
}
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 455 of file class.ilForumTopic.php.

References $res, and DB_FETCHMODE_OBJECT.

{
if ($this->id)
{
$query = "SELECT pos_pk
FROM frm_posts
WHERE 1
AND pos_thr_fk = ".$this->db->quote($this->id)."
ORDER BY pos_date DESC
LIMIT 1";
$res = $this->db->query($query);
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
return new ilForumPost($row->pos_pk);
}
return false;
}
ilForumTopic::getLastPostString ( )

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

References $last_post_string.

ilForumTopic::getLastThreadAccess (   $a_user_id)

Fetches and returns a timestamp of the last topic access.

Parameters
integer$a_user_iduser id
Returns
integer timestamp of last thread access public

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

References $res, and DB_FETCHMODE_OBJECT.

Referenced by countNewActivePosts(), and countNewPosts().

{
$query = "SELECT *
FROM frm_thread_access
WHERE 1
AND thread_id = ".$this->db->quote($this->id)."
AND usr_id = ".$this->db->quote($a_user_id)." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$last_access = $row->access_old;
}
if (!$last_access)
{
$last_access = NEW_DEADLINE;
}
return $last_access;
}

+ Here is the caller graph for this function:

ilForumTopic::getModeratorRight ( )

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

References $orderField.

{
}
ilForumTopic::getNumPosts ( )

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

References $num_posts.

{
}
ilForumTopic::getOrderField ( )

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

References $orderField.

{
}
ilForumTopic::getPostChilds (   $a_node_id,
  $type = '' 
)

Fetches and returns an array of posts from the post tree, starting with the node id passed by the first paramter.

If the second parameter $type is set to 'explorer', the data will be returned different because of compatibility issues in explorer view.

Parameters
integer$a_node_idid of starting node
string$type'explorer' or '' (optional)
Returns
array array of posts public

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

References DB_FETCHMODE_OBJECT.

{
global $ilUser;
$childs = array();
$count = 0;
$query = "SELECT pos_pk
FROM frm_posts_tree
INNER JOIN frm_posts ON frm_posts.pos_pk = frm_posts_tree.pos_fk
WHERE 1
AND frm_posts_tree.parent_pos = ".$this->db->quote($a_node_id)."
AND frm_posts_tree.thr_fk = ".$this->db->quote($this->id)."
ORDER BY frm_posts_tree.lft DESC";
$r = $this->db->query($query);
$count = $r->numRows();
if ($count > 0)
{
$active_count = 0;
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$tmp_obj = new ilForumPost($row->pos_pk);
if ($this->is_moderator ||
($tmp_obj->isActivated() || (!$tmp_obj->isActivated() && $tmp_obj->getUserId() == $ilUser->getId())))
{
$childs[] = ($type == 'explorer' ? $tmp_obj->getDataAsArrayForExplorer() : $tmp_obj->getDataAsArray());
++$active_count;
}
unset($tmp_obj);
}
// mark the last child node (important for display)
if ($active_count > 0) $childs[$active_count - 1]['last'] = true;
return $childs;
}
else
{
return $childs;
}
}
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 535 of file class.ilForumTopic.php.

References $posts, $res, DB_FETCHMODE_OBJECT, ilForumPost\getLft(), ilForumPost\getRgt(), and ilForumPost\getThreadId().

{
global $ilUser;
$this->posts = array();
$query = "SELECT pos_pk
FROM frm_posts_tree
INNER JOIN frm_posts ON pos_fk = pos_pk
WHERE 1
AND lft BETWEEN ".$this->db->quote($a_post_node->getLft())." AND ".$this->db->quote($a_post_node->getRgt())."
AND thr_fk = ".$this->db->quote($a_post_node->getThreadId());
if ($this->orderField == "frm_posts_tree.date")
{
$query .= " ORDER BY ".$this->orderField." ASC";
}
else if ($this->orderField != "")
{
$query .= " ORDER BY ".$this->orderField." DESC";
}
$res = $this->db->query($query);
$deactivated = array();
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$tmp_object = new ilForumPost($row->pos_pk);
if (!$this->is_moderator)
{
if (!$tmp_object->isActivated() && $tmp_object->getUserId() != $ilUser->getId())
{
$deactivated[] = $tmp_object;
unset($tmp_object);
continue;
}
$continue = false;
foreach ($deactivated as $deactivated_node)
{
if ($deactivated_node->getLft() < $tmp_object->getLft() && $deactivated_node->getRgt() > $tmp_object->getLft())
{
$deactivated[] = $tmp_object;
unset($tmp_object);
$continue = true;
break;
}
}
if ($continue) continue;
}
$this->posts[] = $tmp_object;
unset($tmp_object);
}
return $this->posts;
}

+ Here is the call graph for this function:

ilForumTopic::getSubject ( )

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

References $subject.

{
}
ilForumTopic::getUserAlias ( )

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

References $user_alias.

{
}
ilForumTopic::getUserId ( )

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

References $user_id.

{
}
ilForumTopic::getVisits ( )

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

References $visits.

{
return $this->visits;
}
ilForumTopic::insert ( )

Inserts the object data into database.

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

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

{
if ($this->forum_id)
{
$query = "INSERT INTO frm_threads "
."SET "
."thr_top_fk = " . $this->db->quote($this->forum_id). ", "
."thr_usr_id = " . $this->db->quote($this->user_id). ", "
."thr_usr_alias = " . $this->db->quote($this->user_alias). ", "
."thr_subject = " . $this->db->quote($this->subject). ", "
."thr_date = " . $this->db->quote($this->createdate). ", "
."thr_update = " . $this->db->quote($this->changedate). ", "
."thr_num_posts = " . $this->db->quote($this->num_posts). ", "
."thr_last_post = " . $this->db->quote($this->last_post_string). ", "
."is_sticky = " . $this->db->quote($this->is_sticky). ", "
."is_closed = " . $this->db->quote($this->is_closed). ", "
."import_name = " . $this->db->quote($this->import_name). " ";
$this->db->query($query);
$this->id = $this->db->getLastInsertId();
return true;
}
return false;
}
ilForumTopic::isClosed ( )

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

{
return $this->is_closed == 1 ? true : false;
}
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 729 of file class.ilForumTopic.php.

References $result.

Referenced by enableNotification().

{
if ($this->id && $a_user_id)
{
$query = $this->db->prepare("SELECT COUNT(*) AS cnt FROM frm_notification WHERE user_id = ? AND thread_id = ?",
array("integer", "integer"));
$result = $this->db->execute($query, array($a_user_id, $this->id));
while($record = $this->db->fetchAssoc($result))
{
return (bool)$record['cnt'];
}
return false;
}
return false;
}

+ Here is the caller graph for this function:

ilForumTopic::isSticky ( )

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

{
return $this->is_sticky == 1 ? true : false;
}
ilForumTopic::makeSticky ( )

Sets the current topic sticky.

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

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

{
if ($this->id && !$this->is_sticky)
{
$query = "UPDATE frm_threads
SET is_sticky = '1'
WHERE 1
AND thr_pk = ".$this->db->quote($this->id)." ";
$this->db->query($query);
$this->is_sticky = 1;
return true;
}
return false;
}
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 605 of file class.ilForumTopic.php.

References $posts, $res, ilForum\_lookupObjIdForForumId(), DB_FETCHMODE_ASSOC, getAllPosts(), and ilNewsItem\getFirstNewsIdForContext().

{
global $ilDB;
if ($this->id)
{
$nodes = $this->getAllPosts();
if(is_array($nodes))
{
// Move attachments
foreach($nodes as $node)
{
$file_obj = new ilFileDataForum((int)$old_obj_id, (int)$node->pos_pk);
$file_obj->moveFilesOfPost((int)$new_obj_id);
unset($file_obj);
}
}
$query = "UPDATE frm_user_read
SET obj_id = ".$ilDB->quote($new_obj_id)."
WHERE 1
AND thread_id = ".$ilDB->quote($this->id)." ";
$res = $ilDB->query($query);
$query = "UPDATE frm_thread_access
SET obj_id = ".$ilDB->quote($new_obj_id)."
WHERE 1
AND thread_id = ".$ilDB->quote($this->id)." ";
$res = $ilDB->query($query);
$query = "UPDATE frm_posts
SET pos_top_fk = ".$ilDB->quote($new_pk)."
WHERE 1
AND pos_thr_fk = ".$ilDB->quote($this->id)." ";
$res = $ilDB->query($query);
// update all related news
$posts = $ilDB->query("SELECT * FROM frm_posts ".
" WHERE pos_thr_fk = ".$ilDB->quote($this->id));
$old_obj_id = ilForum::_lookupObjIdForForumId($old_pk);
$new_obj_id = ilForum::_lookupObjIdForForumId($new_pk);
while($post = $posts->fetchRow(DB_FETCHMODE_ASSOC))
{
include_once("./Services/News/classes/class.ilNewsItem.php");
$news_id = ilNewsItem::getFirstNewsIdForContext($old_obj_id,
"frm", $post["pos_pk"], "pos");
$news_item = new ilNewsItem($news_id);
$news_item->setContextObjId($new_obj_id);
$news_item->update();
//echo "<br>-".$post["pos_pk"]."-".$old_obj_id."-".$new_obj_id."-";
}
return count($nodes);
}
return 0;
}

+ Here is the call graph for this function:

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

Referenced by __construct(), and reload().

{
if ($this->id)
{
$query = "SELECT frm_threads.*, top_frm_fk AS frm_obj_id
FROM frm_threads
INNER JOIN frm_data ON top_pk = thr_top_fk
WHERE 1
AND thr_pk = " . $this->db->quote($this->id) . " ";
$row = $this->db->getrow($query);
if (is_object($row))
{
$this->thr_pk = $row->pos_pk;
$this->forum_id = $row->thr_top_fk;
$this->user_id = $row->thr_usr_id;
$this->user_alias = $row->thr_usr_alias;
$this->subject = $row->thr_subject;
$this->createdate = $row->thr_date;
$this->changedate = $row->thr_update;
$this->import_name = $row->import_name;
$this->num_posts = $row->thr_num_posts;
$this->last_post_string = $row->thr_last_post;
$this->visits = $row->visits;
$this->is_sticky = $row->is_sticky;
$this->is_closed = $row->is_closed;
$this->frm_obj_id = $row->frm_obj_id;
return true;
}
return false;
}
return false;
}

+ Here is the caller graph for this function:

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

References read().

{
return $this->read();
}

+ Here is the call graph for this function:

ilForumTopic::reopen ( )

Reopens the current topic.

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

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

{
if ($this->id && $this->is_closed)
{
$query = "UPDATE frm_threads
SET is_closed = '0'
WHERE 1
AND thr_pk = ".$this->db->quote($this->id)." ";
$this->db->query($query);
$this->is_closed = 0;
return true;
}
return false;
}
ilForumTopic::setChangeDate (   $a_changedate)

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

{
$this->changedate = $a_changedate;
}
ilForumTopic::setClosed (   $a_closed)

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

{
$this->is_closed = $a_closed;
}
ilForumTopic::setCreateDate (   $a_createdate)

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

{
$this->createdate = $a_createdate;
}
ilForumTopic::setForumId (   $a_forum_id)

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

{
$this->forum_id = $a_forum_id;
}
ilForumTopic::setId (   $a_id)

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

{
$this->id = $a_id;
}
ilForumTopic::setImportName (   $a_import_name)

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

{
$this->import_name = $a_import_name;
}
ilForumTopic::setLastPostString (   $a_last_post)

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

{
$this->last_post_string = $a_last_post;
}
ilForumTopic::setModeratorRight (   $bool)

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

{
$this->is_moderator = $bool;
}
ilForumTopic::setNumPosts (   $a_num_posts)

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

{
$this->num_posts = $a_num_posts;
}
ilForumTopic::setOrderField (   $a_order_field)

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

{
$this->orderField = $a_order_field;
}
ilForumTopic::setSticky (   $a_sticky)

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

{
$this->is_sticky = $a_sticky;
}
ilForumTopic::setSubject (   $a_subject)

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

{
$this->subject = $a_subject;
}
ilForumTopic::setUserAlias (   $a_user_alias)

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

{
$this->user_alias = $a_user_alias;
}
ilForumTopic::setUserId (   $a_user_id)

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

{
$this->user_id = $a_user_id;
}
ilForumTopic::setVisits (   $a_visits)

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

{
$this->visits = $a_visits;
}
ilForumTopic::unmakeSticky ( )

Sets the current topic non-sticky.

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

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

{
if ($this->id && $this->is_sticky)
{
$query = "UPDATE frm_threads
SET is_sticky = '0'
WHERE 1
AND thr_pk = ".$this->db->quote($this->id)." ";
$this->db->query($query);
$this->is_sticky = 0;
return true;
}
return false;
}
ilForumTopic::update ( )

Updates an existing topic.

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

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

{
if ($this->id)
{
$query = "UPDATE frm_threads "
."SET "
."thr_top_fk = " . $this->db->quote($this->forum_id). ", "
."thr_subject = " . $this->db->quote($this->subject). ", "
."thr_update = " . $this->db->quote($this->changedate). ", "
."thr_num_posts = " . $this->db->quote($this->num_posts). ", "
."thr_last_post = " . $this->db->quote($this->last_post_string). " "
."WHERE thr_pk = ". $this->db->quote($this->id) ." ";
$this->db->query($query);
return true;
}
return false;
}
ilForumTopic::updateVisits ( )

Updates the visit counter of the current topic.

public

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

References $_SESSION.

{
$checkTime = time() - (60 * 60);
if ($_SESSION['frm_visit_frm_threads_'.$this->id] < $checkTime)
{
$_SESSION['frm_visit_frm_threads_'.$this->id] = time();
$query = "UPDATE frm_threads
SET
visits = visits + 1
WHERE thr_pk = ".$this->db->quote($this->id)." ";
$this->db->query($query);
}
return true;
}

Field Documentation

ilForumTopic::$changedate = '0000-00-00 00:00:00'
private

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

Referenced by getChangeDate().

ilForumTopic::$createdate = '0000-00-00 00:00:00'
private

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

Referenced by getCreateDate().

ilForumTopic::$db = null
private

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

ilForumTopic::$forum_id = 0
private

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

Referenced by getForumId().

ilForumTopic::$frm_obj_id = 0
private

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

Referenced by getFrmObjId().

ilForumTopic::$id = 0
private

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

Referenced by getId().

ilForumTopic::$import_name = ''
private

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

Referenced by getImportName().

ilForumTopic::$is_closed = 0
private

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

ilForumTopic::$is_moderator = false
private

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

ilForumTopic::$is_sticky = 0
private

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

ilForumTopic::$last_post_string = ''
private

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

Referenced by getLastPostString().

ilForumTopic::$num_posts = 0
private

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

Referenced by getNumPosts().

ilForumTopic::$orderField = ''
private

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

Referenced by getModeratorRight(), and getOrderField().

ilForumTopic::$posts = array()
private

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

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

ilForumTopic::$subject = ''
private

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

Referenced by getSubject().

ilForumTopic::$user_alias = ''
private

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

Referenced by getUserAlias().

ilForumTopic::$user_id = 0
private

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

Referenced by getUserId().

ilForumTopic::$visits = 0
private

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

Referenced by getVisits().


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