ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilObjForum Class Reference

Class ilObjForum. More...

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

Public Member Functions

 __construct ($a_id=0, $a_call_by_reference=true)
 Constructor @access public. More...
 
 create ()
 
 setPermissions ($a_ref_id)
 
 updateModeratorRole ($role_id)
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 getCountUnread ($a_usr_id, $a_thread_id=0, $ignoreRoot=false)
 
 markThreadRead ($a_usr_id, $a_thread_id)
 
 markAllThreadsRead ($a_usr_id)
 
 markPostRead ($a_usr_id, $a_thread_id, $a_post_id)
 
 markPostUnread ($a_user_id, $a_post_id)
 
 isRead ($a_usr_id, $a_post_id)
 
 updateLastAccess ($a_usr_id, $a_thread_id)
 
 update ($a_update_user_id=0)
 update forum data @access public More...
 
 cloneAutoGeneratedRoles ($new_obj)
 Clone forum moderator role @access public. More...
 
 delete ()
 Delete forum and all related data @access public. More...
 
 initDefaultRoles ()
 init default roles settings @access public More...
 
 createSettings ()
 
 saveData ($a_roles=array())
 
 setThreadSorting ($a_thr_pk, $a_sorting_value)
 
- Public Member Functions inherited from ilObject
 __construct ($a_id=0, $a_reference=true)
 Constructor @access public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ()
 read object data from db into object More...
 
 getId ()
 get object id @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 setOfflineStatus ($a_status)
 Set offline status. More...
 
 getOfflineStatus ()
 Get offline status. More...
 
 supportsOfflineHandling ()
 Check whether object supports offline handling. More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object 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 If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) @access public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static _lookupThreadSubject ($a_thread_id)
 
static _updateOldAccess ($a_usr_id)
 
static _deleteUser ($a_usr_id)
 
static _deleteReadEntries ($a_post_id)
 
static _deleteAccessEntries ($a_thread_id)
 
static _lookupModeratorRole ($a_ref_id)
 Lookup moderator role @access public. More...
 
static lookupForumIdByObjId ($obj_id)
 
static lookupForumIdByRefId ($ref_id)
 
static preloadForumIdsByObjIds (array $obj_ids)
 
static preloadForumIdsByRefIds (array $ref_ids)
 
static lookupStatisticsByRefId ($ref_id)
 
static lookupLastPostByRefId ($ref_id)
 
static getUserIdsOfLastPostsByRefIdAndThreadIds ($ref_id, array $thread_ids)
 
static mergeForumUserRead ($merge_source_thread_id, $merge_target_thread_id)
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static lookupOfflineStatus ($a_obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id, $a_deleted_by)
 
static setDeletedDates ($a_ref_ids, $a_user_id)
 Set deleted date. More...
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data@access public More...
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection. More...
 
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $a_obj_ids)
 Get long description data. More...
 
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns. More...
 
static fixMissingTitles ($a_type, array &$a_obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Data Fields

 $Forum
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 

Static Protected Attributes

static $obj_id_to_forum_id_cache = array()
 
static $ref_id_to_forum_id_cache = array()
 
static $forum_statistics_cache = array()
 
static $forum_last_post_cache = array()
 

Private Member Functions

 deleteDraftsByForumId ($forum_id)
 

Private Attributes

 $settings
 
 $rbac
 
 $ilBench
 
 $user
 
 $logger
 

Additional Inherited Members

- Protected Attributes inherited from ilObject
 $objDefinition
 
 $db
 
 $log
 
 $error
 
 $tree
 
 $app_event_handler
 
 $rbacadmin
 
 $rbacreview
 

Detailed Description

Class ilObjForum.

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

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor @access public.

Parameters
integer$a_idreference_id or object_id
boolean$a_call_by_referencetreat the id as reference_id (true) or object_id (false)

Reimplemented from ilObject.

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

61 {
62 global $DIC;
63 $this->settings = $DIC->settings();
64 $this->rbac = $DIC->rbac();
65 $this->db = $DIC->database();
66 $this->ilBench = $DIC['ilBench'];
67 $this->user = $DIC->user();
68 $this->logger = $DIC->logger()->root();
69
70 $this->type = 'frm';
71 parent::__construct($a_id, $a_call_by_reference);
72
73 /*
74 * this constant is used for the information if a single post is marked as new
75 * All threads/posts created before this date are never marked as new
76 * Default is 8 weeks
77 *
78 */
79 $new_deadline = time() - 60 * 60 * 24 * 7 * ($this->settings->get('frm_store_new') ?
80 $this->settings->get('frm_store_new') :
81 8);
82 define('NEW_DEADLINE', $new_deadline);
83
84 // TODO: needs to rewrite scripts that are using Forum outside this class
85 $this->Forum = new ilForum();
86 }
user()
Definition: user.php:4
Class Forum core functions for forum.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), settings(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteAccessEntries()

static ilObjForum::_deleteAccessEntries (   $a_thread_id)
static

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

464 {
465 global $DIC;
466 $ilDB = $DIC->database();
467 $ilDB->manipulateF(
468 '
469 DELETE FROM frm_thread_access WHERE thread_id = %s',
470 array('integer'),
471 array($a_thread_id)
472 );
473
474 return true;
475 }
global $ilDB

References $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ _deleteReadEntries()

static ilObjForum::_deleteReadEntries (   $a_post_id)
static

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

449 {
450 global $DIC;
451 $ilDB = $DIC->database();
452
453 $ilDB->manipulateF(
454 '
455 DELETE FROM frm_user_read WHERE post_id = %s',
456 array('integer'),
457 array($a_post_id)
458 );
459
460 return true;
461 }

References $DIC, and $ilDB.

Referenced by ilForum\deletePost().

+ Here is the caller graph for this function:

◆ _deleteUser()

static ilObjForum::_deleteUser (   $a_usr_id)
static

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

416 {
417 global $DIC;
418 $ilDB = $DIC->database();
419
420 $data = array($a_usr_id);
421
422 $ilDB->manipulateF(
423 '
424 DELETE FROM frm_user_read WHERE usr_id = %s',
425 array('integer'),
426 $data
427 );
428
429 $ilDB->manipulateF(
430 '
431 DELETE FROM frm_thread_access WHERE usr_id = %s',
432 array('integer'),
433 $data
434 );
435
436 // delete notifications of deleted user
437 $ilDB->manipulateF(
438 '
439 DELETE FROM frm_notification WHERE user_id = %s',
440 array('integer'),
441 $data
442 );
443
444 return true;
445 }
$data
Definition: storeScorm.php:23

References $data, $DIC, and $ilDB.

Referenced by ilObjUser\delete().

+ Here is the caller graph for this function:

◆ _lookupModeratorRole()

static ilObjForum::_lookupModeratorRole (   $a_ref_id)
static

Lookup moderator role @access public.

Parameters
int$a_ref_idref_id of forum

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

763 {
764 global $DIC;
765 $ilDB = $DIC->database();
766
767 $mod_title = 'il_frm_moderator_' . $a_ref_id;
768
769 $res = $ilDB->queryf(
770 '
771 SELECT * FROM object_data WHERE title = %s',
772 array('text'),
773 array($mod_title)
774 );
775
776 while ($row = $ilDB->fetchObject($res)) {
777 return $row->obj_id;
778 }
779 return 0;
780 }
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 (   $a_thread_id)
static

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

142 {
143 global $DIC;
144 $ilDB = $DIC->database();
145
146 $res = $ilDB->queryf(
147 '
148 SELECT thr_subject FROM frm_threads WHERE thr_pk = %s',
149 array('integer'),
150 array($a_thread_id)
151 );
152
153 while ($row = $ilDB->fetchObject($res)) {
154 return $row->thr_subject;
155 }
156 return '';
157 }

References $DIC, $ilDB, and $res.

Referenced by ilObjForumSubItemListGUI\getHTML().

+ Here is the caller graph for this function:

◆ _updateOldAccess()

static ilObjForum::_updateOldAccess (   $a_usr_id)
static
Parameters
int

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

376 {
377 global $DIC;
378 $ilDB = $DIC->database();
379
380 $ilDB->manipulateF(
381 '
382 UPDATE frm_thread_access
383 SET access_old = access_last
384 WHERE usr_id = %s',
385 array('integer'),
386 array($a_usr_id)
387 );
388
389 $set = $ilDB->query(
390 "SELECT * FROM frm_thread_access " .
391 " WHERE usr_id = " . $ilDB->quote($a_usr_id, "integer")
392 );
393 while ($rec = $ilDB->fetchAssoc($set)) {
394 $ilDB->manipulate(
395 "UPDATE frm_thread_access SET " .
396 " access_old_ts = " . $ilDB->quote(date('Y-m-d H:i:s', $rec["access_old"]), "timestamp") .
397 " WHERE usr_id = " . $ilDB->quote($rec["usr_id"], "integer") .
398 " AND obj_id = " . $ilDB->quote($rec["obj_id"], "integer") .
399 " AND thread_id = " . $ilDB->quote($rec["thread_id"], "integer")
400 );
401 }
402
403 $new_deadline = time() - 60 * 60 * 24 * 7 * ($DIC->settings()->get('frm_store_new') ?
404 $DIC->settings()->get('frm_store_new') :
405 8);
406
407 $ilDB->manipulateF(
408 '
409 DELETE FROM frm_thread_access WHERE access_last < %s',
410 array('integer'),
411 array($new_deadline)
412 );
413 }

References $DIC, and $ilDB.

Referenced by ilAuthFrontend\handleAuthenticationSuccess().

+ Here is the caller graph for this function:

◆ cloneAutoGeneratedRoles()

ilObjForum::cloneAutoGeneratedRoles (   $new_obj)

Clone forum moderator role @access public.

Parameters
object$new_objforum object

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

613 {
614 $moderator = ilObjForum::_lookupModeratorRole($this->getRefId());
615 $new_moderator = ilObjForum::_lookupModeratorRole($new_obj->getRefId());
616
617 if (!$moderator || !$new_moderator || !$this->getRefId() || !$new_obj->getRefId()) {
618 $this->logger->write(__METHOD__ . ' : Error cloning auto generated role: il_frm_moderator');
619 }
620 $this->rbac->admin()->copyRolePermissions($moderator, $this->getRefId(), $new_obj->getRefId(), $new_moderator, true);
621 $this->logger->write(__METHOD__ . ' : Finished copying of role il_frm_moderator.');
622
623 $obj_mods = new ilForumModerators($this->getRefId());
624
625 $old_mods = $obj_mods->getCurrentModerators();
626 foreach ($old_mods as $user_id) {
627 // The object owner is already member of the moderator role when this method is called
628 // Since the new static caches are introduced with ILIAS 5.0, a database error occurs if we try to assign the user here.
629 if ($this->getOwner() != $user_id) {
630 $this->rbac->admin()->assignUser($new_moderator, $user_id);
631 }
632 }
633 }
Class ilForumModerators.
static _lookupModeratorRole($a_ref_id)
Lookup moderator role @access public.
getOwner()
get object owner
getRefId()
get reference id @access public

References _lookupModeratorRole(), ilObject\getOwner(), and ilObject\getRefId().

+ Here is the call graph for this function:

◆ create()

ilObjForum::create ( )
Returns
int

Reimplemented from ilObject.

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

92 {
93 $id = parent::create();
94
95 $properties = ilForumProperties::getInstance($this->getId());
96 $properties->setDefaultView(ilForumProperties::VIEW_DATE_ASC);
97 $properties->setAnonymisation(0);
98 $properties->setStatisticsStatus(0);
99 $properties->setPostActivation(0);
100 $properties->setThreadSorting(0);
101 $properties->insert();
102
103 $this->createSettings();
104
105 $this->saveData();
106
107 return $id;
108 }
static getInstance($a_obj_id=0)
saveData($a_roles=array())
getId()
get object id @access public

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

+ Here is the call graph for this function:

◆ createSettings()

ilObjForum::createSettings ( )

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

784 {
785 // news settings (public notifications yes/no)
786 $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET["ref_id"]);
787 if ($default_visibility == "public") {
788 ilBlockSetting::_write("news", "public_notifications", 1, 0, $this->getId());
789 }
790
791 return true;
792 }
$_GET["client_id"]
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.

References $_GET, ilNewsItem\_getDefaultVisibilityForRefId(), ilBlockSetting\_write(), 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 forum and all related data @access public.

Returns
boolean true if all object data were removed; false if only a references were removed

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

641 {
642 // always call parent delete function first!!
643 if (!parent::delete()) {
644 return false;
645 }
646
647 // delete attachments
648 $tmp_file_obj = new ilFileDataForum($this->getId());
649 $tmp_file_obj->delete();
650 unset($tmp_file_obj);
651
652 $this->Forum->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($this->getId()));
653
654 $topData = $this->Forum->getOneTopic();
655
656 $threads = $this->Forum->getAllThreads($topData['top_pk']);
657 foreach ($threads['items'] as $thread) {
658 $thread_ids_to_delete[$thread->getId()] = $thread->getId();
659 }
660
661 // delete tree
662 $this->db->manipulate('DELETE FROM frm_posts_tree WHERE ' . $this->db->in('thr_fk', $thread_ids_to_delete, false, 'integer'));
663
664 // delete posts
665 $this->db->manipulate('DELETE FROM frm_posts WHERE ' . $this->db->in('pos_thr_fk', $thread_ids_to_delete, false, 'integer'));
666
667 // delete threads
668 $this->db->manipulate('DELETE FROM frm_threads WHERE ' . $this->db->in('thr_pk', $thread_ids_to_delete, false, 'integer'));
669
670 $obj_id = array($this->getId());
671 // delete forum
672 $this->db->manipulateF(
673 'DELETE FROM frm_data WHERE top_frm_fk = %s',
674 array('integer'),
675 $obj_id
676 );
677
678 // delete settings
679 $this->db->manipulateF(
680 'DELETE FROM frm_settings WHERE obj_id = %s',
681 array('integer'),
682 $obj_id
683 );
684
685 // delete read infos
686 $this->db->manipulateF(
687 'DELETE FROM frm_user_read WHERE obj_id = %s',
688 array('integer'),
689 $obj_id
690 );
691
692 // delete thread access entries
693 $this->db->manipulateF(
694 'DELETE FROM frm_thread_access WHERE obj_id = %s',
695 array('integer'),
696 $obj_id
697 );
698
699 //delete thread notifications
700 $this->db->manipulate('DELETE FROM frm_notification WHERE ' . $this->db->in('thread_id', $thread_ids_to_delete, false, 'integer'));
701
702 //delete forum notifications
703 $this->db->manipulateF('DELETE FROM frm_notification WHERE frm_id = %s', array('integer'), $obj_id);
704
705 // delete posts_deleted entries
706 $this->db->manipulateF('DELETE FROM frm_posts_deleted WHERE obj_id = %s', array('integer'), $obj_id);
707
708 //delete drafts
709 $this->deleteDraftsByForumId((int) $topData['top_pk']);
710
711 return true;
712 }
This class handles all operations on files for the forum object.
deleteDraftsByForumId($forum_id)

References deleteDraftsByForumId(), and ilObject\getId().

+ Here is the call graph for this function:

◆ deleteDraftsByForumId()

ilObjForum::deleteDraftsByForumId (   $forum_id)
private
Parameters
int$forum_id

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

718 {
719 $res = $this->db->queryF(
720 'SELECT draft_id FROM frm_posts_drafts WHERE forum_id = %s',
721 array('integer'),
722 array((int) $forum_id)
723 );
724
725 $draft_ids = array();
726 while ($row = $this->db->fetchAssoc($res)) {
727 $draft_ids[] = $row['draft_id'];
728 }
729
730 if (count($draft_ids) > 0) {
731 $historyObj = new ilForumDraftsHistory();
732 $historyObj->deleteHistoryByDraftIds($draft_ids);
733
734 $draftObj = new ilForumPostDraft();
735 $draftObj->deleteDraftsByDraftIds($draft_ids);
736 }
737 }
Class ilForumDraftHistory.
Class ilForumPostDraft.

References $res.

Referenced by delete().

+ Here is the caller graph for this function:

◆ getCountUnread()

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

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

