ILIAS  release_7 Revision v7.30-3-g800a261c036
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 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 public More...
 
 cloneAutoGeneratedRoles ($new_obj)
 Clone forum moderator role public. More...
 
 delete ()
 Delete forum and all related data public. More...
 
 initDefaultRoles ()
 init default roles settings public More...
 
 createSettings ()
 
 saveData ($a_roles=array())
 
 setThreadSorting ($a_thr_pk, $a_sorting_value)
 
 getNumStickyThreads ()
 
- Public Member Functions inherited from ilObject
 __construct ($a_id=0, $a_reference=true)
 Constructor 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 public More...
 
 setId ($a_id)
 set object id public More...
 
 setRefId ($a_id)
 set reference id public More...
 
 getRefId ()
 get reference id public More...
 
 getType ()
 get object type public More...
 
 setType ($a_type)
 set object type public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title public More...
 
 getUntranslatedTitle ()
 get untranslated object title 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 public More...
 
 getLastUpdateDate ()
 get last update date 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...
 
 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 If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) 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 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 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 _getIcon ( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. 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 public.

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

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

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

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  }
Class Forum core functions for forum.
settings()
Definition: settings.php:2
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
+ 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.

References $DIC, and $ilDB.

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

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 $DIC
Definition: goto.php:24
global $ilDB
+ 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.

References $DIC, and $ilDB.

Referenced by ilForum\deletePost().

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  }
global $DIC
Definition: goto.php:24
global $ilDB
+ 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.

References $data, $DIC, and $ilDB.

Referenced by ilObjUser\delete().

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
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupModeratorRole()

static ilObjForum::_lookupModeratorRole (   $a_ref_id)
static

Lookup moderator role public.

Parameters
int$a_ref_idref_id of forum

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

References $DIC, $ilDB, and $res.

Referenced by cloneAutoGeneratedRoles(), and setPermissions().

767  {
768  global $DIC;
769  $ilDB = $DIC->database();
770 
771  $mod_title = 'il_frm_moderator_' . $a_ref_id;
772 
773  $res = $ilDB->queryf(
774  '
775  SELECT * FROM object_data WHERE title = %s',
776  array('text'),
777  array($mod_title)
778  );
779 
780  while ($row = $ilDB->fetchObject($res)) {
781  return $row->obj_id;
782  }
783  return 0;
784  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
global $ilDB
+ 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.

References $DIC, $ilDB, and $res.

Referenced by ilObjForumSubItemListGUI\getHTML().

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  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
global $ilDB
+ 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.

References $DIC, and $ilDB.

Referenced by ilAuthFrontend\handleAuthenticationSuccess().

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  }
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ cloneAutoGeneratedRoles()

ilObjForum::cloneAutoGeneratedRoles (   $new_obj)

Clone forum moderator role public.

Parameters
object$new_objforum object

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

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

Referenced by update().

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

◆ create()

ilObjForum::create ( )
Returns
int

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

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

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  }
saveData($a_roles=array())
static getInstance($a_obj_id=0)
getId()
get object id public
+ Here is the call graph for this function:

◆ createSettings()

ilObjForum::createSettings ( )

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

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

Referenced by create().

788  {
789  // news settings (public notifications yes/no)
790  $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET["ref_id"]);
791  if ($default_visibility == "public") {
792  ilBlockSetting::_write("news", "public_notifications", 1, 0, $this->getId());
793  }
794 
795  return true;
796  }
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
$_GET["client_id"]
getId()
get object id public
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
+ 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 public.

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

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

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

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

◆ deleteDraftsByForumId()

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

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

References $res.

Referenced by delete().

722  {
723  $res = $this->db->queryF(
724  'SELECT draft_id FROM frm_posts_drafts WHERE forum_id = %s',
725  array('integer'),
726  array((int) $forum_id)
727  );
728 
729  $draft_ids = array();
730  while ($row = $this->db->fetchAssoc($res)) {
731  $draft_ids[] = $row['draft_id'];
732  }
733 
734  if (count($draft_ids) > 0) {
735  $historyObj = new ilForumDraftsHistory();
736  $historyObj->deleteHistoryByDraftIds($draft_ids);
737 
738  $draftObj = new ilForumPostDraft();
739  $draftObj->deleteDraftsByDraftIds($draft_ids);
740  }
741  }
Class ilForumPostDraft.
Class ilForumDraftHistory.
foreach($_POST as $key=> $value) $res
+ 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.

References $res, and ilObject\getId().

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  }
foreach($_POST as $key=> $value) $res
getId()
get object id public
+ Here is the call graph for this function:

◆ getDiskUsage()

ilObjForum::getDiskUsage ( )

Gets the disk usage of the object in bytes.

public

Returns
integer the disk usage in bytes

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

References ilObjForumAccess\_lookupDiskUsage().

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

◆ getNumStickyThreads()

ilObjForum::getNumStickyThreads ( )

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

References $res.

1207  : int
1208  {
1209  $res = $this->db->query(
1210  'SELECT COUNT(is_sticky) num_sticky FROM frm_threads
1211  INNER JOIN frm_data ON top_pk = thr_top_fk
1212  WHERE frm_data.top_frm_fk = ' . $this->db->quote($this->getId(), 'integer') . '
1213  AND is_sticky = ' . $this->db->quote(1, 'integer')
1214  );
1215  if ($row = $this->db->fetchAssoc($res)) {
1216  return (int) $row['num_sticky'];
1217  }
1218  return 0;
1219  }
foreach($_POST as $key=> $value) $res

◆ getUserIdsOfLastPostsByRefIdAndThreadIds()

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

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

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

Referenced by ilForumTopicTableGUI\numericOrdering().

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

◆ initDefaultRoles()

ilObjForum::initDefaultRoles ( )

init default roles settings public

Returns
array object IDs of created local roles.

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

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

749  {
751  'il_frm_moderator_' . $this->getRefId(),
752  "Moderator of forum obj_no." . $this->getId(),
753  'il_frm_moderator',
754  $this->getRefId()
755  );
756  return array();
757  }
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)
getId()
get object id public
getRefId()
get reference id public
+ 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.

References $res.

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  }
foreach($_POST as $key=> $value) $res

◆ lookupForumIdByObjId()

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

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

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

862  {
863  if (array_key_exists($obj_id, self::$obj_id_to_forum_id_cache)) {
864  return (int) self::$obj_id_to_forum_id_cache[$obj_id];
865  }
866 
867  self::preloadForumIdsByObjIds(array($obj_id));
868 
869  return (int) self::$obj_id_to_forum_id_cache[$obj_id];
870  }
+ Here is the caller graph for this function:

◆ lookupForumIdByRefId()

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

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

References ilObject\$ref_id.

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

878  {
879  if (array_key_exists($ref_id, self::$ref_id_to_forum_id_cache)) {
880  return (int) self::$ref_id_to_forum_id_cache[$ref_id];
881  }
882 
883  self::preloadForumIdsByRefIds(array($ref_id));
884 
885  return (int) self::$ref_id_to_forum_id_cache[$ref_id];
886  }
+ Here is the caller graph for this function:

◆ lookupLastPostByRefId()

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

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

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

Referenced by ilObjForumAccess\getLastPostByRefId().

1098  {
1099  global $DIC;
1100  $ilAccess = $DIC->access();
1101  $ilUser = $DIC->user();
1102  $ilDB = $DIC->database();
1103 
1104  if (isset(self::$forum_last_post_cache[$ref_id])) {
1105  return self::$forum_last_post_cache[$ref_id];
1106  }
1107 
1108  $forumId = self::lookupForumIdByRefId($ref_id);
1109  if (!$forumId) {
1110  self::$forum_last_post_cache[$ref_id] = array();
1111  return self::$forum_last_post_cache[$ref_id];
1112  }
1113 
1114  $act_clause = '';
1115  if (!$ilAccess->checkAccess('moderate_frm', '', $ref_id)) {
1116  $act_clause .= " AND (frm_posts.pos_status = " . $ilDB->quote(1, "integer") . " OR frm_posts.pos_author_id = " . $ilDB->quote($ilUser->getId(), "integer") . ") ";
1117  }
1118 
1119  $ilDB->setLimit(1, 0);
1120  $query = "
1121  SELECT *
1122  FROM frm_posts
1123  INNER JOIN frm_posts_tree tree1
1124  ON tree1.pos_fk = frm_posts.pos_pk
1125  AND tree1.parent_pos != 0
1126  WHERE pos_top_fk = %s $act_clause
1127  ORDER BY pos_date DESC
1128  ";
1129  $res = $ilDB->queryF(
1130  $query,
1131  array('integer'),
1132  array($forumId)
1133  );
1134 
1135  $data = $ilDB->fetchAssoc($res);
1136 
1137  self::$forum_last_post_cache[$ref_id] = is_array($data) ? $data : array();
1138 
1139  return self::$forum_last_post_cache[$ref_id];
1140  }
$data
Definition: storeScorm.php:23
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
$ilUser
Definition: imgupload.php:18
+ Here is the caller graph for this function:

◆ lookupStatisticsByRefId()

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

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

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

Referenced by ilObjForumAccess\getStatisticsByRefId().

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

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

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)
foreach($_POST as $key=> $value) $res
getId()
get object id public
+ 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.

References $res, and ilObject\getId().

Referenced by markThreadRead().

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  }
foreach($_POST as $key=> $value) $res
getId()
get object id public
+ 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.

References $res, and markPostRead().

Referenced by markAllThreadsRead().

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)
foreach($_POST as $key=> $value) $res
+ 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 1195 of file class.ilObjForum.php.

References $DIC, and $ilDB.

Referenced by ilForum\mergeThreads().

1196  {
1197  global $DIC;
1198  $ilDB = $DIC->database();
1199 
1200  $ilDB->update(
1201  'frm_user_read',
1202  array('thread_id' => array('integer', $merge_target_thread_id)),
1203  array('thread_id' => array('integer',$merge_source_thread_id))
1204  );
1205  }
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ preloadForumIdsByObjIds()

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

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

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

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

◆ preloadForumIdsByRefIds()

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

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

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

Referenced by ilObjForumAccess\_preloadData().

926  {
927  global $DIC;
928  $ilDB = $DIC->database();
929 
930  if (count($ref_ids) == 1) {
931  $in = " objr.ref_id = " . $ilDB->quote(current($ref_ids), 'integer') . " ";
932  } else {
933  $in = $ilDB->in('objr.ref_id', $ref_ids, false, 'integer');
934  }
935  $query = "
936  SELECT frmd.top_pk, objr.ref_id, objr.obj_id
937  FROM object_reference objr
938  INNER JOIN frm_data frmd ON frmd.top_frm_fk = objr.obj_id
939  WHERE $in
940  ";
941  $res = $ilDB->query($query);
942 
943  // Prepare cache array
944  foreach ($ref_ids as $ref_id) {
945  self::$ref_id_to_forum_id_cache[$ref_id] = null;
946  }
947 
948  while ($row = $ilDB->fetchAssoc($res)) {
949  self::$obj_id_to_forum_id_cache[$row['obj_id']] = $row['top_pk'];
950  self::$ref_id_to_forum_id_cache[$row['ref_id']] = $row['top_pk'];
951  }
952  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB
+ Here is the caller graph for this function:

◆ saveData()

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

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

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

Referenced by create().

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

◆ setPermissions()

ilObjForum::setPermissions (   $a_ref_id)
Returns
int

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

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

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  }
getOwner()
get object owner
updateModeratorRole($role_id)
static _lookupModeratorRole($a_ref_id)
Lookup moderator role public.
getRefId()
get reference id public
+ Here is the call graph for this function:

◆ setThreadSorting()

ilObjForum::setThreadSorting (   $a_thr_pk,
  $a_sorting_value 
)

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

847  {
848  $this->db->update(
849  'frm_threads',
850  array('thread_sorting' => array('integer',$a_sorting_value)),
851  array('thr_pk' => array('integer', $a_thr_pk))
852  );
853  }

◆ update()

ilObjForum::update (   $a_update_user_id = 0)

update forum data public

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

References ilCopyWizardOptions\_getInstance(), cloneAutoGeneratedRoles(), ilObject\getDescription(), ilObject\getId(), ilForumProperties\getInstance(), ilObject\getRefId(), ilObject\getTitle(), and user().

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  }
user()
Definition: user.php:4
getId()
get object id public
getTitle()
get object title public
getDescription()
get object description
+ 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.

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

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  }
$data
Definition: storeScorm.php:23
foreach($_POST as $key=> $value) $res
getId()
get object id public
+ 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.

References ilObject\getId().

Referenced by setPermissions().

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  }
getId()
get object id public
+ Here is the call graph for this function:
+ 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: