ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilForum Class Reference

Class Forum core functions for forum. More...

+ Collaboration diagram for ilForum:

Public Member Functions

 ilForum ()
 Constructor public.
 setLanguage ($lng)
 setForumId ($a_obj_id)
 set object id which refers to ILIAS obj_id
 setForumRefId ($a_ref_id)
 set reference id which refers to ILIAS obj_id
 getForumId ()
 get forum id public
 getForumRefId ()
 get forum ref_id public
 setOrderField ($orderField)
 set database field for sorting results
 getOrderField ()
 get name of orderField
 setDbTable ($dbTable)
 set database table
 getDbTable ()
 get name of database table
 setMDB2WhereCondition ($query_string, $data_type, $data_value)
 set content for additional condition
 getMDB2Query ()
 get content of additional condition
 getMDB2DataValue ()
 /* get content of additional condition
 getMDB2DataType ()
 get content of additional condition
 setPageHits ($pageHits)
 set number of max.
 getPageHits ()
 get number of max.
 getOneDataset ()
 get one dataset from set Table and set WhereCondition
 getOneTopic ()
 get one topic-dataset by WhereCondition
 fixThreadNumber ($a_top_pk, $a_num_threads)
 In some rare cases the thread number in frm_data is incorrect.
 _lookupForumData ($a_obj_id)
 lookup forum data
 getOneThread ()
 get one thread-dataset by WhereCondition
 getOnePost ($post)
 get one post-dataset
 getPostById ($a_id)
 _lookupPostMessage ($a_id)
 generatePost ($forum_id, $thread_id, $user, $message, $parent_pos, $notify, $subject= '', $alias= '', $date= '', $status=1, $send_activation_mail=0)
 generate new dataset in frm_posts
 generateThread ($forum_id, $user, $subject, $message, $notify, $notify_posts, $alias= '', $date= '')
 generate new dataset in frm_threads
 updatePost ($message, $pos_pk, $notify, $subject, $thr_pk=0)
 update dataset in frm_posts
 updateThread ($thr_pk, $subject)
 update dataset in frm_threads
 getAllForums ()
 moveThreads ($thread_ids=array(), $src_ref_id=0, $dest_top_frm_fk=0)
 Moves all chosen threads and their posts to a new forum.
 postCensorship ($message, $pos_pk, $cens=0)
 update dataset in frm_posts with censorship info
 deletePost ($post)
 delete post and sub-posts
 getAllThreads ($a_topic_id, $is_moderator=false)
 Get all threads of given thread.
 getPostList ($topic, $thread)
 get all posts of given thread
 getUserStatistic ($is_moderator=false)
 getFirstPostByThread ($a_thread_id)
 Get first post of thread.
 getLastPost ($lastPost)
 get content of given ID's
 getUser ($a_user_id)
 get content of given user-ID
 getModerators ()
 get all users assigned to local role il_frm_moderator_<frm_ref_id>
 _getModerators ($a_ref_id)
 get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)
 _isModerator ($a_ref_id, $a_usr_id)
 checks whether a user is moderator of a given forum object
 countUserArticles ($a_user_id)
 get number of articles from given user-ID
 countActiveUserArticles ($a_user_id)
 getForumPath ($a_ref_id)
 builds a string to show the forum-context
 convertDate ($date)
 converts the date format
 addPostTree ($a_tree_id, $a_node_id=-1, $a_date= '')
 create a new post-tree
 insertPostNode ($a_node_id, $a_parent_id, $tree_id, $a_date= '')
 insert node under parent node public
 getPostDepth ($a_node_id, $tree_id)
 Return depth of an object private.
 getPostTree ($a_node)
 get all nodes in the subtree under specified node
 getPostChilds ($a_node_id, $a_thr_id)
 get child nodes of given node public
 getFirstPostNode ($tree_id)
 get data of the first node from frm_posts_tree and frm_posts public
 getPostNode ($post_id)
 get data of given node from frm_posts_tree and frm_posts public
 fetchPostNodeData ($a_row)
 get data of parent node from frm_posts_tree and frm_posts private
 getPostMaximumDepth ($a_thr_id)
 Return the maximum depth in tree public.
 deletePostTree ($a_node)
 delete node and the whole subtree under this node public
 updateVisits ($ID)
 update page hits of given forum- or thread-ID public
 prepareText ($text, $edit=0, $quote_user= '', $type= '')
 prepares given string public
 getModeratorFromPost ($pos_pk)
 get one post-dataset
 __deletePostFiles ($a_ids)
 __sendMessage ($a_parent_pos, $post_data=array())
 __formatSubject ($thread_data)
 __formatMessage ($thread_data, $post_data=array())
 getUserData ($a_id, $a_import_name=0)
 getImportName ()
 setImportName ($a_import_name)
 enableForumNotification ($user_id)
 Enable a user's notification about new posts in this forum.
 disableForumNotification ($user_id)
 Disable a user's notification about new posts in this forum.
 isForumNotificationEnabled ($user_id)
 Check whether a user's notification about new posts in this forum is enabled (result > 0) or not (result == 0)
 enableThreadNotification ($user_id, $thread_id)
 Enable a user's notification about new posts in a thread.
 isThreadNotificationEnabled ($user_id, $thread_id)
 Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (result == 0)
 sendThreadNotifications ($post_data)
 sendForumNotifications ($post_data)
 formatPostActivationNotificationSubject ()
 formatPostActivationNotification ($post_data)
 sendPostActivationNotification ($post_data)
 formatNotificationSubject ($post_data)
 formatNotification ($post_data, $cron=0)
 limitMsgString ($message)
 _lookupObjIdForForumId ($a_for_id)

Static Public Member Functions

static _getLanguageInstanceByUsrId ($usr_id)
 Get the ilLanguage instance for the passed user id.
static _getThreads ($a_obj_id, $a_sort_mode=self::SORT_DATE)
 Get thread infos of object.

Data Fields

const SORT_TITLE = 1
const SORT_DATE = 2
 $ilias
 $lng
 $dbTable
 $className = "ilForum"
 $orderField
 $mdb2Query
 $mdb2DataValue
 $mdb2DataType
 $txtQuote1 = "[quote]"
 $txtQuote2 = "[/quote]"
 $replQuote1 = '<blockquote class="ilForumQuote">'
 $replQuote2 = '</blockquote>'
 $pageHits = 30
 $id

Private Attributes

 $threads = array()

Detailed Description

Class Forum core functions for forum.

Author
Wolfgang Merkens wmerk.nosp@m.ens@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
Id:
class.ilForum.php 27071 2010-12-22 11:18:31Z akordosz

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

Member Function Documentation

ilForum::__deletePostFiles (   $a_ids)

Definition at line 2170 of file class.ilForum.php.

References $file, $files, and getForumId().

Referenced by deletePost().

{
if(!is_array($a_ids))
{
return false;
}
include_once "./Modules/Forum/classes/class.ilFileDataForum.php";
$tmp_file_obj =& new ilFileDataForum($this->getForumId());
foreach($a_ids as $pos_id)
{
$tmp_file_obj->setPosId($pos_id);
$files = $tmp_file_obj->getFilesOfPost();
foreach($files as $file)
{
$tmp_file_obj->unlinkFile($file["name"]);
}
}
unset($tmp_file_obj);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::__formatMessage (   $thread_data,
  $post_data = array() 
)

Definition at line 2229 of file class.ilForum.php.

References $title, getForumRefId(), and ilObjectFactory\getInstanceByRefId().

Referenced by __sendMessage().

{
include_once "./classes/class.ilObjectFactory.php";
$title = $frm_obj->getTitle();
unset($frm_obj);
$message = $this->lng->txt("forum").": ".$title." -> ".$thread_data["thr_subject"]."\n\n";
$message .= $this->lng->txt("forum_post_replied");
$message .= "\n------------------------------------------------------------\n";
$message .= $post_data["pos_message"];
$message .= "\n------------------------------------------------------------\n";
$message .= sprintf($this->lng->txt("forums_notification_show_post"), "http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/goto.php?target=frm_".$post_data["ref_id"]."_".$post_data["pos_thr_fk"].'&client_id='.CLIENT_ID);
return $message;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::__formatSubject (   $thread_data)

Definition at line 2224 of file class.ilForum.php.

Referenced by __sendMessage().

{
return $this->lng->txt("forums_notification_subject");
}

+ Here is the caller graph for this function:

ilForum::__sendMessage (   $a_parent_pos,
  $post_data = array() 
)

Definition at line 2193 of file class.ilForum.php.

References $ilDB, __formatMessage(), __formatSubject(), getOnePost(), getOneThread(), and setMDB2WhereCondition().

Referenced by generatePost().

{
global $ilUser, $ilDB;
$parent_data = $this->getOnePost($a_parent_pos);
// only if the current user is not the owner of the parent post and the parent's notification flag is set...
if($parent_data["notify"] && $parent_data["pos_usr_id"] != $ilUser->getId())
{
// SEND MESSAGE
include_once "Services/Mail/classes/class.ilMail.php";
include_once './Services/User/classes/class.ilObjUser.php';
$tmp_user =& new ilObjUser($parent_data["pos_usr_id"]);
// NONSENSE
$this->setMDB2WhereCondition('thr_pk = %s ', array('integer'), array($parent_data["pos_thr_fk"]));
$thread_data = $this->getOneThread();
$tmp_mail_obj = new ilMail(ANONYMOUS_USER_ID);
$message = $tmp_mail_obj->sendMail($tmp_user->getLogin(),"","",
$this->__formatSubject($thread_data),
$this->__formatMessage($thread_data, $post_data),
array(),array("system"));
unset($tmp_user);
unset($tmp_mail_obj);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilForum::_getLanguageInstanceByUsrId (   $usr_id)
static

Get the ilLanguage instance for the passed user id.

Parameters
integer$usr_ida user id
Returns
ilLanguage public

Definition at line 118 of file class.ilForum.php.

References $usr_id, and ilObjUser\_lookupLanguage().

Referenced by ilCronForumNotification\sendMails().

{
static $lngCache = array();
$languageShorthandle = ilObjUser::_lookupLanguage($usr_id);
// lookup in cache array
if(!isset($lngCache[$languageShorthandle]))
{
$lngCache[$languageShorthandle] = new ilLanguage($languageShorthandle);
$lngCache[$languageShorthandle]->loadLanguageModule('forum');
}
return $lngCache[$languageShorthandle];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::_getModerators (   $a_ref_id)

get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)

Parameters
int$a_ref_idreference id
Returns
array user_ids public

Definition at line 1487 of file class.ilForum.php.

References $title, and ilObject\_lookupTitle().

Referenced by _isModerator(), and getModerators().

{
global $rbacreview;
$rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
$role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
foreach ($role_arr as $role_id)
{
//$roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
if ($title == "il_frm_moderator_".$a_ref_id)
{
#return $rbacreview->assignedUsers($roleObj->getId());
return $title = $rbacreview->assignedUsers($role_id);
}
}
return array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilForum::_getThreads (   $a_obj_id,
  $a_sort_mode = self::SORT_DATE 
)
static

Get thread infos of object.

public

Parameters
intobj_id of forum
intsort mode SORT_TITLE or SORT_DATE

Definition at line 2784 of file class.ilForum.php.

References $ilDB, $res, $row, $threads, and DB_FETCHMODE_OBJECT.

Referenced by ilObjForumGUI\cloneWizardPageObject().

{
global $ilDB;
switch($a_sort_mode)
{
case self::SORT_DATE:
$sort = 'thr_date';
break;
case self::SORT_TITLE:
default:
$sort = 'thr_subject';
break;
}
$res = $ilDB->queryf('
SELECT * FROM frm_threads
JOIN frm_data ON top_pk = thr_top_fk
WHERE top_frm_fk = %s
ORDER BY %s',
array('integer', 'text'), array($a_obj_id, $sort));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$threads[$row->thr_pk] = $row->thr_subject;
}
return $threads ? $threads : array();
}

+ Here is the caller graph for this function:

ilForum::_isModerator (   $a_ref_id,
  $a_usr_id 
)

checks whether a user is moderator of a given forum object

Parameters
int$a_ref_idreference id
int$a_usr_iduser id
Returns
bool public

Definition at line 1516 of file class.ilForum.php.

References _getModerators().

Referenced by ilForumExplorer\setOutput(), and ilObjForumGUI\viewThreadObject().

{
return in_array($a_usr_id, ilForum::_getModerators($a_ref_id));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::_lookupForumData (   $a_obj_id)

lookup forum data

Definition at line 454 of file class.ilForum.php.

References $ilDB, $res, $result, and DB_FETCHMODE_ASSOC.

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_data
WHERE top_frm_fk = %s',
array('integer'),array($a_obj_id));
$result["top_name"] = trim($result["top_name"]);
$result["top_description"] = nl2br($result["top_description"]);
return $result;
}
ilForum::_lookupObjIdForForumId (   $a_for_id)

Definition at line 2834 of file class.ilForum.php.

References $ilDB, $res, and DB_FETCHMODE_ASSOC.

Referenced by ilObjMediaObject\getParentObjectIdForUsage(), ilForumTopic\movePosts(), sendForumNotifications(), and sendThreadNotifications().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT top_frm_fk FROM frm_data
WHERE top_pk = %s',
array('integer'), array($a_for_id));
if ($fdata = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
return $fdata["top_frm_fk"];
}
return false;
}

+ Here is the caller graph for this function:

ilForum::_lookupPostMessage (   $a_id)

Definition at line 539 of file class.ilForum.php.

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

Referenced by ilObjForum\cloneObject().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_posts WHERE pos_pk = %s',
array('integer'), array($a_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->pos_message;
}
return '';
}

+ Here is the caller graph for this function:

ilForum::addPostTree (   $a_tree_id,
  $a_node_id = -1,
  $a_date = '' 
)

create a new post-tree

Parameters
integera_tree_id: id where tree belongs to
integera_node_id: root node of tree (optional; default is tree_id itself)
Returns
boolean true on success public

Definition at line 1610 of file class.ilForum.php.

References $ilDB.

Referenced by generatePost().

{
global $ilDB;
$a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
if ($a_node_id <= 0)
{
$a_node_id = $a_tree_id;
}
$nextId = $ilDB->nextId('frm_posts_tree');
$statement = $ilDB->manipulateF('
INSERT INTO frm_posts_tree
( fpt_pk,
thr_fk,
pos_fk,
parent_pos,
lft,
rgt,
depth,
fpt_date
)
VALUES(%s, %s, %s, %s, %s, %s, %s, %s )',
array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
array($nextId, $a_tree_id, $a_node_id, '0', '1', '2', '1', $a_date));
return true;
}

+ Here is the caller graph for this function:

ilForum::convertDate (   $date)

converts the date format

Parameters
string$date
Returns
string formatted datetime public

Definition at line 1596 of file class.ilForum.php.

References $lng, ilDatePresentation\formatDate(), and IL_CAL_DATETIME.

Referenced by getLastPost(), and getOnePost().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::countActiveUserArticles (   $a_user_id)

Definition at line 1543 of file class.ilForum.php.

References $ilDB, $res, and getForumId().

{
global $ilDB, $ilUser;
$res = $ilDB->queryf('
SELECT * FROM frm_data
INNER JOIN frm_posts ON pos_top_fk = top_pk
WHERE top_frm_fk = %s
AND (pos_status = %s
OR (pos_status = %s
AND pos_usr_id = %s
)
)
AND pos_usr_id = %s',
array('integer', 'integer', 'integer', 'integer', 'integer'),
array($this->getForumId(),'1', '0', $ilUser->getId(), $a_user_id));
return $res->numRows();
}

+ Here is the call graph for this function:

ilForum::countUserArticles (   $a_user_id)

get number of articles from given user-ID

Parameters
integer$user,:user-ID
Returns
integer public

Definition at line 1528 of file class.ilForum.php.

References $ilDB, $res, and getForumId().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_data
INNER JOIN frm_posts ON pos_top_fk = top_pk
WHERE top_frm_fk = %s
AND pos_usr_id = %s',
array('integer', 'integer'),
array($this->getForumId(), $a_user_id));
return $res->numRows();
}

+ Here is the call graph for this function:

ilForum::deletePost (   $post)

delete post and sub-posts

Parameters
integer$post,:ID public
Returns
integer 0 or thread-ID

Definition at line 1029 of file class.ilForum.php.

References $ilDB, $mobs, __deletePostFiles(), ilObjForum\_deleteAccessEntries(), ilObjForum\_deleteReadEntries(), ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), DB_FETCHMODE_ASSOC, deletePostTree(), ilNewsItem\getFirstNewsIdForContext(), and getPostNode().

{
global $ilDB;
include_once "./Modules/Forum/classes/class.ilObjForum.php";
// delete tree and get id's of all posts to delete
$p_node = $this->getPostNode($post);
$del_id = $this->deletePostTree($p_node);
// Delete User read entries
foreach($del_id as $post_id)
{
}
// DELETE ATTACHMENTS ASSIGNED TO POST
$this->__deletePostFiles($del_id);
$dead_pos = count($del_id);
$dead_thr = 0;
// if deletePost is thread opener ...
if ($p_node["parent"] == 0)
{
// delete thread access data
include_once './Modules/Forum/classes/class.ilObjForum.php';
// delete thread
$dead_thr = $p_node["tree"];
$statement = $ilDB->manipulateF('
DELETE FROM frm_threads
WHERE thr_pk = %s',
array('integer'), array($p_node['tree']));
// update num_threads
$statement = $ilDB->manipulateF('
UPDATE frm_data
SET top_num_threads = top_num_threads - 1
WHERE top_frm_fk = %s',
array('integer'), array($this->id));
// delete all related news
$posset = $ilDB->queryf('
SELECT * FROM frm_posts
WHERE pos_thr_fk = %s',
array('integer'), array($p_node['tree']));
while ($posrec = $posset->fetchRow(DB_FETCHMODE_ASSOC))
{
include_once("./Services/News/classes/class.ilNewsItem.php");
"frm", $posrec["pos_pk"], "pos");
if ($news_id > 0)
{
$news_item = new ilNewsItem($news_id);
$news_item->delete();
}
try
{
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
$mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $posrec['pos_pk']);
foreach($mobs as $mob)
{
{
ilObjMediaObject::_removeUsage($mob, 'frm:html', $posrec['pos_pk']);
$mob_obj = new ilObjMediaObject($mob);
$mob_obj->delete();
}
}
}
catch(Exception $e)
{
}
}
// delete all posts of this thread
$statement = $ilDB->manipulateF('
DELETE FROM frm_posts
WHERE pos_thr_fk = %s',
array('integer'), array($p_node['tree']));
}
else
{
// delete this post and its sub-posts
for ($i = 0; $i < $dead_pos; $i++)
{
$statement = $ilDB->manipulateF('
DELETE FROM frm_posts
WHERE pos_pk = %s',
array('integer'), array($del_id[$i]));
// delete related news item
include_once("./Services/News/classes/class.ilNewsItem.php");
"frm", $del_id[$i], "pos");
if ($news_id > 0)
{
$news_item = new ilNewsItem($news_id);
$news_item->delete();
}
try
{
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
$mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $del_id[$i]);
foreach($mobs as $mob)
{
{
ilObjMediaObject::_removeUsage($mob, 'frm:html', $del_id[$i]);
$mob_obj = new ilObjMediaObject($mob);
$mob_obj->delete();
}
}
}
catch(Exception $e)
{
}
}
// update num_posts in frm_threads
$statement = $ilDB->manipulateF('
UPDATE frm_threads
SET thr_num_posts = thr_num_posts - %s
WHERE thr_pk = %s',
array('integer', 'integer'),
array($dead_pos, $p_node['tree']));
// get latest post of thread and update last_post
$res1 = $ilDB->queryf('
SELECT * FROM frm_posts
WHERE pos_thr_fk = %s
ORDER BY pos_date DESC',
array('integer'), array($p_node['tree']));
if ($res1->numRows() == 0)
{
$lastPost_thr = "";
}
else
{
$z = 0;
while ($selData = $res1->fetchRow(DB_FETCHMODE_ASSOC))
{
if ($z > 0)
{
break;
}
$lastPost_thr = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
$z ++;
}
}
$statement = $ilDB->manipulateF('
UPDATE frm_threads
SET thr_last_post = %s
WHERE thr_pk = %s',
array('text', 'integer'), array($lastPost_thr, $p_node['tree']));
}
// update num_posts in frm_data
$statement = $ilDB->manipulateF('
UPDATE frm_data
SET top_num_posts = top_num_posts - %s
WHERE top_frm_fk = %s',
array('integer', 'integer'), array($dead_pos, $this->id));
// get latest post of forum and update last_post
$res2 = $ilDB->queryf('
SELECT * FROM frm_posts, frm_data
WHERE pos_top_fk = top_pk
AND top_frm_fk = %s
ORDER BY pos_date DESC',
array('integer'), array($this->id));
if ($res2->numRows() == 0)
{
$lastPost_top = "";
}
else
{
$z = 0;
while ($selData = $res2->fetchRow(DB_FETCHMODE_ASSOC))
{
if ($z > 0)
{
break;
}
$lastPost_top = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
$z ++;
}
}
$statement = $ilDB->manipulateF('
UPDATE frm_data
SET top_last_post = %s
WHERE top_frm_fk = %s',
array('text', 'integer'), array($lastPost_top, $this->id));
return $dead_thr;
}

+ Here is the call graph for this function:

ilForum::deletePostTree (   $a_node)

delete node and the whole subtree under this node public

Parameters
arraynode_data of a node
Returns
array ID's of deleted posts

Definition at line 1960 of file class.ilForum.php.

References $diff, $ilDB, $res, $result, $row, DB_FETCHMODE_ASSOC, and DB_FETCHMODE_OBJECT.

Referenced by deletePost().

{
global $ilDB;
// GET LEFT AND RIGHT VALUES
$res = $ilDB->queryf('
SELECT * FROM frm_posts_tree
WHERE thr_fk = %s
AND pos_fk = %s
AND parent_pos = %s',
array('integer', 'integer', 'integer'),
array($a_node['tree'], $a_node['pos_pk'], $a_node['parent']));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$a_node["lft"] = $row->lft;
$a_node["rgt"] = $row->rgt;
}
$diff = $a_node["rgt"] - $a_node["lft"] + 1;
// get data of posts
$result = $ilDB->queryf('
SELECT * FROM frm_posts_tree
WHERE lft BETWEEN %s AND %s
AND thr_fk = %s',
array('integer', 'integer', 'integer'),
array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
$del_id = array();
while ($treeData = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
$del_id[] = $treeData["pos_fk"];
}
// delete subtree
$statement = $ilDB->manipulateF('
DELETE FROM frm_posts_tree
WHERE lft BETWEEN %s AND %s
AND thr_fk = %s',
array('integer', 'integer', 'integer'),
array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
// close gaps
$statement = $ilDB->manipulateF('
UPDATE frm_posts_tree
SET lft = CASE
WHEN lft > %s
THEN lft - %s
ELSE lft
END,
rgt = CASE
WHEN rgt > %s
THEN rgt - %s
ELSE rgt
END
WHERE thr_fk = %s',
array('integer', 'integer', 'integer', 'integer', 'integer'),
array($a_node['lft'], $diff, $a_node['lft'], $diff, $a_node['tree']));
return $del_id;
}

+ Here is the caller graph for this function:

ilForum::disableForumNotification (   $user_id)

Disable a user's notification about new posts in this forum.

Parameters
integeruser_id A user's ID
Returns
bool true private

Definition at line 2373 of file class.ilForum.php.

References $ilDB.

{
global $ilDB;
$statement = $ilDB->manipulateF('
DELETE FROM frm_notification
WHERE user_id = %s
AND frm_id = %s',
array('integer', 'integer'),
array($user_id, $this->id));
return true;
}
ilForum::enableForumNotification (   $user_id)

Enable a user's notification about new posts in this forum.

Parameters
integeruser_id A user's ID
Returns
bool true private

Definition at line 2294 of file class.ilForum.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_ASSOC, and isForumNotificationEnabled().

{
global $ilDB;
if (!$this->isForumNotificationEnabled($user_id))
{
/* Remove all notifications of threads that belong to the forum */
$res = $ilDB->queryf('
SELECT frm_notification.thread_id FROM frm_data, frm_notification, frm_threads
WHERE frm_notification.user_id = %s
AND frm_notification.thread_id = frm_threads.thr_pk
AND frm_threads.thr_top_fk = frm_data.top_pk
AND frm_data.top_frm_fk = %s
GROUP BY frm_notification.thread_id',
array('integer', 'integer'),
array($user_id, $this->id));
if (is_object($res) && $res->numRows() > 0)
{
$thread_data = array();
$thread_data_types = array();
$query = ' DELETE FROM frm_notification
WHERE user_id = %s
AND thread_id IN (';
array_push($thread_data, $user_id);
array_push($thread_data_types, 'integer');
$counter = 1;
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
if($counter < $res->numRows())
{
$query .= '%s, ';
array_push($thread_data, $row['thread_id']);
array_push($thread_data_types, 'integer');
}
if($counter == $res->numRows())
{
$query .= '%s)';
array_push($thread_data, $row['thread_id']);
array_push($thread_data_types, 'integer');
}
$counter++;
}
$statement = $ilDB->manipulateF($query, $thread_data_types, $thread_data);
}
/* Insert forum notification */
$nextId = $ilDB->nextId('frm_notification');
$statement = $ilDB->manipulateF('
INSERT INTO frm_notification
( notification_id,
user_id,
frm_id
)
VALUES(%s, %s, %s)',
array('integer','integer', 'integer'),
array($nextId, $user_id, $this->id));
}
return true;
}

+ Here is the call graph for this function:

ilForum::enableThreadNotification (   $user_id,
  $thread_id 
)

Enable a user's notification about new posts in a thread.

Parameters
integeruser_id A user's ID
integerthread_id ID of the thread
Returns
bool true private

Definition at line 2415 of file class.ilForum.php.

References $ilDB, and isThreadNotificationEnabled().

{
global $ilDB;
if (!$this->isThreadNotificationEnabled($user_id, $thread_id))
{
$nextId = $ilDB->nextId('frm_notification');
$statement = $ilDB->manipulateF('
INSERT INTO frm_notification
( notification_id,
user_id,
thread_id
)
VALUES (%s, %s, %s)',
array('integer', 'integer', 'integer'), array($nextId, $user_id, $thread_id));
}
return true;
}

+ Here is the call graph for this function:

ilForum::fetchPostNodeData (   $a_row)

get data of parent node from frm_posts_tree and frm_posts private

Parameters
objectdb db result object containing node_data
Returns
array 2-dim (int/str) node_data

Definition at line 1885 of file class.ilForum.php.

References $data, $lng, and ilObject\_exists().

Referenced by getFirstPostNode(), getPostChilds(), getPostNode(), and getPostTree().

{
global $lng;
require_once('./Services/User/classes/class.ilObjUser.php');
if (ilObject::_exists($a_row->pos_usr_id))
{
$tmp_user = new ilObjUser($a_row->pos_usr_id);
$fullname = $tmp_user->getFullname();
$loginname = $tmp_user->getLogin();
}
$fullname = $fullname ? $fullname : ($a_row->import_name ? $a_row->import_name : $lng->txt("unknown"));
$data = array(
"pos_pk" => $a_row->pos_pk,
"child" => $a_row->pos_pk,
"author" => $a_row->pos_usr_id,
"alias" => $a_row->pos_usr_alias,
"title" => $fullname,
"loginname" => $loginname,
"type" => "post",
"message" => $a_row->pos_message,
"subject" => $a_row->pos_subject,
"pos_cens_com" => $a_row->pos_cens_com,
"pos_cens" => $a_row->pos_cens,
// "date" => $a_row->date,
"date" => $a_row->fpt_date,
"create_date" => $a_row->pos_date,
"update" => $a_row->pos_update,
"update_user" => $a_row->update_user,
"tree" => $a_row->thr_fk,
"parent" => $a_row->parent_pos,
"lft" => $a_row->lft,
"rgt" => $a_row->rgt,
"depth" => $a_row->depth,
"id" => $a_row->fpt_pk,
"notify" => $a_row->notify,
"import_name" => $a_row->import_name,
"pos_status" => $a_row->pos_status
);
// why this line? data should be stored without slashes in db
//$data["message"] = stripslashes($data["message"]);
return $data ? $data : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::fixThreadNumber (   $a_top_pk,
  $a_num_threads 
)

In some rare cases the thread number in frm_data is incorrect.

This function fixes this. (called in ilObjForumGUI->showThreadsObject())

Definition at line 435 of file class.ilForum.php.

References $ilDB.

{
global $ilDB;
if ($a_top_pk > 0)
{
$statement = $ilDB->manipulateF('
UPDATE frm_data
SET top_num_threads = %s
WHERE top_pk = %s',
array('integer', 'integer'),
array($a_num_threads, $a_top_pk));
}
}
ilForum::formatNotification (   $post_data,
  $cron = 0 
)

Definition at line 2732 of file class.ilForum.php.

References $ilIliasIniFile.

Referenced by sendForumNotifications(), and sendThreadNotifications().

{
if ($cron == 1)
{
$message = sprintf($this->lng->txt("forums_notification_intro"),
$this->ilias->ini->readVariable("client","name"),
$ilIliasIniFile->readVariable("server","http_path").'/?client_id='.CLIENT_ID)."\n\n";
}
else
{
$message = sprintf($this->lng->txt("forums_notification_intro"),
$this->ilias->ini->readVariable("client","name"),
ILIAS_HTTP_PATH.'/?client_id='.CLIENT_ID)."\n\n";
}
$message .= $this->lng->txt("forum").": ".$post_data["top_name"]."\n\n";
$message .= $this->lng->txt("thread").": ".$post_data["thr_subject"]."\n\n";
$message .= $this->lng->txt("new_post").":\n------------------------------------------------------------\n";
$message .= $this->lng->txt("author").": ".$post_data["pos_usr_name"]."\n";
$message .= $this->lng->txt("date").": ".$post_data["pos_date"]."\n";
$message .= $this->lng->txt("subject").": ".$post_data["pos_subject"]."\n\n";
if ($post_data["pos_cens"] == 1)
{
$message .= $post_data["pos_cens_com"]."\n";
}
else
{
$message .= $post_data["pos_message"]."\n";
}
$message .= "------------------------------------------------------------\n";
if ($cron == 1)
{
$message .= sprintf($this->lng->txt("forums_notification_show_post"), $ilIliasIniFile->readVariable("server","http_path")."/goto.php?target=frm_".$post_data["ref_id"]."_".$post_data["pos_thr_fk"]."_".$post_data["pos_pk"].'&client_id='.CLIENT_ID);
}
else
{
$message .= sprintf($this->lng->txt("forums_notification_show_post"), ILIAS_HTTP_PATH."/goto.php?target=frm_".$post_data["ref_id"]."_".$post_data["pos_thr_fk"]."_".$post_data["pos_pk"].'&client_id='.CLIENT_ID);
}
return $message;
}

+ Here is the caller graph for this function:

ilForum::formatNotificationSubject (   $post_data)

Definition at line 2727 of file class.ilForum.php.

Referenced by sendForumNotifications(), and sendThreadNotifications().

{
return $this->lng->txt("forums_notification_subject").' '.$post_data['top_name'];
}

+ Here is the caller graph for this function:

ilForum::formatPostActivationNotification (   $post_data)

Definition at line 2639 of file class.ilForum.php.

Referenced by sendPostActivationNotification().

{
$message = sprintf($this->lng->txt('forums_notification_intro'),
$this->ilias->ini->readVariable('client', 'name'),
ILIAS_HTTP_PATH.'/?client_id='.CLIENT_ID)."\n\n";
$message .= $this->lng->txt('forums_post_activation_mail')."\n\n";
$message .= $this->lng->txt("forum").": ".$post_data["top_name"]."\n\n";
$message .= $this->lng->txt("thread").": ".$post_data["thr_subject"]."\n\n";
$message .= $this->lng->txt("new_post").":\n------------------------------------------------------------\n";
$message .= $this->lng->txt("author").": ".$post_data["pos_usr_name"]."\n";
$message .= $this->lng->txt("date").": ".$post_data["pos_date"]."\n";
$message .= $this->lng->txt("subject").": ".$post_data["pos_subject"]."\n\n";
if ($post_data["pos_cens"] == 1)
{
$message .= $post_data["pos_cens_com"]."\n";
}
else
{
$message .= $post_data["pos_message"]."\n";
}
$message .= "------------------------------------------------------------\n";
$message .= sprintf($this->lng->txt('forums_notification_show_post'), ILIAS_HTTP_PATH."/goto.php?target=frm_".$post_data["ref_id"]."_".$post_data["pos_thr_fk"]."_".$post_data["pos_pk"].'&client_id='.CLIENT_ID);
return $message;
}

+ Here is the caller graph for this function:

ilForum::formatPostActivationNotificationSubject ( )

Definition at line 2634 of file class.ilForum.php.

Referenced by sendPostActivationNotification().

{
return $this->lng->txt('forums_notification_subject');
}

+ Here is the caller graph for this function:

ilForum::generatePost (   $forum_id,
  $thread_id,
  $user,
  $message,
  $parent_pos,
  $notify,
  $subject = '',
  $alias = '',
  $date = '',
  $status = 1,
  $send_activation_mail = 0 
)

generate new dataset in frm_posts

Parameters
integer$topic
integer$thread
integer$user
string$message
integer$parent_pos
integer$notify
integer$anonymize
string$subject
datetime$date
Returns
integer $lastInsert: new post ID public

Definition at line 569 of file class.ilForum.php.

References $ilDB, $result, $user, __sendMessage(), ilRTE\_replaceMediaObjectImageSrc(), addPostTree(), getForumRefId(), getImportName(), ilObjectFactory\getInstanceByRefId(), insertPostNode(), NEWS_NOTICE, NEWS_USERS, prepareText(), sendForumNotifications(), sendPostActivationNotification(), and sendThreadNotifications().

Referenced by generateThread().

{
global $ilUser, $ilDB;
$objNewPost = new ilForumPost();
$objNewPost->setForumId($forum_id);
$objNewPost->setThreadId($thread_id);
$objNewPost->setSubject($subject);
$objNewPost->setMessage($message);
$objNewPost->setUserId($user);
$objNewPost->setUserAlias($alias);
if ($date == "")
{
$objNewPost->setCreateDate(date("Y-m-d H:i:s"));
}
else
{
if (strpos($date, "-") > 0) // in mysql format
{
$objNewPost->setCreateDate($date);
}
else // a timestamp
{
$objNewPost->setCreateDate(date("Y-m-d H:i:s", $date));
}
}
$objNewPost->setImportName($this->getImportName());
$objNewPost->setNotification($notify);
$objNewPost->setStatus($status);
$objNewPost->insert();
// entry in tree-table
if ($parent_pos == 0)
{
$this->addPostTree($objNewPost->getThreadId(), $objNewPost->getId(), $objNewPost->getCreateDate());
}
else
{
$this->insertPostNode($objNewPost->getId(), $parent_pos, $objNewPost->getThreadId(), $objNewPost->getCreateDate());
}
//echo "<br>->".$objNewPost->getId()."-".$parent_pos."-".$objNewPost->getThreadId()."-".
// $objNewPost->getCreateDate()."-".$forum_id."-".$message."-".$user."-";
// string last post
$lastPost = $objNewPost->getForumId()."#".$objNewPost->getThreadId()."#".$objNewPost->getId();
// update thread
$result = $ilDB->manipulateF('
UPDATE frm_threads
SET thr_num_posts = thr_num_posts + 1,
thr_last_post = %s
WHERE thr_pk = %s',
array('text', 'integer'),
array($lastPost, $objNewPost->getThreadId()));
// update forum
$result = $ilDB->manipulateF('
UPDATE frm_data
SET top_num_posts = top_num_posts + 1,
top_last_post = %s
WHERE top_pk = %s',
array('text', 'integer'),
array($lastPost, $objNewPost->getForumId()));
// MARK READ
$forum_obj->markPostRead($objNewPost->getUserId(), $objNewPost->getThreadId(), $objNewPost->getId());
$pos_data = $objNewPost->getDataAsArray();
$pos_data["ref_id"] = $this->getForumRefId();
// FINALLY SEND MESSAGE
if ($this->ilias->getSetting("forum_notification") == 1 && (int)$status )
{
$this->__sendMessage($parent_pos, $pos_data);
$pos_data["top_name"] = $forum_obj->getTitle();
$this->sendForumNotifications($pos_data);
$this->sendThreadNotifications($pos_data);
}
// Send notification to moderators if they have to enable a post
if (!$status && $send_activation_mail)
{
$pos_data["top_name"] = $forum_obj->getTitle();
$this->sendPostActivationNotification($pos_data);
}
// Add Notification to news
if ($status)
{
require_once 'Services/RTE/classes/class.ilRTE.php';
include_once("./Services/News/classes/class.ilNewsItem.php");
$news_item = new ilNewsItem();
$news_item->setContext($forum_obj->getId(), 'frm', $objNewPost->getId(), 'pos');
$news_item->setPriority(NEWS_NOTICE);
$news_item->setTitle($objNewPost->getSubject());
$news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($this->prepareText($objNewPost->getMessage(), 0), 1));
$news_item->setUserId($user);
$news_item->setVisibility(NEWS_USERS);
$news_item->create();
}
return $objNewPost->getId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::generateThread (   $forum_id,
  $user,
  $subject,
  $message,
  $notify,
  $notify_posts,
  $alias = '',
  $date = '' 
)

generate new dataset in frm_threads

Parameters
integer$topic
integer$user
string$subject
string$message
integer$notify
integer$notify_posts
integer$anonymize
datetime$date
Returns
integer new post ID public

Definition at line 690 of file class.ilForum.php.

References $ilDB, $user, generatePost(), and getImportName().

{
global $ilDB;
$objNewThread = new ilForumTopic();
$objNewThread->setForumId($forum_id);
$objNewThread->setUserId($user);
$objNewThread->setSubject($subject);
if ($date == "")
{
$objNewThread->setCreateDate(date("Y-m-d H:i:s"));
}
else
{
if (strpos($date, "-") > 0) // in mysql format
{
$objNewThread->setCreateDate($date);
}
else // a timestamp
{
$objNewThread->setCreateDate(date("Y-m-d H:i:s", $date));
}
}
$objNewThread->setImportName($this->getImportName());
$objNewThread->setUserAlias($alias);
$objNewThread->insert();
if ($notify_posts == 1)
{
$objNewThread->enableNotification($user);
}
// update forum
$statement = $ilDB->manipulateF('
UPDATE frm_data
SET top_num_threads = top_num_threads + 1
WHERE top_pk = %s',
array('integer'), array($forum_id));
return $this->generatePost($forum_id, $objNewThread->getId(), $user, $message, 0, $notify, $subject, $alias, $objNewThread->getCreateDate());
}

+ Here is the call graph for this function:

ilForum::getAllForums ( )

Definition at line 808 of file class.ilForum.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_ASSOC, getMDB2DataType(), getMDB2DataValue(), and getMDB2Query().

{
global $ilDB;
$data_type = array();
$data_value = array();
$query = 'SELECT *
FROM frm_data
WHERE ';
if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
{
$query .= $this->getMDB2Query();
$data_type = $data_type + $this->getMDB2DataType();
$data_value = $data_value + $this->getMDB2DataValue();
$res = $ilDB->queryf($query, $data_type, $data_value);
}
else
{
$query .= '1';
$res = $ilDB->query($query);
}
$counter = 0;
while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
$forums[$counter] = $row;
++$counter;
}
return is_array($forums) ? $forums : array();
}

+ Here is the call graph for this function:

ilForum::getAllThreads (   $a_topic_id,
  $is_moderator = false 
)

Get all threads of given thread.

Parameters
integertopic: Forum-ID
Returns
array this->threads array ob thread objects public

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

References $data, $ilDB, $query, $res, $row, and $threads.

{
global $ilDB, $ilUser;
$this->threads = array();
$data = array();
$data_types = array();
$query = 'SELECT thr_pk, MAX(pos_date) post_date, is_sticky, thr_date
FROM frm_threads
LEFT JOIN frm_posts ON pos_thr_fk = thr_pk';
if (!$is_moderator)
{
$query .= ' AND (pos_status = %s
OR (pos_status = %s
AND pos_usr_id = %s))';
array_push($data_types, 'integer', 'integer', 'integer');
array_push($data, '1', '0', $ilUser->getId());
}
$query .= ' WHERE thr_top_fk = %s
GROUP BY thr_pk, is_sticky, thr_date
ORDER BY is_sticky DESC, post_date DESC, thr_date DESC';
array_push($data_types, 'integer');
array_push($data, $a_topic_id);
$res = $ilDB->queryf($query, $data_types, $data);
while ($row = $ilDB->fetchObject($res))
{
$this->threads[] = new ilForumTopic($row->thr_pk);
}
return $this->threads;
}
ilForum::getDbTable ( )

get name of database table

Returns
string name of database table
See Also
$dbTable User interface

Definition at line 240 of file class.ilForum.php.

References $dbTable.

{
}
ilForum::getFirstPostByThread (   $a_thread_id)

Get first post of thread.

public

Parameters
intthread id
Returns

Definition at line 1396 of file class.ilForum.php.

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

Referenced by updatePost().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_posts_tree
WHERE thr_fk = %s
AND parent_pos = %s',
array('integer', 'integer'), array($a_thread_id, '0'));
return $row->pos_fk ? $row->pos_fk : 0;
}

+ Here is the caller graph for this function:

ilForum::getFirstPostNode (   $tree_id)

get data of the first node from frm_posts_tree and frm_posts public

Parameters
integertree id
Returns
object db result object

Definition at line 1840 of file class.ilForum.php.

References $ilDB, $res, $row, DB_FETCHMODE_OBJECT, and fetchPostNodeData().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_posts, frm_posts_tree
WHERE pos_pk = pos_fk
AND parent_pos = %s
AND thr_fk = %s',
array('integer', 'integer'),
array('0', $tree_id));
return $this->fetchPostNodeData($row);
}

+ Here is the call graph for this function:

ilForum::getForumId ( )

get forum id public

Returns
integer object id of forum

Definition at line 172 of file class.ilForum.php.

References $id.

Referenced by __deletePostFiles(), countActiveUserArticles(), countUserArticles(), and getUserStatistic().

{
return $this->id;
}

+ Here is the caller graph for this function:

ilForum::getForumPath (   $a_ref_id)

builds a string to show the forum-context

Parameters
integerref_id
Returns
string public

Definition at line 1569 of file class.ilForum.php.

{
global $tree;
$path = "";
$tmpPath = $tree->getPathFull($a_ref_id);
// count -1, to exclude the forum itself
for ($i = 0; $i < (count($tmpPath)-1); $i++)
{
if ($path != "")
{
$path .= " > ";
}
$path .= $tmpPath[$i]["title"];
}
return $path;
}
ilForum::getForumRefId ( )

get forum ref_id public

Returns
integer reference id of forum

Definition at line 182 of file class.ilForum.php.

References $ref_id.

Referenced by __formatMessage(), generatePost(), and getModerators().

{
return $this->ref_id;
}

+ Here is the caller graph for this function:

ilForum::getImportName ( )

Definition at line 2279 of file class.ilForum.php.

Referenced by generatePost(), and generateThread().

{
return $this->import_name;
}

+ Here is the caller graph for this function:

ilForum::getLastPost (   $lastPost)

get content of given ID's

Parameters
string$lastPost,:ID's, separated with #
Returns
array $result public

Definition at line 1417 of file class.ilForum.php.

References $data, $result, convertDate(), and prepareText().

{
$data = explode('#', $lastPost);
$objLastPost = new ilForumPost($data[2]);
// limit the message-size
$message = $this->prepareText($objLastPost->getMessage(), 2);
if (strpos($message, $this->txtQuote2) > 0)
{
$viewPos = strrpos($message, $this->txtQuote2) + strlen($this->txtQuote2);
$message = substr($message, $viewPos);
}
if (strlen($message) > 40)
{
$message = substr($objLastPost->getMessage(), 0, 37).'...';
}
$result["pos_message"] = $result["pos_message"];
// convert date
$objLastPost->setCreateDate($this->convertDate($objLastPost->getCreateDate()));
return $objLastPost;
}

+ Here is the call graph for this function:

ilForum::getMDB2DataType ( )

get content of additional condition

Returns
array

Definition at line 299 of file class.ilForum.php.

References $mdb2DataType.

Referenced by getAllForums(), getOneDataset(), getOneThread(), getOneTopic(), and updateVisits().

{
if($this->mdb2DataType != '')
{
}
}

+ Here is the caller graph for this function:

ilForum::getMDB2DataValue ( )

/* get content of additional condition

Returns
array

Definition at line 286 of file class.ilForum.php.

References $mdb2DataValue.

Referenced by getAllForums(), getOneDataset(), getOneThread(), getOneTopic(), and updateVisits().

{
if($this->mdb2DataValue != '')
{
}
}

+ Here is the caller graph for this function:

ilForum::getMDB2Query ( )

get content of additional condition

Returns
string

Definition at line 272 of file class.ilForum.php.

References $mdb2Query.

Referenced by getAllForums(), getOneDataset(), getOneThread(), getOneTopic(), and updateVisits().

{
if($this->mdb2Query != '')
{
}
}

+ Here is the caller graph for this function:

ilForum::getModeratorFromPost (   $pos_pk)

get one post-dataset

Parameters
integerpost id
Returns
array result dataset of the post public

Definition at line 2154 of file class.ilForum.php.

References $ilDB, $res, $row, and DB_FETCHMODE_ASSOC.

{
global $ilDB;
$res = $ilDB->queryf('
SELECT frm_data.* FROM frm_data, frm_posts
WHERE pos_pk = %s
AND pos_top_fk = top_pk',
array('integer'), array($pos_pk));
return $row;
}
ilForum::getModerators ( )

get all users assigned to local role il_frm_moderator_<frm_ref_id>

Returns
array user_ids public

Definition at line 1473 of file class.ilForum.php.

References _getModerators(), and getForumRefId().

Referenced by sendPostActivationNotification().

{
global $rbacreview;
return $this->_getModerators($this->getForumRefId());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::getOneDataset ( )

get one dataset from set Table and set WhereCondition

Returns
array $res dataset public

Definition at line 344 of file class.ilForum.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_ASSOC, getMDB2DataType(), getMDB2DataValue(), and getMDB2Query().

{
global $ilDB;
$data_type = array();
$data_value = array();
$query = 'SELECT * FROM '.$this->dbTable.' WHERE ';
if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
{
$query .= $this->getMDB2Query();
if ($this->orderField != "")
{
$query .= " ORDER BY ".$this->orderField;
}
$data_type = $data_type + $this->getMDB2DataType();
$data_value = $data_value + $this->getMDB2DataValue();
$res = $ilDB->queryf($query, $data_type, $data_value);
}
else
{
$query .= '1';
if ($this->orderField != "")
{
$query .= " ORDER BY ".$this->orderField;
}
$res = $ilDB->query($query);
}
return $row;
}

+ Here is the call graph for this function:

ilForum::getOnePost (   $post)

get one post-dataset

Parameters
integerpost id
Returns
array result dataset of the post public

Definition at line 504 of file class.ilForum.php.

References $ilDB, $res, $row, convertDate(), and DB_FETCHMODE_ASSOC.

Referenced by __sendMessage().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT frm_posts.*, usr_data.lastname FROM frm_posts, usr_data
WHERE pos_pk = %s
AND pos_usr_id = usr_id',
array('integer'), array($post));
$row["pos_date"] = $this->convertDate($row["pos_date"]);
$row["pos_message"] = nl2br($row["pos_message"]);
return $row;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::getOneThread ( )

get one thread-dataset by WhereCondition

Returns
array $result dataset of the thread public

Definition at line 475 of file class.ilForum.php.

References $ilDB, $query, $result, DB_FETCHMODE_ASSOC, getMDB2DataType(), getMDB2DataValue(), and getMDB2Query().

Referenced by __sendMessage().

{
global $ilDB;
$data_type = array();
$data_value = array();
$query = 'SELECT * FROM frm_threads WHERE ';
if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
{
$query .= $this->getMDB2Query();
$data_type = $data_type + $this->getMDB2DataType();
$data_value = $data_value + $this->getMDB2DataValue();
$sql_res = $ilDB->queryf($query, $data_type, $data_value);
$result = $sql_res->fetchRow(DB_FETCHMODE_ASSOC);
$result["thr_subject"] = trim($result["thr_subject"]);
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::getOneTopic ( )

get one topic-dataset by WhereCondition

Returns
array $result dataset of the topic public

Definition at line 389 of file class.ilForum.php.

References $ilDB, $query, $res, $row, getMDB2DataType(), getMDB2DataValue(), and getMDB2Query().

Referenced by moveThreads().

{
global $ilDB;
$data_type = array();
$data_value = array();
$query = 'SELECT * FROM frm_data WHERE ';
if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
{
$query .= ''.$this->getMDB2Query().'';
$data_type = $data_type + $this->getMDB2DataType();
$data_value = $data_value + $this->getMDB2DataValue();
$res = $ilDB->queryf($query, $data_type, $data_value);
$row = $ilDB->fetchAssoc($res);
if(is_null($row)) return NULL;
$row["top_name"] = trim($row["top_name"]);
$row["top_description"] = nl2br($row["top_description"]);
return $row;
}
else
{
$query .= '1 = 1';
$res = $ilDB->query($query);
$row = $ilDB->fetchAssoc($res);
if(!is_array($row) || !count($row)) return null;
$row['top_name'] = trim($row['top_name']);
$row['top_description'] = nl2br($row['top_description']);
return $row;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::getOrderField ( )

get name of orderField

Returns
string name of orderField
See Also
$orderField User interface

Definition at line 211 of file class.ilForum.php.

References $orderField.

{
}
ilForum::getPageHits ( )

get number of max.

visible datasets

Returns
integer $pageHits
See Also
$pageHits User interface

Definition at line 332 of file class.ilForum.php.

References $pageHits.

{
}
ilForum::getPostById (   $a_id)

Definition at line 523 of file class.ilForum.php.

References $ilDB, $res, $row, and DB_FETCHMODE_ASSOC.

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_posts
WHERE pos_pk = %s',
array('integer'), array($a_id));
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
return $row;
}
return array();
}
ilForum::getPostChilds (   $a_node_id,
  $a_thr_id 
)

get child nodes of given node public

Parameters
integernode_id
stringsort order of returned childs, optional (possible values: 'title','desc','last_update' or 'type')
stringsort direction, optional (possible values: 'DESC' or 'ASC'; defalut is 'ASC')
Returns
array with node data of all childs or empty array

Definition at line 1796 of file class.ilForum.php.

References $ilDB, $res, $row, DB_FETCHMODE_OBJECT, and fetchPostNodeData().

{
global $ilDB;
// init childs
$childs = array();
// number of childs
$count = 0;
$res = $ilDB->queryf('
SELECT * FROM frm_posts_tree,frm_posts
WHERE frm_posts.pos_pk = frm_posts_tree.pos_fk
AND 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, $a_thr_id));
$count = $res->numRows();
if ($count > 0)
{
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$childs[] = $this->fetchPostNodeData($row);
}
// mark the last child node (important for display)
$childs[$count - 1]["last"] = true;
return $childs;
}
else
{
return $childs;
}
}

+ Here is the call graph for this function:

ilForum::getPostDepth (   $a_node_id,
  $tree_id 
)

Return depth of an object private.

Parameters
integernode_id of parent's node_id
integernode_id of parent's node parent_id
Returns
integer depth of node

Definition at line 1722 of file class.ilForum.php.

References $ilDB, $res, and DB_FETCHMODE_OBJECT.

Referenced by insertPostNode().

{
global $ilDB;
if ($tree_id)
{
$sql_res = $ilDB->queryf('
SELECT depth FROM frm_posts_tree
WHERE pos_fk = %s
AND thr_fk = %s',
array('integer', 'integer'),
array($a_node_id, $tree_id));
$res = $sql_res->fetchRow(DB_FETCHMODE_OBJECT);
return $res->depth;
}
else
{
return 0;
}
}

+ Here is the caller graph for this function:

ilForum::getPostList (   $topic,
  $thread 
)

get all posts of given thread

Parameters
integertopic: forum-ID
integerthread: thread-ID
Returns
object res result identifier for use with fetchRow public

Definition at line 1305 of file class.ilForum.php.

References $data, $ilDB, $query, and $result.

{
global $ilDB;
$data_types = array();
$data = array();
$query =' SELECT frm_posts.*, usr_data.lastname FROM frm_posts, usr_data
WHERE pos_top_fk = %s
AND pos_thr_fk = %s
AND pos_usr_id = usr_id';
array_push($data_types, 'integer', 'integer');
array_push($data, $topic, $thread);
if($this->orderField != '')
{
$query .= ' ORDER BY '.$this->orderField .' ';
}
$result = $ilDB->queryf($query, $data_types, $data);
return $result;
}
ilForum::getPostMaximumDepth (   $a_thr_id)

Return the maximum depth in tree public.

Returns
integer max depth level of tree

Definition at line 1939 of file class.ilForum.php.

References $ilDB, $res, and $row.

{
global $ilDB;
$res = $ilDB->queryf('
SELECT MAX(depth) FROM frm_posts_tree
WHERE thr_fk = %s',
array('integer'),array($a_thr_id));
$row = $res->fetchRow();
return $row[0];
}
ilForum::getPostNode (   $post_id)

get data of given node from frm_posts_tree and frm_posts public

Parameters
integerpost_id
Returns
object db result object

Definition at line 1863 of file class.ilForum.php.

References $ilDB, $res, $row, DB_FETCHMODE_OBJECT, and fetchPostNodeData().

Referenced by deletePost().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_posts, frm_posts_tree
WHERE pos_pk = pos_fk
AND pos_pk = %s',
array('integer'),
array($post_id));
return $this->fetchPostNodeData($row);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::getPostTree (   $a_node)

get all nodes in the subtree under specified node

public

Parameters
arraynode_data
Returns
array 2-dim (int/array) key, node_data of each subtree node including the specified node

Definition at line 1752 of file class.ilForum.php.

References $data, $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, and fetchPostNodeData().

{
global $ilDB;
$subtree = array();
$data = array();
$data_types = array();
$query = ' SELECT * FROM frm_posts_tree
LEFT JOIN frm_posts ON frm_posts.pos_pk = frm_posts_tree.pos_fk
WHERE frm_posts_tree.lft BETWEEN %s AND %s
AND thr_fk = %s';
array_push($data_types, 'integer', 'integer', 'integer');
array_push($data, $a_node['lft'], $a_node['rgt'], $a_node['tree']);
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 = $ilDB->queryf($query, $data_types, $data);
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$subtree[] = $this->fetchPostNodeData($row);
}
return $subtree;
}

+ Here is the call graph for this function:

ilForum::getUser (   $a_user_id)

get content of given user-ID

Parameters
integer$a_user_id,:user-ID
Returns
object user object public

Definition at line 1452 of file class.ilForum.php.

References $lng, ilObject\_exists(), and ilObjectFactory\getInstanceByObjId().

{
global $lng;
$userObj = ilObjectFactory::getInstanceByObjId($a_user_id, false);
if(!ilObject::_exists($a_user_id) || !$userObj)
{
$userObj = new ilObjUser();
$userObj->setLogin($lng->txt("unknown"));
}
return $userObj;
}

+ Here is the call graph for this function:

ilForum::getUserData (   $a_id,
  $a_import_name = 0 
)

Definition at line 2249 of file class.ilForum.php.

References $ilDB, $lng, $login, $res, $row, ilObject\_exists(), ilObjUser\_lookupPref(), DB_FETCHMODE_OBJECT, and ilObjectFactory\getInstanceByObjId().

{
global $lng, $ilDB;
if($a_id && ilObject::_exists($a_id) && ilObjectFactory::getInstanceByObjId($a_id,false))
{
$res = $ilDB->queryf('
SELECT * FROM usr_data WHERE usr_id = %s',
array('integer'), array($a_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$tmp_array["usr_id"] = $row->usr_id;
$tmp_array["login"] = $row->login;
$tmp_array["firstname"] = $row->firstname;
$tmp_array["lastname"] = $row->lastname;
$tmp_array["public_profile"] = ilObjUser::_lookupPref($a_id, "public_profile");
$tmp_array["create_date"] = $row->create_date;
}
return $tmp_array ? $tmp_array : array();
}
else
{
$login = $a_import_name ? $a_import_name." (".$lng->txt("imported").")" : $lng->txt("unknown");
return array("usr_id" => 0, "login" => $login, "firstname" => "", "lastname" => "");
}
}

+ Here is the call graph for this function:

ilForum::getUserStatistic (   $is_moderator = false)

Definition at line 1330 of file class.ilForum.php.

References $data, $ilDB, $query, $res, $row, DB_FETCHMODE_ASSOC, and getForumId().

{
global $ilDB, $ilUser;
$statistic = array();
$data_types = array();
$data = array();
$query = "SELECT COUNT(f.pos_usr_id) ranking, u.login, p.value, u.lastname, u.firstname
FROM frm_posts f
INNER JOIN frm_posts_tree t
ON f.pos_pk = t.pos_fk
INNER JOIN frm_threads th
ON t.thr_fk = th.thr_pk
INNER JOIN usr_data u
ON u.usr_id = f.pos_usr_id
INNER JOIN frm_data d
ON d.top_pk = f.pos_top_fk
LEFT JOIN usr_pref p
ON p.usr_id = u.usr_id AND p.keyword = %s
WHERE 1 = 1";
array_push($data_types, 'text');
array_push($data, 'public_profile');
if (!$is_moderator)
{
$query .= ' AND (pos_status = %s
OR (pos_status = %s
AND pos_usr_id = %s ))';
array_push($data_types,'integer', 'integer', 'integer');
array_push($data, '1', '0', $ilUser->getId());
}
$query .= ' AND d.top_frm_fk = %s
GROUP BY pos_usr_id, u.login, p.value, u.lastname, u.firstname';
array_push($data_types,'integer');
array_push($data, $this->getForumId());
$res = $ilDB->queryf($query, $data_types, $data);
$counter = 0;
while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
$statistic[$counter][] = $row['ranking'];
$statistic[$counter][] = $row['login'];
$statistic[$counter][] = ($row['value'] != 'y' ? '' : $row['lastname']);
$statistic[$counter][] = ($row['value'] != 'y' ? '' : $row['firstname']);
++$counter;
}
return is_array($statistic) ? $statistic : array();
}

+ Here is the call graph for this function:

ilForum::ilForum ( )

Constructor public.

Definition at line 95 of file class.ilForum.php.

References $ilias, and $lng.

{
global $ilias,$lng;
$this->ilias =& $ilias;
$this->lng =& $lng;
}
ilForum::insertPostNode (   $a_node_id,
  $a_parent_id,
  $tree_id,
  $a_date = '' 
)

insert node under parent node public

Parameters
integernode_id
integertree_id
integerparent_id (optional)

Definition at line 1648 of file class.ilForum.php.

References $ilDB, $res, DB_FETCHMODE_OBJECT, and getPostDepth().

Referenced by generatePost().

{
global $ilDB;
$a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
// get left value
$sql_res = $ilDB->queryf('
SELECT * FROM frm_posts_tree
WHERE pos_fk = %s
AND thr_fk = %s',
array('integer', 'integer'),
array($a_parent_id, $tree_id));
$res = $sql_res->fetchRow(DB_FETCHMODE_OBJECT);
$left = $res->lft;
$lft = $left + 1;
$rgt = $left + 2;
// spread tree
$statement = $ilDB->manipulateF('
UPDATE frm_posts_tree
SET lft = CASE
WHEN lft > %s
THEN lft + 2
ELSE lft
END,
rgt = CASE
WHEN rgt > %s
THEN rgt + 2
ELSE rgt
END
WHERE thr_fk = %s',
array('integer', 'integer', 'integer'),
array($left, $left, $tree_id));
$depth = $this->getPostDepth($a_parent_id, $tree_id) + 1;
// insert node
$nextId = $ilDB->nextId('frm_posts_tree');
$statement = $ilDB->manipulateF('
INSERT INTO frm_posts_tree
( fpt_pk,
thr_fk,
pos_fk,
parent_pos,
lft,
rgt,
depth,
fpt_date
)
VALUES(%s,%s,%s, %s, %s, %s,%s, %s)',
array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
array( $nextId,
$tree_id,
$a_node_id,
$a_parent_id,
$lft,
$rgt,
$depth,
$a_date)
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::isForumNotificationEnabled (   $user_id)

Check whether a user's notification about new posts in this forum is enabled (result > 0) or not (result == 0)

Parameters
integeruser_id A user's ID
Returns
integer Result private

Definition at line 2393 of file class.ilForum.php.

References $ilDB, and $result.

Referenced by enableForumNotification().

{
global $ilDB;
$result = $ilDB->queryf('SELECT COUNT(*) cnt FROM frm_notification WHERE user_id = %s AND frm_id = %s',
array('integer', 'integer'), array($user_id, $this->id));
while($record = $ilDB->fetchAssoc($result))
{
return (bool)$record['cnt'];
}
return false;
}

+ Here is the caller graph for this function:

ilForum::isThreadNotificationEnabled (   $user_id,
  $thread_id 
)

Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (result == 0)

Parameters
integeruser_id A user's ID
integerthread_id ID of the thread
Returns
integer Result private

Definition at line 2443 of file class.ilForum.php.

References $ilDB, and $result.

Referenced by enableThreadNotification().

{
global $ilDB;
$result = $ilDB->queryf('
SELECT COUNT(*) cnt FROM frm_notification
WHERE user_id = %s
AND thread_id = %s',
array('integer', 'integer'),
array($user_id, $thread_id));
while($record = $ilDB->fetchAssoc($result))
{
return (bool)$record['cnt'];
}
return false;
}

+ Here is the caller graph for this function:

ilForum::limitMsgString (   $message)

Definition at line 2814 of file class.ilForum.php.

References prepareText().

{
// limit the message-size
$message = $this->prepareText($message, 2);
if (strpos($message, $this->txtQuote2) > 0)
{
$viewPos = strrpos($message, $this->txtQuote2) + strlen($this->txtQuote2);
$message = substr($message, $viewPos);
}
if (strlen($message) > 40)
{
$message = substr($message, 0, 37).'...';
}
return $this->prepareText($message);
}

+ Here is the call graph for this function:

ilForum::moveThreads (   $thread_ids = array(),
  $src_ref_id = 0,
  $dest_top_frm_fk = 0 
)

Moves all chosen threads and their posts to a new forum.

Parameters
arraychosen thread pks
integerobject id of src forum
integerobject id of dest forum public

Definition at line 853 of file class.ilForum.php.

References $id, $ilDB, $res, $row, ilObject\_lookupObjectId(), DB_FETCHMODE_OBJECT, getOneTopic(), and setMDB2WhereCondition().

{
global $ilDB;
$src_top_frm_fk = ilObject::_lookupObjectId($src_ref_id);
if (is_numeric($src_top_frm_fk) && $src_top_frm_fk > 0 && is_numeric($dest_top_frm_fk) && $dest_top_frm_fk > 0)
{
$this->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($src_top_frm_fk));
$oldFrmData = $this->getOneTopic();
$this->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($dest_top_frm_fk));
$newFrmData = $this->getOneTopic();
if ($oldFrmData['top_pk'] && $newFrmData['top_pk'])
{
$moved_posts = 0;
$moved_threads = 0;
$visits = 0;
foreach ($thread_ids as $id)
{
$objTmpThread = new ilForumTopic($id);
$numPosts = $objTmpThread->movePosts($src_top_frm_fk, $oldFrmData['top_pk'], $dest_top_frm_fk, $newFrmData['top_pk']);
if (($last_post_string = $objTmpThread->getLastPostString()) != '')
{
$last_post_string = explode('#', $last_post_string);
$last_post_string[0] = $newFrmData['top_pk'];
$last_post_string = implode('#', $last_post_string);
$objTmpThread->setLastPostString($last_post_string);
}
$visits += $objTmpThread->getVisits();
$moved_posts += $numPosts;
++$moved_threads;
$objTmpThread->setForumId($newFrmData['top_pk']);
$objTmpThread->update();
unset($objTmpThread);
}
// update frm_data source forum
$ilDB->setLimit(1);
$res = $ilDB->queryf('
SELECT pos_thr_fk, pos_pk
FROM frm_posts
WHERE pos_top_fk = %s
ORDER BY pos_date DESC',
array('integer'), array($oldFrmData['top_pk']));
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
$last_post_src = $oldFrmData['top_pk'] . '#' . $row->pos_thr_fk . '#' . $row->pos_pk;
$statement = $ilDB->manipulateF('
UPDATE frm_data
SET top_num_posts = top_num_posts - %s,
top_num_threads = top_num_threads - %s,
visits = visits - %s,
top_last_post = %s
WHERE top_pk = %s',
array('integer', 'integer', 'integer', 'text', 'integer'),
array( $moved_posts,
$moved_threads,
$visits,
$last_post_src,
$oldFrmData['top_pk']));
// update frm_data destination forum
$ilDB->setLimit(1);
$res = $ilDB->queryf('
SELECT pos_thr_fk, pos_pk
FROM frm_posts
WHERE pos_top_fk = %s
ORDER BY pos_date DESC',
array('integer'), array($newFrmData['top_kp']));
$last_post_dest = $newFrmData['top_pk'] . '#' . $row->pos_thr_fk . '#' . $row->pos_pk;
$statement = $ilDB->manipulateF('
UPDATE frm_data
SET top_num_posts = top_num_posts + %s,
top_num_threads = top_num_threads + %s,
visits = visits + %s,
top_last_post = %s
WHERE top_pk = %s',
array('integer', 'integer', 'integer', 'text', 'integer'),
array($moved_posts, $moved_threads, $visits, $last_post_dest, $newFrmData['top_pk']));
/*
// update news items
include_once("./Services/News/classes/class.ilNewsItem.php");
$objNewsItem = new ilNewsItem();
$news_items = $objNewsItem->getNewsForRefId($src_ref_id);
foreach ($news_items as $news_item)
{
$tmpObjNewsItem = new ilNewsItem($news_item['id']);
if ($tmpObjNewsItem->getContextObjId() == $src_top_frm_fk)
{
$tmpObjNewsItem->setContextObjId($dest_top_frm_fk);
$tmpObjNewsItem->update();
}
unset($tmpObjNewsItem);
}
*/
}
}
}

+ Here is the call graph for this function:

ilForum::postCensorship (   $message,
  $pos_pk,
  $cens = 0 
)

update dataset in frm_posts with censorship info

Parameters
stringmessage
integerpos_pk
Returns
boolean public

Definition at line 976 of file class.ilForum.php.

References $_SESSION, $ilDB, $res, DB_FETCHMODE_ASSOC, ilNewsItem\getFirstNewsIdForContext(), and prepareText().

{
global $ilDB;
$statement = $ilDB->manipulateF('
UPDATE frm_posts
SET pos_cens_com = %s,
pos_update = %s,
pos_cens = %s,
update_user = %s
WHERE pos_pk = %s',
array('text', 'timestamp', 'integer', 'integer', 'integer'),
array($message, date("Y-m-d H:i:s"), $cens, $_SESSION['AccountId'], $pos_pk));
// Change news item accordingly
include_once("./Services/News/classes/class.ilNewsItem.php");
"frm", $pos_pk, "pos");
if ($news_id > 0)
{
if ($cens > 0) // censor
{
$news_item = new ilNewsItem($news_id);
//$news_item->setTitle($subject);
$news_item->setContent(nl2br($this->prepareText($message, 0)));
$news_item->update();
}
else // revoke censorship
{
// get original message
$res = $ilDB->queryf('
SELECT * FROM frm_posts
WHERE pos_pk = %s',
array('integer'), array($pos_pk));
$rec = $res->fetchRow(DB_FETCHMODE_ASSOC);
$news_item = new ilNewsItem($news_id);
//$news_item->setTitle($subject);
$news_item->setContent(nl2br($this->prepareText($rec["pos_message"], 0)));
$news_item->update();
}
}
return true;
}

+ Here is the call graph for this function:

ilForum::prepareText (   $text,
  $edit = 0,
  $quote_user = '',
  $type = '' 
)

prepares given string public

Parameters
string
integer
Returns
string

Definition at line 2065 of file class.ilForum.php.

References $diff, $lng, $txtQuote2, $type, elseif(), and ilUtil\insertLatexImages().

Referenced by generatePost(), getLastPost(), limitMsgString(), postCensorship(), and updatePost().

{
global $lng;
if($type == 'export')
{
$this->replQuote1 = "<blockquote class=\"quote\"><hr size=\"1\" color=\"#000000\">";
$this->replQuote2 = "<hr size=\"1\" color=\"#000000\"/></blockquote>";
}
if($edit == 1)
{
// add login name of quoted users
$lname = ($quote_user != "")
? '="'.$quote_user.'"'
: "";
$text = "[quote$lname]".$text."[/quote]";
}
else
{
// check for quotation
$startZ = substr_count ($text, "[quote"); // also count [quote="..."]
$endZ = substr_count ($text, "[/quote]");
if ($startZ > 0 || $endZ > 0)
{
// add missing opening and closing tags
if ($startZ > $endZ)
{
$diff = $startZ - $endZ;
for ($i = 0; $i < $diff; $i++)
{
if ($type == 'export') $text .= $this->txtQuote2;
else $text .= "[/quote]";
}
}
elseif ($startZ < $endZ)
{
$diff = $endZ - $startZ;
for ($i = 0; $i < $diff; $i++)
{
if ($type == 'export') $text = $this->txtQuote1.$text;
else $text = "[quote]".$text;
}
}
if($edit == 0)
{
$ws= "[ \t\r\f\v\n]*";
$text = eregi_replace("\[(quote$ws=$ws\"([^\"]*)\"$ws)\]",
$this->replQuote1.'<div class="ilForumQuoteHead">'.$lng->txt("quote")." (\\2)".'</div>', $text);
$text = str_replace("[quote]",
$this->replQuote1.'<div class="ilForumQuoteHead">'.$lng->txt("quote").'</div>', $text);
$text = str_replace("[/quote]", $this->replQuote2, $text);
}
}
}
if($type != 'export')
{
if($edit == 0)
{
$text = ilUtil::insertLatexImages($text, "<span class\=\"latex\">", "<\/span>");
$text = ilUtil::insertLatexImages($text, "\[tex\]", "\[\/tex\]");
}
// workaround for preventing template engine
// from hiding text that is enclosed
// in curly brackets (e.g. "{a}")
$text = str_replace("{", "&#123;", $text);
$text = str_replace("}", "&#125;", $text);
}
return $text;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::sendForumNotifications (   $post_data)

Definition at line 2546 of file class.ilForum.php.

References $_SESSION, $ilDB, $lng, $ref_id, $res, $result, $row, ilObject\_getAllReferences(), ilObjUser\_lookupLogin(), _lookupObjIdForForumId(), DB_FETCHMODE_ASSOC, formatNotification(), formatNotificationSubject(), and setLanguage().

Referenced by generatePost().

{
global $ilDB, $ilAccess, $lng;
include_once "Services/Mail/classes/class.ilMail.php";
include_once './Services/User/classes/class.ilObjUser.php';
// GET THREAD DATA
$result = $ilDB->queryf('
SELECT thr_subject FROM frm_threads
WHERE thr_pk = %s',
array('integer'),
array($post_data['pos_thr_fk']));
while($record = $ilDB->fetchAssoc($result))
{
$post_data['thr_subject'] = $record['thr_subject'];
break;
}
// determine obj_id of the forum
$obj_id = self::_lookupObjIdForForumId($post_data['pos_top_fk']);
// GET AUTHOR OF NEW POST
if($post_data['pos_usr_id'])
{
$post_data['pos_usr_name'] = ilObjUser::_lookupLogin($post_data['pos_usr_id']);
}
else if(strlen($post_data['pos_usr_alias']))
{
$post_data['pos_usr_name'] = $post_data['pos_usr_alias'].' ('.$lng->txt('frm_pseudonym').')';
}
if($post_data['pos_usr_name'] == '')
{
$post_data['pos_usr_name'] = $this->lng->txt('forums_anonymous');
}
// GET USERS WHO WANT TO BE INFORMED ABOUT NEW POSTS
$res = $ilDB->queryf('
SELECT frm_notification.user_id FROM frm_notification, frm_data
WHERE frm_data.top_pk = %s
AND frm_notification.frm_id = frm_data.top_frm_fk
AND frm_notification.user_id <> %s
GROUP BY frm_notification.user_id',
array('integer', 'integer'),
array($post_data['pos_top_fk'], $_SESSION['AccountId']));
// get all references of obj_id
$frm_references = ilObject::_getAllReferences($obj_id);
// save language of the current user
global $lng;
$userLanguage = $lng;
$mail_obj = new ilMail(ANONYMOUS_USER_ID);
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
// do rbac check before sending notification
$send_mail = false;
foreach((array)$frm_references as $ref_id)
{
if($ilAccess->checkAccessOfUser($row['user_id'], 'read', '', $ref_id))
{
$send_mail = true;
break;
}
}
if($send_mail)
{
// set forum language instance for earch user
$this->setLanguage(self::_getLanguageInstanceByUsrId($row['user_id']));
// SEND NOTIFICATIONS BY E-MAIL
$message = $mail_obj->sendMail(ilObjUser::_lookupLogin($row["user_id"]),"","",
$this->formatNotificationSubject($post_data),
strip_tags($this->formatNotification($post_data)),
array(),array("system"));
}
}
// reset language
$this->setLanguage($userLanguage);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::sendPostActivationNotification (   $post_data)

Definition at line 2669 of file class.ilForum.php.

References $ilDB, $lng, $result, ilObjUser\_lookupLogin(), formatPostActivationNotification(), formatPostActivationNotificationSubject(), getModerators(), and setLanguage().

Referenced by generatePost().

{
global $ilDB, $ilUser, $lng;
if (is_array($moderators = $this->getModerators()))
{
// GET THREAD DATA
$result = $ilDB->queryf('
SELECT thr_subject FROM frm_threads
WHERE thr_pk = %s',
array('integer'),
array($post_data['pos_thr_fk']));
while($record = $ilDB->fetchAssoc($result))
{
$post_data['thr_subject'] = $record['thr_subject'];
break;
}
// GET AUTHOR OF NEW POST
if($post_data['pos_usr_id'])
{
$post_data['pos_usr_name'] = ilObjUser::_lookupLogin($post_data['pos_usr_id']);
}
else if(strlen($post_data['pos_usr_alias']))
{
$post_data['pos_usr_name'] = $post_data['pos_usr_alias'].' ('.$lng->txt('frm_pseudonym').')';
}
if($post_data['pos_usr_name'] == '')
{
$post_data['pos_usr_name'] = $this->lng->txt('forums_anonymous');
}
// save language of the current user
global $lng;
$userLanguage = $lng;
$mail_obj = new ilMail(ANONYMOUS_USER_ID);
foreach ($moderators as $moderator)
{
// set forum language instance for earch user
$this->setLanguage(self::_getLanguageInstanceByUsrId($moderator));
$message = $this->formatPostActivationNotification($post_data);
$message = $mail_obj->sendMail(ilObjUser::_lookupLogin($moderator), '', '',
$subject,
strip_tags($message),
array(), array("system"));
}
// reset language
$this->setLanguage($userLanguage);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::sendThreadNotifications (   $post_data)

Definition at line 2463 of file class.ilForum.php.

References $_SESSION, $ilDB, $lng, $ref_id, $res, $result, $row, ilObject\_getAllReferences(), ilObjUser\_lookupLogin(), _lookupObjIdForForumId(), DB_FETCHMODE_ASSOC, formatNotification(), formatNotificationSubject(), and setLanguage().

Referenced by generatePost().

{
global $ilDB, $ilAccess, $lng;
include_once "Services/Mail/classes/class.ilMail.php";
include_once './Services/User/classes/class.ilObjUser.php';
// GET THREAD DATA
$result = $ilDB->queryf('
SELECT thr_subject FROM frm_threads
WHERE thr_pk = %s',
array('integer'), array($post_data['pos_thr_fk']));
while($record = $ilDB->fetchAssoc($result))
{
$post_data['thr_subject'] = $record['thr_subject'];
break;
}
// determine obj_id of the forum
$obj_id = self::_lookupObjIdForForumId($post_data['pos_top_fk']);
// GET AUTHOR OF NEW POST
if($post_data['pos_usr_id'])
{
$post_data['pos_usr_name'] = ilObjUser::_lookupLogin($post_data['pos_usr_id']);
}
else if(strlen($post_data['pos_usr_alias']))
{
$post_data['pos_usr_name'] = $post_data['pos_usr_alias'].' ('.$lng->txt('frm_pseudonym').')';
}
if($post_data['pos_usr_name'] == '')
{
$post_data['pos_usr_name'] = $this->lng->txt('forums_anonymous');
}
// GET USERS WHO WANT TO BE INFORMED ABOUT NEW POSTS
$res = $ilDB->queryf('
SELECT user_id FROM frm_notification
WHERE thread_id = %s
AND user_id <> %s',
array('integer', 'integer'),
array($post_data['pos_thr_fk'], $_SESSION['AccountId']));
// get all references of obj_id
$frm_references = ilObject::_getAllReferences($obj_id);
// save language of the current user
global $lng;
$userLanguage = $lng;
$mail_obj = new ilMail(ANONYMOUS_USER_ID);
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
// do rbac check before sending notification
$send_mail = false;
foreach((array)$frm_references as $ref_id)
{
if($ilAccess->checkAccessOfUser($row['user_id'], 'read', '', $ref_id))
{
$send_mail = true;
break;
}
}
if($send_mail)
{
// set forum language instance for earch user
$this->setLanguage(self::_getLanguageInstanceByUsrId($row['user_id']));
// SEND NOTIFICATIONS BY E-MAIL
$message = $mail_obj->sendMail(ilObjUser::_lookupLogin($row["user_id"]),"","",
$this->formatNotificationSubject($post_data),
strip_tags($this->formatNotification($post_data)),
array(),array("system"));
}
}
// reset language
$this->setLanguage($userLanguage);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForum::setDbTable (   $dbTable)

set database table

Parameters
string$dbTabledatabase table
See Also
$dbTable User interface

Definition at line 222 of file class.ilForum.php.

References $dbTable.

{
if ($dbTable == "")
{
die($this->className . "::setDbTable(): No database table given.");
}
else
{
$this->dbTable = $dbTable;
}
}
ilForum::setForumId (   $a_obj_id)

set object id which refers to ILIAS obj_id

Parameters
integerobject id public

Definition at line 139 of file class.ilForum.php.

{
if (!isset($a_obj_id))
{
$message = get_class($this)."::setForumId(): No obj_id given!";
$this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
}
$this->id = $a_obj_id;
}
ilForum::setForumRefId (   $a_ref_id)

set reference id which refers to ILIAS obj_id

Parameters
integerobject id public

Definition at line 156 of file class.ilForum.php.

{
if (!isset($a_ref_id))
{
$message = get_class($this)."::setForumRefId(): No ref_id given!";
$this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
}
$this->ref_id = $a_ref_id;
}
ilForum::setImportName (   $a_import_name)

Definition at line 2283 of file class.ilForum.php.

{
$this->import_name = $a_import_name;
}
ilForum::setLanguage (   $lng)

Definition at line 103 of file class.ilForum.php.

References $lng.

Referenced by sendForumNotifications(), sendPostActivationNotification(), and sendThreadNotifications().

{
$this->lng =& $lng;
}

+ Here is the caller graph for this function:

ilForum::setMDB2WhereCondition (   $query_string,
  $data_type,
  $data_value 
)

set content for additional condition

Parameters
string$query_string
array$data_type
array$data_value

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

Referenced by __sendMessage(), and moveThreads().

{
$this->mdb2Query = $query_string;
$this->mdb2DataValue = $data_value;
$this->mdb2DataType = $data_type;
return true;
}

+ Here is the caller graph for this function:

ilForum::setOrderField (   $orderField)

set database field for sorting results

Parameters
string$orderFielddatabase field for sorting
See Also
$orderField private

Definition at line 193 of file class.ilForum.php.

References $orderField.

{
if ($orderField == "")
{
die($this->className . "::setOrderField(): No orderField given.");
}
else
{
$this->orderField = $orderField;
}
}
ilForum::setPageHits (   $pageHits)

set number of max.

visible datasets

Parameters
integer$pageHits
See Also
$pageHits User interface

Definition at line 313 of file class.ilForum.php.

References $pageHits.

{
if ($pageHits < 1)
{
die($this->className . "::setPageHits(): No int pageHits given.");
}
else
{
$this->pageHits = $pageHits;
return true;
}
}
ilForum::updatePost (   $message,
  $pos_pk,
  $notify,
  $subject,
  $thr_pk = 0 
)

update dataset in frm_posts

Parameters
stringmessage
integerpos_pk
Returns
boolean public

Definition at line 739 of file class.ilForum.php.

References $_SESSION, $ilDB, ilNewsItem\getFirstNewsIdForContext(), getFirstPostByThread(), prepareText(), and updateThread().

{
global $ilDB;
$statement = $ilDB->manipulateF('
UPDATE frm_posts
SET pos_message = %s,
pos_subject = %s,
pos_update = %s,
update_user = %s,
notify = %s
WHERE pos_pk = %s',
array( 'text',
'text',
'timestamp',
'integer',
'integer',
'integer'
),
array( $message,
$subject,
date("Y-m-d H:i:s"),
$_SESSION['AccountId'],
$notify,
$pos_pk
));
if ($thr_pk > 0 &&
$pos_pk == $this->getFirstPostByThread($thr_pk))
{
$this->updateThread($thr_pk, $subject);
}
// Change news item accordingly
include_once("./Services/News/classes/class.ilNewsItem.php");
"frm", $pos_pk, "pos");
if ($news_id > 0)
{
$news_item = new ilNewsItem($news_id);
$news_item->setTitle($subject);
$news_item->setContent(nl2br($this->prepareText($message, 0)));
$news_item->update();
}
return true;
}

+ Here is the call graph for this function:

ilForum::updateThread (   $thr_pk,
  $subject 
)

update dataset in frm_threads

Parameters
integerthr_pk
stringsubject
Returns
boolean public

Definition at line 794 of file class.ilForum.php.

References $ilDB.

Referenced by updatePost().

{
global $ilDB;
$statement = $ilDB->manipulateF('
UPDATE frm_threads
SET thr_subject = %s
WHERE thr_pk = %s',
array('text', 'integer'),
array($subject, $thr_pk));
return true;
}

+ Here is the caller graph for this function:

ilForum::updateVisits (   $ID)

update page hits of given forum- or thread-ID public

Parameters
integer

Definition at line 2031 of file class.ilForum.php.

References $_SESSION, $ilDB, $query, $res, getMDB2DataType(), getMDB2DataValue(), and getMDB2Query().

{
global $ilDB;
$checkTime = time() - (60*60);
if ($_SESSION["frm_visit_".$this->dbTable."_".$ID] < $checkTime)
{
$_SESSION["frm_visit_".$this->dbTable."_".$ID] = time();
$query = 'UPDATE '.$this->dbTable.' SET visits = visits + 1 WHERE ';
$data_type = array();
$data_value = array();
if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
{
$query .= $this->getMDB2Query();
$data_type = $data_type + $this->getMDB2DataType();
$data_value = $data_value + $this->getMDB2DataValue();
$res = $ilDB->queryf($query, $data_type, $data_value);
}
}
}

+ Here is the call graph for this function:

Field Documentation

ilForum::$className = "ilForum"

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

ilForum::$dbTable

Definition at line 57 of file class.ilForum.php.

Referenced by getDbTable(), and setDbTable().

ilForum::$id

Definition at line 87 of file class.ilForum.php.

Referenced by getForumId(), and moveThreads().

ilForum::$ilias

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

Referenced by ilForum().

ilForum::$mdb2DataType

Definition at line 76 of file class.ilForum.php.

Referenced by getMDB2DataType().

ilForum::$mdb2DataValue

Definition at line 75 of file class.ilForum.php.

Referenced by getMDB2DataValue().

ilForum::$mdb2Query

Definition at line 74 of file class.ilForum.php.

Referenced by getMDB2Query().

ilForum::$orderField

Definition at line 72 of file class.ilForum.php.

Referenced by getOrderField(), and setOrderField().

ilForum::$pageHits = 30

Definition at line 84 of file class.ilForum.php.

Referenced by getPageHits(), and setPageHits().

ilForum::$replQuote1 = '<blockquote class="ilForumQuote">'

Definition at line 80 of file class.ilForum.php.

ilForum::$replQuote2 = '</blockquote>'

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

ilForum::$threads = array()
private

Definition at line 89 of file class.ilForum.php.

Referenced by _getThreads(), and getAllThreads().

ilForum::$txtQuote1 = "[quote]"

Definition at line 78 of file class.ilForum.php.

ilForum::$txtQuote2 = "[/quote]"

Definition at line 79 of file class.ilForum.php.

Referenced by prepareText().

const ilForum::SORT_DATE = 2

Definition at line 41 of file class.ilForum.php.

const ilForum::SORT_TITLE = 1

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

Referenced by ilObjForumGUI\cloneWizardPageObject().


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