161 {
162 $a_frm_id = $this->getId();
163
164 $this->ilBench->start("Forum", 'getCountRead');
165 if (!$a_thread_id) {
166 // Get topic_id
167 $res = $this->db->queryf(
168 '
169 SELECT top_pk FROM frm_data WHERE top_frm_fk = %s',
170 array('integer'),
171 array($a_frm_id)
172 );
173
174
175 while ($row = $this->db->fetchObject($res)) {
176 $topic_id = $row->top_pk;
177 }
178
179 // Get number of posts
180 $res = $this->db->queryf(
181 '
182 SELECT COUNT(pos_pk) num_posts
183 FROM frm_posts
184 LEFT JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
185 WHERE pos_top_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
186 array('integer'),
187 array($topic_id)
188 );
189
190 while ($row = $this->db->fetchObject($res)) {
191 $num_posts = $row->num_posts;
192 }
193
194 $res = $this->db->queryf(
195 '
196 SELECT COUNT(post_id) count_read FROM frm_user_read
197 WHERE obj_id = %s
198 AND usr_id = %s',
199 array('integer', 'integer'),
200 array($a_frm_id, $a_usr_id)
201 );
202
203 while ($row = $this->db->fetchObject($res)) {
204 $count_read = $row->count_read;
205 }
206 $unread = $num_posts - $count_read;
207
208 $this->ilBench->stop("Forum", 'getCountRead');
209 return $unread > 0 ? $unread : 0;
210 } else {
211 $res = $this->db->queryf(
212 '
213 SELECT COUNT(pos_pk) num_posts FROM frm_posts
214 LEFT JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk
215 WHERE pos_thr_fk = %s' . ($ignoreRoot ? ' AND parent_pos != 0 ' : ''),
216 array('integer'),
217 array($a_thread_id)
218 );
219
220 $row = $this->db->fetchObject($res);
221 $num_posts = $row->num_posts;
222
223 $res = $this->db->queryf(
224 '
225 SELECT COUNT(post_id) count_read FROM frm_user_read
226 WHERE obj_id = %s
227 AND usr_id = %s
228 AND thread_id = %s',
229 array('integer', 'integer', 'integer'),
230 array($a_frm_id, $a_frm_id, $a_thread_id)
231 );
232
233 $row = $this->db->fetchObject($res);
234 $count_read = $row->count_read;
235
236 $unread = $num_posts - $count_read;
237
238 $this->ilBench->stop("Forum", 'getCountRead');
239 return $unread > 0 ? $unread : 0;
240 }
241 $this->ilBench->stop("Forum", 'getCountRead');
242 return false;
243 }

References $res, and ilObject\getId().

+ Here is the call graph for this function:

◆ getDiskUsage()

ilObjForum::getDiskUsage ( )

Gets the disk usage of the object in bytes.

@access public

Returns
integer the disk usage in bytes

Reimplemented from ilObject.

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

137 {
138 return ilObjForumAccess::_lookupDiskUsage($this->id);
139 }
static _lookupDiskUsage($a_obj_id)
Returns the number of bytes used on the harddisk by the specified forum.

References ilObjForumAccess\_lookupDiskUsage().

+ Here is the call graph for this function:

◆ getUserIdsOfLastPostsByRefIdAndThreadIds()

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

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

1145 {
1146 global $DIC;
1147 $ilAccess = $DIC->access();
1148 $ilUser = $DIC->user();
1149 $ilDB = $DIC->database();
1150
1151 $act_clause = '';
1152 $act_inner_clause = '';
1153 if (!$ilAccess->checkAccess('moderate_frm', '', $ref_id)) {
1154 $act_clause .= " AND (t1.pos_status = " . $ilDB->quote(1, "integer") . " OR t1.pos_author_id = " . $ilDB->quote($ilUser->getId(), "integer") . ") ";
1155 $act_inner_clause .= " AND (t3.pos_status = " . $ilDB->quote(1, "integer") . " OR t3.pos_author_id = " . $ilDB->quote($ilUser->getId(), "integer") . ") ";
1156 }
1157
1158 $in = $ilDB->in("t1.pos_thr_fk", $thread_ids, false, 'integer');
1159 $inner_in = $ilDB->in("t3.pos_thr_fk", $thread_ids, false, 'integer');
1160
1161 $query = "
1162 SELECT t1.pos_display_user_id, t1.update_user
1163 FROM frm_posts t1
1164 INNER JOIN frm_posts_tree tree1 ON tree1.pos_fk = t1.pos_pk AND tree1.parent_pos != 0
1165 INNER JOIN (
1166 SELECT t3.pos_thr_fk, MAX(t3.pos_date) pos_date
1167 FROM frm_posts t3
1168 INNER JOIN frm_posts_tree tree2 ON tree2.pos_fk = t3.pos_pk AND tree2.parent_pos != 0
1169 WHERE $inner_in $act_inner_clause
1170 GROUP BY t3.pos_thr_fk
1171 ) t2 ON t2.pos_thr_fk = t1.pos_thr_fk AND t2.pos_date = t1.pos_date
1172 WHERE $in $act_clause
1173 GROUP BY t1.pos_thr_fk, t1.pos_display_user_id, t1.update_user
1174 ";
1176 $usr_ids = array();
1177
1178 $res = $ilDB->query($query);
1179 while ($row = $ilDB->fetchAssoc($res)) {
1180 if ((int) $row['pos_display_user_id']) {
1181 $usr_ids[] = (int) $row['pos_display_user_id'];
1182 }
1183 if ((int) $row['update_user']) {
1184 $usr_ids[] = (int) $row['update_user'];
1185 }
1186 }
1187
1188 return array_unique($usr_ids);
1189 }
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
$query
$ilUser
Definition: imgupload.php:18

References $DIC, $ilDB, $ilUser, $in, $query, ilObject\$ref_id, and $res.

◆ initDefaultRoles()

ilObjForum::initDefaultRoles ( )

init default roles settings @access public

Returns
array object IDs of created local roles.

Reimplemented from ilObject.

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

745 {
747 'il_frm_moderator_' . $this->getRefId(),
748 "Moderator of forum obj_no." . $this->getId(),
749 'il_frm_moderator',
750 $this->getRefId()
751 );
752 return array();
753 }
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)

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

+ Here is the call graph for this function:

◆ isRead()

ilObjForum::isRead (   $a_usr_id,
  $a_post_id 
)

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

328 {
329 $res = $this->db->queryf(
330 '
331 SELECT * FROM frm_user_read
332 WHERE usr_id = %s
333 AND post_id = %s',
334 array('integer', 'integer'),
335 array($a_usr_id, $a_post_id)
336 );
337
338 return $this->db->numRows($res) ? true : false;
339 }

References $res.

◆ lookupForumIdByObjId()

static ilObjForum::lookupForumIdByObjId (   $obj_id)
static
Parameters
int$obj_id
Returns
int

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

858 {
859 if (array_key_exists($obj_id, self::$obj_id_to_forum_id_cache)) {
860 return (int) self::$obj_id_to_forum_id_cache[$obj_id];
861 }
862
863 self::preloadForumIdsByObjIds(array($obj_id));
864
865 return (int) self::$obj_id_to_forum_id_cache[$obj_id];
866 }
static preloadForumIdsByObjIds(array $obj_ids)

References preloadForumIdsByObjIds().

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

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

◆ lookupForumIdByRefId()

static ilObjForum::lookupForumIdByRefId (   $ref_id)
static
Parameters
int$ref_id
Returns
int

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

874 {
875 if (array_key_exists($ref_id, self::$ref_id_to_forum_id_cache)) {
876 return (int) self::$ref_id_to_forum_id_cache[$ref_id];
877 }
878
880
881 return (int) self::$ref_id_to_forum_id_cache[$ref_id];
882 }
static preloadForumIdsByRefIds(array $ref_ids)

References ilObject\$ref_id, and preloadForumIdsByRefIds().

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

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

◆ lookupLastPostByRefId()

static ilObjForum::lookupLastPostByRefId (   $ref_id)
static
Parameters
int$ref_id
Returns
array

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

1094 {
1095 global $DIC;
1096 $ilAccess = $DIC->access();
1097 $ilUser = $DIC->user();
1098 $ilDB = $DIC->database();
1099
1100 if (isset(self::$forum_last_post_cache[$ref_id])) {
1101 return self::$forum_last_post_cache[$ref_id];
1102 }
1103
1105 if (!$forumId) {
1106 self::$forum_last_post_cache[$ref_id] = array();
1107 return self::$forum_last_post_cache[$ref_id];
1108 }
1109
1110 $act_clause = '';
1111 if (!$ilAccess->checkAccess('moderate_frm', '', $ref_id)) {
1112 $act_clause .= " AND (frm_posts.pos_status = " . $ilDB->quote(1, "integer") . " OR frm_posts.pos_author_id = " . $ilDB->quote($ilUser->getId(), "integer") . ") ";
1113 }
1114
1115 $ilDB->setLimit(1, 0);
1116 $query = "
1117 SELECT *
1118 FROM frm_posts
1119 INNER JOIN frm_posts_tree tree1
1120 ON tree1.pos_fk = frm_posts.pos_pk
1121 AND tree1.parent_pos != 0
1122 WHERE pos_top_fk = %s $act_clause
1123 ORDER BY pos_date DESC
1124 ";
1125 $res = $ilDB->queryF(
1126 $query,
1127 array('integer'),
1128 array($forumId)
1129 );
1130
1131 $data = $ilDB->fetchAssoc($res);
1132
1133 self::$forum_last_post_cache[$ref_id] = is_array($data) ? $data : array();
1134
1135 return self::$forum_last_post_cache[$ref_id];
1136 }
static lookupForumIdByRefId($ref_id)

References $data, $DIC, $ilDB, $ilUser, $query, ilObject\$ref_id, $res, 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 (   $ref_id)
static
Parameters
int$ref_id
Returns
array

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

956 {
957 global $DIC;
958 $ilAccess = $DIC->access();
959 $ilUser = $DIC->user();
960 $ilDB = $DIC->database();
961 $ilSetting = $DIC->settings();
962
963 if (isset(self::$forum_statistics_cache[$ref_id])) {
964 return self::$forum_statistics_cache[$ref_id];
965 }
966
967 $statistics = array(
968 'num_posts' => 0,
969 'num_unread_posts' => 0,
970 'num_new_posts' => 0
971 );
972
974 if (!$forumId) {
975 self::$forum_statistics_cache[$ref_id] = $statistics;
976 return self::$forum_statistics_cache[$ref_id];
977 }
978
980 $is_post_activation_enabled = $objProperties->isPostActivationEnabled();
981
982 $act_clause = '';
983
984 if ($is_post_activation_enabled && !$ilAccess->checkAccess('moderate_frm', '', $ref_id)) {
985 $act_clause .= " AND (frm_posts.pos_status = " . $ilDB->quote(1, "integer") . " OR frm_posts.pos_author_id = " . $ilDB->quote($ilUser->getId(), "integer") . ") ";
986 }
987
988 $new_deadline = date('Y-m-d H:i:s', time() - 60 * 60 * 24 * 7 * ($ilSetting->get('frm_store_new') ? $ilSetting->get('frm_store_new') : 8));
989
990 if (!$ilUser->isAnonymous()) {
991 $query = "
992 (SELECT COUNT(frm_posts.pos_pk) cnt
993 FROM frm_posts
994 INNER JOIN frm_posts_tree tree1
995 ON tree1.pos_fk = frm_posts.pos_pk
996 AND tree1.parent_pos != 0
997 INNER JOIN frm_threads ON frm_posts.pos_thr_fk = frm_threads.thr_pk
998 WHERE frm_threads.thr_top_fk = %s $act_clause)
999
1000 UNION ALL
1001
1002 (SELECT COUNT(DISTINCT(frm_user_read.post_id)) cnt
1003 FROM frm_user_read
1004 INNER JOIN frm_posts ON frm_user_read.post_id = frm_posts.pos_pk
1005 INNER JOIN frm_posts_tree tree1
1006 ON tree1.pos_fk = frm_posts.pos_pk
1007 AND tree1.parent_pos != 0
1008 INNER JOIN frm_threads ON frm_threads.thr_pk = frm_posts.pos_thr_fk
1009 WHERE frm_user_read.usr_id = %s AND frm_posts.pos_top_fk = %s $act_clause)
1010 ";
1011
1012 $types = array('integer', 'integer', 'integer');
1013 $values = array($forumId, $ilUser->getId(), $forumId);
1014
1015 $forum_overview_setting = (int) $ilSetting::_lookupValue('frma', 'forum_overview');
1016 if ($forum_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS) {
1017 $news_types = array('integer', 'integer', 'integer', 'timestamp', 'integer');
1018 $news_values = array($ilUser->getId(), $ilUser->getId(), $forumId, $new_deadline, $ilUser->getId());
1019
1020 $query .= "
1021 UNION ALL
1022
1023 (SELECT COUNT(frm_posts.pos_pk) cnt
1024 FROM frm_posts
1025 INNER JOIN frm_posts_tree tree1
1026 ON tree1.pos_fk = frm_posts.pos_pk
1027 AND tree1.parent_pos != 0
1028 LEFT JOIN frm_user_read ON (post_id = frm_posts.pos_pk AND frm_user_read.usr_id = %s)
1029 LEFT JOIN frm_thread_access ON (frm_thread_access.thread_id = frm_posts.pos_thr_fk AND frm_thread_access.usr_id = %s)
1030 WHERE frm_posts.pos_top_fk = %s
1031 AND ( (frm_posts.pos_update > frm_thread_access.access_old_ts)
1032 OR (frm_thread_access.access_old IS NULL AND frm_posts.pos_update > %s)
1033 )
1034 AND frm_posts.pos_author_id != %s
1035 AND frm_user_read.usr_id IS NULL $act_clause)";
1036
1037 $types = array_merge($types, $news_types);
1038 $values = array_merge($values, $news_values);
1039 }
1040
1041 $mapping = array_keys($statistics);
1042 $res = $ilDB->queryF(
1043 $query,
1044 $types,
1045 $values
1046 );
1047 for ($i = 0; $i <= 2; $i++) {
1048 $row = $ilDB->fetchAssoc($res);
1049
1050 $statistics[$mapping[$i]] = (int) $row['cnt'];
1051
1052 if ($i == 1) {
1053 // unread = all - read
1054 $statistics[$mapping[$i]] = $statistics[$mapping[$i - 1]] - $statistics[$mapping[$i]];
1055 }
1056 }
1057 } else {
1058 $query = "
1059 SELECT COUNT(frm_posts.pos_pk) cnt
1060 FROM frm_posts
1061 INNER JOIN frm_posts_tree tree1
1062 ON tree1.pos_fk = frm_posts.pos_pk
1063 AND tree1.parent_pos != 0
1064 INNER JOIN frm_threads ON frm_posts.pos_thr_fk = frm_threads.thr_pk
1065 WHERE frm_threads.thr_top_fk = %s $act_clause
1066 ";
1067 $types = array('integer');
1068 $values = array($forumId);
1069 $res = $ilDB->queryF(
1070 $query,
1071 $types,
1072 $values
1073 );
1074 $row = $ilDB->fetchAssoc($res);
1075
1076 $statistics = array(
1077 'num_posts' => $row['cnt'],
1078 'num_unread_posts' => $row['cnt'],
1079 'num_new_posts' => $row['cnt']
1080 );
1081 }
1082
1083 self::$forum_statistics_cache[$ref_id] = $statistics;
1084
1085 return self::$forum_statistics_cache[$ref_id];
1086 }
static _lookupObjectId($a_ref_id)
lookup object id
$i
Definition: metadata.php:24
global $ilSetting
Definition: privfeed.php:17

References $DIC, $i, $ilDB, $ilSetting, $ilUser, $query, ilObject\$ref_id, $res, ilObject\_lookupObjectId(), ilForumProperties\FORUM_OVERVIEW_WITH_NEW_POSTS, ilForumProperties\getInstance(), 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 (   $a_usr_id)

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

263 {
264 $res = $this->db->queryf(
265 '
266 SELECT * FROM frm_data, frm_threads
267 WHERE top_frm_fk = %s
268 AND top_pk = thr_top_fk',
269 array('integer'),
270 array($this->getId())
271 );
272
273 while ($row = $this->db->fetchObject($res)) {
274 $this->markThreadRead($a_usr_id, $row->thr_pk);
275 }
276
277 return true;
278 }
markThreadRead($a_usr_id, $a_thread_id)

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

+ Here is the call graph for this function:

◆ markPostRead()

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

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

282 {
283 // CHECK IF ENTRY EXISTS
284 $res = $this->db->queryf(
285 '
286 SELECT * FROM frm_user_read
287 WHERE usr_id = %s
288 AND obj_id = %s
289 AND thread_id = %s
290 AND post_id = %s',
291 array('integer', 'integer', 'integer', 'integer'),
292 array($a_usr_id, $this->getId(), $a_thread_id, $a_post_id)
293 );
294
295 if ($this->db->numRows($res)) {
296 return true;
297 }
298
299 $this->db->manipulateF(
300 '
301 INSERT INTO frm_user_read
302 ( usr_id,
303 obj_id,
304 thread_id,
305 post_id
306 )
307 VALUES (%s,%s,%s,%s)',
308 array('integer', 'integer', 'integer', 'integer'),
309 array($a_usr_id, $this->getId(), $a_thread_id, $a_post_id)
310 );
311
312 return true;
313 }

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 (   $a_user_id,
  $a_post_id 
)

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

316 {
317 $this->db->manipulateF(
318 '
319 DELETE FROM frm_user_read
320 WHERE usr_id = %s
321 AND post_id = %s',
322 array('integer', 'integer'),
323 array($a_user_id, $a_post_id)
324 );
325 }

◆ markThreadRead()

ilObjForum::markThreadRead (   $a_usr_id,
  $a_thread_id 
)

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

247 {
248 // Get all post ids
249 $res = $this->db->queryf(
250 '
251 SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
252 array('integer'),
253 array($a_thread_id)
254 );
255
256 while ($row = $this->db->fetchObject($res)) {
257 $this->markPostRead($a_usr_id, $a_thread_id, $row->pos_pk);
258 }
259 return true;
260 }
markPostRead($a_usr_id, $a_thread_id, $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 (   $merge_source_thread_id,
  $merge_target_thread_id 
)
static

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

1192 {
1193 global $DIC;
1194 $ilDB = $DIC->database();
1195
1196 $ilDB->update(
1197 'frm_user_read',
1198 array('thread_id' => array('integer', $merge_target_thread_id)),
1199 array('thread_id' => array('integer',$merge_source_thread_id))
1200 );
1201 }

References $DIC, and $ilDB.

Referenced by ilForum\mergeThreads().

+ Here is the caller graph for this function:

◆ preloadForumIdsByObjIds()

static ilObjForum::preloadForumIdsByObjIds ( array  $obj_ids)
static
Parameters
array$obj_ids

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

889 {
890 global $DIC;
891 $ilDB = $DIC->database();
892
893 if (count($obj_ids) == 1) {
894 $in = " objr.obj_id = " . $ilDB->quote(current($obj_ids), 'integer') . " ";
895 } else {
896 $in = $ilDB->in('objr.obj_id', $obj_ids, false, 'integer');
897 }
898 $query = "
899 SELECT frmd.top_pk, objr.ref_id, objr.obj_id
900 FROM object_reference objr
901 INNER JOIN frm_data frmd ON frmd.top_frm_fk = objr.obj_id
902 WHERE $in
903 ";
904 $res = $ilDB->query($query);
905
906 // Prepare cache array
907 foreach ($obj_ids as $obj_id) {
908 self::$obj_id_to_forum_id_cache[$obj_id] = null;
909 }
910
911 while ($row = $ilDB->fetchAssoc($res)) {
912 self::$obj_id_to_forum_id_cache[$row['obj_id']] = $row['top_pk'];
913 self::$ref_id_to_forum_id_cache[$row['ref_id']] = $row['top_pk'];
914 }
915 }

References $DIC, $ilDB, $in, $query, and $res.

Referenced by lookupForumIdByObjId().

+ Here is the caller graph for this function:

◆ preloadForumIdsByRefIds()

static ilObjForum::preloadForumIdsByRefIds ( array  $ref_ids)
static
Parameters
array$ref_ids

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

922 {
923 global $DIC;
924 $ilDB = $DIC->database();
925
926 if (count($ref_ids) == 1) {
927 $in = " objr.ref_id = " . $ilDB->quote(current($ref_ids), 'integer') . " ";
928 } else {
929 $in = $ilDB->in('objr.ref_id', $ref_ids, false, 'integer');
930 }
931 $query = "
932 SELECT frmd.top_pk, objr.ref_id, objr.obj_id
933 FROM object_reference objr
934 INNER JOIN frm_data frmd ON frmd.top_frm_fk = objr.obj_id
935 WHERE $in
936 ";
937 $res = $ilDB->query($query);
938
939 // Prepare cache array
940 foreach ($ref_ids as $ref_id) {
941 self::$ref_id_to_forum_id_cache[$ref_id] = null;
942 }
943
944 while ($row = $ilDB->fetchAssoc($res)) {
945 self::$obj_id_to_forum_id_cache[$row['obj_id']] = $row['top_pk'];
946 self::$ref_id_to_forum_id_cache[$row['ref_id']] = $row['top_pk'];
947 }
948 }

References $DIC, $ilDB, $in, $query, ilObject\$ref_id, and $res.

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

+ Here is the caller graph for this function:

◆ saveData()

ilObjForum::saveData (   $a_roles = array())

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

795 {
796 $nextId = $this->db->nextId('frm_data');
797
798 $top_data = array(
799 'top_frm_fk' => $this->getId(),
800 'top_name' => $this->getTitle(),
801 'top_description' => $this->getDescription(),
802 'top_num_posts' => 0,
803 'top_num_threads' => 0,
804 'top_last_post' => null,
805 'top_mods' => !is_numeric($a_roles[0]) ? 0 : $a_roles[0],
806 'top_usr_id' => $this->user->getId(),
807 'top_date' => ilUtil::now()
808 );
809
810 $this->db->manipulateF(
811 '
812 INSERT INTO frm_data
813 (
814 top_pk,
815 top_frm_fk,
816 top_name,
817 top_description,
818 top_num_posts,
819 top_num_threads,
820 top_last_post,
821 top_mods,
822 top_date,
823 top_usr_id
824 )
825 VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
826 array('integer', 'integer', 'text', 'text', 'integer', 'integer', 'text', 'integer', 'timestamp', 'integer'),
827 array(
828 $nextId,
829 $top_data['top_frm_fk'],
830 $top_data['top_name'],
831 $top_data['top_description'],
832 $top_data['top_num_posts'],
833 $top_data['top_num_threads'],
834 $top_data['top_last_post'],
835 $top_data['top_mods'],
836 $top_data['top_date'],
837 $top_data['top_usr_id']
838 )
839 );
840 }
getDescription()
get object description
getTitle()
get object title @access public
static now()
Return current timestamp in Y-m-d H:i:s format.

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

Referenced by create().

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

◆ setPermissions()

ilObjForum::setPermissions (   $a_ref_id)
Returns
int

Reimplemented from ilObject.

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

114 {
115 parent::setPermissions($a_ref_id);
116
117 // ...finally assign moderator role to creator of forum object
118 $roles = array(ilObjForum::_lookupModeratorRole($this->getRefId()));
119 $this->rbac->admin()->assignUser($roles[0], $this->getOwner(), 'n');
120 $this->updateModeratorRole($roles[0]);
121 }
updateModeratorRole($role_id)

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

+ Here is the call graph for this function:

◆ setThreadSorting()

ilObjForum::setThreadSorting (   $a_thr_pk,
  $a_sorting_value 
)

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

843 {
844 $this->db->update(
845 'frm_threads',
846 array('thread_sorting' => array('integer',$a_sorting_value)),
847 array('thr_pk' => array('integer', $a_thr_pk))
848 );
849 }

◆ update()

ilObjForum::update (   $a_update_user_id = 0)

update forum data @access public

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

482 {
483 if (!$a_update_user_id) {
484 $a_update_user_id = $this->user->getId();
485 }
486
487 if (parent::update()) {
488 $this->db->manipulateF(
489 '
490 UPDATE frm_data
491 SET top_name = %s,
492 top_description = %s,
493 top_update = %s,
494 update_user = %s
495 WHERE top_frm_fk =%s',
496 array('text', 'text', 'timestamp', 'integer', 'integer'),
497 array(
498 $this->getTitle(),
499 $this->getDescription(),
500 date("Y-m-d H:i:s"),
501 (int) $a_update_user_id,
502 (int) $this->getId()
503 )
504 );
505
506 return true;
507 }
508
509 return false;
510 }

References ilObject\getDescription(), ilObject\getId(), ilObject\getTitle(), and user().

+ Here is the call graph for this function:

◆ updateLastAccess()

ilObjForum::updateLastAccess (   $a_usr_id,
  $a_thread_id 
)

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

342 {
343 $res = $this->db->queryf(
344 '
345 SELECT * FROM frm_thread_access
346 WHERE usr_id = %s
347 AND obj_id = %s
348 AND thread_id = %s',
349 array('integer', 'integer', 'integer'),
350 array($a_usr_id, $this->getId(), $a_thread_id)
351 );
352 $data = $this->db->fetchAssoc($res);
353
354 $this->db->replace(
355 'frm_thread_access',
356 array(
357 'usr_id' => array('integer', $a_usr_id),
358 'obj_id' => array('integer', $this->getId()),
359 'thread_id' => array('integer', $a_thread_id)
360 ),
361 array(
362 'access_last' => array('integer', time()),
363 'access_old' => array('integer', isset($data['access_old']) ? $data['access_old'] : 0),
364 'access_old_ts' => array('timestamp', $data['access_old_ts'])
365 )
366 );
367
368 return true;
369 }

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

+ Here is the call graph for this function:

◆ updateModeratorRole()

ilObjForum::updateModeratorRole (   $role_id)
Parameters
int$role_id

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

127 {
128 $this->db->manipulate('UPDATE frm_data SET top_mods = ' . $this->db->quote($role_id, 'integer') . ' WHERE top_frm_fk = ' . $this->db->quote($this->getId(), 'integer'));
129 }

Referenced by setPermissions().

+ Here is the caller graph for this function:

Field Documentation

◆ $Forum

ilObjForum::$Forum

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

◆ $forum_last_post_cache

ilObjForum::$forum_last_post_cache = array()
staticprotected

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

◆ $forum_statistics_cache

ilObjForum::$forum_statistics_cache = array()
staticprotected

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

◆ $ilBench

ilObjForum::$ilBench
private

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

◆ $logger

ilObjForum::$logger
private

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

◆ $obj_id_to_forum_id_cache

ilObjForum::$obj_id_to_forum_id_cache = array()
staticprotected

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

◆ $rbac

ilObjForum::$rbac
private

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

◆ $ref_id_to_forum_id_cache

ilObjForum::$ref_id_to_forum_id_cache = array()
staticprotected

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

◆ $settings

ilObjForum::$settings
private

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

◆ $user

ilObjForum::$user
private

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


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