ILIAS  Release_4_0_x_branch Revision 61816
 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 ()

Static Public Member Functions

static _lookupTitle ($a_topic_id)
 Looks up the title/subject of a topic/thread.

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 $ilDB, and 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

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

References $ilDB, $res, and $row.

Referenced by ilObjForumGUI\confirmDeleteThreads(), and ilObjForumGUI\moveThreadsObject().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT thr_subject
FROM frm_threads
WHERE thr_pk = %s',
array('integer'), array($a_topic_id));
$row = $ilDB->fetchObject($res);
if(is_object($row))
{
return $row->thr_subject;
}
return '';
}

+ Here is the caller graph for this function:

ilForumTopic::close ( )

Closes the current topic.

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

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

{
if ($this->id && !$this->is_closed)
{
$statement = $this->db->manipulateF('
UPDATE frm_threads
SET is_closed = %s
WHERE thr_pk = %s',
array('integer', 'integer'),
array('1', $this->id));
$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 341 of file class.ilForumTopic.php.

References $id, $res, and DB_FETCHMODE_ASSOC.

{
global $ilUser;
$res = $this->db->queryf('
SELECT COUNT(*) cnt
FROM frm_posts
WHERE (pos_status = %s
OR (pos_status = %s AND pos_usr_id = %s))
AND pos_thr_fk = %s',
array('integer', 'integer', 'integer', 'integer'), array('1', '0', $ilUser->getId(), $this->id));
$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 447 of file class.ilForumTopic.php.

References $res, DB_FETCHMODE_ASSOC, and getLastThreadAccess().

{
global $ilUser;
$timest = $this->getLastThreadAccess($a_user_id);
$res = $this->db->queryf('
SELECT COUNT(pos_pk) cnt
FROM frm_posts
LEFT JOIN frm_user_read ON post_id = pos_pk AND usr_id = %s
WHERE pos_thr_fk = %s
AND (pos_date > %s OR pos_update > %s)
AND pos_usr_id != %s
AND (pos_status = %s OR (pos_status = %s AND pos_usr_id = %s))
AND usr_id IS NULL',
array( 'integer',
'integer',
'timestamp',
'timestamp',
'integer',
'integer',
'integer',
'integer'),
array( $a_user_id,
$this->id,
date('Y-m-d H:i:s', $timest),
date('Y-m-d H:i:s', $timest),
$a_user_id,
'1',
'0',
$ilUser->getId()
));
$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 415 of file class.ilForumTopic.php.

References $res, DB_FETCHMODE_ASSOC, and getLastThreadAccess().

{
$timest = $this->getLastThreadAccess($a_user_id);
$res = $this->db->queryf('
SELECT COUNT(pos_pk) cnt
FROM frm_posts
LEFT JOIN frm_user_read ON post_id = pos_pk AND usr_id = %s
WHERE pos_thr_fk = %s
AND (pos_date > %s OR pos_update > %s)
AND pos_usr_id != %s
AND usr_id IS NULL',
array('integer', 'integer', 'timestamp','timestamp', 'integer'),
array( $a_user_id,
$this->id,
date('Y-m-d H:i:s', $timest),
date('Y-m-d H:i:s', $timest),
$a_user_id
));
$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 321 of file class.ilForumTopic.php.

References $res, and DB_FETCHMODE_ASSOC.

{
$res = $this->db->queryf('
SELECT COUNT(*) cnt
FROM frm_posts
WHERE pos_thr_fk = %s',
array('integer'), array($this->id));
$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 388 of file class.ilForumTopic.php.

References $res, and DB_FETCHMODE_ASSOC.

{
global $ilUser;
$res = $this->db->queryf('
SELECT COUNT(*) cnt
FROM frm_user_read
INNER JOIN frm_posts ON pos_pk = post_id
WHERE usr_id = %s
AND thread_id = %s
AND (pos_status = %s
OR (pos_status = %s AND pos_usr_id = %s))',
array('integer', 'integer', 'integer', 'integer', 'integer'),
array($a_user_id, $this->id, '1', '0', $ilUser->getId()));
$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 365 of file class.ilForumTopic.php.

References $res, and DB_FETCHMODE_ASSOC.

{
$res = $this->db->queryf('
SELECT COUNT(*) cnt FROM frm_user_read
INNER JOIN frm_posts ON pos_pk = post_id
WHERE usr_id = %s
AND thread_id = %s',
array('integer', 'integer'),
array($a_user_id, $this->id));
$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 857 of file class.ilForumTopic.php.

{
if ($this->id && $a_user_id)
{
$statement = $this->db->manipulateF('
DELETE FROM frm_notification
WHERE user_id = %s
AND thread_id = %s',
array('integer', 'integer'),
array($a_user_id, $this->id));
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 826 of file class.ilForumTopic.php.

References isNotificationEnabled().

{
if ($this->id && $a_user_id)
{
if (!$this->isNotificationEnabled($a_user_id))
{
$nextId = $this->db->nextId('frm_notification');
$statement = $this->db->manipulateF('
INSERT INTO frm_notification
( notification_id,
user_id,
thread_id
)
VALUES(%s, %s, %s)',
array('integer', 'integer', 'integer'),
array($nextId, $a_user_id, $this->id));
return true;
}
return false;
}
return false;
}

+ Here is the call graph for this function:

ilForumTopic::getAllPosts ( )

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

References $posts, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by movePosts().

{
$posts = array();
if($this->id)
{
$res = $this->db->queryf('
SELECT pos_pk
FROM frm_posts
WHERE pos_thr_fk = %s',
array('integer'),
array($this->id));
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 1029 of file class.ilForumTopic.php.

References $changedate.

{
}
ilForumTopic::getCreateDate ( )

Definition at line 1018 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 250 of file class.ilForumTopic.php.

References $res, $row, and DB_FETCHMODE_OBJECT.

{
$res = $this->db->queryf('
SELECT * FROM frm_posts_tree
WHERE thr_fk = %s
AND parent_pos = %s',
array('integer', 'integer'), array($this->id, '1'));
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 491 of file class.ilForumTopic.php.

References $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilForumExportGUI\exportHTML().

{
$res = $this->db->queryf('
SELECT pos_pk
FROM frm_posts
INNER JOIN frm_posts_tree ON pos_fk = pos_pk
WHERE parent_pos = %s
AND thr_fk = %s',
array('integer', 'integer'),
array('0', $this->id));
return new ilForumPost($row->pos_pk);
}

+ Here is the caller graph for this function:

ilForumTopic::getForumId ( )

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

References $forum_id.

{
}
ilForumTopic::getFrmObjId ( )

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

References $frm_obj_id.

{
}
ilForumTopic::getId ( )

Definition at line 978 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 1037 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 539 of file class.ilForumTopic.php.

References $res, $row, and DB_FETCHMODE_OBJECT.

{
global $ilUser;
if ($this->id)
{
$this->db->setLimit(1);
$res = $this->db->queryf('
SELECT pos_pk
FROM frm_posts
WHERE pos_thr_fk = %s
AND (pos_status = %s OR
(pos_status = %s AND pos_usr_id = %s))
ORDER BY pos_date DESC',
array('integer', 'integer', 'integer', 'integer'),
array($this->id, '1', '0', $ilUser->getId()));
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 513 of file class.ilForumTopic.php.

References $res, $row, and DB_FETCHMODE_OBJECT.

{
if ($this->id)
{
$this->db->setLimit(1);
$res = $this->db->queryf('
SELECT pos_pk
FROM frm_posts
WHERE pos_thr_fk = %s
ORDER BY pos_date DESC',
array('integer'), array($this->id));
return new ilForumPost($row->pos_pk);
}
return false;
}
ilForumTopic::getLastPostString ( )

Definition at line 1055 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 293 of file class.ilForumTopic.php.

References $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by countNewActivePosts(), and countNewPosts().

{
$res = $this->db->queryf('
SELECT * FROM frm_thread_access
WHERE thread_id = %s
AND usr_id = %s',
array('integer', 'integer'),
array($this->id, $a_user_id));
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 1095 of file class.ilForumTopic.php.

References $is_moderator.

{
}
ilForumTopic::getNumPosts ( )

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

References $num_posts.

{
}
ilForumTopic::getOrderField ( )

Definition at line 1087 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 743 of file class.ilForumTopic.php.

References $row, $type, and DB_FETCHMODE_OBJECT.

{
global $ilUser;
$childs = array();
$count = 0;
$r = $this->db->queryf('
SELECT pos_pk
FROM frm_posts_tree
INNER JOIN frm_posts ON frm_posts.pos_pk = frm_posts_tree.pos_fk
WHERE frm_posts_tree.parent_pos = %s
AND frm_posts_tree.thr_fk = %s
ORDER BY frm_posts_tree.lft DESC',
array('integer', 'integer'),
array($a_node_id, $this->id));
$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 594 of file class.ilForumTopic.php.

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

{
global $ilUser;
$this->posts = array();
$data = array();
$data_types = array();
$query = 'SELECT pos_pk FROM frm_posts_tree
INNER JOIN frm_posts ON pos_fk = pos_pk
WHERE lft BETWEEN %s AND %s
AND thr_fk = %s';
array_push($data_types, 'integer', 'integer', 'integer');
array_push($data, $a_post_node->getLft(), $a_post_node->getRgt(), $a_post_node->getThreadId());
if ($this->orderField == "frm_posts_tree.fpt_date")
{
$query .= " ORDER BY ".$this->orderField." ASC";
}
else if ($this->orderField != "")
{
$query .= " ORDER BY ".$this->orderField." DESC";
}
$res = $this->db->queryf($query, $data_types, $data);
$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 1010 of file class.ilForumTopic.php.

References $subject.

{
}
ilForumTopic::getUserAlias ( )

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

References $user_alias.

{
}
ilForumTopic::getUserId ( )

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

References $user_id.

{
}
ilForumTopic::getVisits ( )

Definition at line 1063 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)
{
$nextId = $this->db->nextId('frm_threads');
$statement = $this->db->manipulateF('
INSERT INTO frm_threads
( thr_pk,
thr_top_fk,
thr_subject,
thr_usr_id,
thr_usr_alias,
thr_num_posts,
thr_last_post,
thr_date,
thr_update,
import_name,
is_sticky,
is_closed
)
VALUES(%s,%s,%s,%s,%s,%s,%s,%s, %s, %s,%s,%s)',
array( 'integer',
'integer',
'text',
'integer',
'text',
'integer',
'text',
'timestamp',
'timestamp',
'text',
'integer',
'integer'),
array( $nextId,
$this->forum_id,
$this->subject,
$this->user_id,
$this->user_alias,
$this->num_posts,
$this->last_post_string,
$this->createdate,
NULL,
$this->import_name,
$this->is_sticky,
$this->is_closed
));
$this->id = $nextId;
return true;
}
return false;
}
ilForumTopic::isClosed ( )

Definition at line 1079 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 799 of file class.ilForumTopic.php.

References $result.

Referenced by enableNotification().

{
if ($this->id && $a_user_id)
{
$result = $this->db->queryf('
SELECT COUNT(notification_id) cnt FROM frm_notification
WHERE user_id = %s AND thread_id = %s',
array('integer', 'integer'),
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 1071 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 880 of file class.ilForumTopic.php.

{
if ($this->id && !$this->is_sticky)
{
$statement = $this->db->manipulateF('
UPDATE frm_threads
SET is_sticky = %s
WHERE thr_pk = %s',
array('integer', 'integer'),
array('1', $this->id));
$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 668 of file class.ilForumTopic.php.

References $ilDB, $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);
}
}
$res = $this->db->manipulateF('
UPDATE frm_user_read
SET obj_id = %s
WHERE thread_id = %s',
array('integer', 'integer'),
array($new_obj_id, $this->id));
$res = $this->db->manipulateF('
UPDATE frm_thread_access
SET obj_id = %s
WHERE thread_id =%s',
array('integer', 'integer'),
array($new_obj_id, $this->id));
$res = $this->db->manipulateF('
UPDATE frm_posts
SET pos_top_fk = %s
WHERE pos_thr_fk = %s',
array('integer', 'integer'),
array($new_pk, $this->id));
// update all related news
$posts = $ilDB->queryf('
SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
array('integer'), array($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 193 of file class.ilForumTopic.php.

References $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by __construct(), and reload().

{
if ($this->id)
{
$res = $this->db->queryf('
SELECT frm_threads.*, top_frm_fk frm_obj_id
FROM frm_threads
INNER JOIN frm_data ON top_pk = thr_top_fk
WHERE thr_pk = %s',
array('integer'), array($this->id));
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 239 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 955 of file class.ilForumTopic.php.

{
if ($this->id && $this->is_closed)
{
$statement = $this->db->manipulateF('
UPDATE frm_threads
SET is_closed = %s
WHERE thr_pk = %s',
array('integer', 'integer'),
array('0', $this->id));
$this->is_closed = 0;
return true;
}
return false;
}
ilForumTopic::setChangeDate (   $a_changedate)

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

{
if($a_changedate == '0000-00-00 00:00:00')
$this->changedate = NULL;
else
$this->changedate = $a_changedate;
}
ilForumTopic::setClosed (   $a_closed)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Referenced by ilForumExportGUI\printThread().

{
$this->orderField = $a_order_field;
}

+ Here is the caller graph for this function:

ilForumTopic::setSticky (   $a_sticky)

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

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

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

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

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

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

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

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

Definition at line 1059 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 905 of file class.ilForumTopic.php.

{
if ($this->id && $this->is_sticky)
{
$statement = $this->db->manipulateF('
UPDATE frm_threads
SET is_sticky = %s
WHERE thr_pk = %s',
array('integer', 'integer'),
array('0', $this->id));
$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 158 of file class.ilForumTopic.php.

{
if ($this->id)
{
$statement = $this->db->manipulateF('
UPDATE frm_threads
SET thr_top_fk = %s,
thr_subject = %s,
thr_update = %s,
thr_num_posts = %s,
thr_last_post = %s
WHERE thr_pk = %s',
array('integer', 'text','timestamp', 'integer', 'text', 'integer'),
array( $this->forum_id,
$this->subject,
/* $this->changedate, */
date('Y-m-d H:i:s'),
$this->num_posts,
$this->last_post_string,
$this->id
));
return true;
}
return false;
}
ilForumTopic::updateVisits ( )

Updates the visit counter of the current topic.

public

Definition at line 268 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();
$statement = $this->db->manipulateF('
UPDATE frm_threads
SET visits = visits + 1
WHERE thr_pk = %s',
array('integer'), array($this->id));
}
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 countActivePosts(), and 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.

Referenced by getModeratorRight().

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