ILIAS  Release_4_4_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, $preventImplicitRead=false)
 Constructor.
 assignData ($data)
 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.
 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.
 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.
 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).
 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 ()
 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 ()
 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.
static lookupForumIdByTopicId ($a_topic_id)
static deleteByThreadId ($thr_id)
static _lookupDate ($thread_id)

Protected Attributes

 $orderDirection = 'DESC'

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.

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

Constructor & Destructor Documentation

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

References read().

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

+ Here is the call graph for this function:

Member Function Documentation

static ilForumTopic::_lookupDate (   $thread_id)
static
Parameters
integer$thread_id
Returns
string datetime

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

References $res, and $row.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

{
global $ilDB;
$res = $ilDB->queryF('SELECT thr_date FROM frm_threads WHERE thr_pk = %s',
array('integer'), array((int)$thread_id));
$row = $ilDB->fetchAssoc($res);
return $row['thr_date'] ? $row['thr_date'] : '0000-00-00 00:00:00';
}

+ Here is the caller graph for this function:

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

References $res, and $row.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

{
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::assignData (   $data)
Parameters
$data

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

References setChangeDate(), setClosed(), setCreateDate(), setForumId(), setId(), setImportName(), setLastPostString(), setNumNewPosts(), setNumPosts(), setNumUnreadPosts(), setSticky(), setSubject(), setUserAlias(), setUserId(), setUserNotificationEnabled(), and setVisits().

{
$this->setId((int) $data['thr_pk']);
$this->setForumId((int) $data['thr_top_fk']);
$this->setSubject($data['thr_subject']);
$this->setUserId((int) $data['thr_usr_id']);
$this->setUserAlias($data['thr_usr_alias']);
$this->setLastPostString($data['last_post_string']);
$this->setCreateDate($data['thr_date']);
$this->setChangeDate($data['thr_update']);
$this->setVisits((int) $data['visits']);
$this->setImportName($data['import_name']);
$this->setSticky((int) $data['is_sticky']);
$this->setClosed((int) $data['is_closed']);
// Aggregated values
$this->setNumPosts((int) $data['num_posts']);
$this->setNumUnreadPosts((int) $data['num_unread_posts']);
$this->setNumNewPosts((int) $data['num_new_posts']);
$this->setUserNotificationEnabled((bool) $data['usr_notification_is_enabled']);
}

+ Here is the call 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 923 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 328 of file class.ilForumTopic.php.

References $id, $ilUser, $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::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 308 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'];
}
static ilForumTopic::deleteByThreadId (   $thr_id)
static

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

Referenced by ilForum\mergeThreads().

{
global $ilDB;
$ilDB->manipulateF('DELETE FROM frm_threads WHERE thr_pk = %s',
array('integer'), array($thr_id));
}

+ Here is the caller graph for this function:

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 850 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 819 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 424 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 1022 of file class.ilForumTopic.php.

References $changedate.

{
}
ilForumTopic::getCreateDate ( )

Definition at line 1011 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 265 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 351 of file class.ilForumTopic.php.

References $res, $row, and DB_FETCHMODE_OBJECT.

{
$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);
}
ilForumTopic::getForumId ( )

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

References $forum_id.

{
}
ilForumTopic::getFrmObjId ( )

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

References $frm_obj_id.

{
}
ilForumTopic::getId ( )

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

References $id.

Referenced by updateMergedThread(), and updateThreadTitle().

{
return $this->id;
}

+ Here is the caller graph for this function:

ilForumTopic::getImportName ( )

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

References $ilUser, $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 373 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 1040 of file class.ilForumTopic.php.

References $last_post_string.

Referenced by updateMergedThread().

+ Here is the caller graph for this function:

ilForumTopic::getModeratorRight ( )

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

References $is_moderator.

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

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

References $ilUser, $query, $res, and $row.

{
global $ilUser;
$data = null;
if( $pos_id !== null )
{
$res = $this->db->queryF("
SELECT lft, rgt
FROM frm_posts_tree
WHERE pos_fk = %s
AND thr_fk = %s",
array('integer', 'integer'),
array($pos_id, $this->id)
);
$data = $this->db->fetchAssoc($res);
}
$query = '
SELECT fpt.depth,
fpt.rgt,
fpt.parent_pos,
fp.pos_pk,
fp.pos_subject,
fp.pos_usr_alias,
fp.pos_date,
fp.pos_update,
fp.pos_status,
fp.pos_usr_id,
fp.pos_usr_alias,
fp.import_name,
fur.post_id,
(CASE
WHEN fur.post_id IS NULL '.
($ilUser->getId() == ANONYMOUS_USER_ID ? ' AND 1 = 2 ' : '').'
THEN 0
ELSE 1
END) post_read,
COUNT(fpt2.pos_fk) children
FROM frm_posts_tree fpt
INNER JOIN frm_posts fp
ON fp.pos_pk = fpt.pos_fk
LEFT JOIN frm_posts_tree fpt2
ON fpt2.lft BETWEEN fpt.lft AND fpt.rgt
AND fpt.thr_fk = fpt2.thr_fk
AND fpt.pos_fk != fpt2.pos_fk ';
$query .= '
LEFT JOIN frm_user_read fur
ON fur.thread_id = fp.pos_thr_fk
AND fur.post_id = fp.pos_pk
AND fur.usr_id = '.$this->db->quote($ilUser->getId(), 'integer').'
LEFT JOIN usr_data ud
ON ud.usr_id = fp.pos_usr_id
WHERE fpt.thr_fk = '.$this->db->quote($this->id, 'integer');
if( $data )
{
$query .= ' AND fpt.lft > '.$this->db->quote($data['lft'], 'integer').
' AND fpt.lft < '.$this->db->quote($data['rgt'], 'integer').' ';
}
if( !$this->is_moderator )
{
$query .= ' AND (fp.pos_status = 1 OR fp.pos_status = 0 AND fp.pos_usr_id = '.
$this->db->quote($ilUser->getId(), 'integer').') ';
}
if( $expandedNodes )
{
$query .= ' AND '.$this->db->in('fpt.parent_pos', $expandedNodes, false, 'integer').' ';
}
$query .= ' GROUP BY fpt.depth,
fpt.parent_pos,
fp.pos_pk,
fp.pos_subject,
fp.pos_usr_alias,
fp.pos_date,
fp.pos_update,
fp.pos_status,
fp.pos_usr_id,
fp.pos_usr_alias,
fp.import_name,
fur.post_id,
fpt.rgt
ORDER BY fpt.rgt DESC
';
$queryCounter = '
SELECT pos_fk
FROM frm_posts_tree fpt
INNER JOIN frm_posts fp
ON fp.pos_pk = fpt.pos_fk
WHERE fpt.thr_fk = '.$this->db->quote($this->id, 'integer');
if( !$this->is_moderator )
{
$queryCounter .= ' AND (fp.pos_status = 1 OR fp.pos_status = 0 AND fp.pos_usr_id = '.
$this->db->quote($ilUser->getId(), 'integer').') ';
}
$queryCounter .= ' ORDER BY fpt.rgt DESC';
$resCounter = $this->db->query($queryCounter);
$counter = array();
$i = 0;
while( $row = $this->db->fetchAssoc($resCounter) )
{
$counter[$row['pos_fk']] = $i++;
}
$res = $this->db->query($query);
$children = array();
$usr_ids = array();
while( $row = $this->db->fetchAssoc($res) )
{
if((int)$row['pos_usr_id'])
{
$usr_ids[] = (int)$row['pos_usr_id'];
}
$row['counter'] = $counter[$row['pos_pk']];
$children[] = $row;
}
require_once 'Modules/Forum/classes/class.ilForumAuthorInformationCache.php';
ilForumAuthorInformationCache::preloadUserObjects(array_unique($usr_ids));
return $children;
}
ilForumTopic::getNumNewPosts ( )
Returns
int

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

{
return $this->num_new_posts;
}
ilForumTopic::getNumPosts ( )
Returns
int

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

References $num_posts.

Referenced by updateMergedThread().

{
}

+ Here is the caller graph for this function:

ilForumTopic::getNumUnreadPosts ( )
Returns
int

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

{
return $this->num_unread_posts;
}
ilForumTopic::getOrderDirection ( )

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

References $orderDirection.

Referenced by getPostTree().

{
}

+ Here is the caller graph for this function:

ilForumTopic::getOrderField ( )

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

References $orderField.

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

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

