ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

53 {
54 global $DIC;
55
56 $this->db = $DIC->database();
57
58 if ($user_id && $post_id && $draft_id) {
60 $this->setPostId($post_id);
61 $this->setDraftId($draft_id);
62 $this->readDraft();
63 }
64 }
setPostAuthorId(int $post_author_id)
global $DIC
Definition: shib_login.php:26

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

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

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 }
Class ilForumDraftHistory.
static populateWithDatabaseRecord(ilForumPostDraft $draft, array $row)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
$res
Definition: ltiservices.php:69

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

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

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

391 : void
392 {
393 $this->db->manipulateF(
394 'DELETE FROM frm_posts_drafts WHERE draft_id = %s',
395 ['integer'],
396 [$this->getDraftId()]
397 );
398 }

Referenced by ilObjForumGUI\createThread().

+ 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) {
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 }
static deleteMobsOfDraft(int $draft_id)

◆ deleteDraftsByPostIds()

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

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

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) {
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 }

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

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

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) {
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 }

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

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

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)
checks if an object exists in object_data
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.

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

+ Here is the call graph for this function:

◆ getDraftId()

ilForumPostDraft::getDraftId ( )

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

115 : int
116 {
117 return $this->draft_id;
118 }

References $draft_id.

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

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

319 : array
320 {
321 if (!isset(self::$instances[$user_id])) {
323 }
324
325 return self::$instances[$user_id]['draft_ids'];
326 }
static readDrafts(int $user_id)

References $user_id.

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

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

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 }
static lookupForumIdByRefId(int $ref_id)
$ref_id
Definition: ltiauth.php:66

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

Referenced by ilObjForumListGUI\getProperties().

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

135 : int
136 {
137 return $this->forum_id;
138 }

References $forum_id.

◆ getPostAuthorId()

ilForumPostDraft::getPostAuthorId ( )

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

215 : int
216 {
218 }

References $post_author_id.

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

+ Here is the caller graph for this function:

◆ getPostDate()

ilForumPostDraft::getPostDate ( )

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

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

References $post_date.

◆ getPostDisplayUserId()

ilForumPostDraft::getPostDisplayUserId ( )

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

225 : int
226 {
228 }

References $post_display_user_id.

Referenced by ilObjForumGUI\createThread().

+ Here is the caller graph for this function:

◆ getPostId()

ilForumPostDraft::getPostId ( )

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

125 : int
126 {
127 return $this->post_id;
128 }

References $post_id.

◆ getPostMessage()

ilForumPostDraft::getPostMessage ( )

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

165 : string
166 {
167 return $this->post_message;
168 }

References $post_message.

◆ getPostSubject()

ilForumPostDraft::getPostSubject ( )

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

155 : string
156 {
157 return $this->post_subject;
158 }

References $post_subject.

◆ getPostUpdate()

ilForumPostDraft::getPostUpdate ( )

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

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

References $post_update.

◆ getPostUserAlias()

ilForumPostDraft::getPostUserAlias ( )

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

205 : string
206 {
208 }

References $post_user_alias.

Referenced by ilObjForumGUI\createThread().

+ Here is the caller graph for this function:

◆ getRCID()

ilForumPostDraft::getRCID ( )

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

85 : string
86 {
87 return $this->rcid;
88 }

References $rcid.

Referenced by ilObjForumGUI\createThread().

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

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();
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 }
Class ilForumPostDraft.

References ilForumProperties\VIEW_DATE_DESC.

Referenced by ilObjForumGUI\viewThreadObject().

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

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'],
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 }

References $DIC, $ilDB, and $res.

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

+ Here is the caller graph for this function:

◆ getThreadId()

ilForumPostDraft::getThreadId ( )

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

145 : int
146 {
147 return $this->thread_id;
148 }

References $thread_id.

◆ getUpdateUserId()

ilForumPostDraft::getUpdateUserId ( )

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

195 : int
196 {
198 }

References $update_user_id.

◆ isAutoSavePostDraftAllowed()

static ilForumPostDraft::isAutoSavePostDraftAllowed ( )
static

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

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 }

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

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

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

105 : bool
106 {
107 return $this->notify;
108 }

References $notify.

Referenced by ilObjForumGUI\createThread().

+ Here is the caller graph for this function:

◆ isPostNotificationEnabled()

ilForumPostDraft::isPostNotificationEnabled ( )

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

95 : bool
96 {
97 return $this->post_notify;
98 }

References $post_notify.

Referenced by ilObjForumGUI\createThread().

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

540 : int
541 {
542 if (self::isAutoSavePostDraftAllowed()) {
543 return (int) self::$drafts_settings_cache['autosave_drafts_ival'];
544 }
545 return 0;
546 }

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

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

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 }

References $DIC, and $ilDB.

◆ newInstanceByDraftId()

◆ populateWithDatabaseRecord()

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

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

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 }
setUpdateUserId(int $update_user_id)
setThreadId(int $thread_id)
setPostDisplayUserId(int $post_display_user_id)
setNotificationStatus(bool $notify)
setPostMessage(string $post_message)
setPostUserAlias(string $post_user_alias)
setPostUpdate(string $post_update)
setPostNotificationStatus(bool $post_notify)
setPostDate(string $post_date)
setPostSubject(string $post_subject)

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

Referenced by readDraft(), and readDrafts().

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

◆ readDraft()

ilForumPostDraft::readDraft ( )
protected

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

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)) {
245 }
246 }

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

Referenced by __construct().

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

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();
266 self::$instances[$user_id][$row['thread_id']][$draft->getPostId()][] = $draft;
267 self::$instances[$user_id]['draft_ids'][$draft->getDraftId()] = $draft;
268 }
269 }

References $DIC, $ilDB, $res, $user_id, and populateWithDatabaseRecord().

+ Here is the call graph for this function:

◆ saveDraft()

ilForumPostDraft::saveDraft ( )

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

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 }

◆ setDraftId()

ilForumPostDraft::setDraftId ( int  $draft_id)

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

120 : void
121 {
122 $this->draft_id = $draft_id;
123 }

References $draft_id.

Referenced by __construct(), and populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setForumId()

ilForumPostDraft::setForumId ( int  $forum_id)

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

140 : void
141 {
142 $this->forum_id = $forum_id;
143 }

References $forum_id.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setNotificationStatus()

ilForumPostDraft::setNotificationStatus ( bool  $notify)

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

110 : void
111 {
112 $this->notify = $notify;
113 }

References $notify.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostAuthorId()

ilForumPostDraft::setPostAuthorId ( int  $post_author_id)

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

220 : void
221 {
222 $this->post_author_id = $post_author_id;
223 }

References $post_author_id.

Referenced by __construct(), and populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostDate()

ilForumPostDraft::setPostDate ( string  $post_date)

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

180 : void
181 {
182 $this->post_date = $post_date;
183 }

References $post_date.

Referenced by populateWithDatabaseRecord().

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

230 : void
231 {
232 $this->post_display_user_id = $post_display_user_id;
233 }

References $post_display_user_id.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostId()

ilForumPostDraft::setPostId ( int  $post_id)

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

130 : void
131 {
132 $this->post_id = $post_id;
133 }

References $post_id.

Referenced by __construct(), and populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostMessage()

ilForumPostDraft::setPostMessage ( string  $post_message)

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

170 : void
171 {
172 $this->post_message = $post_message;
173 }

References $post_message.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostNotificationStatus()

ilForumPostDraft::setPostNotificationStatus ( bool  $post_notify)

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

100 : void
101 {
102 $this->post_notify = $post_notify;
103 }

References $post_notify.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostSubject()

ilForumPostDraft::setPostSubject ( string  $post_subject)

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

160 : void
161 {
162 $this->post_subject = $post_subject;
163 }

References $post_subject.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostUpdate()

ilForumPostDraft::setPostUpdate ( string  $post_update)

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

190 : void
191 {
192 $this->post_update = $post_update;
193 }

References $post_update.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostUserAlias()

ilForumPostDraft::setPostUserAlias ( string  $post_user_alias)

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

210 : void
211 {
212 $this->post_user_alias = $post_user_alias;
213 }

References $post_user_alias.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setRCID()

ilForumPostDraft::setRCID ( string  $rcid)

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

90 : void
91 {
92 $this->rcid = $rcid;
93 }

References $rcid.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setThreadId()

ilForumPostDraft::setThreadId ( int  $thread_id)

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

150 : void
151 {
152 $this->thread_id = $thread_id;
153 }

References $thread_id.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setUpdateUserId()

ilForumPostDraft::setUpdateUserId ( int  $update_user_id)

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

200 : void
201 {
202 $this->update_user_id = $update_user_id;
203 }

References $update_user_id.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ update()

ilForumPostDraft::update ( )

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

370 : void
371 {
372 $this->updateDraft();
373 }

◆ updateDraft()

ilForumPostDraft::updateDraft ( )

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

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 }

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 __construct(), getDraftId(), 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 __construct(), 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: