ILIAS  trunk Revision v11.0_alpha-1862-g4e205cb56d4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilForum Class Reference

Class Forum core functions for forum. More...

+ Collaboration diagram for ilForum:

Public Member Functions

 __construct ()
 
 setForumId (int $a_obj_id)
 
 setForumRefId (int $a_ref_id)
 
 getForumId ()
 
 getForumRefId ()
 
 setDbTable (string $dbTable)
 
 getDbTable ()
 
 setMDB2WhereCondition (string $query_string, array $data_type, array $data_value)
 
 getMDB2Query ()
 
 getMDB2DataValue ()
 
 getMDB2DataType ()
 
 setPageHits (int $pageHits)
 
 getPageHits ()
 
 getOneTopic ()
 
 getOneThread ()
 
 generateThread (ilForumTopic $thread, string $message, bool $notify, bool $notify_posts, bool $status=true, bool $withFirstVisibleEntry=true)
 
 moveThreads (array $thread_ids, ilObjForum $src_forum, int $target_obj_id)
 
 postCensorship (ilObjForum $forum, string $message, int $pos_pk, int $cens=0)
 
 deletePost ($postIdOrRecord, bool $raiseEvents=true)
 
 getAllThreads (int $a_topic_id, array $params=[], int $limit=0, int $offset=0)
 
 getNumberOfPublishedUserPostings (int $usr_id, bool $post_activation_required)
 
 getUserStatistics (bool $post_activation_required)
 
 getRootPostIdByThread (int $a_thread_id)
 
 getModerators ()
 
 countUserArticles (int $a_user_id)
 
 countActiveUserArticles (int $a_user_id)
 
 convertDate (string $date)
 
 addPostTree (int $a_tree_id, int $a_node_id=-1, string $a_date='')
 
 insertPostNode (int $a_node_id, int $a_parent_id, int $tree_id, string $a_date='')
 insert node under parent node More...
 
 getPostDepth (int $a_node_id, int $tree_id)
 
 getFirstPostNode (int $tree_id)
 
 getPostNode (int $post_id)
 
 fetchPostNodeData (stdClass $a_row)
 
 getSubPathIdsForNode (ilForumPost $post)
 
 deletePostTree (array $a_node)
 
 updateVisits (int $ID)
 
 prepareText (string $text, int $edit=0, string $quote_user='', string $type='')
 
 getImportName ()
 
 setImportName (string $a_import_name)
 
 enableForumNotification (int $user_id)
 
 disableForumNotification (int $user_id)
 
 isForumNotificationEnabled (int $user_id)
 
 isThreadNotificationEnabled (int $user_id, int $thread_id)
 
 mergeThreads (int $source_id, int $target_id)
 

Static Public Member Functions

static _getModerators (int $a_ref_id)
 
static _isModerator (int $a_ref_id, int $a_usr_id)
 
static getSortedThreadSubjects (int $a_obj_id, int $a_sort_mode=self::SORT_DATE)
 
static _lookupObjIdForForumId (int $a_for_id)
 

Data Fields

ilLanguage $lng
 
ilErrorHandling $error
 
ilDBInterface $db
 
ilObjUser $user
 
ilSetting $settings
 

Static Protected Attributes

static array $moderators_by_ref_id_map = []
 

Private Member Functions

 deletePostFiles (array $a_ids)
 

Private Attributes

const SORT_TITLE = 1
 
const SORT_DATE = 2
 
const DEFAULT_PAGE_HITS = 30
 
readonly ilAppEventHandler $event
 
string $dbTable
 
string $className = 'ilForum'
 
string $mdb2Query = ''
 
array $mdb2DataValue = []
 
array $mdb2DataType = []
 
string $txtQuote1 = "[quote]"
 
string $txtQuote2 = "[/quote]"
 
string $replQuote1 = '<blockquote class="ilForumQuote">'
 
string $replQuote2 = '</blockquote>'
 
int $pageHits = self::DEFAULT_PAGE_HITS
 
int $id
 
int $ref_id
 
string $import_name = ''
 

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 \

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

Constructor & Destructor Documentation

◆ __construct()

ilForum::__construct ( )

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

References $DIC, ILIAS\Repository\lng(), ILIAS\Repository\settings(), and ILIAS\Repository\user().

59  {
60  global $DIC;
61 
62  $this->error = $DIC['ilErr'];
63  $this->lng = $DIC->language();
64  $this->db = $DIC->database();
65  $this->user = $DIC->user();
66  $this->settings = $DIC->settings();
67  $this->event = $DIC->event();
68  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ _getModerators()

static ilForum::_getModerators ( int  $a_ref_id)
static
Returns
int[]

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

References $DIC, and ilObject\_lookupTitle().

Referenced by ilForumNotificationDataProvider\getPostActivationRecipients(), ilForumSettingsGUI\saveEventsForUser(), ilForumSettingsGUI\showMembers(), and ilForumSettingsGUI\updateUserNotifications().

1069  : array
1070  {
1071  global $DIC;
1072 
1073  $rbacreview = $DIC->rbac()->review();
1074 
1075  $role_arr = $rbacreview->getRolesOfRoleFolder($a_ref_id);
1076  foreach ($role_arr as $role_id) {
1077  if (ilObject::_lookupTitle($role_id) === 'il_frm_moderator_' . $a_ref_id) {
1078  return array_map('intval', $rbacreview->assignedUsers($role_id));
1079  }
1080  }
1081 
1082  return [];
1083  }
static _lookupTitle(int $obj_id)
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isModerator()

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

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

Referenced by ilObjForumGUI\renderDraftContent(), ilObjForumGUI\renderPostContent(), and ilForumExportGUI\renderPostHtml().

1085  : bool
1086  {
1087  if (!isset(self::$moderators_by_ref_id_map[$a_ref_id])) {
1088  self::$moderators_by_ref_id_map[$a_ref_id] = self::_getModerators($a_ref_id);
1089  }
1090 
1091  return in_array($a_usr_id, self::$moderators_by_ref_id_map[$a_ref_id], true);
1092  }
+ Here is the caller graph for this function:

◆ _lookupObjIdForForumId()

static ilForum::_lookupObjIdForForumId ( int  $a_for_id)
static

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

References $DIC, and $res.

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

1646  : int
1647  {
1648  global $DIC;
1649 
1650  $res = $DIC->database()->queryF('SELECT top_frm_fk FROM frm_data WHERE top_pk = %s', ['integer'], [$a_for_id]);
1651  if ($row = $DIC->database()->fetchAssoc($res)) {
1652  return (int) $row['top_frm_fk'];
1653  }
1654 
1655  return 0;
1656  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ addPostTree()

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

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

Referenced by getOneThread().

1130  : bool
1131  {
1132  $a_date = $a_date ?: date('Y-m-d H:i:s');
1133 
1134  if ($a_node_id <= 0) {
1135  $a_node_id = $a_tree_id;
1136  }
1137 
1138  $nextId = $this->db->nextId('frm_posts_tree');
1139 
1140  $this->db->manipulateF(
1141  '
1142  INSERT INTO frm_posts_tree
1143  ( fpt_pk,
1144  thr_fk,
1145  pos_fk,
1146  parent_pos,
1147  lft,
1148  rgt,
1149  depth,
1150  fpt_date
1151  )
1152  VALUES(%s, %s, %s, %s, %s, %s, %s, %s )',
1153  ['integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'],
1154  [$nextId, $a_tree_id, $a_node_id, 0, 1, 2, 1, $a_date]
1155  );
1156 
1157  return true;
1158  }
+ Here is the caller graph for this function:

◆ convertDate()

ilForum::convertDate ( string  $date)

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

References ilDatePresentation\formatDate(), and IL_CAL_DATETIME.

1125  : string
1126  {
1128  }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:

◆ countActiveUserArticles()

ilForum::countActiveUserArticles ( int  $a_user_id)

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

References $res, getForumId(), and ILIAS\Repository\user().

1109  : int
1110  {
1111  $res = $this->db->queryF(
1112  'SELECT * FROM frm_data
1113  INNER JOIN frm_posts ON pos_top_fk = top_pk
1114  INNER JOIN frm_posts_tree tree1 ON tree1.pos_fk = frm_posts.pos_pk AND tree1.parent_pos != 0
1115  WHERE top_frm_fk = %s
1116  AND (pos_status = %s OR (pos_status = %s AND pos_author_id = %s))
1117  AND pos_author_id = %s',
1118  ['integer', 'integer', 'integer', 'integer', 'integer'],
1119  [$this->getForumId(), 1, 0, $this->user->getId(), $a_user_id]
1120  );
1121 
1122  return $res->numRows();
1123  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ countUserArticles()

ilForum::countUserArticles ( int  $a_user_id)

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

References $res, and getForumId().

1094  : int
1095  {
1096  $res = $this->db->queryF(
1097  'SELECT * FROM frm_data
1098  INNER JOIN frm_posts ON pos_top_fk = top_pk
1099  INNER JOIN frm_posts_tree tree1 ON tree1.pos_fk = frm_posts.pos_pk AND tree1.parent_pos != 0
1100  WHERE top_frm_fk = %s
1101  AND pos_author_id = %s',
1102  ['integer', 'integer'],
1103  [$this->getForumId(), $a_user_id]
1104  );
1105 
1106  return $res->numRows();
1107  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ deletePost()

ilForum::deletePost (   $postIdOrRecord,
bool  $raiseEvents = true 
)
Parameters
int|array<string,mixed>$postIdOrRecord

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

References $post, $res, ilObjForum\_deleteReadEntries(), ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), deletePostFiles(), deletePostTree(), ilNewsItem\getFirstNewsIdForContext(), getForumId(), getForumRefId(), getPostNode(), getSubPathIdsForNode(), and ILIAS\Repository\int().

Referenced by mergeThreads().

531  : int
532  {
533  $p_node = $postIdOrRecord;
534  if (is_numeric($postIdOrRecord)) {
535  $p_node = $this->getPostNode($postIdOrRecord);
536  }
537 
538  $post = new ilForumPost((int) $p_node['pos_pk']);
539  if ($raiseEvents) {
540  $is_deleted_thread = ($post->getParentId() == 0) ? true : false;
541  $num_visible_active_posts = 0;
542  if ($is_deleted_thread) {
543  $query = '
544  SELECT COUNT(*) AS cnt
545  FROM frm_posts
546  INNER JOIN frm_posts_tree ON pos_pk = pos_fk
547  WHERE frm_posts_tree.parent_pos != 0
548  AND pos_thr_fk = ' . $this->db->quote($post->getThreadId(), 'integer') . '
549  AND pos_status = ' . $this->db->quote(1, 'integer');
550  $res = $this->db->query($query);
551  $row = $this->db->fetchAssoc($res);
552  $num_visible_active_posts = (int) ($row['cnt'] ?? 0);
553  }
554 
555  $this->event->raise(
556  'components/ILIAS/Forum',
557  'beforePostDeletion',
558  [
559  'obj_id' => $this->getForumId(),
560  'ref_id' => $this->getForumRefId(),
561  'post' => $post,
562  'thread_deleted' => $is_deleted_thread,
563  'num_visible_active_posts' => $num_visible_active_posts
564  ]
565  );
566  }
567 
568  $this->deletePostFiles(array_merge(
569  $this->getSubPathIdsForNode($post),
570  [$post->getId()]
571  ));
572 
573  $affected_user_ids[] = $post->getPosAuthorId();
574  $deleted_post_ids = $this->deletePostTree($p_node);
575 
576  $obj_history = new ilForumDraftsHistory();
577  $obj_history->deleteHistoryByPostIds($deleted_post_ids);
578 
579  $obj_draft = new ilForumPostDraft();
580  $obj_draft->deleteDraftsByPostIds($deleted_post_ids);
581 
582  foreach ($deleted_post_ids as $post_id) {
584  }
585 
586  $dead_pos = count($deleted_post_ids);
587  $dead_thr = 0;
588 
589  if ((int) $post->getParentId() === 0) {
590  $dead_thr = $post->getThreadId();
591 
592  $this->db->manipulateF('DELETE FROM frm_threads WHERE thr_pk = %s', ['integer'], [$dead_thr]);
593  $this->db->manipulateF(
594  'UPDATE frm_data SET top_num_threads = top_num_threads - 1 WHERE top_frm_fk = %s',
595  ['integer'],
596  [$this->id]
597  );
598 
599  $posset = $this->db->queryF('SELECT * FROM frm_posts WHERE pos_thr_fk = %s', ['integer'], [$dead_thr]);
600  while ($posrec = $this->db->fetchAssoc($posset)) {
602  $this->id,
603  'frm',
604  (int) $posrec['pos_pk'],
605  'pos'
606  );
607  if ($news_id > 0) {
608  $news_item = new ilNewsItem($news_id);
609  $news_item->delete();
610  }
611 
612  try {
613  $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', (int) $posrec['pos_pk']);
614  foreach ($mobs as $mob) {
615  if (ilObjMediaObject::_exists($mob)) {
616  ilObjMediaObject::_removeUsage($mob, 'frm:html', (int) $posrec['pos_pk']);
617  $mob_obj = new ilObjMediaObject($mob);
618  $mob_obj->delete();
619  }
620  }
621  } catch (Exception) {
622  }
623  $affected_user_ids[] = (int) $posrec['pos_author_id'];
624  }
625 
626  $this->db->manipulateF('DELETE FROM frm_posts WHERE pos_thr_fk = %s', ['integer'], [$post->getThreadId()]);
627  } else {
628  for ($i = 0; $i < $dead_pos; $i++) {
629  $this->db->manipulateF('DELETE FROM frm_posts WHERE pos_pk = %s', ['integer'], [$deleted_post_ids[$i]]);
630 
632  $this->id,
633  'frm',
634  $deleted_post_ids[$i],
635  'pos'
636  );
637  if ($news_id > 0) {
638  $news_item = new ilNewsItem($news_id);
639  $news_item->delete();
640  }
641 
642  try {
643  $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $deleted_post_ids[$i]);
644  foreach ($mobs as $mob) {
645  if (ilObjMediaObject::_exists($mob)) {
646  ilObjMediaObject::_removeUsage($mob, 'frm:html', $deleted_post_ids[$i]);
647  $mob_obj = new ilObjMediaObject($mob);
648  $mob_obj->delete();
649  }
650  }
651  } catch (Exception) {
652  }
653  }
654 
655  $this->db->manipulateF(
656  'UPDATE frm_threads SET thr_num_posts = thr_num_posts - %s WHERE thr_pk = %s',
657  ['integer', 'integer'],
658  [$dead_pos, $post->getTreeId()]
659  );
660 
661  $res1 = $this->db->queryF(
662  'SELECT * FROM frm_posts WHERE pos_thr_fk = %s ORDER BY pos_date DESC',
663  ['integer'],
664  [$post->getTreeId()]
665  );
666 
667  $lastPost_thr = '';
668  if ($res1->numRows() > 0) {
669  $z = 0;
670 
671  while ($selData = $this->db->fetchAssoc($res1)) {
672  if ($z > 0) {
673  break;
674  }
675 
676  $lastPost_thr = $selData['pos_top_fk'] . '#' . $selData['pos_thr_fk'] . '#' . $selData['pos_pk'];
677  $z++;
678  }
679  }
680 
681  $this->db->manipulateF(
682  'UPDATE frm_threads SET thr_last_post = %s WHERE thr_pk = %s',
683  ['text', 'integer'],
684  [$lastPost_thr, $post->getTreeId()]
685  );
686  }
687 
688  $this->db->manipulateF(
689  'UPDATE frm_data SET top_num_posts = top_num_posts - %s WHERE top_frm_fk = %s',
690  ['integer', 'integer'],
691  [$dead_pos, $this->id]
692  );
693 
694  $res2 = $this->db->queryF(
695  'SELECT * FROM frm_posts, frm_data WHERE pos_top_fk = top_pk AND top_frm_fk = %s ORDER BY pos_date DESC',
696  ['integer'],
697  [$this->id]
698  );
699 
700  $lastPost_top = '';
701  if ($res2->numRows() > 0) {
702  $z = 0;
703 
704  while ($selData = $this->db->fetchAssoc($res2)) {
705  if ($z > 0) {
706  break;
707  }
708 
709  $lastPost_top = $selData['pos_top_fk'] . '#' . $selData['pos_thr_fk'] . '#' . $selData['pos_pk'];
710  $z++;
711  }
712  }
713 
714  $this->db->manipulateF(
715  'UPDATE frm_data SET top_last_post = %s WHERE top_frm_fk = %s',
716  ['text', 'integer'],
717  [$lastPost_top, $this->id]
718  );
719 
720  if ($raiseEvents) {
721  $this->event->raise(
722  'components/ILIAS/Forum',
723  'afterPostDeletion',
724  [
725  'obj_id' => $this->getForumId(),
726  'ref_id' => $this->getForumRefId(),
727  'user_ids' => $affected_user_ids
728  ]
729  );
730  }
731 
732  return $dead_thr;
733  }
$res
Definition: ltiservices.php:66
getPostNode(int $post_id)
deletePostFiles(array $a_ids)
static _deleteReadEntries(int $a_post_id)
Class ilForumDraftHistory.
getSubPathIdsForNode(ilForumPost $post)
static _exists(int $id, bool $reference=false, ?string $type=null)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
A news item can be created by different sources.
static getFirstNewsIdForContext(int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
$post
Definition: ltitoken.php:46
deletePostTree(array $a_node)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deletePostFiles()

ilForum::deletePostFiles ( array  $a_ids)
private
Parameters
int[]$a_ids

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

References getForumId().

Referenced by deletePost().

1503  : void
1504  {
1505  foreach ($a_ids as $pos_id) {
1506  $forumFiles = new ilFileDataForum($this->getForumId(), $pos_id);
1507  $files = $forumFiles->getFilesOfPost();
1508  foreach ($files as $file) {
1509  $forumFiles->unlinkFile($file['name']);
1510  }
1511  }
1512  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deletePostTree()

ilForum::deletePostTree ( array  $a_node)
Returns
int[] An list of deleted post ids

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

References $res, and ILIAS\Repository\int().

Referenced by deletePost().

1349  : array
1350  {
1351  $res = $this->db->queryF(
1352  'SELECT lft, rgt FROM frm_posts_tree WHERE thr_fk = %s AND pos_fk = %s AND parent_pos = %s',
1353  ['integer', 'integer', 'integer'],
1354  [$a_node['tree'], $a_node['pos_pk'], $a_node['parent']]
1355  );
1356 
1357  while ($row = $this->db->fetchObject($res)) {
1358  $a_node['lft'] = (int) $row->lft;
1359  $a_node['rgt'] = (int) $row->rgt;
1360  }
1361 
1362  $diff = $a_node['rgt'] - $a_node['lft'] + 1;
1363 
1364  $res = $this->db->queryF(
1365  'SELECT pos_fk FROM frm_posts_tree WHERE lft BETWEEN %s AND %s AND thr_fk = %s',
1366  ['integer', 'integer', 'integer'],
1367  [$a_node['lft'], $a_node['rgt'], $a_node['tree']]
1368  );
1369 
1370  $deleted_post_ids = [];
1371  while ($treeData = $this->db->fetchAssoc($res)) {
1372  $deleted_post_ids[] = (int) $treeData['pos_fk'];
1373  }
1374 
1375  $this->db->manipulateF(
1376  'DELETE FROM frm_posts_tree WHERE lft BETWEEN %s AND %s AND thr_fk = %s',
1377  ['integer', 'integer', 'integer'],
1378  [$a_node['lft'], $a_node['rgt'], $a_node['tree']]
1379  );
1380 
1381  $this->db->manipulateF(
1382  '
1383  UPDATE frm_posts_tree
1384  SET lft = CASE
1385  WHEN lft > %s
1386  THEN lft - %s
1387  ELSE lft
1388  END,
1389  rgt = CASE
1390  WHEN rgt > %s
1391  THEN rgt - %s
1392  ELSE rgt
1393  END
1394  WHERE thr_fk = %s',
1395  ['integer', 'integer', 'integer', 'integer', 'integer'],
1396  [$a_node['lft'], $diff, $a_node['lft'], $diff, $a_node['tree']]
1397  );
1398 
1399  return $deleted_post_ids;
1400  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ disableForumNotification()

ilForum::disableForumNotification ( int  $user_id)

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

1579  : bool
1580  {
1581  $this->db->manipulateF(
1582  'DELETE FROM frm_notification WHERE user_id = %s AND frm_id = %s',
1583  ['integer', 'integer'],
1584  [$user_id, $this->id]
1585  );
1586 
1587  return true;
1588  }

◆ enableForumNotification()

ilForum::enableForumNotification ( int  $user_id)

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

References $res, $user_id, and isForumNotificationEnabled().

1524  : bool
1525  {
1526  if (!$this->isForumNotificationEnabled($user_id)) {
1527  /* Remove all notifications of threads that belong to the forum */
1528  $res = $this->db->queryF(
1529  '
1530  SELECT frm_notification.thread_id FROM frm_data, frm_notification, frm_threads
1531  WHERE frm_notification.user_id = %s
1532  AND frm_notification.thread_id = frm_threads.thr_pk
1533  AND frm_threads.thr_top_fk = frm_data.top_pk
1534  AND frm_data.top_frm_fk = %s
1535  GROUP BY frm_notification.thread_id',
1536  ['integer', 'integer'],
1537  [$user_id, $this->id]
1538  );
1539 
1540  if ($res->numRows() > 0) {
1541  $thread_data = [];
1542  $thread_data_types = [];
1543 
1544  $query = ' DELETE FROM frm_notification WHERE user_id = %s AND thread_id IN (';
1545  $thread_data[] = $user_id;
1546  $thread_data_types[] = 'integer';
1547 
1548  $counter = 1;
1549  while ($row = $this->db->fetchAssoc($res)) {
1550  if ($counter < $res->numRows()) {
1551  $query .= '%s, ';
1552  $thread_data[] = $row['thread_id'];
1553  $thread_data_types[] = 'integer';
1554  }
1555 
1556  if ($counter === $res->numRows()) {
1557  $query .= '%s)';
1558  $thread_data[] = $row['thread_id'];
1559  $thread_data_types[] = 'integer';
1560  }
1561  $counter++;
1562  }
1563 
1564  $this->db->manipulateF($query, $thread_data_types, $thread_data);
1565  }
1566 
1567  /* Insert forum notification */
1568  $nextId = $this->db->nextId('frm_notification');
1569  $this->db->manipulateF(
1570  'INSERT INTO frm_notification (notification_id, user_id, frm_id) VALUES(%s, %s, %s)',
1571  ['integer', 'integer', 'integer'],
1572  [$nextId, $user_id, $this->id]
1573  );
1574  }
1575 
1576  return true;
1577  }
isForumNotificationEnabled(int $user_id)
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ fetchPostNodeData()

ilForum::fetchPostNodeData ( stdClass  $a_row)
Returns
array{type: string, pos_pk: int, child: int, author: int, alias: string, title: mixed, loginname: string, message: string, subject: string, pos_cens_com: string, pos_cens: int, date: mixed, create_date: mixed, update: mixed, update_user: int, tree: int, parent: int, lft: int, rgt: int, depth: int, id: int, notify: int, import_name: mixed, pos_status: int}

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

References ilObject\_exists(), ILIAS\Repository\int(), and ILIAS\Repository\lng().

Referenced by getFirstPostNode(), and getPostNode().

1280  : array
1281  {
1282  $fullname = '';
1283  $loginname = '';
1284 
1285  if (ilObject::_exists((int) $a_row->pos_display_user_id)) {
1286  $tmp_user = new ilObjUser((int) $a_row->pos_display_user_id);
1287  $fullname = $tmp_user->getFullname();
1288  $loginname = $tmp_user->getLogin();
1289  }
1290 
1291  if ($fullname === '') {
1292  $fullname = $this->lng->txt('unknown');
1293  if ($a_row->import_name) {
1294  $fullname = $a_row->import_name;
1295  }
1296  }
1297 
1298  return [
1299  'type' => 'post',
1300  'pos_pk' => (int) $a_row->pos_pk,
1301  'pos_thr_fk' => (int) $a_row->pos_thr_fk,
1302  'child' => (int) $a_row->pos_pk,
1303  'author' => (int) $a_row->pos_display_user_id,
1304  'alias' => (string) $a_row->pos_usr_alias,
1305  'title' => $fullname,
1306  'loginname' => $loginname,
1307  'message' => (string) $a_row->pos_message,
1308  'subject' => (string) $a_row->pos_subject,
1309  'pos_cens_com' => (string) $a_row->pos_cens_com,
1310  'pos_cens' => (int) $a_row->pos_cens,
1311  'date' => $a_row->fpt_date,
1312  'create_date' => $a_row->pos_date,
1313  'update' => $a_row->pos_update,
1314  'update_user' => (int) $a_row->update_user,
1315  'tree' => (int) $a_row->thr_fk,
1316  'parent' => (int) $a_row->parent_pos,
1317  'lft' => (int) $a_row->lft,
1318  'rgt' => (int) $a_row->rgt,
1319  'depth' => (int) $a_row->depth,
1320  'id' => (int) $a_row->fpt_pk,
1321  'notify' => (int) $a_row->notify,
1322  'import_name' => $a_row->import_name,
1323  'pos_status' => (int) $a_row->pos_status
1324  ];
1325  }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateThread()

ilForum::generateThread ( ilForumTopic  $thread,
string  $message,
bool  $notify,
bool  $notify_posts,
bool  $status = true,
bool  $withFirstVisibleEntry = true 
)

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

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

294  : int {
295  if (!$thread->getCreateDate()) {
296  $thread->setCreateDate(date('Y-m-d H:i:s'));
297  }
298 
299  $thread->setImportName($this->getImportName());
300  $thread->insert();
301 
302  if ($notify_posts) {
303  $thread->enableNotification($thread->getThrAuthorId());
304  }
305 
306  $this->db->manipulateF(
307  'UPDATE frm_data SET top_num_threads = top_num_threads + 1 WHERE top_pk = %s',
308  ['integer'],
309  [$thread->getForumId()]
310  );
311 
312  $rootNodeId = $this->generatePost(
313  $thread->getForumId(),
314  $thread->getId(),
315  $thread->getThrAuthorId(),
316  $thread->getDisplayUserId(),
317  '',
318  0,
319  false,
320  $thread->getSubject(),
321  $thread->getUserAlias(),
322  $thread->getCreateDate(),
323  true,
324  false
325  );
326 
327  if (!$withFirstVisibleEntry) {
328  return $rootNodeId;
329  }
330 
331  return $this->generatePost(
332  $thread->getForumId(),
333  $thread->getId(),
334  $thread->getThrAuthorId(),
335  $thread->getDisplayUserId(),
336  $message,
337  $rootNodeId,
338  $notify,
339  $thread->getSubject(),
340  $thread->getUserAlias(),
341  $thread->getCreateDate(),
342  $status,
343  false
344  );
345  }
setCreateDate(?string $a_createdate)
enableNotification(int $a_user_id)
setImportName(?string $a_import_name)
bool $notify
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:

◆ getAllThreads()

ilForum::getAllThreads ( int  $a_topic_id,
array  $params = [],
int  $limit = 0,
int  $offset = 0 
)
Returns
array{cnt: int, items: array<int, ilForumTopic>}

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

References $data, $params, $res, $user_id, getForumId(), ilForumProperties\getInstance(), ILIAS\Repository\int(), and ILIAS\Repository\user().

Referenced by ILIAS\Forum\Thread\ForumThreadTableSessionStorage\__construct().

738  : array
739  {
740  $frm_props = ilForumProperties::getInstance($this->getForumId());
741  $is_post_activation_enabled = $frm_props->isPostActivationEnabled();
742 
743  $user_id = $this->user->getId();
744 
745  $excluded_ids_condition = '';
746  if (isset($params['excluded_ids']) && is_array($params['excluded_ids']) && $params['excluded_ids']) {
747  $excluded_ids_condition = ' AND ' . $this->db->in('thr_pk', $params['excluded_ids'], true, 'integer') . ' ';
748  }
749 
750  if (!isset($params['order_column']) || !in_array(
751  strtolower($params['order_column']),
752  ['lp_date', 'rating', 'thr_subject', 'num_posts', 'num_visit']
753  )) {
754  $params['order_column'] = 'post_date';
755  }
756  if (!isset($params['order_direction']) || !in_array(strtolower($params['order_direction']), ['asc', 'desc'])) {
757  $params['order_direction'] = 'desc';
758  }
759 
760  $cnt_active_pos_query = '';
761  $cnt_join_type = 'LEFT';
762  if ($is_post_activation_enabled && !$params['is_moderator']) {
763  $cnt_active_pos_query = " AND (pos_status = {$this->db->quote(1, 'integer')} OR pos_author_id = {$this->db->quote($user_id, 'integer')}) ";
764  $cnt_join_type = "INNER";
765  }
766  $query =
767  "SELECT COUNT(DISTINCT(thr_pk)) cnt
768  FROM frm_threads
769  $cnt_join_type JOIN frm_posts
770  ON pos_thr_fk = thr_pk $cnt_active_pos_query
771  WHERE thr_top_fk = %s $excluded_ids_condition
772  ";
773  $res = $this->db->queryF($query, ['integer'], [$a_topic_id]);
774  $cntData = $this->db->fetchAssoc($res);
775  $cnt = (int) $cntData['cnt'];
776 
777  $active_query = '';
778  $having = '';
779  if ($is_post_activation_enabled && !$params['is_moderator']) {
780  $active_query = ' AND (pos_status = %s OR pos_author_id = %s) ';
781  $having = ' HAVING num_posts > 0';
782  }
783 
784  $threads = [];
785  $data = [];
786  $data_types = [];
787 
788  $optional_fields = '';
789  if ($frm_props->isIsThreadRatingEnabled()) {
790  $optional_fields = ', avg_rating';
791  }
792 
793  $additional_sort = '';
794 
795  if ($params['order_column'] === 'thr_subject') {
796  $dynamic_columns = [', thr_subject ' . $params['order_direction']];
797  } elseif ($params['order_column'] === 'num_posts') {
798  $dynamic_columns = [', num_posts ' . $params['order_direction']];
799  } elseif ($params['order_column'] === 'num_visit') {
800  $dynamic_columns = [', visits ' . $params['order_direction']];
801  } else {
802  $dynamic_columns = [', post_date ' . $params['order_direction']];
803  }
804 
805  if ($frm_props->isIsThreadRatingEnabled()) {
806  $dynamic_columns[] = ' ,avg_rating ' . $params['order_direction'];
807  }
808  if ('rating' === strtolower($params['order_column'])) {
809  $dynamic_columns = array_reverse($dynamic_columns);
810  }
811  $additional_sort .= implode(' ', $dynamic_columns);
812 
813 
814  if (!$this->user->isAnonymous()) {
815  $query = "SELECT
816  (CASE WHEN COUNT(DISTINCT(notification_id)) > 0 THEN 1 ELSE 0 END) usr_notification_is_enabled,
817  MAX(pos_date) post_date,
818  SUM(tree1.parent_pos != 0) num_posts,
819  SUM(tree1.parent_pos != 0) - SUM(tree1.parent_pos != 0 AND postread.post_id IS NOT NULL) num_unread_posts, ";
820 
821  $query .= " thr_pk, thr_top_fk, thr_subject, thr_author_id, thr_display_user_id, thr_usr_alias, thr_num_posts, thr_last_post, thr_date, thr_update, visits, frm_threads.import_name, is_sticky, is_closed
822  $optional_fields
823  FROM frm_threads
824 
825  LEFT JOIN frm_notification
826  ON frm_notification.thread_id = thr_pk
827  AND frm_notification.user_id = %s
828 
829  LEFT JOIN frm_posts
830  ON pos_thr_fk = thr_pk $active_query
831  LEFT JOIN frm_posts_tree tree1
832  ON tree1.pos_fk = frm_posts.pos_pk
833  LEFT JOIN frm_user_read postread
834  ON postread.post_id = pos_pk
835  AND postread.usr_id = %s";
836 
837  $query .= " WHERE thr_top_fk = %s
838  $excluded_ids_condition
839  GROUP BY thr_pk, thr_top_fk, thr_subject, thr_author_id, thr_display_user_id, thr_usr_alias, thr_num_posts, thr_last_post, thr_date, thr_update, visits, frm_threads.import_name, is_sticky, is_closed
840  $optional_fields
841  $having
842  ORDER BY is_sticky DESC $additional_sort, thr_date DESC";
843 
844 
845  $data_types[] = 'integer';
846  if ($is_post_activation_enabled && !$params['is_moderator']) {
847  $data_types[] = 'integer';
848  $data_types[] = 'integer';
849  }
850  $data_types[] = 'integer';
851  $data_types[] = 'integer';
852 
853 
854  $data[] = $user_id;
855  if ($is_post_activation_enabled && !$params['is_moderator']) {
856  $data[] = 1;
857  $data[] = $user_id;
858  }
859  $data[] = $user_id;
860  } else {
861  $query = "SELECT
862  0 usr_notification_is_enabled,
863  MAX(pos_date) post_date,
864  COUNT(DISTINCT(tree1.pos_fk)) num_posts,
865  COUNT(DISTINCT(tree1.pos_fk)) num_unread_posts,
866  thr_pk, thr_top_fk, thr_subject, thr_author_id, thr_display_user_id, thr_usr_alias, thr_num_posts, thr_last_post, thr_date, thr_update, visits, frm_threads.import_name, is_sticky, is_closed
867  $optional_fields
868  FROM frm_threads
869 
870  LEFT JOIN frm_posts
871  ON pos_thr_fk = thr_pk $active_query
872  LEFT JOIN frm_posts_tree tree1
873  ON tree1.pos_fk = frm_posts.pos_pk AND tree1.parent_pos != 0
874  ";
875 
876  $query .= " WHERE thr_top_fk = %s
877  $excluded_ids_condition
878  GROUP BY thr_pk, thr_top_fk, thr_subject, thr_author_id, thr_display_user_id, thr_usr_alias, thr_num_posts, thr_last_post, thr_date, thr_update, visits, frm_threads.import_name, is_sticky, is_closed
879  $optional_fields
880  $having
881  ORDER BY is_sticky DESC $additional_sort, thr_date DESC";
882 
883  if ($is_post_activation_enabled && !$params['is_moderator']) {
884  $data_types[] = 'integer';
885  $data_types[] = 'integer';
886  }
887  $data_types[] = 'integer';
888  if ($is_post_activation_enabled && !$params['is_moderator']) {
889  $data[] = 1;
890  $data[] = $user_id;
891  }
892  }
893  $data[] = $a_topic_id;
894 
895  if ($limit || $offset) {
896  $this->db->setLimit($limit, $offset);
897  }
898 
899  $threadIds = [];
900  $res = $this->db->queryF($query, $data_types, $data);
901  while ($row = $this->db->fetchAssoc($res)) {
902  $thread = new ilForumTopic((int) $row['thr_pk'], (bool) $params['is_moderator'], true);
903  $thread->assignData($row);
904  $threads[(int) $row['thr_pk']] = $thread;
905  $threadIds[] = (int) $row['thr_pk'];
906  }
907 
908  $inner_last_active_post_condition = '';
909  if ($is_post_activation_enabled && !$params['is_moderator']) {
910  $inner_last_active_post_condition = sprintf(
911  ' AND (iposts.pos_status = %s OR (iposts.pos_status = %s AND iposts.pos_author_id = %s)) ',
912  $this->db->quote(1, 'integer'),
913  $this->db->quote(0, 'integer'),
914  $this->db->quote($this->user->getId(), 'integer')
915  );
916  }
917 
918  $post_res = $this->db->query(
919  'SELECT frm_posts.*
920  FROM frm_posts
921  INNER JOIN (
922  SELECT pos_thr_fk, MAX(iposts.pos_date) i_pos_date
923  FROM frm_posts iposts
924  WHERE ' . $this->db->in('iposts.pos_thr_fk', $threadIds, false, 'integer') . '
925  ' . $inner_last_active_post_condition . '
926  GROUP BY pos_thr_fk
927  ) opost ON frm_posts.pos_thr_fk = opost.pos_thr_fk AND frm_posts.pos_date = opost.i_pos_date'
928  );
929  while ($post_row = $this->db->fetchAssoc($post_res)) {
930  $tmp_obj = new ilForumPost((int) $post_row['pos_pk'], (bool) $params['is_moderator'], true);
931  $tmp_obj->setPosAuthorId((int) $post_row['pos_author_id']);
932  $tmp_obj->setDisplayUserId((int) $post_row['pos_display_user_id']);
933  $tmp_obj->setUserAlias((string) $post_row['pos_usr_alias']);
934  $tmp_obj->setImportName((string) $post_row['import_name']);
935  $tmp_obj->setId((int) $post_row['pos_pk']);
936  $tmp_obj->setCreateDate((string) $post_row['pos_date']);
937 
938  $threads[(int) $post_row['pos_thr_fk']]->setLastPostForThreadOverview($tmp_obj);
939  }
940 
941  return [
942  'items' => $threads,
943  'cnt' => $cnt
944  ];
945  }
$res
Definition: ltiservices.php:66
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
static getInstance(int $a_obj_id=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDbTable()

ilForum::getDbTable ( )

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

References $dbTable.

99  : string
100  {
101  return $this->dbTable;
102  }
string $dbTable

◆ getFirstPostNode()

ilForum::getFirstPostNode ( int  $tree_id)

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

References $res, fetchPostNodeData(), and null.

1247  : array
1248  {
1249  $res = $this->db->queryF(
1250  'SELECT * FROM frm_posts, frm_posts_tree WHERE pos_pk = pos_fk AND parent_pos = %s AND thr_fk = %s',
1251  ['integer', 'integer'],
1252  [0, $tree_id]
1253  );
1254 
1255  if (($row = $this->db->fetchObject($res)) !== null) {
1256  return $this->fetchPostNodeData($row);
1257  }
1258 
1259  return [];
1260  }
$res
Definition: ltiservices.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
fetchPostNodeData(stdClass $a_row)
+ Here is the call graph for this function:

◆ getForumId()

ilForum::getForumId ( )

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

References $id.

Referenced by countActiveUserArticles(), countUserArticles(), deletePost(), deletePostFiles(), getAllThreads(), getNumberOfPublishedUserPostings(), getOneThread(), getUserStatistics(), and mergeThreads().

80  : int
81  {
82  return $this->id;
83  }
+ Here is the caller graph for this function:

◆ getForumRefId()

ilForum::getForumRefId ( )

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

References $ref_id.

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

85  : int
86  {
87  return $this->ref_id;
88  }
+ Here is the caller graph for this function:

◆ getImportName()

ilForum::getImportName ( )

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

References $import_name.

Referenced by generateThread(), and getOneThread().

1514  : string
1515  {
1516  return $this->import_name;
1517  }
string $import_name
+ Here is the caller graph for this function:

◆ getMDB2DataType()

ilForum::getMDB2DataType ( )

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

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

123  : array
124  {
125  return $this->mdb2DataType ?: [];
126  }
+ Here is the caller graph for this function:

◆ getMDB2DataValue()

ilForum::getMDB2DataValue ( )

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

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

118  : array
119  {
120  return $this->mdb2DataValue ?: [];
121  }
+ Here is the caller graph for this function:

◆ getMDB2Query()

ilForum::getMDB2Query ( )

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

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

113  : string
114  {
115  return $this->mdb2Query ?: '';
116  }
+ Here is the caller graph for this function:

◆ getModerators()

ilForum::getModerators ( )
Returns
int[]

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

References getForumRefId().

1061  : array
1062  {
1063  return self::_getModerators($this->getForumRefId());
1064  }
+ Here is the call graph for this function:

◆ getNumberOfPublishedUserPostings()

ilForum::getNumberOfPublishedUserPostings ( int  $usr_id,
bool  $post_activation_required 
)

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

References $res, and getForumId().

947  : int
948  {
949  $query = '
950  SELECT
951  SUM(IF(f.pos_cens = %s, 1, 0)) cnt
952  FROM frm_posts f
953  INNER JOIN frm_posts_tree t ON f.pos_pk = t.pos_fk AND t.parent_pos != %s
954  INNER JOIN frm_threads th ON t.thr_fk = th.thr_pk
955  INNER JOIN frm_data d ON d.top_pk = f.pos_top_fk AND d.top_frm_fk = %s
956  WHERE f.pos_author_id = %s
957  ';
958 
959  if ($post_activation_required) {
960  $query .= ' AND f.pos_status = ' . $this->db->quote(1, 'integer');
961  }
962 
963  $res = $this->db->queryF(
964  $query,
965  ['integer', 'integer', 'integer', 'integer'],
966  [0, 0, $this->getForumId(), $usr_id]
967  );
968  $row = $this->db->fetchAssoc($res);
969  if (is_array($row)) {
970  return (int) $row['cnt'];
971  }
972 
973  return 0;
974  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ getOneThread()

ilForum::getOneThread ( )

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

References $message, $notify, ilRTE\_replaceMediaObjectImageSrc(), addPostTree(), getForumId(), getForumRefId(), getImportName(), ilForumProperties\getInstance(), ilObjectFactory\getInstanceByRefId(), getMDB2DataType(), getMDB2DataValue(), getMDB2Query(), insertPostNode(), NEWS_NOTICE, NEWS_USERS, null, and prepareText().

167  : ilForumTopic
168  {
169  $data_type = [];
170  $data_value = [];
171 
172  $query = 'SELECT * FROM frm_threads WHERE ';
173  if ($this->getMDB2Query() !== '' && $this->getMDB2DataType() !== [] && $this->getMDB2DataValue() !== []) {
174  $query .= ' ' . $this->getMDB2Query() . ' ';
175  $data_type += $this->getMDB2DataType();
176  $data_value += $this->getMDB2DataValue();
177  } else {
178  $query .= '1 = 1';
179  }
180 
181  $sql_res = $this->db->queryF($query, $data_type, $data_value);
182  $result = $this->db->fetchAssoc($sql_res);
183  $result['thr_subject'] = trim((string) ($result['thr_subject'] ?? ''));
184 
185  $thread_obj = new ilForumTopic();
186  $thread_obj->assignData($result);
187 
188  return $thread_obj;
189  }
getMDB2DataValue()
+ Here is the call graph for this function:

◆ getOneTopic()

ilForum::getOneTopic ( )

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

References $res, ForumDto\getEmptyInstance(), ForumDto\getInstanceFromArray(), getMDB2DataType(), getMDB2DataValue(), and getMDB2Query().

Referenced by moveThreads().

143  : ForumDto
144  {
145  $data_type = [];
146  $data_value = [];
147 
148  $query = 'SELECT * FROM frm_data WHERE ';
149  if ($this->getMDB2Query() !== '' && $this->getMDB2DataType() !== [] && $this->getMDB2DataValue() !== []) {
150  $query .= ' ' . $this->getMDB2Query() . ' ';
151  $data_type += $this->getMDB2DataType();
152  $data_value += $this->getMDB2DataValue();
153  } else {
154  $query .= '1 = 1';
155  }
156 
157  $res = $this->db->queryF($query, $data_type, $data_value);
158  $row = $this->db->fetchAssoc($res);
159 
160  if (!is_array($row) || $row === []) {
162  }
163 
164  return ForumDto::getInstanceFromArray($row);
165  }
$res
Definition: ltiservices.php:66
static getInstanceFromArray(array $record)
static getEmptyInstance()
getMDB2DataValue()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPageHits()

ilForum::getPageHits ( )

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

References $pageHits.

138  : int
139  {
140  return $this->pageHits;
141  }
int $pageHits

◆ getPostDepth()

ilForum::getPostDepth ( int  $a_node_id,
int  $tree_id 
)

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

References $res.

Referenced by insertPostNode().

1229  : int
1230  {
1231  if ($tree_id !== 0) {
1232  $res = $this->db->queryF(
1233  'SELECT depth FROM frm_posts_tree WHERE pos_fk = %s AND thr_fk = %s',
1234  ['integer', 'integer'],
1235  [$a_node_id, $tree_id]
1236  );
1237 
1238  $row = $this->db->fetchObject($res);
1239  if ($row instanceof stdClass) {
1240  return (int) $row->depth;
1241  }
1242  }
1243 
1244  return 0;
1245  }
$res
Definition: ltiservices.php:66
+ Here is the caller graph for this function:

◆ getPostNode()

ilForum::getPostNode ( int  $post_id)

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

References $res, fetchPostNodeData(), and null.

Referenced by deletePost(), and mergeThreads().

1262  : array
1263  {
1264  $res = $this->db->queryF(
1265  'SELECT * FROM frm_posts, frm_posts_tree WHERE pos_pk = pos_fk AND pos_pk = %s',
1266  ['integer'],
1267  [$post_id]
1268  );
1269 
1270  if (($row = $this->db->fetchObject($res)) !== null) {
1271  return $this->fetchPostNodeData($row);
1272  }
1273 
1274  return [];
1275  }
$res
Definition: ltiservices.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
fetchPostNodeData(stdClass $a_row)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRootPostIdByThread()

ilForum::getRootPostIdByThread ( int  $a_thread_id)

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

References $res.

1042  : int
1043  {
1044  $res = $this->db->queryF(
1045  'SELECT pos_fk FROM frm_posts_tree WHERE thr_fk = %s AND parent_pos = %s',
1046  ['integer', 'integer'],
1047  [$a_thread_id, 0]
1048  );
1049 
1050  $row = $this->db->fetchObject($res);
1051  if ($row instanceof stdClass) {
1052  return (int) $row->pos_fk;
1053  }
1054 
1055  return 0;
1056  }
$res
Definition: ltiservices.php:66

◆ getSortedThreadSubjects()

static ilForum::getSortedThreadSubjects ( int  $a_obj_id,
int  $a_sort_mode = self::SORT_DATE 
)
static
Returns
array<int, string>

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

References $DIC, $res, and ILIAS\Repository\int().

Referenced by ilObjForumSearchResultTableGUI\parse(), and ilForumExportGUI\printPost().

1623  : array
1624  {
1625  global $DIC;
1626 
1627  $sort = match ($a_sort_mode) {
1628  self::SORT_DATE => 'thr_date',
1629  default => 'thr_subject',
1630  };
1631 
1632  $res = $DIC->database()->queryF(
1633  'SELECT thr_pk, thr_subject FROM frm_threads INNER JOIN frm_data ON top_pk = thr_top_fk WHERE top_frm_fk = %s ORDER BY %s',
1634  ['integer', 'text'],
1635  [$a_obj_id, $sort]
1636  );
1637 
1638  $threads = [];
1639  while ($row = $DIC->database()->fetchObject($res)) {
1640  $threads[(int) $row->thr_pk] = $row->thr_subject;
1641  }
1642 
1643  return $threads;
1644  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubPathIdsForNode()

ilForum::getSubPathIdsForNode ( ilForumPost  $post)
Returns
list<int> A list of post ids

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

References $res, ilForumPost\getLft(), ilForumPost\getRgt(), ilForumPost\getTreeId(), ILIAS\Repository\int(), and ilDBConstants\T_INTEGER.

Referenced by deletePost().

1330  : array
1331  {
1332  $res = $this->db->queryF(
1333  'SELECT pos_fk FROM frm_posts_tree WHERE lft BETWEEN %s AND %s AND thr_fk = %s',
1335  [$post->getLft(), $post->getRgt(), $post->getTreeId()]
1336  );
1337 
1338  $post_ids = [];
1339  while ($post_tree_data = $this->db->fetchAssoc($res)) {
1340  $post_ids[] = (int) $post_tree_data['pos_fk'];
1341  }
1342 
1343  return $post_ids;
1344  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserStatistics()

ilForum::getUserStatistics ( bool  $post_activation_required)
Returns
array{usr_id: int, pos_author_id: int, firstname: string, lastname: string, login: string, public_profile: string, num_postings: int}[]

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

References $data, $res, getForumId(), ILIAS\Repository\int(), and ILIAS\Repository\user().

979  : array
980  {
981  $statistic = [];
982  $data_types = [];
983  $data = [];
984 
985  $query = '
986  SELECT
987  u.login, u.lastname, u.firstname, f.pos_author_id, u.usr_id,
988  p.value public_profile,
989  SUM(IF(f.pos_cens = %s, 1, 0)) num_postings
990  FROM frm_posts f
991  INNER JOIN frm_posts_tree t ON f.pos_pk = t.pos_fk
992  INNER JOIN frm_threads th ON t.thr_fk = th.thr_pk
993  INNER JOIN usr_data u ON u.usr_id = f.pos_author_id
994  INNER JOIN frm_data d ON d.top_pk = f.pos_top_fk
995  LEFT JOIN usr_pref p ON p.usr_id = u.usr_id AND p.keyword = %s
996  WHERE t.parent_pos != %s
997  ';
998 
999  $data_types[] = 'integer';
1000  $data_types[] = 'text';
1001  $data_types[] = 'integer';
1002  $data[] = 0;
1003  $data[] = 'public_profile';
1004  $data[] = 0;
1005 
1006  if ($post_activation_required) {
1007  $query .= ' AND pos_status = %s';
1008  $data_types[] = 'integer';
1009  $data[] = 1;
1010  }
1011 
1012  $query .= '
1013  AND d.top_frm_fk = %s
1014  GROUP BY u.login, p.value,u.lastname, u.firstname, f.pos_author_id
1015  ';
1016 
1017  $data_types[] = 'integer';
1018  $data[] = $this->getForumId();
1019 
1020  $res = $this->db->queryF($query, $data_types, $data);
1021  while ($row = $this->db->fetchAssoc($res)) {
1022  if (
1023  !in_array($row['public_profile'], [
1024  PersonalProfileMode::PROFILE_ENABLED_LOGGED_IN_USERS,
1025  PersonalProfileMode::PROFILE_ENABLED_GLOBAL], true)
1026  || ($this->user->isAnonymous() && $row['public_profile'] !== PersonalProfileMode::PROFILE_ENABLED_GLOBAL)
1027  ) {
1028  $row['lastname'] = '';
1029  $row['firstname'] = '';
1030  }
1031 
1032  $row['usr_id'] = (int) $row['usr_id'];
1033  $row['pos_author_id'] = (int) $row['pos_author_id'];
1034  $row['num_postings'] = (int) $row['num_postings'];
1035 
1036  $statistic[] = $row;
1037  }
1038 
1039  return $statistic;
1040  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ insertPostNode()

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

insert node under parent node

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

References $res, getPostDepth(), and ILIAS\Repository\int().

Referenced by getOneThread().

1163  : void
1164  {
1165  $a_date = $a_date ?: date('Y-m-d H:i:s');
1166  $left = 1;
1167 
1168  $res = $this->db->queryF(
1169  'SELECT lft FROM frm_posts_tree WHERE pos_fk = %s AND thr_fk = %s',
1170  ['integer', 'integer'],
1171  [$a_parent_id, $tree_id]
1172  );
1173  $row = $this->db->fetchObject($res);
1174  if ($row instanceof stdClass) {
1175  $left = (int) $row->lft;
1176  }
1177 
1178  $lft = $left + 1;
1179  $rgt = $left + 2;
1180 
1181  $this->db->manipulateF(
1182  '
1183  UPDATE frm_posts_tree
1184  SET lft = CASE
1185  WHEN lft > %s
1186  THEN lft + 2
1187  ELSE lft
1188  END,
1189  rgt = CASE
1190  WHEN rgt > %s
1191  THEN rgt + 2
1192  ELSE rgt
1193  END
1194  WHERE thr_fk = %s',
1195  ['integer', 'integer', 'integer'],
1196  [$left, $left, $tree_id]
1197  );
1198 
1199  $depth = $this->getPostDepth($a_parent_id, $tree_id) + 1;
1200 
1201  $nextId = $this->db->nextId('frm_posts_tree');
1202  $this->db->manipulateF(
1203  '
1204  INSERT INTO frm_posts_tree
1205  ( fpt_pk,
1206  thr_fk,
1207  pos_fk,
1208  parent_pos,
1209  lft,
1210  rgt,
1211  depth,
1212  fpt_date
1213  )
1214  VALUES(%s,%s,%s, %s, %s, %s,%s, %s)',
1215  ['integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'],
1216  [
1217  $nextId,
1218  $tree_id,
1219  $a_node_id,
1220  $a_parent_id,
1221  $lft,
1222  $rgt,
1223  $depth,
1224  $a_date
1225  ]
1226  );
1227  }
$res
Definition: ltiservices.php:66
getPostDepth(int $a_node_id, int $tree_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isForumNotificationEnabled()

ilForum::isForumNotificationEnabled ( int  $user_id)

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

References $res.

Referenced by enableForumNotification().

1590  : bool
1591  {
1592  $res = $this->db->queryF(
1593  'SELECT COUNT(*) cnt FROM frm_notification WHERE user_id = %s AND frm_id = %s',
1594  ['integer', 'integer'],
1595  [$user_id, $this->id]
1596  );
1597 
1598  if ($row = $this->db->fetchAssoc($res)) {
1599  return (int) $row['cnt'] > 0;
1600  }
1601 
1602  return false;
1603  }
$res
Definition: ltiservices.php:66
+ Here is the caller graph for this function:

◆ isThreadNotificationEnabled()

ilForum::isThreadNotificationEnabled ( int  $user_id,
int  $thread_id 
)

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

References $res.

1605  : bool
1606  {
1607  $res = $this->db->queryF(
1608  'SELECT COUNT(*) cnt FROM frm_notification WHERE user_id = %s AND thread_id = %s',
1609  ['integer', 'integer'],
1610  [$user_id, $thread_id]
1611  );
1612 
1613  if ($row = $this->db->fetchAssoc($res)) {
1614  return (int) $row['cnt'] > 0;
1615  }
1616 
1617  return false;
1618  }
$res
Definition: ltiservices.php:66

◆ mergeThreads()

ilForum::mergeThreads ( int  $source_id,
int  $target_id 
)

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

References $ilDB, deletePost(), getForumId(), getPostNode(), ilObjForum\mergeForumUserRead(), ilForumPost\mergePosts(), ilForumNotification\mergeThreadNotifications(), null, and ilForumPostsTree\updateTargetRootRgt().

1658  : void
1659  {
1660  // selected source and target objects
1661  $sourceThread = new ilForumTopic($source_id);
1662  $targetThread = new ilForumTopic($target_id);
1663 
1664  if ($sourceThread->getForumId() !== $targetThread->getForumId()) {
1665  throw new ilException('not_allowed_to_merge_into_another_forum');
1666  }
1667 
1668  // use the 'older' thread as target
1669  if ($sourceThread->getCreateDate() > $targetThread->getCreateDate()) {
1670  $sourceThreadForMerge = $sourceThread;
1671  $targetThreadForMerge = $targetThread;
1672  } else {
1673  $sourceThreadForMerge = $targetThread;
1674  $targetThreadForMerge = $sourceThread;
1675  }
1676 
1677  $threadSubject = $targetThreadForMerge->getSubject();
1678 
1679  $targetWasClosedBeforeMerge = $targetThreadForMerge->isClosed();
1680  $sourceThreadForMerge->close();
1681 
1682  if (!$targetWasClosedBeforeMerge) {
1683  $targetThreadForMerge->close();
1684  }
1685 
1686  $allSourcePostings = $sourceThreadForMerge->getAllPostIds();
1687  $sourceThreadRootNode = $sourceThreadForMerge->getPostRootNode();
1688  $targetThreadRootNode = $targetThreadForMerge->getPostRootNode();
1689 
1690  $sourceThreadRootArray = $this->getPostNode($sourceThreadRootNode->getId());
1691 
1692  $ilAtomQuery = $this->db->buildAtomQuery();
1693  $ilAtomQuery->addTableLock('frm_posts');
1694  $ilAtomQuery->addTableLock('frm_posts_tree');
1695  $ilAtomQuery->addTableLock('frm_threads');
1696  $ilAtomQuery->addTableLock('frm_data');
1697 
1698  $ilAtomQuery->addQueryCallable(static function (ilDBInterface $ilDB) use (
1699  $targetThreadForMerge,
1700  $sourceThreadForMerge,
1701  $targetThreadRootNode,
1702  $sourceThreadRootNode,
1703  $allSourcePostings
1704  ): void {
1705  $targetRootNodeRgt = $targetThreadRootNode->getRgt();
1706  $targetRootNodeId = $targetThreadRootNode->getId();
1707 
1708  // update target root node rgt: Ignore the root node itself from the source (= -2)
1710  $targetThreadRootNode->getId(),
1711  ($targetThreadRootNode->getRgt() + $sourceThreadRootNode->getRgt() - 2)
1712  );
1713 
1714  // get source post tree and update posts tree
1715  foreach ($allSourcePostings as $pos_pk) {
1716  $post_obj = new ilForumPost($pos_pk);
1717 
1718  if ($post_obj->getId() === $sourceThreadRootNode->getId()) {
1719  // Ignore the source root node (MUST be deleted later)
1720  continue;
1721  }
1722 
1723  $tree = new ilForumPostsTree();
1724  $tree->setPosFk($pos_pk);
1725 
1726  if ($post_obj->getParentId() === $sourceThreadRootNode->getId()) {
1727  $tree->setParentPos($targetRootNodeId);
1728  } else {
1729  $tree->setParentPos($post_obj->getParentId());
1730  }
1731 
1732  $tree->setLft(($post_obj->getLft() + $targetRootNodeRgt) - 2);
1733  $tree->setRgt(($post_obj->getRgt() + $targetRootNodeRgt) - 2);
1734 
1735  $tree->setDepth($post_obj->getDepth());
1736  $tree->setTargetThreadId($targetThreadForMerge->getId());
1737  $tree->setSourceThreadId($sourceThreadForMerge->getId());
1738 
1739  $tree->merge();
1740  }
1741 
1743  $sourceThreadForMerge->getId(),
1744  $targetThreadForMerge->getId(),
1745  [$sourceThreadRootNode->getId()]
1746  );
1747  });
1748  $ilAtomQuery->run();
1749 
1750  ilForumNotification::mergeThreadNotifications($sourceThreadForMerge->getId(), $targetThreadForMerge->getId());
1751  ilObjForum::mergeForumUserRead($sourceThreadForMerge->getId(), $targetThreadForMerge->getId());
1752 
1753  $lastPostString = $targetThreadForMerge->getLastPostString() ?? '';
1754  $exp = explode('#', $lastPostString);
1755  if (array_key_exists(2, $exp)) {
1756  try {
1757  $exp[2] = $targetThreadForMerge->getLastPost()->getId();
1758  $lastPostString = implode('#', $exp);
1759  } catch (OutOfBoundsException) {
1760  $lastPostString = null;
1761  }
1762  }
1763 
1764  $frm_topic_obj = new ilForumTopic(0, false, true);
1765  $frm_topic_obj->setNumPosts($sourceThreadForMerge->getNumPosts() + $targetThreadForMerge->getNumPosts());
1766  $frm_topic_obj->setVisits($sourceThreadForMerge->getVisits() + $targetThreadForMerge->getVisits());
1767  $frm_topic_obj->setLastPostString($lastPostString);
1768  $frm_topic_obj->setSubject($threadSubject);
1769  $frm_topic_obj->setId($targetThreadForMerge->getId());
1770  $frm_topic_obj->updateMergedThread();
1771 
1772  if (!$targetWasClosedBeforeMerge) {
1773  $targetThreadForMerge->reopen();
1774  }
1775 
1776  $this->event->raise(
1777  'components/ILIAS/Forum',
1778  'mergedThreads',
1779  [
1780  'obj_id' => $this->getForumId(),
1781  'source_thread_id' => $sourceThreadForMerge->getId(),
1782  'target_thread_id' => $targetThreadForMerge->getId()
1783  ]
1784  );
1785 
1786  $this->deletePost($sourceThreadRootArray, false);
1787  }
getPostNode(int $post_id)
static mergeForumUserRead(int $merge_source_thread_id, int $merge_target_thread_id)
static mergePosts(int $sourceThreadId, int $targetThreadId, array $excludedPostIds=[])
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static updateTargetRootRgt(int $root_node_id, int $rgt)
deletePost($postIdOrRecord, bool $raiseEvents=true)
static mergeThreadNotifications($merge_source_thread_id, $merge_target_thread_id)
+ Here is the call graph for this function:

◆ moveThreads()

ilForum::moveThreads ( array  $thread_ids,
ilObjForum  $src_forum,
int  $target_obj_id 
)
Parameters
int[]$thread_ids
Returns
string[] A list of error message strings

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

References $res, ILIAS\Survey\Mode\getId(), ilObject\getId(), getOneTopic(), ILIAS\Repository\lng(), null, and setMDB2WhereCondition().

351  : array
352  {
353  $errorMessages = [];
354 
355  if ($target_obj_id <= 0 || $src_forum->getId() <= 0) {
356  return $errorMessages;
357  }
358 
359  $this->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$src_forum->getId()]);
360  $oldFrmData = $this->getOneTopic();
361 
362  $this->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$target_obj_id]);
363  $newFrmData = $this->getOneTopic();
364 
365  if (!$oldFrmData->getTopPk() || !$newFrmData->getTopPk()) {
366  return $errorMessages;
367  }
368 
369  $num_moved_posts = 0;
370  $num_moved_threads = 0;
371  $num_visits = 0;
372 
373  foreach ($thread_ids as $id) {
374  $objTmpThread = new ilForumTopic($id);
375 
376  try {
377  $numPosts = $objTmpThread->movePosts(
378  $src_forum->getId(),
379  $oldFrmData->getTopPk(),
380  $target_obj_id,
381  $newFrmData->getTopPk()
382  );
383 
384  if (($last_post_string = ($objTmpThread->getLastPostString() ?? '')) !== '') {
385  $last_post_string = explode('#', $last_post_string);
386  $last_post_string[0] = $newFrmData->getTopPk();
387  $last_post_string = implode('#', $last_post_string);
388  $objTmpThread->setLastPostString($last_post_string);
389  }
390 
391  $num_visits += $objTmpThread->getVisits();
392  $num_moved_posts += $numPosts;
393  ++$num_moved_threads;
394 
395  $objTmpThread->setForumId($newFrmData->getTopPk());
396  $objTmpThread->update();
397  } catch (ilFileUtilsException) {
398  $errorMessages[] = sprintf($this->lng->txt('frm_move_invalid_file_type'), $objTmpThread->getSubject());
399  continue;
400  }
401  }
402 
403  if (0 === max($num_moved_threads, $num_moved_posts, $num_visits)) {
404  return $errorMessages;
405  }
406 
407  $this->db->setLimit(1, 0);
408  $res = $this->db->queryF(
409  'SELECT pos_thr_fk, pos_pk FROM frm_posts WHERE pos_top_fk = %s ORDER BY pos_date DESC',
410  ['integer'],
411  [$oldFrmData->getTopPk()]
412  );
413 
414  $last_post_src = '';
415  $row = $this->db->fetchObject($res);
416  if ($row !== null) {
417  $last_post_src = $oldFrmData->getTopPk() . '#' . $row->pos_thr_fk . '#' . $row->pos_pk;
418  }
419 
420  $this->db->manipulateF(
421  'UPDATE frm_data ' .
422  'SET top_num_posts = top_num_posts - %s, top_num_threads = top_num_threads - %s, visits = visits - %s, ' .
423  'top_last_post = %s WHERE top_pk = %s',
424  ['integer', 'integer', 'integer', 'text', 'integer'],
425  [
426  $num_moved_posts,
427  $num_moved_threads,
428  $num_visits,
429  $last_post_src,
430  $oldFrmData->getTopPk()
431  ]
432  );
433 
434  $this->db->setLimit(1, 0);
435  $res = $this->db->queryF(
436  'SELECT pos_thr_fk, pos_pk FROM frm_posts WHERE pos_top_fk = %s ORDER BY pos_date DESC',
437  ['integer'],
438  [$newFrmData->getTopPk()]
439  );
440 
441  $last_post_dest = '';
442  $row = $this->db->fetchObject($res);
443  if ($row !== null) {
444  $last_post_dest = $newFrmData->getTopPk() . '#' . $row->pos_thr_fk . '#' . $row->pos_pk;
445  }
446 
447  $this->db->manipulateF(
448  'UPDATE frm_data SET top_num_posts = top_num_posts + %s, top_num_threads = top_num_threads + %s, ' .
449  'visits = visits + %s, top_last_post = %s WHERE top_pk = %s',
450  ['integer', 'integer', 'integer', 'text', 'integer'],
451  [$num_moved_posts, $num_moved_threads, $num_visits, $last_post_dest, $newFrmData->getTopPk()]
452  );
453 
454  $this->event->raise(
455  'components/ILIAS/Forum',
456  'movedThreads',
457  [
458  'source_ref_id' => $src_forum->getId(),
459  'target_ref_id' => $src_forum->getId(),
460  'thread_ids' => $src_forum->getId(),
461  'source_frm_obj_id' => $src_forum->getId(),
462  'target_frm_obj_id' => $target_obj_id
463  ]
464  );
465 
466  return $errorMessages;
467  }
$res
Definition: ltiservices.php:66
setMDB2WhereCondition(string $query_string, array $data_type, array $data_value)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ postCensorship()

ilForum::postCensorship ( ilObjForum  $forum,
string  $message,
int  $pos_pk,
int  $cens = 0 
)

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

References $res, ilNewsItem\getFirstNewsIdForContext(), getForumRefId(), prepareText(), and ILIAS\Repository\user().

469  : void
470  {
471  $cens_date = date('Y-m-d H:i:s');
472 
473  $this->db->manipulateF(
474  'UPDATE frm_posts
475  SET pos_cens_com = %s,
476  pos_cens_date = %s,
477  pos_cens = %s,
478  update_user = %s
479  WHERE pos_pk = %s',
480  ['text', 'timestamp', 'integer', 'integer', 'integer'],
481  [$message,
482  $cens_date,
483  $cens,
484  $this->user->getId(),
485  $pos_pk
486  ]
487  );
488 
490  $this->id,
491  'frm',
492  $pos_pk,
493  'pos'
494  );
495  if ($news_id > 0) {
496  if ($cens > 0) {
497  $news_item = new ilNewsItem($news_id);
498  $news_item->setContent(nl2br($this->prepareText($message, 0)));
499  $news_item->setContentHtml(false);
500  if ($message !== strip_tags($message)) {
501  $news_item->setContentHtml(true);
502  }
503  } else {
504  $res = $this->db->queryF('SELECT pos_message FROM frm_posts WHERE pos_pk = %s', ['integer'], [$pos_pk]);
505  $rec = $this->db->fetchAssoc($res);
506 
507  $news_item = new ilNewsItem($news_id);
508  $news_item->setContent(nl2br($this->prepareText($rec['pos_message'], 0)));
509  $news_item->setContentHtml(false);
510  if ($rec['pos_message'] !== strip_tags($rec['pos_message'])) {
511  $news_item->setContentHtml(true);
512  }
513  }
514  $news_item->update();
515  }
516 
517  $this->event->raise(
518  'components/ILIAS/Forum',
519  'censoredPost',
520  [
521  'ref_id' => $this->getForumRefId(),
522  'post' => new ilForumPost($pos_pk),
523  'object' => $forum
524  ]
525  );
526  }
$res
Definition: ltiservices.php:66
prepareText(string $text, int $edit=0, string $quote_user='', string $type='')
A news item can be created by different sources.
static getFirstNewsIdForContext(int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:

◆ prepareText()

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

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

References $replQuote2, $txtQuote2, ilMathJax\getInstance(), and ILIAS\Repository\lng().

Referenced by getOneThread(), postCensorship(), and ilObjForumGUI\renderPostingForm().

1423  : string
1424  {
1425  if ($type === 'export') {
1426  $this->replQuote1 = "<blockquote class=\"quote\"><hr size=\"1\" color=\"#000000\">";
1427  $this->replQuote2 = "<hr size=\"1\" color=\"#000000\"/></blockquote>";
1428  }
1429 
1430  if ($edit === 1) {
1431  $lname = '';
1432  if ($quote_user !== '') {
1433  $lname = '="' . $quote_user . '"';
1434  }
1435 
1436  $text = "[quote$lname]" . $text . "[/quote]";
1437  } else {
1438  // check for quotation
1439  $startZ = substr_count($text, "[quote"); // also count [quote="..."]
1440  $endZ = substr_count($text, "[/quote]");
1441 
1442  if ($startZ > 0 || $endZ > 0) {
1443  // add missing opening and closing tags
1444  if ($startZ > $endZ) {
1445  $diff = $startZ - $endZ;
1446 
1447  for ($i = 0; $i < $diff; $i++) {
1448  if ($type === 'export') {
1449  $text .= $this->txtQuote2;
1450  } else {
1451  $text .= "[/quote]";
1452  }
1453  }
1454  } elseif ($startZ < $endZ) {
1455  $diff = $endZ - $startZ;
1456 
1457  for ($i = 0; $i < $diff; $i++) {
1458  if ($type === 'export') {
1459  $text = $this->txtQuote1 . $text;
1460  } else {
1461  $text = "[quote]" . $text;
1462  }
1463  }
1464  }
1465 
1466  if ($edit === 0) {
1467  $text = preg_replace(
1468  '@\[(quote\s*?=\s*?"([^"]*?)"\s*?)\]@i',
1469  $this->replQuote1 . '<div class="ilForumQuoteHead">' . $this->lng->txt('quote') . ' ($2)</div>',
1470  $text
1471  );
1472 
1473  $text = str_replace(
1474  ["[quote]", "[/quote]"],
1475  [
1476  $this->replQuote1 . '<div class="ilForumQuoteHead">' . $this->lng->txt('quote') . '</div>',
1478  ],
1479  $text
1480  );
1481  }
1482  }
1483  }
1484 
1485  if ($type !== 'export') {
1486  if ($edit === 0) {
1487  $text = ilMathJax::getInstance()->insertLatexImages($text, "<span class\=\"latex\">", "<\/span>");
1488  $text = ilMathJax::getInstance()->insertLatexImages($text, "\[tex\]", "\[\/tex\]");
1489  }
1490 
1491  // workaround for preventing template engine
1492  // from hiding text that is enclosed
1493  // in curly brackets (e.g. "{a}")
1494  $text = str_replace(["{", "}"], ["&#123;", "&#125;"], $text);
1495  }
1496 
1497  return $text;
1498  }
string $txtQuote2
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
string $replQuote2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDbTable()

ilForum::setDbTable ( string  $dbTable)

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

References $dbTable.

90  : void
91  {
92  if ($dbTable === '') {
93  die($this->className . '::setDbTable(): No database table given.');
94  }
95 
96  $this->dbTable = $dbTable;
97  }
string $dbTable

◆ setForumId()

ilForum::setForumId ( int  $a_obj_id)

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

70  : void
71  {
72  $this->id = $a_obj_id;
73  }

◆ setForumRefId()

ilForum::setForumRefId ( int  $a_ref_id)

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

75  : void
76  {
77  $this->ref_id = $a_ref_id;
78  }

◆ setImportName()

ilForum::setImportName ( string  $a_import_name)

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

1519  : void
1520  {
1521  $this->import_name = $a_import_name;
1522  }

◆ setMDB2WhereCondition()

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

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

Referenced by moveThreads().

104  : bool
105  {
106  $this->mdb2Query = $query_string;
107  $this->mdb2DataValue = $data_value;
108  $this->mdb2DataType = $data_type;
109 
110  return true;
111  }
+ Here is the caller graph for this function:

◆ setPageHits()

ilForum::setPageHits ( int  $pageHits)

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

References $pageHits.

128  : bool
129  {
130  if ($pageHits < 1) {
131  $pageHits = 1;
132  }
133 
134  $this->pageHits = $pageHits;
135  return true;
136  }
int $pageHits

◆ updateVisits()

ilForum::updateVisits ( int  $ID)

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

References ilSession\get(), getMDB2DataType(), getMDB2DataValue(), getMDB2Query(), and ilSession\set().

1402  : void
1403  {
1404  $checkTime = time() - (60 * 60);
1405  $session_key = 'frm_visit_' . $this->dbTable . '_' . $ID;
1406 
1407  if (ilSession::get($session_key) < $checkTime) {
1408  ilSession::set($session_key, time());
1409  $query = 'UPDATE ' . $this->dbTable . ' SET visits = visits + 1 WHERE ';
1410  $data_type = [];
1411  $data_value = [];
1412 
1413  if ($this->getMDB2Query() !== '' && $this->getMDB2DataType() !== [] && $this->getMDB2DataValue() !== []) {
1414  $query .= $this->getMDB2Query();
1415  $data_type += $this->getMDB2DataType();
1416  $data_value += $this->getMDB2DataValue();
1417 
1418  $this->db->manipulateF($query, $data_type, $data_value);
1419  }
1420  }
1421  }
static get(string $a_var)
getMDB2DataValue()
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

Field Documentation

◆ $className

string ilForum::$className = 'ilForum'
private

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

◆ $db

ilDBInterface ilForum::$db

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

◆ $dbTable

string ilForum::$dbTable
private

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

Referenced by getDbTable(), and setDbTable().

◆ $error

ilErrorHandling ilForum::$error

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

◆ $event

readonly ilAppEventHandler ilForum::$event
private

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

◆ $id

int ilForum::$id
private

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

Referenced by getForumId().

◆ $import_name

string ilForum::$import_name = ''
private

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

Referenced by getImportName().

◆ $lng

ilLanguage ilForum::$lng

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

◆ $mdb2DataType

array ilForum::$mdb2DataType = []
private

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

◆ $mdb2DataValue

array ilForum::$mdb2DataValue = []
private

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

◆ $mdb2Query

string ilForum::$mdb2Query = ''
private

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

◆ $moderators_by_ref_id_map

array ilForum::$moderators_by_ref_id_map = []
staticprotected

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

◆ $pageHits

int ilForum::$pageHits = self::DEFAULT_PAGE_HITS
private

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

Referenced by getPageHits(), and setPageHits().

◆ $ref_id

int ilForum::$ref_id
private

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

Referenced by getForumRefId().

◆ $replQuote1

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

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

◆ $replQuote2

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

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

Referenced by prepareText().

◆ $settings

ilSetting ilForum::$settings

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

◆ $txtQuote1

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

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

◆ $txtQuote2

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

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

Referenced by prepareText().

◆ $user

ilObjUser ilForum::$user

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

◆ DEFAULT_PAGE_HITS

const ilForum::DEFAULT_PAGE_HITS = 30
private

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

◆ SORT_DATE

const ilForum::SORT_DATE = 2
private

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

◆ SORT_TITLE

const ilForum::SORT_TITLE = 1
private

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


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