ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilForum Class Reference

Class Forum core functions for forum. More...

+ Collaboration diagram for ilForum:

Public Member Functions

 __construct ()
 Constructor @access public. More...
 
 setLanguage ($lng)
 
 setForumId ($a_obj_id)
 set object id which refers to ILIAS obj_id More...
 
 setForumRefId ($a_ref_id)
 set reference id which refers to ILIAS obj_id More...
 
 getForumId ()
 get forum id @access public More...
 
 getForumRefId ()
 get forum ref_id @access public More...
 
 getOrderField ()
 get name of orderField More...
 
 setDbTable ($dbTable)
 set database table More...
 
 getDbTable ()
 get name of database table More...
 
 setMDB2WhereCondition ($query_string, $data_type, $data_value)
 set content for additional condition More...
 
 getMDB2Query ()
 get content of additional condition More...
 
 getMDB2DataValue ()
 /* get content of additional condition More...
 
 getMDB2DataType ()
 get content of additional condition More...
 
 setPageHits ($pageHits)
 
 getPageHits ()
 get number of max. More...
 
 getOneTopic ()
 get one topic-dataset by WhereCondition More...
 
 getOneThread ()
 get one thread-dataset by WhereCondition More...
 
 getOnePost ($post)
 get one post-dataset More...
 
 generatePost ($forum_id, $thread_id, $author_id, $display_user_id, $message, $parent_pos, $notify, $subject='', $alias='', $date='', $status=1, $send_activation_mail=0)
 generate new dataset in frm_posts More...
 
 generateThread (ilForumTopic $thread, $message, $notify, $notify_posts, $status=1)
 
 moveThreads ($thread_ids=array(), $src_ref_id=0, $dest_top_frm_fk=0)
 Moves all chosen threads and their posts to a new forum. More...
 
 postCensorship ($message, $pos_pk, $cens=0)
 update dataset in frm_posts with censorship info More...
 
 deletePost ($post)
 delete post and sub-posts More...
 
 getUserStatistic ($is_moderator=false)
 
 getFirstPostByThread ($a_thread_id)
 Get first post of thread. More...
 
 getModerators ()
 get all users assigned to local role il_frm_moderator_<frm_ref_id> More...
 
 countUserArticles ($a_user_id)
 get number of articles from given user-ID More...
 
 countActiveUserArticles ($a_user_id)
 
 convertDate ($date)
 converts the date format More...
 
 addPostTree ($a_tree_id, $a_node_id=-1, $a_date='')
 create a new post-tree More...
 
 insertPostNode ($a_node_id, $a_parent_id, $tree_id, $a_date='')
 insert node under parent node @access public More...
 
 getPostDepth ($a_node_id, $tree_id)
 Return depth of an object @access private. More...
 
 getFirstPostNode ($tree_id)
 get data of the first node from frm_posts_tree and frm_posts @access public More...
 
 getPostNode ($post_id)
 get data of given node from frm_posts_tree and frm_posts @access public More...
 
 fetchPostNodeData ($a_row)
 get data of parent node from frm_posts_tree and frm_posts @access private More...
 
 deletePostTree ($a_node)
 delete node and the whole subtree under this node @access public More...
 
 updateVisits ($ID)
 update page hits of given forum- or thread-ID @access public More...
 
 prepareText ($text, $edit=0, $quote_user='', $type='')
 prepares given string @access public More...
 
 getModeratorFromPost ($pos_pk)
 get one post-dataset More...
 
 __deletePostFiles ($a_ids)
 
 getImportName ()
 
 setImportName ($a_import_name)
 
 enableForumNotification ($user_id)
 Enable a user's notification about new posts in this forum. More...
 
 disableForumNotification ($user_id)
 Disable a user's notification about new posts in this forum. More...
 
 isForumNotificationEnabled ($user_id)
 Check whether a user's notification about new posts in this forum is enabled (result > 0) or not (result == 0) More...
 
 enableThreadNotification ($user_id, $thread_id)
 Enable a user's notification about new posts in a thread. More...
 
 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) More...
 

Static Public Member Functions

static _getLanguageInstanceByUsrId ($usr_id)
 Get the ilLanguage instance for the passed user id. More...
 
static _lookupPostMessage ($a_id)
 
static _getModerators ($a_ref_id)
 get all users assigned to local role il_frm_moderator_<frm_ref_id> (static) More...
 
static _isModerator ($a_ref_id, $a_usr_id)
 checks whether a user is moderator of a given forum object More...
 
static _getThreads ($a_obj_id, $a_sort_mode=self::SORT_DATE)
 Get thread infos of object. More...
 
static _lookupObjIdForForumId ($a_for_id)
 
static updateLastPostByObjId ($a_obj_id)
 
static mergeThreads ($obj_id, $source_id, $target_id)
 

Data Fields

const SORT_TITLE = 1
 
const SORT_DATE = 2
 
const DEFAULT_PAGE_HITS = 30
 
 $ilias
 
 $lng
 

Static Protected Attributes

static $moderators_by_ref_id_map = array()
 

Private Member Functions

 setOrderField ($orderField)
 set database field for sorting results More...
 

Private Attributes

 $dbTable
 
 $className ="ilForum"
 
 $orderField
 
 $mdb2Query
 
 $mdb2DataValue
 
 $mdb2DataType
 
 $txtQuote1 = "[quote]"
 
 $txtQuote2 = "[/quote]"
 
 $replQuote1 = '<blockquote class="ilForumQuote">'
 
 $replQuote2 = '</blockquote>'
 
 $pageHits = self::DEFAULT_PAGE_HITS
 
 $id
 

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$

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

Constructor & Destructor Documentation

◆ __construct()

ilForum::__construct ( )

Constructor @access public.

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

81 {
82 global $ilias,$lng;
83
84 $this->ilias = $ilias;
85 $this->lng = $lng;
86 }
redirection script todo: (a better solution should control the processing via a xml file)

References $ilias, and $lng.

Member Function Documentation

◆ __deletePostFiles()

ilForum::__deletePostFiles (   $a_ids)

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

1959 {
1960 if(!is_array($a_ids))
1961 {
1962 return false;
1963 }
1964 include_once "./Modules/Forum/classes/class.ilFileDataForum.php";
1965
1966 $tmp_file_obj = new ilFileDataForum($this->getForumId());
1967 foreach($a_ids as $pos_id)
1968 {
1969 $tmp_file_obj->setPosId($pos_id);
1970 $files = $tmp_file_obj->getFilesOfPost();
1971 foreach($files as $file)
1972 {
1973 $tmp_file_obj->unlinkFile($file["name"]);
1974 }
1975 }
1976 unset($tmp_file_obj);
1977 return true;
1978 }
$files
Definition: add-vimline.php:18
This class handles all operations on files for the forum object.
getForumId()
get forum id @access public
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

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

Referenced by deletePost().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getLanguageInstanceByUsrId()

static ilForum::_getLanguageInstanceByUsrId (   $usr_id)
static

Get the ilLanguage instance for the passed user id.

Parameters
integer$usr_ida user id
Returns
ilLanguage @access public

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

104 {
105 static $lngCache = array();
106
107 $languageShorthandle = ilObjUser::_lookupLanguage($usr_id);
108
109 // lookup in cache array
110 if(!isset($lngCache[$languageShorthandle]))
111 {
112 $lngCache[$languageShorthandle] = new ilLanguage($languageShorthandle);
113 $lngCache[$languageShorthandle]->loadLanguageModule('forum');
114 }
115
116 return $lngCache[$languageShorthandle];
117 }
language handling
static _lookupLanguage($a_usr_id)

References ilObjUser\_lookupLanguage().

+ Here is the call graph for this function:

◆ _getModerators()

static ilForum::_getModerators (   $a_ref_id)
static

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

Parameters
int$a_ref_idreference id
Returns
array user_ids @access public

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

1413 {
1414 global $rbacreview;
1415
1416 $role_arr = $rbacreview->getRolesOfRoleFolder($a_ref_id);
1417 foreach($role_arr as $role_id)
1418 {
1419 if(ilObject::_lookupTitle($role_id) == 'il_frm_moderator_' . $a_ref_id)
1420 {
1421 return $rbacreview->assignedUsers($role_id);
1422 }
1423 }
1424
1425 return array();
1426 }
static _lookupTitle($a_id)
lookup object title

References ilObject\_lookupTitle().

Referenced by _isModerator(), ilForumNotification\checkParentNodeTree(), getModerators(), ilObjForumNotificationDataProvider\getPostActivationRecipients(), and ilObjForumGUI\updateUserNotifications().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getThreads()

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

Get thread infos of object.

@access public

Parameters
intobj_id of forum
intsort mode SORT_TITLE or SORT_DATE

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

2174 {
2175 global $ilDB;
2176
2177 switch($a_sort_mode)
2178 {
2179 case self::SORT_DATE:
2180 $sort = 'thr_date';
2181 break;
2182
2183 case self::SORT_TITLE:
2184 default:
2185 $sort = 'thr_subject';
2186 break;
2187 }
2188
2189 $res = $ilDB->queryf('
2190 SELECT * FROM frm_threads
2191 JOIN frm_data ON top_pk = thr_top_fk
2192 WHERE top_frm_fk = %s
2193 ORDER BY %s',
2194 array('integer', 'text'), array($a_obj_id, $sort));
2195
2196 while($row = $ilDB->fetchObject($res))
2197 {
2198 $threads[$row->thr_pk] = $row->thr_subject;
2199 }
2200 return $threads ? $threads : array();
2201 }
const SORT_DATE
const SORT_TITLE
global $ilDB

References $ilDB, $res, $row, SORT_DATE, and SORT_TITLE.

Referenced by ilObjForumGUI\cloneWizardPageObject().

+ Here is the caller graph for this function:

◆ _isModerator()

static ilForum::_isModerator (   $a_ref_id,
  $a_usr_id 
)
static

checks whether a user is moderator of a given forum object

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

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

1437 {
1438 if(!self::$moderators_by_ref_id_map[$a_ref_id])
1439 {
1440 self::$moderators_by_ref_id_map[$a_ref_id] = self::_getModerators($a_ref_id);
1441 }
1442 return in_array($a_usr_id, self::$moderators_by_ref_id_map[$a_ref_id]);
1443 }
static _getModerators($a_ref_id)
get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)

References _getModerators().

Referenced by generatePost().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupObjIdForForumId()

static ilForum::_lookupObjIdForForumId (   $a_for_id)
static

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

2204 {
2205 global $ilDB;
2206
2207 $res = $ilDB->queryf('
2208 SELECT top_frm_fk FROM frm_data
2209 WHERE top_pk = %s',
2210 array('integer'), array($a_for_id));
2211
2212 if ($fdata = $ilDB->fetchAssoc($res))
2213 {
2214 return $fdata["top_frm_fk"];
2215 }
2216 return false;
2217 }

References $ilDB, and $res.

Referenced by ilForumPostingDraftsBlockGUI\fillDataSection(), ilObjMediaObject\getParentObjectIdForUsage(), ilObjForumGUI\mergeThreadsObject(), and ilForumTopic\movePosts().

+ Here is the caller graph for this function:

◆ _lookupPostMessage()

static ilForum::_lookupPostMessage (   $a_id)
static

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

419 {
420 global $ilDB;
421
422 $res = $ilDB->queryf('
423 SELECT * FROM frm_posts WHERE pos_pk = %s',
424 array('integer'), array($a_id));
425
426 while($row = $ilDB->fetchObject($res))
427 {
428 return $row->pos_message;
429 }
430 return '';
431 }

References $ilDB, $res, and $row.

◆ addPostTree()

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 @access public

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

1506 {
1507 global $ilDB;
1508
1509 $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1510
1511 if ($a_node_id <= 0)
1512 {
1513 $a_node_id = $a_tree_id;
1514 }
1515
1516 $nextId = $ilDB->nextId('frm_posts_tree');
1517
1518 $statement = $ilDB->manipulateF('
1519 INSERT INTO frm_posts_tree
1520 ( fpt_pk,
1521 thr_fk,
1522 pos_fk,
1523 parent_pos,
1524 lft,
1525 rgt,
1526 depth,
1527 fpt_date
1528 )
1529 VALUES(%s, %s, %s, %s, %s, %s, %s, %s )',
1530 array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1531 array($nextId, $a_tree_id, $a_node_id, '0', '1', '2', '1', $a_date));
1532
1533 return true;
1534 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())

References $ilDB, and date.

Referenced by generatePost().

+ Here is the caller graph for this function:

◆ convertDate()

ilForum::convertDate (   $date)

converts the date format

Parameters
string$date
Returns
string formatted datetime @access public

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

1494 {
1496 }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling

References ilDatePresentation\formatDate(), and IL_CAL_DATETIME.

Referenced by getOnePost().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countActiveUserArticles()

ilForum::countActiveUserArticles (   $a_user_id)

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

1468 {
1469 global $ilDB, $ilUser;
1470
1471 $res = $ilDB->queryf('
1472 SELECT * FROM frm_data
1473 INNER JOIN frm_posts ON pos_top_fk = top_pk
1474 WHERE top_frm_fk = %s
1475 AND (pos_status = %s
1476 OR (pos_status = %s
1477 AND pos_author_id = %s
1478 )
1479 )
1480 AND pos_author_id = %s',
1481 array('integer', 'integer', 'integer', 'integer', 'integer'),
1482 array($this->getForumId(),'1', '0', $ilUser->getId(), $a_user_id));
1483
1484 return $res->numRows();
1485 }
$ilUser
Definition: imgupload.php:18

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

+ Here is the call graph for this function:

◆ countUserArticles()

ilForum::countUserArticles (   $a_user_id)

get number of articles from given user-ID

Parameters
integer$user,user-ID
Returns
integer @access public

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

1453 {
1454 global $ilDB;
1455
1456 $res = $ilDB->queryf('
1457 SELECT * FROM frm_data
1458 INNER JOIN frm_posts ON pos_top_fk = top_pk
1459 WHERE top_frm_fk = %s
1460 AND pos_author_id = %s',
1461 array('integer', 'integer'),
1462 array($this->getForumId(), $a_user_id));
1463
1464 return $res->numRows();
1465 }

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

+ Here is the call graph for this function:

◆ deletePost()

ilForum::deletePost (   $post)

delete post and sub-posts

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

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

816 {
817 global $ilDB;
818
819 include_once "./Modules/Forum/classes/class.ilObjForum.php";
820
821 $p_node = $this->getPostNode($post);
822
823 $GLOBALS['ilAppEventHandler']->raise(
824 'Modules/Forum',
825 'deletedPost',
826 array(
827 'ref_id' => $this->getForumRefId(),
828 'post' => new ilForumPost($post),
829 'thread_deleted' => ($p_node["parent"] == 0)? true : false
830 )
831 );
832
833 // delete tree and get id's of all posts to delete
834 $del_id = $this->deletePostTree($p_node);
835
836 // delete drafts_history
837 $obj_history = new ilForumDraftsHistory();
838 $draft_ids = $obj_history->deleteHistoryByPostIds($del_id);
839 // delete all drafts
840 $obj_draft = new ilForumPostDraft();
841 $obj_draft->deleteDraftsByDraftIds($draft_ids);
842
843 // Delete User read entries
844 foreach($del_id as $post_id)
845 {
846 ilObjForum::_deleteReadEntries($post_id);
847 }
848
849 // DELETE ATTACHMENTS ASSIGNED TO POST
850 $this->__deletePostFiles($del_id);
851
852 $dead_pos = count($del_id);
853 $dead_thr = 0;
854
855 // if deletePost is thread opener ...
856 if ($p_node["parent"] == 0)
857 {
858 // delete thread access data
859 include_once './Modules/Forum/classes/class.ilObjForum.php';
860
861 ilObjForum::_deleteAccessEntries($p_node['tree']);
862
863 // delete thread
864 $dead_thr = $p_node["tree"];
865
866 $statement = $ilDB->manipulateF('
867 DELETE FROM frm_threads
868 WHERE thr_pk = %s',
869 array('integer'), array($p_node['tree']));
870
871 // update num_threads
872 $statement = $ilDB->manipulateF('
873 UPDATE frm_data
874 SET top_num_threads = top_num_threads - 1
875 WHERE top_frm_fk = %s',
876 array('integer'), array($this->id));
877
878 // delete all related news
879 $posset = $ilDB->queryf('
880 SELECT * FROM frm_posts
881 WHERE pos_thr_fk = %s',
882 array('integer'), array($p_node['tree']));
883
884 while ($posrec = $ilDB->fetchAssoc($posset))
885 {
886 include_once("./Services/News/classes/class.ilNewsItem.php");
887 $news_id = ilNewsItem::getFirstNewsIdForContext($this->id,
888 "frm", $posrec["pos_pk"], "pos");
889 if ($news_id > 0)
890 {
891 $news_item = new ilNewsItem($news_id);
892 $news_item->delete();
893 }
894
895 try
896 {
897 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
898 $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $posrec['pos_pk']);
899 foreach($mobs as $mob)
900 {
902 {
903 ilObjMediaObject::_removeUsage($mob, 'frm:html', $posrec['pos_pk']);
904 $mob_obj = new ilObjMediaObject($mob);
905 $mob_obj->delete();
906 }
907 }
908 }
909 catch(Exception $e)
910 {
911 }
912 }
913
914
915 // delete all posts of this thread
916 $statement = $ilDB->manipulateF('
917 DELETE FROM frm_posts
918 WHERE pos_thr_fk = %s',
919 array('integer'), array($p_node['tree']));
920
921 }
922 else
923 {
924
925 // delete this post and its sub-posts
926 for ($i = 0; $i < $dead_pos; $i++)
927 {
928 $statement = $ilDB->manipulateF('
929 DELETE FROM frm_posts
930 WHERE pos_pk = %s',
931 array('integer'), array($del_id[$i]));
932
933 // delete related news item
934 include_once("./Services/News/classes/class.ilNewsItem.php");
935 $news_id = ilNewsItem::getFirstNewsIdForContext($this->id,
936 "frm", $del_id[$i], "pos");
937 if ($news_id > 0)
938 {
939 $news_item = new ilNewsItem($news_id);
940 $news_item->delete();
941 }
942
943 try
944 {
945 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
946 $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $del_id[$i]);
947 foreach($mobs as $mob)
948 {
950 {
951 ilObjMediaObject::_removeUsage($mob, 'frm:html', $del_id[$i]);
952 $mob_obj = new ilObjMediaObject($mob);
953 $mob_obj->delete();
954 }
955 }
956 }
957 catch(Exception $e)
958 {
959 }
960 }
961
962 // update num_posts in frm_threads
963 $statement = $ilDB->manipulateF('
964 UPDATE frm_threads
965 SET thr_num_posts = thr_num_posts - %s
966 WHERE thr_pk = %s',
967 array('integer', 'integer'),
968 array($dead_pos, $p_node['tree']));
969
970
971 // get latest post of thread and update last_post
972 $res1 = $ilDB->queryf('
973 SELECT * FROM frm_posts
974 WHERE pos_thr_fk = %s
975 ORDER BY pos_date DESC',
976 array('integer'), array($p_node['tree']));
977
978 if ($res1->numRows() == 0)
979 {
980 $lastPost_thr = "";
981 }
982 else
983 {
984 $z = 0;
985
986 while ($selData = $ilDB->fetchAssoc($res1))
987 {
988 if ($z > 0)
989 {
990 break;
991 }
992
993 $lastPost_thr = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
994 $z ++;
995 }
996 }
997
998 $statement = $ilDB->manipulateF('
999 UPDATE frm_threads
1000 SET thr_last_post = %s
1001 WHERE thr_pk = %s',
1002 array('text', 'integer'), array($lastPost_thr, $p_node['tree']));
1003 }
1004
1005 // update num_posts in frm_data
1006 $statement = $ilDB->manipulateF('
1007 UPDATE frm_data
1008 SET top_num_posts = top_num_posts - %s
1009 WHERE top_frm_fk = %s',
1010 array('integer', 'integer'), array($dead_pos, $this->id));
1011
1012
1013 // get latest post of forum and update last_post
1014 $res2 = $ilDB->queryf('
1015 SELECT * FROM frm_posts, frm_data
1016 WHERE pos_top_fk = top_pk
1017 AND top_frm_fk = %s
1018 ORDER BY pos_date DESC',
1019 array('integer'), array($this->id));
1020
1021 if ($res2->numRows() == 0)
1022 {
1023 $lastPost_top = "";
1024 }
1025 else
1026 {
1027 $z = 0;
1028
1029 while ($selData = $ilDB->fetchAssoc($res2))
1030 {
1031 if ($z > 0)
1032 {
1033 break;
1034 }
1035
1036 $lastPost_top = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
1037 $z ++;
1038 }
1039 }
1040
1041 $statement = $ilDB->manipulateF('
1042 UPDATE frm_data
1043 SET top_last_post = %s
1044 WHERE top_frm_fk = %s',
1045 array('text', 'integer'), array($lastPost_top, $this->id));
1046
1047 return $dead_thr;
1048 }
Class ilForumDraftHistory.
Class ilForumPostDraft.
deletePostTree($a_node)
delete node and the whole subtree under this node @access public
__deletePostFiles($a_ids)
getPostNode($post_id)
get data of given node from frm_posts_tree and frm_posts @access public
getForumRefId()
get forum ref_id @access public
static getFirstNewsIdForContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
Class ilObjMediaObject.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
static _exists($a_id, $a_reference=false, $a_type=NULL)
checks wether a lm content object with specified id exists or not
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$mobs

References $GLOBALS, $ilDB, $mobs, __deletePostFiles(), ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), deletePostTree(), ilNewsItem\getFirstNewsIdForContext(), getForumRefId(), and getPostNode().

+ Here is the call graph for this function:

◆ deletePostTree()

ilForum::deletePostTree (   $a_node)

delete node and the whole subtree under this node @access public

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

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

1747 {
1748 global $ilDB;
1749
1750 // GET LEFT AND RIGHT VALUES
1751 $res = $ilDB->queryf('
1752 SELECT * FROM frm_posts_tree
1753 WHERE thr_fk = %s
1754 AND pos_fk = %s
1755 AND parent_pos = %s',
1756 array('integer', 'integer', 'integer'),
1757 array($a_node['tree'], $a_node['pos_pk'], $a_node['parent']));
1758
1759 while($row = $ilDB->fetchObject($res))
1760 {
1761 $a_node["lft"] = $row->lft;
1762 $a_node["rgt"] = $row->rgt;
1763 }
1764
1765 $diff = $a_node["rgt"] - $a_node["lft"] + 1;
1766
1767 // get data of posts
1768 $result = $ilDB->queryf('
1769 SELECT * FROM frm_posts_tree
1770 WHERE lft BETWEEN %s AND %s
1771 AND thr_fk = %s',
1772 array('integer', 'integer', 'integer'),
1773 array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
1774
1775 $del_id = array();
1776
1777 while ($treeData = $ilDB->fetchAssoc($result))
1778 {
1779 $del_id[] = $treeData["pos_fk"];
1780 }
1781
1782 // delete subtree
1783 $statement = $ilDB->manipulateF('
1784 DELETE FROM frm_posts_tree
1785 WHERE lft BETWEEN %s AND %s
1786 AND thr_fk = %s',
1787 array('integer', 'integer', 'integer'),
1788 array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
1789
1790
1791 // close gaps
1792 $statement = $ilDB->manipulateF('
1793 UPDATE frm_posts_tree
1794 SET lft = CASE
1795 WHEN lft > %s
1796 THEN lft - %s
1797 ELSE lft
1798 END,
1799 rgt = CASE
1800 WHEN rgt > %s
1801 THEN rgt - %s
1802 ELSE rgt
1803 END
1804 WHERE thr_fk = %s',
1805 array('integer', 'integer', 'integer', 'integer', 'integer'),
1806 array($a_node['lft'], $diff, $a_node['lft'], $diff, $a_node['tree']));
1807
1808 return $del_id;
1809
1810 }
$result

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

Referenced by deletePost().

+ Here is the caller graph for this function:

◆ disableForumNotification()

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 @access private

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

2075 {
2076 global $ilDB;
2077
2078 $statement = $ilDB->manipulateF('
2079 DELETE FROM frm_notification
2080 WHERE user_id = %s
2081 AND frm_id = %s',
2082 array('integer', 'integer'),
2083 array($user_id, $this->id));
2084
2085 return true;
2086 }

References $ilDB.

◆ enableForumNotification()

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 @access private

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

1996 {
1997 global $ilDB;
1998
1999 if (!$this->isForumNotificationEnabled($user_id))
2000 {
2001 /* Remove all notifications of threads that belong to the forum */
2002
2003 $res = $ilDB->queryf('
2004 SELECT frm_notification.thread_id FROM frm_data, frm_notification, frm_threads
2005 WHERE frm_notification.user_id = %s
2006 AND frm_notification.thread_id = frm_threads.thr_pk
2007 AND frm_threads.thr_top_fk = frm_data.top_pk
2008 AND frm_data.top_frm_fk = %s
2009 GROUP BY frm_notification.thread_id',
2010 array('integer', 'integer'),
2011 array($user_id, $this->id));
2012
2013 if (is_object($res) && $res->numRows() > 0)
2014 {
2015 $thread_data = array();
2016 $thread_data_types = array();
2017
2018 $query = ' DELETE FROM frm_notification
2019 WHERE user_id = %s
2020 AND thread_id IN (';
2021
2022 array_push($thread_data, $user_id);
2023 array_push($thread_data_types, 'integer');
2024
2025 $counter = 1;
2026
2027 while($row = $ilDB->fetchAssoc($res))
2028 {
2029 if($counter < $res->numRows())
2030 {
2031 $query .= '%s, ';
2032 array_push($thread_data, $row['thread_id']);
2033 array_push($thread_data_types, 'integer');
2034 }
2035
2036 if($counter == $res->numRows())
2037 {
2038 $query .= '%s)';
2039 array_push($thread_data, $row['thread_id']);
2040 array_push($thread_data_types, 'integer');
2041
2042 }
2043 $counter++;
2044 }
2045
2046 $statement = $ilDB->manipulateF($query, $thread_data_types, $thread_data);
2047 }
2048
2049 /* Insert forum notification */
2050
2051 $nextId = $ilDB->nextId('frm_notification');
2052
2053 $statement = $ilDB->manipulateF('
2054 INSERT INTO frm_notification
2055 ( notification_id,
2056 user_id,
2057 frm_id
2058 )
2059 VALUES(%s, %s, %s)',
2060 array('integer','integer', 'integer'),
2061 array($nextId, $user_id, $this->id));
2062
2063 }
2064
2065 return true;
2066 }
isForumNotificationEnabled($user_id)
Check whether a user's notification about new posts in this forum is enabled (result > 0) or not (res...
$counter

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

+ Here is the call graph for this function:

◆ enableThreadNotification()

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 @access private

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

2117 {
2118 global $ilDB;
2119
2120 if (!$this->isThreadNotificationEnabled($user_id, $thread_id))
2121 {
2122 $nextId = $ilDB->nextId('frm_notification');
2123 $statement = $ilDB->manipulateF('
2124 INSERT INTO frm_notification
2125 ( notification_id,
2126 user_id,
2127 thread_id
2128 )
2129 VALUES (%s, %s, %s)',
2130 array('integer', 'integer', 'integer'), array($nextId, $user_id, $thread_id));
2131
2132 }
2133
2134 return true;
2135 }
isThreadNotificationEnabled($user_id, $thread_id)
Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (resul...

References $ilDB, and isThreadNotificationEnabled().

+ Here is the call graph for this function:

◆ fetchPostNodeData()

ilForum::fetchPostNodeData (   $a_row)

get data of parent node from frm_posts_tree and frm_posts @access private

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

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

1692 {
1693 global $lng;
1694
1695 require_once('./Services/User/classes/class.ilObjUser.php');
1696
1697 if (ilObject::_exists($a_row->pos_display_user_id))
1698 {
1699 $tmp_user = new ilObjUser($a_row->pos_display_user_id);
1700 $fullname = $tmp_user->getFullname();
1701 $loginname = $tmp_user->getLogin();
1702 }
1703
1704 $fullname = $fullname ? $fullname : ($a_row->import_name ? $a_row->import_name : $lng->txt("unknown"));
1705
1706 $data = array(
1707 "pos_pk" => $a_row->pos_pk,
1708 "child" => $a_row->pos_pk,
1709 "author" => $a_row->pos_display_user_id,
1710 "alias" => $a_row->pos_usr_alias,
1711 "title" => $fullname,
1712 "loginname" => $loginname,
1713 "type" => "post",
1714 "message" => $a_row->pos_message,
1715 "subject" => $a_row->pos_subject,
1716 "pos_cens_com" => $a_row->pos_cens_com,
1717 "pos_cens" => $a_row->pos_cens,
1718 // "date" => $a_row->date,
1719 "date" => $a_row->fpt_date,
1720 "create_date" => $a_row->pos_date,
1721 "update" => $a_row->pos_update,
1722 "update_user" => $a_row->update_user,
1723 "tree" => $a_row->thr_fk,
1724 "parent" => $a_row->parent_pos,
1725 "lft" => $a_row->lft,
1726 "rgt" => $a_row->rgt,
1727 "depth" => $a_row->depth,
1728 "id" => $a_row->fpt_pk,
1729 "notify" => $a_row->notify,
1730 "import_name" => $a_row->import_name,
1731 "pos_status" => $a_row->pos_status
1732 );
1733
1734 // why this line? data should be stored without slashes in db
1735 //$data["message"] = stripslashes($data["message"]);
1736
1737 return $data ? $data : array();
1738 }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public

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

Referenced by getFirstPostNode(), and getPostNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generatePost()

ilForum::generatePost (   $forum_id,
  $thread_id,
  $author_id,
  $display_user_id,
  $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$author_id
integer$display_user_id
string$message
integer$parent_pos
integer$notify
integer$anonymize
string$subject
datetime$date
Returns
integer $last: new post ID @access public

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

449 {
450 global $ilDB;
451
452 $objNewPost = new ilForumPost();
453 $objNewPost->setForumId($forum_id);
454 $objNewPost->setThreadId($thread_id);
455 $objNewPost->setSubject($subject);
456 $objNewPost->setMessage($message);
457 $objNewPost->setDisplayUserId($display_user_id);
458 $objNewPost->setUserAlias($alias);
459 $objNewPost->setPosAuthorId($author_id);
460
461 $frm_settings = ilForumProperties::getInstance($this->getForumId());
462
463 if($frm_settings->getMarkModeratorPosts() == 1)
464 {
465 self::_isModerator($this->getForumRefId(), $author_id) ? $is_moderator = true : $is_moderator = false;
466 }
467 else
468 {
469 $is_moderator = false;
470 }
471 $objNewPost->setIsAuthorModerator($is_moderator);
472
473 if ($date == "")
474 {
475 $objNewPost->setCreateDate(date("Y-m-d H:i:s"));
476 }
477 else
478 {
479 if (strpos($date, "-") > 0) // in mysql format
480 {
481 $objNewPost->setCreateDate($date);
482 }
483 else // a timestamp
484 {
485 $objNewPost->setCreateDate(date("Y-m-d H:i:s", $date));
486 }
487 }
488 if($status == 1)
489 {
490 $objNewPost->setPostActivationDate($objNewPost->getCreateDate());
491 }
492
493 $objNewPost->setImportName($this->getImportName());
494 $objNewPost->setNotification($notify);
495 $objNewPost->setStatus($status);
496 $objNewPost->insert();
497
498 // entry in tree-table
499 if ($parent_pos == 0)
500 {
501 $this->addPostTree($objNewPost->getThreadId(), $objNewPost->getId(), $objNewPost->getCreateDate());
502 }
503 else
504 {
505 $this->insertPostNode($objNewPost->getId(), $parent_pos, $objNewPost->getThreadId(), $objNewPost->getCreateDate());
506 }
507
508 // string last post
509 $lastPost = $objNewPost->getForumId()."#".$objNewPost->getThreadId()."#".$objNewPost->getId();
510
511 // update thread
512 $result = $ilDB->manipulateF('
513 UPDATE frm_threads
514 SET thr_num_posts = thr_num_posts + 1,
515 thr_last_post = %s
516 WHERE thr_pk = %s',
517 array('text', 'integer'),
518 array($lastPost, $objNewPost->getThreadId()));
519
520 // update forum
521 $result = $ilDB->manipulateF('
522 UPDATE frm_data
523 SET top_num_posts = top_num_posts + 1,
524 top_last_post = %s
525 WHERE top_pk = %s',
526 array('text', 'integer'),
527 array($lastPost, $objNewPost->getForumId()));
528
529 // MARK READ
531 $forum_obj->markPostRead($objNewPost->getPosAuthorId(), $objNewPost->getThreadId(), $objNewPost->getId());
532
533 // Add Notification to news
534 if($status)
535 {
536 require_once 'Services/RTE/classes/class.ilRTE.php';
537 include_once("./Services/News/classes/class.ilNewsItem.php");
538 $news_item = new ilNewsItem();
539 $news_item->setContext($forum_obj->getId(), 'frm', $objNewPost->getId(), 'pos');
540 $news_item->setPriority(NEWS_NOTICE);
541 $news_item->setTitle($objNewPost->getSubject());
542 $news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($this->prepareText($objNewPost->getMessage(), 0), 1));
543 if($objNewPost->getMessage() != strip_tags($objNewPost->getMessage()))
544 {
545 $news_item->setContentHtml(true);
546 }
547
548 $news_item->setUserId($display_user_id);
549 $news_item->setVisibility(NEWS_USERS);
550 $news_item->create();
551 }
552
553 return $objNewPost->getId();
554 }
const NEWS_USERS
const NEWS_NOTICE
static getInstance($a_obj_id=0)
addPostTree($a_tree_id, $a_node_id=-1, $a_date='')
create a new post-tree
static _isModerator($a_ref_id, $a_usr_id)
checks whether a user is moderator of a given forum object
prepareText($text, $edit=0, $quote_user='', $type='')
prepares given string @access public
insertPostNode($a_node_id, $a_parent_id, $tree_id, $a_date='')
insert node under parent node @access public
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...

References $ilDB, $result, _isModerator(), ilRTE\_replaceMediaObjectImageSrc(), addPostTree(), date, getForumId(), getForumRefId(), getImportName(), ilForumProperties\getInstance(), ilObjectFactory\getInstanceByRefId(), insertPostNode(), NEWS_NOTICE, NEWS_USERS, and prepareText().

Referenced by generateThread().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateThread()

ilForum::generateThread ( ilForumTopic  $thread,
  $message,
  $notify,
  $notify_posts,
  $status = 1 
)
Parameters
ilForumTopic$thread
string$message
int$notify
int$notify_posts
int$status
Returns
int The id of the new posting, created implicitly when creating new threads

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

565 {
566 global $ilDB;
567
568 if(!$thread->getCreateDate())
569 {
570 $thread->setCreateDate(date('Y-m-d H:i:s'));
571 }
572
573 $thread->setImportName($this->getImportName());
574 $thread->insert();
575
576 if($notify_posts == 1)
577 {
578 $thread->enableNotification($thread->getThrAuthorId());
579 }
580
581 $ilDB->manipulateF('
582 UPDATE frm_data
583 SET top_num_threads = top_num_threads + 1
584 WHERE top_pk = %s',
585 array('integer'), array($thread->getForumId()));
586
587 return $this->generatePost(
588 $thread->getForumId(),
589 $thread->getId(),
590 $thread->getThrAuthorId(),
591 $thread->getDisplayUserId(),
592 $message, 0, $notify,
593 $thread->getSubject(),
594 $thread->getUserAlias(),
595 $thread->getCreateDate(),
596 $status,
597 0
598 );
599 }
insert()
Inserts the object data into database.
setImportName($a_import_name)
enableNotification($a_user_id)
Enable a user's notification about new posts in a thread.
setCreateDate($a_createdate)
generatePost($forum_id, $thread_id, $author_id, $display_user_id, $message, $parent_pos, $notify, $subject='', $alias='', $date='', $status=1, $send_activation_mail=0)
generate new dataset in frm_posts

References $ilDB, date, ilForumTopic\enableNotification(), generatePost(), ilForumTopic\getCreateDate(), ilForumTopic\getDisplayUserId(), ilForumTopic\getForumId(), ilForumTopic\getId(), getImportName(), ilForumTopic\getSubject(), ilForumTopic\getThrAuthorId(), ilForumTopic\getUserAlias(), ilForumTopic\insert(), ilForumTopic\setCreateDate(), and ilForumTopic\setImportName().

+ Here is the call graph for this function:

◆ getDbTable()

ilForum::getDbTable ( )

get name of database table

Returns
string name of database table
See also
$dbTable @access User interface

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

226 {
227 return $this->dbTable;
228 }

References $dbTable.

◆ getFirstPostByThread()

ilForum::getFirstPostByThread (   $a_thread_id)

Get first post of thread.

@access public

Parameters
intthread id
Returns

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

1380 {
1381 global $ilDB;
1382
1383 $res = $ilDB->queryf('
1384 SELECT * FROM frm_posts_tree
1385 WHERE thr_fk = %s
1386 AND parent_pos = %s',
1387 array('integer', 'integer'), array($a_thread_id, '0'));
1388
1389 $row = $ilDB->fetchObject($res);
1390
1391 return $row->pos_fk ? $row->pos_fk : 0;
1392 }

References $ilDB, $res, and $row.

◆ getFirstPostNode()

ilForum::getFirstPostNode (   $tree_id)

get data of the first node from frm_posts_tree and frm_posts @access public

Parameters
integertree id
Returns
object db result object

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

1647 {
1648 global $ilDB;
1649
1650 $res = $ilDB->queryf('
1651 SELECT * FROM frm_posts, frm_posts_tree
1652 WHERE pos_pk = pos_fk
1653 AND parent_pos = %s
1654 AND thr_fk = %s',
1655 array('integer', 'integer'),
1656 array('0', $tree_id));
1657
1658 $row = $ilDB->fetchObject($res);
1659
1660 return $this->fetchPostNodeData($row);
1661 }
fetchPostNodeData($a_row)
get data of parent node from frm_posts_tree and frm_posts @access private

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

+ Here is the call graph for this function:

◆ getForumId()

ilForum::getForumId ( )

get forum id @access public

Returns
integer object id of forum

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

158 {
159 return $this->id;
160 }

References $id.

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

+ Here is the caller graph for this function:

◆ getForumRefId()

ilForum::getForumRefId ( )

get forum ref_id @access public

Returns
integer reference id of forum

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

168 {
169 return $this->ref_id;
170 }
$ref_id
Definition: sahs_server.php:39

References $ref_id.

Referenced by deletePost(), generatePost(), getModerators(), and postCensorship().

+ Here is the caller graph for this function:

◆ getImportName()

ilForum::getImportName ( )

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

1981 {
1982 return $this->import_name;
1983 }

Referenced by generatePost(), and generateThread().

+ Here is the caller graph for this function:

◆ getMDB2DataType()

ilForum::getMDB2DataType ( )

get content of additional condition

Returns
array

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

283 {
284 if($this->mdb2DataType != '')
285 {
286 return $this->mdb2DataType;
287 }
288 }

References $mdb2DataType.

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

+ Here is the caller graph for this function:

◆ getMDB2DataValue()

ilForum::getMDB2DataValue ( )

/* get content of additional condition

Returns
array

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

270 {
271 if($this->mdb2DataValue != '')
272 {
274 }
275 }

References $mdb2DataValue.

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

+ Here is the caller graph for this function:

◆ getMDB2Query()

ilForum::getMDB2Query ( )

get content of additional condition

       @return string 

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

256 {
257 if($this->mdb2Query != '')
258 {
259 return $this->mdb2Query;
260 }
261
262 }

References $mdb2Query.

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

+ Here is the caller graph for this function:

◆ getModeratorFromPost()

ilForum::getModeratorFromPost (   $pos_pk)

get one post-dataset

Parameters
integerpost id
Returns
array result dataset of the post @access public

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

1943 {
1944 global $ilDB;
1945
1946 $res = $ilDB->queryf('
1947 SELECT frm_data.* FROM frm_data, frm_posts
1948 WHERE pos_pk = %s
1949 AND pos_top_fk = top_pk',
1950 array('integer'), array($pos_pk));
1951
1952 $row = $ilDB->fetchAssoc($res);
1953
1954 return $row;
1955
1956 }

References $ilDB, $res, and $row.

◆ getModerators()

ilForum::getModerators ( )

get all users assigned to local role il_frm_moderator_<frm_ref_id>

Returns
array user_ids @access public

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

1401 {
1402 return self::_getModerators($this->getForumRefId());
1403 }

References _getModerators(), and getForumRefId().

+ Here is the call graph for this function:

◆ getOnePost()

ilForum::getOnePost (   $post)

get one post-dataset

Parameters
integerpost id
Returns
array result dataset of the post @access public

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

400 {
401 global $ilDB;
402
403 $res = $ilDB->queryf('
404 SELECT frm_posts.*, usr_data.lastname FROM frm_posts, usr_data
405 WHERE pos_pk = %s
406 AND pos_display_user_id = usr_id',
407 array('integer'), array($post));
408
409 $row = $ilDB->fetchAssoc($res);
410
411
412 $row["pos_date"] = $this->convertDate($row["pos_date"]);
413 $row["pos_message"] = nl2br($row["pos_message"]);
414
415 return $row;
416 }
convertDate($date)
converts the date format

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

+ Here is the call graph for this function:

◆ getOneThread()

ilForum::getOneThread ( )

get one thread-dataset by WhereCondition

Returns
array $result dataset of the thread @access public

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

371 {
372 global $ilDB;
373
374 $data_type = array();
375 $data_value = array();
376
377 $query = 'SELECT * FROM frm_threads WHERE ';
378
379 if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
380 {
381 $query .= $this->getMDB2Query();
382 $data_type = $data_type + $this->getMDB2DataType();
383 $data_value = $data_value + $this->getMDB2DataValue();
384
385 $sql_res = $ilDB->queryf($query, $data_type, $data_value);
386 $result = $ilDB->fetchAssoc($sql_res);
387 $result["thr_subject"] = trim($result["thr_subject"]);
388 }
389
390 return $result;
391 }
getMDB2Query()
get content of additional condition
getMDB2DataType()
get content of additional condition
getMDB2DataValue()
/* get content of additional condition

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

+ Here is the call graph for this function:

◆ getOneTopic()

ilForum::getOneTopic ( )

get one topic-dataset by WhereCondition

Returns
array $result dataset of the topic @access public

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

324 {
325 global $ilDB;
326
327 $data_type = array();
328 $data_value = array();
329
330 $query = 'SELECT * FROM frm_data WHERE ';
331
332 if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
333 {
334 $query .= ''.$this->getMDB2Query().'';
335 $data_type = $data_type + $this->getMDB2DataType();
336 $data_value = $data_value + $this->getMDB2DataValue();
337
338 $res = $ilDB->queryf($query, $data_type, $data_value);
339 $row = $ilDB->fetchAssoc($res);
340
341 if(is_null($row)) return NULL;
342
343 $row["top_name"] = trim($row["top_name"]);
344 $row["top_description"] = nl2br($row["top_description"]);
345
346 return $row;
347
348 }
349 else
350 {
351 $query .= '1 = 1';
352
353 $res = $ilDB->query($query);
354 $row = $ilDB->fetchAssoc($res);
355
356 if(!is_array($row) || !count($row)) return null;
357
358 $row['top_name'] = trim($row['top_name']);
359 $row['top_description'] = nl2br($row['top_description']);
360
361 return $row;
362 }
363 }

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

Referenced by moveThreads().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOrderField()

ilForum::getOrderField ( )

get name of orderField

Returns
string name of orderField
See also
$orderField @access User interface

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

197 {
198 return $this->orderField;
199 }

References $orderField.

◆ getPageHits()

ilForum::getPageHits ( )

get number of max.

visible datasets

Returns
integer $pageHits
See also
$pageHits @access User interface

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

312 {
313 return $this->pageHits;
314 }

References $pageHits.

◆ getPostDepth()

ilForum::getPostDepth (   $a_node_id,
  $tree_id 
)

Return depth of an object @access 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 1617 of file class.ilForum.php.

1618 {
1619 global $ilDB;
1620
1621 if ($tree_id)
1622 {
1623 $sql_res = $ilDB->queryf('
1624 SELECT depth FROM frm_posts_tree
1625 WHERE pos_fk = %s
1626 AND thr_fk = %s',
1627 array('integer', 'integer'),
1628 array($a_node_id, $tree_id));
1629
1630 $res = $ilDB->fetchObject($sql_res);
1631
1632 return $res->depth;
1633 }
1634 else
1635 {
1636 return 0;
1637 }
1638 }

References $ilDB, and $res.

Referenced by insertPostNode().

+ Here is the caller graph for this function:

◆ getPostNode()

ilForum::getPostNode (   $post_id)

get data of given node from frm_posts_tree and frm_posts @access public

Parameters
integerpost_id
Returns
object db result object

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

1670 {
1671 global $ilDB;
1672
1673 $res = $ilDB->queryf('
1674 SELECT * FROM frm_posts, frm_posts_tree
1675 WHERE pos_pk = pos_fk
1676 AND pos_pk = %s',
1677 array('integer'),
1678 array($post_id));
1679
1680 $row = $ilDB->fetchObject($res);
1681
1682 return $this->fetchPostNodeData($row);
1683 }

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

Referenced by deletePost().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserStatistic()

ilForum::getUserStatistic (   $is_moderator = false)

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

1302 {
1303 global $ilDB, $ilUser;
1304
1305 $statistic = array();
1306
1307 $data_types = array();
1308 $data = array();
1309
1310 $query = "SELECT COUNT(f.pos_display_user_id) ranking, u.login, p.value, u.lastname, u.firstname
1311 FROM frm_posts f
1312 INNER JOIN frm_posts_tree t
1313 ON f.pos_pk = t.pos_fk
1314 INNER JOIN frm_threads th
1315 ON t.thr_fk = th.thr_pk
1316 INNER JOIN usr_data u
1317 ON u.usr_id = f.pos_display_user_id
1318 INNER JOIN frm_data d
1319 ON d.top_pk = f.pos_top_fk
1320 LEFT JOIN usr_pref p
1321 ON p.usr_id = u.usr_id AND p.keyword = %s
1322 WHERE 1 = 1";
1323
1324 array_push($data_types, 'text');
1325 array_push($data, 'public_profile');
1326
1327 if (!$is_moderator)
1328 {
1329 $query .= ' AND (pos_status = %s
1330 OR (pos_status = %s
1331 AND pos_author_id = %s ))';
1332
1333 array_push($data_types,'integer', 'integer', 'integer');
1334 array_push($data, '1', '0', $ilUser->getId());
1335 }
1336
1337 $query .= ' AND d.top_frm_fk = %s
1338 GROUP BY pos_display_user_id, u.login, p.value,u.lastname, u.firstname';
1339
1340 array_push($data_types,'integer');
1341 array_push($data, $this->getForumId());
1342
1343
1344
1345 $res = $ilDB->queryf($query, $data_types, $data);
1346
1347 $counter = 0;
1348 while ($row = $ilDB->fetchAssoc($res))
1349 {
1350 $statistic[$counter][] = $row['ranking'];
1351 $statistic[$counter][] = $row['login'];
1352
1353 $lastname ='';
1354 $firstname = '';
1355 if(!$ilUser->isAnonymous() && in_array($row['value'], array('y', 'g')) ||
1356 $ilUser->isAnonymous() && 'g' == $row['value'])
1357 {
1358 $lastname = $row['lastname'];
1359 $firstname = $row['firstname'];
1360 }
1361
1362 $statistic[$counter][] = $lastname;
1363 $statistic[$counter][] = $firstname;
1364
1365 ++$counter;
1366 }
1367
1368 return is_array($statistic) ? $statistic : array();
1369 }

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

+ Here is the call graph for this function:

◆ insertPostNode()

ilForum::insertPostNode (   $a_node_id,
  $a_parent_id,
  $tree_id,
  $a_date = '' 
)

insert node under parent node @access public

Parameters
integernode_id
integertree_id
integerparent_id (optional)

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

1544 {
1545 global $ilDB;
1546
1547 $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1548
1549 // get left value
1550 $sql_res = $ilDB->queryf('
1551 SELECT * FROM frm_posts_tree
1552 WHERE pos_fk = %s
1553 AND thr_fk = %s',
1554 array('integer', 'integer'),
1555 array($a_parent_id, $tree_id));
1556
1557 $res = $ilDB->fetchObject($sql_res);
1558
1559 $left = $res->lft;
1560
1561 $lft = $left + 1;
1562 $rgt = $left + 2;
1563
1564 // spread tree
1565 $statement = $ilDB->manipulateF('
1566 UPDATE frm_posts_tree
1567 SET lft = CASE
1568 WHEN lft > %s
1569 THEN lft + 2
1570 ELSE lft
1571 END,
1572 rgt = CASE
1573 WHEN rgt > %s
1574 THEN rgt + 2
1575 ELSE rgt
1576 END
1577 WHERE thr_fk = %s',
1578 array('integer', 'integer', 'integer'),
1579 array($left, $left, $tree_id));
1580
1581 $depth = $this->getPostDepth($a_parent_id, $tree_id) + 1;
1582
1583 // insert node
1584 $nextId = $ilDB->nextId('frm_posts_tree');
1585 $statement = $ilDB->manipulateF('
1586 INSERT INTO frm_posts_tree
1587 ( fpt_pk,
1588 thr_fk,
1589 pos_fk,
1590 parent_pos,
1591 lft,
1592 rgt,
1593 depth,
1594 fpt_date
1595 )
1596 VALUES(%s,%s,%s, %s, %s, %s,%s, %s)',
1597 array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1598 array( $nextId,
1599 $tree_id,
1600 $a_node_id,
1601 $a_parent_id,
1602 $lft,
1603 $rgt,
1604 $depth,
1605 $a_date)
1606 );
1607
1608 }
getPostDepth($a_node_id, $tree_id)
Return depth of an object @access private.

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

Referenced by generatePost().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isForumNotificationEnabled()

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 @access private

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

2095 {
2096 global $ilDB;
2097
2098 $result = $ilDB->queryf('SELECT COUNT(*) cnt FROM frm_notification WHERE user_id = %s AND frm_id = %s',
2099 array('integer', 'integer'), array($user_id, $this->id));
2100
2101 while($record = $ilDB->fetchAssoc($result))
2102 {
2103 return (bool)$record['cnt'];
2104 }
2105
2106 return false;
2107 }

References $ilDB, and $result.

Referenced by enableForumNotification().

+ Here is the caller graph for this function:

◆ isThreadNotificationEnabled()

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 @access private

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

2145 {
2146 global $ilDB;
2147
2148 $result = $ilDB->queryf('
2149 SELECT COUNT(*) cnt FROM frm_notification
2150 WHERE user_id = %s
2151 AND thread_id = %s',
2152 array('integer', 'integer'),
2153 array($user_id, $thread_id));
2154
2155
2156 while($record = $ilDB->fetchAssoc($result))
2157 {
2158 return (bool)$record['cnt'];
2159 }
2160
2161 return false;
2162 }

References $ilDB, and $result.

Referenced by enableThreadNotification().

+ Here is the caller graph for this function:

◆ mergeThreads()

static ilForum::mergeThreads (   $obj_id,
  $source_id,
  $target_id 
)
static
Parameters
$obj_id
$source_id
$target_id
Exceptions
ilException

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

2265 {
2266 // selected source & target objects
2267 $source_thread_obj = new ilForumTopic((int)$source_id);
2268 $target_thread_obj = new ilForumTopic((int)$target_id);
2269
2270 if($source_thread_obj->getForumId() != $target_thread_obj->getForumId())
2271 {
2272 throw new ilException('not_allowed_to_merge_into_another_forum');
2273 }
2274 // use the "older" thread as target
2275 if($source_thread_obj->getCreateDate() > $target_thread_obj->getCreateDate())
2276 {
2277 $merge_thread_source = $source_thread_obj;
2278 $merge_thread_target = $target_thread_obj;
2279 }
2280 else
2281 {
2282 $merge_thread_source = $target_thread_obj;
2283 $merge_thread_target = $source_thread_obj;
2284 }
2285
2286 $thread_subject = $target_thread_obj->getSubject();
2287
2288 // remember if the threads are open or closed and then close both threads !
2289 $targed_was_closed = $merge_thread_target->isClosed();
2290
2291 $merge_thread_source->close();
2292
2293 if($targed_was_closed == false)
2294 {
2295 $merge_thread_target->close();
2296 }
2297
2298 $source_all_posts = $merge_thread_source->getAllPosts();
2299 $source_root_node = $merge_thread_source->getFirstPostNode();
2300 $target_root_node = $merge_thread_target->getFirstPostNode();
2301
2302 $add_difference = $target_root_node->getRgt();
2303
2304// update target root node rgt
2305 include_once 'Modules/Forum/classes/class.ilForumPostsTree.php';
2306// $new_target_rgt = ($target_root_node->getRgt() + $source_root_node->getRgt() + 1);
2307 $new_target_rgt = ($target_root_node->getRgt() + $source_root_node->getRgt());
2308 ilForumPostsTree::updateTargetRootRgt($target_root_node->getId(), $new_target_rgt);
2309
2310 $new_target_root = $target_root_node->getId();
2311
2312 // get source post tree and update posts tree
2313 foreach($source_all_posts as $post)
2314 {
2315 $post_obj = new ilForumPost($post->pos_pk);
2316
2317 $posts_tree_obj = new ilForumPostsTree();
2318 $posts_tree_obj->setPosFk($post->pos_pk);
2319
2320 if($post_obj->getParentId() == 0)
2321 {
2322 $posts_tree_obj->setParentPos($new_target_root);
2323
2324 //$posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference));
2325 $posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference) - 1);
2326 $posts_tree_obj->setLft($target_root_node->getRgt());
2327
2328 $posts_tree_obj->setDepth(($post_obj->getDepth() + 1));
2329 $posts_tree_obj->setSourceThreadId($merge_thread_source->getId());
2330
2331 $posts_tree_obj->setTargetThreadId($merge_thread_target->getId());
2332
2333 $posts_tree_obj->mergeParentPos();
2334 }
2335 else
2336 {
2337 $posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference) - 1);
2338 $posts_tree_obj->setLft(($post_obj->getLft() + $add_difference) - 1);
2339
2340 $posts_tree_obj->setDepth(($post_obj->getDepth() + 1));
2341 $posts_tree_obj->setSourceThreadId($merge_thread_source->getId());
2342
2343 $posts_tree_obj->setParentPos($post_obj->getParentId());
2344 $posts_tree_obj->setTargetThreadId($merge_thread_target->getId());
2345
2346 $posts_tree_obj->merge();
2347 }
2348 }
2349
2350// update frm_posts pos_thr_fk = target_thr_id
2351 include_once 'Modules/Forum/classes/class.ilForumPost.php';
2352 ilForumPost::mergePosts($merge_thread_source->getId(), $merge_thread_target->getId());
2353
2354// check notifications
2355 include_once 'Modules/Forum/classes/class.ilForumNotification.php';
2356 ilForumNotification::mergeThreadNotificiations($merge_thread_source->getId(), $merge_thread_target->getId());
2357
2358// delete frm_thread_access entries
2359 include_once './Modules/Forum/classes/class.ilObjForum.php';
2360 ilObjForum::_deleteAccessEntries($merge_thread_source->getId());
2361
2362// update frm_user_read
2363 ilObjForum::mergeForumUserRead($merge_thread_source->getId(), $merge_thread_target->getId());
2364
2365// update visits, thr_num_posts, last_post, subject
2366 $post_date_source = $merge_thread_source->getLastPost()->getCreateDate();
2367 $post_date_target = $merge_thread_target->getLastPost()->getCreateDate();
2368
2369 $target_last_post = $merge_thread_target->getLastPostString();
2370 $exp = explode('#', $target_last_post);
2371
2372 if($post_date_source > $post_date_target)
2373 {
2374 $exp[2] = $merge_thread_source->getLastPost()->getId();
2375 }
2376 else
2377 {
2378 $exp[2] = $merge_thread_target->getLastPost()->getId();
2379 }
2380 $new_thr_last_post = implode('#', $exp);
2381
2382 $num_posts_source = (int)$merge_thread_source->getNumPosts();
2383 $num_visits_source = (int)$merge_thread_source->getVisits();
2384 $num_posts_target = (int)$merge_thread_target->getNumPosts();
2385 $num_visits_target = (int)$merge_thread_source->getVisits();
2386
2387 $frm_topic_obj = new ilForumTopic(0, false, true);
2388 $frm_topic_obj->setNumPosts(($num_posts_source + $num_posts_target));
2389 $frm_topic_obj->setVisits(($num_visits_source + $num_visits_target));
2390 $frm_topic_obj->setLastPostString($new_thr_last_post);
2391 $frm_topic_obj->setSubject($thread_subject);
2392 $frm_topic_obj->setId($merge_thread_target->getId());
2393
2394 $frm_topic_obj->updateMergedThread();
2395
2396// update frm_data: top_last_post , top_num_threads
2398
2399// reopen target if was not "closed" before merging
2400 if(!$targed_was_closed)
2401 {
2402 $merge_thread_target->reopen();
2403 }
2404 // raise event for updating existing drafts
2405 $GLOBALS['ilAppEventHandler']->raise('Modules/Forum', 'mergedThreads',
2406 array( 'source_thread_id' => $merge_thread_source->getId(),
2407 'target_thread_id' => $merge_thread_target->getId())
2408 );
2409
2410// delete source thread
2411 ilForumTopic::deleteByThreadId($merge_thread_source->getId());
2412 }
Base class for ILIAS Exception handling.
static mergeThreadNotificiations($merge_source_thread_id, $merge_target_thread_id)
static mergePosts($source_thread_id, $target_thread_id)
static updateTargetRootRgt($root_node_id, $rgt)
static deleteByThreadId($thr_id)
static updateLastPostByObjId($a_obj_id)
static mergeForumUserRead($merge_source_thread_id, $merge_target_thread_id)
$target_id
Definition: goto.php:51

References $GLOBALS, $target_id, ilForumTopic\deleteByThreadId(), ilObjForum\mergeForumUserRead(), ilForumPost\mergePosts(), ilForumNotification\mergeThreadNotificiations(), updateLastPostByObjId(), and ilForumPostsTree\updateTargetRootRgt().

+ Here is the call graph for this function:

◆ moveThreads()

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 @access public

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

610 {
611 global $ilDB;
612
613 $src_top_frm_fk = ilObject::_lookupObjectId($src_ref_id);
614
615 if (is_numeric($src_top_frm_fk) && $src_top_frm_fk > 0 && is_numeric($dest_top_frm_fk) && $dest_top_frm_fk > 0)
616 {
617
618 $this->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($src_top_frm_fk));
619
620 $oldFrmData = $this->getOneTopic();
621
622 $this->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($dest_top_frm_fk));
623
624 $newFrmData = $this->getOneTopic();
625
626 if ($oldFrmData['top_pk'] && $newFrmData['top_pk'])
627 {
628 $moved_posts = 0;
629 $moved_threads = 0;
630 $visits = 0;
631 foreach ($thread_ids as $id)
632 {
633 $objTmpThread = new ilForumTopic($id);
634
635 $numPosts = $objTmpThread->movePosts($src_top_frm_fk, $oldFrmData['top_pk'], $dest_top_frm_fk, $newFrmData['top_pk']);
636 if (($last_post_string = $objTmpThread->getLastPostString()) != '')
637 {
638 $last_post_string = explode('#', $last_post_string);
639 $last_post_string[0] = $newFrmData['top_pk'];
640 $last_post_string = implode('#', $last_post_string);
641 $objTmpThread->setLastPostString($last_post_string);
642 }
643
644 $visits += $objTmpThread->getVisits();
645
646 $moved_posts += $numPosts;
647 ++$moved_threads;
648
649 $objTmpThread->setForumId($newFrmData['top_pk']);
650 $objTmpThread->update();
651
652 unset($objTmpThread);
653 }
654
655 // update frm_data source forum
656 $ilDB->setLimit(1);
657 $res = $ilDB->queryf('
658 SELECT pos_thr_fk, pos_pk
659 FROM frm_posts
660 WHERE pos_top_fk = %s
661 ORDER BY pos_date DESC',
662 array('integer'), array($oldFrmData['top_pk']));
663
664 $row = $ilDB->fetchObject($res);
665 $last_post_src = $oldFrmData['top_pk'] . '#' . $row->pos_thr_fk . '#' . $row->pos_pk;
666
667 $statement = $ilDB->manipulateF('
668 UPDATE frm_data
669 SET top_num_posts = top_num_posts - %s,
670 top_num_threads = top_num_threads - %s,
671 visits = visits - %s,
672 top_last_post = %s
673 WHERE top_pk = %s',
674 array('integer', 'integer', 'integer', 'text', 'integer'),
675 array( $moved_posts,
676 $moved_threads,
677 $visits,
678 $last_post_src,
679 $oldFrmData['top_pk']));
680
681 // update frm_data destination forum
682
683 $ilDB->setLimit(1);
684 $res = $ilDB->queryf('
685 SELECT pos_thr_fk, pos_pk
686 FROM frm_posts
687 WHERE pos_top_fk = %s
688 ORDER BY pos_date DESC',
689 array('integer'), array($newFrmData['top_kp']));
690
691 $row = $ilDB->fetchObject($res);
692 $last_post_dest = $newFrmData['top_pk'] . '#' . $row->pos_thr_fk . '#' . $row->pos_pk;
693
694 $statement = $ilDB->manipulateF('
695 UPDATE frm_data
696 SET top_num_posts = top_num_posts + %s,
697 top_num_threads = top_num_threads + %s,
698 visits = visits + %s,
699 top_last_post = %s
700 WHERE top_pk = %s',
701 array('integer', 'integer', 'integer', 'text', 'integer'),
702 array($moved_posts, $moved_threads, $visits, $last_post_dest, $newFrmData['top_pk']));
703
704 /*
705 // update news items
706 include_once("./Services/News/classes/class.ilNewsItem.php");
707 $objNewsItem = new ilNewsItem();
708 $news_items = $objNewsItem->getNewsForRefId($src_ref_id);
709 foreach ($news_items as $news_item)
710 {
711 $tmpObjNewsItem = new ilNewsItem($news_item['id']);
712 if ($tmpObjNewsItem->getContextObjId() == $src_top_frm_fk)
713 {
714 $tmpObjNewsItem->setContextObjId($dest_top_frm_fk);
715 $tmpObjNewsItem->update();
716 }
717 unset($tmpObjNewsItem);
718 }
719 */
720 }
721 }
722}
getOneTopic()
get one topic-dataset by WhereCondition
setMDB2WhereCondition($query_string, $data_type, $data_value)
set content for additional condition
static _lookupObjectId($a_ref_id)
lookup object id

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

+ Here is the call graph for this function:

◆ postCensorship()

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

update dataset in frm_posts with censorship info

Parameters
stringmessage
integerpos_pk
Returns
boolean @access public

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

733 {
734 global $ilDB;
735
736 $cens_date = date("Y-m-d H:i:s");
737
738 $ilDB->manipulateF('
739 UPDATE frm_posts
740 SET pos_cens_com = %s,
741 pos_cens_date = %s,
742 pos_cens = %s,
743 update_user = %s
744 WHERE pos_pk = %s',
745 array('text', 'timestamp', 'integer', 'integer', 'integer'),
746 array($message, $cens_date, $cens, $GLOBALS['DIC']['ilUser']->getId(), $pos_pk));
747
748 // Change news item accordingly
749 include_once("./Services/News/classes/class.ilNewsItem.php");
750 $news_id = ilNewsItem::getFirstNewsIdForContext($this->id,
751 "frm", $pos_pk, "pos");
752 if ($news_id > 0)
753 {
754 if ($cens > 0) // censor
755 {
756 $news_item = new ilNewsItem($news_id);
757 //$news_item->setTitle($subject);
758 $news_item->setContent(nl2br($this->prepareText($message, 0)));
759 if($message != strip_tags($message))
760 {
761 $news_item->setContentHtml(true);
762 }
763 else
764 {
765 $news_item->setContentHtml(false);
766 }
767
768 $news_item->update();
769 }
770 else // revoke censorship
771 {
772 // get original message
773 $res = $ilDB->queryf('
774 SELECT * FROM frm_posts
775 WHERE pos_pk = %s',
776 array('integer'), array($pos_pk));
777
778 $rec = $ilDB->fetchAssoc($res);
779
780 $news_item = new ilNewsItem($news_id);
781 //$news_item->setTitle($subject);
782 $news_item->setContent(nl2br($this->prepareText($rec["pos_message"], 0)));
783 if($rec["pos_message"] != strip_tags($rec["pos_message"]))
784 {
785 $news_item->setContentHtml(true);
786 }
787 else
788 {
789 $news_item->setContentHtml(false);
790 }
791
792 $news_item->update();
793 }
794 }
795
796 require_once 'Modules/Forum/classes/class.ilForumPost.php';
797 $GLOBALS['ilAppEventHandler']->raise(
798 'Modules/Forum',
799 'censoredPost',
800 array(
801 'ref_id' => $this->getForumRefId(),
802 'post' => new ilForumPost($pos_pk)
803 )
804 );
805
806 return true;
807 }

References $GLOBALS, $ilDB, $res, date, ilNewsItem\getFirstNewsIdForContext(), getForumRefId(), and prepareText().

+ Here is the call graph for this function:

◆ prepareText()

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

prepares given string @access public

Parameters
string
integer
Returns
string

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

1852 {
1853 global $lng;
1854
1855 if($type == 'export')
1856 {
1857 $this->replQuote1 = "<blockquote class=\"quote\"><hr size=\"1\" color=\"#000000\">";
1858 $this->replQuote2 = "<hr size=\"1\" color=\"#000000\"/></blockquote>";
1859 }
1860
1861 if($edit == 1)
1862 {
1863 // add login name of quoted users
1864 $lname = ($quote_user != "")
1865 ? '="'.$quote_user.'"'
1866 : "";
1867
1868 $text = "[quote$lname]".$text."[/quote]";
1869 }
1870 else
1871 {
1872 // check for quotation
1873 $startZ = substr_count ($text, "[quote"); // also count [quote="..."]
1874 $endZ = substr_count ($text, "[/quote]");
1875
1876 if ($startZ > 0 || $endZ > 0)
1877 {
1878 // add missing opening and closing tags
1879 if ($startZ > $endZ)
1880 {
1881 $diff = $startZ - $endZ;
1882
1883 for ($i = 0; $i < $diff; $i++)
1884 {
1885 if ($type == 'export') $text .= $this->txtQuote2;
1886 else $text .= "[/quote]";
1887 }
1888 }
1889 elseif ($startZ < $endZ)
1890 {
1891 $diff = $endZ - $startZ;
1892
1893 for ($i = 0; $i < $diff; $i++)
1894 {
1895 if ($type == 'export') $text = $this->txtQuote1.$text;
1896 else $text = "[quote]".$text;
1897 }
1898 }
1899
1900 if($edit == 0)
1901 {
1902 $text = preg_replace(
1903 '@\[(quote\s*?=\s*?"([^"]*?)"\s*?)\]@i',
1904 $this->replQuote1 . '<div class="ilForumQuoteHead">' . $lng->txt('quote'). ' ($2)</div>',
1905 $text
1906 );
1907
1908 $text = str_replace("[quote]",
1909 $this->replQuote1.'<div class="ilForumQuoteHead">'.$lng->txt("quote").'</div>', $text);
1910
1911 $text = str_replace("[/quote]", $this->replQuote2, $text);
1912 }
1913 }
1914 }
1915
1916 if($type != 'export')
1917 {
1918 if($edit == 0)
1919 {
1920 include_once './Services/MathJax/classes/class.ilMathJax.php';
1921 $text = ilMathJax::getInstance()->insertLatexImages($text, "<span class\=\"latex\">", "<\/span>");
1922 $text = ilMathJax::getInstance()->insertLatexImages($text, "\[tex\]", "\[\/tex\]");
1923 }
1924
1925 // workaround for preventing template engine
1926 // from hiding text that is enclosed
1927 // in curly brackets (e.g. "{a}")
1928 $text = str_replace("{", "&#123;", $text);
1929 $text = str_replace("}", "&#125;", $text);
1930 }
1931
1932 return $text;
1933 }
static getInstance()
Singleton: get instance.
$text

References $lng, $text, $txtQuote2, and ilMathJax\getInstance().

Referenced by generatePost(), and postCensorship().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDbTable()

ilForum::setDbTable (   $dbTable)

set database table

Parameters
string$dbTabledatabase table
See also
$dbTable @access User interface

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

208 {
209 if ($dbTable == "")
210 {
211 die($this->className . "::setDbTable(): No database table given.");
212 }
213 else
214 {
215 $this->dbTable = $dbTable;
216 }
217 }

References $dbTable.

◆ setForumId()

ilForum::setForumId (   $a_obj_id)

set object id which refers to ILIAS obj_id

Parameters
integerobject id @access public

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

125 {
126
127 if (!isset($a_obj_id))
128 {
129 $message = get_class($this)."::setForumId(): No obj_id given!";
130 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
131 }
132
133 $this->id = $a_obj_id;
134 }

◆ setForumRefId()

ilForum::setForumRefId (   $a_ref_id)

set reference id which refers to ILIAS obj_id

Parameters
integerobject id @access public

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

142 {
143 if (!isset($a_ref_id))
144 {
145 $message = get_class($this)."::setForumRefId(): No ref_id given!";
146 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
147 }
148
149 $this->ref_id = $a_ref_id;
150 }

◆ setImportName()

ilForum::setImportName (   $a_import_name)

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

1985 {
1986 $this->import_name = $a_import_name;
1987 }

◆ setLanguage()

ilForum::setLanguage (   $lng)

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

89 {
90 $this->lng = $lng;
91 }

References $lng.

◆ setMDB2WhereCondition()

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 240 of file class.ilForum.php.

241 {
242 $this->mdb2Query = $query_string;
243 $this->mdb2DataValue = $data_value;
244 $this->mdb2DataType = $data_type;
245
246 return true;
247 }

Referenced by moveThreads().

+ Here is the caller graph for this function:

◆ setOrderField()

ilForum::setOrderField (   $orderField)
private

set database field for sorting results

Parameters
string$orderFielddatabase field for sorting
See also
$orderField @access private

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

179 {
180 if ($orderField == "")
181 {
182 die($this->className . "::setOrderField(): No orderField given.");
183 }
184 else
185 {
186 $this->orderField = $orderField;
187 }
188 }

References $orderField.

◆ setPageHits()

ilForum::setPageHits (   $pageHits)
Parameters
int$pageHits
Returns
bool

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

295 {
296 if($pageHits < 1 || !is_numeric($pageHits))
297 {
298 $pageHits = 1;
299 }
300
301 $this->pageHits = (int)$pageHits;
302 return true;
303 }

References $pageHits.

◆ updateLastPostByObjId()

static ilForum::updateLastPostByObjId (   $a_obj_id)
static

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

2220 {
2221 global $ilDB;
2222 // get latest post of forum and update last_post
2223 $ilDB->setLimit(1);
2224 $res2 = $ilDB->queryf('
2225 SELECT pos_top_fk, pos_thr_fk, pos_pk FROM frm_posts, frm_data
2226 WHERE pos_top_fk = top_pk
2227 AND top_frm_fk = %s
2228 ORDER BY pos_date DESC',
2229 array('integer'), array($a_obj_id));
2230
2231 if ($res2->numRows() == 0)
2232 {
2233 $lastPost_top = "";
2234 }
2235 else
2236 {
2237 $z = 0;
2238
2239 while ($selData = $ilDB->fetchAssoc($res2))
2240 {
2241 if ($z > 0)
2242 {
2243 break;
2244 }
2245
2246 $lastPost_top = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
2247 $z ++;
2248 }
2249 }
2250
2251 $ilDB->update('frm_data',
2252 array('top_last_post' => array('text', $lastPost_top)),
2253 array('top_frm_fk' => array('integer', $a_obj_id))
2254 );
2255
2256 }

References $ilDB.

Referenced by mergeThreads().

+ Here is the caller graph for this function:

◆ updateVisits()

ilForum::updateVisits (   $ID)

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

Parameters
integer

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

1818 {
1819
1820 global $ilDB;
1821
1822 $checkTime = time() - (60*60);
1823
1824 if ($_SESSION["frm_visit_".$this->dbTable."_".$ID] < $checkTime)
1825 {
1826
1827 $_SESSION["frm_visit_".$this->dbTable."_".$ID] = time();
1828 $query = 'UPDATE '.$this->dbTable.' SET visits = visits + 1 WHERE ';
1829
1830 $data_type = array();
1831 $data_value = array();
1832
1833 if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
1834 {
1835 $query .= $this->getMDB2Query();
1836 $data_type = $data_type + $this->getMDB2DataType();
1837 $data_value = $data_value + $this->getMDB2DataValue();
1838
1839 $res = $ilDB->queryf($query, $data_type, $data_value);
1840 }
1841 }
1842 }
$_SESSION["AccountId"]

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

+ Here is the call graph for this function:

Field Documentation

◆ $className

ilForum::$className ="ilForum"
private

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

◆ $dbTable

ilForum::$dbTable
private

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

Referenced by getDbTable(), and setDbTable().

◆ $id

ilForum::$id
private

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

Referenced by getForumId(), and moveThreads().

◆ $ilias

ilForum::$ilias

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

Referenced by __construct().

◆ $lng

ilForum::$lng

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

Referenced by __construct(), fetchPostNodeData(), prepareText(), and setLanguage().

◆ $mdb2DataType

ilForum::$mdb2DataType
private

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

Referenced by getMDB2DataType().

◆ $mdb2DataValue

ilForum::$mdb2DataValue
private

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

Referenced by getMDB2DataValue().

◆ $mdb2Query

ilForum::$mdb2Query
private

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

Referenced by getMDB2Query().

◆ $moderators_by_ref_id_map

ilForum::$moderators_by_ref_id_map = array()
staticprotected

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

◆ $orderField

ilForum::$orderField
private

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

Referenced by getOrderField(), and setOrderField().

◆ $pageHits

ilForum::$pageHits = self::DEFAULT_PAGE_HITS
private

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

Referenced by getPageHits(), and setPageHits().

◆ $replQuote1

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

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

◆ $replQuote2

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

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

◆ $txtQuote1

ilForum::$txtQuote1 = "[quote]"
private

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

◆ $txtQuote2

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

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

Referenced by prepareText().

◆ DEFAULT_PAGE_HITS

const ilForum::DEFAULT_PAGE_HITS = 30

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

◆ SORT_DATE

const ilForum::SORT_DATE = 2

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

Referenced by _getThreads().

◆ SORT_TITLE

const ilForum::SORT_TITLE = 1

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

Referenced by _getThreads(), and ilObjForumGUI\cloneWizardPageObject().


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