ILIAS  release_7 Revision v7.30-3-g800a261c036
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 getSortedDrafts (int $usrId, int $threadId, int $sorting=ilForumProperties::VIEW_DATE_ASC)
 
static getDraftInstancesByUserId ($user_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 335 of file class.ilForumPostDraft.php.

336 {
337 global $DIC;
338
339 $this->db = $DIC->database();
340
341 if ($user_id && $post_id && $draft_id) {
342 $this->setPostAuthorId($user_id);
343 $this->setPostId($post_id);
344 $this->setDraftId($draft_id);
345 $this->readDraft();
346 }
347 }
setPostAuthorId($post_author_id)
global $DIC
Definition: goto.php:24

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

782 {
783 global $DIC;
784 $ilDB = $DIC->database();
785
786 $res = $ilDB->queryF(
787 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
788 array('integer'),
789 array((int) $draft_id)
790 );
791
792 while ($row = $ilDB->fetchAssoc($res)) {
793 $tmp_obj = new self;
794 self::populateWithDatabaseRecord($tmp_obj, $row);
795 }
796
797 $history_obj = new ilForumDraftsHistory();
798 $history_obj->deleteHistoryByDraftIds(array($draft_id));
799
800 $history_obj->setDraftId($draft_id);
801 $history_obj->setPostSubject($tmp_obj->getPostSubject());
802 $history_obj->setPostMessage($tmp_obj->getPostMessage());
803 $history_obj->addDraftToHistory();
804
806 $tmp_obj->getPostMessage(),
807 self::MEDIAOBJECT_TYPE,
808 $draft_id,
810 $history_obj->getHistoryId()
811 );
812 }
Class ilForumDraftHistory.
static populateWithDatabaseRecord(ilForumPostDraft $draft, array $row)
static moveMediaObjects($post_message, $source_type, $source_id, $target_type, $target_id, $direction=0)
foreach($_POST as $key=> $value) $res
global $ilDB

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

540 {
541 $this->db->manipulateF(
542 'DELETE FROM frm_posts_drafts WHERE draft_id = %s',
543 array('integer'),
544 array($this->getDraftId())
545 );
546 }

Referenced by ilObjForumGUI\createThread().

+ Here is the caller graph for this function:

◆ deleteDraftsByDraftIds()

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

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

590 {
591 foreach ($draft_ids as $draft_id) {
593
594 // delete attachments of draft
595 $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
596 $objFileDataForumDrafts->delete();
597 }
598 $this->db->manipulate('DELETE FROM frm_drafts_history WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
599 $this->db->manipulate('DELETE FROM frm_posts_drafts WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
600 }
This class handles all operations on files for the drafts of a forum object.
static deleteMobsOfDraft($draft_id)

◆ deleteDraftsByPostIds()

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

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

568 {
569 $draft_ids = array();
570 $res = $this->db->query('SELECT draft_id FROM frm_posts_drafts WHERE ' . $this->db->in('post_id', $post_ids, false, 'integer'));
571 while ($row = $this->db->fetchAssoc($res)) {
572 $draft_ids[] = $row['draft_id'];
573 }
574
575 foreach ($draft_ids as $draft_id) {
577
578 // delete attachments of draft
579 $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
580 $objFileDataForumDrafts->delete();
581 }
582 $this->db->manipulate('DELETE FROM frm_drafts_history WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
583 $this->db->manipulate('DELETE FROM frm_posts_drafts WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
584 }

References $res.

◆ deleteDraftsByUserId()

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

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

606 {
607 global $DIC;
608 $ilDB = $DIC->database();
609
610 $res = $ilDB->queryF(
611 'SELECT draft_id FROM frm_posts_drafts WHERE post_author_id = %s',
612 array('integer'),
613 array($user_id)
614 );
615
616 $draft_ids = array();
617 while ($row = $ilDB->fetchAssoc($res)) {
618 $draft_ids[] = $row['draft_id'];
619 }
620
621 foreach ($draft_ids as $draft_id) {
623
624 // delete attachments of draft
625 $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
626 $objFileDataForumDrafts->delete();
627 }
628
629 $ilDB->manipulate('DELETE FROM frm_drafts_history WHERE ' . $ilDB->in('draft_id', $draft_ids, false, 'integer'));
630 $ilDB->manipulateF(
631 'DELETE FROM frm_posts_drafts WHERE post_author_id = %s',
632 array('integer'),
633 array($user_id)
634 );
635 }

References $DIC, $ilDB, and $res.

◆ deleteMobsOfDraft()

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

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

552 {
553 // delete mobs of draft
554 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draft_id);
555 foreach ($oldMediaObjects as $oldMob) {
556 if (ilObjMediaObject::_exists($oldMob)) {
557 ilObjMediaObject::_removeUsage($oldMob, 'frm~d:html', $draft_id);
558 $mob_obj = new ilObjMediaObject($oldMob);
559 $mob_obj->delete();
560 }
561 }
562 }
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 ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), and ilObjMediaObject\_removeUsage().

+ Here is the call graph for this function:

◆ getDraftId()

ilForumPostDraft::getDraftId ( )
Returns
int

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

126 {
127 return $this->draft_id;
128 }

References $draft_id.

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

+ Here is the caller graph for this function:

◆ getDraftInstancesByUserId()

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

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

443 : array
444 {
445 if (!isset(self::$instances[$user_id])) {
446 self::readDrafts($user_id);
447 }
448
449 return self::$instances[$user_id]['draft_ids'];
450 }
static readDrafts($user_id)

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

+ Here is the caller graph for this function:

◆ getDraftsStatisticsByRefId()

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

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

680 {
681 global $DIC;
682 $ilDB = $DIC->database();
683 $ilUser = $DIC->user();
684
685 if (!isset(self::$forum_statistics_cache[$ref_id][$ilUser->getId()])) {
686 $forumId = ilObjForum::lookupForumIdByRefId($ref_id);
687
688 $res = $ilDB->queryF(
689 '
690 SELECT COUNT(draft_id) num_drafts, thread_id FROM frm_posts_drafts
691 WHERE forum_id = %s AND post_author_id = %s
692 GROUP BY thread_id',
693 array('integer', 'integer'),
694 array($forumId, $ilUser->getId())
695 );
696
697 $num_drafts_total = 0;
698
699 while ($row = $ilDB->fetchAssoc($res)) {
700 $num_drafts_total += $row['num_drafts'];
701 self::$forum_statistics_cache[$ref_id][$ilUser->getId()][$row['thread_id']] = $row['num_drafts'];
702 }
703
704 self::$forum_statistics_cache[$ref_id][$ilUser->getId()]['total'] = $num_drafts_total;
705 }
706 return self::$forum_statistics_cache[$ref_id][$ilUser->getId()];
707 }
static lookupForumIdByRefId($ref_id)
$ilUser
Definition: imgupload.php:18

References $DIC, $ilDB, $ilUser, $res, 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 157 of file class.ilForumPostDraft.php.

158 {
159 return $this->forum_id;
160 }

References $forum_id.

◆ getNotify()

ilForumPostDraft::getNotify ( )
Returns
int

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

318 {
319 return $this->notify;
320 }

References $notify.

Referenced by ilObjForumGUI\createThread().

+ Here is the caller graph for this function:

◆ getPostAuthorId()

ilForumPostDraft::getPostAuthorId ( )
Returns
int

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

References $post_author_id.

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

+ Here is the caller graph for this function:

◆ getPostDate()

ilForumPostDraft::getPostDate ( )
Returns
string

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

222 {
223 return $this->post_date;
224 }

References $post_date.

◆ getPostDisplayUserId()

ilForumPostDraft::getPostDisplayUserId ( )
Returns
int

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

References $post_display_user_id.

Referenced by ilObjForumGUI\createThread().

+ Here is the caller graph for this function:

◆ getPostId()

ilForumPostDraft::getPostId ( )
Returns
int

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

142 {
143 return $this->post_id;
144 }

References $post_id.

Referenced by readDraft().

+ Here is the caller graph for this function:

◆ getPostMessage()

ilForumPostDraft::getPostMessage ( )
Returns
string

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

206 {
207 return $this->post_message;
208 }

References $post_message.

◆ getPostNotify()

ilForumPostDraft::getPostNotify ( )
Returns
int

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

110 {
111 return $this->post_notify;
112 }

References $post_notify.

Referenced by ilObjForumGUI\createThread().

+ Here is the caller graph for this function:

◆ getPostSubject()

ilForumPostDraft::getPostSubject ( )
Returns
string

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

190 {
191 return $this->post_subject;
192 }

References $post_subject.

◆ getPostUpdate()

ilForumPostDraft::getPostUpdate ( )
Returns
string

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

238 {
239 return $this->post_update;
240 }

References $post_update.

◆ getPostUserAlias()

ilForumPostDraft::getPostUserAlias ( )
Returns
string

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

References $post_user_alias.

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
Parameters
int$usrId
int$threadId
int$sorting
Returns
ilForumPostDraft[]|array<int, ilForumPostDraft[]>

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

401 : array {
402 global $DIC;
403 $ilDB = $DIC->database();
404
405 $drafts = [];
406
407 $orderColumn = ' ';
408 $orderDirection = ' ';
409
410 if ($sorting !== ilForumProperties::VIEW_TREE) {
411 $orderColumn = ' ORDER BY post_date ';
412 $orderDirection = 'ASC';
413 if ($sorting === ilForumProperties::VIEW_DATE_DESC) {
414 $orderDirection = 'DESC';
415 }
416 }
417
418 $res = $ilDB->queryF(
419 'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s AND thread_id = %s' .
420 $orderColumn . $orderDirection,
421 ['integer', 'integer'],
422 [$usrId, $threadId]
423 );
424
425 while ($row = $ilDB->fetchAssoc($res)) {
426 $draft = new ilForumPostDraft();
428 $drafts[] = $draft;
429 self::$instances[$usrId][$threadId][$draft->getPostId()][] = $draft;
430 }
431
432 if (ilForumProperties::VIEW_TREE === $sorting) {
433 return self::$instances[$usrId][$threadId] ?? [];
434 }
435
436 return $drafts;
437 }
Class ilForumPostDraft.

References ilForumProperties\VIEW_DATE_DESC.

◆ getThreadDraftData()

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

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

755 {
756 global $DIC;
757 $ilDB = $DIC->database();
758
759 $res = $ilDB->queryF(
760 'SELECT * FROM frm_posts_drafts
761 WHERE post_author_id = %s
762 AND forum_id = %s
763 AND thread_id = %s
764 AND post_id = %s
765 ORDER BY post_date DESC',
766 array('integer', 'integer', 'integer', 'integer'),
767 array($post_author_id, $forum_id, 0, 0)
768 );
769 $draft_data = array();
770 while ($row = $ilDB->fetchAssoc($res)) {
771 $tmp_obj = new self;
772 self::populateWithDatabaseRecord($tmp_obj, $row);
773 $draft_data[] = array('subject' => $tmp_obj->getPostSubject(), 'post_update' => $tmp_obj->getPostUpdate(), 'draft_id' => $tmp_obj->getDraftId());
774 }
775 return $draft_data;
776 }

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\getContent().

+ Here is the caller graph for this function:

◆ getThreadId()

ilForumPostDraft::getThreadId ( )
Returns
int

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

174 {
175 return $this->thread_id;
176 }

References $thread_id.

◆ getUpdateUserId()

ilForumPostDraft::getUpdateUserId ( )
Returns
int

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

References $update_user_id.

◆ isAutoSavePostDraftAllowed()

static ilForumPostDraft::isAutoSavePostDraftAllowed ( )
static
Returns
bool

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

653 {
654 if (!self::isSavePostDraftAllowed()) {
655 // feature is globally deactivated
656 return false;
657 }
658 if (!isset(self::$drafts_settings_cache['autosave_drafts'])) {
659 global $DIC;
660
661 self::$drafts_settings_cache['autosave_drafts'] = (bool) $DIC->settings()->get('autosave_drafts', false);
662 self::$drafts_settings_cache['autosave_drafts_ival'] = (int) $DIC->settings()->get('autosave_drafts_ival', 30);
663 }
664 return self::$drafts_settings_cache['autosave_drafts'];
665 }

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

641 {
642 if (!isset(self::$drafts_settings_cache['save_post_drafts'])) {
643 global $DIC;
644 self::$drafts_settings_cache['save_post_drafts'] = (bool) $DIC->settings()->get('save_post_drafts', false);
645 }
646 return self::$drafts_settings_cache['save_post_drafts'];
647 }

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

668 {
669 if (self::isAutoSavePostDraftAllowed()) {
670 return self::$drafts_settings_cache['autosave_drafts_ival'];
671 }
672 return 0;
673 }

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

714 {
715 global $DIC;
716 $ilDB = $DIC->database();
717
718 $ilDB->update(
719 'frm_posts_drafts',
720 array('thread_id' => array('integer', $target_thread_id)),
721 array('thread_id' => array('integer', $source_thread_id))
722 );
723 }

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

731 {
732 global $DIC;
733 $ilDB = $DIC->database();
734
735 $source_forum_id = ilObjForum::lookupForumIdByRefId($source_ref_id);
736 $target_forum_id = ilObjForum::lookupForumIdByRefId($target_ref_id);
737
738 $ilDB->manipulateF(
739 '
740 UPDATE frm_posts_drafts
741 SET forum_id = %s
742 WHERE forum_id = %s
743 AND ' . $ilDB->in('thread_id', $thread_ids, false, 'integer'),
744 array('integer', 'integer'),
745 array($target_forum_id, $source_forum_id)
746 );
747 }

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

457 {
458 global $DIC;
459 $ilDB = $DIC->database();
460
461 $res = $ilDB->queryF(
462 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
463 array('integer'),
464 array($draft_id)
465 );
466
467 $tmp_obj = new ilForumPostDraft();
468 while ($row = $ilDB->fetchAssoc($res)) {
469 self::populateWithDatabaseRecord($tmp_obj, $row);
470 }
471 return $tmp_obj;
472 }

References $DIC, $ilDB, and $res.

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 caller graph for this function:

◆ newInstanceByHistorytId()

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

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

480 {
481 global $DIC;
482 $ilDB = $DIC->database();
483
484 $res = $ilDB->queryF(
485 'SELECT * FROM frm_drafts_history WHERE history_id = %s',
486 array('integer'),
487 array($history_id)
488 );
489
490 while ($row = $ilDB->fetchAssoc($res)) {
491 $tmp_obj = new ilForumPostDraft();
492 self::populateWithDatabaseRecord($tmp_obj, $row);
493 return $tmp_obj;
494 }
495
496 throw new ilException(sprintf("Could not find history object for id %s", $history_id));
497 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $DIC, $ilDB, and $res.

◆ populateWithDatabaseRecord()

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

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

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

References setDraftId(), setForumId(), setNotify(), setPostAuthorId(), setPostDate(), setPostDisplayUserId(), setPostId(), setPostMessage(), setPostNotify(), setPostSubject(), setPostUpdate(), setPostUserAlias(), 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 352 of file class.ilForumPostDraft.php.

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

References $res, 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 368 of file class.ilForumPostDraft.php.

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

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

+ Here is the call graph for this function:

◆ saveDraft()

ilForumPostDraft::saveDraft ( )

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

500 {
501 $draft_id = $this->db->nextId('frm_posts_drafts');
502 $post_date = date("Y-m-d H:i:s");
503
504 $this->db->insert('frm_posts_drafts', array(
505 'draft_id' => array('integer', $draft_id),
506 'post_id' => array('integer', $this->getPostId()),
507 'thread_id' => array('integer', $this->getThreadId()),
508 'forum_id' => array('integer', $this->getForumId()),
509 'post_author_id' => array('integer', $this->getPostAuthorId()),
510 'post_subject' => array('text', $this->getPostSubject()),
511 'post_message' => array('clob', $this->getPostMessage()),
512 'notify' => array('integer', $this->getNotify()),
513 'post_notify' => array('integer', $this->getPostNotify()),
514 'post_date' => array('timestamp', $post_date),
515 'post_update' => array('timestamp', $post_date),
516// 'update_user_id' => array('integer', $this->getUpdateUserId()),
517 'post_user_alias' => array('text', $this->getPostUserAlias()),
518 'pos_display_usr_id' => array('integer', $this->getPostDisplayUserId())
519 ));
520 $this->setDraftId($draft_id);
521 return $draft_id;
522 }

◆ setDraftId()

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

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

134 {
135 $this->draft_id = $draft_id;
136 }

References $draft_id.

Referenced by __construct(), and populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setForumId()

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

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

166 {
167 $this->forum_id = $forum_id;
168 }

References $forum_id.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ setNotify()

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

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

326 {
327 $this->notify = $notify;
328 }

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

294 {
295 $this->post_author_id = $post_author_id;
296 }

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

230 {
231 $this->post_date = $post_date;
232 }

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

310 {
311 $this->post_display_user_id = $post_display_user_id;
312 }

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

150 {
151 $this->post_id = $post_id;
152 }

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

214 {
215 $this->post_message = $post_message;
216 }

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

118 {
119 $this->post_notify = $post_notify;
120 }

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

198 {
199 $this->post_subject = $post_subject;
200 }

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

246 {
247 $this->post_update = $post_update;
248 }

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

278 {
279 $this->post_user_alias = $post_user_alias;
280 }

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

182 {
183 $this->thread_id = $thread_id;
184 }

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

262 {
263 $this->update_user_id = $update_user_id;
264 }

References $update_user_id.

Referenced by populateWithDatabaseRecord().

+ Here is the caller graph for this function:

◆ updateDraft()

ilForumPostDraft::updateDraft ( )

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

525 {
526 $this->db->update(
527 'frm_posts_drafts',
528 array(
529 'post_subject' => array('text', $this->getPostSubject()),
530 'post_message' => array('clob', $this->getPostMessage()),
531 'post_user_alias' => array('text', $this->getPostUserAlias()),
532 'post_update' => array('timestamp', date("Y-m-d H:i:s")),
533 'update_user_id' => array('integer', $this->getUpdateUserId()),
534 ),
535 array('draft_id' => array('integer', $this->getDraftId()))
536 );
537 }

Field Documentation

◆ $draft_id

ilForumPostDraft::$draft_id = 0
protected

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

Referenced by __construct(), getDraftId(), and setDraftId().

◆ $drafts_settings_cache

ilForumPostDraft::$drafts_settings_cache = array()
staticprotected

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

◆ $forum_id

ilForumPostDraft::$forum_id = 0
protected

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

Referenced by getForumId(), and setForumId().

◆ $forum_statistics_cache

ilForumPostDraft::$forum_statistics_cache = array()
staticprotected

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

◆ $instances

ilForumPostDraft::$instances = array()
staticprivate

Definition at line 71 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(), 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(), 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 66 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

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

Referenced by getThreadId(), and setThreadId().

◆ $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: