ILIAS  Release_5_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, $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.
 getAverageRating ()
 setAverageRating ($average_rating)
 setId ($a_id)
 getId ()
 setForumId ($a_forum_id)
 getForumId ()
 setDisplayUserId ($a_user_id)
 getDisplayUserId ()
 setUserAlias ($a_user_alias)
 getUserAlias ()
 setSubject ($a_subject)
 getSubject ()
 setCreateDate ($a_createdate)
 getCreateDate ()
 setChangeDate ($a_changedate)
 getChangeDate ()
 setImportName ($a_import_name)
 getImportName ()
 setLastPostString ($a_last_post)
 getLastPostString ()
 setVisits ($a_visits)
 getVisits ()
 setSticky ($a_sticky)
 isSticky ()
 setClosed ($a_closed)
 isClosed ()
 setOrderField ($a_order_field)
 getOrderField ()
 setModeratorRight ($bool)
 getModeratorRight ()
 getFrmObjId ()
 setThrAuthorId ($thr_author_id)
 getThrAuthorId ()
 updateThreadTitle ()
 setNumPosts ($a_num_posts)
 getNumPosts ()
 setNumNewPosts ($num_new_posts)
 getNumNewPosts ()
 setNumUnreadPosts ($num_unread_posts)
 getNumUnreadPosts ()
 setUserNotificationEnabled ($user_notification_enabled)
 getUserNotificationEnabled ()
 setOrderDirection ($direction)
 getOrderDirection ()
 getSorting ()
 updateMergedThread ()

Static Public Member Functions

static _lookupTitle ($a_topic_id)
 Looks up the title/subject of a topic/thread.
static lookupForumIdByTopicId ($a_topic_id)
static deleteByThreadId ($thr_id)
static _lookupDate ($thread_id)

Static Protected Attributes

static $possibleOrderDirections = array('ASC', 'DESC')

Private Member Functions

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

Private Attributes

 $id = 0
 $forum_id = 0
 $frm_obj_id = 0
 $display_user_id = 0
 $user_alias = ''
 $subject = ''
 $createdate = '0000-00-00 00:00:00'
 $changedate = '0000-00-00 00:00:00'
 $num_posts = 0
 $last_post_string = ''
 $visits = 0
 $import_name = ''
 $is_sticky = 0
 $is_closed = 0
 $orderField = ''
 $posts = array()
 $db = null
 $is_moderator = false
 $thr_author_id = 0
 $average_rating = 0
 $orderDirection = 'DESC'

Detailed Description

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

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

Constructor & Destructor Documentation

ilForumTopic::__construct (   $a_id = 0,
  $a_is_moderator = false,
  $preventImplicitRead = false 
)

Constructor.

Returns an object of a forum topic. The constructor calls the private method read() to load the topic data from database into the object.

Parameters
integer$a_idprimary key of a forum topic (optional)
bool$a_is_moderatormoderator-status of the current user (optional)
bool$preventImplicitReadPrevents the implicit database query if an id was passed

public

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

References $ilDB, and read().

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

References $ilDB, $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 1121 of file class.ilForumTopic.php.

References $ilDB, $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 90 of file class.ilForumTopic.php.

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

{
$this->setId((int) $data['thr_pk']);
$this->setForumId((int) $data['thr_top_fk']);
$this->setSubject($data['thr_subject']);
$this->setDisplayUserId((int) $data['thr_display_user_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']);
$this->setAverageRating($data['avg_rating']);
$this->setThrAuthorId($data['thr_author_id']);
// 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 915 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 317 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_display_user_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 297 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 1268 of file class.ilForumTopic.php.

References $ilDB.

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 842 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 811 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 413 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::getAverageRating ( )
Returns
int

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

References $average_rating.

{
}
ilForumTopic::getChangeDate ( )

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

References $changedate.

{
}
ilForumTopic::getCreateDate ( )

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

References $createdate.

{
}
ilForumTopic::getDisplayUserId ( )

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

References $display_user_id.

ilForumTopic::getFirstPostId ( )

Fetches the primary key of the first post node of the current topic from database and returns it.

Returns
integer primary key of the first post node public

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

References $res, $row, and DB_FETCHMODE_OBJECT.

{
$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 340 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 987 of file class.ilForumTopic.php.

References $forum_id.

{
}
ilForumTopic::getFrmObjId ( )

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

References $frm_obj_id.

Referenced by getNestedSetPostChildren().

{
}

+ Here is the caller graph for this function:

ilForumTopic::getId ( )

Definition at line 979 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 1038 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 388 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_display_user_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 362 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 1048 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 1088 of file class.ilForumTopic.php.

References $is_moderator.

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

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

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

{
global $ilUser;
$data = null;
$objProperties = ilForumProperties::getInstance($this->getFrmObjId());
$is_post_activation_enabled = $objProperties->isPostActivationEnabled();
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_display_user_id,
fp.pos_usr_alias,
fp.import_name,
fp.pos_author_id,
fp.is_author_moderator,
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_display_user_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($is_post_activation_enabled && !$this->is_moderator)
{
$query .= ' AND (fp.pos_status = 1 OR fp.pos_status = 0 AND fp.pos_display_user_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.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_display_user_id,
fp.pos_usr_alias,
fp.import_name,
fp.pos_author_id,
fp.is_author_moderator,
fur.post_id
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($is_post_activation_enabled && !$this->is_moderator)
{
$queryCounter .= ' AND (fp.pos_status = 1 OR fp.pos_status = 0 AND fp.pos_display_user_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_display_user_id'])
{
$usr_ids[] = (int)$row['pos_display_user_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;
}

+ Here is the call graph for this function:

ilForumTopic::getNumNewPosts ( )
Returns
int

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

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

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

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

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

References $orderDirection.

Referenced by getPostTree().

{
}

+ Here is the caller graph for this function:

ilForumTopic::getOrderField ( )

Definition at line 1080 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 443 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 is_author_moderator, pos_author_id, pos_pk, fpt_date, rgt, pos_top_fk, pos_thr_fk,
pos_display_user_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_display_user_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->getDisplayUserId() != $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_display_user_id'])
{
$usr_ids[] = (int)$row['pos_display_user_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 1250 of file class.ilForumTopic.php.

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

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

References $subject.

Referenced by updateMergedThread(), and updateThreadTitle().

{
}

+ Here is the caller graph for this function:

ilForumTopic::getThrAuthorId ( )
Returns
int

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

References $thr_author_id.

{
}
ilForumTopic::getUserAlias ( )

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

References $user_alias.

{
}
ilForumTopic::getUserNotificationEnabled ( )
Returns
boolean

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

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

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

{
if ($this->forum_id)
{
$nextId = $this->db->nextId('frm_threads');
$this->db->insert('frm_threads',
array(
'thr_pk' => array('integer', $nextId),
'thr_top_fk' => array('integer', $this->forum_id),
'thr_subject' => array('text', $this->subject),
'thr_display_user_id' => array('integer', $this->display_user_id),
'thr_usr_alias' => array('text', $this->user_alias),
'thr_num_posts' => array('integer', $this->num_posts),
'thr_last_post' => array('text', $this->last_post_string),
'thr_date' => array('timestamp', $this->createdate),
'thr_update' => array('timestamp', NULL),
'import_name' => array('text', $this->import_name),
'is_sticky' => array('integer', $this->is_sticky),
'is_closed' => array('integer', $this->is_closed),
'avg_rating' => array('float', $this->average_rating),
'thr_author_id' => array('integer', $this->thr_author_id)
));
$this->id = $nextId;
return true;
}
return false;
}
ilForumTopic::isClosed ( )

Definition at line 1072 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 784 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 1064 of file class.ilForumTopic.php.

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

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

References $ilDB, $res, and $row.

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

{
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 865 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 550 of file class.ilForumTopic.php.

References $ilDB, $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 195 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->display_user_id = $row->thr_display_user_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;
$this->average_rating = $row->avg_rating;
$this->thr_author_id = $row->thr_author_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 243 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 940 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::setAverageRating (   $average_rating)
Parameters
int$average_rating

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

References $average_rating.

Referenced by assignData().

{
$this->average_rating = $average_rating;
}

+ Here is the caller graph for this function:

ilForumTopic::setChangeDate (   $a_changedate)

Definition at line 1023 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 1068 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 1015 of file class.ilForumTopic.php.

Referenced by assignData().

{
$this->createdate = $a_createdate;
}

+ Here is the caller graph for this function:

ilForumTopic::setDisplayUserId (   $a_user_id)

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

Referenced by assignData().

{
$this->display_user_id = $a_user_id;
}

+ Here is the caller graph for this function:

ilForumTopic::setForumId (   $a_forum_id)

Definition at line 983 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 975 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 1034 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 1042 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 1084 of file class.ilForumTopic.php.

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

Definition at line 1172 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 1154 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 1190 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 1222 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 1076 of file class.ilForumTopic.php.

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

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

Referenced by assignData().

{
$this->subject = $a_subject;
}

+ Here is the caller graph for this function:

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

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

References $thr_author_id.

Referenced by assignData().

{
$this->thr_author_id = $thr_author_id;
}

+ Here is the caller graph for this function:

ilForumTopic::setUserAlias (   $a_user_alias)

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

Referenced by assignData().

{
$this->user_alias = $a_user_alias;
}

+ Here is the caller graph for this function:

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

Definition at line 1208 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 1052 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 890 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,
avg_rating = %s
WHERE thr_pk = %s',
array('integer', 'text','timestamp', 'integer', 'text', 'float', 'integer'),
array( $this->forum_id,
$this->subject,
/* $this->changedate, */
date('Y-m-d H:i:s'),
$this->num_posts,
$this->last_post_string,
$this->average_rating,
$this->id
));
return true;
}
return false;
}
ilForumTopic::updateMergedThread ( )

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

References $ilDB, 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 1140 of file class.ilForumTopic.php.

References $ilDB, 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 272 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::$average_rating = 0
private

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

Referenced by getAverageRating(), and setAverageRating().

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::$display_user_id = 0
private

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

Referenced by getDisplayUserId().

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'
private

Definition at line 57 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 59 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::$thr_author_id = 0
private

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

Referenced by getThrAuthorId(), and setThrAuthorId().

ilForumTopic::$user_alias = ''
private

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

Referenced by getUserAlias().

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: