ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilForumPostDraft Class Reference

Class ilForumPostDraft. More...

+ Collaboration diagram for ilForumPostDraft:

Public Member Functions

 getPostNotify ()
 
 setPostNotify ($post_notify)
 
 getDraftId ()
 
 setDraftId ($draft_id)
 
 getPostId ()
 
 setPostId ($post_id)
 
 getForumId ()
 
 setForumId ($forum_id)
 
 getThreadId ()
 
 setThreadId ($thread_id)
 
 getPostSubject ()
 
 setPostSubject ($post_subject)
 
 getPostMessage ()
 
 setPostMessage ($post_message)
 
 getPostDate ()
 
 setPostDate ($post_date)
 
 getPostUpdate ()
 
 setPostUpdate ($post_update)
 
 getUpdateUserId ()
 
 setUpdateUserId ($update_user_id)
 
 getPostUserAlias ()
 
 setPostUserAlias ($post_user_alias)
 
 getPostAuthorId ()
 
 setPostAuthorId ($post_author_id)
 
 getPostDisplayUserId ()
 
 setPostDisplayUserId ($post_display_user_id)
 
 getNotify ()
 
 setNotify ($notify)
 
 __construct ($user_id=0, $post_id=0, $draft_id=0)
 ilForumPostDraft constructor. More...
 
 saveDraft ()
 
 updateDraft ()
 
 deleteDraft ()
 
 deleteDraftsByPostIds (array $post_ids=array())
 
 deleteDraftsByDraftIds (array $draft_ids=array())
 

Static Public Member Functions

static getDraftInstancesByUserId ($user_id)
 
static getInstancesByUserIdAndThreadId ($user_id, $thread_id)
 
static newInstanceByDraftId ($draft_id)
 
static newInstanceByHistorytId ($history_id)
 
static deleteMobsOfDraft ($draft_id)
 
static deleteDraftsByUserId ($user_id)
 
static isSavePostDraftAllowed ()
 
static isAutoSavePostDraftAllowed ()
 
static lookupAutosaveInterval ()
 
static getDraftsStatisticsByRefId ($ref_id)
 
static moveDraftsByMergedThreads ($source_thread_id, $target_thread_id)
 
static moveDraftsByMovedThread ($thread_ids, $source_ref_id, $target_ref_id)
 
static getThreadDraftData ($post_author_id, $forum_id)
 
static createDraftBackup ($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 ($user_id)
 

Protected Attributes

 $draft_id = 0
 
 $post_id = 0
 
 $forum_id = 0
 
 $thread_id = 0
 
 $post_subject = ''
 
 $post_message = ''
 
 $post_date = '0000-00-00 00:00:00'
 
 $post_update = '0000-00-00 00:00:00'
 
 $update_user_id = 0
 
 $post_user_alias = ''
 
 $post_author_id = 0
 
 $post_display_user_id = 0
 
 $notify = 0
 
 $post_notify = 0
 

Static Protected Attributes

static $forum_statistics_cache = array()
 
static $drafts_settings_cache = array()
 

Static Private Attributes

static $instances = array()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilForumPostDraft constructor.

Parameters
int$user_id
int$post_id

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

333 {
334 global $DIC;
335
336 $this->db = $DIC->database();
337
338 if ($user_id && $post_id && $draft_id) {
339 $this->setPostAuthorId($user_id);
340 $this->setPostId($post_id);
341 $this->setDraftId($draft_id);
342 $this->readDraft();
343 }
344 }
setPostAuthorId($post_author_id)
global $DIC
Definition: saml.php:7

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

+ Here is the call graph for this function:

Member Function Documentation

◆ createDraftBackup()

static ilForumPostDraft::createDraftBackup (   $draft_id)
static
Parameters
$draft_id

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

745 {
746 global $DIC;
747 $ilDB = $DIC->database();
748
749 $res = $ilDB->queryF(
750 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
751 array('integer'),
752 array((int) $draft_id)
753 );
754
755 while ($row = $ilDB->fetchAssoc($res)) {
756 $tmp_obj = new self;
758 }
759
760 $history_obj = new ilForumDraftsHistory();
761 $history_obj->deleteHistoryByDraftIds(array($draft_id));
762
763 $history_obj->setDraftId($draft_id);
764 $history_obj->setPostSubject($tmp_obj->getPostSubject());
765 $history_obj->setPostMessage($tmp_obj->getPostMessage());
766 $history_obj->addDraftToHistory();
767
769 $tmp_obj->getPostMessage(),
770 self::MEDIAOBJECT_TYPE,
771 $draft_id,
773 $history_obj->getHistoryId()
774 );
775 }
Class ilForumDraftHistory.
static populateWithDatabaseRecord(ilForumPostDraft $draft, array $row)
static moveMediaObjects($post_message, $source_type, $source_id, $target_type, $target_id, $direction=0)
$row
foreach($_POST as $key=> $value) $res
global $ilDB

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

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

503 {
504 $this->db->manipulateF(
505 'DELETE FROM frm_posts_drafts WHERE draft_id = %s',
506 array('integer'),
507 array($this->getDraftId())
508 );
509 }

References getDraftId().

Referenced by ilObjForumGUI\createThread().

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

◆ deleteDraftsByDraftIds()

ilForumPostDraft::deleteDraftsByDraftIds ( array  $draft_ids = array())
Parameters
array$draft_ids

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

553 {
554 foreach ($draft_ids as $draft_id) {
556
557 // delete attachments of draft
558 $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
559 $objFileDataForumDrafts->delete();
560 }
561 $this->db->manipulate('DELETE FROM frm_drafts_history WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
562 $this->db->manipulate('DELETE FROM frm_posts_drafts WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
563 }
This class handles all operations on files for the drafts of a forum object.
static deleteMobsOfDraft($draft_id)

References $draft_id, and deleteMobsOfDraft().

+ Here is the call graph for this function:

◆ deleteDraftsByPostIds()

ilForumPostDraft::deleteDraftsByPostIds ( array  $post_ids = array())
Parameters
array$post_ids

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

531 {
532 $draft_ids = array();
533 $res = $this->db->query('SELECT draft_id FROM frm_posts_drafts WHERE ' . $this->db->in('post_id', $post_ids, false, 'integer'));
534 while ($row = $this->db->fetchAssoc($res)) {
535 $draft_ids[] = $row['draft_id'];
536 }
537
538 foreach ($draft_ids as $draft_id) {
540
541 // delete attachments of draft
542 $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
543 $objFileDataForumDrafts->delete();
544 }
545 $this->db->manipulate('DELETE FROM frm_drafts_history WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
546 $this->db->manipulate('DELETE FROM frm_posts_drafts WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
547 }

References $draft_id, $res, $row, and deleteMobsOfDraft().

+ Here is the call graph for this function:

◆ deleteDraftsByUserId()

static ilForumPostDraft::deleteDraftsByUserId (   $user_id)
static
Parameters
int$user_id

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

569 {
570 global $DIC;
571 $ilDB = $DIC->database();
572
573 $res = $ilDB->queryF(
574 'SELECT draft_id FROM frm_posts_drafts WHERE post_author_id = %s',
575 array('integer'),
576 array($user_id)
577 );
578
579 $draft_ids = array();
580 while ($row = $ilDB->fetchAssoc($res)) {
581 $draft_ids[] = $row['draft_id'];
582 }
583
584 foreach ($draft_ids as $draft_id) {
586
587 // delete attachments of draft
588 $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
589 $objFileDataForumDrafts->delete();
590 }
591
592 $ilDB->manipulate('DELETE FROM frm_drafts_history WHERE ' . $ilDB->in('draft_id', $draft_ids, false, 'integer'));
593 $ilDB->manipulateF(
594 'DELETE FROM frm_posts_drafts WHERE post_author_id = %s',
595 array('integer'),
596 array($user_id)
597 );
598 }

References $DIC, $draft_id, $ilDB, $res, $row, and deleteMobsOfDraft().

+ Here is the call graph for this function:

◆ deleteMobsOfDraft()

static ilForumPostDraft::deleteMobsOfDraft (   $draft_id)
static
Parameters
$draft_id

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

515 {
516 // delete mobs of draft
517 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draft_id);
518 foreach ($oldMediaObjects as $oldMob) {
519 if (ilObjMediaObject::_exists($oldMob)) {
520 ilObjMediaObject::_removeUsage($oldMob, 'frm~d:html', $draft_id);
521 $mob_obj = new ilObjMediaObject($oldMob);
522 $mob_obj->delete();
523 }
524 }
525 }
Class ilObjMediaObject.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
static _exists($a_id, $a_reference=false, $a_type=null)
checks wether a lm content object with specified id exists or not

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

Referenced by deleteDraftsByDraftIds(), deleteDraftsByPostIds(), and deleteDraftsByUserId().

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

◆ getDraftId()

ilForumPostDraft::getDraftId ( )
Returns
int

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

123 {
124 return $this->draft_id;
125 }

References $draft_id.

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

+ Here is the caller graph for this function:

◆ getDraftInstancesByUserId()

static ilForumPostDraft::getDraftInstancesByUserId (   $user_id)
static
Parameters
int$user_id
Returns
mixed

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

391 {
392 if (!self::$instances[$user_id]) {
393 self::readDrafts($user_id);
394 }
395
396 return self::$instances[$user_id]['draft_ids'];
397 }
static readDrafts($user_id)

References readDrafts().

Referenced by ilObjForumGUI\confirmDeleteThreadDraftsObject(), ilObjForumGUI\deleteThreadDraftsObject(), and ilForumPostingDraftsBlockGUI\fillDataSection().

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

◆ getDraftsStatisticsByRefId()

static ilForumPostDraft::getDraftsStatisticsByRefId (   $ref_id)
static
Parameters
$ref_id
Returns
mixed

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

643 {
644 global $DIC;
645 $ilDB = $DIC->database();
646 $ilUser = $DIC->user();
647
648 if (!isset(self::$forum_statistics_cache[$ref_id][$ilUser->getId()])) {
649 $forumId = ilObjForum::lookupForumIdByRefId($ref_id);
650
651 $res = $ilDB->queryF(
652 '
653 SELECT COUNT(draft_id) num_drafts, thread_id FROM frm_posts_drafts
654 WHERE forum_id = %s AND post_author_id = %s
655 GROUP BY thread_id',
656 array('integer', 'integer'),
657 array($forumId, $ilUser->getId())
658 );
659
660 $num_drafts_total = 0;
661
662 while ($row = $ilDB->fetchAssoc($res)) {
663 $num_drafts_total += $row['num_drafts'];
664 self::$forum_statistics_cache[$ref_id][$ilUser->getId()][$row['thread_id']] = $row['num_drafts'];
665 }
666
667 self::$forum_statistics_cache[$ref_id][$ilUser->getId()]['total'] = $num_drafts_total;
668 }
669 return self::$forum_statistics_cache[$ref_id][$ilUser->getId()];
670 }
static lookupForumIdByRefId($ref_id)
$ilUser
Definition: imgupload.php:18

References $DIC, $ilDB, $ilUser, $res, $row, and ilObjForum\lookupForumIdByRefId().

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

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

◆ getForumId()

ilForumPostDraft::getForumId ( )
Returns
int

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

155 {
156 return $this->forum_id;
157 }

References $forum_id.

Referenced by saveDraft().

+ Here is the caller graph for this function:

◆ getInstancesByUserIdAndThreadId()

static ilForumPostDraft::getInstancesByUserIdAndThreadId (   $user_id,
  $thread_id 
)
static
Parameters
$user_id
$thread_id
Returns
\ilForumPostDraft[]

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

404 : array
405 {
406 if (!self::$instances[$user_id]) {
407 self::readDrafts($user_id);
408 }
409
410 if (isset(self::$instances[$user_id][$thread_id])) {
411 return self::$instances[$user_id][$thread_id];
412 }
413
414 return [];
415 }

References $thread_id, and readDrafts().

Referenced by ilObjForumGUI\renderDraftContent(), and ilObjForumGUI\renderSplitButton().

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

◆ getNotify()

ilForumPostDraft::getNotify ( )
Returns
int

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

315 {
316 return $this->notify;
317 }

References $notify.

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

+ Here is the caller graph for this function:

◆ getPostAuthorId()

ilForumPostDraft::getPostAuthorId ( )
Returns
int

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

References $post_author_id.

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

+ Here is the caller graph for this function:

◆ getPostDate()

ilForumPostDraft::getPostDate ( )
Returns
string

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

219 {
220 return $this->post_date;
221 }

References $post_date.

◆ getPostDisplayUserId()

ilForumPostDraft::getPostDisplayUserId ( )
Returns
int

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

References $post_display_user_id.

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

+ Here is the caller graph for this function:

◆ getPostId()

ilForumPostDraft::getPostId ( )
Returns
int

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

139 {
140 return $this->post_id;
141 }

References $post_id.

Referenced by readDraft(), and saveDraft().

+ Here is the caller graph for this function:

◆ getPostMessage()

ilForumPostDraft::getPostMessage ( )
Returns
string

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

203 {
204 return $this->post_message;
205 }

References $post_message.

Referenced by saveDraft(), and updateDraft().

+ Here is the caller graph for this function:

◆ getPostNotify()

ilForumPostDraft::getPostNotify ( )
Returns
int

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

107 {
108 return $this->post_notify;
109 }

References $post_notify.

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

+ Here is the caller graph for this function:

◆ getPostSubject()

ilForumPostDraft::getPostSubject ( )
Returns
string

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

187 {
188 return $this->post_subject;
189 }

References $post_subject.

Referenced by saveDraft(), and updateDraft().

+ Here is the caller graph for this function:

◆ getPostUpdate()

ilForumPostDraft::getPostUpdate ( )
Returns
string

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

235 {
236 return $this->post_update;
237 }

References $post_update.

◆ getPostUserAlias()

ilForumPostDraft::getPostUserAlias ( )
Returns
string

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

References $post_user_alias.

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

+ Here is the caller graph for this function:

◆ getThreadDraftData()

static ilForumPostDraft::getThreadDraftData (   $post_author_id,
  $forum_id 
)
static
Parameters
$post_author_id
$forum_id
Returns
array

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

718 {
719 global $DIC;
720 $ilDB = $DIC->database();
721
722 $res = $ilDB->queryF(
723 'SELECT * FROM frm_posts_drafts
724 WHERE post_author_id = %s
725 AND forum_id = %s
726 AND thread_id = %s
727 AND post_id = %s
728 ORDER BY post_date DESC',
729 array('integer', 'integer', 'integer', 'integer'),
730 array($post_author_id, $forum_id, 0, 0)
731 );
732 $draft_data = array();
733 while ($row = $ilDB->fetchAssoc($res)) {
734 $tmp_obj = new self;
736 $draft_data[] = array('subject' => $tmp_obj->getPostSubject(), 'post_update' => $tmp_obj->getPostUpdate(), 'draft_id' => $tmp_obj->getDraftId());
737 }
738 return $draft_data;
739 }

References $DIC, $forum_id, $ilDB, $post_author_id, $res, $row, and populateWithDatabaseRecord().

Referenced by ilObjForumGUI\getContent().

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

◆ getThreadId()

ilForumPostDraft::getThreadId ( )
Returns
int

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

171 {
172 return $this->thread_id;
173 }

References $thread_id.

Referenced by saveDraft().

+ Here is the caller graph for this function:

◆ getUpdateUserId()

ilForumPostDraft::getUpdateUserId ( )
Returns
int

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

References $update_user_id.

◆ isAutoSavePostDraftAllowed()

static ilForumPostDraft::isAutoSavePostDraftAllowed ( )
static
Returns
bool

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

616 {
617 if (!self::isSavePostDraftAllowed()) {
618 // feature is globally deactivated
619 return false;
620 }
621 if (!isset(self::$drafts_settings_cache['autosave_drafts'])) {
622 global $DIC;
623
624 self::$drafts_settings_cache['autosave_drafts'] = (bool) $DIC->settings()->get('autosave_drafts', false);
625 self::$drafts_settings_cache['autosave_drafts_ival'] = (int) $DIC->settings()->get('autosave_drafts_ival', 30);
626 }
627 return self::$drafts_settings_cache['autosave_drafts'];
628 }

References $DIC.

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

+ Here is the caller graph for this function:

◆ isSavePostDraftAllowed()

static ilForumPostDraft::isSavePostDraftAllowed ( )
static
Returns
bool

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

604 {
605 if (!isset(self::$drafts_settings_cache['save_post_drafts'])) {
606 global $DIC;
607 self::$drafts_settings_cache['save_post_drafts'] = (bool) $DIC->settings()->get('save_post_drafts', false);
608 }
609 return self::$drafts_settings_cache['save_post_drafts'];
610 }

References $DIC.

Referenced by ilForumTopicTableGUI\__construct(), ilObjForumGUI\addThreadObject(), ilObjForumGUI\createTopLevelPostObject(), ilObjForumGUI\deleteSelectedDraft(), ilObjForumGUI\editThreadDraftObject(), ilObjForumGUI\getContent(), ilObjForumListGUI\getProperties(), ilForumThreadFormGUI\initForm(), ilObjForumGUI\publishDraftObject(), ilObjForumGUI\publishThreadDraftObject(), ilObjForumGUI\saveThreadAsDraftObject(), and ilObjForumGUI\updateThreadDraftObject().

+ Here is the caller graph for this function:

◆ lookupAutosaveInterval()

static ilForumPostDraft::lookupAutosaveInterval ( )
static

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

631 {
632 if (self::isAutoSavePostDraftAllowed()) {
633 return self::$drafts_settings_cache['autosave_drafts_ival'];
634 }
635 return 0;
636 }

Referenced by ilObjForumGUI\decorateWithAutosave().

+ Here is the caller graph for this function:

◆ moveDraftsByMergedThreads()

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

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

677 {
678 global $DIC;
679 $ilDB = $DIC->database();
680
681 $ilDB->update(
682 'frm_posts_drafts',
683 array('thread_id' => array('integer', $target_thread_id)),
684 array('thread_id' => array('integer', $source_thread_id))
685 );
686 }

References $DIC, and $ilDB.

◆ moveDraftsByMovedThread()

static ilForumPostDraft::moveDraftsByMovedThread (   $thread_ids,
  $source_ref_id,
  $target_ref_id 
)
static
Parameters
array$thread_ids
int$source_ref_id
int$target_ref_id

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

694 {
695 global $DIC;
696 $ilDB = $DIC->database();
697
698 $source_forum_id = ilObjForum::lookupForumIdByRefId($source_ref_id);
699 $target_forum_id = ilObjForum::lookupForumIdByRefId($target_ref_id);
700
701 $ilDB->manipulateF(
702 '
703 UPDATE frm_posts_drafts
704 SET forum_id = %s
705 WHERE forum_id = %s
706 AND ' . $ilDB->in('thread_id', $thread_ids, false, 'integer'),
707 array('integer', 'integer'),
708 array($target_forum_id, $source_forum_id)
709 );
710 }

References $DIC, $ilDB, and ilObjForum\lookupForumIdByRefId().

+ Here is the call graph for this function:

◆ newInstanceByDraftId()

static ilForumPostDraft::newInstanceByDraftId (   $draft_id)
static
Parameters
$draft_id
Returns
self

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

422 {
423 global $DIC;
424 $ilDB = $DIC->database();
425
426 $res = $ilDB->queryF(
427 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
428 array('integer'),
429 array($draft_id)
430 );
431
432 $tmp_obj = new ilForumPostDraft();
433 while ($row = $ilDB->fetchAssoc($res)) {
435 }
436 return $tmp_obj;
437 }
Class ilForumPostDraft.

References $DIC, $draft_id, $ilDB, $res, $row, and populateWithDatabaseRecord().

Referenced by ilObjForumGUI\addThreadObject(), ilObjForumGUI\cancelDraftObject(), ilObjForumGUI\cancelPostObject(), ilObjForumGUI\checkDraftAccess(), ilObjForumGUI\deliverDraftZipFileObject(), ilFileDataForumDrafts\deliverZipFile(), ilForumAutoSaveAsyncDraftAction\executeAndGetResponseObject(), ilObjMediaObject\getParentObjectIdForUsage(), ilForumThreadFormGUI\initForm(), ilObjForumGUI\publishThreadDraftObject(), ilForumDraftsHistory\rollbackAutosave(), ilObjForumGUI\saveThreadAsDraftObject(), and ilObjForumGUI\updateThreadDraftObject().

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

◆ newInstanceByHistorytId()

static ilForumPostDraft::newInstanceByHistorytId (   $history_id)
static
Parameters
$history_id
Returns
ilForumPostDraft
Exceptions
ilException

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

445 {
446 global $DIC;
447 $ilDB = $DIC->database();
448
449 $res = $ilDB->queryF(
450 'SELECT * FROM frm_drafts_history WHERE history_id = %s',
451 array('integer'),
452 array($history_id)
453 );
454
455 while ($row = $ilDB->fetchAssoc($res)) {
456 $tmp_obj = new ilForumPostDraft();
458 return $tmp_obj;
459 }
460
461 throw new ilException(sprintf("Could not find history object for id %s", $history_id));
462 }
Base class for ILIAS Exception handling.

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

+ Here is the call graph for this function:

◆ populateWithDatabaseRecord()

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

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

86 {
87 $draft->setDraftId($row['draft_id']);
88 $draft->setForumId($row['forum_id']);
89 $draft->setPostAuthorId($row['post_author_id']);
90 $draft->setPostDate($row['post_date']);
91 $draft->setPostDisplayUserId($row['pos_display_usr_id']);
92 $draft->setPostId($row['post_id']);
93 $draft->setPostMessage($row['post_message']);
94 $draft->setPostSubject($row['post_subject']);
95 $draft->setPostUpdate($row['post_update']);
96 $draft->setPostUserAlias($row['post_user_alias']);
97 $draft->setThreadId($row['thread_id']);
98 $draft->setUpdateUserId($row['update_user_id']);
99 $draft->setNotify($row['notify']);
100 $draft->setPostNotify($row['post_notify']);
101 }
setPostUserAlias($post_user_alias)
setPostMessage($post_message)
setPostSubject($post_subject)
setPostDisplayUserId($post_display_user_id)
setUpdateUserId($update_user_id)

References $row, setDraftId(), setForumId(), setNotify(), setPostAuthorId(), setPostDate(), setPostDisplayUserId(), setPostId(), setPostMessage(), setPostNotify(), setPostSubject(), setPostUpdate(), setPostUserAlias(), setThreadId(), and setUpdateUserId().

Referenced by createDraftBackup(), getThreadDraftData(), newInstanceByDraftId(), newInstanceByHistorytId(), 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 349 of file class.ilForumPostDraft.php.

350 {
351 $res = $this->db->queryF(
352 'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s AND post_id = %s AND draft_id = %s',
353 array('integer', 'integer','integer'),
354 array($this->getPostAuthorId(), $this->getPostId(), $this->getDraftId())
355 );
356
357 while ($row = $this->db->fetchAssoc($res)) {
359 }
360 }

References $res, $row, getDraftId(), getPostAuthorId(), getPostId(), 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 (   $user_id)
staticprotected
Parameters
int$user_id

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

366 {
367 global $DIC;
368 $ilDB = $DIC->database();
369
370 $res = $ilDB->queryF(
371 'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s',
372 array('integer'),
373 array($user_id)
374 );
375
376 self::$instances[$user_id] = array();
377 while ($row = $ilDB->fetchAssoc($res)) {
378 $tmp_obj = new ilForumPostDraft();
380 self::$instances[$user_id][$row['thread_id']][$tmp_obj->getPostId()][] = $tmp_obj;
381 self::$instances[$user_id]['draft_ids'][$tmp_obj->getDraftId()] = $tmp_obj;
382 }
383 unset($tmp_obj);
384 }

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

Referenced by getDraftInstancesByUserId(), and getInstancesByUserIdAndThreadId().

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

◆ saveDraft()

ilForumPostDraft::saveDraft ( )

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

465 {
466 $draft_id = $this->db->nextId('frm_posts_drafts');
467 $post_date = date("Y-m-d H:i:s");
468
469 $this->db->insert('frm_posts_drafts', array(
470 'draft_id' => array('integer', $draft_id),
471 'post_id' => array('integer', $this->getPostId()),
472 'thread_id' => array('integer', $this->getThreadId()),
473 'forum_id' => array('integer', $this->getForumId()),
474 'post_author_id' => array('integer', $this->getPostAuthorId()),
475 'post_subject' => array('text', $this->getPostSubject()),
476 'post_message' => array('clob', $this->getPostMessage()),
477 'notify' => array('integer', $this->getNotify()),
478 'post_notify' => array('integer', $this->getPostNotify()),
479 'post_date' => array('timestamp', $post_date),
480 'post_update' => array('timestamp', $post_date),
481// 'update_user_id' => array('integer', $this->getUpdateUserId()),
482 'post_user_alias' => array('text', $this->getPostUserAlias()),
483 'pos_display_usr_id' => array('integer', $this->getPostDisplayUserId())
484 ));
485 $this->setDraftId($draft_id);
486 return $draft_id;
487 }

References $draft_id, $post_date, getForumId(), getNotify(), getPostAuthorId(), getPostDisplayUserId(), getPostId(), getPostMessage(), getPostNotify(), getPostSubject(), getPostUserAlias(), getThreadId(), and setDraftId().

+ Here is the call graph for this function:

◆ setDraftId()

ilForumPostDraft::setDraftId (   $draft_id)
Parameters
int$draft_id

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

131 {
132 $this->draft_id = $draft_id;
133 }

References $draft_id.

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

+ Here is the caller graph for this function:

◆ setForumId()

ilForumPostDraft::setForumId (   $forum_id)
Parameters
int$forum_id

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

163 {
164 $this->forum_id = $forum_id;
165 }

References $forum_id.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setNotify()

ilForumPostDraft::setNotify (   $notify)
Parameters
int$notify

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

323 {
324 $this->notify = $notify;
325 }

References $notify.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostAuthorId()

ilForumPostDraft::setPostAuthorId (   $post_author_id)
Parameters
int$post_author_id

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

291 {
292 $this->post_author_id = $post_author_id;
293 }

References $post_author_id.

Referenced by __construct(), and populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostDate()

ilForumPostDraft::setPostDate (   $post_date)
Parameters
string$post_date

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

227 {
228 $this->post_date = $post_date;
229 }

References $post_date.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostDisplayUserId()

ilForumPostDraft::setPostDisplayUserId (   $post_display_user_id)
Parameters
int$post_display_user_id

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

307 {
308 $this->post_display_user_id = $post_display_user_id;
309 }

References $post_display_user_id.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostId()

ilForumPostDraft::setPostId (   $post_id)
Parameters
int$post_id

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

147 {
148 $this->post_id = $post_id;
149 }

References $post_id.

Referenced by __construct(), and populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostMessage()

ilForumPostDraft::setPostMessage (   $post_message)
Parameters
string$post_message

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

211 {
212 $this->post_message = $post_message;
213 }

References $post_message.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostNotify()

ilForumPostDraft::setPostNotify (   $post_notify)
Parameters
int$post_notify

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

115 {
116 $this->post_notify = $post_notify;
117 }

References $post_notify.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostSubject()

ilForumPostDraft::setPostSubject (   $post_subject)
Parameters
string$post_subject

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

195 {
196 $this->post_subject = $post_subject;
197 }

References $post_subject.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostUpdate()

ilForumPostDraft::setPostUpdate (   $post_update)
Parameters
string$post_update

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

243 {
244 $this->post_update = $post_update;
245 }

References $post_update.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setPostUserAlias()

ilForumPostDraft::setPostUserAlias (   $post_user_alias)
Parameters
string$post_user_alias

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

275 {
276 $this->post_user_alias = $post_user_alias;
277 }

References $post_user_alias.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setThreadId()

ilForumPostDraft::setThreadId (   $thread_id)
Parameters
int$thread_id

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

179 {
180 $this->thread_id = $thread_id;
181 }

References $thread_id.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setUpdateUserId()

ilForumPostDraft::setUpdateUserId (   $update_user_id)
Parameters
int$update_user_id

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

259 {
260 $this->update_user_id = $update_user_id;
261 }

References $update_user_id.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ updateDraft()

ilForumPostDraft::updateDraft ( )

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

490 {
491 $this->db->update(
492 'frm_posts_drafts',
493 array(
494 'post_subject' => array('text', $this->getPostSubject()),
495 'post_message' => array('clob', $this->getPostMessage()),
496 'post_user_alias' => array('text', $this->getPostUserAlias())
497 ),
498 array('draft_id' => array('integer', $this->getDraftId()))
499 );
500 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $draft_id

◆ $drafts_settings_cache

ilForumPostDraft::$drafts_settings_cache = array()
staticprotected

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

◆ $forum_id

ilForumPostDraft::$forum_id = 0
protected

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

Referenced by getForumId(), getThreadDraftData(), and setForumId().

◆ $forum_statistics_cache

ilForumPostDraft::$forum_statistics_cache = array()
staticprotected

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

◆ $instances

ilForumPostDraft::$instances = array()
staticprivate

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

◆ $notify

ilForumPostDraft::$notify = 0
protected

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

Referenced by getNotify(), and setNotify().

◆ $post_author_id

ilForumPostDraft::$post_author_id = 0
protected

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

Referenced by getPostAuthorId(), getThreadDraftData(), and setPostAuthorId().

◆ $post_date

ilForumPostDraft::$post_date = '0000-00-00 00:00:00'
protected

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

Referenced by getPostDate(), saveDraft(), and setPostDate().

◆ $post_display_user_id

ilForumPostDraft::$post_display_user_id = 0
protected

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

Referenced by getPostDisplayUserId(), and setPostDisplayUserId().

◆ $post_id

ilForumPostDraft::$post_id = 0
protected

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

Referenced by __construct(), getPostId(), and setPostId().

◆ $post_message

ilForumPostDraft::$post_message = ''
protected

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

Referenced by getPostMessage(), and setPostMessage().

◆ $post_notify

ilForumPostDraft::$post_notify = 0
protected

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

Referenced by getPostNotify(), and setPostNotify().

◆ $post_subject

ilForumPostDraft::$post_subject = ''
protected

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

Referenced by getPostSubject(), and setPostSubject().

◆ $post_update

ilForumPostDraft::$post_update = '0000-00-00 00:00:00'
protected

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

Referenced by getPostUpdate(), and setPostUpdate().

◆ $post_user_alias

ilForumPostDraft::$post_user_alias = ''
protected

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

Referenced by getPostUserAlias(), and setPostUserAlias().

◆ $thread_id

ilForumPostDraft::$thread_id = 0
protected

◆ $update_user_id

ilForumPostDraft::$update_user_id = 0
protected

Definition at line 45 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: