ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilForumPostDraft Class Reference

Class ilForumPostDraft. More...

+ Collaboration diagram for ilForumPostDraft:

Public Member Functions

 __construct (int $user_id=0, int $post_id=0, int $draft_id=0)
 
 getRCID ()
 
 setRCID (string $rcid)
 
 isPostNotificationEnabled ()
 
 setPostNotificationStatus (bool $post_notify)
 
 isNotificationEnabled ()
 
 setNotificationStatus (bool $notify)
 
 getDraftId ()
 
 setDraftId (int $draft_id)
 
 getPostId ()
 
 setPostId (int $post_id)
 
 getForumId ()
 
 setForumId (int $forum_id)
 
 getThreadId ()
 
 setThreadId (int $thread_id)
 
 getPostSubject ()
 
 setPostSubject (string $post_subject)
 
 getPostMessage ()
 
 setPostMessage (string $post_message)
 
 getPostDate ()
 
 setPostDate (string $post_date)
 
 getPostUpdate ()
 
 setPostUpdate (string $post_update)
 
 getUpdateUserId ()
 
 setUpdateUserId (int $update_user_id)
 
 getPostUserAlias ()
 
 setPostUserAlias (string $post_user_alias)
 
 getPostAuthorId ()
 
 setPostAuthorId (int $post_author_id)
 
 getPostDisplayUserId ()
 
 setPostDisplayUserId (int $post_display_user_id)
 
 saveDraft ()
 
 update ()
 
 updateDraft ()
 
 deleteDraft ()
 
 deleteDraftsByPostIds (array $post_ids=[])
 
 deleteDraftsByDraftIds (array $draft_ids=[])
 

Static Public Member Functions

static getSortedDrafts (int $usrId, int $threadId, int $sorting=ilForumProperties::VIEW_DATE_ASC)
 
static getDraftInstancesByUserId (int $user_id)
 
static newInstanceByDraftId (int $draft_id)
 
static deleteMobsOfDraft (int $draft_id)
 
static deleteDraftsByUserId (int $user_id)
 
static isSavePostDraftAllowed ()
 
static isAutoSavePostDraftAllowed ()
 
static lookupAutosaveInterval ()
 
static getDraftsStatisticsByRefId (int $ref_id)
 
static moveDraftsByMergedThreads (int $source_thread_id, int $target_thread_id)
 
static getThreadDraftData (int $post_author_id, int $forum_id)
 
static createDraftBackup (int $draft_id)
 

Data Fields

const MEDIAOBJECT_TYPE = 'frm~d:html'
 
const NO_RCID = '-'
 

Protected Member Functions

 readDraft ()
 

Static Protected Member Functions

static readDrafts (int $user_id)
 

Static Private Member Functions

static populateWithDatabaseRecord (ilForumPostDraft $draft, array $row)
 

Private Attributes

readonly ilDBInterface $db
 
int $draft_id = 0
 
int $post_id = 0
 
int $forum_id = 0
 
int $thread_id = 0
 
string $post_subject = ''
 
string $post_message = ''
 
string $post_date = '0000-00-00 00:00:00'
 
string $post_update = '0000-00-00 00:00:00'
 
int $update_user_id = 0
 
string $post_user_alias = ''
 
int $post_author_id = 0
 
int $post_display_user_id = 0
 
bool $notify = false
 
bool $post_notify = false
 
string $rcid = ''
 

Static Private Attributes

static array $instances = []
 
static array $forum_statistics_cache = []
 
static array $drafts_settings_cache = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilForumPostDraft::__construct ( int  $user_id = 0,
int  $post_id = 0,
int  $draft_id = 0 
)

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

References $DIC, $user_id, readDraft(), setDraftId(), setPostAuthorId(), and setPostId().

53  {
54  global $DIC;
55 
56  $this->db = $DIC->database();
57 
58  if ($user_id && $post_id && $draft_id) {
59  $this->setPostAuthorId($user_id);
60  $this->setPostId($post_id);
61  $this->setDraftId($draft_id);
62  $this->readDraft();
63  }
64  }
global $DIC
Definition: shib_login.php:22
setPostAuthorId(int $post_author_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ createDraftBackup()

static ilForumPostDraft::createDraftBackup ( int  $draft_id)
static

Definition at line 618 of file class.ilForumPostDraft.php.

References $DIC, $draft_id, $ilDB, $res, ilForumDraftsHistory\MEDIAOBJECT_TYPE, and ilForumUtil\moveMediaObjects().

Referenced by ilObjForumGUI\doHistoryCheck(), and ilObjForumGUI\restoreFromHistoryObject().

618  : void
619  {
620  global $DIC;
621  $ilDB = $DIC->database();
622 
623  $res = $ilDB->queryF(
624  'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
625  ['integer'],
626  [$draft_id]
627  );
628 
629  $tmp_obj = new self();
630  while ($row = $ilDB->fetchAssoc($res)) {
631  self::populateWithDatabaseRecord($tmp_obj, $row);
632  }
633 
634  $history_obj = new ilForumDraftsHistory();
635  $history_obj->deleteHistoryByDraftIds([$draft_id]);
636 
637  $history_obj->setDraftId($draft_id);
638  $history_obj->setPostSubject($tmp_obj->getPostSubject());
639  $history_obj->setPostMessage($tmp_obj->getPostMessage());
640  $history_obj->addDraftToHistory();
641 
643  $tmp_obj->getPostMessage(),
644  self::MEDIAOBJECT_TYPE,
645  $draft_id,
647  $history_obj->getHistoryId()
648  );
649  }
$res
Definition: ltiservices.php:66
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
Class ilForumDraftHistory.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteDraft()

ilForumPostDraft::deleteDraft ( )

Definition at line 391 of file class.ilForumPostDraft.php.

References getDraftId().

Referenced by ilObjForumGUI\createThread().

391  : void
392  {
393  $this->db->manipulateF(
394  'DELETE FROM frm_posts_drafts WHERE draft_id = %s',
395  ['integer'],
396  [$this->getDraftId()]
397  );
398  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteDraftsByDraftIds()

ilForumPostDraft::deleteDraftsByDraftIds ( array  $draft_ids = [])
Parameters
int[]$draft_ids

Definition at line 452 of file class.ilForumPostDraft.php.

452  : void
453  {
454  foreach ($draft_ids as $draft_id) {
455  self::deleteMobsOfDraft($draft_id);
456  }
457 
458  $objFileDataForumDrafts = new ilFileDataForumDrafts();
459  $objFileDataForumDrafts->delete($draft_ids);
460 
461  $this->db->manipulate('DELETE FROM frm_drafts_history WHERE ' . $this->db->in(
462  'draft_id',
463  $draft_ids,
464  false,
465  'integer'
466  ));
467  $this->db->manipulate('DELETE FROM frm_posts_drafts WHERE ' . $this->db->in(
468  'draft_id',
469  $draft_ids,
470  false,
471  'integer'
472  ));
473  }

◆ deleteDraftsByPostIds()

ilForumPostDraft::deleteDraftsByPostIds ( array  $post_ids = [])
Parameters
int[]$post_ids

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

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

415  : void
416  {
417  $draft_ids = [];
418  $res = $this->db->query('SELECT draft_id FROM frm_posts_drafts WHERE ' . $this->db->in(
419  'post_id',
420  $post_ids,
421  false,
422  'integer'
423  ));
424  while ($row = $this->db->fetchAssoc($res)) {
425  $draft_ids[] = (int) $row['draft_id'];
426  }
427 
428  foreach ($draft_ids as $draft_id) {
429  self::deleteMobsOfDraft($draft_id);
430  }
431 
432  $objFileDataForumDrafts = new ilFileDataForumDrafts();
433  $objFileDataForumDrafts->delete($draft_ids);
434 
435  $this->db->manipulate('DELETE FROM frm_drafts_history WHERE ' . $this->db->in(
436  'draft_id',
437  $draft_ids,
438  false,
439  'integer'
440  ));
441  $this->db->manipulate('DELETE FROM frm_posts_drafts WHERE ' . $this->db->in(
442  'draft_id',
443  $draft_ids,
444  false,
445  'integer'
446  ));
447  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ deleteDraftsByUserId()

static ilForumPostDraft::deleteDraftsByUserId ( int  $user_id)
static

Definition at line 475 of file class.ilForumPostDraft.php.

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

475  : void
476  {
477  global $DIC;
478  $ilDB = $DIC->database();
479 
480  $res = $ilDB->queryF(
481  'SELECT draft_id FROM frm_posts_drafts WHERE post_author_id = %s',
482  ['integer'],
483  [$user_id]
484  );
485 
486  $draft_ids = [];
487  while ($row = $ilDB->fetchAssoc($res)) {
488  $draft_ids[] = (int) $row['draft_id'];
489  }
490 
491  foreach ($draft_ids as $draft_id) {
492  self::deleteMobsOfDraft($draft_id);
493  }
494 
495  $objFileDataForumDrafts = new ilFileDataForumDrafts();
496  $objFileDataForumDrafts->delete($draft_ids);
497 
498  $ilDB->manipulate('DELETE FROM frm_drafts_history WHERE ' . $ilDB->in(
499  'draft_id',
500  $draft_ids,
501  false,
502  'integer'
503  ));
504  $ilDB->manipulateF(
505  'DELETE FROM frm_posts_drafts WHERE post_author_id = %s',
506  ['integer'],
507  [$user_id]
508  );
509  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ deleteMobsOfDraft()

static ilForumPostDraft::deleteMobsOfDraft ( int  $draft_id)
static

Definition at line 400 of file class.ilForumPostDraft.php.

References ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), and ilObjMediaObject\_removeUsage().

400  : void
401  {
402  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draft_id);
403  foreach ($oldMediaObjects as $oldMob) {
404  if (ilObjMediaObject::_exists($oldMob)) {
405  ilObjMediaObject::_removeUsage($oldMob, 'frm~d:html', $draft_id);
406  $mob_obj = new ilObjMediaObject($oldMob);
407  $mob_obj->delete();
408  }
409  }
410  }
static _exists(int $id, bool $reference=false, ?string $type=null)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
+ Here is the call graph for this function:

◆ getDraftId()

ilForumPostDraft::getDraftId ( )

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

References $draft_id.

Referenced by ilObjForumGUI\createThread(), deleteDraft(), ilObjForumGUI\hasDraftAccess(), readDraft(), and updateDraft().

115  : int
116  {
117  return $this->draft_id;
118  }
+ Here is the caller graph for this function:

◆ getDraftInstancesByUserId()

static ilForumPostDraft::getDraftInstancesByUserId ( int  $user_id)
static
Returns
array<int, ilForumPostDraft>

Definition at line 319 of file class.ilForumPostDraft.php.

References $user_id.

Referenced by ilObjForumGUI\confirmDeleteThreadDraftsObject(), ilObjForumGUI\deleteThreadDraftsObject(), and ilForumDraftsDerivedTaskProvider\getTasks().

319  : array
320  {
321  if (!isset(self::$instances[$user_id])) {
322  self::readDrafts($user_id);
323  }
324 
325  return self::$instances[$user_id]['draft_ids'];
326  }
+ Here is the caller graph for this function:

◆ getDraftsStatisticsByRefId()

static ilForumPostDraft::getDraftsStatisticsByRefId ( int  $ref_id)
static

Definition at line 548 of file class.ilForumPostDraft.php.

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

Referenced by ilObjForumListGUI\getProperties(), and ilForumTopicTableGUI\initMergeThreadsTable().

548  : array
549  {
550  global $DIC;
551  $ilDB = $DIC->database();
552  $ilUser = $DIC->user();
553 
554  if (!isset(self::$forum_statistics_cache[$ref_id][$ilUser->getId()])) {
556 
557  $res = $ilDB->queryF(
558  '
559  SELECT COUNT(draft_id) num_drafts, thread_id FROM frm_posts_drafts
560  LEFT JOIN frm_posts ON pos_pk = post_id
561  WHERE forum_id = %s AND post_author_id = %s AND (frm_posts.pos_pk IS NOT NULL OR post_id = 0)
562  GROUP BY thread_id',
563  ['integer', 'integer'],
564  [$forumId, $ilUser->getId()]
565  );
566 
567  $num_drafts_total = 0;
568 
569  while ($row = $ilDB->fetchAssoc($res)) {
570  $num_drafts_total += $row['num_drafts'];
571  self::$forum_statistics_cache[$ref_id][$ilUser->getId()][(int) $row['thread_id']] = (int) $row['num_drafts'];
572  }
573 
574  self::$forum_statistics_cache[$ref_id][$ilUser->getId()]['total'] = $num_drafts_total;
575  }
576  return self::$forum_statistics_cache[$ref_id][$ilUser->getId()];
577  }
$res
Definition: ltiservices.php:66
static lookupForumIdByRefId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getForumId()

ilForumPostDraft::getForumId ( )

Definition at line 135 of file class.ilForumPostDraft.php.

References $forum_id.

Referenced by saveDraft().

135  : int
136  {
137  return $this->forum_id;
138  }
+ Here is the caller graph for this function:

◆ getPostAuthorId()

ilForumPostDraft::getPostAuthorId ( )

Definition at line 215 of file class.ilForumPostDraft.php.

References $post_author_id.

Referenced by ilObjForumGUI\createThread(), ilObjForumGUI\hasDraftAccess(), readDraft(), and saveDraft().

215  : int
216  {
217  return $this->post_author_id;
218  }
+ Here is the caller graph for this function:

◆ getPostDate()

ilForumPostDraft::getPostDate ( )

Definition at line 175 of file class.ilForumPostDraft.php.

References $post_date.

175  : string
176  {
177  return $this->post_date;
178  }

◆ getPostDisplayUserId()

ilForumPostDraft::getPostDisplayUserId ( )

Definition at line 225 of file class.ilForumPostDraft.php.

References $post_display_user_id.

Referenced by ilObjForumGUI\createThread(), and saveDraft().

225  : int
226  {
228  }
+ Here is the caller graph for this function:

◆ getPostId()

ilForumPostDraft::getPostId ( )

Definition at line 125 of file class.ilForumPostDraft.php.

References $post_id.

Referenced by saveDraft().

125  : int
126  {
127  return $this->post_id;
128  }
+ Here is the caller graph for this function:

◆ getPostMessage()

ilForumPostDraft::getPostMessage ( )

Definition at line 165 of file class.ilForumPostDraft.php.

References $post_message.

Referenced by saveDraft(), and updateDraft().

165  : string
166  {
167  return $this->post_message;
168  }
+ Here is the caller graph for this function:

◆ getPostSubject()

ilForumPostDraft::getPostSubject ( )

Definition at line 155 of file class.ilForumPostDraft.php.

References $post_subject.

Referenced by saveDraft(), and updateDraft().

155  : string
156  {
157  return $this->post_subject;
158  }
+ Here is the caller graph for this function:

◆ getPostUpdate()

ilForumPostDraft::getPostUpdate ( )

Definition at line 185 of file class.ilForumPostDraft.php.

References $post_update.

185  : string
186  {
187  return $this->post_update;
188  }

◆ getPostUserAlias()

ilForumPostDraft::getPostUserAlias ( )

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

References $post_user_alias.

Referenced by ilObjForumGUI\createThread(), saveDraft(), and updateDraft().

205  : string
206  {
207  return $this->post_user_alias;
208  }
+ Here is the caller graph for this function:

◆ getRCID()

ilForumPostDraft::getRCID ( )

Definition at line 85 of file class.ilForumPostDraft.php.

References $rcid.

Referenced by ilObjForumGUI\createThread(), and updateDraft().

85  : string
86  {
87  return $this->rcid;
88  }
+ Here is the caller graph for this function:

◆ getSortedDrafts()

static ilForumPostDraft::getSortedDrafts ( int  $usrId,
int  $threadId,
int  $sorting = ilForumProperties::VIEW_DATE_ASC 
)
static
Returns
ilForumPostDraft[]|array<int, ilForumPostDraft[]>

Definition at line 274 of file class.ilForumPostDraft.php.

References $DIC, $ilDB, $res, ilForumProperties\VIEW_DATE_DESC, and ilForumProperties\VIEW_TREE.

Referenced by ilObjForumGUI\viewThreadObject().

278  : array {
279  global $DIC;
280  $ilDB = $DIC->database();
281 
282  $drafts = [];
283 
284  $orderColumn = ' ';
285  $orderDirection = ' ';
286 
287  if ($sorting !== ilForumProperties::VIEW_TREE) {
288  $orderColumn = ' ORDER BY post_date ';
289  $orderDirection = 'ASC';
290  if ($sorting === ilForumProperties::VIEW_DATE_DESC) {
291  $orderDirection = 'DESC';
292  }
293  }
294 
295  $res = $ilDB->queryF(
296  'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s AND thread_id = %s' .
297  $orderColumn . $orderDirection,
298  ['integer', 'integer'],
299  [$usrId, $threadId]
300  );
301 
302  while ($row = $ilDB->fetchAssoc($res)) {
303  $draft = new ilForumPostDraft();
304  self::populateWithDatabaseRecord($draft, $row);
305  $drafts[] = $draft;
306  self::$instances[$usrId][$threadId][$draft->getPostId()][] = $draft;
307  }
308 
309  if (ilForumProperties::VIEW_TREE === $sorting) {
310  return self::$instances[$usrId][$threadId] ?? [];
311  }
312 
313  return $drafts;
314  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ getThreadDraftData()

static ilForumPostDraft::getThreadDraftData ( int  $post_author_id,
int  $forum_id 
)
static

Definition at line 591 of file class.ilForumPostDraft.php.

References $DIC, $ilDB, and $res.

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

591  : array
592  {
593  global $DIC;
594  $ilDB = $DIC->database();
595 
596  $res = $ilDB->queryF(
597  'SELECT * FROM frm_posts_drafts
598  WHERE post_author_id = %s
599  AND forum_id = %s
600  AND thread_id = %s
601  AND post_id = %s
602  ORDER BY post_date DESC',
603  ['integer', 'integer', 'integer', 'integer'],
604  [$post_author_id, $forum_id, 0, 0]
605  );
606  $draft_data = [];
607  while ($row = $ilDB->fetchAssoc($res)) {
608  $tmp_obj = new self();
609  self::populateWithDatabaseRecord($tmp_obj, $row);
610  $draft_data[] = ['subject' => $tmp_obj->getPostSubject(),
611  'post_update' => $tmp_obj->getPostUpdate(),
612  'draft_id' => $tmp_obj->getDraftId()
613  ];
614  }
615  return $draft_data;
616  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ getThreadId()

ilForumPostDraft::getThreadId ( )

Definition at line 145 of file class.ilForumPostDraft.php.

References $thread_id.

Referenced by saveDraft().

145  : int
146  {
147  return $this->thread_id;
148  }
+ Here is the caller graph for this function:

◆ getUpdateUserId()

ilForumPostDraft::getUpdateUserId ( )

Definition at line 195 of file class.ilForumPostDraft.php.

References $update_user_id.

Referenced by updateDraft().

195  : int
196  {
197  return $this->update_user_id;
198  }
+ Here is the caller graph for this function:

◆ isAutoSavePostDraftAllowed()

static ilForumPostDraft::isAutoSavePostDraftAllowed ( )
static

Definition at line 521 of file class.ilForumPostDraft.php.

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

Referenced by ilForumThreadFormGUI\addAutosaveInfo(), ilObjForumGUI\decorateWithAutosave(), ilObjForumGUI\doHistoryCheck(), ilForumAutoSaveAsyncDraftAction\executeAndGetResponseObject(), and ilObjForumGUI\initReplyEditForm().

521  : bool
522  {
523  if (!self::isSavePostDraftAllowed()) {
524  return false;
525  }
526 
527  if (!isset(self::$drafts_settings_cache['autosave_drafts'])) {
528  global $DIC;
529 
530  self::$drafts_settings_cache['autosave_drafts'] = (bool) $DIC->settings()->get('autosave_drafts', '0');
531  self::$drafts_settings_cache['autosave_drafts_ival'] = (int) $DIC->settings()->get(
532  'autosave_drafts_ival',
533  '30'
534  );
535  }
536 
537  return self::$drafts_settings_cache['autosave_drafts'];
538  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isNotificationEnabled()

ilForumPostDraft::isNotificationEnabled ( )

Definition at line 105 of file class.ilForumPostDraft.php.

References $notify.

Referenced by ilObjForumGUI\createThread(), and saveDraft().

105  : bool
106  {
107  return $this->notify;
108  }
+ Here is the caller graph for this function:

◆ isPostNotificationEnabled()

ilForumPostDraft::isPostNotificationEnabled ( )

Definition at line 95 of file class.ilForumPostDraft.php.

References $post_notify.

Referenced by ilObjForumGUI\createThread(), and saveDraft().

95  : bool
96  {
97  return $this->post_notify;
98  }
+ Here is the caller graph for this function:

◆ isSavePostDraftAllowed()

static ilForumPostDraft::isSavePostDraftAllowed ( )
static

◆ lookupAutosaveInterval()

static ilForumPostDraft::lookupAutosaveInterval ( )
static

Definition at line 540 of file class.ilForumPostDraft.php.

Referenced by ilForumThreadFormGUI\addAutosaveInfo(), ilObjForumGUI\decorateWithAutosave(), and ilObjForumGUI\initReplyEditForm().

540  : int
541  {
542  if (self::isAutoSavePostDraftAllowed()) {
543  return (int) self::$drafts_settings_cache['autosave_drafts_ival'];
544  }
545  return 0;
546  }
+ Here is the caller graph for this function:

◆ moveDraftsByMergedThreads()

static ilForumPostDraft::moveDraftsByMergedThreads ( int  $source_thread_id,
int  $target_thread_id 
)
static

Definition at line 579 of file class.ilForumPostDraft.php.

References $DIC, and $ilDB.

579  : void
580  {
581  global $DIC;
582  $ilDB = $DIC->database();
583 
584  $ilDB->update(
585  'frm_posts_drafts',
586  ['thread_id' => ['integer', $target_thread_id]],
587  ['thread_id' => ['integer', $source_thread_id]]
588  );
589  }
global $DIC
Definition: shib_login.php:22

◆ newInstanceByDraftId()

static ilForumPostDraft::newInstanceByDraftId ( int  $draft_id)
static

Definition at line 328 of file class.ilForumPostDraft.php.

References $DIC, $ilDB, and $res.

Referenced by ilForumThreadFormGUI\addFileUploadInput(), ilObjForumGUI\addThreadObject(), ilObjForumGUI\cancelDraftObject(), ilObjForumGUI\cancelPostObject(), ilObjMediaObjectAccess\checkAccessMob(), ilMobStakeholder\checkAccessMobUsage(), ilObjForumGUI\checkDraftAccess(), ilObjForumGUI\deliverDraftZipFileObject(), ilObjForumGUI\editThreadDraftObject(), ilForumAutoSaveAsyncDraftAction\executeAndGetResponseObject(), ilFileDataForumDraftsRCImplementation\getDraftById(), ilObjMediaObject\getParentObjectIdForUsage(), ilObjForumGUI\hasDraftAccess(), ilObjForumGUI\publishThreadDraftObject(), ilForumDraftsHistory\rollbackAutosave(), ilObjForumGUI\saveAsDraftObject(), ilObjForumGUI\saveThreadAsDraftObject(), and ilObjForumGUI\updateThreadDraftObject().

329  {
330  global $DIC;
331  $ilDB = $DIC->database();
332 
333  $res = $ilDB->queryF(
334  'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
335  ['integer'],
336  [$draft_id]
337  );
338 
339  $tmp_obj = new ilForumPostDraft();
340  while ($row = $ilDB->fetchAssoc($res)) {
341  self::populateWithDatabaseRecord($tmp_obj, $row);
342  }
343  return $tmp_obj;
344  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ populateWithDatabaseRecord()

static ilForumPostDraft::populateWithDatabaseRecord ( ilForumPostDraft  $draft,
array  $row 
)
staticprivate

Definition at line 66 of file class.ilForumPostDraft.php.

References setDraftId(), setForumId(), setNotificationStatus(), setPostAuthorId(), setPostDate(), setPostDisplayUserId(), setPostId(), setPostMessage(), setPostNotificationStatus(), setPostSubject(), setPostUpdate(), setPostUserAlias(), setRCID(), setThreadId(), and setUpdateUserId().

66  : void
67  {
68  $draft->setDraftId((int) $row['draft_id']);
69  $draft->setForumId((int) $row['forum_id']);
70  $draft->setThreadId((int) $row['thread_id']);
71  $draft->setPostId((int) $row['post_id']);
72  $draft->setPostAuthorId((int) $row['post_author_id']);
73  $draft->setPostDisplayUserId((int) $row['pos_display_usr_id']);
74  $draft->setUpdateUserId((int) $row['update_user_id']);
75  $draft->setPostSubject((string) $row['post_subject']);
76  $draft->setPostMessage((string) $row['post_message']);
77  $draft->setPostDate((string) $row['post_date']);
78  $draft->setPostUpdate((string) $row['post_update']);
79  $draft->setPostUserAlias((string) $row['post_user_alias']);
80  $draft->setNotificationStatus((bool) $row['notify']);
81  $draft->setPostNotificationStatus((bool) $row['post_notify']);
82  $draft->setRCID((string) ($row['rcid']));
83  }
setThreadId(int $thread_id)
setPostMessage(string $post_message)
setPostSubject(string $post_subject)
setPostUpdate(string $post_update)
setPostDisplayUserId(int $post_display_user_id)
setUpdateUserId(int $update_user_id)
setNotificationStatus(bool $notify)
setPostUserAlias(string $post_user_alias)
setPostDate(string $post_date)
setPostNotificationStatus(bool $post_notify)
setPostAuthorId(int $post_author_id)
+ Here is the call graph for this function:

◆ readDraft()

ilForumPostDraft::readDraft ( )
protected

Definition at line 235 of file class.ilForumPostDraft.php.

References $res, getDraftId(), and getPostAuthorId().

Referenced by __construct().

235  : void
236  {
237  $res = $this->db->queryF(
238  'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s AND draft_id = %s',
239  ['integer', 'integer'],
240  [$this->getPostAuthorId(), $this->getDraftId()]
241  );
242 
243  if ($row = $this->db->fetchAssoc($res)) {
244  self::populateWithDatabaseRecord($this, $row);
245  }
246  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readDrafts()

static ilForumPostDraft::readDrafts ( int  $user_id)
staticprotected

Definition at line 248 of file class.ilForumPostDraft.php.

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

248  : void
249  {
250  global $DIC;
251  $ilDB = $DIC->database();
252 
253  $res = $ilDB->queryF(
254  'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s',
255  ['integer'],
256  [$user_id]
257  );
258 
259  self::$instances[$user_id] = [
260  'draft_ids' => [],
261  ];
262 
263  while ($row = $ilDB->fetchAssoc($res)) {
264  $draft = new ilForumPostDraft();
265  self::populateWithDatabaseRecord($draft, $row);
266  self::$instances[$user_id][$row['thread_id']][$draft->getPostId()][] = $draft;
267  self::$instances[$user_id]['draft_ids'][$draft->getDraftId()] = $draft;
268  }
269  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22

◆ saveDraft()

ilForumPostDraft::saveDraft ( )

Definition at line 346 of file class.ilForumPostDraft.php.

References $draft_id, getForumId(), getPostAuthorId(), getPostDisplayUserId(), getPostId(), getPostMessage(), getPostSubject(), getPostUserAlias(), getThreadId(), isNotificationEnabled(), isPostNotificationEnabled(), and setDraftId().

346  : int
347  {
348  $draft_id = $this->db->nextId('frm_posts_drafts');
349  $post_date = date("Y-m-d H:i:s");
350 
351  $this->db->insert('frm_posts_drafts', [
352  'draft_id' => ['integer', $draft_id],
353  'post_id' => ['integer', $this->getPostId()],
354  'thread_id' => ['integer', $this->getThreadId()],
355  'forum_id' => ['integer', $this->getForumId()],
356  'post_author_id' => ['integer', $this->getPostAuthorId()],
357  'post_subject' => ['text', $this->getPostSubject()],
358  'post_message' => ['clob', $this->getPostMessage()],
359  'notify' => ['integer', (int) $this->isNotificationEnabled()],
360  'post_notify' => ['integer', (int) $this->isPostNotificationEnabled()],
361  'post_date' => ['timestamp', $post_date],
362  'post_update' => ['timestamp', $post_date],
363  'post_user_alias' => ['text', $this->getPostUserAlias()],
364  'pos_display_usr_id' => ['integer', $this->getPostDisplayUserId()]
365  ]);
366  $this->setDraftId($draft_id);
367  return $draft_id;
368  }
+ Here is the call graph for this function:

◆ setDraftId()

ilForumPostDraft::setDraftId ( int  $draft_id)

Definition at line 120 of file class.ilForumPostDraft.php.

References $draft_id.

Referenced by __construct(), populateWithDatabaseRecord(), and saveDraft().

120  : void
121  {
122  $this->draft_id = $draft_id;
123  }
+ Here is the caller graph for this function:

◆ setForumId()

ilForumPostDraft::setForumId ( int  $forum_id)

Definition at line 140 of file class.ilForumPostDraft.php.

References $forum_id.

Referenced by populateWithDatabaseRecord().

140  : void
141  {
142  $this->forum_id = $forum_id;
143  }
+ Here is the caller graph for this function:

◆ setNotificationStatus()

ilForumPostDraft::setNotificationStatus ( bool  $notify)

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

References $notify.

Referenced by populateWithDatabaseRecord().

110  : void
111  {
112  $this->notify = $notify;
113  }
+ Here is the caller graph for this function:

◆ setPostAuthorId()

ilForumPostDraft::setPostAuthorId ( int  $post_author_id)

Definition at line 220 of file class.ilForumPostDraft.php.

References $post_author_id.

Referenced by __construct(), and populateWithDatabaseRecord().

220  : void
221  {
222  $this->post_author_id = $post_author_id;
223  }
+ Here is the caller graph for this function:

◆ setPostDate()

ilForumPostDraft::setPostDate ( string  $post_date)

Definition at line 180 of file class.ilForumPostDraft.php.

References $post_date.

Referenced by populateWithDatabaseRecord().

180  : void
181  {
182  $this->post_date = $post_date;
183  }
+ Here is the caller graph for this function:

◆ setPostDisplayUserId()

ilForumPostDraft::setPostDisplayUserId ( int  $post_display_user_id)

Definition at line 230 of file class.ilForumPostDraft.php.

References $post_display_user_id.

Referenced by populateWithDatabaseRecord().

230  : void
231  {
232  $this->post_display_user_id = $post_display_user_id;
233  }
+ Here is the caller graph for this function:

◆ setPostId()

ilForumPostDraft::setPostId ( int  $post_id)

Definition at line 130 of file class.ilForumPostDraft.php.

References $post_id.

Referenced by __construct(), and populateWithDatabaseRecord().

130  : void
131  {
132  $this->post_id = $post_id;
133  }
+ Here is the caller graph for this function:

◆ setPostMessage()

ilForumPostDraft::setPostMessage ( string  $post_message)

Definition at line 170 of file class.ilForumPostDraft.php.

References $post_message.

Referenced by populateWithDatabaseRecord().

170  : void
171  {
172  $this->post_message = $post_message;
173  }
+ Here is the caller graph for this function:

◆ setPostNotificationStatus()

ilForumPostDraft::setPostNotificationStatus ( bool  $post_notify)

Definition at line 100 of file class.ilForumPostDraft.php.

References $post_notify.

Referenced by populateWithDatabaseRecord().

100  : void
101  {
102  $this->post_notify = $post_notify;
103  }
+ Here is the caller graph for this function:

◆ setPostSubject()

ilForumPostDraft::setPostSubject ( string  $post_subject)

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

References $post_subject.

Referenced by populateWithDatabaseRecord().

160  : void
161  {
162  $this->post_subject = $post_subject;
163  }
+ Here is the caller graph for this function:

◆ setPostUpdate()

ilForumPostDraft::setPostUpdate ( string  $post_update)

Definition at line 190 of file class.ilForumPostDraft.php.

References $post_update.

Referenced by populateWithDatabaseRecord().

190  : void
191  {
192  $this->post_update = $post_update;
193  }
+ Here is the caller graph for this function:

◆ setPostUserAlias()

ilForumPostDraft::setPostUserAlias ( string  $post_user_alias)

Definition at line 210 of file class.ilForumPostDraft.php.

References $post_user_alias.

Referenced by populateWithDatabaseRecord().

210  : void
211  {
212  $this->post_user_alias = $post_user_alias;
213  }
+ Here is the caller graph for this function:

◆ setRCID()

ilForumPostDraft::setRCID ( string  $rcid)

Definition at line 90 of file class.ilForumPostDraft.php.

References $rcid.

Referenced by populateWithDatabaseRecord().

90  : void
91  {
92  $this->rcid = $rcid;
93  }
+ Here is the caller graph for this function:

◆ setThreadId()

ilForumPostDraft::setThreadId ( int  $thread_id)

Definition at line 150 of file class.ilForumPostDraft.php.

References $thread_id.

Referenced by populateWithDatabaseRecord().

150  : void
151  {
152  $this->thread_id = $thread_id;
153  }
+ Here is the caller graph for this function:

◆ setUpdateUserId()

ilForumPostDraft::setUpdateUserId ( int  $update_user_id)

Definition at line 200 of file class.ilForumPostDraft.php.

References $update_user_id.

Referenced by populateWithDatabaseRecord().

200  : void
201  {
202  $this->update_user_id = $update_user_id;
203  }
+ Here is the caller graph for this function:

◆ update()

ilForumPostDraft::update ( )

Definition at line 370 of file class.ilForumPostDraft.php.

References updateDraft().

370  : void
371  {
372  $this->updateDraft();
373  }
+ Here is the call graph for this function:

◆ updateDraft()

ilForumPostDraft::updateDraft ( )

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

References getDraftId(), getPostMessage(), getPostSubject(), getPostUserAlias(), getRCID(), and getUpdateUserId().

Referenced by update().

375  : void
376  {
377  $this->db->update(
378  'frm_posts_drafts',
379  [
380  'post_subject' => ['text', $this->getPostSubject()],
381  'post_message' => ['clob', $this->getPostMessage()],
382  'post_user_alias' => ['text', $this->getPostUserAlias()],
383  'post_update' => ['timestamp', date("Y-m-d H:i:s")],
384  'update_user_id' => ['integer', $this->getUpdateUserId()],
385  'rcid' => ['text', $this->getRCID()]
386  ],
387  ['draft_id' => ['integer', $this->getDraftId()]]
388  );
389  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

readonly ilDBInterface ilForumPostDraft::$db
private

Definition at line 35 of file class.ilForumPostDraft.php.

◆ $draft_id

int ilForumPostDraft::$draft_id = 0
private

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

Referenced by createDraftBackup(), getDraftId(), saveDraft(), and setDraftId().

◆ $drafts_settings_cache

array ilForumPostDraft::$drafts_settings_cache = []
staticprivate

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

◆ $forum_id

int ilForumPostDraft::$forum_id = 0
private

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

Referenced by getForumId(), and setForumId().

◆ $forum_statistics_cache

array ilForumPostDraft::$forum_statistics_cache = []
staticprivate

Definition at line 31 of file class.ilForumPostDraft.php.

◆ $instances

array ilForumPostDraft::$instances = []
staticprivate

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

◆ $notify

bool ilForumPostDraft::$notify = false
private

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

Referenced by isNotificationEnabled(), and setNotificationStatus().

◆ $post_author_id

int ilForumPostDraft::$post_author_id = 0
private

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

Referenced by getPostAuthorId(), and setPostAuthorId().

◆ $post_date

string ilForumPostDraft::$post_date = '0000-00-00 00:00:00'
private

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

Referenced by getPostDate(), and setPostDate().

◆ $post_display_user_id

int ilForumPostDraft::$post_display_user_id = 0
private

Definition at line 47 of file class.ilForumPostDraft.php.

Referenced by getPostDisplayUserId(), and setPostDisplayUserId().

◆ $post_id

int ilForumPostDraft::$post_id = 0
private

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

Referenced by getPostId(), and setPostId().

◆ $post_message

string ilForumPostDraft::$post_message = ''
private

Definition at line 41 of file class.ilForumPostDraft.php.

Referenced by getPostMessage(), and setPostMessage().

◆ $post_notify

bool ilForumPostDraft::$post_notify = false
private

◆ $post_subject

string ilForumPostDraft::$post_subject = ''
private

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

Referenced by getPostSubject(), and setPostSubject().

◆ $post_update

string ilForumPostDraft::$post_update = '0000-00-00 00:00:00'
private

Definition at line 43 of file class.ilForumPostDraft.php.

Referenced by getPostUpdate(), and setPostUpdate().

◆ $post_user_alias

string ilForumPostDraft::$post_user_alias = ''
private

Definition at line 45 of file class.ilForumPostDraft.php.

Referenced by getPostUserAlias(), and setPostUserAlias().

◆ $rcid

string ilForumPostDraft::$rcid = ''
private

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

Referenced by getRCID(), and setRCID().

◆ $thread_id

int ilForumPostDraft::$thread_id = 0
private

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

Referenced by getThreadId(), and setThreadId().

◆ $update_user_id

int ilForumPostDraft::$update_user_id = 0
private

Definition at line 44 of file class.ilForumPostDraft.php.

Referenced by getUpdateUserId(), and setUpdateUserId().

◆ MEDIAOBJECT_TYPE

const ilForumPostDraft::MEDIAOBJECT_TYPE = 'frm~d:html'

◆ NO_RCID

const ilForumPostDraft::NO_RCID = '-'

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


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