ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilForum Class Reference

Class Forum core functions for forum. More...

+ Collaboration diagram for ilForum:

Public Member Functions

 __construct ()
 Constructor 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 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, $user, $message, $parent_pos, $notify, $subject='', $alias='', $date='', $status=1, $send_activation_mail=0)
 generate new dataset in frm_posts More...
 
 generateThread ($forum_id, $user, $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 public More...
 
 getPostDepth ($a_node_id, $tree_id)
 Return depth of an object private. More...
 
 getFirstPostNode ($tree_id)
 get data of the first node from frm_posts_tree and frm_posts public More...
 
 getPostNode ($post_id)
 get data of given node from frm_posts_tree and frm_posts public More...
 
 fetchPostNodeData ($a_row)
 get data of parent node from frm_posts_tree and frm_posts private More...
 
 deletePostTree ($a_node)
 delete node and the whole subtree under this node public More...
 
 updateVisits ($ID)
 update page hits of given forum- or thread-ID public More...
 
 prepareText ($text, $edit=0, $quote_user='', $type='')
 prepares given string 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 public.

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

References $ilias, and $lng.

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) ...

Member Function Documentation

◆ __deletePostFiles()

ilForum::__deletePostFiles (   $a_ids)

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

References $file, and getForumId().

Referenced by deletePost().

1869  {
1870  if(!is_array($a_ids))
1871  {
1872  return false;
1873  }
1874  include_once "./Modules/Forum/classes/class.ilFileDataForum.php";
1875 
1876  $tmp_file_obj =& new ilFileDataForum($this->getForumId());
1877  foreach($a_ids as $pos_id)
1878  {
1879  $tmp_file_obj->setPosId($pos_id);
1880  $files = $tmp_file_obj->getFilesOfPost();
1881  foreach($files as $file)
1882  {
1883  $tmp_file_obj->unlinkFile($file["name"]);
1884  }
1885  }
1886  unset($tmp_file_obj);
1887  return true;
1888  }
print $file
getForumId()
//
This class handles all operations on files for the forum object.
+ 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 1930 of file class.ilForum.php.

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

Referenced by __sendMessage().

1931  {
1932  include_once "./Services/Object/classes/class.ilObjectFactory.php";
1933  $user_lang = self::_getLanguageInstanceByUsrId($user_obj->getId());
1934 
1935  $frm_obj =& ilObjectFactory::getInstanceByRefId($this->getForumRefId());
1936  $title = $frm_obj->getTitle();
1937  unset($frm_obj);
1938 
1939  $message = '';
1940  $message .= ilMail::getSalutation($user_obj->getId(), $user_lang);
1941 
1942  $message .= "\n\n";
1943  $message .= $this->lng->txt("forum_post_replied");
1944  $message .= $this->lng->txt("forum").": ".$title." -> ".$thread_data["thr_subject"]."\n\n";
1945 
1946  $message .= "\n------------------------------------------------------------\n";
1947  $message .= $post_data["pos_message"];
1948  $message .= "\n------------------------------------------------------------\n";
1949  $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";
1950 
1951  $message .= ilMail::_getInstallationSignature();
1952  return $message;
1953  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
getForumRefId()
get forum ref_id public
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
static _getInstallationSignature()
Static getter for the installation signature.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __sendMessage()

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

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

References $ilUser, __formatMessage(), formatNotificationSubject(), getOnePost(), getOneThread(), and setMDB2WhereCondition().

1892  {
1893  global $ilUser, $ilDB;
1894 
1895  $parent_data = $this->getOnePost($a_parent_pos);
1896 
1897  // only if the current user is not the owner of the parent post and the parent's notification flag is set...
1898  if($parent_data["notify"] && $parent_data["pos_usr_id"] != $ilUser->getId())
1899  {
1900  // SEND MESSAGE
1901  include_once "Services/Mail/classes/class.ilMail.php";
1902  include_once './Services/User/classes/class.ilObjUser.php';
1903 
1904  $tmp_user =& new ilObjUser($parent_data["pos_usr_id"]);
1905 
1906  // NONSENSE
1907  $this->setMDB2WhereCondition('thr_pk = %s ', array('integer'), array($parent_data["pos_thr_fk"]));
1908 
1909  $thread_data = $this->getOneThread();
1910 
1911  $tmp_mail_obj = new ilMail(ANONYMOUS_USER_ID);
1912  $message = $tmp_mail_obj->sendMail($tmp_user->getLogin(),"","",
1913  $this->formatNotificationSubject($post_data),
1914  $this->__formatMessage($thread_data, $post_data, $tmp_user),
1915  array(),array("system"));
1916 
1917  unset($tmp_user);
1918  unset($tmp_mail_obj);
1919  }
1920  }
getOnePost($post)
get one post-dataset
setMDB2WhereCondition($query_string, $data_type, $data_value)
set content for additional condition
getOneThread()
get one thread-dataset by WhereCondition
Class Mail this class handles base functions for mail handling.
__formatMessage($thread_data, $post_data=array(), $user_obj)
generates the notificiation message, if a post has been answered
formatNotificationSubject($post_data)
global $ilUser
Definition: imgupload.php:15
+ 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 public

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

References $usr_id, and ilObjUser\_lookupLanguage().

Referenced by ilForumCronNotification\sendMails().

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  }
static _lookupLanguage($a_usr_id)
language handling
+ 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 public

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

References ilObject\_lookupTitle().

Referenced by _isModerator(), and getModerators().

1324  {
1325  global $rbacreview;
1326 
1327  $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
1328  $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
1329 
1330  foreach ($role_arr as $role_id)
1331  {
1332  //$roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1333  $title = ilObject::_lookupTitle($role_id);
1334  if ($title == "il_frm_moderator_".$a_ref_id)
1335  {
1336  #return $rbacreview->assignedUsers($roleObj->getId());
1337  return $title = $rbacreview->assignedUsers($role_id);
1338  }
1339  }
1340 
1341  return array();
1342  }
static _lookupTitle($a_id)
lookup object title
+ 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.

public

Parameters
intobj_id of forum
intsort mode SORT_TITLE or SORT_DATE

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

References $res, and $row.

Referenced by ilObjForumGUI\cloneWizardPageObject().

2526  {
2527  global $ilDB;
2528 
2529  switch($a_sort_mode)
2530  {
2531  case self::SORT_DATE:
2532  $sort = 'thr_date';
2533  break;
2534 
2535  case self::SORT_TITLE:
2536  default:
2537  $sort = 'thr_subject';
2538  break;
2539  }
2540 
2541  $res = $ilDB->queryf('
2542  SELECT * FROM frm_threads
2543  JOIN frm_data ON top_pk = thr_top_fk
2544  WHERE top_frm_fk = %s
2545  ORDER BY %s',
2546  array('integer', 'text'), array($a_obj_id, $sort));
2547 
2548  while($row = $ilDB->fetchObject($res))
2549  {
2550  $threads[$row->thr_pk] = $row->thr_subject;
2551  }
2552  return $threads ? $threads : array();
2553  }
+ 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 public

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

References _getModerators().

Referenced by ilForumExportGUI\executeCommand(), and ilObjForumGUI\setTreeStateAsynchObject().

1353  {
1354  return in_array($a_usr_id, ilForum::_getModerators($a_ref_id));
1355  }
_getModerators($a_ref_id)
get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)
+ 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 2555 of file class.ilForum.php.

References $res.

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

2556  {
2557  global $ilDB;
2558 
2559  $res = $ilDB->queryf('
2560  SELECT top_frm_fk FROM frm_data
2561  WHERE top_pk = %s',
2562  array('integer'), array($a_for_id));
2563 
2564  if ($fdata = $ilDB->fetchAssoc($res))
2565  {
2566  return $fdata["top_frm_fk"];
2567  }
2568  return false;
2569  }
+ Here is the caller graph for this function:

◆ _lookupPostMessage()

ilForum::_lookupPostMessage (   $a_id)

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

References $res, and $row.

Referenced by ilObjForum\getDiskUsage().

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  }
+ Here is the caller graph for this function:

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

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

Referenced by generatePost().

1418  {
1419  global $ilDB;
1420 
1421  $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1422 
1423  if ($a_node_id <= 0)
1424  {
1425  $a_node_id = $a_tree_id;
1426  }
1427 
1428  $nextId = $ilDB->nextId('frm_posts_tree');
1429 
1430  $statement = $ilDB->manipulateF('
1431  INSERT INTO frm_posts_tree
1432  ( fpt_pk,
1433  thr_fk,
1434  pos_fk,
1435  parent_pos,
1436  lft,
1437  rgt,
1438  depth,
1439  fpt_date
1440  )
1441  VALUES(%s, %s, %s, %s, %s, %s, %s, %s )',
1442  array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1443  array($nextId, $a_tree_id, $a_node_id, '0', '1', '2', '1', $a_date));
1444 
1445  return true;
1446  }
+ Here is the caller graph for this function:

◆ convertDate()

ilForum::convertDate (   $date)

converts the date format

Parameters
string$date
Returns
string formatted datetime public

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

References ilDatePresentation\formatDate(), and IL_CAL_DATETIME.

Referenced by getOnePost().

1406  {
1408  }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
+ 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 1379 of file class.ilForum.php.

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

1380  {
1381  global $ilDB, $ilUser;
1382 
1383  $res = $ilDB->queryf('
1384  SELECT * FROM frm_data
1385  INNER JOIN frm_posts ON pos_top_fk = top_pk
1386  WHERE top_frm_fk = %s
1387  AND (pos_status = %s
1388  OR (pos_status = %s
1389  AND pos_usr_id = %s
1390  )
1391  )
1392  AND pos_usr_id = %s',
1393  array('integer', 'integer', 'integer', 'integer', 'integer'),
1394  array($this->getForumId(),'1', '0', $ilUser->getId(), $a_user_id));
1395 
1396  return $res->numRows();
1397  }
getForumId()
//
global $ilUser
Definition: imgupload.php:15
+ 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 public

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

References $res, and getForumId().

1365  {
1366  global $ilDB;
1367 
1368  $res = $ilDB->queryf('
1369  SELECT * FROM frm_data
1370  INNER JOIN frm_posts ON pos_top_fk = top_pk
1371  WHERE top_frm_fk = %s
1372  AND pos_usr_id = %s',
1373  array('integer', 'integer'),
1374  array($this->getForumId(), $a_user_id));
1375 
1376  return $res->numRows();
1377  }
getForumId()
//
+ Here is the call graph for this function:

◆ deletePost()

ilForum::deletePost (   $post)

delete post and sub-posts

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

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

References $data, $ilSetting, $ilUser, $mobs, $query, $res, $row, __deletePostFiles(), ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), deletePostTree(), ilDB\fetchAssoc(), ilForumProperties\FORUM_OVERVIEW_WITH_NEW_POSTS, ilNewsItem\getFirstNewsIdForContext(), getForumId(), ilForumProperties\getInstance(), getPostNode(), and ilDB\setLimit().

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

◆ deletePostTree()

ilForum::deletePostTree (   $a_node)

delete node and the whole subtree under this node public

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

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

References $res, $result, and $row.

Referenced by deletePost().

1659  {
1660  global $ilDB;
1661 
1662  // GET LEFT AND RIGHT VALUES
1663  $res = $ilDB->queryf('
1664  SELECT * FROM frm_posts_tree
1665  WHERE thr_fk = %s
1666  AND pos_fk = %s
1667  AND parent_pos = %s',
1668  array('integer', 'integer', 'integer'),
1669  array($a_node['tree'], $a_node['pos_pk'], $a_node['parent']));
1670 
1671  while($row = $ilDB->fetchObject($res))
1672  {
1673  $a_node["lft"] = $row->lft;
1674  $a_node["rgt"] = $row->rgt;
1675  }
1676 
1677  $diff = $a_node["rgt"] - $a_node["lft"] + 1;
1678 
1679  // get data of posts
1680  $result = $ilDB->queryf('
1681  SELECT * FROM frm_posts_tree
1682  WHERE lft BETWEEN %s AND %s
1683  AND thr_fk = %s',
1684  array('integer', 'integer', 'integer'),
1685  array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
1686 
1687  $del_id = array();
1688 
1689  while ($treeData = $ilDB->fetchAssoc($result))
1690  {
1691  $del_id[] = $treeData["pos_fk"];
1692  }
1693 
1694  // delete subtree
1695  $statement = $ilDB->manipulateF('
1696  DELETE FROM frm_posts_tree
1697  WHERE lft BETWEEN %s AND %s
1698  AND thr_fk = %s',
1699  array('integer', 'integer', 'integer'),
1700  array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
1701 
1702 
1703  // close gaps
1704  $statement = $ilDB->manipulateF('
1705  UPDATE frm_posts_tree
1706  SET lft = CASE
1707  WHEN lft > %s
1708  THEN lft - %s
1709  ELSE lft
1710  END,
1711  rgt = CASE
1712  WHEN rgt > %s
1713  THEN rgt - %s
1714  ELSE rgt
1715  END
1716  WHERE thr_fk = %s',
1717  array('integer', 'integer', 'integer', 'integer', 'integer'),
1718  array($a_node['lft'], $diff, $a_node['lft'], $diff, $a_node['tree']));
1719 
1720  return $del_id;
1721 
1722  }
$result
+ 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 private

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

2050  {
2051  global $ilDB;
2052 
2053  $statement = $ilDB->manipulateF('
2054  DELETE FROM frm_notification
2055  WHERE user_id = %s
2056  AND frm_id = %s',
2057  array('integer', 'integer'),
2058  array($user_id, $this->id));
2059 
2060  return true;
2061  }

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

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

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

1971  {
1972  global $ilDB;
1973 
1974  if (!$this->isForumNotificationEnabled($user_id))
1975  {
1976  /* Remove all notifications of threads that belong to the forum */
1977 
1978  $res = $ilDB->queryf('
1979  SELECT frm_notification.thread_id FROM frm_data, frm_notification, frm_threads
1980  WHERE frm_notification.user_id = %s
1981  AND frm_notification.thread_id = frm_threads.thr_pk
1982  AND frm_threads.thr_top_fk = frm_data.top_pk
1983  AND frm_data.top_frm_fk = %s
1984  GROUP BY frm_notification.thread_id',
1985  array('integer', 'integer'),
1986  array($user_id, $this->id));
1987 
1988  if (is_object($res) && $res->numRows() > 0)
1989  {
1990  $thread_data = array();
1991  $thread_data_types = array();
1992 
1993  $query = ' DELETE FROM frm_notification
1994  WHERE user_id = %s
1995  AND thread_id IN (';
1996 
1997  array_push($thread_data, $user_id);
1998  array_push($thread_data_types, 'integer');
1999 
2000  $counter = 1;
2001 
2002  while($row = $ilDB->fetchAssoc($res))
2003  {
2004  if($counter < $res->numRows())
2005  {
2006  $query .= '%s, ';
2007  array_push($thread_data, $row['thread_id']);
2008  array_push($thread_data_types, 'integer');
2009  }
2010 
2011  if($counter == $res->numRows())
2012  {
2013  $query .= '%s)';
2014  array_push($thread_data, $row['thread_id']);
2015  array_push($thread_data_types, 'integer');
2016 
2017  }
2018  $counter++;
2019  }
2020 
2021  $statement = $ilDB->manipulateF($query, $thread_data_types, $thread_data);
2022  }
2023 
2024  /* Insert forum notification */
2025 
2026  $nextId = $ilDB->nextId('frm_notification');
2027 
2028  $statement = $ilDB->manipulateF('
2029  INSERT INTO frm_notification
2030  ( notification_id,
2031  user_id,
2032  frm_id
2033  )
2034  VALUES(%s, %s, %s)',
2035  array('integer','integer', 'integer'),
2036  array($nextId, $user_id, $this->id));
2037 
2038  }
2039 
2040  return true;
2041  }
isForumNotificationEnabled($user_id)
Check whether a user&#39;s notification about new posts in this forum is enabled (result > 0) or not (res...
+ 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 private

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

References isThreadNotificationEnabled().

2092  {
2093  global $ilDB;
2094 
2095  if (!$this->isThreadNotificationEnabled($user_id, $thread_id))
2096  {
2097  $nextId = $ilDB->nextId('frm_notification');
2098  $statement = $ilDB->manipulateF('
2099  INSERT INTO frm_notification
2100  ( notification_id,
2101  user_id,
2102  thread_id
2103  )
2104  VALUES (%s, %s, %s)',
2105  array('integer', 'integer', 'integer'), array($nextId, $user_id, $thread_id));
2106 
2107  }
2108 
2109  return true;
2110  }
isThreadNotificationEnabled($user_id, $thread_id)
Check whether a user&#39;s notification about new posts in a thread is enabled (result > 0) or not (resul...
+ 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 private

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

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

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

Referenced by getFirstPostNode(), and getPostNode().

1604  {
1605  global $lng;
1606 
1607  require_once('./Services/User/classes/class.ilObjUser.php');
1608 
1609  if (ilObject::_exists($a_row->pos_usr_id))
1610  {
1611  $tmp_user = new ilObjUser($a_row->pos_usr_id);
1612  $fullname = $tmp_user->getFullname();
1613  $loginname = $tmp_user->getLogin();
1614  }
1615 
1616  $fullname = $fullname ? $fullname : ($a_row->import_name ? $a_row->import_name : $lng->txt("unknown"));
1617 
1618  $data = array(
1619  "pos_pk" => $a_row->pos_pk,
1620  "child" => $a_row->pos_pk,
1621  "author" => $a_row->pos_usr_id,
1622  "alias" => $a_row->pos_usr_alias,
1623  "title" => $fullname,
1624  "loginname" => $loginname,
1625  "type" => "post",
1626  "message" => $a_row->pos_message,
1627  "subject" => $a_row->pos_subject,
1628  "pos_cens_com" => $a_row->pos_cens_com,
1629  "pos_cens" => $a_row->pos_cens,
1630  // "date" => $a_row->date,
1631  "date" => $a_row->fpt_date,
1632  "create_date" => $a_row->pos_date,
1633  "update" => $a_row->pos_update,
1634  "update_user" => $a_row->update_user,
1635  "tree" => $a_row->thr_fk,
1636  "parent" => $a_row->parent_pos,
1637  "lft" => $a_row->lft,
1638  "rgt" => $a_row->rgt,
1639  "depth" => $a_row->depth,
1640  "id" => $a_row->fpt_pk,
1641  "notify" => $a_row->notify,
1642  "import_name" => $a_row->import_name,
1643  "pos_status" => $a_row->pos_status
1644  );
1645 
1646  // why this line? data should be stored without slashes in db
1647  //$data["message"] = stripslashes($data["message"]);
1648 
1649  return $data ? $data : array();
1650  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ 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 2445 of file class.ilForum.php.

References $ilIliasIniFile, and ilMail\getSalutation().

Referenced by sendForumNotifications(), and sendThreadNotifications().

2446  {
2447  global $ilIliasIniFile;
2448 
2449  $user_lang = self::_getLanguageInstanceByUsrId($user_id);
2450 
2451  $message = "";
2452 
2453  $message .= ilMail::getSalutation($user_id, $user_lang);
2454  $message .= "\n\n";
2455  $message .= $this->lng->txt("forums_notification_subject")." ".$post_data['top_name']."\n\n";
2456 
2457  $message .= $this->lng->txt("forum").": ".$post_data["top_name"]."\n\n";
2458  $message .= $this->lng->txt("thread").": ".$post_data["thr_subject"]."\n\n";
2459  $message .= $this->lng->txt("new_post").":\n------------------------------------------------------------\n";
2460  $message .= $this->lng->txt("author").": ".$post_data["pos_usr_name"]."\n";
2461  $message .= $this->lng->txt("date").": ".$post_data["pos_date"]."\n";
2462  $message .= $this->lng->txt("subject").": ".$post_data["pos_subject"]."\n\n";
2463 
2464  if ($post_data["pos_cens"] == 1)
2465  {
2466  $message .= $post_data["pos_cens_com"]."\n";
2467  }
2468  else
2469  {
2470  $pos_message = $post_data['pos_message'];
2471  if(strip_tags($pos_message) != $pos_message)
2472  {
2473  $pos_message = preg_replace("/\n/i", "", $pos_message);
2474  $pos_message = preg_replace("/<br(\s*)(\/?)>/i", "\n", $pos_message);
2475  $pos_message = preg_replace("/<p([^>]*)>/i", "\n\n", $pos_message);
2476  $pos_message = preg_replace("/<\/p([^>]*)>/i", '', $pos_message);
2477  }
2478  $message .= strip_tags($pos_message)."\n";
2479  }
2480  $message .= "------------------------------------------------------------\n";
2481 
2482  if(count($attachments) > 0)
2483  {
2484  foreach($attachments as $attachment)
2485  {
2486  $message .= $this->lng->txt('attachment').": ".$attachment."\n";
2487  }
2488  $message .= "\n------------------------------------------------------------\n";
2489  }
2490 
2491  if ($cron == 1)
2492  {
2493  $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";
2494  }
2495  else
2496  {
2497  $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";
2498  }
2499 
2500  if ($cron == 1)
2501  {
2502  $message .= sprintf($this->lng->txt("forums_notification_intro"),
2503  $this->ilias->ini->readVariable("client","name"),
2504  $ilIliasIniFile->readVariable("server","http_path").'/?client_id='.CLIENT_ID)."\n\n";
2505  }
2506  else
2507  {
2508  $message .= sprintf($this->lng->txt("forums_notification_intro"),
2509  $this->ilias->ini->readVariable("client","name"),
2510  ILIAS_HTTP_PATH.'/?client_id='.CLIENT_ID)."\n\n";
2511  }
2512 
2513  return $message;
2514  }
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
redirection script todo: (a better solution should control the processing via a xml file) ...
global $ilIliasIniFile
+ 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 2433 of file class.ilForum.php.

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

2434  {
2435  return $this->lng->txt("forums_notification_subject").' '.$post_data['top_name'];
2436  }
+ 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 2330 of file class.ilForum.php.

References ilMail\getSalutation().

Referenced by sendPostActivationNotification().

2331  {
2332  $user_lang = self::_getLanguageInstanceByUsrId($user_id);
2333 
2334  $message = "";
2335  $message .= ilMail::getSalutation($user_id, $user_lang);
2336  $message .= "\n\n";
2337  $message .= $this->lng->txt('forums_post_activation_mail')."\n\n";
2338 
2339  $message .= $this->lng->txt("forum").": ".$post_data["top_name"]."\n\n";
2340  $message .= $this->lng->txt("thread").": ".$post_data["thr_subject"]."\n\n";
2341  $message .= $this->lng->txt("new_post").":\n------------------------------------------------------------\n";
2342  $message .= $this->lng->txt("author").": ".$post_data["pos_usr_name"]."\n";
2343  $message .= $this->lng->txt("date").": ".$post_data["pos_date"]."\n";
2344  $message .= $this->lng->txt("subject").": ".$post_data["pos_subject"]."\n\n";
2345  if ($post_data["pos_cens"] == 1)
2346  {
2347  $message .= $post_data["pos_cens_com"]."\n";
2348  }
2349  else
2350  {
2351  $pos_message = $post_data['pos_message'];
2352  if(strip_tags($pos_message) != $pos_message)
2353  {
2354  $pos_message = preg_replace("/\n/i", "", $pos_message);
2355  $pos_message = preg_replace("/<br(\s*)(\/?)>/i", "\n", $pos_message);
2356  $pos_message = preg_replace("/<p([^>]*)>/i", "\n\n", $pos_message);
2357  $pos_message = preg_replace("/<\/p([^>]*)>/i", '', $pos_message);
2358  }
2359  $message .= strip_tags($pos_message)."\n";
2360  }
2361  $message .= "------------------------------------------------------------\n";
2362 
2363  $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";
2364  $message .= sprintf($this->lng->txt('forums_notification_intro'),
2365  $this->ilias->ini->readVariable('client', 'name'),
2366  ILIAS_HTTP_PATH.'/?client_id='.CLIENT_ID)."\n\n";
2367 
2368  return $message;
2369  }
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
redirection script todo: (a better solution should control the processing via a xml file) ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generatePost()

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

generate new dataset in frm_posts

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

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

References $ilUser, $result, ilRTE\_replaceMediaObjectImageSrc(), addPostTree(), getForumRefId(), getImportName(), ilObjectFactory\getInstanceByRefId(), insertPostNode(), NEWS_NOTICE, NEWS_USERS, prepareText(), and sendPostActivationNotification().

Referenced by generateThread().

446  {
447  global $ilUser, $ilDB;
448 
449  $objNewPost = new ilForumPost();
450  $objNewPost->setForumId($forum_id);
451  $objNewPost->setThreadId($thread_id);
452  $objNewPost->setSubject($subject);
453  $objNewPost->setMessage($message);
454  $objNewPost->setUserId($user);
455  $objNewPost->setUserAlias($alias);
456  if ($date == "")
457  {
458  $objNewPost->setCreateDate(date("Y-m-d H:i:s"));
459  }
460  else
461  {
462  if (strpos($date, "-") > 0) // in mysql format
463  {
464  $objNewPost->setCreateDate($date);
465  }
466  else // a timestamp
467  {
468  $objNewPost->setCreateDate(date("Y-m-d H:i:s", $date));
469  }
470  }
471 
472  $objNewPost->setImportName($this->getImportName());
473  $objNewPost->setNotification($notify);
474  $objNewPost->setStatus($status);
475  $objNewPost->insert();
476 
477  // entry in tree-table
478  if ($parent_pos == 0)
479  {
480  $this->addPostTree($objNewPost->getThreadId(), $objNewPost->getId(), $objNewPost->getCreateDate());
481  }
482  else
483  {
484  $this->insertPostNode($objNewPost->getId(), $parent_pos, $objNewPost->getThreadId(), $objNewPost->getCreateDate());
485  }
486 //echo "<br>->".$objNewPost->getId()."-".$parent_pos."-".$objNewPost->getThreadId()."-".
487 // $objNewPost->getCreateDate()."-".$forum_id."-".$message."-".$user."-";
488  // string last post
489  $lastPost = $objNewPost->getForumId()."#".$objNewPost->getThreadId()."#".$objNewPost->getId();
490 
491  // update thread
492  $result = $ilDB->manipulateF('
493  UPDATE frm_threads
494  SET thr_num_posts = thr_num_posts + 1,
495  thr_last_post = %s
496  WHERE thr_pk = %s',
497  array('text', 'integer'),
498  array($lastPost, $objNewPost->getThreadId()));
499 
500  // update forum
501  $result = $ilDB->manipulateF('
502  UPDATE frm_data
503  SET top_num_posts = top_num_posts + 1,
504  top_last_post = %s
505  WHERE top_pk = %s',
506  array('text', 'integer'),
507  array($lastPost, $objNewPost->getForumId()));
508 
509  // MARK READ
510  $forum_obj = ilObjectFactory::getInstanceByRefId($this->getForumRefId());
511  $forum_obj->markPostRead($objNewPost->getUserId(), $objNewPost->getThreadId(), $objNewPost->getId());
512 
513  $pos_data = $objNewPost->getDataAsArray();
514  $pos_data["ref_id"] = $this->getForumRefId();
515 
516  // Send notification to moderators if they have to enable a post
517 
518  if (!$status && $send_activation_mail)
519  {
520  $pos_data["top_name"] = $forum_obj->getTitle();
521  $this->sendPostActivationNotification($pos_data);
522  }
523 
524  // Add Notification to news
525  if ($status)
526  {
527  require_once 'Services/RTE/classes/class.ilRTE.php';
528  include_once("./Services/News/classes/class.ilNewsItem.php");
529  $news_item = new ilNewsItem();
530  $news_item->setContext($forum_obj->getId(), 'frm', $objNewPost->getId(), 'pos');
531  $news_item->setPriority(NEWS_NOTICE);
532  $news_item->setTitle($objNewPost->getSubject());
533  $news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($this->prepareText($objNewPost->getMessage(), 0), 1));
534  $news_item->setUserId($user);
535  $news_item->setVisibility(NEWS_USERS);
536  $news_item->create();
537  }
538 
539  return $objNewPost->getId();
540  }
const NEWS_USERS
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
$result
getForumRefId()
get forum ref_id public
insertPostNode($a_node_id, $a_parent_id, $tree_id, $a_date='')
insert node under parent node public
sendPostActivationNotification($post_data)
prepareText($text, $edit=0, $quote_user='', $type='')
prepares given string public
const NEWS_NOTICE
addPostTree($a_tree_id, $a_node_id=-1, $a_date='')
create a new post-tree
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateThread()

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

generate new dataset in frm_threads

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

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

References generatePost(), and getImportName().

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

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

References $dbTable.

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

◆ getFirstPostByThread()

ilForum::getFirstPostByThread (   $a_thread_id)

Get first post of thread.

public

Parameters
intthread id
Returns

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

References $res, and $row.

1289  {
1290  global $ilDB;
1291 
1292  $res = $ilDB->queryf('
1293  SELECT * FROM frm_posts_tree
1294  WHERE thr_fk = %s
1295  AND parent_pos = %s',
1296  array('integer', 'integer'), array($a_thread_id, '0'));
1297 
1298  $row = $ilDB->fetchObject($res);
1299 
1300  return $row->pos_fk ? $row->pos_fk : 0;
1301  }

◆ getFirstPostNode()

ilForum::getFirstPostNode (   $tree_id)

get data of the first node from frm_posts_tree and frm_posts public

Parameters
integertree id
Returns
object db result object

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

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

1559  {
1560  global $ilDB;
1561 
1562  $res = $ilDB->queryf('
1563  SELECT * FROM frm_posts, frm_posts_tree
1564  WHERE pos_pk = pos_fk
1565  AND parent_pos = %s
1566  AND thr_fk = %s',
1567  array('integer', 'integer'),
1568  array('0', $tree_id));
1569 
1570  $row = $ilDB->fetchObject($res);
1571 
1572  return $this->fetchPostNodeData($row);
1573  }
fetchPostNodeData($a_row)
get data of parent node from frm_posts_tree and frm_posts private
+ Here is the call graph for this function:

◆ getForumId()

ilForum::getForumId ( )

//

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

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

References $id.

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

152  {
153  return $this->id;
154  }
+ Here is the caller graph for this function:

◆ getForumRefId()

ilForum::getForumRefId ( )

get forum ref_id public

Returns
integer reference id of forum

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

References $ref_id.

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

162  {
163  return $this->ref_id;
164  }
$ref_id
Definition: sahs_server.php:39
+ Here is the caller graph for this function:

◆ getImportName()

ilForum::getImportName ( )

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

Referenced by generatePost(), and generateThread().

1956  {
1957  return $this->import_name;
1958  }
+ 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.

References $mdb2DataType.

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

277  {
278  if($this->mdb2DataType != '')
279  {
280  return $this->mdb2DataType;
281  }
282  }
+ 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.

References $mdb2DataValue.

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

264  {
265  if($this->mdb2DataValue != '')
266  {
267  return $this->mdb2DataValue;
268  }
269  }
+ Here is the caller graph for this function:

◆ getMDB2Query()

ilForum::getMDB2Query ( )

get content of additional condition

Returns
string

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

References $mdb2Query.

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

250  {
251  if($this->mdb2Query != '')
252  {
253  return $this->mdb2Query;
254  }
255 
256  }
+ 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 public

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

References $res, and $row.

1853  {
1854  global $ilDB;
1855 
1856  $res = $ilDB->queryf('
1857  SELECT frm_data.* FROM frm_data, frm_posts
1858  WHERE pos_pk = %s
1859  AND pos_top_fk = top_pk',
1860  array('integer'), array($pos_pk));
1861 
1862  $row = $ilDB->fetchAssoc($res);
1863 
1864  return $row;
1865 
1866  }

◆ getModerators()

ilForum::getModerators ( )

get all users assigned to local role il_frm_moderator_<frm_ref_id>

Returns
array user_ids public

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

References _getModerators(), and getForumRefId().

Referenced by sendPostActivationNotification().

1310  {
1311  global $rbacreview;
1312 
1313  return $this->_getModerators($this->getForumRefId());
1314  }
getForumRefId()
get forum ref_id public
_getModerators($a_ref_id)
get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)
+ 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 public

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

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

Referenced by __sendMessage().

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_usr_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
+ 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 public

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

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

Referenced by __sendMessage().

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  }
$result
getMDB2DataType()
get content of additional condition
getMDB2Query()
get content of additional condition
getMDB2DataValue()
/* get content of additional condition
+ 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 public

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

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

Referenced by moveThreads().

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  }
getMDB2DataType()
get content of additional condition
getMDB2Query()
get content of additional condition
getMDB2DataValue()
/* get content of additional condition
+ 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 User interface

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

References $orderField.

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

◆ getPageHits()

ilForum::getPageHits ( )

get number of max.

visible datasets

Returns
integer $pageHits
See also
$pageHits User interface

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

References $pageHits.

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

◆ getPostDepth()

ilForum::getPostDepth (   $a_node_id,
  $tree_id 
)

Return depth of an object private.

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

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

References $res.

Referenced by insertPostNode().

1530  {
1531  global $ilDB;
1532 
1533  if ($tree_id)
1534  {
1535  $sql_res = $ilDB->queryf('
1536  SELECT depth FROM frm_posts_tree
1537  WHERE pos_fk = %s
1538  AND thr_fk = %s',
1539  array('integer', 'integer'),
1540  array($a_node_id, $tree_id));
1541 
1542  $res = $ilDB->fetchObject($sql_res);
1543 
1544  return $res->depth;
1545  }
1546  else
1547  {
1548  return 0;
1549  }
1550  }
+ 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 public

Parameters
integerpost_id
Returns
object db result object

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

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

Referenced by deletePost().

1582  {
1583  global $ilDB;
1584 
1585  $res = $ilDB->queryf('
1586  SELECT * FROM frm_posts, frm_posts_tree
1587  WHERE pos_pk = pos_fk
1588  AND pos_pk = %s',
1589  array('integer'),
1590  array($post_id));
1591 
1592  $row = $ilDB->fetchObject($res);
1593 
1594  return $this->fetchPostNodeData($row);
1595  }
fetchPostNodeData($a_row)
get data of parent node from frm_posts_tree and frm_posts private
+ 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 1212 of file class.ilForum.php.

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

1213  {
1214  global $ilDB, $ilUser;
1215 
1216  $statistic = array();
1217 
1218  $data_types = array();
1219  $data = array();
1220 
1221  $query = "SELECT COUNT(f.pos_usr_id) ranking, u.login, p.value, u.lastname, u.firstname
1222  FROM frm_posts f
1223  INNER JOIN frm_posts_tree t
1224  ON f.pos_pk = t.pos_fk
1225  INNER JOIN frm_threads th
1226  ON t.thr_fk = th.thr_pk
1227  INNER JOIN usr_data u
1228  ON u.usr_id = f.pos_usr_id
1229  INNER JOIN frm_data d
1230  ON d.top_pk = f.pos_top_fk
1231  LEFT JOIN usr_pref p
1232  ON p.usr_id = u.usr_id AND p.keyword = %s
1233  WHERE 1 = 1";
1234 
1235  array_push($data_types, 'text');
1236  array_push($data, 'public_profile');
1237 
1238  if (!$is_moderator)
1239  {
1240  $query .= ' AND (pos_status = %s
1241  OR (pos_status = %s
1242  AND pos_usr_id = %s ))';
1243 
1244  array_push($data_types,'integer', 'integer', 'integer');
1245  array_push($data, '1', '0', $ilUser->getId());
1246  }
1247 
1248  $query .= ' AND d.top_frm_fk = %s
1249  GROUP BY pos_usr_id, u.login, p.value,u.lastname, u.firstname';
1250 
1251  array_push($data_types,'integer');
1252  array_push($data, $this->getForumId());
1253 
1254  $res = $ilDB->queryf($query, $data_types, $data);
1255 
1256  $counter = 0;
1257  while ($row = $ilDB->fetchAssoc($res))
1258  {
1259  $statistic[$counter][] = $row['ranking'];
1260  $statistic[$counter][] = $row['login'];
1261 
1262  $lastname ='';
1263  $firstname = '';
1264  if(!$ilUser->isAnonymous() && in_array($row['value'], array('y', 'g')) ||
1265  $ilUser->isAnonymous() && 'g' == $row['value'])
1266  {
1267  $lastname = $row['lastname'];
1268  $firstname = $row['firstname'];
1269  }
1270 
1271  $statistic[$counter][] = $lastname;
1272  $statistic[$counter][] = $firstname;
1273 
1274  ++$counter;
1275  }
1276 
1277  return is_array($statistic) ? $statistic : array();
1278  }
getForumId()
//
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
global $ilUser
Definition: imgupload.php:15
+ 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 public

Parameters
integernode_id
integertree_id
integerparent_id (optional)

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

References $res, and getPostDepth().

Referenced by generatePost().

1456  {
1457  global $ilDB;
1458 
1459  $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1460 
1461  // get left value
1462  $sql_res = $ilDB->queryf('
1463  SELECT * FROM frm_posts_tree
1464  WHERE pos_fk = %s
1465  AND thr_fk = %s',
1466  array('integer', 'integer'),
1467  array($a_parent_id, $tree_id));
1468 
1469  $res = $ilDB->fetchObject($sql_res);
1470 
1471  $left = $res->lft;
1472 
1473  $lft = $left + 1;
1474  $rgt = $left + 2;
1475 
1476  // spread tree
1477  $statement = $ilDB->manipulateF('
1478  UPDATE frm_posts_tree
1479  SET lft = CASE
1480  WHEN lft > %s
1481  THEN lft + 2
1482  ELSE lft
1483  END,
1484  rgt = CASE
1485  WHEN rgt > %s
1486  THEN rgt + 2
1487  ELSE rgt
1488  END
1489  WHERE thr_fk = %s',
1490  array('integer', 'integer', 'integer'),
1491  array($left, $left, $tree_id));
1492 
1493  $depth = $this->getPostDepth($a_parent_id, $tree_id) + 1;
1494 
1495  // insert node
1496  $nextId = $ilDB->nextId('frm_posts_tree');
1497  $statement = $ilDB->manipulateF('
1498  INSERT INTO frm_posts_tree
1499  ( fpt_pk,
1500  thr_fk,
1501  pos_fk,
1502  parent_pos,
1503  lft,
1504  rgt,
1505  depth,
1506  fpt_date
1507  )
1508  VALUES(%s,%s,%s, %s, %s, %s,%s, %s)',
1509  array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1510  array( $nextId,
1511  $tree_id,
1512  $a_node_id,
1513  $a_parent_id,
1514  $lft,
1515  $rgt,
1516  $depth,
1517  $a_date)
1518  );
1519 
1520  }
getPostDepth($a_node_id, $tree_id)
Return depth of an object private.
+ 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 private

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

References $result.

Referenced by enableForumNotification().

2070  {
2071  global $ilDB;
2072 
2073  $result = $ilDB->queryf('SELECT COUNT(*) cnt FROM frm_notification WHERE user_id = %s AND frm_id = %s',
2074  array('integer', 'integer'), array($user_id, $this->id));
2075 
2076  while($record = $ilDB->fetchAssoc($result))
2077  {
2078  return (bool)$record['cnt'];
2079  }
2080 
2081  return false;
2082  }
$result
+ 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 private

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

References $result.

Referenced by enableThreadNotification().

2120  {
2121  global $ilDB;
2122 
2123  $result = $ilDB->queryf('
2124  SELECT COUNT(*) cnt FROM frm_notification
2125  WHERE user_id = %s
2126  AND thread_id = %s',
2127  array('integer', 'integer'),
2128  array($user_id, $thread_id));
2129 
2130 
2131  while($record = $ilDB->fetchAssoc($result))
2132  {
2133  return (bool)$record['cnt'];
2134  }
2135 
2136  return false;
2137  }
$result
+ 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 2616 of file class.ilForum.php.

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

Referenced by ilObjForumGUI\confirmMergeThreadsObject().

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

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

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

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

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

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

729  {
730  global $ilDB;
731 
732  $statement = $ilDB->manipulateF('
733  UPDATE frm_posts
734  SET pos_cens_com = %s,
735  pos_update = %s,
736  pos_cens = %s,
737  update_user = %s
738  WHERE pos_pk = %s',
739  array('text', 'timestamp', 'integer', 'integer', 'integer'),
740  array($message, date("Y-m-d H:i:s"), $cens, $_SESSION['AccountId'], $pos_pk));
741 
742  // Change news item accordingly
743  include_once("./Services/News/classes/class.ilNewsItem.php");
744  $news_id = ilNewsItem::getFirstNewsIdForContext($this->id,
745  "frm", $pos_pk, "pos");
746  if ($news_id > 0)
747  {
748  if ($cens > 0) // censor
749  {
750  $news_item = new ilNewsItem($news_id);
751  //$news_item->setTitle($subject);
752  $news_item->setContent(nl2br($this->prepareText($message, 0)));
753  $news_item->update();
754  }
755  else // revoke censorship
756  {
757  // get original message
758  $res = $ilDB->queryf('
759  SELECT * FROM frm_posts
760  WHERE pos_pk = %s',
761  array('integer'), array($pos_pk));
762 
763  $rec = $ilDB->fetchAssoc($res);
764 
765  $news_item = new ilNewsItem($news_id);
766  //$news_item->setTitle($subject);
767  $news_item->setContent(nl2br($this->prepareText($rec["pos_message"], 0)));
768  $news_item->update();
769  }
770  }
771 
772  return true;
773  }
< 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']
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.
prepareText($text, $edit=0, $quote_user='', $type='')
prepares given string public
+ Here is the call graph for this function:

◆ prepareText()

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

prepares given string public

Parameters
string
integer
Returns
string

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

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

Referenced by generatePost(), and postCensorship().

1764  {
1765  global $lng;
1766 
1767  if($type == 'export')
1768  {
1769  $this->replQuote1 = "<blockquote class=\"quote\"><hr size=\"1\" color=\"#000000\">";
1770  $this->replQuote2 = "<hr size=\"1\" color=\"#000000\"/></blockquote>";
1771  }
1772 
1773  if($edit == 1)
1774  {
1775  // add login name of quoted users
1776  $lname = ($quote_user != "")
1777  ? '="'.$quote_user.'"'
1778  : "";
1779 
1780  $text = "[quote$lname]".$text."[/quote]";
1781  }
1782  else
1783  {
1784  // check for quotation
1785  $startZ = substr_count ($text, "[quote"); // also count [quote="..."]
1786  $endZ = substr_count ($text, "[/quote]");
1787 
1788  if ($startZ > 0 || $endZ > 0)
1789  {
1790  // add missing opening and closing tags
1791  if ($startZ > $endZ)
1792  {
1793  $diff = $startZ - $endZ;
1794 
1795  for ($i = 0; $i < $diff; $i++)
1796  {
1797  if ($type == 'export') $text .= $this->txtQuote2;
1798  else $text .= "[/quote]";
1799  }
1800  }
1801  elseif ($startZ < $endZ)
1802  {
1803  $diff = $endZ - $startZ;
1804 
1805  for ($i = 0; $i < $diff; $i++)
1806  {
1807  if ($type == 'export') $text = $this->txtQuote1.$text;
1808  else $text = "[quote]".$text;
1809  }
1810  }
1811 
1812  if($edit == 0)
1813  {
1814  $ws= "[ \t\r\f\v\n]*";
1815 
1816  $text = eregi_replace("\[(quote$ws=$ws\"([^\"]*)\"$ws)\]",
1817  $this->replQuote1.'<div class="ilForumQuoteHead">'.$lng->txt("quote")." (\\2)".'</div>', $text);
1818 
1819  $text = str_replace("[quote]",
1820  $this->replQuote1.'<div class="ilForumQuoteHead">'.$lng->txt("quote").'</div>', $text);
1821 
1822  $text = str_replace("[/quote]", $this->replQuote2, $text);
1823  }
1824  }
1825  }
1826 
1827  if($type != 'export')
1828  {
1829  if($edit == 0)
1830  {
1831  $text = ilUtil::insertLatexImages($text, "<span class\=\"latex\">", "<\/span>");
1832  $text = ilUtil::insertLatexImages($text, "\[tex\]", "\[\/tex\]");
1833  }
1834 
1835  // workaround for preventing template engine
1836  // from hiding text that is enclosed
1837  // in curly brackets (e.g. "{a}")
1838  $text = str_replace("{", "&#123;", $text);
1839  $text = str_replace("}", "&#125;", $text);
1840  }
1841 
1842  return $text;
1843  }
static insertLatexImages($a_text, $a_start="\ex\, $a_end="\\tex\")
replace [text]...[/tex] tags with formula image code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendForumNotifications()

ilForum::sendForumNotifications (   $post_data)

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

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

2232  {
2233  global $ilDB, $ilAccess, $lng, $ilUser;
2234 
2235  include_once "Services/Mail/classes/class.ilMail.php";
2236  include_once './Services/User/classes/class.ilObjUser.php';
2237 
2238  // GET THREAD DATA
2239  $result = $ilDB->queryf('
2240  SELECT thr_subject FROM frm_threads
2241  WHERE thr_pk = %s',
2242  array('integer'),
2243  array($post_data['pos_thr_fk']));
2244 
2245  while($record = $ilDB->fetchAssoc($result))
2246  {
2247  $post_data['thr_subject'] = $record['thr_subject'];
2248  break;
2249  }
2250 
2251  // determine obj_id of the forum
2252  $obj_id = self::_lookupObjIdForForumId($post_data['pos_top_fk']);
2253 
2254  // GET AUTHOR OF NEW POST
2255  if($post_data['pos_usr_id'])
2256  {
2257  $post_data['pos_usr_name'] = ilObjUser::_lookupLogin($post_data['pos_usr_id']);
2258  }
2259  else if(strlen($post_data['pos_usr_alias']))
2260  {
2261  $post_data['pos_usr_name'] = $post_data['pos_usr_alias'].' ('.$lng->txt('frm_pseudonym').')';
2262  }
2263 
2264  if($post_data['pos_usr_name'] == '')
2265  {
2266  $post_data['pos_usr_name'] = $this->lng->txt('forums_anonymous');
2267  }
2268 
2269  // GET USERS WHO WANT TO BE INFORMED ABOUT NEW POSTS
2270  $res = $ilDB->queryf('
2271  SELECT frm_notification.user_id FROM frm_notification, frm_data
2272  WHERE frm_data.top_pk = %s
2273  AND frm_notification.frm_id = frm_data.top_frm_fk
2274  AND frm_notification.user_id <> %s
2275  GROUP BY frm_notification.user_id',
2276  array('integer', 'integer'),
2277  array($post_data['pos_top_fk'], $ilUser->getId()));
2278 
2279  // get all references of obj_id
2280  $frm_references = ilObject::_getAllReferences($obj_id);
2281 
2282  // save language of the current user
2283  global $lng;
2284  $userLanguage = $lng;
2285 
2286  // get attachments data
2287  $fileDataForum = new ilFileDataForum($obj_id, $post_data['pos_pk']);
2288  $filesOfPost = $fileDataForum->getFilesOfPost();
2289  $attachments = array();
2290  foreach($filesOfPost as $attachment)
2291  {
2292  $attachments[] = $attachment['name'];
2293  }
2294 
2295  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
2296  while($row = $ilDB->fetchAssoc($res))
2297  {
2298  // do rbac check before sending notification
2299  $send_mail = false;
2300  foreach((array)$frm_references as $ref_id)
2301  {
2302  if($ilAccess->checkAccessOfUser($row['user_id'], 'read', '', $ref_id))
2303  {
2304  $send_mail = true;
2305  break;
2306  }
2307  }
2308 
2309  if($send_mail)
2310  {
2311  $this->setLanguage(self::_getLanguageInstanceByUsrId($row['user_id']));
2312  $mail_obj->sendMail(
2313  ilObjUser::_lookupLogin($row["user_id"]), "", "",
2314  $this->formatNotificationSubject($post_data),
2315  $this->formatNotification($post_data, 0, $attachments, $row['user_id']),
2316  array(), array("system")
2317  );
2318  }
2319  }
2320 
2321  // reset language
2322  $this->setLanguage($userLanguage);
2323  }
$result
static _getAllReferences($a_id)
get all reference ids of object
Class Mail this class handles base functions for mail handling.
formatNotification($post_data, $cron=0, $attachments=array(), $user_id)
_lookupLogin($a_user_id)
lookup login
formatNotificationSubject($post_data)
global $ilUser
Definition: imgupload.php:15
$ref_id
Definition: sahs_server.php:39
This class handles all operations on files for the forum object.
setLanguage($lng)
+ Here is the call graph for this function:

◆ sendPostActivationNotification()

ilForum::sendPostActivationNotification (   $post_data)

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

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

Referenced by generatePost().

2372  {
2373  global $ilDB, $ilUser, $lng;
2374 
2375  if (is_array($moderators = $this->getModerators()))
2376  {
2377  // GET THREAD DATA
2378  $result = $ilDB->queryf('
2379  SELECT thr_subject FROM frm_threads
2380  WHERE thr_pk = %s',
2381  array('integer'),
2382  array($post_data['pos_thr_fk']));
2383 
2384  while($record = $ilDB->fetchAssoc($result))
2385  {
2386  $post_data['thr_subject'] = $record['thr_subject'];
2387  break;
2388  }
2389 
2390  // GET AUTHOR OF NEW POST
2391  if($post_data['pos_usr_id'])
2392  {
2393  $post_data['pos_usr_name'] = ilObjUser::_lookupLogin($post_data['pos_usr_id']);
2394  }
2395  else if(strlen($post_data['pos_usr_alias']))
2396  {
2397  $post_data['pos_usr_name'] = $post_data['pos_usr_alias'].' ('.$lng->txt('frm_pseudonym').')';
2398  }
2399 
2400  if($post_data['pos_usr_name'] == '')
2401  {
2402  $post_data['pos_usr_name'] = $this->lng->txt('forums_anonymous');
2403  }
2404 
2405  // save language of the current user
2406  global $lng;
2407  $userLanguage = $lng;
2408 
2409  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
2410  foreach($moderators as $moderator)
2411  {
2412  // set forum language instance for earch user
2413  $this->setLanguage(self::_getLanguageInstanceByUsrId($moderator));
2414  $subject = $this->formatNotificationSubject($post_data);
2415  $message = $this->formatPostActivationNotification($post_data, $moderator);
2416  $mail_obj->sendMail(
2417  ilObjUser::_lookupLogin($moderator), '', '',
2418  $subject,
2419  $message,
2420  array(), array("system")
2421  );
2422  }
2423 
2424  // reset language
2425  $this->setLanguage($userLanguage);
2426  }
2427  }
$result
Class Mail this class handles base functions for mail handling.
getModerators()
get all users assigned to local role il_frm_moderator_<frm_ref_id>
_lookupLogin($a_user_id)
lookup login
formatNotificationSubject($post_data)
formatPostActivationNotification($post_data, $user_id)
global $ilUser
Definition: imgupload.php:15
setLanguage($lng)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendThreadNotifications()

ilForum::sendThreadNotifications (   $post_data)

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

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

2140  {
2141  global $ilDB, $ilAccess, $lng;
2142 
2143  include_once "Services/Mail/classes/class.ilMail.php";
2144  include_once './Services/User/classes/class.ilObjUser.php';
2145 
2146  // GET THREAD DATA
2147  $result = $ilDB->queryf('
2148  SELECT thr_subject FROM frm_threads
2149  WHERE thr_pk = %s',
2150  array('integer'), array($post_data['pos_thr_fk']));
2151 
2152  while($record = $ilDB->fetchAssoc($result))
2153  {
2154  $post_data['thr_subject'] = $record['thr_subject'];
2155  break;
2156  }
2157 
2158  // determine obj_id of the forum
2159  $obj_id = self::_lookupObjIdForForumId($post_data['pos_top_fk']);
2160 
2161  // GET AUTHOR OF NEW POST
2162  if($post_data['pos_usr_id'])
2163  {
2164  $post_data['pos_usr_name'] = ilObjUser::_lookupLogin($post_data['pos_usr_id']);
2165  }
2166  else if(strlen($post_data['pos_usr_alias']))
2167  {
2168  $post_data['pos_usr_name'] = $post_data['pos_usr_alias'].' ('.$lng->txt('frm_pseudonym').')';
2169  }
2170 
2171  if($post_data['pos_usr_name'] == '')
2172  {
2173  $post_data['pos_usr_name'] = $this->lng->txt('forums_anonymous');
2174  }
2175 
2176  // GET USERS WHO WANT TO BE INFORMED ABOUT NEW POSTS
2177  $res = $ilDB->queryf('
2178  SELECT user_id FROM frm_notification
2179  WHERE thread_id = %s
2180  AND user_id <> %s',
2181  array('integer', 'integer'),
2182  array($post_data['pos_thr_fk'], $_SESSION['AccountId']));
2183 
2184  // get all references of obj_id
2185  $frm_references = ilObject::_getAllReferences($obj_id);
2186 
2187  // save language of the current user
2188  global $lng;
2189  $userLanguage = $lng;
2190 
2191  // get attachments data
2192  $fileDataForum = new ilFileDataForum($obj_id, $post_data['pos_pk']);
2193  $filesOfPost = $fileDataForum->getFilesOfPost();
2194 
2195  $attachments = array();
2196  foreach($filesOfPost as $attachment)
2197  {
2198  $attachments[] = $attachment['name'];
2199  }
2200 
2201  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
2202  while($row = $ilDB->fetchAssoc($res))
2203  {
2204  // do rbac check before sending notification
2205  $send_mail = false;
2206  foreach((array)$frm_references as $ref_id)
2207  {
2208  if($ilAccess->checkAccessOfUser($row['user_id'], 'read', '', $ref_id))
2209  {
2210  $send_mail = true;
2211  break;
2212  }
2213  }
2214 
2215  if($send_mail)
2216  {
2217  $this->setLanguage(self::_getLanguageInstanceByUsrId($row['user_id']));
2218  $mail_obj->sendMail(
2219  ilObjUser::_lookupLogin($row["user_id"]), "", "",
2220  $this->formatNotificationSubject($post_data),
2221  $this->formatNotification($post_data, 0, $attachments, $row['user_id']),
2222  array(), array("system")
2223  );
2224  }
2225  }
2226 
2227  // reset language
2228  $this->setLanguage($userLanguage);
2229  }
< 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']
$result
static _getAllReferences($a_id)
get all reference ids of object
Class Mail this class handles base functions for mail handling.
formatNotification($post_data, $cron=0, $attachments=array(), $user_id)
_lookupLogin($a_user_id)
lookup login
formatNotificationSubject($post_data)
$ref_id
Definition: sahs_server.php:39
This class handles all operations on files for the forum object.
setLanguage($lng)
+ Here is the call graph for this function:

◆ setDbTable()

ilForum::setDbTable (   $dbTable)

set database table

Parameters
string$dbTabledatabase table
See also
$dbTable User interface

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

References $dbTable.

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

◆ setForumId()

ilForum::setForumId (   $a_obj_id)

set object id which refers to ILIAS obj_id

Parameters
integerobject id 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  }
redirection script todo: (a better solution should control the processing via a xml file) ...

◆ setForumRefId()

ilForum::setForumRefId (   $a_ref_id)

set reference id which refers to ILIAS obj_id

Parameters
integerobject id 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  }
redirection script todo: (a better solution should control the processing via a xml file) ...

◆ setImportName()

ilForum::setImportName (   $a_import_name)

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

1960  {
1961  $this->import_name = $a_import_name;
1962  }

◆ setLanguage()

ilForum::setLanguage (   $lng)

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

References $lng.

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

82  {
83  $this->lng = $lng;
84  }
+ 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.

Referenced by __sendMessage(), and moveThreads().

235  {
236  $this->mdb2Query = $query_string;
237  $this->mdb2DataValue = $data_value;
238  $this->mdb2DataType = $data_type;
239 
240  return true;
241  }
+ 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 private

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

References $orderField.

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

◆ setPageHits()

ilForum::setPageHits (   $pageHits)

set number of max.

visible datasets

Parameters
integer$pageHits
See also
$pageHits User interface

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

References $pageHits.

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  }

◆ updateLastPostByObjId()

static ilForum::updateLastPostByObjId (   $a_obj_id)
static

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

Referenced by mergeThreads().

2572  {
2573  global $ilDB;
2574  // get latest post of forum and update last_post
2575  $ilDB->setLimit(1);
2576  $res2 = $ilDB->queryf('
2577  SELECT pos_top_fk, pos_thr_fk, pos_pk FROM frm_posts, frm_data
2578  WHERE pos_top_fk = top_pk
2579  AND top_frm_fk = %s
2580  ORDER BY pos_date DESC',
2581  array('integer'), array($a_obj_id));
2582 
2583  if ($res2->numRows() == 0)
2584  {
2585  $lastPost_top = "";
2586  }
2587  else
2588  {
2589  $z = 0;
2590 
2591  while ($selData = $ilDB->fetchAssoc($res2))
2592  {
2593  if ($z > 0)
2594  {
2595  break;
2596  }
2597 
2598  $lastPost_top = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
2599  $z ++;
2600  }
2601  }
2602 
2603  $ilDB->update('frm_data',
2604  array('top_last_post' => array('text', $lastPost_top)),
2605  array('top_frm_fk' => array('integer', $a_obj_id))
2606  );
2607 
2608  }
+ Here is the caller graph for this function:

◆ updateVisits()

ilForum::updateVisits (   $ID)

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

Parameters
integer

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

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

1730  {
1731 
1732  global $ilDB;
1733 
1734  $checkTime = time() - (60*60);
1735 
1736  if ($_SESSION["frm_visit_".$this->dbTable."_".$ID] < $checkTime)
1737  {
1738 
1739  $_SESSION["frm_visit_".$this->dbTable."_".$ID] = time();
1740  $query = 'UPDATE '.$this->dbTable.' SET visits = visits + 1 WHERE ';
1741 
1742  $data_type = array();
1743  $data_value = array();
1744 
1745  if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
1746  {
1747  $query .= $this->getMDB2Query();
1748  $data_type = $data_type + $this->getMDB2DataType();
1749  $data_value = $data_value + $this->getMDB2DataValue();
1750 
1751  $res = $ilDB->queryf($query, $data_type, $data_value);
1752  }
1753  }
1754  }
< 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']
getMDB2DataType()
get content of additional condition
getMDB2Query()
get content of additional condition
getMDB2DataValue()
/* get content of additional condition
+ 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.

◆ SORT_TITLE

const ilForum::SORT_TITLE = 1

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

Referenced by ilObjForumGUI\cloneWizardPageObject().


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