ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 
- 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...
 
 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)
 only called in ilTree::saveSubTree More...
 
static setDeletedDates ($a_ref_ids)
 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 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, 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
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ 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: saml.php:7
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: saml.php:7
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  }
global $DIC
Definition: saml.php:7
global $ilDB
$data
Definition: bench.php:6
+ 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 762 of file class.ilObjForum.php.

References $DIC, $ilDB, $res, and $row.

Referenced by cloneAutoGeneratedRoles(), and setPermissions().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
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, $res, and $row.

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
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(), and ilAuthBase\loginObserver().

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: saml.php:7
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 612 of file class.ilObjForum.php.

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

Referenced by update().

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  }
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(), and saveData().

92  {
93  $id = parent::create();
94 
95  $properties = ilForumProperties::getInstance($this->getId());
96  $properties->setDefaultView(1);
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 783 of file class.ilObjForum.php.

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

Referenced by create().

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  }
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 640 of file class.ilObjForum.php.

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

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  }
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 717 of file class.ilObjForum.php.

References $res, and $row.

Referenced by delete().

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 ilForumPostDraft.
Class ilForumDraftHistory.
foreach($_POST as $key=> $value) $res
$row
+ 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, $row, 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
$row
+ 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:

◆ 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.

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

Referenced by ilForumTopicTableGUI\numericOrdering().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18
$query
$row
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB
+ 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 744 of file class.ilObjForum.php.

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

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)
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 857 of file class.ilObjForum.php.

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

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  }
+ 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.

References ilObject\$ref_id.

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

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 
879  self::preloadForumIdsByRefIds(array($ref_id));
880 
881  return (int) self::$ref_id_to_forum_id_cache[$ref_id];
882  }
+ 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.

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

Referenced by ilObjForumAccess\getLastPostByRefId().

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 
1104  $forumId = self::lookupForumIdByRefId($ref_id);
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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18
$query
global $ilDB
$data
Definition: bench.php:6
+ 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.

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

Referenced by ilObjForumAccess\getStatisticsByRefId().

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 
973  $forumId = self::lookupForumIdByRefId($ref_id);
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  }
global $DIC
Definition: saml.php:7
static _lookupObjectId($a_ref_id)
lookup object id
static getInstance($a_obj_id=0)
foreach($_POST as $key=> $value) $res
$values
$ilUser
Definition: imgupload.php:18
$query
$row
global $ilSetting
Definition: privfeed.php:17
global $ilDB
$i
Definition: disco.tpl.php:19
+ 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, $row, 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
$row
+ 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, $row, 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
$row
+ 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.

References $DIC, and $ilDB.

Referenced by ilForum\mergeThreads().

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  }
global $DIC
Definition: saml.php:7
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 888 of file class.ilObjForum.php.

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
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 921 of file class.ilObjForum.php.

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

Referenced by ilObjForumAccess\_preloadData().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
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 794 of file class.ilObjForum.php.

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

Referenced by create().

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  }
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 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 public

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

References PHPMailer\PHPMailer\$options, ilCopyWizardOptions\_getInstance(), ilForum\_lookupPostMessage(), cloneAutoGeneratedRoles(), ilObject\getDescription(), ilObject\getId(), ilForumProperties\getInstance(), ilObject\getRefId(), ilObject\getTitle(), League\Flysystem\Adapter\Polyfill\update(), 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
update($pash, $contents, Config $config)
+ 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  }
foreach($_POST as $key=> $value) $res
getId()
get object id public
$data
Definition: bench.php:6
+ 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: