ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 
 _lookupPostMessage ($a_id)
 
 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 ($forum_id, $author_id, $display_user_id, $subject, $message, $notify, $notify_posts, $alias='', $date='', $status=1)
 generate new dataset in frm_threads More...
 
 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...
 
 _getModerators ($a_ref_id)
 get all users assigned to local role il_frm_moderator_<frm_ref_id> (static) 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 _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 1909 of file class.ilForum.php.

1910 {
1911 if(!is_array($a_ids))
1912 {
1913 return false;
1914 }
1915 include_once "./Modules/Forum/classes/class.ilFileDataForum.php";
1916
1917 $tmp_file_obj =& new ilFileDataForum($this->getForumId());
1918 foreach($a_ids as $pos_id)
1919 {
1920 $tmp_file_obj->setPosId($pos_id);
1921 $files = $tmp_file_obj->getFilesOfPost();
1922 foreach($files as $file)
1923 {
1924 $tmp_file_obj->unlinkFile($file["name"]);
1925 }
1926 }
1927 unset($tmp_file_obj);
1928 return true;
1929 }
print $file
This class handles all operations on files for the forum object.
getForumId()
get forum id @access public

References $file, 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()

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

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

1362 {
1363 global $rbacreview;
1364
1365 $role_arr = $rbacreview->getRolesOfRoleFolder($a_ref_id);
1366
1367 foreach ($role_arr as $role_id)
1368 {
1369 //$roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1370 $title = ilObject::_lookupTitle($role_id);
1371 if ($title == "il_frm_moderator_".$a_ref_id)
1372 {
1373 #return $rbacreview->assignedUsers($roleObj->getId());
1374 return $title = $rbacreview->assignedUsers($role_id);
1375 }
1376 }
1377
1378 return array();
1379 }
static _lookupTitle($a_id)
lookup object title

References ilObject\_lookupTitle().

Referenced by _isModerator(), getModerators(), and ilObjForumNotificationDataProvider\getPostActivationRecipients().

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

2125 {
2126 global $ilDB;
2127
2128 switch($a_sort_mode)
2129 {
2130 case self::SORT_DATE:
2131 $sort = 'thr_date';
2132 break;
2133
2134 case self::SORT_TITLE:
2135 default:
2136 $sort = 'thr_subject';
2137 break;
2138 }
2139
2140 $res = $ilDB->queryf('
2141 SELECT * FROM frm_threads
2142 JOIN frm_data ON top_pk = thr_top_fk
2143 WHERE top_frm_fk = %s
2144 ORDER BY %s',
2145 array('integer', 'text'), array($a_obj_id, $sort));
2146
2147 while($row = $ilDB->fetchObject($res))
2148 {
2149 $threads[$row->thr_pk] = $row->thr_subject;
2150 }
2151 return $threads ? $threads : array();
2152 }
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 1389 of file class.ilForum.php.

1390 {
1391 if(!self::$moderators_by_ref_id_map[$a_ref_id])
1392 {
1393 self::$moderators_by_ref_id_map[$a_ref_id] = ilForum::_getModerators($a_ref_id);
1394 }
1395 return in_array($a_usr_id, self::$moderators_by_ref_id_map[$a_ref_id]);
1396 }
_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 2154 of file class.ilForum.php.

2155 {
2156 global $ilDB;
2157
2158 $res = $ilDB->queryf('
2159 SELECT top_frm_fk FROM frm_data
2160 WHERE top_pk = %s',
2161 array('integer'), array($a_for_id));
2162
2163 if ($fdata = $ilDB->fetchAssoc($res))
2164 {
2165 return $fdata["top_frm_fk"];
2166 }
2167 return false;
2168 }

References $ilDB, and $res.

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

+ Here is the caller graph for this function:

◆ _lookupPostMessage()

ilForum::_lookupPostMessage (   $a_id)

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

1459 {
1460 global $ilDB;
1461
1462 $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1463
1464 if ($a_node_id <= 0)
1465 {
1466 $a_node_id = $a_tree_id;
1467 }
1468
1469 $nextId = $ilDB->nextId('frm_posts_tree');
1470
1471 $statement = $ilDB->manipulateF('
1472 INSERT INTO frm_posts_tree
1473 ( fpt_pk,
1474 thr_fk,
1475 pos_fk,
1476 parent_pos,
1477 lft,
1478 rgt,
1479 depth,
1480 fpt_date
1481 )
1482 VALUES(%s, %s, %s, %s, %s, %s, %s, %s )',
1483 array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1484 array($nextId, $a_tree_id, $a_node_id, '0', '1', '2', '1', $a_date));
1485
1486 return true;
1487 }

References $ilDB.

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

1447 {
1449 }
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 1420 of file class.ilForum.php.

1421 {
1422 global $ilDB, $ilUser;
1423
1424 $res = $ilDB->queryf('
1425 SELECT * FROM frm_data
1426 INNER JOIN frm_posts ON pos_top_fk = top_pk
1427 WHERE top_frm_fk = %s
1428 AND (pos_status = %s
1429 OR (pos_status = %s
1430 AND pos_author_id = %s
1431 )
1432 )
1433 AND pos_author_id = %s',
1434 array('integer', 'integer', 'integer', 'integer', 'integer'),
1435 array($this->getForumId(),'1', '0', $ilUser->getId(), $a_user_id));
1436
1437 return $res->numRows();
1438 }
global $ilUser
Definition: imgupload.php:15

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

1406 {
1407 global $ilDB;
1408
1409 $res = $ilDB->queryf('
1410 SELECT * FROM frm_data
1411 INNER JOIN frm_posts ON pos_top_fk = top_pk
1412 WHERE top_frm_fk = %s
1413 AND pos_author_id = %s',
1414 array('integer', 'integer'),
1415 array($this->getForumId(), $a_user_id));
1416
1417 return $res->numRows();
1418 }

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

797 {
798 global $ilDB;
799
800 include_once "./Modules/Forum/classes/class.ilObjForum.php";
801
802 $p_node = $this->getPostNode($post);
803
804 $GLOBALS['ilAppEventHandler']->raise(
805 'Modules/Forum',
806 'deletedPost',
807 array(
808 'ref_id' => $this->getForumRefId(),
809 'post' => new ilForumPost($post),
810 'thread_deleted' => ($p_node["parent"] == 0)? true : false
811 )
812 );
813
814 // delete tree and get id's of all posts to delete
815 $del_id = $this->deletePostTree($p_node);
816
817 // Delete User read entries
818 foreach($del_id as $post_id)
819 {
820 ilObjForum::_deleteReadEntries($post_id);
821 }
822
823 // DELETE ATTACHMENTS ASSIGNED TO POST
824 $this->__deletePostFiles($del_id);
825
826 $dead_pos = count($del_id);
827 $dead_thr = 0;
828
829 // if deletePost is thread opener ...
830 if ($p_node["parent"] == 0)
831 {
832 // delete thread access data
833 include_once './Modules/Forum/classes/class.ilObjForum.php';
834
835 ilObjForum::_deleteAccessEntries($p_node['tree']);
836
837 // delete thread
838 $dead_thr = $p_node["tree"];
839
840 $statement = $ilDB->manipulateF('
841 DELETE FROM frm_threads
842 WHERE thr_pk = %s',
843 array('integer'), array($p_node['tree']));
844
845 // update num_threads
846 $statement = $ilDB->manipulateF('
847 UPDATE frm_data
848 SET top_num_threads = top_num_threads - 1
849 WHERE top_frm_fk = %s',
850 array('integer'), array($this->id));
851
852 // delete all related news
853 $posset = $ilDB->queryf('
854 SELECT * FROM frm_posts
855 WHERE pos_thr_fk = %s',
856 array('integer'), array($p_node['tree']));
857
858 while ($posrec = $ilDB->fetchAssoc($posset))
859 {
860 include_once("./Services/News/classes/class.ilNewsItem.php");
861 $news_id = ilNewsItem::getFirstNewsIdForContext($this->id,
862 "frm", $posrec["pos_pk"], "pos");
863 if ($news_id > 0)
864 {
865 $news_item = new ilNewsItem($news_id);
866 $news_item->delete();
867 }
868
869 try
870 {
871 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
872 $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $posrec['pos_pk']);
873 foreach($mobs as $mob)
874 {
876 {
877 ilObjMediaObject::_removeUsage($mob, 'frm:html', $posrec['pos_pk']);
878 $mob_obj = new ilObjMediaObject($mob);
879 $mob_obj->delete();
880 }
881 }
882 }
883 catch(Exception $e)
884 {
885 }
886 }
887
888
889 // delete all posts of this thread
890 $statement = $ilDB->manipulateF('
891 DELETE FROM frm_posts
892 WHERE pos_thr_fk = %s',
893 array('integer'), array($p_node['tree']));
894
895 }
896 else
897 {
898
899 // delete this post and its sub-posts
900 for ($i = 0; $i < $dead_pos; $i++)
901 {
902 $statement = $ilDB->manipulateF('
903 DELETE FROM frm_posts
904 WHERE pos_pk = %s',
905 array('integer'), array($del_id[$i]));
906
907 // delete related news item
908 include_once("./Services/News/classes/class.ilNewsItem.php");
909 $news_id = ilNewsItem::getFirstNewsIdForContext($this->id,
910 "frm", $del_id[$i], "pos");
911 if ($news_id > 0)
912 {
913 $news_item = new ilNewsItem($news_id);
914 $news_item->delete();
915 }
916
917 try
918 {
919 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
920 $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $del_id[$i]);
921 foreach($mobs as $mob)
922 {
924 {
925 ilObjMediaObject::_removeUsage($mob, 'frm:html', $del_id[$i]);
926 $mob_obj = new ilObjMediaObject($mob);
927 $mob_obj->delete();
928 }
929 }
930 }
931 catch(Exception $e)
932 {
933 }
934 }
935
936 // update num_posts in frm_threads
937 $statement = $ilDB->manipulateF('
938 UPDATE frm_threads
939 SET thr_num_posts = thr_num_posts - %s
940 WHERE thr_pk = %s',
941 array('integer', 'integer'),
942 array($dead_pos, $p_node['tree']));
943
944
945 // get latest post of thread and update last_post
946 $res1 = $ilDB->queryf('
947 SELECT * FROM frm_posts
948 WHERE pos_thr_fk = %s
949 ORDER BY pos_date DESC',
950 array('integer'), array($p_node['tree']));
951
952 if ($res1->numRows() == 0)
953 {
954 $lastPost_thr = "";
955 }
956 else
957 {
958 $z = 0;
959
960 while ($selData = $ilDB->fetchAssoc($res1))
961 {
962 if ($z > 0)
963 {
964 break;
965 }
966
967 $lastPost_thr = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
968 $z ++;
969 }
970 }
971
972 $statement = $ilDB->manipulateF('
973 UPDATE frm_threads
974 SET thr_last_post = %s
975 WHERE thr_pk = %s',
976 array('text', 'integer'), array($lastPost_thr, $p_node['tree']));
977 }
978
979 // update num_posts in frm_data
980 $statement = $ilDB->manipulateF('
981 UPDATE frm_data
982 SET top_num_posts = top_num_posts - %s
983 WHERE top_frm_fk = %s',
984 array('integer', 'integer'), array($dead_pos, $this->id));
985
986
987 // get latest post of forum and update last_post
988 $res2 = $ilDB->queryf('
989 SELECT * FROM frm_posts, frm_data
990 WHERE pos_top_fk = top_pk
991 AND top_frm_fk = %s
992 ORDER BY pos_date DESC',
993 array('integer'), array($this->id));
994
995 if ($res2->numRows() == 0)
996 {
997 $lastPost_top = "";
998 }
999 else
1000 {
1001 $z = 0;
1002
1003 while ($selData = $ilDB->fetchAssoc($res2))
1004 {
1005 if ($z > 0)
1006 {
1007 break;
1008 }
1009
1010 $lastPost_top = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
1011 $z ++;
1012 }
1013 }
1014
1015 $statement = $ilDB->manipulateF('
1016 UPDATE frm_data
1017 SET top_last_post = %s
1018 WHERE top_frm_fk = %s',
1019 array('text', 'integer'), array($lastPost_top, $this->id));
1020
1021 return $dead_thr;
1022 }
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.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _exists($a_id)
checks wether a lm content object with specified id exists or not
_removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
$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 1699 of file class.ilForum.php.

1700 {
1701 global $ilDB;
1702
1703 // GET LEFT AND RIGHT VALUES
1704 $res = $ilDB->queryf('
1705 SELECT * FROM frm_posts_tree
1706 WHERE thr_fk = %s
1707 AND pos_fk = %s
1708 AND parent_pos = %s',
1709 array('integer', 'integer', 'integer'),
1710 array($a_node['tree'], $a_node['pos_pk'], $a_node['parent']));
1711
1712 while($row = $ilDB->fetchObject($res))
1713 {
1714 $a_node["lft"] = $row->lft;
1715 $a_node["rgt"] = $row->rgt;
1716 }
1717
1718 $diff = $a_node["rgt"] - $a_node["lft"] + 1;
1719
1720 // get data of posts
1721 $result = $ilDB->queryf('
1722 SELECT * FROM frm_posts_tree
1723 WHERE lft BETWEEN %s AND %s
1724 AND thr_fk = %s',
1725 array('integer', 'integer', 'integer'),
1726 array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
1727
1728 $del_id = array();
1729
1730 while ($treeData = $ilDB->fetchAssoc($result))
1731 {
1732 $del_id[] = $treeData["pos_fk"];
1733 }
1734
1735 // delete subtree
1736 $statement = $ilDB->manipulateF('
1737 DELETE FROM frm_posts_tree
1738 WHERE lft BETWEEN %s AND %s
1739 AND thr_fk = %s',
1740 array('integer', 'integer', 'integer'),
1741 array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
1742
1743
1744 // close gaps
1745 $statement = $ilDB->manipulateF('
1746 UPDATE frm_posts_tree
1747 SET lft = CASE
1748 WHEN lft > %s
1749 THEN lft - %s
1750 ELSE lft
1751 END,
1752 rgt = CASE
1753 WHEN rgt > %s
1754 THEN rgt - %s
1755 ELSE rgt
1756 END
1757 WHERE thr_fk = %s',
1758 array('integer', 'integer', 'integer', 'integer', 'integer'),
1759 array($a_node['lft'], $diff, $a_node['lft'], $diff, $a_node['tree']));
1760
1761 return $del_id;
1762
1763 }
$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 2025 of file class.ilForum.php.

2026 {
2027 global $ilDB;
2028
2029 $statement = $ilDB->manipulateF('
2030 DELETE FROM frm_notification
2031 WHERE user_id = %s
2032 AND frm_id = %s',
2033 array('integer', 'integer'),
2034 array($user_id, $this->id));
2035
2036 return true;
2037 }

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

1947 {
1948 global $ilDB;
1949
1950 if (!$this->isForumNotificationEnabled($user_id))
1951 {
1952 /* Remove all notifications of threads that belong to the forum */
1953
1954 $res = $ilDB->queryf('
1955 SELECT frm_notification.thread_id FROM frm_data, frm_notification, frm_threads
1956 WHERE frm_notification.user_id = %s
1957 AND frm_notification.thread_id = frm_threads.thr_pk
1958 AND frm_threads.thr_top_fk = frm_data.top_pk
1959 AND frm_data.top_frm_fk = %s
1960 GROUP BY frm_notification.thread_id',
1961 array('integer', 'integer'),
1962 array($user_id, $this->id));
1963
1964 if (is_object($res) && $res->numRows() > 0)
1965 {
1966 $thread_data = array();
1967 $thread_data_types = array();
1968
1969 $query = ' DELETE FROM frm_notification
1970 WHERE user_id = %s
1971 AND thread_id IN (';
1972
1973 array_push($thread_data, $user_id);
1974 array_push($thread_data_types, 'integer');
1975
1976 $counter = 1;
1977
1978 while($row = $ilDB->fetchAssoc($res))
1979 {
1980 if($counter < $res->numRows())
1981 {
1982 $query .= '%s, ';
1983 array_push($thread_data, $row['thread_id']);
1984 array_push($thread_data_types, 'integer');
1985 }
1986
1987 if($counter == $res->numRows())
1988 {
1989 $query .= '%s)';
1990 array_push($thread_data, $row['thread_id']);
1991 array_push($thread_data_types, 'integer');
1992
1993 }
1994 $counter++;
1995 }
1996
1997 $statement = $ilDB->manipulateF($query, $thread_data_types, $thread_data);
1998 }
1999
2000 /* Insert forum notification */
2001
2002 $nextId = $ilDB->nextId('frm_notification');
2003
2004 $statement = $ilDB->manipulateF('
2005 INSERT INTO frm_notification
2006 ( notification_id,
2007 user_id,
2008 frm_id
2009 )
2010 VALUES(%s, %s, %s)',
2011 array('integer','integer', 'integer'),
2012 array($nextId, $user_id, $this->id));
2013
2014 }
2015
2016 return true;
2017 }
isForumNotificationEnabled($user_id)
Check whether a user's notification about new posts in this forum is enabled (result > 0) or not (res...

References $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 2067 of file class.ilForum.php.

2068 {
2069 global $ilDB;
2070
2071 if (!$this->isThreadNotificationEnabled($user_id, $thread_id))
2072 {
2073 $nextId = $ilDB->nextId('frm_notification');
2074 $statement = $ilDB->manipulateF('
2075 INSERT INTO frm_notification
2076 ( notification_id,
2077 user_id,
2078 thread_id
2079 )
2080 VALUES (%s, %s, %s)',
2081 array('integer', 'integer', 'integer'), array($nextId, $user_id, $thread_id));
2082
2083 }
2084
2085 return true;
2086 }
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 1644 of file class.ilForum.php.

1645 {
1646 global $lng;
1647
1648 require_once('./Services/User/classes/class.ilObjUser.php');
1649
1650 if (ilObject::_exists($a_row->pos_display_user_id))
1651 {
1652 $tmp_user = new ilObjUser($a_row->pos_display_user_id);
1653 $fullname = $tmp_user->getFullname();
1654 $loginname = $tmp_user->getLogin();
1655 }
1656
1657 $fullname = $fullname ? $fullname : ($a_row->import_name ? $a_row->import_name : $lng->txt("unknown"));
1658
1659 $data = array(
1660 "pos_pk" => $a_row->pos_pk,
1661 "child" => $a_row->pos_pk,
1662 "author" => $a_row->pos_display_user_id,
1663 "alias" => $a_row->pos_usr_alias,
1664 "title" => $fullname,
1665 "loginname" => $loginname,
1666 "type" => "post",
1667 "message" => $a_row->pos_message,
1668 "subject" => $a_row->pos_subject,
1669 "pos_cens_com" => $a_row->pos_cens_com,
1670 "pos_cens" => $a_row->pos_cens,
1671 // "date" => $a_row->date,
1672 "date" => $a_row->fpt_date,
1673 "create_date" => $a_row->pos_date,
1674 "update" => $a_row->pos_update,
1675 "update_user" => $a_row->update_user,
1676 "tree" => $a_row->thr_fk,
1677 "parent" => $a_row->parent_pos,
1678 "lft" => $a_row->lft,
1679 "rgt" => $a_row->rgt,
1680 "depth" => $a_row->depth,
1681 "id" => $a_row->fpt_pk,
1682 "notify" => $a_row->notify,
1683 "import_name" => $a_row->import_name,
1684 "pos_status" => $a_row->pos_status
1685 );
1686
1687 // why this line? data should be stored without slashes in db
1688 //$data["message"] = stripslashes($data["message"]);
1689
1690 return $data ? $data : array();
1691 }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
$data

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 self::_isModerator($this->getForumRefId(), $author_id) ? $is_moderator = true : $is_moderator = false;
462 $objNewPost->setIsAuthorModerator($is_moderator);
463
464 if ($date == "")
465 {
466 $objNewPost->setCreateDate(date("Y-m-d H:i:s"));
467 }
468 else
469 {
470 if (strpos($date, "-") > 0) // in mysql format
471 {
472 $objNewPost->setCreateDate($date);
473 }
474 else // a timestamp
475 {
476 $objNewPost->setCreateDate(date("Y-m-d H:i:s", $date));
477 }
478 }
479 if($status == 1)
480 {
481 $objNewPost->setPostActivationDate($objNewPost->getCreateDate());
482 }
483
484 $objNewPost->setImportName($this->getImportName());
485 $objNewPost->setNotification($notify);
486 $objNewPost->setStatus($status);
487 $objNewPost->insert();
488
489 // entry in tree-table
490 if ($parent_pos == 0)
491 {
492 $this->addPostTree($objNewPost->getThreadId(), $objNewPost->getId(), $objNewPost->getCreateDate());
493 }
494 else
495 {
496 $this->insertPostNode($objNewPost->getId(), $parent_pos, $objNewPost->getThreadId(), $objNewPost->getCreateDate());
497 }
498
499 // string last post
500 $lastPost = $objNewPost->getForumId()."#".$objNewPost->getThreadId()."#".$objNewPost->getId();
501
502 // update thread
503 $result = $ilDB->manipulateF('
504 UPDATE frm_threads
505 SET thr_num_posts = thr_num_posts + 1,
506 thr_last_post = %s
507 WHERE thr_pk = %s',
508 array('text', 'integer'),
509 array($lastPost, $objNewPost->getThreadId()));
510
511 // update forum
512 $result = $ilDB->manipulateF('
513 UPDATE frm_data
514 SET top_num_posts = top_num_posts + 1,
515 top_last_post = %s
516 WHERE top_pk = %s',
517 array('text', 'integer'),
518 array($lastPost, $objNewPost->getForumId()));
519
520 // MARK READ
522 $forum_obj->markPostRead($objNewPost->getPosAuthorId(), $objNewPost->getThreadId(), $objNewPost->getId());
523
524 // Add Notification to news
525 if($status)
526 {
527 require_once 'Services/RTE/classes/class.ilRTE.php';
528 include_once("./Services/News/classes/class.ilNewsItem.php");
529 $news_item = new ilNewsItem();
530 $news_item->setContext($forum_obj->getId(), 'frm', $objNewPost->getId(), 'pos');
531 $news_item->setPriority(NEWS_NOTICE);
532 $news_item->setTitle($objNewPost->getSubject());
533 $news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($this->prepareText($objNewPost->getMessage(), 0), 1));
534 $news_item->setUserId($display_user_id);
535 $news_item->setVisibility(NEWS_USERS);
536 $news_item->create();
537 }
538
539 return $objNewPost->getId();
540 }
const NEWS_USERS
const NEWS_NOTICE
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
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(), getForumRefId(), getImportName(), 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 (   $forum_id,
  $author_id,
  $display_user_id,
  $subject,
  $message,
  $notify,
  $notify_posts,
  $alias = '',
  $date = '',
  $status = 1 
)

generate new dataset in frm_threads

Parameters
integer$topic
integer$author_id
integer$display_user_id
string$subject
string$message
integer$notify
integer$notify_posts
integer$anonymize
datetime$date
Returns
integer new post ID @access public

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

557 {
558 global $ilDB;
559
560 $objNewThread = new ilForumTopic();
561 $objNewThread->setForumId($forum_id);
562 $objNewThread->setDisplayUserId($display_user_id);
563 $objNewThread->setSubject($subject);
564 $objNewThread->setThrAuthorId($author_id);
565
566 if ($date == "")
567 {
568 $objNewThread->setCreateDate(date("Y-m-d H:i:s"));
569 }
570 else
571 {
572 if (strpos($date, "-") > 0) // in mysql format
573 {
574 $objNewThread->setCreateDate($date);
575 }
576 else // a timestamp
577 {
578 $objNewThread->setCreateDate(date("Y-m-d H:i:s", $date));
579 }
580 }
581 $objNewThread->setImportName($this->getImportName());
582 $objNewThread->setUserAlias($alias);
583 $objNewThread->insert();
584
585 if ($notify_posts == 1)
586 {
587 $objNewThread->enableNotification($author_id);
588 }
589
590 // update forum
591 $statement = $ilDB->manipulateF('
592 UPDATE frm_data
593 SET top_num_threads = top_num_threads + 1
594 WHERE top_pk = %s',
595 array('integer'), array($forum_id));
596
597 return $this->generatePost($forum_id, $objNewThread->getId(), $author_id, $display_user_id, $message, 0, $notify, $subject, $alias, $objNewThread->getCreateDate(), $status, 0);
598 }
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, generatePost(), and getImportName().

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

1327 {
1328 global $ilDB;
1329
1330 $res = $ilDB->queryf('
1331 SELECT * FROM frm_posts_tree
1332 WHERE thr_fk = %s
1333 AND parent_pos = %s',
1334 array('integer', 'integer'), array($a_thread_id, '0'));
1335
1336 $row = $ilDB->fetchObject($res);
1337
1338 return $row->pos_fk ? $row->pos_fk : 0;
1339 }

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

1600 {
1601 global $ilDB;
1602
1603 $res = $ilDB->queryf('
1604 SELECT * FROM frm_posts, frm_posts_tree
1605 WHERE pos_pk = pos_fk
1606 AND parent_pos = %s
1607 AND thr_fk = %s',
1608 array('integer', 'integer'),
1609 array('0', $tree_id));
1610
1611 $row = $ilDB->fetchObject($res);
1612
1613 return $this->fetchPostNodeData($row);
1614 }
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(), 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 1931 of file class.ilForum.php.

1932 {
1933 return $this->import_name;
1934 }

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

1894 {
1895 global $ilDB;
1896
1897 $res = $ilDB->queryf('
1898 SELECT frm_data.* FROM frm_data, frm_posts
1899 WHERE pos_pk = %s
1900 AND pos_top_fk = top_pk',
1901 array('integer'), array($pos_pk));
1902
1903 $row = $ilDB->fetchAssoc($res);
1904
1905 return $row;
1906
1907 }

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

1348 {
1349 global $rbacreview;
1350
1351 return $this->_getModerators($this->getForumRefId());
1352 }

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

1571 {
1572 global $ilDB;
1573
1574 if ($tree_id)
1575 {
1576 $sql_res = $ilDB->queryf('
1577 SELECT depth FROM frm_posts_tree
1578 WHERE pos_fk = %s
1579 AND thr_fk = %s',
1580 array('integer', 'integer'),
1581 array($a_node_id, $tree_id));
1582
1583 $res = $ilDB->fetchObject($sql_res);
1584
1585 return $res->depth;
1586 }
1587 else
1588 {
1589 return 0;
1590 }
1591 }

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

1623 {
1624 global $ilDB;
1625
1626 $res = $ilDB->queryf('
1627 SELECT * FROM frm_posts, frm_posts_tree
1628 WHERE pos_pk = pos_fk
1629 AND pos_pk = %s',
1630 array('integer'),
1631 array($post_id));
1632
1633 $row = $ilDB->fetchObject($res);
1634
1635 return $this->fetchPostNodeData($row);
1636 }

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

1249 {
1250 global $ilDB, $ilUser;
1251
1252 $statistic = array();
1253
1254 $data_types = array();
1255 $data = array();
1256
1257 $query = "SELECT COUNT(f.pos_display_user_id) ranking, u.login, p.value, u.lastname, u.firstname
1258 FROM frm_posts f
1259 INNER JOIN frm_posts_tree t
1260 ON f.pos_pk = t.pos_fk
1261 INNER JOIN frm_threads th
1262 ON t.thr_fk = th.thr_pk
1263 INNER JOIN usr_data u
1264 ON u.usr_id = f.pos_display_user_id
1265 INNER JOIN frm_data d
1266 ON d.top_pk = f.pos_top_fk
1267 LEFT JOIN usr_pref p
1268 ON p.usr_id = u.usr_id AND p.keyword = %s
1269 WHERE 1 = 1";
1270
1271 array_push($data_types, 'text');
1272 array_push($data, 'public_profile');
1273
1274 if (!$is_moderator)
1275 {
1276 $query .= ' AND (pos_status = %s
1277 OR (pos_status = %s
1278 AND pos_author_id = %s ))';
1279
1280 array_push($data_types,'integer', 'integer', 'integer');
1281 array_push($data, '1', '0', $ilUser->getId());
1282 }
1283
1284 $query .= ' AND d.top_frm_fk = %s
1285 GROUP BY pos_display_user_id, u.login, p.value,u.lastname, u.firstname';
1286
1287 array_push($data_types,'integer');
1288 array_push($data, $this->getForumId());
1289
1290
1291
1292 $res = $ilDB->queryf($query, $data_types, $data);
1293
1294 $counter = 0;
1295 while ($row = $ilDB->fetchAssoc($res))
1296 {
1297 $statistic[$counter][] = $row['ranking'];
1298 $statistic[$counter][] = $row['login'];
1299
1300 $lastname ='';
1301 $firstname = '';
1302 if(!$ilUser->isAnonymous() && in_array($row['value'], array('y', 'g')) ||
1303 $ilUser->isAnonymous() && 'g' == $row['value'])
1304 {
1305 $lastname = $row['lastname'];
1306 $firstname = $row['firstname'];
1307 }
1308
1309 $statistic[$counter][] = $lastname;
1310 $statistic[$counter][] = $firstname;
1311
1312 ++$counter;
1313 }
1314
1315 return is_array($statistic) ? $statistic : array();
1316 }

References $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 1496 of file class.ilForum.php.

1497 {
1498 global $ilDB;
1499
1500 $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1501
1502 // get left value
1503 $sql_res = $ilDB->queryf('
1504 SELECT * FROM frm_posts_tree
1505 WHERE pos_fk = %s
1506 AND thr_fk = %s',
1507 array('integer', 'integer'),
1508 array($a_parent_id, $tree_id));
1509
1510 $res = $ilDB->fetchObject($sql_res);
1511
1512 $left = $res->lft;
1513
1514 $lft = $left + 1;
1515 $rgt = $left + 2;
1516
1517 // spread tree
1518 $statement = $ilDB->manipulateF('
1519 UPDATE frm_posts_tree
1520 SET lft = CASE
1521 WHEN lft > %s
1522 THEN lft + 2
1523 ELSE lft
1524 END,
1525 rgt = CASE
1526 WHEN rgt > %s
1527 THEN rgt + 2
1528 ELSE rgt
1529 END
1530 WHERE thr_fk = %s',
1531 array('integer', 'integer', 'integer'),
1532 array($left, $left, $tree_id));
1533
1534 $depth = $this->getPostDepth($a_parent_id, $tree_id) + 1;
1535
1536 // insert node
1537 $nextId = $ilDB->nextId('frm_posts_tree');
1538 $statement = $ilDB->manipulateF('
1539 INSERT INTO frm_posts_tree
1540 ( fpt_pk,
1541 thr_fk,
1542 pos_fk,
1543 parent_pos,
1544 lft,
1545 rgt,
1546 depth,
1547 fpt_date
1548 )
1549 VALUES(%s,%s,%s, %s, %s, %s,%s, %s)',
1550 array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1551 array( $nextId,
1552 $tree_id,
1553 $a_node_id,
1554 $a_parent_id,
1555 $lft,
1556 $rgt,
1557 $depth,
1558 $a_date)
1559 );
1560
1561 }
getPostDepth($a_node_id, $tree_id)
Return depth of an object @access private.

References $ilDB, $res, 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 2045 of file class.ilForum.php.

2046 {
2047 global $ilDB;
2048
2049 $result = $ilDB->queryf('SELECT COUNT(*) cnt FROM frm_notification WHERE user_id = %s AND frm_id = %s',
2050 array('integer', 'integer'), array($user_id, $this->id));
2051
2052 while($record = $ilDB->fetchAssoc($result))
2053 {
2054 return (bool)$record['cnt'];
2055 }
2056
2057 return false;
2058 }

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

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

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

2216 {
2217 // selected source & target objects
2218 $source_thread_obj = new ilForumTopic((int)$source_id);
2219 $target_thread_obj = new ilForumTopic((int)$target_id);
2220
2221 if($source_thread_obj->getForumId() != $target_thread_obj->getForumId())
2222 {
2223 throw new ilException('not_allowed_to_merge_into_another_forum');
2224 }
2225 // use the "older" thread as target
2226 if($source_thread_obj->getCreateDate() > $target_thread_obj->getCreateDate())
2227 {
2228 $merge_thread_source = $source_thread_obj;
2229 $merge_thread_target = $target_thread_obj;
2230 }
2231 else
2232 {
2233 $merge_thread_source = $target_thread_obj;
2234 $merge_thread_target = $source_thread_obj;
2235 }
2236
2237 $thread_subject = $target_thread_obj->getSubject();
2238
2239 // remember if the threads are open or closed and then close both threads !
2240 $targed_was_closed = $merge_thread_target->isClosed();
2241
2242 $merge_thread_source->close();
2243
2244 if($targed_was_closed == false)
2245 {
2246 $merge_thread_target->close();
2247 }
2248
2249 $source_all_posts = $merge_thread_source->getAllPosts();
2250 $source_root_node = $merge_thread_source->getFirstPostNode();
2251 $target_root_node = $merge_thread_target->getFirstPostNode();
2252
2253 $add_difference = $target_root_node->getRgt();
2254
2255// update target root node rgt
2256 include_once 'Modules/Forum/classes/class.ilForumPostsTree.php';
2257// $new_target_rgt = ($target_root_node->getRgt() + $source_root_node->getRgt() + 1);
2258 $new_target_rgt = ($target_root_node->getRgt() + $source_root_node->getRgt());
2259 ilForumPostsTree::updateTargetRootRgt($target_root_node->getId(), $new_target_rgt);
2260
2261 $new_target_root = $target_root_node->getId();
2262
2263 // get source post tree and update posts tree
2264 foreach($source_all_posts as $post)
2265 {
2266 $post_obj = new ilForumPost($post->pos_pk);
2267
2268 $posts_tree_obj = new ilForumPostsTree();
2269 $posts_tree_obj->setPosFk($post->pos_pk);
2270
2271 if($post_obj->getParentId() == 0)
2272 {
2273 $posts_tree_obj->setParentPos($new_target_root);
2274
2275 //$posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference));
2276 $posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference) - 1);
2277 $posts_tree_obj->setLft($target_root_node->getRgt());
2278
2279 $posts_tree_obj->setDepth(($post_obj->getDepth() + 1));
2280 $posts_tree_obj->setSourceThreadId($merge_thread_source->getId());
2281
2282 $posts_tree_obj->setTargetThreadId($merge_thread_target->getId());
2283
2284 $posts_tree_obj->mergeParentPos();
2285 }
2286 else
2287 {
2288 $posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference) - 1);
2289 $posts_tree_obj->setLft(($post_obj->getLft() + $add_difference) - 1);
2290
2291 $posts_tree_obj->setDepth(($post_obj->getDepth() + 1));
2292 $posts_tree_obj->setSourceThreadId($merge_thread_source->getId());
2293
2294 $posts_tree_obj->setParentPos($post_obj->getParentId());
2295 $posts_tree_obj->setTargetThreadId($merge_thread_target->getId());
2296
2297 $posts_tree_obj->merge();
2298 }
2299 }
2300
2301// update frm_posts pos_thr_fk = target_thr_id
2302 include_once 'Modules/Forum/classes/class.ilForumPost.php';
2303 ilForumPost::mergePosts($merge_thread_source->getId(), $merge_thread_target->getId());
2304
2305// check notifications
2306 include_once 'Modules/Forum/classes/class.ilForumNotification.php';
2307 ilForumNotification::mergeThreadNotificiations($merge_thread_source->getId(), $merge_thread_target->getId());
2308
2309// delete frm_thread_access entries
2310 include_once './Modules/Forum/classes/class.ilObjForum.php';
2311 ilObjForum::_deleteAccessEntries($merge_thread_source->getId());
2312
2313// update frm_user_read
2314 ilObjForum::mergeForumUserRead($merge_thread_source->getId(), $merge_thread_target->getId());
2315
2316// update visits, thr_num_posts, last_post, subject
2317 $post_date_source = $merge_thread_source->getLastPost()->getCreateDate();
2318 $post_date_target = $merge_thread_target->getLastPost()->getCreateDate();
2319
2320 $target_last_post = $merge_thread_target->getLastPostString();
2321 $exp = explode('#', $target_last_post);
2322
2323 if($post_date_source > $post_date_target)
2324 {
2325 $exp[2] = $merge_thread_source->getLastPost()->getId();
2326 }
2327 else
2328 {
2329 $exp[2] = $merge_thread_target->getLastPost()->getId();
2330 }
2331 $new_thr_last_post = implode('#', $exp);
2332
2333 $num_posts_source = (int)$merge_thread_source->getNumPosts();
2334 $num_visits_source = (int)$merge_thread_source->getVisits();
2335 $num_posts_target = (int)$merge_thread_target->getNumPosts();
2336 $num_visits_target = (int)$merge_thread_source->getVisits();
2337
2338 $frm_topic_obj = new ilForumTopic(0, false, true);
2339 $frm_topic_obj->setNumPosts(($num_posts_source + $num_posts_target));
2340 $frm_topic_obj->setVisits(($num_visits_source + $num_visits_target));
2341 $frm_topic_obj->setLastPostString($new_thr_last_post);
2342 $frm_topic_obj->setSubject($thread_subject);
2343 $frm_topic_obj->setId($merge_thread_target->getId());
2344
2345 $frm_topic_obj->updateMergedThread();
2346
2347// update frm_data: top_last_post , top_num_threads
2349
2350// reopen target if was not "closed" before merging
2351 if(!$targed_was_closed)
2352 {
2353 $merge_thread_target->reopen();
2354 }
2355
2356// delete source thread
2357 ilForumTopic::deleteByThreadId($merge_thread_source->getId());
2358 }
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:88

References $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 608 of file class.ilForum.php.

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

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

References $_SESSION, $GLOBALS, $ilDB, $res, 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 1804 of file class.ilForum.php.

1805 {
1806 global $lng;
1807
1808 if($type == 'export')
1809 {
1810 $this->replQuote1 = "<blockquote class=\"quote\"><hr size=\"1\" color=\"#000000\">";
1811 $this->replQuote2 = "<hr size=\"1\" color=\"#000000\"/></blockquote>";
1812 }
1813
1814 if($edit == 1)
1815 {
1816 // add login name of quoted users
1817 $lname = ($quote_user != "")
1818 ? '="'.$quote_user.'"'
1819 : "";
1820
1821 $text = "[quote$lname]".$text."[/quote]";
1822 }
1823 else
1824 {
1825 // check for quotation
1826 $startZ = substr_count ($text, "[quote"); // also count [quote="..."]
1827 $endZ = substr_count ($text, "[/quote]");
1828
1829 if ($startZ > 0 || $endZ > 0)
1830 {
1831 // add missing opening and closing tags
1832 if ($startZ > $endZ)
1833 {
1834 $diff = $startZ - $endZ;
1835
1836 for ($i = 0; $i < $diff; $i++)
1837 {
1838 if ($type == 'export') $text .= $this->txtQuote2;
1839 else $text .= "[/quote]";
1840 }
1841 }
1842 elseif ($startZ < $endZ)
1843 {
1844 $diff = $endZ - $startZ;
1845
1846 for ($i = 0; $i < $diff; $i++)
1847 {
1848 if ($type == 'export') $text = $this->txtQuote1.$text;
1849 else $text = "[quote]".$text;
1850 }
1851 }
1852
1853 if($edit == 0)
1854 {
1855 $ws= "[ \t\r\f\v\n]*";
1856
1857 $text = eregi_replace("\[(quote$ws=$ws\"([^\"]*)\"$ws)\]",
1858 $this->replQuote1.'<div class="ilForumQuoteHead">'.$lng->txt("quote")." (\\2)".'</div>', $text);
1859
1860 $text = str_replace("[quote]",
1861 $this->replQuote1.'<div class="ilForumQuoteHead">'.$lng->txt("quote").'</div>', $text);
1862
1863 $text = str_replace("[/quote]", $this->replQuote2, $text);
1864 }
1865 }
1866 }
1867
1868 if($type != 'export')
1869 {
1870 if($edit == 0)
1871 {
1872 $text = ilUtil::insertLatexImages($text, "<span class\=\"latex\">", "<\/span>");
1873 $text = ilUtil::insertLatexImages($text, "\[tex\]", "\[\/tex\]");
1874 }
1875
1876 // workaround for preventing template engine
1877 // from hiding text that is enclosed
1878 // in curly brackets (e.g. "{a}")
1879 $text = str_replace("{", "&#123;", $text);
1880 $text = str_replace("}", "&#125;", $text);
1881 }
1882
1883 return $text;
1884 }
static insertLatexImages($a_text, $a_start="\[tex\]", $a_end="\[\/tex\]")
replace [text]...[/tex] tags with formula image code
$text

References $lng, $text, $txtQuote2, and ilUtil\insertLatexImages().

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

1936 {
1937 $this->import_name = $a_import_name;
1938 }

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

2171 {
2172 global $ilDB;
2173 // get latest post of forum and update last_post
2174 $ilDB->setLimit(1);
2175 $res2 = $ilDB->queryf('
2176 SELECT pos_top_fk, pos_thr_fk, pos_pk FROM frm_posts, frm_data
2177 WHERE pos_top_fk = top_pk
2178 AND top_frm_fk = %s
2179 ORDER BY pos_date DESC',
2180 array('integer'), array($a_obj_id));
2181
2182 if ($res2->numRows() == 0)
2183 {
2184 $lastPost_top = "";
2185 }
2186 else
2187 {
2188 $z = 0;
2189
2190 while ($selData = $ilDB->fetchAssoc($res2))
2191 {
2192 if ($z > 0)
2193 {
2194 break;
2195 }
2196
2197 $lastPost_top = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
2198 $z ++;
2199 }
2200 }
2201
2202 $ilDB->update('frm_data',
2203 array('top_last_post' => array('text', $lastPost_top)),
2204 array('top_frm_fk' => array('integer', $a_obj_id))
2205 );
2206
2207 }

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

1771 {
1772
1773 global $ilDB;
1774
1775 $checkTime = time() - (60*60);
1776
1777 if ($_SESSION["frm_visit_".$this->dbTable."_".$ID] < $checkTime)
1778 {
1779
1780 $_SESSION["frm_visit_".$this->dbTable."_".$ID] = time();
1781 $query = 'UPDATE '.$this->dbTable.' SET visits = visits + 1 WHERE ';
1782
1783 $data_type = array();
1784 $data_value = array();
1785
1786 if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
1787 {
1788 $query .= $this->getMDB2Query();
1789 $data_type = $data_type + $this->getMDB2DataType();
1790 $data_value = $data_value + $this->getMDB2DataValue();
1791
1792 $res = $ilDB->queryf($query, $data_type, $data_value);
1793 }
1794 }
1795 }

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: