ILIAS  trunk Revision v13.0_alpha-46-gad4e41c4eac
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 ()
 note: title, description and type should be set when this function is called More...
 
 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)
 
 updateModificationUserId (int $usr_id)
 
 update ()
 
 isParentMembershipEnabledContainer ()
 
 getAllForumParticipants ()
 
 parentParticipants ()
 
 cloneAutoGeneratedRoles (self $new_obj)
 
 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...
 
 createSettings ()
 
 saveData ()
 
 getNumStickyThreads ()
 
 getPageObjIds ()
 
- Public Member Functions inherited from ilObject
 getObjectProperties ()
 
 flushObjectProperties ()
 
 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 $description)
 
 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, int $new_obj_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 _deleteUser (int $a_usr_id)
 
static _deleteReadEntries (int $a_post_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 getIconForType (string $type)
 
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

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

readonly ILIAS DI RBACServices $rbac
 
readonly ilLogger $logger
 
readonly ilSetting $settings
 

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
 
LOMServices $lom_services
 
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 = ""
 
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 41 of file class.ilObjForum.php.

42 {
43 global $DIC;
44
45 $this->type = 'frm';
46 parent::__construct($a_id, $a_call_by_reference);
47
48 $this->rbac = $DIC->rbac();
49 $this->logger = $DIC->logger()->forComponent('frm');
50
51 $this->settings = $DIC->settings();
52 $this->Forum = new ilForum();
53 }
Class Forum core functions for forum.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteReadEntries()

static ilObjForum::_deleteReadEntries ( int  $a_post_id)
static

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

259 : void
260 {
261 global $DIC;
262
263 $DIC->database()->manipulateF('DELETE FROM frm_user_read WHERE post_id = %s', ['integer'], [$a_post_id]);
264 }

References $DIC.

Referenced by ilForum\deletePost().

+ Here is the caller graph for this function:

◆ _deleteUser()

static ilObjForum::_deleteUser ( int  $a_usr_id)
static

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

249 : void
250 {
251 global $DIC;
252
253 $data = [$a_usr_id];
254
255 $DIC->database()->manipulateF('DELETE FROM frm_user_read WHERE usr_id = %s', ['integer'], $data);
256 $DIC->database()->manipulateF('DELETE FROM frm_notification WHERE user_id = %s', ['integer'], $data);
257 }
$data
Definition: storeScorm.php:45

References $data, and $DIC.

◆ _lookupModeratorRole()

static ilObjForum::_lookupModeratorRole ( int  $a_ref_id)
static

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

635 : int
636 {
637 global $DIC;
638
639 $ilDB = $DIC->database();
640
641 $mod_title = 'il_frm_moderator_' . $a_ref_id;
642
643 $res = $ilDB->queryF('SELECT obj_id FROM object_data WHERE title = %s', ['text'], [$mod_title]);
644 while ($row = $ilDB->fetchObject($res)) {
645 return (int) $row->obj_id;
646 }
647
648 return 0;
649 }
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, and $res.

Referenced by cloneAutoGeneratedRoles(), and setPermissions().

+ Here is the caller graph for this function:

◆ _lookupThreadSubject()

static ilObjForum::_lookupThreadSubject ( int  $a_thread_id)
static

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

96 : string
97 {
98 global $DIC;
99
100 $ilDB = $DIC->database();
101
102 $res = $ilDB->queryF('SELECT thr_subject FROM frm_threads WHERE thr_pk = %s', ['integer'], [$a_thread_id]);
103 while ($row = $ilDB->fetchObject($res)) {
104 return $row->thr_subject ?? '';
105 }
106
107 return '';
108 }

References $DIC, $ilDB, and $res.

Referenced by ILIAS\Forum\Search\SubitemPropertiesReader\getSubitemProperties().

+ Here is the caller graph for this function:

◆ cloneAutoGeneratedRoles()

ilObjForum::cloneAutoGeneratedRoles ( self  $new_obj)

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

468 : void
469 {
470 $src_moderator_role_id = self::_lookupModeratorRole($this->getRefId());
471 $new_moderator_role_id = self::_lookupModeratorRole($new_obj->getRefId());
472
473 if (
474 0 === $src_moderator_role_id ||
475 0 === $new_moderator_role_id ||
476 0 === $this->getRefId() ||
477 0 === $new_obj->getRefId()
478 ) {
479 $this->logger->info('Error cloning auto generated role: il_frm_moderator');
480 }
481
482 $this->rbac->admin()->copyRolePermissions(
483 $src_moderator_role_id,
484 $this->getRefId(),
485 $new_obj->getRefId(),
486 $new_moderator_role_id,
487 true
488 );
489
490 $this->logger->info('Finished copying of role il_frm_moderator.');
491
492 $moderators = new ilForumModerators($this->getRefId());
493 $src_moderator_usr_ids = $moderators->getCurrentModerators();
494 foreach ($src_moderator_usr_ids as $usr_id) {
495 // The object owner is already member of the moderator role when this method is called
496 // Since the new static caches are introduced with ILIAS 5.0, a database error occurs if we try to assign the user here.
497 if ($this->getOwner() !== $usr_id) {
498 $this->rbac->admin()->assignUser($new_moderator_role_id, $usr_id);
499 }
500 }
501 }
Class ilForumModerators.
static _lookupModeratorRole(int $a_ref_id)

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

+ Here is the call graph for this function:

◆ create()

ilObjForum::create ( )

note: title, description and type should be set when this function is called

Reimplemented from ilObject.

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

55 : int
56 {
57 $id = parent::create();
58
59 $properties = ilForumProperties::getInstance($this->getId());
60 $properties->setDefaultView(
61 (int) $this->settings->get('forum_default_view', (string) ilForumProperties::VIEW_DATE_ASC)
62 );
63 $properties->setAnonymisation(false);
64 $properties->setStatisticsStatus(false);
65 $properties->setPostActivation(false);
66 $properties->insert();
67
68 $this->createSettings();
69
70 $this->setOfflineStatus(true);
71 $this->update();
72 $this->saveData();
73
74 return $id;
75 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getInstance(int $a_obj_id=0)
setOfflineStatus(bool $status)

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

+ Here is the call graph for this function:

◆ createSettings()

ilObjForum::createSettings ( )

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

651 : void
652 {
653 // news settings (public notifications yes/no)
654 $default_visibility = ilNewsItem::getDefaultVisibility();
655 if ($default_visibility === 'public') {
656 ilBlockSetting::_write('news', 'public_notifications', '1', 0, $this->getId());
657 }
658 }
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
static getDefaultVisibility()
Get global default visibility for news items.

References ilBlockSetting\_write(), ilNewsItem\getDefaultVisibility(), and ilObject\getId().

Referenced by create().

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

◆ delete()

ilObjForum::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!!

Returns
bool true if object was removed completely; false if only a references was removed

Reimplemented from ilObject.

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

503 : bool
504 {
505 $this->Forum->setForumId($this->getId());
506
507 if (!parent::delete()) {
508 return false;
509 }
510
511 if (ilForumPage::_exists($this->getType(), $this->getId())) {
512 $originalPageObject = new ilForumPage($this->getId());
513 $originalPageObject->delete();
514 }
515
516 $this->Forum->setMDB2WhereCondition('top_frm_fk = %s ', [ilDBConstants::T_INTEGER], [$this->getId()]);
517
518 $topData = $this->Forum->getOneTopic();
519
520 if ($topData !== null) {
521 $threads = $this->Forum->getAllThreads($topData->getTopPk(), [
522 'is_moderator' => true,
523 ]);
524 $thread_ids_to_delete = [];
525 foreach ($threads['items'] as $thread) {
526 $thread_ids_to_delete[$thread->getId()] = $thread->getId();
527 }
528
529 // Get All posting IDs
530 $posting_ids = [];
531 $res = $this->db->query(
532 'SELECT pos_pk FROM frm_posts WHERE '
533 . $this->db->in('pos_thr_fk', $thread_ids_to_delete, false, ilDBConstants::T_INTEGER)
534 );
535
536 while ($row = $res->fetchObject()) {
537 $posting_ids[] = (int) $row->pos_pk;
538 }
539
540 $tmp_file_obj = new ilFileDataForum($this->getId());
541 $tmp_file_obj->delete($posting_ids);
542
543 // Get All draft IDs
544 $draft_ids = [];
545 $res = $this->db->query(
546 'SELECT draft_id FROM frm_posts_drafts WHERE '
547 . $this->db->in('thread_id', $thread_ids_to_delete, false, ilDBConstants::T_INTEGER)
548 );
549
550 while ($row = $res->fetchObject()) {
551 $draft_ids[] = (int) $row->draft_id;
552 }
553
554 $tmp_file_obj = new ilFileDataForumDrafts($this->getId());
555 $tmp_file_obj->delete($draft_ids);
556
557 $this->db->manipulate(
558 'DELETE FROM frm_posts_tree WHERE ' . $this->db->in(
559 'thr_fk',
560 $thread_ids_to_delete,
561 false,
563 )
564 );
565 $this->db->manipulate(
566 'DELETE FROM frm_posts WHERE ' . $this->db->in(
567 'pos_thr_fk',
568 $thread_ids_to_delete,
569 false,
571 )
572 );
573 $this->db->manipulate(
574 'DELETE FROM frm_threads WHERE ' . $this->db->in(
575 'thr_pk',
576 $thread_ids_to_delete,
577 false,
579 )
580 );
581 $this->db->manipulate(
582 'DELETE FROM frm_notification WHERE ' . $this->db->in(
583 'thread_id',
584 $thread_ids_to_delete,
585 false,
586 'integer'
587 )
588 );
589 $this->deleteDraftsByForumId($topData->getTopPk());
590 }
591
592 $obj_id = [$this->getId()];
593
594 $this->db->manipulateF('DELETE FROM frm_data WHERE top_frm_fk = %s', [ilDBConstants::T_INTEGER], $obj_id);
595 $this->db->manipulateF('DELETE FROM frm_settings WHERE obj_id = %s', [ilDBConstants::T_INTEGER], $obj_id);
596 $this->db->manipulateF('DELETE FROM frm_user_read WHERE obj_id = %s', [ilDBConstants::T_INTEGER], $obj_id);
597 $this->db->manipulateF('DELETE FROM frm_notification WHERE frm_id = %s', [ilDBConstants::T_INTEGER], $obj_id);
598 $this->db->manipulateF('DELETE FROM frm_posts_deleted WHERE obj_id = %s', [ilDBConstants::T_INTEGER], $obj_id);
599
600 return true;
601 }
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.

References $res, ilPageObject\_exists(), deleteDraftsByForumId(), ilObject\getId(), ilObject\getType(), ILIAS\Repository\int(), and ilDBConstants\T_INTEGER.

+ Here is the call graph for this function:

◆ deleteDraftsByForumId()

ilObjForum::deleteDraftsByForumId ( int  $forum_id)
private

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

603 : void
604 {
605 $res = $this->db->queryF(
606 'SELECT draft_id FROM frm_posts_drafts WHERE forum_id = %s',
607 ['integer'],
608 [$forum_id]
609 );
610
611 $draft_ids = [];
612 while ($row = $this->db->fetchAssoc($res)) {
613 $draft_ids[] = (int) $row['draft_id'];
614 }
615
616 if ($draft_ids !== []) {
617 $historyObj = new ilForumDraftsHistory();
618 $historyObj->deleteHistoryByDraftIds($draft_ids);
619
620 $draftObj = new ilForumPostDraft();
621 $draftObj->deleteDraftsByDraftIds($draft_ids);
622 }
623 }
Class ilForumDraftHistory.
Class ilForumPostDraft.

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

Referenced by delete().

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

◆ getAllForumParticipants()

ilObjForum::getAllForumParticipants ( )
Returns
list<int>

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

428 : array
429 {
430 $participant_usr_ids = ilForum::_getModerators($this->getRefId());
431
432 try {
433 $participants = $this->parentParticipants();
434 $participant_usr_ids = array_merge(
435 $participant_usr_ids,
436 $participants->getAdmins(),
437 $participants->getMembers(),
438 $participants->getTutors()
439 );
440 } catch (DomainException) {
441 }
442
443 return array_unique($participant_usr_ids);
444 }
static _getModerators(int $a_ref_id)

References ilForum\_getModerators(), ilObject\getRefId(), and parentParticipants().

+ Here is the call graph for this function:

◆ getCountUnread()

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

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

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

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

+ Here is the call graph for this function:

◆ getNumStickyThreads()

ilObjForum::getNumStickyThreads ( )

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

1062 : int
1063 {
1064 $res = $this->db->query(
1065 'SELECT COUNT(is_sticky) num_sticky FROM frm_threads
1066 INNER JOIN frm_data ON top_pk = thr_top_fk
1067 WHERE frm_data.top_frm_fk = ' . $this->db->quote($this->getId(), 'integer') . '
1068 AND is_sticky = ' . $this->db->quote(1, 'integer')
1069 );
1070 if ($row = $this->db->fetchAssoc($res)) {
1071 return (int) $row['num_sticky'];
1072 }
1073
1074 return 0;
1075 }

References $res.

◆ getPageObjIds()

ilObjForum::getPageObjIds ( )
Returns
int[]

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

1080 : array
1081 {
1082 $pageObjIds = [];
1083
1084 $sql = 'SELECT DISTINCT page_id FROM page_object WHERE parent_id = %s AND parent_type = %s';
1085 $res = $this->db->queryF(
1086 $sql,
1087 ['integer', 'text'],
1088 [$this->getId(), $this->getType()]
1089 );
1090
1091 while ($row = $this->db->fetchAssoc($res)) {
1092 $pageObjIds[] = (int) $row['page_id'];
1093 }
1094
1095 return $pageObjIds;
1096 }

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

+ Here is the call graph for this function:

◆ getUserIdsOfLastPostsByRefIdAndThreadIds()

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

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

997 : array
998 {
999 global $DIC;
1000
1001 $ilAccess = $DIC->access();
1002 $ilUser = $DIC->user();
1003 $ilDB = $DIC->database();
1004
1005 $act_clause = '';
1006 $act_inner_clause = '';
1007 if (!$ilAccess->checkAccess('moderate_frm', '', $ref_id)) {
1008 $act_clause .= " AND (t1.pos_status = " . $ilDB->quote(
1009 1,
1010 "integer"
1011 ) . " OR t1.pos_author_id = " . $ilDB->quote($ilUser->getId(), "integer") . ") ";
1012 $act_inner_clause .= " AND (t3.pos_status = " . $ilDB->quote(
1013 1,
1014 "integer"
1015 ) . " OR t3.pos_author_id = " . $ilDB->quote($ilUser->getId(), "integer") . ") ";
1016 }
1017
1018 $in = $ilDB->in("t1.pos_thr_fk", $thread_ids, false, 'integer');
1019 $inner_in = $ilDB->in("t3.pos_thr_fk", $thread_ids, false, 'integer');
1020
1021 $query = "
1022 SELECT t1.pos_display_user_id, t1.update_user
1023 FROM frm_posts t1
1024 INNER JOIN frm_posts_tree tree1 ON tree1.pos_fk = t1.pos_pk AND tree1.parent_pos != 0
1025 INNER JOIN (
1026 SELECT t3.pos_thr_fk, MAX(t3.pos_date) pos_date
1027 FROM frm_posts t3
1028 INNER JOIN frm_posts_tree tree2 ON tree2.pos_fk = t3.pos_pk AND tree2.parent_pos != 0
1029 WHERE $inner_in $act_inner_clause
1030 GROUP BY t3.pos_thr_fk
1031 ) t2 ON t2.pos_thr_fk = t1.pos_thr_fk AND t2.pos_date = t1.pos_date
1032 WHERE $in $act_clause
1033 GROUP BY t1.pos_thr_fk, t1.pos_display_user_id, t1.update_user
1034 ";
1035
1036 $usr_ids = [];
1037
1038 $res = $ilDB->query($query);
1039 while ($row = $ilDB->fetchAssoc($res)) {
1040 if ((int) $row['pos_display_user_id'] !== 0) {
1041 $usr_ids[] = (int) $row['pos_display_user_id'];
1042 }
1043 if ((int) $row['update_user'] !== 0) {
1044 $usr_ids[] = (int) $row['update_user'];
1045 }
1046 }
1047
1048 return array_unique($usr_ids);
1049 }

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

+ Here is the call graph for this function:

◆ initDefaultRoles()

ilObjForum::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.

If you want to set up default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example).

Reimplemented from ilObject.

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

625 : void
626 {
628 'il_frm_moderator_' . $this->getRefId(),
629 "Moderator of forum obj_no." . $this->getId(),
630 'il_frm_moderator',
631 $this->getRefId()
632 );
633 }
static createDefaultRole(string $a_title, string $a_description, string $a_tpl_name, int $a_ref_id)

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

+ Here is the call graph for this function:

◆ isParentMembershipEnabledContainer()

ilObjForum::isParentMembershipEnabledContainer ( )

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

415 : bool
416 {
417 $maybe_grp_ref_id = $this->tree->checkForParentType($this->getRefId(), 'grp');
418 if ($maybe_grp_ref_id > 0) {
419 return true;
420 }
421
422 return $this->tree->checkForParentType($this->getRefId(), 'crs') > 0;
423 }

References ilObject\getRefId().

Referenced by parentParticipants().

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

◆ isRead()

ilObjForum::isRead (   $a_usr_id,
  $a_post_id 
)

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

238 : bool
239 {
240 $res = $this->db->queryF(
241 'SELECT * FROM frm_user_read WHERE usr_id = %s AND post_id = %s',
242 ['integer', 'integer'],
243 [$a_usr_id, $a_post_id]
244 );
245
246 return (bool) $this->db->numRows($res);
247 }

References $res.

◆ lookupForumIdByObjId()

static ilObjForum::lookupForumIdByObjId ( int  $obj_id)
static

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

719 : int
720 {
721 if (array_key_exists($obj_id, self::$obj_id_to_forum_id_cache)) {
722 return self::$obj_id_to_forum_id_cache[$obj_id];
723 }
724
726
727 return self::$obj_id_to_forum_id_cache[$obj_id];
728 }
static preloadForumIdsByObjIds(array $obj_ids)

References preloadForumIdsByObjIds().

Referenced by ilObjForumGUI\addDraftButtonIfDraftsExists(), ilObjForumGUI\confirmDeleteThreadDraftsObject(), ilForumExportGUI\ensureThreadBelongsToForum(), ilObjForumGUI\ensureThreadBelongsToForum(), and ILIAS\Forum\Drafts\ForumDraftsTable\initRecords().

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

◆ lookupForumIdByRefId()

static ilObjForum::lookupForumIdByRefId ( int  $ref_id)
static

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

730 : int
731 {
732 if (array_key_exists($ref_id, self::$ref_id_to_forum_id_cache)) {
733 return self::$ref_id_to_forum_id_cache[$ref_id];
734 }
735
737
738 return self::$ref_id_to_forum_id_cache[$ref_id];
739 }
static preloadForumIdsByRefIds(array $ref_ids)

References ilObject\$ref_id, and preloadForumIdsByRefIds().

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

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

◆ lookupLastPostByRefId()

static ilObjForum::lookupLastPostByRefId ( int  $ref_id)
static

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

919 : ?array
920 {
921 global $DIC;
922
923 $ilAccess = $DIC->access();
924 $ilUser = $DIC->user();
925 $ilDB = $DIC->database();
926
927 if (array_key_exists($ref_id, self::$forum_last_post_cache)) {
928 return self::$forum_last_post_cache[$ref_id];
929 }
930
932 if ($forumId === 0) {
933 self::$forum_last_post_cache[$ref_id] = null;
934 return self::$forum_last_post_cache[$ref_id];
935 }
936
937 $act_clause = '';
938 if (!$ilAccess->checkAccess('moderate_frm', '', $ref_id)) {
939 $act_clause .= ' AND (frm_posts.pos_status = ' . $ilDB->quote(
940 1,
941 'integer'
942 ) . ' OR frm_posts.pos_author_id = ' . $ilDB->quote($ilUser->getId(), 'integer') . ') ';
943 }
944
945 $ilDB->setLimit(1, 0);
946 $query = "
947 SELECT *
948 FROM frm_posts
949 INNER JOIN frm_posts_tree tree1
950 ON tree1.pos_fk = frm_posts.pos_pk
951 AND tree1.parent_pos != 0
952 WHERE pos_top_fk = %s $act_clause
953 ORDER BY pos_date DESC
954 ";
955 $res = $ilDB->queryF(
956 $query,
957 ['integer'],
958 [$forumId]
959 );
960
961 $data = $ilDB->fetchAssoc($res);
962 if (!is_array($data) || empty($data)) {
963 self::$forum_last_post_cache[$ref_id] = null;
964 return self::$forum_last_post_cache[$ref_id];
965 }
966
967 $casted_data = [];
968 $casted_data['pos_pk'] = (int) $data['pos_pk'];
969 $casted_data['pos_top_fk'] = (int) $data['pos_top_fk'];
970 $casted_data['pos_thr_fk'] = (int) $data['pos_thr_fk'];
971 $casted_data['pos_usr_alias'] = (string) $data['pos_usr_alias'];
972 $casted_data['pos_subject'] = (string) $data['pos_subject'];
973 $casted_data['pos_date'] = (string) $data['pos_date'];
974 $casted_data['pos_update'] = (string) $data['pos_update'];
975 $casted_data['update_user'] = (int) $data['update_user'];
976 $casted_data['pos_cens'] = (int) $data['pos_cens'];
977 $casted_data['pos_cens_com'] = (string) $data['pos_cens_com'];
978 $casted_data['notify'] = (int) $data['notify'];
979 $casted_data['import_name'] = (string) $data['import_name'];
980 $casted_data['pos_status'] = (int) $data['pos_status'];
981 $casted_data['pos_message'] = (string) $data['pos_message'];
982 $casted_data['pos_author_id'] = (int) $data['pos_author_id'];
983 $casted_data['pos_display_user_id'] = (int) $data['pos_display_user_id'];
984 $casted_data['is_author_moderator'] = (int) $data['is_author_moderator'];
985 $casted_data['pos_cens_date'] = (string) $data['pos_cens_date'];
986 $casted_data['pos_activation_date'] = (string) $data['pos_activation_date'];
987
988 self::$forum_last_post_cache[$ref_id] = $casted_data;
989
990 return self::$forum_last_post_cache[$ref_id];
991 }
static lookupForumIdByRefId(int $ref_id)

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

Referenced by ilObjForumAccess\getLastPostByRefId().

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

◆ lookupStatisticsByRefId()

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

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

812 : array
813 {
814 global $DIC;
815
816 $ilAccess = $DIC->access();
817 $ilUser = $DIC->user();
818 $ilDB = $DIC->database();
819 $ilSetting = $DIC->settings();
820
821 if (isset(self::$forum_statistics_cache[$ref_id])) {
822 return self::$forum_statistics_cache[$ref_id];
823 }
824
825 $statistics = [
826 'num_posts' => 0,
827 'num_unread_posts' => 0,
828 ];
829
831 if ($forumId === 0) {
832 self::$forum_statistics_cache[$ref_id] = $statistics;
833 return self::$forum_statistics_cache[$ref_id];
834 }
835
837 $is_post_activation_enabled = $objProperties->isPostActivationEnabled();
838
839 $act_clause = '';
840
841 if ($is_post_activation_enabled && !$ilAccess->checkAccess('moderate_frm', '', $ref_id)) {
842 $act_clause .= ' AND (frm_posts.pos_status = ' . $ilDB->quote(
843 1,
844 'integer'
845 ) . ' OR frm_posts.pos_author_id = ' . $ilDB->quote($ilUser->getId(), 'integer') . ') ';
846 }
847
848 if (!$ilUser->isAnonymous()) {
849 $query = "
850 (SELECT COUNT(frm_posts.pos_pk) cnt
851 FROM frm_posts
852 INNER JOIN frm_posts_tree tree1
853 ON tree1.pos_fk = frm_posts.pos_pk
854 AND tree1.parent_pos != 0
855 INNER JOIN frm_threads ON frm_posts.pos_thr_fk = frm_threads.thr_pk
856 WHERE frm_threads.thr_top_fk = %s $act_clause)
857
858 UNION ALL
859
860 (SELECT COUNT(DISTINCT(frm_user_read.post_id)) cnt
861 FROM frm_user_read
862 INNER JOIN frm_posts ON frm_user_read.post_id = frm_posts.pos_pk
863 INNER JOIN frm_posts_tree tree1
864 ON tree1.pos_fk = frm_posts.pos_pk
865 AND tree1.parent_pos != 0
866 INNER JOIN frm_threads ON frm_threads.thr_pk = frm_posts.pos_thr_fk
867 WHERE frm_user_read.usr_id = %s AND frm_posts.pos_top_fk = %s $act_clause)
868 ";
869
870 $types = ['integer', 'integer', 'integer'];
871 $values = [$forumId, $ilUser->getId(), $forumId];
872
873 $mapping = array_keys($statistics);
874 $res = $ilDB->queryF(
875 $query,
876 $types,
877 $values
878 );
879 for ($i = 0; $i < 2; $i++) {
880 $row = $ilDB->fetchAssoc($res);
881
882 $statistics[$mapping[$i]] = (int) ((is_array($row) ? $row['cnt'] : 0));
883
884 if ($i === 1) {
885 // unread = all - read
886 $statistics[$mapping[$i]] = $statistics[$mapping[$i - 1]] - $statistics[$mapping[$i]];
887 }
888 }
889 } else {
890 $query = "
891 SELECT COUNT(frm_posts.pos_pk) cnt
892 FROM frm_posts
893 INNER JOIN frm_posts_tree tree1
894 ON tree1.pos_fk = frm_posts.pos_pk
895 AND tree1.parent_pos != 0
896 INNER JOIN frm_threads ON frm_posts.pos_thr_fk = frm_threads.thr_pk
897 WHERE frm_threads.thr_top_fk = %s $act_clause
898 ";
899 $types = ['integer'];
900 $values = [$forumId];
901 $res = $ilDB->queryF(
902 $query,
903 $types,
904 $values
905 );
906 $row = $ilDB->fetchAssoc($res);
907
908 $statistics = [
909 'num_posts' => (int) $row['cnt'],
910 'num_unread_posts' => (int) $row['cnt'],
911 ];
912 }
913
914 self::$forum_statistics_cache[$ref_id] = $statistics;
915
916 return self::$forum_statistics_cache[$ref_id];
917 }
static _lookupObjectId(int $ref_id)
global $ilSetting
Definition: privfeed.php:26

References $DIC, $ilDB, $ilSetting, ilObject\$ref_id, $res, ilObject\_lookupObjectId(), ilForumProperties\getInstance(), ILIAS\Repository\int(), and lookupForumIdByRefId().

Referenced by ilObjForumAccess\getStatisticsByRefId().

+ 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 187 of file class.ilObjForum.php.

187 : void
188 {
189 $res = $this->db->queryF(
190 'SELECT thr_pk FROM frm_data, frm_threads WHERE top_frm_fk = %s AND top_pk = thr_top_fk',
191 ['integer'],
192 [$this->getId()]
193 );
194
195 while ($row = $this->db->fetchObject($res)) {
196 $this->markThreadRead($a_usr_id, (int) $row->thr_pk);
197 }
198 }
markThreadRead(int $a_usr_id, int $a_thread_id)

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

+ 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 200 of file class.ilObjForum.php.

200 : void
201 {
202 $res = $this->db->queryF(
203 '
204 SELECT thread_id FROM frm_user_read
205 WHERE usr_id = %s
206 AND obj_id = %s
207 AND thread_id = %s
208 AND post_id = %s',
209 ['integer', 'integer', 'integer', 'integer'],
210 [$a_usr_id, $this->getId(), $a_thread_id, $a_post_id]
211 );
212
213 if ($this->db->numRows($res) === 0) {
214 $this->db->manipulateF(
215 '
216 INSERT INTO frm_user_read
217 ( usr_id,
218 obj_id,
219 thread_id,
220 post_id
221 )
222 VALUES (%s,%s,%s,%s)',
223 ['integer', 'integer', 'integer', 'integer'],
224 [$a_usr_id, $this->getId(), $a_thread_id, $a_post_id]
225 );
226 }
227 }

References $res, and ilObject\getId().

Referenced by markThreadRead().

+ 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 229 of file class.ilObjForum.php.

229 : void
230 {
231 $this->db->manipulateF(
232 'DELETE FROM frm_user_read WHERE usr_id = %s AND post_id = %s',
233 ['integer', 'integer'],
234 [$a_user_id, $a_post_id]
235 );
236 }

◆ markThreadRead()

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

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

177 : bool
178 {
179 $res = $this->db->queryF('SELECT pos_pk FROM frm_posts WHERE pos_thr_fk = %s', ['integer'], [$a_thread_id]);
180 while ($row = $this->db->fetchObject($res)) {
181 $this->markPostRead($a_usr_id, $a_thread_id, (int) $row->pos_pk);
182 }
183
184 return true;
185 }
markPostRead(int $a_usr_id, int $a_thread_id, int $a_post_id)

References $res, and markPostRead().

Referenced by markAllThreadsRead().

+ 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 1051 of file class.ilObjForum.php.

1051 : void
1052 {
1053 global $DIC;
1054
1055 $DIC->database()->update(
1056 'frm_user_read',
1057 ['thread_id' => ['integer', $merge_target_thread_id]],
1058 ['thread_id' => ['integer', $merge_source_thread_id]]
1059 );
1060 }

References $DIC.

Referenced by ilForum\mergeThreads().

+ Here is the caller graph for this function:

◆ parentParticipants()

ilObjForum::parentParticipants ( )
Exceptions
DomainException

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

450 {
452 throw new DomainException('Parent is not a membership enabled container.');
453 }
454
455 $maybe_grp_ref_id = $this->tree->checkForParentType($this->getRefId(), 'grp');
456 if ($maybe_grp_ref_id > 0) {
457 $parent_obj = ilObjectFactory::getInstanceByRefId($maybe_grp_ref_id);
458
459 return ilGroupParticipants::_getInstanceByObjId($parent_obj->getId());
460 }
461
462 $crs_ref_id = $this->tree->checkForParentType($this->getRefId(), 'crs');
463 $parent_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id);
464
465 return ilCourseParticipants::_getInstanceByObjId($parent_obj->getId());
466 }
static _getInstanceByObjId(int $a_obj_id)
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
isParentMembershipEnabledContainer()
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Base class for course and group participants.

References ilCourseParticipants\_getInstanceByObjId(), ilGroupParticipants\_getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilObject\getRefId(), and isParentMembershipEnabledContainer().

Referenced by getAllForumParticipants().

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

◆ preloadForumIdsByObjIds()

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

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

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

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

Referenced by lookupForumIdByObjId().

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

◆ preloadForumIdsByRefIds()

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

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

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

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

Referenced by ilObjForumAccess\_preloadData(), and lookupForumIdByRefId().

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

◆ saveData()

ilObjForum::saveData ( )

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

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

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

Referenced by create().

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

◆ setPermissions()

ilObjForum::setPermissions ( int  $parent_ref_id)

Reimplemented from ilObject.

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

77 : void
78 {
79 parent::setPermissions($parent_ref_id);
80
81 $roles = [self::_lookupModeratorRole($this->getRefId())];
82 $this->rbac->admin()->assignUser($roles[0], $this->getOwner());
83 $this->updateModeratorRole($roles[0]);
84 }
updateModeratorRole(int $role_id)

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

+ Here is the call graph for this function:

◆ update()

ilObjForum::update ( )

Reimplemented from ilObject.

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

275 : bool
276 {
277 if (parent::update()) {
278 $this->db->manipulateF(
279 'UPDATE frm_data SET top_name = %s, top_description = %s, top_update = %s, update_user = %s WHERE top_frm_fk = %s',
280 ['text', 'text', 'timestamp', 'integer', 'integer'],
281 [
282 $this->getTitle(),
283 $this->getDescription(),
284 date("Y-m-d H:i:s"),
285 $this->user->getId(),
286 $this->getId()
287 ]
288 );
289
290 return true;
291 }
292
293 return false;
294 }

References ILIAS\UI\examples\Symbol\Glyph\Date\date(), ilObject\getDescription(), ilObject\getTitle(), and ILIAS\Repository\user().

Referenced by create().

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

◆ updateModeratorRole()

ilObjForum::updateModeratorRole ( int  $role_id)

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

86 : void
87 {
88 $this->db->manipulate(
89 'UPDATE frm_data SET top_mods = ' . $this->db->quote(
90 $role_id,
91 'integer'
92 ) . ' WHERE top_frm_fk = ' . $this->db->quote($this->getId(), 'integer')
93 );
94 }

Referenced by setPermissions().

+ Here is the caller graph for this function:

◆ updateModificationUserId()

ilObjForum::updateModificationUserId ( int  $usr_id)

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

266 : void
267 {
268 $this->db->manipulateF(
269 'UPDATE frm_data SET update_user = %s WHERE top_frm_fk = %s',
270 ['integer', 'integer'],
271 [$usr_id, $this->getId()],
272 );
273 }

References ilObject\getId().

+ Here is the call graph for this function:

Field Documentation

◆ $Forum

ilForum ilObjForum::$Forum

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

◆ $forum_last_post_cache

array ilObjForum::$forum_last_post_cache = []
staticprivate

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

◆ $forum_statistics_cache

array ilObjForum::$forum_statistics_cache = []
staticprivate

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

◆ $logger

readonly ilLogger ilObjForum::$logger
private

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

◆ $obj_id_to_forum_id_cache

array ilObjForum::$obj_id_to_forum_id_cache = []
staticprivate

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

◆ $rbac

readonly ILIAS DI RBACServices ilObjForum::$rbac
private

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

◆ $ref_id_to_forum_id_cache

array ilObjForum::$ref_id_to_forum_id_cache = []
staticprivate

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

◆ $settings

readonly ilSetting ilObjForum::$settings
private

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


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