ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjForum Class Reference

Class ilObjForum. More...

+ Inheritance diagram for ilObjForum:
+ Collaboration diagram for ilObjForum:

Public Member Functions

 __construct (int $a_id=0, bool $a_call_by_reference=true)
 
 create ()
 
 setPermissions (int $parent_ref_id)
 
 updateModeratorRole (int $role_id)
 
 getCountUnread (int $a_usr_id, int $a_thread_id=0, bool $ignoreRoot=false)
 
 markThreadRead (int $a_usr_id, int $a_thread_id)
 
 markAllThreadsRead (int $a_usr_id)
 
 markPostRead (int $a_usr_id, int $a_thread_id, int $a_post_id)
 
 markPostUnread (int $a_user_id, int $a_post_id)
 
 isRead ($a_usr_id, $a_post_id)
 
 updateLastAccess (int $a_usr_id, int $a_thread_id)
 
 updateMoficationUserId (int $usr_id)
 
 update ()
 
 cloneAutoGeneratedRoles (self $new_obj)
 
 delete ()
 
 initDefaultRoles ()
 
 createSettings ()
 
 saveData ()
 
 setThreadSorting (int $a_thr_pk, int $a_sorting_value)
 
 getNumStickyThreads ()
 
 getPageObjIds ()
 
- Public Member Functions inherited from ilObject
 __construct (int $id=0, bool $reference=true)
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 processAutoRating ()
 
 read ()
 
 getId ()
 
 setId (int $id)
 
 setRefId (int $ref_id)
 
 getRefId ()
 
 getType ()
 
 setType (string $type)
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 
 getUntranslatedTitle ()
 Get untranslated object title WebDAV needs to access the untranslated title of an object. More...
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $desc)
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 
 setImportId (string $import_id)
 
 setOfflineStatus (bool $status)
 
 getOfflineStatus ()
 
 supportsOfflineHandling ()
 
 getOwner ()
 
 getOwnerName ()
 get full name of object owner More...
 
 setOwner (int $usr_id)
 
 getCreateDate ()
 Get create date in YYYY-MM-DD HH-MM-SS format. More...
 
 getLastUpdateDate ()
 Get last update date in YYYY-MM-DD HH-MM-SS format. More...
 
 create ()
 note: title, description and type should be set when this function is called More...
 
 update ()
 
 MDUpdateListener (string $element)
 Metadata update listener. More...
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree (int $parent_ref_id)
 maybe this method should be in tree object!? More...
 
 setPermissions (int $parent_ref_id)
 
 setParentRolePermissions (int $parent_ref_id)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type. More...
 
 applyDidacticTemplate (int $tpl_id)
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo (int $target_id, int $copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies (int $target_id, int $copy_id)
 Clone object dependencies. More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 selfOrParentWithRatingEnabled ()
 
 getPossibleSubObjects (bool $filter=true)
 get all possible sub objects of this type the object can decide which types of sub objects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static _lookupThreadSubject (int $a_thread_id)
 
static _updateOldAccess (int $a_usr_id)
 
static _deleteUser (int $a_usr_id)
 
static _deleteReadEntries (int $a_post_id)
 
static _deleteAccessEntries (int $a_thread_id)
 
static _lookupModeratorRole (int $a_ref_id)
 
static lookupForumIdByObjId (int $obj_id)
 
static lookupForumIdByRefId (int $ref_id)
 
static preloadForumIdsByObjIds (array $obj_ids)
 
static preloadForumIdsByRefIds (array $ref_ids)
 
static lookupStatisticsByRefId (int $ref_id)
 
static lookupLastPostByRefId (int $ref_id)
 
static getUserIdsOfLastPostsByRefIdAndThreadIds (int $ref_id, array $thread_ids)
 
static mergeForumUserRead (int $merge_source_thread_id, int $merge_target_thread_id)
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId (string $import_id)
 Get (latest) object id for an import id. More...
 
static _lookupImportId (int $obj_id)
 
static _lookupOwnerName (int $owner_id)
 Lookup owner name for owner id. More...
 
static _getIdForImportId (string $import_id)
 
static _getAllReferences (int $id)
 get all reference ids for object ID More...
 
static _lookupTitle (int $obj_id)
 
static lookupOfflineStatus (int $obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner (int $obj_id)
 Lookup owner user ID for object ID. More...
 
static _getIdsForTitle (string $title, string $type='', bool $partial_match=false)
 
static _lookupDescription (int $obj_id)
 
static _lookupLastUpdate (int $obj_id, bool $formatted=false)
 
static _getLastUpdateOfObjects (array $obj_ids)
 
static _lookupObjId (int $ref_id)
 
static _setDeletedDate (int $ref_id, int $deleted_by)
 
static setDeletedDates (array $ref_ids, int $user_id)
 
static _resetDeletedDate (int $ref_id)
 
static _lookupDeletedDate (int $ref_id)
 
static _writeTitle (int $obj_id, string $title)
 write title to db (static) More...
 
static _writeDescription (int $obj_id, string $desc)
 write description to db (static) More...
 
static _writeImportId (int $obj_id, string $import_id)
 write import id to db (static) More...
 
static _lookupType (int $id, bool $reference=false)
 
static _isInTrash (int $ref_id)
 
static _hasUntrashedReference (int $obj_id)
 checks whether an object has at least one reference that is not in trash More...
 
static _lookupObjectId (int $ref_id)
 
static _getObjectsDataForType (string $type, bool $omit_trash=false)
 get all objects of a certain type More...
 
static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType (string $obj_type="", int $owner=null)
 
static _prepareCloneSelection (array $ref_ids, string $new_type, bool $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon (int $obj_id=0, string $size="big", string $type="", bool $offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies (int $obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $obj_ids)
 
static getAllOwnedRepositoryObjects (int $user_id)
 
static fixMissingTitles ($type, array &$obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate (int $obj_id)
 
static _getObjectTypeIdByTitle (string $type, \ilDBInterface $ilDB=null)
 

Data Fields

const NEWS_NEW_CONSIDERATION_WEEKS = 8
 
ilForum $Forum
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 
const DESC_LENGTH = 128
 
const LONG_DESC_LENGTH = 4000
 
const TABLE_OBJECT_DATA = "object_data"
 
array $objectList
 
string $untranslatedTitle
 

Private Member Functions

 deleteDraftsByForumId (int $forum_id)
 

Private Attributes

ILIAS DI RBACServices $rbac
 
ilLogger $logger
 

Static Private Attributes

static array $obj_id_to_forum_id_cache = []
 
static array $ref_id_to_forum_id_cache = []
 
static array $forum_statistics_cache = []
 
static array $forum_last_post_cache = []
 

Additional Inherited Members

- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 
- Protected Attributes inherited from ilObject
ilLogger $obj_log
 
ILIAS $ilias
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLogger $log
 
ilErrorHandling $error
 
ilTree $tree
 
ilAppEventHandler $app_event_handler
 
ilRbacAdmin $rbac_admin
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilLanguage $lng
 
int $id
 
bool $referenced
 
bool $call_by_reference
 
int $max_title = self::TITLE_LENGTH
 
int $max_desc = self::DESC_LENGTH
 
bool $add_dots = true
 
int $ref_id = null
 
string $type = ""
 
string $title = ""
 
bool $offline = false
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Detailed Description

Class ilObjForum.

Author
Wolfgang Merkens wmerk.nosp@m.ens@.nosp@m.datab.nosp@m.ay.d.nosp@m.e

Definition at line 26 of file class.ilObjForum.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjForum::__construct ( int  $a_id = 0,
bool  $a_call_by_reference = true 
)

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

References $DIC, ILIAS\LTI\ToolProvider\$settings, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\int(), ILIAS\Repository\logger(), and ILIAS\Repository\rbac().

43  {
44  global $DIC;
45 
46  $this->type = 'frm';
47  parent::__construct($a_id, $a_call_by_reference);
48 
49  $this->rbac = $DIC->rbac();
50  $this->logger = $DIC->logger()->root();
51 
52  $settings = $DIC->settings();
53  $weeks = self::NEWS_NEW_CONSIDERATION_WEEKS;
54  if ($settings->get('frm_store_new')) {
55  $weeks = (int) $settings->get('frm_store_new');
56  }
57  $new_deadline = time() - 60 * 60 * 24 * 7 * $weeks;
58  $settings->set('frm_new_deadline', (string) $new_deadline);
59 
60  $this->Forum = new ilForum();
61  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
Class Forum core functions for forum.
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteAccessEntries()

static ilObjForum::_deleteAccessEntries ( int  $a_thread_id)
static

Definition at line 332 of file class.ilObjForum.php.

References $DIC.

Referenced by ilForum\deletePost(), and ilForum\mergeThreads().

332  : void
333  {
334  global $DIC;
335 
336  $DIC->database()->manipulateF('DELETE FROM frm_thread_access WHERE thread_id = %s', ['integer'], [$a_thread_id]);
337  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _deleteReadEntries()

static ilObjForum::_deleteReadEntries ( int  $a_post_id)
static

Definition at line 325 of file class.ilObjForum.php.

References $DIC.

Referenced by ilForum\deletePost().

325  : void
326  {
327  global $DIC;
328 
329  $DIC->database()->manipulateF('DELETE FROM frm_user_read WHERE post_id = %s', ['integer'], [$a_post_id]);
330  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _deleteUser()

static ilObjForum::_deleteUser ( int  $a_usr_id)
static

Definition at line 314 of file class.ilObjForum.php.

References $data, and $DIC.

314  : void
315  {
316  global $DIC;
317 
318  $data = [$a_usr_id];
319 
320  $DIC->database()->manipulateF('DELETE FROM frm_user_read WHERE usr_id = %s', ['integer'], $data);
321  $DIC->database()->manipulateF('DELETE FROM frm_thread_access WHERE usr_id = %s', ['integer'], $data);
322  $DIC->database()->manipulateF('DELETE FROM frm_notification WHERE user_id = %s', ['integer'], $data);
323  }
global $DIC
Definition: feed.php:28

◆ _lookupModeratorRole()

static ilObjForum::_lookupModeratorRole ( int  $a_ref_id)
static

Definition at line 617 of file class.ilObjForum.php.

References $DIC, $ilDB, and $res.

617  : int
618  {
619  global $DIC;
620 
621  $ilDB = $DIC->database();
622 
623  $mod_title = 'il_frm_moderator_' . $a_ref_id;
624 
625  $res = $ilDB->queryF('SELECT obj_id FROM object_data WHERE title = %s', ['text'], [$mod_title]);
626  while ($row = $ilDB->fetchObject($res)) {
627  return (int) $row->obj_id;
628  }
629 
630  return 0;
631  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28

◆ _lookupThreadSubject()

static ilObjForum::_lookupThreadSubject ( int  $a_thread_id)
static

Definition at line 101 of file class.ilObjForum.php.

References $DIC, $ilDB, and $res.

Referenced by ilObjForumSubItemListGUI\getHTML().

101  : string
102  {
103  global $DIC;
104 
105  $ilDB = $DIC->database();
106 
107  $res = $ilDB->queryF('SELECT thr_subject FROM frm_threads WHERE thr_pk = %s', ['integer'], [$a_thread_id]);
108  while ($row = $ilDB->fetchObject($res)) {
109  return $row->thr_subject ?? '';
110  }
111 
112  return '';
113  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _updateOldAccess()

static ilObjForum::_updateOldAccess ( int  $a_usr_id)
static

Definition at line 280 of file class.ilObjForum.php.

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

Referenced by ilAuthFrontend\handleAuthenticationSuccess().

280  : void
281  {
282  global $DIC;
283 
284  $ilDB = $DIC->database();
285 
286  $ilDB->manipulateF(
287  'UPDATE frm_thread_access SET access_old = access_last WHERE usr_id = %s',
288  ['integer'],
289  [$a_usr_id]
290  );
291 
292  $res = $ilDB->query(
293  'SELECT * FROM frm_thread_access WHERE usr_id = ' . $ilDB->quote($a_usr_id, 'integer')
294  );
295  while ($row = $ilDB->fetchAssoc($res)) {
296  $ilDB->manipulate(
297  "UPDATE frm_thread_access SET " .
298  " access_old_ts = " . $ilDB->quote(date('Y-m-d H:i:s', (int) $row["access_old"]), "timestamp") .
299  " WHERE usr_id = " . $ilDB->quote((int) $row["usr_id"], "integer") .
300  " AND obj_id = " . $ilDB->quote((int) $row["obj_id"], "integer") .
301  " AND thread_id = " . $ilDB->quote((int) $row["thread_id"], "integer")
302  );
303  }
304 
305  $weeks = self::NEWS_NEW_CONSIDERATION_WEEKS;
306  if ($DIC->settings()->get('frm_store_new')) {
307  $weeks = (int) $DIC->settings()->get('frm_store_new');
308  }
309  $new_deadline = time() - 60 * 60 * 24 * 7 * $weeks;
310 
311  $ilDB->manipulateF('DELETE FROM frm_thread_access WHERE access_last < %s', ['integer'], [$new_deadline]);
312  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneAutoGeneratedRoles()

ilObjForum::cloneAutoGeneratedRoles ( self  $new_obj)

Definition at line 484 of file class.ilObjForum.php.

References ilObject\getOwner(), ilObject\getRefId(), ILIAS\Repository\logger(), and ILIAS\Repository\rbac().

Referenced by update().

484  : void
485  {
486  $src_moderator_role_id = self::_lookupModeratorRole($this->getRefId());
487  $new_moderator_role_id = self::_lookupModeratorRole($new_obj->getRefId());
488 
489  if (
490  0 === $src_moderator_role_id ||
491  0 === $new_moderator_role_id ||
492  0 === $this->getRefId() ||
493  0 === $new_obj->getRefId()
494  ) {
495  $this->logger->write(__METHOD__ . ' : Error cloning auto generated role: il_frm_moderator');
496  }
497 
498  $this->rbac->admin()->copyRolePermissions(
499  $src_moderator_role_id,
500  $this->getRefId(),
501  $new_obj->getRefId(),
502  $new_moderator_role_id,
503  true
504  );
505 
506  $this->logger->write(__METHOD__ . ' : Finished copying of role il_frm_moderator.');
507 
508  $moderators = new ilForumModerators($this->getRefId());
509  $src_moderator_usr_ids = $moderators->getCurrentModerators();
510  foreach ($src_moderator_usr_ids as $usr_id) {
511  // The object owner is already member of the moderator role when this method is called
512  // Since the new static caches are introduced with ILIAS 5.0, a database error occurs if we try to assign the user here.
513  if ($this->getOwner() !== $usr_id) {
514  $this->rbac->admin()->assignUser($new_moderator_role_id, $usr_id);
515  }
516  }
517  }
Class ilForumModerators.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilObjForum::create ( )

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

References ilObject\$id, createSettings(), ilObject\getId(), ilForumProperties\getInstance(), saveData(), ilObject\setOfflineStatus(), update(), and ilForumProperties\VIEW_DATE_ASC.

63  : int
64  {
65  $id = parent::create();
66 
67  $properties = ilForumProperties::getInstance($this->getId());
68  $properties->setDefaultView(ilForumProperties::VIEW_DATE_ASC);
69  $properties->setAnonymisation(false);
70  $properties->setStatisticsStatus(false);
71  $properties->setPostActivation(false);
72  $properties->setThreadSorting(0);
73  $properties->insert();
74 
75  $this->createSettings();
76 
77  $this->setOfflineStatus(true);
78  $this->update();
79  $this->saveData();
80 
81  return $id;
82  }
static getInstance(int $a_obj_id=0)
setOfflineStatus(bool $status)
+ Here is the call graph for this function:

◆ createSettings()

ilObjForum::createSettings ( )

Definition at line 633 of file class.ilObjForum.php.

References $DIC, ilObject\$ref_id, ilNewsItem\_getDefaultVisibilityForRefId(), ilBlockSetting\_write(), and ilObject\getId().

Referenced by create().

633  : void
634  {
635  global $DIC;
636 
637  $ref_id = 0;
638  if ($DIC->http()->wrapper()->query()->has('ref_id')) {
639  $ref_id = $DIC->http()->wrapper()->query()->retrieve(
640  'ref_id',
641  $DIC->refinery()->kindlyTo()->int()
642  );
643  }
644 
645  // news settings (public notifications yes/no)
646  $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($ref_id);
647  if ($default_visibility === 'public') {
648  ilBlockSetting::_write('news', 'public_notifications', '1', 0, $this->getId());
649  }
650  }
static _getDefaultVisibilityForRefId(int $a_ref_id)
Get default visibility for reference id.
global $DIC
Definition: feed.php:28
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilObjForum::delete ( )

Definition at line 519 of file class.ilObjForum.php.

References ilPageObject\_exists(), deleteDraftsByForumId(), ilObject\getId(), and ilObject\getType().

519  : bool
520  {
521  $this->Forum->setForumId($this->getId());
522 
523  if (!parent::delete()) {
524  return false;
525  }
526 
527  if (ilForumPage::_exists($this->getType(), $this->getId())) {
528  $originalPageObject = new ilForumPage($this->getId());
529  $originalPageObject->delete();
530  }
531 
532  $tmp_file_obj = new ilFileDataForum($this->getId());
533  $tmp_file_obj->delete();
534 
535  $this->Forum->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$this->getId()]);
536 
537  $topData = $this->Forum->getOneTopic();
538 
539  $threads = $this->Forum->getAllThreads($topData->getTopPk(), [
540  'is_moderator' => true,
541  ]);
542  $thread_ids_to_delete = [];
543  foreach ($threads['items'] as $thread) {
544  $thread_ids_to_delete[$thread->getId()] = $thread->getId();
545  }
546 
547  $this->db->manipulate('DELETE FROM frm_posts_tree WHERE ' . $this->db->in(
548  'thr_fk',
549  $thread_ids_to_delete,
550  false,
551  'integer'
552  ));
553  $this->db->manipulate('DELETE FROM frm_posts WHERE ' . $this->db->in(
554  'pos_thr_fk',
555  $thread_ids_to_delete,
556  false,
557  'integer'
558  ));
559  $this->db->manipulate('DELETE FROM frm_threads WHERE ' . $this->db->in(
560  'thr_pk',
561  $thread_ids_to_delete,
562  false,
563  'integer'
564  ));
565 
566  $obj_id = [$this->getId()];
567 
568  $this->db->manipulateF('DELETE FROM frm_data WHERE top_frm_fk = %s', ['integer'], $obj_id);
569  $this->db->manipulateF('DELETE FROM frm_settings WHERE obj_id = %s', ['integer'], $obj_id);
570  $this->db->manipulateF('DELETE FROM frm_user_read WHERE obj_id = %s', ['integer'], $obj_id);
571  $this->db->manipulateF('DELETE FROM frm_thread_access WHERE obj_id = %s', ['integer'], $obj_id);
572  $this->db->manipulate('DELETE FROM frm_notification WHERE ' . $this->db->in(
573  'thread_id',
574  $thread_ids_to_delete,
575  false,
576  'integer'
577  ));
578  $this->db->manipulateF('DELETE FROM frm_notification WHERE frm_id = %s', ['integer'], $obj_id);
579  $this->db->manipulateF('DELETE FROM frm_posts_deleted WHERE obj_id = %s', ['integer'], $obj_id);
580  $this->deleteDraftsByForumId($topData->getTopPk());
581 
582  return true;
583  }
deleteDraftsByForumId(int $forum_id)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
This class handles all operations on files for the forum object.
+ Here is the call graph for this function:

◆ deleteDraftsByForumId()

ilObjForum::deleteDraftsByForumId ( int  $forum_id)
private

Definition at line 585 of file class.ilObjForum.php.

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

Referenced by delete().

585  : void
586  {
587  $res = $this->db->queryF(
588  'SELECT draft_id FROM frm_posts_drafts WHERE forum_id = %s',
589  ['integer'],
590  [$forum_id]
591  );
592 
593  $draft_ids = [];
594  while ($row = $this->db->fetchAssoc($res)) {
595  $draft_ids[] = (int) $row['draft_id'];
596  }
597 
598  if (count($draft_ids) > 0) {
599  $historyObj = new ilForumDraftsHistory();
600  $historyObj->deleteHistoryByDraftIds($draft_ids);
601 
602  $draftObj = new ilForumPostDraft();
603  $draftObj->deleteDraftsByDraftIds($draft_ids);
604  }
605  }
Class ilForumPostDraft.
$res
Definition: ltiservices.php:69
Class ilForumDraftHistory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCountUnread()

ilObjForum::getCountUnread ( int  $a_usr_id,
int  $a_thread_id = 0,
bool  $ignoreRoot = false 
)

Definition at line 115 of file class.ilObjForum.php.

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

115  : int
116  {
117  $a_frm_id = $this->getId();
118  $topic_id = 0;
119  $num_posts = 0;
120  $count_read = 0;
121 
122  if ($a_thread_id === 0) {
123  $res = $this->db->queryF('SELECT top_pk FROM frm_data WHERE top_frm_fk = %s', ['integer'], [$a_frm_id]);
124  while ($row = $this->db->fetchObject($res)) {
125  $topic_id = (int) $row->top_pk;
126  }
127 
128  $res = $this->db->queryF(
129  '
130  SELECT COUNT(pos_pk) num_posts
131  FROM frm_posts
132  LEFT JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
133  WHERE pos_top_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
134  ['integer'],
135  [$topic_id]
136  );
137 
138  while ($row = $this->db->fetchObject($res)) {
139  $num_posts = (int) $row->num_posts;
140  }
141 
142  $res = $this->db->queryF(
143  'SELECT COUNT(post_id) count_read FROM frm_user_read WHERE obj_id = %s AND usr_id = %s',
144  ['integer', 'integer'],
145  [$a_frm_id, $a_usr_id]
146  );
147 
148  while ($row = $this->db->fetchObject($res)) {
149  $count_read = (int) $row->count_read;
150  }
151  } else {
152  $res = $this->db->queryF(
153  '
154  SELECT COUNT(pos_pk) num_posts FROM frm_posts
155  LEFT JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
156  WHERE pos_thr_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
157  ['integer'],
158  [$a_thread_id]
159  );
160 
161  $row = $this->db->fetchObject($res);
162  $num_posts = (int) $row->num_posts;
163 
164  $res = $this->db->queryF(
165  '
166  SELECT COUNT(post_id) count_read FROM frm_user_read
167  WHERE obj_id = %s
168  AND usr_id = %s
169  AND thread_id = %s',
170  ['integer', 'integer', 'integer'],
171  [$a_frm_id, $a_frm_id, $a_thread_id]
172  );
173 
174  $row = $this->db->fetchObject($res);
175  $count_read = (int) $row->count_read;
176  }
177  $unread = $num_posts - $count_read;
178 
179  return max($unread, 0);
180  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ getNumStickyThreads()

ilObjForum::getNumStickyThreads ( )

Definition at line 1102 of file class.ilObjForum.php.

References $res.

1102  : int
1103  {
1104  $res = $this->db->query(
1105  'SELECT COUNT(is_sticky) num_sticky FROM frm_threads
1106  INNER JOIN frm_data ON top_pk = thr_top_fk
1107  WHERE frm_data.top_frm_fk = ' . $this->db->quote($this->getId(), 'integer') . '
1108  AND is_sticky = ' . $this->db->quote(1, 'integer')
1109  );
1110  if ($row = $this->db->fetchAssoc($res)) {
1111  return (int) $row['num_sticky'];
1112  }
1113 
1114  return 0;
1115  }
$res
Definition: ltiservices.php:69

◆ getPageObjIds()

ilObjForum::getPageObjIds ( )
Returns
int[]

Definition at line 1120 of file class.ilObjForum.php.

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

1120  : array
1121  {
1122  $pageObjIds = [];
1123 
1124  $sql = 'SELECT DISTINCT page_id FROM page_object WHERE parent_id = %s AND parent_type = %s';
1125  $res = $this->db->queryF(
1126  $sql,
1127  ['integer', 'text'],
1128  [$this->getId(), $this->getType()]
1129  );
1130 
1131  while ($row = $this->db->fetchAssoc($res)) {
1132  $pageObjIds[] = (int) $row['page_id'];
1133  }
1134 
1135  return $pageObjIds;
1136  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ getUserIdsOfLastPostsByRefIdAndThreadIds()

static ilObjForum::getUserIdsOfLastPostsByRefIdAndThreadIds ( int  $ref_id,
array  $thread_ids 
)
static
Parameters
int$ref_id
int[]$thread_ids
Returns
int[]

Definition at line 1037 of file class.ilObjForum.php.

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

Referenced by ilForumTopicTableGUI\initMergeThreadsTable().

1037  : array
1038  {
1039  global $DIC;
1040 
1041  $ilAccess = $DIC->access();
1042  $ilUser = $DIC->user();
1043  $ilDB = $DIC->database();
1044 
1045  $act_clause = '';
1046  $act_inner_clause = '';
1047  if (!$ilAccess->checkAccess('moderate_frm', '', $ref_id)) {
1048  $act_clause .= " AND (t1.pos_status = " . $ilDB->quote(
1049  1,
1050  "integer"
1051  ) . " OR t1.pos_author_id = " . $ilDB->quote($ilUser->getId(), "integer") . ") ";
1052  $act_inner_clause .= " AND (t3.pos_status = " . $ilDB->quote(
1053  1,
1054  "integer"
1055  ) . " OR t3.pos_author_id = " . $ilDB->quote($ilUser->getId(), "integer") . ") ";
1056  }
1057 
1058  $in = $ilDB->in("t1.pos_thr_fk", $thread_ids, false, 'integer');
1059  $inner_in = $ilDB->in("t3.pos_thr_fk", $thread_ids, false, 'integer');
1060 
1061  $query = "
1062  SELECT t1.pos_display_user_id, t1.update_user
1063  FROM frm_posts t1
1064  INNER JOIN frm_posts_tree tree1 ON tree1.pos_fk = t1.pos_pk AND tree1.parent_pos != 0
1065  INNER JOIN (
1066  SELECT t3.pos_thr_fk, MAX(t3.pos_date) pos_date
1067  FROM frm_posts t3
1068  INNER JOIN frm_posts_tree tree2 ON tree2.pos_fk = t3.pos_pk AND tree2.parent_pos != 0
1069  WHERE $inner_in $act_inner_clause
1070  GROUP BY t3.pos_thr_fk
1071  ) t2 ON t2.pos_thr_fk = t1.pos_thr_fk AND t2.pos_date = t1.pos_date
1072  WHERE $in $act_clause
1073  GROUP BY t1.pos_thr_fk, t1.pos_display_user_id, t1.update_user
1074  ";
1075 
1076  $usr_ids = [];
1077 
1078  $res = $ilDB->query($query);
1079  while ($row = $ilDB->fetchAssoc($res)) {
1080  if ((int) $row['pos_display_user_id']) {
1081  $usr_ids[] = (int) $row['pos_display_user_id'];
1082  }
1083  if ((int) $row['update_user']) {
1084  $usr_ids[] = (int) $row['update_user'];
1085  }
1086  }
1087 
1088  return array_unique($usr_ids);
1089  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initDefaultRoles()

ilObjForum::initDefaultRoles ( )

Definition at line 607 of file class.ilObjForum.php.

References ilObjRole\createDefaultRole(), ilObject\getId(), and ilObject\getRefId().

607  : void
608  {
610  'il_frm_moderator_' . $this->getRefId(),
611  "Moderator of forum obj_no." . $this->getId(),
612  'il_frm_moderator',
613  $this->getRefId()
614  );
615  }
static createDefaultRole(string $a_title, string $a_description, string $a_tpl_name, int $a_ref_id)
+ Here is the call graph for this function:

◆ isRead()

ilObjForum::isRead (   $a_usr_id,
  $a_post_id 
)

Definition at line 243 of file class.ilObjForum.php.

References $res.

243  : bool
244  {
245  $res = $this->db->queryF(
246  'SELECT * FROM frm_user_read WHERE usr_id = %s AND post_id = %s',
247  ['integer', 'integer'],
248  [$a_usr_id, $a_post_id]
249  );
250 
251  return (bool) $this->db->numRows($res);
252  }
$res
Definition: ltiservices.php:69

◆ lookupForumIdByObjId()

static ilObjForum::lookupForumIdByObjId ( int  $obj_id)
static

Definition at line 720 of file class.ilObjForum.php.

Referenced by ilForumExportGUI\ensureThreadBelongsToForum(), ilObjForumGUI\ensureThreadBelongsToForum(), and ilObjForumGUI\getContent().

720  : int
721  {
722  if (array_key_exists($obj_id, self::$obj_id_to_forum_id_cache)) {
723  return self::$obj_id_to_forum_id_cache[$obj_id];
724  }
725 
726  self::preloadForumIdsByObjIds([$obj_id]);
727 
728  return self::$obj_id_to_forum_id_cache[$obj_id];
729  }
+ Here is the caller graph for this function:

◆ lookupForumIdByRefId()

static ilObjForum::lookupForumIdByRefId ( int  $ref_id)
static

Definition at line 731 of file class.ilObjForum.php.

References ilObject\$ref_id.

Referenced by ilObjForumGUI\autosaveDraftAsyncObject(), ilObjForumGUI\autosaveThreadDraftAsyncObject(), and ilForumPostDraft\getDraftsStatisticsByRefId().

731  : int
732  {
733  if (array_key_exists($ref_id, self::$ref_id_to_forum_id_cache)) {
734  return self::$ref_id_to_forum_id_cache[$ref_id];
735  }
736 
737  self::preloadForumIdsByRefIds([$ref_id]);
738 
739  return self::$ref_id_to_forum_id_cache[$ref_id];
740  }
+ Here is the caller graph for this function:

◆ lookupLastPostByRefId()

static ilObjForum::lookupLastPostByRefId ( int  $ref_id)
static

Definition at line 958 of file class.ilObjForum.php.

References $data, $DIC, $ilDB, $ilUser, $query, ilObject\$ref_id, $res, and ILIAS\Repository\int().

Referenced by ilObjForumAccess\getLastPostByRefId().

958  : ?array
959  {
960  global $DIC;
961 
962  $ilAccess = $DIC->access();
963  $ilUser = $DIC->user();
964  $ilDB = $DIC->database();
965 
966  if (array_key_exists($ref_id, self::$forum_last_post_cache)) {
967  return self::$forum_last_post_cache[$ref_id];
968  }
969 
970  $forumId = self::lookupForumIdByRefId($ref_id);
971  if (!$forumId) {
972  self::$forum_last_post_cache[$ref_id] = null;
973  return self::$forum_last_post_cache[$ref_id];
974  }
975 
976  $act_clause = '';
977  if (!$ilAccess->checkAccess('moderate_frm', '', $ref_id)) {
978  $act_clause .= ' AND (frm_posts.pos_status = ' . $ilDB->quote(
979  1,
980  'integer'
981  ) . ' OR frm_posts.pos_author_id = ' . $ilDB->quote($ilUser->getId(), 'integer') . ') ';
982  }
983 
984  $ilDB->setLimit(1, 0);
985  $query = "
986  SELECT *
987  FROM frm_posts
988  INNER JOIN frm_posts_tree tree1
989  ON tree1.pos_fk = frm_posts.pos_pk
990  AND tree1.parent_pos != 0
991  WHERE pos_top_fk = %s $act_clause
992  ORDER BY pos_date DESC
993  ";
994  $res = $ilDB->queryF(
995  $query,
996  ['integer'],
997  [$forumId]
998  );
999 
1000  $data = $ilDB->fetchAssoc($res);
1001  if (!is_array($data) || empty($data)) {
1002  self::$forum_last_post_cache[$ref_id] = null;
1003  return self::$forum_last_post_cache[$ref_id];
1004  }
1005 
1006  $casted_data = [];
1007  $casted_data['pos_pk'] = (int) $data['pos_pk'];
1008  $casted_data['pos_top_fk'] = (int) $data['pos_top_fk'];
1009  $casted_data['pos_thr_fk'] = (int) $data['pos_thr_fk'];
1010  $casted_data['pos_usr_alias'] = (string) $data['pos_usr_alias'];
1011  $casted_data['pos_subject'] = (string) $data['pos_subject'];
1012  $casted_data['pos_date'] = (string) $data['pos_date'];
1013  $casted_data['pos_update'] = (string) $data['pos_update'];
1014  $casted_data['update_user'] = (int) $data['update_user'];
1015  $casted_data['pos_cens'] = (int) $data['pos_cens'];
1016  $casted_data['pos_cens_com'] = (string) $data['pos_cens_com'];
1017  $casted_data['notify'] = (int) $data['notify'];
1018  $casted_data['import_name'] = (string) $data['import_name'];
1019  $casted_data['pos_status'] = (int) $data['pos_status'];
1020  $casted_data['pos_message'] = (string) $data['pos_message'];
1021  $casted_data['pos_author_id'] = (int) $data['pos_author_id'];
1022  $casted_data['pos_display_user_id'] = (int) $data['pos_display_user_id'];
1023  $casted_data['is_author_moderator'] = (int) $data['is_author_moderator'];
1024  $casted_data['pos_cens_date'] = (string) $data['pos_cens_date'];
1025  $casted_data['pos_activation_date'] = (string) $data['pos_activation_date'];
1026 
1027  self::$forum_last_post_cache[$ref_id] = $casted_data;
1028 
1029  return self::$forum_last_post_cache[$ref_id];
1030  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupStatisticsByRefId()

static ilObjForum::lookupStatisticsByRefId ( int  $ref_id)
static
Parameters
int$ref_id
Returns
array{num_posts: int, num_unread_posts: int, num_new_posts: int}

Definition at line 814 of file class.ilObjForum.php.

References $DIC, $i, $ilDB, $ilSetting, $ilUser, $query, ilObject\$ref_id, $res, ilObject\_lookupObjectId(), ilSetting\_lookupValue(), ilForumProperties\FORUM_OVERVIEW_WITH_NEW_POSTS, ilForumProperties\getInstance(), and ILIAS\Repository\int().

Referenced by ilObjForumAccess\getStatisticsByRefId().

814  : array
815  {
816  global $DIC;
817 
818  $ilAccess = $DIC->access();
819  $ilUser = $DIC->user();
820  $ilDB = $DIC->database();
821  $ilSetting = $DIC->settings();
822 
823  if (isset(self::$forum_statistics_cache[$ref_id])) {
824  return self::$forum_statistics_cache[$ref_id];
825  }
826 
827  $statistics = [
828  'num_posts' => 0,
829  'num_unread_posts' => 0,
830  'num_new_posts' => 0
831  ];
832 
833  $forumId = self::lookupForumIdByRefId($ref_id);
834  if (!$forumId) {
835  self::$forum_statistics_cache[$ref_id] = $statistics;
836  return self::$forum_statistics_cache[$ref_id];
837  }
838 
840  $is_post_activation_enabled = $objProperties->isPostActivationEnabled();
841 
842  $act_clause = '';
843 
844  if ($is_post_activation_enabled && !$ilAccess->checkAccess('moderate_frm', '', $ref_id)) {
845  $act_clause .= ' AND (frm_posts.pos_status = ' . $ilDB->quote(
846  1,
847  'integer'
848  ) . ' OR frm_posts.pos_author_id = ' . $ilDB->quote($ilUser->getId(), 'integer') . ') ';
849  }
850 
851  $weeks = self::NEWS_NEW_CONSIDERATION_WEEKS;
852  if ($ilSetting->get('frm_store_new')) {
853  $weeks = (int) $ilSetting->get('frm_store_new');
854  }
855 
856  $new_deadline = (new DateTime())
857  ->setTimestamp(time() - 60 * 60 * 24 * 7 * $weeks)
858  ->format('Y-m-d H:i:s');
859 
860  if (!$ilUser->isAnonymous()) {
861  $query = "
862  (SELECT COUNT(frm_posts.pos_pk) cnt
863  FROM frm_posts
864  INNER JOIN frm_posts_tree tree1
865  ON tree1.pos_fk = frm_posts.pos_pk
866  AND tree1.parent_pos != 0
867  INNER JOIN frm_threads ON frm_posts.pos_thr_fk = frm_threads.thr_pk
868  WHERE frm_threads.thr_top_fk = %s $act_clause)
869 
870  UNION ALL
871 
872  (SELECT COUNT(DISTINCT(frm_user_read.post_id)) cnt
873  FROM frm_user_read
874  INNER JOIN frm_posts ON frm_user_read.post_id = frm_posts.pos_pk
875  INNER JOIN frm_posts_tree tree1
876  ON tree1.pos_fk = frm_posts.pos_pk
877  AND tree1.parent_pos != 0
878  INNER JOIN frm_threads ON frm_threads.thr_pk = frm_posts.pos_thr_fk
879  WHERE frm_user_read.usr_id = %s AND frm_posts.pos_top_fk = %s $act_clause)
880  ";
881 
882  $types = ['integer', 'integer', 'integer'];
883  $values = [$forumId, $ilUser->getId(), $forumId];
884 
885  $forum_overview_setting = (int) ilSetting::_lookupValue('frma', 'forum_overview');
886  if ($forum_overview_setting === ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS) {
887  $news_types = ['integer', 'integer', 'integer', 'timestamp', 'integer'];
888  $news_values = [$ilUser->getId(), $ilUser->getId(), $forumId, $new_deadline, $ilUser->getId()];
889 
890  $query .= "
891  UNION ALL
892 
893  (SELECT COUNT(frm_posts.pos_pk) cnt
894  FROM frm_posts
895  INNER JOIN frm_posts_tree tree1
896  ON tree1.pos_fk = frm_posts.pos_pk
897  AND tree1.parent_pos != 0
898  LEFT JOIN frm_user_read ON (post_id = frm_posts.pos_pk AND frm_user_read.usr_id = %s)
899  LEFT JOIN frm_thread_access ON (frm_thread_access.thread_id = frm_posts.pos_thr_fk AND frm_thread_access.usr_id = %s)
900  WHERE frm_posts.pos_top_fk = %s
901  AND ( (frm_posts.pos_update > frm_thread_access.access_old_ts)
902  OR (frm_thread_access.access_old IS NULL AND frm_posts.pos_update > %s)
903  )
904  AND frm_posts.pos_author_id != %s
905  AND frm_user_read.usr_id IS NULL $act_clause)";
906 
907  $types = array_merge($types, $news_types);
908  $values = array_merge($values, $news_values);
909  }
910 
911  $mapping = array_keys($statistics);
912  $res = $ilDB->queryF(
913  $query,
914  $types,
915  $values
916  );
917  for ($i = 0; $i <= 2; $i++) {
918  $row = $ilDB->fetchAssoc($res);
919 
920  $statistics[$mapping[$i]] = (int) ((is_array($row) ? $row['cnt'] : 0));
921 
922  if ($i === 1) {
923  // unread = all - read
924  $statistics[$mapping[$i]] = $statistics[$mapping[$i - 1]] - $statistics[$mapping[$i]];
925  }
926  }
927  } else {
928  $query = "
929  SELECT COUNT(frm_posts.pos_pk) cnt
930  FROM frm_posts
931  INNER JOIN frm_posts_tree tree1
932  ON tree1.pos_fk = frm_posts.pos_pk
933  AND tree1.parent_pos != 0
934  INNER JOIN frm_threads ON frm_posts.pos_thr_fk = frm_threads.thr_pk
935  WHERE frm_threads.thr_top_fk = %s $act_clause
936  ";
937  $types = ['integer'];
938  $values = [$forumId];
939  $res = $ilDB->queryF(
940  $query,
941  $types,
942  $values
943  );
944  $row = $ilDB->fetchAssoc($res);
945 
946  $statistics = [
947  'num_posts' => (int) $row['cnt'],
948  'num_unread_posts' => (int) $row['cnt'],
949  'num_new_posts' => (int) $row['cnt']
950  ];
951  }
952 
953  self::$forum_statistics_cache[$ref_id] = $statistics;
954 
955  return self::$forum_statistics_cache[$ref_id];
956  }
$res
Definition: ltiservices.php:69
static getInstance(int $a_obj_id=0)
static _lookupValue(string $a_module, string $a_keyword)
global $DIC
Definition: feed.php:28
static _lookupObjectId(int $ref_id)
$query
global $ilSetting
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:34
$i
Definition: metadata.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ markAllThreadsRead()

ilObjForum::markAllThreadsRead ( int  $a_usr_id)

Definition at line 192 of file class.ilObjForum.php.

References $res, ilObject\getId(), and markThreadRead().

192  : void
193  {
194  $res = $this->db->queryF(
195  'SELECT thr_pk FROM frm_data, frm_threads WHERE top_frm_fk = %s AND top_pk = thr_top_fk',
196  ['integer'],
197  [$this->getId()]
198  );
199 
200  while ($row = $this->db->fetchObject($res)) {
201  $this->markThreadRead($a_usr_id, (int) $row->thr_pk);
202  }
203  }
$res
Definition: ltiservices.php:69
markThreadRead(int $a_usr_id, int $a_thread_id)
+ Here is the call graph for this function:

◆ markPostRead()

ilObjForum::markPostRead ( int  $a_usr_id,
int  $a_thread_id,
int  $a_post_id 
)

Definition at line 205 of file class.ilObjForum.php.

References $res, and ilObject\getId().

Referenced by markThreadRead().

205  : void
206  {
207  $res = $this->db->queryF(
208  '
209  SELECT thread_id FROM frm_user_read
210  WHERE usr_id = %s
211  AND obj_id = %s
212  AND thread_id = %s
213  AND post_id = %s',
214  ['integer', 'integer', 'integer', 'integer'],
215  [$a_usr_id, $this->getId(), $a_thread_id, $a_post_id]
216  );
217 
218  if (!$this->db->numRows($res)) {
219  $this->db->manipulateF(
220  '
221  INSERT INTO frm_user_read
222  ( usr_id,
223  obj_id,
224  thread_id,
225  post_id
226  )
227  VALUES (%s,%s,%s,%s)',
228  ['integer', 'integer', 'integer', 'integer'],
229  [$a_usr_id, $this->getId(), $a_thread_id, $a_post_id]
230  );
231  }
232  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ markPostUnread()

ilObjForum::markPostUnread ( int  $a_user_id,
int  $a_post_id 
)

Definition at line 234 of file class.ilObjForum.php.

234  : void
235  {
236  $this->db->manipulateF(
237  'DELETE FROM frm_user_read WHERE usr_id = %s AND post_id = %s',
238  ['integer', 'integer'],
239  [$a_user_id, $a_post_id]
240  );
241  }

◆ markThreadRead()

ilObjForum::markThreadRead ( int  $a_usr_id,
int  $a_thread_id 
)

Definition at line 182 of file class.ilObjForum.php.

References $res, and markPostRead().

Referenced by markAllThreadsRead().

182  : bool
183  {
184  $res = $this->db->queryF('SELECT pos_pk FROM frm_posts WHERE pos_thr_fk = %s', ['integer'], [$a_thread_id]);
185  while ($row = $this->db->fetchObject($res)) {
186  $this->markPostRead($a_usr_id, $a_thread_id, (int) $row->pos_pk);
187  }
188 
189  return true;
190  }
$res
Definition: ltiservices.php:69
markPostRead(int $a_usr_id, int $a_thread_id, int $a_post_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mergeForumUserRead()

static ilObjForum::mergeForumUserRead ( int  $merge_source_thread_id,
int  $merge_target_thread_id 
)
static

Definition at line 1091 of file class.ilObjForum.php.

References $DIC.

Referenced by ilForum\mergeThreads().

1091  : void
1092  {
1093  global $DIC;
1094 
1095  $DIC->database()->update(
1096  'frm_user_read',
1097  ['thread_id' => ['integer', $merge_target_thread_id]],
1098  ['thread_id' => ['integer', $merge_source_thread_id]]
1099  );
1100  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ preloadForumIdsByObjIds()

static ilObjForum::preloadForumIdsByObjIds ( array  $obj_ids)
static
Parameters
int[]$obj_ids

Definition at line 745 of file class.ilObjForum.php.

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

745  : void
746  {
747  global $DIC;
748 
749  $ilDB = $DIC->database();
750 
751  if (count($obj_ids) === 1) {
752  $in = ' objr.obj_id = ' . $ilDB->quote(current($obj_ids), 'integer') . ' ';
753  } else {
754  $in = $ilDB->in('objr.obj_id', $obj_ids, false, 'integer');
755  }
756  $query = "
757  SELECT frmd.top_pk, objr.ref_id, objr.obj_id
758  FROM object_reference objr
759  INNER JOIN frm_data frmd ON frmd.top_frm_fk = objr.obj_id
760  WHERE $in
761  ";
762  $res = $ilDB->query($query);
763 
764  // Prepare cache array
765  foreach ($obj_ids as $obj_id) {
766  self::$obj_id_to_forum_id_cache[$obj_id] = 0;
767  }
768 
769  while ($row = $ilDB->fetchAssoc($res)) {
770  self::$obj_id_to_forum_id_cache[(int) $row['obj_id']] = (int) $row['top_pk'];
771  self::$ref_id_to_forum_id_cache[(int) $row['ref_id']] = (int) $row['top_pk'];
772  }
773  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ Here is the call graph for this function:

◆ preloadForumIdsByRefIds()

static ilObjForum::preloadForumIdsByRefIds ( array  $ref_ids)
static
Parameters
int[]$ref_ids

Definition at line 778 of file class.ilObjForum.php.

References $DIC, $ilDB, $query, ilObject\$ref_id, $res, and ILIAS\Repository\int().

Referenced by ilObjForumAccess\_preloadData().

778  : void
779  {
780  global $DIC;
781 
782  $ilDB = $DIC->database();
783 
784  if (count($ref_ids) === 1) {
785  $in = " objr.ref_id = " . $ilDB->quote(current($ref_ids), 'integer') . " ";
786  } else {
787  $in = $ilDB->in('objr.ref_id', $ref_ids, false, 'integer');
788  }
789  $query = "
790  SELECT frmd.top_pk, objr.ref_id, objr.obj_id
791  FROM object_reference objr
792  INNER JOIN frm_data frmd ON frmd.top_frm_fk = objr.obj_id
793  WHERE $in
794  ";
795  $res = $ilDB->query($query);
796 
797  // Prepare cache array
798  foreach ($ref_ids as $ref_id) {
799  if (!array_key_exists($ref_id, self::$ref_id_to_forum_id_cache)) {
800  self::$ref_id_to_forum_id_cache[$ref_id] = 0;
801  }
802  }
803 
804  while ($row = $ilDB->fetchAssoc($res)) {
805  self::$obj_id_to_forum_id_cache[(int) $row['obj_id']] = (int) $row['top_pk'];
806  self::$ref_id_to_forum_id_cache[(int) $row['ref_id']] = (int) $row['top_pk'];
807  }
808  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveData()

ilObjForum::saveData ( )

Definition at line 652 of file class.ilObjForum.php.

References ilObject\getDescription(), ilObject\getId(), ilObject\getTitle(), ilUtil\now(), and ILIAS\Repository\user().

Referenced by create().

652  : void
653  {
654  $nextId = $this->db->nextId('frm_data');
655 
656  $top_data = [
657  'top_frm_fk' => $this->getId(),
658  'top_name' => $this->getTitle(),
659  'top_description' => $this->getDescription(),
660  'top_num_posts' => 0,
661  'top_num_threads' => 0,
662  'top_last_post' => null,
663  'top_mods' => 0,
664  'top_usr_id' => $this->user->getId(),
665  'top_date' => ilUtil::now()
666  ];
667 
668  $this->db->manipulateF(
669  '
670  INSERT INTO frm_data
671  (
672  top_pk,
673  top_frm_fk,
674  top_name,
675  top_description,
676  top_num_posts,
677  top_num_threads,
678  top_last_post,
679  top_mods,
680  top_date,
681  top_usr_id
682  )
683  VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
684  [
685  'integer',
686  'integer',
687  'text',
688  'text',
689  'integer',
690  'integer',
691  'text',
692  'integer',
693  'timestamp',
694  'integer'
695  ],
696  [
697  $nextId,
698  $top_data['top_frm_fk'],
699  $top_data['top_name'],
700  $top_data['top_description'],
701  $top_data['top_num_posts'],
702  $top_data['top_num_threads'],
703  $top_data['top_last_post'],
704  $top_data['top_mods'],
705  $top_data['top_date'],
706  $top_data['top_usr_id']
707  ]
708  );
709  }
static now()
Return current timestamp in Y-m-d H:i:s format.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPermissions()

ilObjForum::setPermissions ( int  $parent_ref_id)

Definition at line 84 of file class.ilObjForum.php.

References ilObject\getOwner(), ilObject\getRefId(), ILIAS\Repository\rbac(), and updateModeratorRole().

84  : void
85  {
86  parent::setPermissions($parent_ref_id);
87 
88  $roles = [self::_lookupModeratorRole($this->getRefId())];
89  $this->rbac->admin()->assignUser($roles[0], $this->getOwner());
90  $this->updateModeratorRole($roles[0]);
91  }
updateModeratorRole(int $role_id)
+ Here is the call graph for this function:

◆ setThreadSorting()

ilObjForum::setThreadSorting ( int  $a_thr_pk,
int  $a_sorting_value 
)

Definition at line 711 of file class.ilObjForum.php.

711  : void
712  {
713  $this->db->update(
714  'frm_threads',
715  ['thread_sorting' => ['integer', $a_sorting_value]],
716  ['thr_pk' => ['integer', $a_thr_pk]]
717  );
718  }

◆ update()

ilObjForum::update ( )

Definition at line 348 of file class.ilObjForum.php.

References Vendor\Package\$e, $target_id, ilPageObject\_exists(), ilCopyWizardOptions\_getInstance(), cloneAutoGeneratedRoles(), ilObject\getDescription(), ilObject\getId(), ilForumProperties\getInstance(), ilObject\getOfflineStatus(), ilObject\getRefId(), ilObject\getTitle(), ilObject\getType(), ilFileDataForum\ilClone(), ilPageObject\lookupTranslations(), and ILIAS\Repository\user().

Referenced by create().

348  : bool
349  {
350  if (parent::update()) {
351  $this->db->manipulateF(
352  'UPDATE frm_data SET top_name = %s, top_description = %s, top_update = %s, update_user = %s WHERE top_frm_fk = %s',
353  ['text', 'text', 'timestamp', 'integer', 'integer'],
354  [
355  $this->getTitle(),
356  $this->getDescription(),
357  date("Y-m-d H:i:s"),
358  $this->user->getId(),
359  $this->getId()
360  ]
361  );
362 
363  return true;
364  }
365 
366  return false;
367  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateLastAccess()

ilObjForum::updateLastAccess ( int  $a_usr_id,
int  $a_thread_id 
)

Definition at line 254 of file class.ilObjForum.php.

References $data, $res, and ilObject\getId().

254  : void
255  {
256  $res = $this->db->queryF(
257  'SELECT * FROM frm_thread_access WHERE usr_id = %s AND obj_id = %s AND thread_id = %s',
258  ['integer', 'integer', 'integer'],
259  [$a_usr_id, $this->getId(), $a_thread_id]
260  );
261  $data = $this->db->fetchAssoc($res);
262 
263  if (is_array($data)) {
264  $this->db->replace(
265  'frm_thread_access',
266  [
267  'usr_id' => ['integer', $a_usr_id],
268  'obj_id' => ['integer', $this->getId()],
269  'thread_id' => ['integer', $a_thread_id]
270  ],
271  [
272  'access_last' => ['integer', time()],
273  'access_old' => ['integer', (int) ($data['access_old'] ?? 0)],
274  'access_old_ts' => ['timestamp', $data['access_old_ts']]
275  ]
276  );
277  }
278  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ updateModeratorRole()

ilObjForum::updateModeratorRole ( int  $role_id)

Definition at line 93 of file class.ilObjForum.php.

References ilObject\getId().

Referenced by setPermissions().

93  : void
94  {
95  $this->db->manipulate('UPDATE frm_data SET top_mods = ' . $this->db->quote(
96  $role_id,
97  'integer'
98  ) . ' WHERE top_frm_fk = ' . $this->db->quote($this->getId(), 'integer'));
99  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateMoficationUserId()

ilObjForum::updateMoficationUserId ( int  $usr_id)

Definition at line 339 of file class.ilObjForum.php.

References ilObject\getId().

339  : void
340  {
341  $this->db->manipulateF(
342  'UPDATE frm_data SET update_user = %s WHERE top_frm_fk = %s',
343  ['integer', 'integer'],
344  [$usr_id, $this->getId()],
345  );
346  }
+ Here is the call graph for this function:

Field Documentation

◆ $Forum

ilForum ilObjForum::$Forum

Definition at line 30 of file class.ilObjForum.php.

◆ $forum_last_post_cache

array ilObjForum::$forum_last_post_cache = []
staticprivate

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

◆ $forum_statistics_cache

array ilObjForum::$forum_statistics_cache = []
staticprivate

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

◆ $logger

ilLogger ilObjForum::$logger
private

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

◆ $obj_id_to_forum_id_cache

array ilObjForum::$obj_id_to_forum_id_cache = []
staticprivate

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

◆ $rbac

ILIAS DI RBACServices ilObjForum::$rbac
private

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

◆ $ref_id_to_forum_id_cache

array ilObjForum::$ref_id_to_forum_id_cache = []
staticprivate

Definition at line 34 of file class.ilObjForum.php.

◆ NEWS_NEW_CONSIDERATION_WEEKS

const ilObjForum::NEWS_NEW_CONSIDERATION_WEEKS = 8

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

Referenced by ilForum\getAllThreads().


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