{
global $ilUser;
$posts = array();
$data = array();
$data_types = array();
$query = '
SELECT pos_pk, fpt_date, rgt, pos_top_fk, pos_thr_fk,
pos_usr_id, pos_usr_alias, pos_subject,
pos_status, pos_message, pos_date, pos_update,
update_user, pos_cens, pos_cens_com, notify,
import_name, fpt_pk, parent_pos, lft, depth,
(CASE
WHEN fur.post_id IS NULL '.
($ilUser->getId() == ANONYMOUS_USER_ID ? ' AND 1 = 2 ' : '').'
THEN 0
ELSE 1
END) post_read,
firstname, lastname, title, login
FROM frm_posts_tree
INNER JOIN frm_posts
ON pos_fk = pos_pk
LEFT JOIN usr_data
ON pos_usr_id = usr_id
LEFT JOIN frm_user_read fur
ON fur.thread_id = pos_thr_fk
AND fur.post_id = pos_pk
AND fur.usr_id = %s
WHERE lft BETWEEN %s AND %s
AND thr_fk = %s';
array_push($data_types, 'integer', 'integer', 'integer', 'integer');
array_push($data, $ilUser->getId(), $a_post_node->getLft(), $a_post_node->getRgt(), $a_post_node->getThreadId());
if($this->orderField != "")
{
$query .= " ORDER BY ".$this->orderField." ".$this->getOrderDirection();
}
$res = $this->db->queryf($query, $data_types, $data);
$usr_ids = array();
$deactivated = array();
while( $row = $this->db->fetchAssoc($res) )
{
$tmp_object = new ilForumPost($row['pos_pk'], false, true);
$tmp_object->assignData($row);
if (!$this->is_moderator)
{
if (!$tmp_object->isActivated() && $tmp_object->getUserId() != $ilUser->getId())
{
$deactivated[] = $tmp_object;
unset($tmp_object);
continue;
}
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 2;
}
}
}
if((int)$row['pos_usr_id'])
{
$usr_ids[] = (int)$row['pos_usr_id'];
}
if((int)$row['update_user'])
{
$usr_ids[] = (int)$row['update_user'];
}
$posts[] = $tmp_object;
unset($tmp_object);
}
require_once 'Modules/Forum/classes/class.ilForumAuthorInformationCache.php';
ilForumAuthorInformationCache::preloadUserObjects(array_unique($usr_ids));
return $posts;
}

+ Here is the call graph for this function:

ilForumTopic::getSorting ( )

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

{
return $this->thread_sorting;
}
ilForumTopic::getSubject ( )

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

References $subject.

Referenced by updateMergedThread(), and updateThreadTitle().

{
}

+ Here is the caller graph for this function:

ilForumTopic::getUserAlias ( )

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

References $user_alias.

{
}
ilForumTopic::getUserId ( )

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

References $user_id.

{
}
ilForumTopic::getUserNotificationEnabled ( )
Returns
boolean

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

{
return $this->user_notification_enabled;
}
ilForumTopic::getVisits ( )

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

References $visits.

Referenced by updateMergedThread().

{
return $this->visits;
}

+ Here is the caller graph for this function:

ilForumTopic::insert ( )

Inserts the object data into database.

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

Definition at line 111 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 1064 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 792 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 1056 of file class.ilForumTopic.php.

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

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

References $res, and $row.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

{
global $ilDB;
$res = $ilDB->queryF('SELECT thr_top_fk FROM frm_threads WHERE thr_pk = %s',
array('integer'), array($a_topic_id));
$row = $ilDB->fetchAssoc($res);
return $row['thr_top_fk'];
}

+ Here is the caller graph for this function:

ilForumTopic::makeSticky ( )

Sets the current topic sticky.

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

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

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

{
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);
}
}
$this->db->lockTables(
array(
0 => array('name' => 'frm_user_read', 'type' => ilDB::LOCK_WRITE),
1 => array('name' => 'frm_thread_access', 'type' => ilDB::LOCK_WRITE)
)
);
$this->db->manipulateF('
DELETE FROM frm_user_read
WHERE obj_id = %s AND thread_id =%s',
array('integer', 'integer'),
array($new_obj_id, $this->id));
$this->db->manipulateF('
UPDATE frm_user_read
SET obj_id = %s
WHERE thread_id = %s',
array('integer', 'integer'),
array($new_obj_id, $this->id));
$this->db->manipulateF('
DELETE FROM frm_thread_access
WHERE obj_id = %s AND thread_id =%s',
array('integer', 'integer'),
array($new_obj_id, $this->id));
$this->db->manipulateF('
UPDATE frm_thread_access
SET obj_id = %s
WHERE thread_id =%s',
array('integer', 'integer'),
array($new_obj_id, $this->id));
$this->db->unlockTables();
$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 207 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; // thr_pk = 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 = html_entity_decode($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;
}
$this->id = 0;
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 254 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 948 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 1015 of file class.ilForumTopic.php.

Referenced by assignData().

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

+ Here is the caller graph for this function:

ilForumTopic::setClosed (   $a_closed)

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

Referenced by assignData().

{
$this->is_closed = $a_closed;
}

+ Here is the caller graph for this function:

ilForumTopic::setCreateDate (   $a_createdate)

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

Referenced by assignData().

{
$this->createdate = $a_createdate;
}

+ Here is the caller graph for this function:

ilForumTopic::setForumId (   $a_forum_id)

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

Referenced by assignData().

{
$this->forum_id = $a_forum_id;
}

+ Here is the caller graph for this function:

ilForumTopic::setId (   $a_id)

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

Referenced by assignData().

{
$this->id = $a_id;
}

+ Here is the caller graph for this function:

ilForumTopic::setImportName (   $a_import_name)

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

Referenced by assignData().

{
$this->import_name = $a_import_name;
}

+ Here is the caller graph for this function:

ilForumTopic::setLastPostString (   $a_last_post)

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

Referenced by assignData().

{
if($a_last_post == '') $a_last_post = NULL;
$this->last_post_string = $a_last_post;
}

+ Here is the caller graph for this function:

ilForumTopic::setModeratorRight (   $bool)

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

{
$this->is_moderator = $bool;
}
ilForumTopic::setNumNewPosts (   $num_new_posts)
Parameters
int$num_new_posts
Returns
ilForumTopic

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

Referenced by assignData().

{
$this->num_new_posts = $num_new_posts;
return $this;
}

+ Here is the caller graph for this function:

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

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

Referenced by assignData().

{
$this->num_posts = $a_num_posts;
return $this;
}

+ Here is the caller graph for this function:

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

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

Referenced by assignData().

{
$this->num_unread_posts = $num_unread_posts;
return $this;
}

+ Here is the caller graph for this function:

ilForumTopic::setOrderDirection (   $direction)

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

{
if(!in_array(strtoupper($direction), self::$possibleOrderDirections))
{
$direction = current(self::$possibleOrderDirections);
}
$this->orderDirection = $direction;
return $this;
}
ilForumTopic::setOrderField (   $a_order_field)

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

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

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

Referenced by assignData().

{
$this->is_sticky = $a_sticky;
}

+ Here is the caller graph for this function:

ilForumTopic::setSubject (   $a_subject)

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

Referenced by assignData().

{
$this->subject = $a_subject;
}

+ Here is the caller graph for this function:

ilForumTopic::setUserAlias (   $a_user_alias)

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

Referenced by assignData().

{
$this->user_alias = $a_user_alias;
}

+ Here is the caller graph for this function:

ilForumTopic::setUserId (   $a_user_id)

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

Referenced by assignData().

{
$this->user_id = $a_user_id;
}

+ Here is the caller graph for this function:

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

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

Referenced by assignData().

{
$this->user_notification_enabled = $user_notification_enabled;
return $this;
}

+ Here is the caller graph for this function:

ilForumTopic::setVisits (   $a_visits)

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

Referenced by assignData().

{
$this->visits = $a_visits;
}

+ Here is the caller graph for this function:

ilForumTopic::unmakeSticky ( )

Sets the current topic non-sticky.

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

Definition at line 898 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 172 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::updateMergedThread ( )

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

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

{
global $ilDB;
$ilDB->update('frm_threads',
array(
'thr_num_posts' => array('integer', $this->getNumPosts()),
'visits' => array('integer', $this->getVisits()),
'thr_last_post' => array('text', $this->getLastPostString()),
'thr_subject' => array('text', $this->getSubject())
),
array('thr_pk' => array('integer', $this->getId())));
}

+ Here is the call graph for this function:

ilForumTopic::updateThreadTitle ( )

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

References getId(), and getSubject().

{
global $ilDB;
$ilDB->update('frm_threads',
array('thr_subject' => array('text',$this->getSubject())),
array('thr_pk'=> array('integer', $this->getId()))
);
}

+ Here is the call graph for this function:

ilForumTopic::updateVisits ( )

Updates the visit counter of the current topic.

public

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

Referenced by getChangeDate().

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

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

Referenced by getCreateDate().

ilForumTopic::$db = null
private

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

ilForumTopic::$forum_id = 0
private

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

Referenced by getForumId().

ilForumTopic::$frm_obj_id = 0
private

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

Referenced by getFrmObjId().

ilForumTopic::$id = 0
private

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

Referenced by countActivePosts(), and getId().

ilForumTopic::$import_name = ''
private

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

Referenced by getImportName().

ilForumTopic::$is_closed = 0
private

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

ilForumTopic::$is_moderator = false
private

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

Referenced by getModeratorRight().

ilForumTopic::$is_sticky = 0
private

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

ilForumTopic::$last_post_string = ''
private

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

Referenced by getLastPostString().

ilForumTopic::$num_posts = 0
private

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

Referenced by getNumPosts().

ilForumTopic::$orderDirection = 'DESC'
protected

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

Referenced by getOrderDirection().

ilForumTopic::$orderField = ''
private

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

Referenced by getOrderField().

ilForumTopic::$possibleOrderDirections = array('ASC', 'DESC')
staticprotected

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

ilForumTopic::$posts = array()
private

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

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

ilForumTopic::$subject = ''
private

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

Referenced by getSubject().

ilForumTopic::$user_alias = ''
private

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

Referenced by getUserAlias().

ilForumTopic::$user_id = 0
private

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

Referenced by getUserId().

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: