ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables 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)
 
 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 ()
 
 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'
 

Protected Member Functions

 readDraft ()
 

Static Protected Member Functions

static populateWithDatabaseRecord (ilForumPostDraft $draft, array $row)
 
static readDrafts (int $user_id)
 

Private Attributes

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
 

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 50 of file class.ilForumPostDraft.php.

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

51  {
52  global $DIC;
53 
54  $this->db = $DIC->database();
55 
56  if ($user_id && $post_id && $draft_id) {
57  $this->setPostAuthorId($user_id);
58  $this->setPostId($post_id);
59  $this->setDraftId($draft_id);
60  $this->readDraft();
61  }
62  }
global $DIC
Definition: feed.php:28
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 596 of file class.ilForumPostDraft.php.

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

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

596  : void
597  {
598  global $DIC;
599  $ilDB = $DIC->database();
600 
601  $res = $ilDB->queryF(
602  'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
603  ['integer'],
604  [$draft_id]
605  );
606 
607  $tmp_obj = new self();
608  while ($row = $ilDB->fetchAssoc($res)) {
609  self::populateWithDatabaseRecord($tmp_obj, $row);
610  }
611 
612  $history_obj = new ilForumDraftsHistory();
613  $history_obj->deleteHistoryByDraftIds([$draft_id]);
614 
615  $history_obj->setDraftId($draft_id);
616  $history_obj->setPostSubject($tmp_obj->getPostSubject());
617  $history_obj->setPostMessage($tmp_obj->getPostMessage());
618  $history_obj->addDraftToHistory();
619 
621  $tmp_obj->getPostMessage(),
622  self::MEDIAOBJECT_TYPE,
623  $draft_id,
625  $history_obj->getHistoryId()
626  );
627  }
$res
Definition: ltiservices.php:69
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: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteDraft()

ilForumPostDraft::deleteDraft ( )

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

References getDraftId().

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

372  : void
373  {
374  $this->db->manipulateF(
375  'DELETE FROM frm_posts_drafts WHERE draft_id = %s',
376  ['integer'],
377  [$this->getDraftId()]
378  );
379  }
+ 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 432 of file class.ilForumPostDraft.php.

432  : void
433  {
434  foreach ($draft_ids as $draft_id) {
435  self::deleteMobsOfDraft($draft_id);
436 
437  $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
438  $objFileDataForumDrafts->delete();
439  }
440  $this->db->manipulate('DELETE FROM frm_drafts_history WHERE ' . $this->db->in(
441  'draft_id',
442  $draft_ids,
443  false,
444  'integer'
445  ));
446  $this->db->manipulate('DELETE FROM frm_posts_drafts WHERE ' . $this->db->in(
447  'draft_id',
448  $draft_ids,
449  false,
450  'integer'
451  ));
452  }
This class handles all operations on files for the drafts of a forum object.

◆ deleteDraftsByPostIds()

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

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

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

396  : void
397  {
398  $draft_ids = [];
399  $res = $this->db->query('SELECT draft_id FROM frm_posts_drafts WHERE ' . $this->db->in(
400  'post_id',
401  $post_ids,
402  false,
403  'integer'
404  ));
405  while ($row = $this->db->fetchAssoc($res)) {
406  $draft_ids[] = (int) $row['draft_id'];
407  }
408 
409  foreach ($draft_ids as $draft_id) {
410  self::deleteMobsOfDraft($draft_id);
411 
412  $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
413  $objFileDataForumDrafts->delete();
414  }
415  $this->db->manipulate('DELETE FROM frm_drafts_history WHERE ' . $this->db->in(
416  'draft_id',
417  $draft_ids,
418  false,
419  'integer'
420  ));
421  $this->db->manipulate('DELETE FROM frm_posts_drafts WHERE ' . $this->db->in(
422  'draft_id',
423  $draft_ids,
424  false,
425  'integer'
426  ));
427  }
$res
Definition: ltiservices.php:69
This class handles all operations on files for the drafts of a forum object.
+ Here is the call graph for this function:

◆ deleteDraftsByUserId()

static ilForumPostDraft::deleteDraftsByUserId ( int  $user_id)
static

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

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

454  : void
455  {
456  global $DIC;
457  $ilDB = $DIC->database();
458 
459  $res = $ilDB->queryF(
460  'SELECT draft_id FROM frm_posts_drafts WHERE post_author_id = %s',
461  ['integer'],
462  [$user_id]
463  );
464 
465  $draft_ids = [];
466  while ($row = $ilDB->fetchAssoc($res)) {
467  $draft_ids[] = (int) $row['draft_id'];
468  }
469 
470  foreach ($draft_ids as $draft_id) {
471  self::deleteMobsOfDraft($draft_id);
472 
473  $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
474  $objFileDataForumDrafts->delete();
475  }
476 
477  $ilDB->manipulate('DELETE FROM frm_drafts_history WHERE ' . $ilDB->in(
478  'draft_id',
479  $draft_ids,
480  false,
481  'integer'
482  ));
483  $ilDB->manipulateF(
484  'DELETE FROM frm_posts_drafts WHERE post_author_id = %s',
485  ['integer'],
486  [$user_id]
487  );
488  }
$res
Definition: ltiservices.php:69
This class handles all operations on files for the drafts of a forum object.
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ deleteMobsOfDraft()

static ilForumPostDraft::deleteMobsOfDraft ( int  $draft_id)
static

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

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

381  : void
382  {
383  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draft_id);
384  foreach ($oldMediaObjects as $oldMob) {
385  if (ilObjMediaObject::_exists($oldMob)) {
386  ilObjMediaObject::_removeUsage($oldMob, 'frm~d:html', $draft_id);
387  $mob_obj = new ilObjMediaObject($oldMob);
388  $mob_obj->delete();
389  }
390  }
391  }
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 102 of file class.ilForumPostDraft.php.

References $draft_id.

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

102  : int
103  {
104  return $this->draft_id;
105  }
+ Here is the caller graph for this function:

◆ getDraftInstancesByUserId()

static ilForumPostDraft::getDraftInstancesByUserId ( int  $user_id)
static
Returns
ilForumPostDraft[]

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

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

306  : array
307  {
308  if (!isset(self::$instances[$user_id])) {
309  self::readDrafts($user_id);
310  }
311 
312  return self::$instances[$user_id]['draft_ids'];
313  }
+ Here is the caller graph for this function:

◆ getDraftsStatisticsByRefId()

static ilForumPostDraft::getDraftsStatisticsByRefId ( int  $ref_id)
static

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

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

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

527  : array
528  {
529  global $DIC;
530  $ilDB = $DIC->database();
531  $ilUser = $DIC->user();
532 
533  if (!isset(self::$forum_statistics_cache[$ref_id][$ilUser->getId()])) {
535 
536  $res = $ilDB->queryF(
537  '
538  SELECT COUNT(draft_id) num_drafts, thread_id FROM frm_posts_drafts
539  WHERE forum_id = %s AND post_author_id = %s
540  GROUP BY thread_id',
541  ['integer', 'integer'],
542  [$forumId, $ilUser->getId()]
543  );
544 
545  $num_drafts_total = 0;
546 
547  while ($row = $ilDB->fetchAssoc($res)) {
548  $num_drafts_total += $row['num_drafts'];
549  self::$forum_statistics_cache[$ref_id][$ilUser->getId()][(int) $row['thread_id']] = (int) $row['num_drafts'];
550  }
551 
552  self::$forum_statistics_cache[$ref_id][$ilUser->getId()]['total'] = $num_drafts_total;
553  }
554  return self::$forum_statistics_cache[$ref_id][$ilUser->getId()];
555  }
$res
Definition: ltiservices.php:69
static lookupForumIdByRefId(int $ref_id)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getForumId()

ilForumPostDraft::getForumId ( )

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

References $forum_id.

Referenced by saveDraft().

122  : int
123  {
124  return $this->forum_id;
125  }
+ Here is the caller graph for this function:

◆ getPostAuthorId()

ilForumPostDraft::getPostAuthorId ( )

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

References $post_author_id.

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

202  : int
203  {
204  return $this->post_author_id;
205  }
+ Here is the caller graph for this function:

◆ getPostDate()

ilForumPostDraft::getPostDate ( )

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

References $post_date.

162  : string
163  {
164  return $this->post_date;
165  }

◆ getPostDisplayUserId()

ilForumPostDraft::getPostDisplayUserId ( )

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

References $post_display_user_id.

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

212  : int
213  {
215  }
+ Here is the caller graph for this function:

◆ getPostId()

ilForumPostDraft::getPostId ( )

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

References $post_id.

Referenced by saveDraft().

112  : int
113  {
114  return $this->post_id;
115  }
+ Here is the caller graph for this function:

◆ getPostMessage()

ilForumPostDraft::getPostMessage ( )

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

References $post_message.

Referenced by saveDraft(), and updateDraft().

152  : string
153  {
154  return $this->post_message;
155  }
+ Here is the caller graph for this function:

◆ getPostSubject()

ilForumPostDraft::getPostSubject ( )

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

References $post_subject.

Referenced by saveDraft(), and updateDraft().

142  : string
143  {
144  return $this->post_subject;
145  }
+ Here is the caller graph for this function:

◆ getPostUpdate()

ilForumPostDraft::getPostUpdate ( )

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

References $post_update.

172  : string
173  {
174  return $this->post_update;
175  }

◆ getPostUserAlias()

ilForumPostDraft::getPostUserAlias ( )

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

References $post_user_alias.

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

192  : string
193  {
194  return $this->post_user_alias;
195  }
+ 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 261 of file class.ilForumPostDraft.php.

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

Referenced by ilObjForumGUI\viewThreadObject().

265  : array {
266  global $DIC;
267  $ilDB = $DIC->database();
268 
269  $drafts = [];
270 
271  $orderColumn = ' ';
272  $orderDirection = ' ';
273 
274  if ($sorting !== ilForumProperties::VIEW_TREE) {
275  $orderColumn = ' ORDER BY post_date ';
276  $orderDirection = 'ASC';
277  if ($sorting === ilForumProperties::VIEW_DATE_DESC) {
278  $orderDirection = 'DESC';
279  }
280  }
281 
282  $res = $ilDB->queryF(
283  'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s AND thread_id = %s' .
284  $orderColumn . $orderDirection,
285  ['integer', 'integer'],
286  [$usrId, $threadId]
287  );
288 
289  while ($row = $ilDB->fetchAssoc($res)) {
290  $draft = new ilForumPostDraft();
291  self::populateWithDatabaseRecord($draft, $row);
292  $drafts[] = $draft;
293  self::$instances[$usrId][$threadId][$draft->getPostId()][] = $draft;
294  }
295 
296  if (ilForumProperties::VIEW_TREE === $sorting) {
297  return self::$instances[$usrId][$threadId] ?? [];
298  }
299 
300  return $drafts;
301  }
Class ilForumPostDraft.
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getThreadDraftData()

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

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

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\getContent().

569  : array
570  {
571  global $DIC;
572  $ilDB = $DIC->database();
573 
574  $res = $ilDB->queryF(
575  'SELECT * FROM frm_posts_drafts
576  WHERE post_author_id = %s
577  AND forum_id = %s
578  AND thread_id = %s
579  AND post_id = %s
580  ORDER BY post_date DESC',
581  ['integer', 'integer', 'integer', 'integer'],
582  [$post_author_id, $forum_id, 0, 0]
583  );
584  $draft_data = [];
585  while ($row = $ilDB->fetchAssoc($res)) {
586  $tmp_obj = new self();
587  self::populateWithDatabaseRecord($tmp_obj, $row);
588  $draft_data[] = ['subject' => $tmp_obj->getPostSubject(),
589  'post_update' => $tmp_obj->getPostUpdate(),
590  'draft_id' => $tmp_obj->getDraftId()
591  ];
592  }
593  return $draft_data;
594  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getThreadId()

ilForumPostDraft::getThreadId ( )

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

References $thread_id.

Referenced by saveDraft().

132  : int
133  {
134  return $this->thread_id;
135  }
+ Here is the caller graph for this function:

◆ getUpdateUserId()

ilForumPostDraft::getUpdateUserId ( )

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

References $update_user_id.

Referenced by updateDraft().

182  : int
183  {
184  return $this->update_user_id;
185  }
+ Here is the caller graph for this function:

◆ isAutoSavePostDraftAllowed()

static ilForumPostDraft::isAutoSavePostDraftAllowed ( )
static

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

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

Referenced by ilObjForumGUI\cancelDraftObject(), ilObjForumGUI\decorateWithAutosave(), ilObjForumGUI\doHistoryCheck(), ilObjForumGUI\editDraftObject(), ilForumAutoSaveAsyncDraftAction\executeAndGetResponseObject(), ilObjForumGUI\initReplyEditForm(), ilObjForumGUI\saveAsDraftObject(), and ilObjForumGUI\savePostObject().

500  : bool
501  {
502  if (!self::isSavePostDraftAllowed()) {
503  return false;
504  }
505 
506  if (!isset(self::$drafts_settings_cache['autosave_drafts'])) {
507  global $DIC;
508 
509  self::$drafts_settings_cache['autosave_drafts'] = (bool) $DIC->settings()->get('autosave_drafts', '0');
510  self::$drafts_settings_cache['autosave_drafts_ival'] = (int) $DIC->settings()->get(
511  'autosave_drafts_ival',
512  '30'
513  );
514  }
515 
516  return self::$drafts_settings_cache['autosave_drafts'];
517  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isNotificationEnabled()

ilForumPostDraft::isNotificationEnabled ( )

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

References $notify.

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

92  : bool
93  {
94  return $this->notify;
95  }
+ Here is the caller graph for this function:

◆ isPostNotificationEnabled()

ilForumPostDraft::isPostNotificationEnabled ( )

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

References $post_notify.

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

82  : bool
83  {
84  return $this->post_notify;
85  }
+ Here is the caller graph for this function:

◆ isSavePostDraftAllowed()

static ilForumPostDraft::isSavePostDraftAllowed ( )
static

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

References $DIC.

Referenced by ilForumTopicTableGUI\__construct(), ilObjForumGUI\addEmptyThreadObject(), ilObjForumGUI\addThreadObject(), ilObjForumGUI\createTopLevelPostObject(), ilObjForumGUI\deleteSelectedDraft(), ilObjForumGUI\editThreadDraftObject(), ilForumThreadFormGUI\generateDefaultForm(), ilObjForumGUI\getContent(), ilObjForumListGUI\getProperties(), ilObjForumGUI\initReplyEditForm(), ilObjForumGUI\publishDraftObject(), ilObjForumGUI\publishThreadDraftObject(), ilObjForumGUI\saveAsDraftObject(), ilObjForumGUI\savePostObject(), ilObjForumGUI\saveThreadAsDraftObject(), ilObjForumGUI\updateDraftObject(), ilObjForumGUI\updateThreadDraftObject(), and ilObjForumGUI\viewThreadObject().

490  : bool
491  {
492  if (!isset(self::$drafts_settings_cache['save_post_drafts'])) {
493  global $DIC;
494  self::$drafts_settings_cache['save_post_drafts'] = (bool) $DIC->settings()->get('save_post_drafts', '0');
495  }
496 
497  return self::$drafts_settings_cache['save_post_drafts'];
498  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ lookupAutosaveInterval()

static ilForumPostDraft::lookupAutosaveInterval ( )
static

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

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

519  : int
520  {
521  if (self::isAutoSavePostDraftAllowed()) {
522  return (int) self::$drafts_settings_cache['autosave_drafts_ival'];
523  }
524  return 0;
525  }
+ Here is the caller graph for this function:

◆ moveDraftsByMergedThreads()

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

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

References $DIC, and $ilDB.

557  : void
558  {
559  global $DIC;
560  $ilDB = $DIC->database();
561 
562  $ilDB->update(
563  'frm_posts_drafts',
564  ['thread_id' => ['integer', $target_thread_id]],
565  ['thread_id' => ['integer', $source_thread_id]]
566  );
567  }
global $DIC
Definition: feed.php:28

◆ newInstanceByDraftId()

static ilForumPostDraft::newInstanceByDraftId ( int  $draft_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\addEmptyThreadObject(), ilForumThreadFormGUI\addFileUploadInput(), ilObjForumGUI\addThreadObject(), ilObjForumGUI\cancelDraftObject(), ilObjForumGUI\cancelPostObject(), ilObjMediaObjectAccess\checkAccessMob(), ilObjForumGUI\checkDraftAccess(), ilObjForumGUI\deliverDraftZipFileObject(), ilFileDataForumDrafts\deliverZipFile(), ilObjForumGUI\editThreadDraftObject(), ilForumAutoSaveAsyncDraftAction\executeAndGetResponseObject(), ilObjMediaObject\getParentObjectIdForUsage(), ilObjForumGUI\publishThreadDraftObject(), ilForumDraftsHistory\rollbackAutosave(), ilObjForumGUI\saveAsDraftObject(), ilObjForumGUI\saveThreadAsDraftObject(), and ilObjForumGUI\updateThreadDraftObject().

316  {
317  global $DIC;
318  $ilDB = $DIC->database();
319 
320  $res = $ilDB->queryF(
321  'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
322  ['integer'],
323  [$draft_id]
324  );
325 
326  $tmp_obj = new ilForumPostDraft();
327  while ($row = $ilDB->fetchAssoc($res)) {
328  self::populateWithDatabaseRecord($tmp_obj, $row);
329  }
330  return $tmp_obj;
331  }
Class ilForumPostDraft.
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ populateWithDatabaseRecord()

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

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

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

64  : void
65  {
66  $draft->setDraftId((int) $row['draft_id']);
67  $draft->setForumId((int) $row['forum_id']);
68  $draft->setThreadId((int) $row['thread_id']);
69  $draft->setPostId((int) $row['post_id']);
70  $draft->setPostAuthorId((int) $row['post_author_id']);
71  $draft->setPostDisplayUserId((int) $row['pos_display_usr_id']);
72  $draft->setUpdateUserId((int) $row['update_user_id']);
73  $draft->setPostSubject((string) $row['post_subject']);
74  $draft->setPostMessage((string) $row['post_message']);
75  $draft->setPostDate((string) $row['post_date']);
76  $draft->setPostUpdate((string) $row['post_update']);
77  $draft->setPostUserAlias((string) $row['post_user_alias']);
78  $draft->setNotificationStatus((bool) $row['notify']);
79  $draft->setPostNotificationStatus((bool) $row['post_notify']);
80  }
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 222 of file class.ilForumPostDraft.php.

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

Referenced by __construct().

222  : void
223  {
224  $res = $this->db->queryF(
225  'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s AND draft_id = %s',
226  ['integer', 'integer'],
227  [$this->getPostAuthorId(), $this->getDraftId()]
228  );
229 
230  if ($row = $this->db->fetchAssoc($res)) {
231  self::populateWithDatabaseRecord($this, $row);
232  }
233  }
$res
Definition: ltiservices.php:69
+ 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 235 of file class.ilForumPostDraft.php.

References $DIC, $ilDB, and $res.

235  : void
236  {
237  global $DIC;
238  $ilDB = $DIC->database();
239 
240  $res = $ilDB->queryF(
241  'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s',
242  ['integer'],
243  [$user_id]
244  );
245 
246  self::$instances[$user_id] = [
247  'draft_ids' => [],
248  ];
249 
250  while ($row = $ilDB->fetchAssoc($res)) {
251  $tmp_obj = new ilForumPostDraft();
252  self::populateWithDatabaseRecord($tmp_obj, $row);
253  self::$instances[$user_id][$row['thread_id']][$tmp_obj->getPostId()][] = $tmp_obj;
254  self::$instances[$user_id]['draft_ids'][$tmp_obj->getDraftId()] = $tmp_obj;
255  }
256  }
Class ilForumPostDraft.
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28

◆ saveDraft()

ilForumPostDraft::saveDraft ( )

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

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

333  : int
334  {
335  $draft_id = $this->db->nextId('frm_posts_drafts');
336  $post_date = date("Y-m-d H:i:s");
337 
338  $this->db->insert('frm_posts_drafts', [
339  'draft_id' => ['integer', $draft_id],
340  'post_id' => ['integer', $this->getPostId()],
341  'thread_id' => ['integer', $this->getThreadId()],
342  'forum_id' => ['integer', $this->getForumId()],
343  'post_author_id' => ['integer', $this->getPostAuthorId()],
344  'post_subject' => ['text', $this->getPostSubject()],
345  'post_message' => ['clob', $this->getPostMessage()],
346  'notify' => ['integer', (int) $this->isNotificationEnabled()],
347  'post_notify' => ['integer', (int) $this->isPostNotificationEnabled()],
348  'post_date' => ['timestamp', $post_date],
349  'post_update' => ['timestamp', $post_date],
350  'post_user_alias' => ['text', $this->getPostUserAlias()],
351  'pos_display_usr_id' => ['integer', $this->getPostDisplayUserId()]
352  ]);
353  $this->setDraftId($draft_id);
354  return $draft_id;
355  }
+ Here is the call graph for this function:

◆ setDraftId()

ilForumPostDraft::setDraftId ( int  $draft_id)

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

References $draft_id.

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

107  : void
108  {
109  $this->draft_id = $draft_id;
110  }
+ Here is the caller graph for this function:

◆ setForumId()

ilForumPostDraft::setForumId ( int  $forum_id)

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

References $forum_id.

Referenced by populateWithDatabaseRecord().

127  : void
128  {
129  $this->forum_id = $forum_id;
130  }
+ Here is the caller graph for this function:

◆ setNotificationStatus()

ilForumPostDraft::setNotificationStatus ( bool  $notify)

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

References $notify.

Referenced by populateWithDatabaseRecord().

97  : void
98  {
99  $this->notify = $notify;
100  }
+ Here is the caller graph for this function:

◆ setPostAuthorId()

ilForumPostDraft::setPostAuthorId ( int  $post_author_id)

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

References $post_author_id.

Referenced by __construct(), and populateWithDatabaseRecord().

207  : void
208  {
209  $this->post_author_id = $post_author_id;
210  }
+ Here is the caller graph for this function:

◆ setPostDate()

ilForumPostDraft::setPostDate ( string  $post_date)

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

References $post_date.

Referenced by populateWithDatabaseRecord().

167  : void
168  {
169  $this->post_date = $post_date;
170  }
+ Here is the caller graph for this function:

◆ setPostDisplayUserId()

ilForumPostDraft::setPostDisplayUserId ( int  $post_display_user_id)

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

References $post_display_user_id.

Referenced by populateWithDatabaseRecord().

217  : void
218  {
219  $this->post_display_user_id = $post_display_user_id;
220  }
+ Here is the caller graph for this function:

◆ setPostId()

ilForumPostDraft::setPostId ( int  $post_id)

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

References $post_id.

Referenced by __construct(), and populateWithDatabaseRecord().

117  : void
118  {
119  $this->post_id = $post_id;
120  }
+ Here is the caller graph for this function:

◆ setPostMessage()

ilForumPostDraft::setPostMessage ( string  $post_message)

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

References $post_message.

Referenced by populateWithDatabaseRecord().

157  : void
158  {
159  $this->post_message = $post_message;
160  }
+ Here is the caller graph for this function:

◆ setPostNotificationStatus()

ilForumPostDraft::setPostNotificationStatus ( bool  $post_notify)

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

References $post_notify.

Referenced by populateWithDatabaseRecord().

87  : void
88  {
89  $this->post_notify = $post_notify;
90  }
+ Here is the caller graph for this function:

◆ setPostSubject()

ilForumPostDraft::setPostSubject ( string  $post_subject)

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

References $post_subject.

Referenced by populateWithDatabaseRecord(), and ilObjForumGUI\updateDraftObject().

147  : void
148  {
149  $this->post_subject = $post_subject;
150  }
+ Here is the caller graph for this function:

◆ setPostUpdate()

ilForumPostDraft::setPostUpdate ( string  $post_update)

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

References $post_update.

Referenced by populateWithDatabaseRecord().

177  : void
178  {
179  $this->post_update = $post_update;
180  }
+ Here is the caller graph for this function:

◆ setPostUserAlias()

ilForumPostDraft::setPostUserAlias ( string  $post_user_alias)

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

References $post_user_alias.

Referenced by populateWithDatabaseRecord().

197  : void
198  {
199  $this->post_user_alias = $post_user_alias;
200  }
+ Here is the caller graph for this function:

◆ setThreadId()

ilForumPostDraft::setThreadId ( int  $thread_id)

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

References $thread_id.

Referenced by populateWithDatabaseRecord().

137  : void
138  {
139  $this->thread_id = $thread_id;
140  }
+ Here is the caller graph for this function:

◆ setUpdateUserId()

ilForumPostDraft::setUpdateUserId ( int  $update_user_id)

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

References $update_user_id.

Referenced by populateWithDatabaseRecord().

187  : void
188  {
189  $this->update_user_id = $update_user_id;
190  }
+ Here is the caller graph for this function:

◆ updateDraft()

ilForumPostDraft::updateDraft ( )

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

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

357  : void
358  {
359  $this->db->update(
360  'frm_posts_drafts',
361  [
362  'post_subject' => ['text', $this->getPostSubject()],
363  'post_message' => ['clob', $this->getPostMessage()],
364  'post_user_alias' => ['text', $this->getPostUserAlias()],
365  'post_update' => ['timestamp', date("Y-m-d H:i:s")],
366  'update_user_id' => ['integer', $this->getUpdateUserId()],
367  ],
368  ['draft_id' => ['integer', $this->getDraftId()]]
369  );
370  }
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilForumPostDraft::$db
private

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

◆ $draft_id

int ilForumPostDraft::$draft_id = 0
private

Definition at line 35 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 37 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 47 of file class.ilForumPostDraft.php.

Referenced by isNotificationEnabled(), and setNotificationStatus().

◆ $post_author_id

int ilForumPostDraft::$post_author_id = 0
private

Definition at line 45 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 41 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 46 of file class.ilForumPostDraft.php.

Referenced by getPostDisplayUserId(), and setPostDisplayUserId().

◆ $post_id

int ilForumPostDraft::$post_id = 0
private

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

Referenced by getPostId(), and setPostId().

◆ $post_message

string ilForumPostDraft::$post_message = ''
private

Definition at line 40 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 39 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 42 of file class.ilForumPostDraft.php.

Referenced by getPostUpdate(), and setPostUpdate().

◆ $post_user_alias

string ilForumPostDraft::$post_user_alias = ''
private

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

Referenced by getPostUserAlias(), and setPostUserAlias().

◆ $thread_id

int ilForumPostDraft::$thread_id = 0
private

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

Referenced by getThreadId(), and setThreadId().

◆ $update_user_id

int ilForumPostDraft::$update_user_id = 0
private

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

Referenced by getUpdateUserId(), and setUpdateUserId().

◆ MEDIAOBJECT_TYPE

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

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