ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 ()
 // 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)
 set number of max. More...
 
 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)
 
 __sendMessage ($a_parent_pos, $post_data=array())
 
 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...
 
 sendThreadNotifications ($post_data)
 
 sendForumNotifications ($post_data)
 
 sendPostActivationNotification ($post_data)
 
 formatNotificationSubject ($post_data)
 
 formatNotification ($post_data, $cron=0, $attachments=array(), $user_id)
 

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
 
 $ilias
 
 $lng
 

Private Member Functions

 setOrderField ($orderField)
 set database field for sorting results More...
 
 __formatMessage ($thread_data, $post_data=array(), $user_obj)
 generates the notificiation message, if a post has been answered More...
 
 formatPostActivationNotification ($post_data, $user_id)
 

Private Attributes

 $dbTable
 
 $className ="ilForum"
 
 $orderField
 
 $mdb2Query
 
 $mdb2DataValue
 
 $mdb2DataType
 
 $txtQuote1 = "[quote]"
 
 $txtQuote2 = "[/quote]"
 
 $replQuote1 = '<blockquote class="ilForumQuote">'
 
 $replQuote2 = '</blockquote>'
 
 $pageHits = 30
 
 $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 73 of file class.ilForum.php.

74 {
75 global $ilias,$lng;
76
77 $this->ilias = $ilias;
78 $this->lng = $lng;
79 }
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 1889 of file class.ilForum.php.

1890 {
1891 if(!is_array($a_ids))
1892 {
1893 return false;
1894 }
1895 include_once "./Modules/Forum/classes/class.ilFileDataForum.php";
1896
1897 $tmp_file_obj =& new ilFileDataForum($this->getForumId());
1898 foreach($a_ids as $pos_id)
1899 {
1900 $tmp_file_obj->setPosId($pos_id);
1901 $files = $tmp_file_obj->getFilesOfPost();
1902 foreach($files as $file)
1903 {
1904 $tmp_file_obj->unlinkFile($file["name"]);
1905 }
1906 }
1907 unset($tmp_file_obj);
1908 return true;
1909 }
print $file
This class handles all operations on files for the forum object.
getForumId()
//

References $file, and getForumId().

Referenced by deletePost().

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

◆ __formatMessage()

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

generates the notificiation message, if a post has been answered

Parameters
array$thread_data
array$post_data
object$user_objilObjUser
Returns
string

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

1952 {
1953 include_once "./Services/Object/classes/class.ilObjectFactory.php";
1954 $user_lang = self::_getLanguageInstanceByUsrId($user_obj->getId());
1955
1957 $title = $frm_obj->getTitle();
1958 unset($frm_obj);
1959
1960 $message = '';
1961 $message .= ilMail::getSalutation($user_obj->getId(), $user_lang);
1962
1963 $message .= "\n\n";
1964 $message .= $this->lng->txt("forum_post_replied");
1965 $message .= $this->lng->txt("forum").": ".$title." -> ".$thread_data["thr_subject"]."\n\n";
1966
1967 $message .= "\n------------------------------------------------------------\n";
1968 $message .= $post_data["pos_message"];
1969 $message .= "\n------------------------------------------------------------\n";
1970 $message .= sprintf($this->lng->txt("forums_notification_show_post"), "http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/goto.php?target=frm_".$post_data["ref_id"]."_".$post_data["pos_thr_fk"].'&client_id='.CLIENT_ID)."\n\n";
1971
1972 $message .= ilMail::_getInstallationSignature();
1973 return $message;
1974 }
static _getLanguageInstanceByUsrId($usr_id)
Get the ilLanguage instance for the passed user id.
getForumRefId()
get forum ref_id @access public
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
static _getInstallationSignature()
Static getter for the installation signature.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id

References ilMail\_getInstallationSignature(), _getLanguageInstanceByUsrId(), getForumRefId(), ilObjectFactory\getInstanceByRefId(), and ilMail\getSalutation().

+ Here is the call graph for this function:

◆ __sendMessage()

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

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

1913 {
1914 global $ilUser, $ilDB;
1915
1916 $parent_data = $this->getOnePost($a_parent_pos);
1917
1918 // only if the current user is not the owner of the parent post and the parent's notification flag is set...
1919 if($parent_data["notify"] && $parent_data["pos_author_id"] != $ilUser->getId())
1920 {
1921 // SEND MESSAGE
1922 include_once "Services/Mail/classes/class.ilMail.php";
1923 include_once './Services/User/classes/class.ilObjUser.php';
1924
1925 $tmp_user =& new ilObjUser($parent_data["pos_author_id"]);
1926
1927 // NONSENSE
1928 $this->setMDB2WhereCondition('thr_pk = %s ', array('integer'), array($parent_data["pos_thr_fk"]));
1929
1930 $thread_data = $this->getOneThread();
1931
1932 $tmp_mail_obj = new ilMail(ANONYMOUS_USER_ID);
1933 $message = $tmp_mail_obj->sendMail($tmp_user->getLogin(),"","",
1934 $this->formatNotificationSubject($post_data),
1935 $this->__formatMessage($thread_data, $post_data, $tmp_user),
1936 array(),array("system"));
1937
1938 unset($tmp_user);
1939 unset($tmp_mail_obj);
1940 }
1941 }
getOnePost($post)
get one post-dataset
getOneThread()
get one thread-dataset by WhereCondition
setMDB2WhereCondition($query_string, $data_type, $data_value)
set content for additional condition
Class Mail this class handles base functions for mail handling.
global $ilDB
global $ilUser
Definition: imgupload.php:15

References $ilDB, $ilUser, getOnePost(), getOneThread(), and setMDB2WhereCondition().

+ Here is the call 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 96 of file class.ilForum.php.

97 {
98 static $lngCache = array();
99
100 $languageShorthandle = ilObjUser::_lookupLanguage($usr_id);
101
102 // lookup in cache array
103 if(!isset($lngCache[$languageShorthandle]))
104 {
105 $lngCache[$languageShorthandle] = new ilLanguage($languageShorthandle);
106 $lngCache[$languageShorthandle]->loadLanguageModule('forum');
107 }
108
109 return $lngCache[$languageShorthandle];
110 }
language handling
static _lookupLanguage($a_usr_id)

References ilObjUser\_lookupLanguage().

Referenced by __formatMessage(), formatNotification(), formatPostActivationNotification(), and ilForumCronNotification\sendMails().

+ Here is the call graph for this function:
+ Here is the caller 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 1345 of file class.ilForum.php.

1346 {
1347 global $rbacreview;
1348
1349 $role_arr = $rbacreview->getRolesOfRoleFolder($a_ref_id);
1350
1351 foreach ($role_arr as $role_id)
1352 {
1353 //$roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1354 $title = ilObject::_lookupTitle($role_id);
1355 if ($title == "il_frm_moderator_".$a_ref_id)
1356 {
1357 #return $rbacreview->assignedUsers($roleObj->getId());
1358 return $title = $rbacreview->assignedUsers($role_id);
1359 }
1360 }
1361
1362 return array();
1363 }
static _lookupTitle($a_id)
lookup object title

References ilObject\_lookupTitle().

Referenced by _isModerator(), and getModerators().

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

2547 {
2548 global $ilDB;
2549
2550 switch($a_sort_mode)
2551 {
2552 case self::SORT_DATE:
2553 $sort = 'thr_date';
2554 break;
2555
2556 case self::SORT_TITLE:
2557 default:
2558 $sort = 'thr_subject';
2559 break;
2560 }
2561
2562 $res = $ilDB->queryf('
2563 SELECT * FROM frm_threads
2564 JOIN frm_data ON top_pk = thr_top_fk
2565 WHERE top_frm_fk = %s
2566 ORDER BY %s',
2567 array('integer', 'text'), array($a_obj_id, $sort));
2568
2569 while($row = $ilDB->fetchObject($res))
2570 {
2571 $threads[$row->thr_pk] = $row->thr_subject;
2572 }
2573 return $threads ? $threads : array();
2574 }
const SORT_DATE
const SORT_TITLE

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

1374 {
1375 return in_array($a_usr_id, ilForum::_getModerators($a_ref_id));
1376 }
_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 2576 of file class.ilForum.php.

2577 {
2578 global $ilDB;
2579
2580 $res = $ilDB->queryf('
2581 SELECT top_frm_fk FROM frm_data
2582 WHERE top_pk = %s',
2583 array('integer'), array($a_for_id));
2584
2585 if ($fdata = $ilDB->fetchAssoc($res))
2586 {
2587 return $fdata["top_frm_fk"];
2588 }
2589 return false;
2590 }

References $ilDB, and $res.

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

+ Here is the caller graph for this function:

◆ _lookupPostMessage()

ilForum::_lookupPostMessage (   $a_id)

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

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

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

1439 {
1440 global $ilDB;
1441
1442 $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1443
1444 if ($a_node_id <= 0)
1445 {
1446 $a_node_id = $a_tree_id;
1447 }
1448
1449 $nextId = $ilDB->nextId('frm_posts_tree');
1450
1451 $statement = $ilDB->manipulateF('
1452 INSERT INTO frm_posts_tree
1453 ( fpt_pk,
1454 thr_fk,
1455 pos_fk,
1456 parent_pos,
1457 lft,
1458 rgt,
1459 depth,
1460 fpt_date
1461 )
1462 VALUES(%s, %s, %s, %s, %s, %s, %s, %s )',
1463 array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1464 array($nextId, $a_tree_id, $a_node_id, '0', '1', '2', '1', $a_date));
1465
1466 return true;
1467 }

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

1427 {
1429 }
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 1400 of file class.ilForum.php.

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

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

1386 {
1387 global $ilDB;
1388
1389 $res = $ilDB->queryf('
1390 SELECT * FROM frm_data
1391 INNER JOIN frm_posts ON pos_top_fk = top_pk
1392 WHERE top_frm_fk = %s
1393 AND pos_author_id = %s',
1394 array('integer', 'integer'),
1395 array($this->getForumId(), $a_user_id));
1396
1397 return $res->numRows();
1398 }

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

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

References $ilDB, $mobs, __deletePostFiles(), ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), deletePostTree(), ilNewsItem\getFirstNewsIdForContext(), 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 1679 of file class.ilForum.php.

1680 {
1681 global $ilDB;
1682
1683 // GET LEFT AND RIGHT VALUES
1684 $res = $ilDB->queryf('
1685 SELECT * FROM frm_posts_tree
1686 WHERE thr_fk = %s
1687 AND pos_fk = %s
1688 AND parent_pos = %s',
1689 array('integer', 'integer', 'integer'),
1690 array($a_node['tree'], $a_node['pos_pk'], $a_node['parent']));
1691
1692 while($row = $ilDB->fetchObject($res))
1693 {
1694 $a_node["lft"] = $row->lft;
1695 $a_node["rgt"] = $row->rgt;
1696 }
1697
1698 $diff = $a_node["rgt"] - $a_node["lft"] + 1;
1699
1700 // get data of posts
1701 $result = $ilDB->queryf('
1702 SELECT * FROM frm_posts_tree
1703 WHERE lft BETWEEN %s AND %s
1704 AND thr_fk = %s',
1705 array('integer', 'integer', 'integer'),
1706 array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
1707
1708 $del_id = array();
1709
1710 while ($treeData = $ilDB->fetchAssoc($result))
1711 {
1712 $del_id[] = $treeData["pos_fk"];
1713 }
1714
1715 // delete subtree
1716 $statement = $ilDB->manipulateF('
1717 DELETE FROM frm_posts_tree
1718 WHERE lft BETWEEN %s AND %s
1719 AND thr_fk = %s',
1720 array('integer', 'integer', 'integer'),
1721 array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
1722
1723
1724 // close gaps
1725 $statement = $ilDB->manipulateF('
1726 UPDATE frm_posts_tree
1727 SET lft = CASE
1728 WHEN lft > %s
1729 THEN lft - %s
1730 ELSE lft
1731 END,
1732 rgt = CASE
1733 WHEN rgt > %s
1734 THEN rgt - %s
1735 ELSE rgt
1736 END
1737 WHERE thr_fk = %s',
1738 array('integer', 'integer', 'integer', 'integer', 'integer'),
1739 array($a_node['lft'], $diff, $a_node['lft'], $diff, $a_node['tree']));
1740
1741 return $del_id;
1742
1743 }
$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 2070 of file class.ilForum.php.

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

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

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

2113 {
2114 global $ilDB;
2115
2116 if (!$this->isThreadNotificationEnabled($user_id, $thread_id))
2117 {
2118 $nextId = $ilDB->nextId('frm_notification');
2119 $statement = $ilDB->manipulateF('
2120 INSERT INTO frm_notification
2121 ( notification_id,
2122 user_id,
2123 thread_id
2124 )
2125 VALUES (%s, %s, %s)',
2126 array('integer', 'integer', 'integer'), array($nextId, $user_id, $thread_id));
2127
2128 }
2129
2130 return true;
2131 }
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 1624 of file class.ilForum.php.

1625 {
1626 global $lng;
1627
1628 require_once('./Services/User/classes/class.ilObjUser.php');
1629
1630 if (ilObject::_exists($a_row->pos_display_user_id))
1631 {
1632 $tmp_user = new ilObjUser($a_row->pos_display_user_id);
1633 $fullname = $tmp_user->getFullname();
1634 $loginname = $tmp_user->getLogin();
1635 }
1636
1637 $fullname = $fullname ? $fullname : ($a_row->import_name ? $a_row->import_name : $lng->txt("unknown"));
1638
1639 $data = array(
1640 "pos_pk" => $a_row->pos_pk,
1641 "child" => $a_row->pos_pk,
1642 "author" => $a_row->pos_display_user_id,
1643 "alias" => $a_row->pos_usr_alias,
1644 "title" => $fullname,
1645 "loginname" => $loginname,
1646 "type" => "post",
1647 "message" => $a_row->pos_message,
1648 "subject" => $a_row->pos_subject,
1649 "pos_cens_com" => $a_row->pos_cens_com,
1650 "pos_cens" => $a_row->pos_cens,
1651 // "date" => $a_row->date,
1652 "date" => $a_row->fpt_date,
1653 "create_date" => $a_row->pos_date,
1654 "update" => $a_row->pos_update,
1655 "update_user" => $a_row->update_user,
1656 "tree" => $a_row->thr_fk,
1657 "parent" => $a_row->parent_pos,
1658 "lft" => $a_row->lft,
1659 "rgt" => $a_row->rgt,
1660 "depth" => $a_row->depth,
1661 "id" => $a_row->fpt_pk,
1662 "notify" => $a_row->notify,
1663 "import_name" => $a_row->import_name,
1664 "pos_status" => $a_row->pos_status
1665 );
1666
1667 // why this line? data should be stored without slashes in db
1668 //$data["message"] = stripslashes($data["message"]);
1669
1670 return $data ? $data : array();
1671 }
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:

◆ formatNotification()

ilForum::formatNotification (   $post_data,
  $cron = 0,
  $attachments = array(),
  $user_id 
)
Parameters
$post_data
int$cron
array$attachments
int$user_iduser_id of mail-recipient
Returns
string

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

2467 {
2468 global $ilIliasIniFile;
2469
2470 $user_lang = self::_getLanguageInstanceByUsrId($user_id);
2471
2472 $message = "";
2473
2474 $message .= ilMail::getSalutation($user_id, $user_lang);
2475 $message .= "\n\n";
2476 $message .= $this->lng->txt("forums_notification_subject")." ".$post_data['top_name']."\n\n";
2477
2478 $message .= $this->lng->txt("forum").": ".$post_data["top_name"]."\n\n";
2479 $message .= $this->lng->txt("thread").": ".$post_data["thr_subject"]."\n\n";
2480 $message .= $this->lng->txt("new_post").":\n------------------------------------------------------------\n";
2481 $message .= $this->lng->txt("author").": ".$post_data["pos_usr_name"]."\n";
2482 $message .= $this->lng->txt("date").": ".$post_data["pos_date"]."\n";
2483 $message .= $this->lng->txt("subject").": ".$post_data["pos_subject"]."\n\n";
2484
2485 if ($post_data["pos_cens"] == 1)
2486 {
2487 $message .= $post_data["pos_cens_com"]."\n";
2488 }
2489 else
2490 {
2491 $pos_message = $post_data['pos_message'];
2492 if(strip_tags($pos_message) != $pos_message)
2493 {
2494 $pos_message = preg_replace("/\n/i", "", $pos_message);
2495 $pos_message = preg_replace("/<br(\s*)(\/?)>/i", "\n", $pos_message);
2496 $pos_message = preg_replace("/<p([^>]*)>/i", "\n\n", $pos_message);
2497 $pos_message = preg_replace("/<\/p([^>]*)>/i", '', $pos_message);
2498 }
2499 $message .= strip_tags($pos_message)."\n";
2500 }
2501 $message .= "------------------------------------------------------------\n";
2502
2503 if(count($attachments) > 0)
2504 {
2505 foreach($attachments as $attachment)
2506 {
2507 $message .= $this->lng->txt('attachment').": ".$attachment."\n";
2508 }
2509 $message .= "\n------------------------------------------------------------\n";
2510 }
2511
2512 if ($cron == 1)
2513 {
2514 $message .= sprintf($this->lng->txt("forums_notification_show_post"), $ilIliasIniFile->readVariable("server","http_path")."/goto.php?target=frm_".$post_data["ref_id"]."_".$post_data["pos_thr_fk"]."_".$post_data["pos_pk"].'&client_id='.CLIENT_ID)."\n\n";
2515 }
2516 else
2517 {
2518 $message .= sprintf($this->lng->txt("forums_notification_show_post"), ILIAS_HTTP_PATH."/goto.php?target=frm_".$post_data["ref_id"]."_".$post_data["pos_thr_fk"]."_".$post_data["pos_pk"].'&client_id='.CLIENT_ID)."\n\n";
2519 }
2520
2521 if ($cron == 1)
2522 {
2523 $message .= sprintf($this->lng->txt("forums_notification_intro"),
2524 $this->ilias->ini->readVariable("client","name"),
2525 $ilIliasIniFile->readVariable("server","http_path").'/?client_id='.CLIENT_ID)."\n\n";
2526 }
2527 else
2528 {
2529 $message .= sprintf($this->lng->txt("forums_notification_intro"),
2530 $this->ilias->ini->readVariable("client","name"),
2531 ILIAS_HTTP_PATH.'/?client_id='.CLIENT_ID)."\n\n";
2532 }
2533
2534 return $message;
2535 }
global $ilIliasIniFile

References $ilIliasIniFile, _getLanguageInstanceByUsrId(), and ilMail\getSalutation().

Referenced by sendForumNotifications(), and sendThreadNotifications().

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

◆ formatNotificationSubject()

ilForum::formatNotificationSubject (   $post_data)
Parameters
array$post_datause $post_data['top_name'] for forum-title
Returns
string

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

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

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

+ Here is the caller graph for this function:

◆ formatPostActivationNotification()

ilForum::formatPostActivationNotification (   $post_data,
  $user_id 
)
private
Parameters
$post_data
$user_id
Returns
string

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

2352 {
2353 $user_lang = self::_getLanguageInstanceByUsrId($user_id);
2354
2355 $message = "";
2356 $message .= ilMail::getSalutation($user_id, $user_lang);
2357 $message .= "\n\n";
2358 $message .= $this->lng->txt('forums_post_activation_mail')."\n\n";
2359
2360 $message .= $this->lng->txt("forum").": ".$post_data["top_name"]."\n\n";
2361 $message .= $this->lng->txt("thread").": ".$post_data["thr_subject"]."\n\n";
2362 $message .= $this->lng->txt("new_post").":\n------------------------------------------------------------\n";
2363 $message .= $this->lng->txt("author").": ".$post_data["pos_usr_name"]."\n";
2364 $message .= $this->lng->txt("date").": ".$post_data["pos_date"]."\n";
2365 $message .= $this->lng->txt("subject").": ".$post_data["pos_subject"]."\n\n";
2366 if ($post_data["pos_cens"] == 1)
2367 {
2368 $message .= $post_data["pos_cens_com"]."\n";
2369 }
2370 else
2371 {
2372 $pos_message = $post_data['pos_message'];
2373 if(strip_tags($pos_message) != $pos_message)
2374 {
2375 $pos_message = preg_replace("/\n/i", "", $pos_message);
2376 $pos_message = preg_replace("/<br(\s*)(\/?)>/i", "\n", $pos_message);
2377 $pos_message = preg_replace("/<p([^>]*)>/i", "\n\n", $pos_message);
2378 $pos_message = preg_replace("/<\/p([^>]*)>/i", '', $pos_message);
2379 }
2380 $message .= strip_tags($pos_message)."\n";
2381 }
2382 $message .= "------------------------------------------------------------\n";
2383
2384 $message .= sprintf($this->lng->txt('forums_notification_show_post'), ILIAS_HTTP_PATH."/goto.php?target=frm_".$post_data["ref_id"]."_".$post_data["pos_thr_fk"]."_".$post_data["pos_pk"].'&client_id='.CLIENT_ID)."\n\n";
2385 $message .= sprintf($this->lng->txt('forums_notification_intro'),
2386 $this->ilias->ini->readVariable('client', 'name'),
2387 ILIAS_HTTP_PATH.'/?client_id='.CLIENT_ID)."\n\n";
2388
2389 return $message;
2390 }

References _getLanguageInstanceByUsrId(), and ilMail\getSalutation().

Referenced by sendPostActivationNotification().

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

447 {
448 global $ilDB;
449
450 $objNewPost = new ilForumPost();
451 $objNewPost->setForumId($forum_id);
452 $objNewPost->setThreadId($thread_id);
453 $objNewPost->setSubject($subject);
454 $objNewPost->setMessage($message);
455 $objNewPost->setDisplayUserId($display_user_id);
456 $objNewPost->setUserAlias($alias);
457 $objNewPost->setPosAuthorId($author_id);
458
459 $this->_isModerator($this->getForumRefId(), $author_id) ? $is_moderator = true : $is_moderator = false;
460 $objNewPost->setIsAuthorModerator($is_moderator);
461
462 if ($date == "")
463 {
464 $objNewPost->setCreateDate(date("Y-m-d H:i:s"));
465 }
466 else
467 {
468 if (strpos($date, "-") > 0) // in mysql format
469 {
470 $objNewPost->setCreateDate($date);
471 }
472 else // a timestamp
473 {
474 $objNewPost->setCreateDate(date("Y-m-d H:i:s", $date));
475 }
476 }
477
478 $objNewPost->setImportName($this->getImportName());
479 $objNewPost->setNotification($notify);
480 $objNewPost->setStatus($status);
481 $objNewPost->insert();
482
483 // entry in tree-table
484 if ($parent_pos == 0)
485 {
486 $this->addPostTree($objNewPost->getThreadId(), $objNewPost->getId(), $objNewPost->getCreateDate());
487 }
488 else
489 {
490 $this->insertPostNode($objNewPost->getId(), $parent_pos, $objNewPost->getThreadId(), $objNewPost->getCreateDate());
491 }
492//echo "<br>->".$objNewPost->getId()."-".$parent_pos."-".$objNewPost->getThreadId()."-".
493// $objNewPost->getCreateDate()."-".$forum_id."-".$message."-".$user."-";
494 // string last post
495 $lastPost = $objNewPost->getForumId()."#".$objNewPost->getThreadId()."#".$objNewPost->getId();
496
497 // update thread
498 $result = $ilDB->manipulateF('
499 UPDATE frm_threads
500 SET thr_num_posts = thr_num_posts + 1,
501 thr_last_post = %s
502 WHERE thr_pk = %s',
503 array('text', 'integer'),
504 array($lastPost, $objNewPost->getThreadId()));
505
506 // update forum
507 $result = $ilDB->manipulateF('
508 UPDATE frm_data
509 SET top_num_posts = top_num_posts + 1,
510 top_last_post = %s
511 WHERE top_pk = %s',
512 array('text', 'integer'),
513 array($lastPost, $objNewPost->getForumId()));
514
515 // MARK READ
517 $forum_obj->markPostRead($objNewPost->getPosAuthorId(), $objNewPost->getThreadId(), $objNewPost->getId());
518
519 $pos_data = $objNewPost->getDataAsArray();
520 $pos_data["ref_id"] = $this->getForumRefId();
521
522 // Send notification to moderators if they have to enable a post
523
524 if (!$status && $send_activation_mail)
525 {
526 $pos_data["top_name"] = $forum_obj->getTitle();
527 $this->sendPostActivationNotification($pos_data);
528 }
529
530 // Add Notification to news
531 if ($status)
532 {
533 require_once 'Services/RTE/classes/class.ilRTE.php';
534 include_once("./Services/News/classes/class.ilNewsItem.php");
535 $news_item = new ilNewsItem();
536 $news_item->setContext($forum_obj->getId(), 'frm', $objNewPost->getId(), 'pos');
537 $news_item->setPriority(NEWS_NOTICE);
538 $news_item->setTitle($objNewPost->getSubject());
539 $news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($this->prepareText($objNewPost->getMessage(), 0), 1));
540 $news_item->setUserId($display_user_id);
541 $news_item->setVisibility(NEWS_USERS);
542 $news_item->create();
543 }
544
545 return $objNewPost->getId();
546 }
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
sendPostActivationNotification($post_data)
insertPostNode($a_node_id, $a_parent_id, $tree_id, $a_date='')
insert node under parent node @access public
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, prepareText(), and sendPostActivationNotification().

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

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

220 {
221 return $this->dbTable;
222 }

References $dbTable.

◆ getFirstPostByThread()

ilForum::getFirstPostByThread (   $a_thread_id)

Get first post of thread.

@access public

Parameters
intthread id
Returns

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

1311 {
1312 global $ilDB;
1313
1314 $res = $ilDB->queryf('
1315 SELECT * FROM frm_posts_tree
1316 WHERE thr_fk = %s
1317 AND parent_pos = %s',
1318 array('integer', 'integer'), array($a_thread_id, '0'));
1319
1320 $row = $ilDB->fetchObject($res);
1321
1322 return $row->pos_fk ? $row->pos_fk : 0;
1323 }

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

1580 {
1581 global $ilDB;
1582
1583 $res = $ilDB->queryf('
1584 SELECT * FROM frm_posts, frm_posts_tree
1585 WHERE pos_pk = pos_fk
1586 AND parent_pos = %s
1587 AND thr_fk = %s',
1588 array('integer', 'integer'),
1589 array('0', $tree_id));
1590
1591 $row = $ilDB->fetchObject($res);
1592
1593 return $this->fetchPostNodeData($row);
1594 }
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 ( )

//

Todo:
this should be renamed to getObjId() get forum id @access public
Returns
integer object id of forum

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

152 {
153 return $this->id;
154 }

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

162 {
163 return $this->ref_id;
164 }
$ref_id
Definition: sahs_server.php:39

References $ref_id.

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

+ Here is the caller graph for this function:

◆ getImportName()

ilForum::getImportName ( )

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

1977 {
1978 return $this->import_name;
1979 }

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

277 {
278 if($this->mdb2DataType != '')
279 {
280 return $this->mdb2DataType;
281 }
282 }

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

264 {
265 if($this->mdb2DataValue != '')
266 {
268 }
269 }

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

250 {
251 if($this->mdb2Query != '')
252 {
253 return $this->mdb2Query;
254 }
255
256 }

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

1874 {
1875 global $ilDB;
1876
1877 $res = $ilDB->queryf('
1878 SELECT frm_data.* FROM frm_data, frm_posts
1879 WHERE pos_pk = %s
1880 AND pos_top_fk = top_pk',
1881 array('integer'), array($pos_pk));
1882
1883 $row = $ilDB->fetchAssoc($res);
1884
1885 return $row;
1886
1887 }

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

1332 {
1333 global $rbacreview;
1334
1335 return $this->_getModerators($this->getForumRefId());
1336 }

References _getModerators(), and getForumRefId().

Referenced by sendPostActivationNotification().

+ Here is the call graph for this function:
+ Here is the caller 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 397 of file class.ilForum.php.

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

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

Referenced by __sendMessage().

+ Here is the call graph for this function:
+ Here is the caller 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 368 of file class.ilForum.php.

369 {
370 global $ilDB;
371
372 $data_type = array();
373 $data_value = array();
374
375 $query = 'SELECT * FROM frm_threads WHERE ';
376
377 if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
378 {
379 $query .= $this->getMDB2Query();
380 $data_type = $data_type + $this->getMDB2DataType();
381 $data_value = $data_value + $this->getMDB2DataValue();
382
383 $sql_res = $ilDB->queryf($query, $data_type, $data_value);
384 $result = $ilDB->fetchAssoc($sql_res);
385 $result["thr_subject"] = trim($result["thr_subject"]);
386 }
387
388 return $result;
389 }
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().

Referenced by __sendMessage().

+ Here is the call graph for this function:
+ Here is the caller 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 321 of file class.ilForum.php.

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

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

191 {
192 return $this->orderField;
193 }

References $orderField.

◆ getPageHits()

ilForum::getPageHits ( )

get number of max.

visible datasets

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

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

310 {
311 return $this->pageHits;
312 }

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

1551 {
1552 global $ilDB;
1553
1554 if ($tree_id)
1555 {
1556 $sql_res = $ilDB->queryf('
1557 SELECT depth FROM frm_posts_tree
1558 WHERE pos_fk = %s
1559 AND thr_fk = %s',
1560 array('integer', 'integer'),
1561 array($a_node_id, $tree_id));
1562
1563 $res = $ilDB->fetchObject($sql_res);
1564
1565 return $res->depth;
1566 }
1567 else
1568 {
1569 return 0;
1570 }
1571 }

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

1603 {
1604 global $ilDB;
1605
1606 $res = $ilDB->queryf('
1607 SELECT * FROM frm_posts, frm_posts_tree
1608 WHERE pos_pk = pos_fk
1609 AND pos_pk = %s',
1610 array('integer'),
1611 array($post_id));
1612
1613 $row = $ilDB->fetchObject($res);
1614
1615 return $this->fetchPostNodeData($row);
1616 }

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

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

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

1477 {
1478 global $ilDB;
1479
1480 $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1481
1482 // get left value
1483 $sql_res = $ilDB->queryf('
1484 SELECT * FROM frm_posts_tree
1485 WHERE pos_fk = %s
1486 AND thr_fk = %s',
1487 array('integer', 'integer'),
1488 array($a_parent_id, $tree_id));
1489
1490 $res = $ilDB->fetchObject($sql_res);
1491
1492 $left = $res->lft;
1493
1494 $lft = $left + 1;
1495 $rgt = $left + 2;
1496
1497 // spread tree
1498 $statement = $ilDB->manipulateF('
1499 UPDATE frm_posts_tree
1500 SET lft = CASE
1501 WHEN lft > %s
1502 THEN lft + 2
1503 ELSE lft
1504 END,
1505 rgt = CASE
1506 WHEN rgt > %s
1507 THEN rgt + 2
1508 ELSE rgt
1509 END
1510 WHERE thr_fk = %s',
1511 array('integer', 'integer', 'integer'),
1512 array($left, $left, $tree_id));
1513
1514 $depth = $this->getPostDepth($a_parent_id, $tree_id) + 1;
1515
1516 // insert node
1517 $nextId = $ilDB->nextId('frm_posts_tree');
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,
1532 $tree_id,
1533 $a_node_id,
1534 $a_parent_id,
1535 $lft,
1536 $rgt,
1537 $depth,
1538 $a_date)
1539 );
1540
1541 }
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 2090 of file class.ilForum.php.

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

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

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

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

2638 {
2639 // selected source & target objects
2640 $source_thread_obj = new ilForumTopic((int)$source_id);
2641 $target_thread_obj = new ilForumTopic((int)$target_id);
2642
2643 if($source_thread_obj->getForumId() != $target_thread_obj->getForumId())
2644 {
2645 throw new ilException('not_allowed_to_merge_into_another_forum');
2646 }
2647 // use the "older" thread as target
2648 if($source_thread_obj->getCreateDate() > $target_thread_obj->getCreateDate())
2649 {
2650 $merge_thread_source = $source_thread_obj;
2651 $merge_thread_target = $target_thread_obj;
2652 }
2653 else
2654 {
2655 $merge_thread_source = $target_thread_obj;
2656 $merge_thread_target = $source_thread_obj;
2657 }
2658
2659 $thread_subject = $target_thread_obj->getSubject();
2660
2661 // remember if the threads are open or closed and then close both threads !
2662 $targed_was_closed = $merge_thread_target->isClosed();
2663
2664 $merge_thread_source->close();
2665
2666 if($targed_was_closed == false)
2667 {
2668 $merge_thread_target->close();
2669 }
2670
2671 $source_all_posts = $merge_thread_source->getAllPosts();
2672 $source_root_node = $merge_thread_source->getFirstPostNode();
2673 $target_root_node = $merge_thread_target->getFirstPostNode();
2674
2675 $add_difference = $target_root_node->getRgt();
2676
2677// update target root node rgt
2678 include_once 'Modules/Forum/classes/class.ilForumPostsTree.php';
2679// $new_target_rgt = ($target_root_node->getRgt() + $source_root_node->getRgt() + 1);
2680 $new_target_rgt = ($target_root_node->getRgt() + $source_root_node->getRgt());
2681 ilForumPostsTree::updateTargetRootRgt($target_root_node->getId(), $new_target_rgt);
2682
2683 $new_target_root = $target_root_node->getId();
2684
2685 // get source post tree and update posts tree
2686 foreach($source_all_posts as $post)
2687 {
2688 $post_obj = new ilForumPost($post->pos_pk);
2689
2690 $posts_tree_obj = new ilForumPostsTree();
2691 $posts_tree_obj->setPosFk($post->pos_pk);
2692
2693 if($post_obj->getParentId() == 0)
2694 {
2695 $posts_tree_obj->setParentPos($new_target_root);
2696
2697 //$posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference));
2698 $posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference) - 1);
2699 $posts_tree_obj->setLft($target_root_node->getRgt());
2700
2701 $posts_tree_obj->setDepth(($post_obj->getDepth() + 1));
2702 $posts_tree_obj->setSourceThreadId($merge_thread_source->getId());
2703
2704 $posts_tree_obj->setTargetThreadId($merge_thread_target->getId());
2705
2706 $posts_tree_obj->mergeParentPos();
2707 }
2708 else
2709 {
2710 $posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference) - 1);
2711 $posts_tree_obj->setLft(($post_obj->getLft() + $add_difference) - 1);
2712
2713 $posts_tree_obj->setDepth(($post_obj->getDepth() + 1));
2714 $posts_tree_obj->setSourceThreadId($merge_thread_source->getId());
2715
2716 $posts_tree_obj->setParentPos($post_obj->getParentId());
2717 $posts_tree_obj->setTargetThreadId($merge_thread_target->getId());
2718
2719 $posts_tree_obj->merge();
2720 }
2721 }
2722
2723// update frm_posts pos_thr_fk = target_thr_id
2724 include_once 'Modules/Forum/classes/class.ilForumPost.php';
2725 ilForumPost::mergePosts($merge_thread_source->getId(), $merge_thread_target->getId());
2726
2727// check notifications
2728 include_once 'Modules/Forum/classes/class.ilForumNotification.php';
2729 ilForumNotification::mergeThreadNotificiations($merge_thread_source->getId(), $merge_thread_target->getId());
2730
2731// delete frm_thread_access entries
2732 include_once './Modules/Forum/classes/class.ilObjForum.php';
2733 ilObjForum::_deleteAccessEntries($merge_thread_source->getId());
2734
2735// update frm_user_read
2736 ilObjForum::mergeForumUserRead($merge_thread_source->getId(), $merge_thread_target->getId());
2737
2738// update visits, thr_num_posts, last_post, subject
2739 $post_date_source = $merge_thread_source->getLastPost()->getCreateDate();
2740 $post_date_target = $merge_thread_target->getLastPost()->getCreateDate();
2741
2742 $target_last_post = $merge_thread_target->getLastPostString();
2743 $exp = explode('#', $target_last_post);
2744
2745 if($post_date_source > $post_date_target)
2746 {
2747 $exp[2] = $merge_thread_source->getLastPost()->getId();
2748 }
2749 else
2750 {
2751 $exp[2] = $merge_thread_target->getLastPost()->getId();
2752 }
2753 $new_thr_last_post = implode('#', $exp);
2754
2755 $num_posts_source = (int)$merge_thread_source->getNumPosts();
2756 $num_visits_source = (int)$merge_thread_source->getVisits();
2757 $num_posts_target = (int)$merge_thread_target->getNumPosts();
2758 $num_visits_target = (int)$merge_thread_source->getVisits();
2759
2760 $frm_topic_obj = new ilForumTopic(0, false, true);
2761 $frm_topic_obj->setNumPosts(($num_posts_source + $num_posts_target));
2762 $frm_topic_obj->setVisits(($num_visits_source + $num_visits_target));
2763 $frm_topic_obj->setLastPostString($new_thr_last_post);
2764 $frm_topic_obj->setSubject($thread_subject);
2765 $frm_topic_obj->setId($merge_thread_target->getId());
2766
2767 $frm_topic_obj->updateMergedThread();
2768
2769// update frm_data: top_last_post , top_num_threads
2771
2772// reopen target if was not "closed" before merging
2773 if(!$targed_was_closed)
2774 {
2775 $merge_thread_target->reopen();
2776 }
2777
2778// delete source thread
2779 ilForumTopic::deleteByThreadId($merge_thread_source->getId());
2780 }
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 614 of file class.ilForum.php.

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

738 {
739 global $ilDB;
740
741 $statement = $ilDB->manipulateF('
742 UPDATE frm_posts
743 SET pos_cens_com = %s,
744 pos_update = %s,
745 pos_cens = %s,
746 update_user = %s
747 WHERE pos_pk = %s',
748 array('text', 'timestamp', 'integer', 'integer', 'integer'),
749 array($message, date("Y-m-d H:i:s"), $cens, $_SESSION['AccountId'], $pos_pk));
750
751 // Change news item accordingly
752 include_once("./Services/News/classes/class.ilNewsItem.php");
753 $news_id = ilNewsItem::getFirstNewsIdForContext($this->id,
754 "frm", $pos_pk, "pos");
755 if ($news_id > 0)
756 {
757 if ($cens > 0) // censor
758 {
759 $news_item = new ilNewsItem($news_id);
760 //$news_item->setTitle($subject);
761 $news_item->setContent(nl2br($this->prepareText($message, 0)));
762 $news_item->update();
763 }
764 else // revoke censorship
765 {
766 // get original message
767 $res = $ilDB->queryf('
768 SELECT * FROM frm_posts
769 WHERE pos_pk = %s',
770 array('integer'), array($pos_pk));
771
772 $rec = $ilDB->fetchAssoc($res);
773
774 $news_item = new ilNewsItem($news_id);
775 //$news_item->setTitle($subject);
776 $news_item->setContent(nl2br($this->prepareText($rec["pos_message"], 0)));
777 $news_item->update();
778 }
779 }
780
781 return true;
782 }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']

References $_SESSION, $ilDB, $res, ilNewsItem\getFirstNewsIdForContext(), 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 1784 of file class.ilForum.php.

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

References $lng, $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:

◆ sendForumNotifications()

ilForum::sendForumNotifications (   $post_data)

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

2253 {
2254 global $ilDB, $ilAccess, $lng, $ilUser;
2255
2256 include_once "Services/Mail/classes/class.ilMail.php";
2257 include_once './Services/User/classes/class.ilObjUser.php';
2258
2259 // GET THREAD DATA
2260 $result = $ilDB->queryf('
2261 SELECT thr_subject FROM frm_threads
2262 WHERE thr_pk = %s',
2263 array('integer'),
2264 array($post_data['pos_thr_fk']));
2265
2266 while($record = $ilDB->fetchAssoc($result))
2267 {
2268 $post_data['thr_subject'] = $record['thr_subject'];
2269 break;
2270 }
2271
2272 // determine obj_id of the forum
2273 $obj_id = self::_lookupObjIdForForumId($post_data['pos_top_fk']);
2274
2275 // GET AUTHOR OF NEW POST
2276 if($post_data['pos_display_user_id'])
2277 {
2278 $post_data['pos_usr_name'] = ilObjUser::_lookupLogin($post_data['pos_display_user_id']);
2279 }
2280 else if(strlen($post_data['pos_usr_alias']))
2281 {
2282 $post_data['pos_usr_name'] = $post_data['pos_usr_alias'].' ('.$lng->txt('frm_pseudonym').')';
2283 }
2284
2285 if($post_data['pos_usr_name'] == '')
2286 {
2287 $post_data['pos_usr_name'] = $this->lng->txt('forums_anonymous');
2288 }
2289
2290 // GET USERS WHO WANT TO BE INFORMED ABOUT NEW POSTS
2291 $res = $ilDB->queryf('
2292 SELECT frm_notification.user_id FROM frm_notification, frm_data
2293 WHERE frm_data.top_pk = %s
2294 AND frm_notification.frm_id = frm_data.top_frm_fk
2295 AND frm_notification.user_id <> %s
2296 GROUP BY frm_notification.user_id',
2297 array('integer', 'integer'),
2298 array($post_data['pos_top_fk'], $ilUser->getId()));
2299
2300 // get all references of obj_id
2301 $frm_references = ilObject::_getAllReferences($obj_id);
2302
2303 // save language of the current user
2304 global $lng;
2305 $userLanguage = $lng;
2306
2307 // get attachments data
2308 $fileDataForum = new ilFileDataForum($obj_id, $post_data['pos_pk']);
2309 $filesOfPost = $fileDataForum->getFilesOfPost();
2310 $attachments = array();
2311 foreach($filesOfPost as $attachment)
2312 {
2313 $attachments[] = $attachment['name'];
2314 }
2315
2316 $mail_obj = new ilMail(ANONYMOUS_USER_ID);
2317 while($row = $ilDB->fetchAssoc($res))
2318 {
2319 // do rbac check before sending notification
2320 $send_mail = false;
2321 foreach((array)$frm_references as $ref_id)
2322 {
2323 if($ilAccess->checkAccessOfUser($row['user_id'], 'read', '', $ref_id))
2324 {
2325 $send_mail = true;
2326 break;
2327 }
2328 }
2329
2330 if($send_mail)
2331 {
2332 $this->setLanguage(self::_getLanguageInstanceByUsrId($row['user_id']));
2333 $mail_obj->sendMail(
2334 ilObjUser::_lookupLogin($row["user_id"]), "", "",
2335 $this->formatNotificationSubject($post_data),
2336 $this->formatNotification($post_data, 0, $attachments, $row['user_id']),
2337 array(), array("system")
2338 );
2339 }
2340 }
2341
2342 // reset language
2343 $this->setLanguage($userLanguage);
2344 }
formatNotificationSubject($post_data)
formatNotification($post_data, $cron=0, $attachments=array(), $user_id)
static _lookupObjIdForForumId($a_for_id)
setLanguage($lng)
_lookupLogin($a_user_id)
lookup login
static _getAllReferences($a_id)
get all reference ids of object

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

+ Here is the call graph for this function:

◆ sendPostActivationNotification()

ilForum::sendPostActivationNotification (   $post_data)

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

2393 {
2394 global $ilDB, $ilUser, $lng;
2395
2396 if (is_array($moderators = $this->getModerators()))
2397 {
2398 // GET THREAD DATA
2399 $result = $ilDB->queryf('
2400 SELECT thr_subject FROM frm_threads
2401 WHERE thr_pk = %s',
2402 array('integer'),
2403 array($post_data['pos_thr_fk']));
2404
2405 while($record = $ilDB->fetchAssoc($result))
2406 {
2407 $post_data['thr_subject'] = $record['thr_subject'];
2408 break;
2409 }
2410
2411 // GET AUTHOR OF NEW POST
2412 if($post_data['pos_display_user_id'])
2413 {
2414 $post_data['pos_usr_name'] = ilObjUser::_lookupLogin($post_data['pos_display_user_id']);
2415 }
2416 else if(strlen($post_data['pos_usr_alias']))
2417 {
2418 $post_data['pos_usr_name'] = $post_data['pos_usr_alias'].' ('.$lng->txt('frm_pseudonym').')';
2419 }
2420
2421 if($post_data['pos_usr_name'] == '')
2422 {
2423 $post_data['pos_usr_name'] = $this->lng->txt('forums_anonymous');
2424 }
2425
2426 // save language of the current user
2427 global $lng;
2428 $userLanguage = $lng;
2429
2430 $mail_obj = new ilMail(ANONYMOUS_USER_ID);
2431 foreach($moderators as $moderator)
2432 {
2433 // set forum language instance for earch user
2434 $this->setLanguage(self::_getLanguageInstanceByUsrId($moderator));
2435 $subject = $this->formatNotificationSubject($post_data);
2436 $message = $this->formatPostActivationNotification($post_data, $moderator);
2437 $mail_obj->sendMail(
2438 ilObjUser::_lookupLogin($moderator), '', '',
2439 $subject,
2440 $message,
2441 array(), array("system")
2442 );
2443 }
2444
2445 // reset language
2446 $this->setLanguage($userLanguage);
2447 }
2448 }
formatPostActivationNotification($post_data, $user_id)
getModerators()
get all users assigned to local role il_frm_moderator_<frm_ref_id>

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

Referenced by generatePost().

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

◆ sendThreadNotifications()

ilForum::sendThreadNotifications (   $post_data)

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

2161 {
2162 global $ilDB, $ilAccess, $lng;
2163
2164 include_once "Services/Mail/classes/class.ilMail.php";
2165 include_once './Services/User/classes/class.ilObjUser.php';
2166
2167 // GET THREAD DATA
2168 $result = $ilDB->queryf('
2169 SELECT thr_subject FROM frm_threads
2170 WHERE thr_pk = %s',
2171 array('integer'), array($post_data['pos_thr_fk']));
2172
2173 while($record = $ilDB->fetchAssoc($result))
2174 {
2175 $post_data['thr_subject'] = $record['thr_subject'];
2176 break;
2177 }
2178
2179 // determine obj_id of the forum
2180 $obj_id = self::_lookupObjIdForForumId($post_data['pos_top_fk']);
2181
2182 // GET AUTHOR OF NEW POST
2183 if($post_data['pos_display_user_id'])
2184 {
2185 $post_data['pos_usr_name'] = ilObjUser::_lookupLogin($post_data['pos_display_user_id']);
2186 }
2187 else if(strlen($post_data['pos_usr_alias']))
2188 {
2189 $post_data['pos_usr_name'] = $post_data['pos_usr_alias'].' ('.$lng->txt('frm_pseudonym').')';
2190 }
2191
2192 if($post_data['pos_usr_name'] == '')
2193 {
2194 $post_data['pos_usr_name'] = $this->lng->txt('forums_anonymous');
2195 }
2196
2197 // GET USERS WHO WANT TO BE INFORMED ABOUT NEW POSTS
2198 $res = $ilDB->queryf('
2199 SELECT user_id FROM frm_notification
2200 WHERE thread_id = %s
2201 AND user_id <> %s',
2202 array('integer', 'integer'),
2203 array($post_data['pos_thr_fk'], $_SESSION['AccountId']));
2204
2205 // get all references of obj_id
2206 $frm_references = ilObject::_getAllReferences($obj_id);
2207
2208 // save language of the current user
2209 global $lng;
2210 $userLanguage = $lng;
2211
2212 // get attachments data
2213 $fileDataForum = new ilFileDataForum($obj_id, $post_data['pos_pk']);
2214 $filesOfPost = $fileDataForum->getFilesOfPost();
2215
2216 $attachments = array();
2217 foreach($filesOfPost as $attachment)
2218 {
2219 $attachments[] = $attachment['name'];
2220 }
2221
2222 $mail_obj = new ilMail(ANONYMOUS_USER_ID);
2223 while($row = $ilDB->fetchAssoc($res))
2224 {
2225 // do rbac check before sending notification
2226 $send_mail = false;
2227 foreach((array)$frm_references as $ref_id)
2228 {
2229 if($ilAccess->checkAccessOfUser($row['user_id'], 'read', '', $ref_id))
2230 {
2231 $send_mail = true;
2232 break;
2233 }
2234 }
2235
2236 if($send_mail)
2237 {
2238 $this->setLanguage(self::_getLanguageInstanceByUsrId($row['user_id']));
2239 $mail_obj->sendMail(
2240 ilObjUser::_lookupLogin($row["user_id"]), "", "",
2241 $this->formatNotificationSubject($post_data),
2242 $this->formatNotification($post_data, 0, $attachments, $row['user_id']),
2243 array(), array("system")
2244 );
2245 }
2246 }
2247
2248 // reset language
2249 $this->setLanguage($userLanguage);
2250 }

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

+ Here is the call graph for this function:

◆ setDbTable()

ilForum::setDbTable (   $dbTable)

set database table

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

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

202 {
203 if ($dbTable == "")
204 {
205 die($this->className . "::setDbTable(): No database table given.");
206 }
207 else
208 {
209 $this->dbTable = $dbTable;
210 }
211 }

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

118 {
119
120 if (!isset($a_obj_id))
121 {
122 $message = get_class($this)."::setForumId(): No obj_id given!";
123 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
124 }
125
126 $this->id = $a_obj_id;
127 }

◆ setForumRefId()

ilForum::setForumRefId (   $a_ref_id)

set reference id which refers to ILIAS obj_id

Parameters
integerobject id @access public

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

135 {
136 if (!isset($a_ref_id))
137 {
138 $message = get_class($this)."::setForumRefId(): No ref_id given!";
139 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
140 }
141
142 $this->ref_id = $a_ref_id;
143 }

◆ setImportName()

ilForum::setImportName (   $a_import_name)

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

1981 {
1982 $this->import_name = $a_import_name;
1983 }

◆ setLanguage()

ilForum::setLanguage (   $lng)

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

82 {
83 $this->lng = $lng;
84 }

References $lng.

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

+ Here is the caller graph for this function:

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

235 {
236 $this->mdb2Query = $query_string;
237 $this->mdb2DataValue = $data_value;
238 $this->mdb2DataType = $data_type;
239
240 return true;
241 }

Referenced by __sendMessage(), and 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 172 of file class.ilForum.php.

173 {
174 if ($orderField == "")
175 {
176 die($this->className . "::setOrderField(): No orderField given.");
177 }
178 else
179 {
180 $this->orderField = $orderField;
181 }
182 }

References $orderField.

◆ setPageHits()

ilForum::setPageHits (   $pageHits)

set number of max.

visible datasets

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

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

291 {
292 if ($pageHits < 1)
293 {
294 die($this->className . "::setPageHits(): No int pageHits given.");
295 }
296 else
297 {
298 $this->pageHits = $pageHits;
299 return true;
300 }
301 }

References $pageHits.

◆ updateLastPostByObjId()

static ilForum::updateLastPostByObjId (   $a_obj_id)
static

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

2593 {
2594 global $ilDB;
2595 // get latest post of forum and update last_post
2596 $ilDB->setLimit(1);
2597 $res2 = $ilDB->queryf('
2598 SELECT pos_top_fk, pos_thr_fk, pos_pk FROM frm_posts, frm_data
2599 WHERE pos_top_fk = top_pk
2600 AND top_frm_fk = %s
2601 ORDER BY pos_date DESC',
2602 array('integer'), array($a_obj_id));
2603
2604 if ($res2->numRows() == 0)
2605 {
2606 $lastPost_top = "";
2607 }
2608 else
2609 {
2610 $z = 0;
2611
2612 while ($selData = $ilDB->fetchAssoc($res2))
2613 {
2614 if ($z > 0)
2615 {
2616 break;
2617 }
2618
2619 $lastPost_top = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
2620 $z ++;
2621 }
2622 }
2623
2624 $ilDB->update('frm_data',
2625 array('top_last_post' => array('text', $lastPost_top)),
2626 array('top_frm_fk' => array('integer', $a_obj_id))
2627 );
2628
2629 }

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

1751 {
1752
1753 global $ilDB;
1754
1755 $checkTime = time() - (60*60);
1756
1757 if ($_SESSION["frm_visit_".$this->dbTable."_".$ID] < $checkTime)
1758 {
1759
1760 $_SESSION["frm_visit_".$this->dbTable."_".$ID] = time();
1761 $query = 'UPDATE '.$this->dbTable.' SET visits = visits + 1 WHERE ';
1762
1763 $data_type = array();
1764 $data_value = array();
1765
1766 if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
1767 {
1768 $query .= $this->getMDB2Query();
1769 $data_type = $data_type + $this->getMDB2DataType();
1770 $data_value = $data_value + $this->getMDB2DataValue();
1771
1772 $res = $ilDB->queryf($query, $data_type, $data_value);
1773 }
1774 }
1775 }

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

◆ $dbTable

ilForum::$dbTable
private

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

Referenced by getDbTable(), and setDbTable().

◆ $id

ilForum::$id
private

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

Referenced by getForumId(), and moveThreads().

◆ $ilias

ilForum::$ilias

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

Referenced by __construct().

◆ $lng

◆ $mdb2DataType

ilForum::$mdb2DataType
private

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

Referenced by getMDB2DataType().

◆ $mdb2DataValue

ilForum::$mdb2DataValue
private

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

Referenced by getMDB2DataValue().

◆ $mdb2Query

ilForum::$mdb2Query
private

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

Referenced by getMDB2Query().

◆ $orderField

ilForum::$orderField
private

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

Referenced by getOrderField(), and setOrderField().

◆ $pageHits

ilForum::$pageHits = 30
private

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

Referenced by getPageHits(), and setPageHits().

◆ $replQuote1

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

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

◆ $replQuote2

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

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

◆ $txtQuote1

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

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

◆ $txtQuote2

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

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

Referenced by prepareText().

◆ 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: