336 $this->db = $DIC->database();
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'),
357 while (
$row = $this->db->fetchAssoc(
$res)) {
358 self::populateWithDatabaseRecord($this,
$row);
368 $ilDB = $DIC->database();
371 'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s',
376 self::$instances[$user_id] = array();
379 self::populateWithDatabaseRecord($tmp_obj,
$row);
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;
392 if (!self::$instances[$user_id]) {
393 self::readDrafts($user_id);
396 return self::$instances[$user_id][
'draft_ids'];
406 if (!self::$instances[$user_id]) {
407 self::readDrafts($user_id);
410 if (isset(self::$instances[$user_id][
$thread_id])) {
411 return self::$instances[$user_id][
$thread_id];
424 $ilDB = $DIC->database();
427 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
434 self::populateWithDatabaseRecord($tmp_obj,
$row);
447 $ilDB = $DIC->database();
450 'SELECT * FROM frm_drafts_history WHERE history_id = %s',
457 self::populateWithDatabaseRecord($tmp_obj,
$row);
461 throw new ilException(sprintf(
"Could not find history object for id %s", $history_id));
466 $draft_id = $this->db->nextId(
'frm_posts_drafts');
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()),
477 'notify' => array(
'integer', $this->
getNotify()),
479 'post_date' => array(
'timestamp',
$post_date),
480 'post_update' => array(
'timestamp',
$post_date),
498 array(
'draft_id' => array(
'integer', $this->
getDraftId()))
504 $this->db->manipulateF(
505 'DELETE FROM frm_posts_drafts WHERE draft_id = %s',
518 foreach ($oldMediaObjects as $oldMob) {
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'];
539 self::deleteMobsOfDraft($draft_id);
543 $objFileDataForumDrafts->delete();
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'));
555 self::deleteMobsOfDraft($draft_id);
559 $objFileDataForumDrafts->delete();
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'));
571 $ilDB = $DIC->database();
574 'SELECT draft_id FROM frm_posts_drafts WHERE post_author_id = %s',
579 $draft_ids = array();
581 $draft_ids[] =
$row[
'draft_id'];
585 self::deleteMobsOfDraft($draft_id);
589 $objFileDataForumDrafts->delete();
592 $ilDB->manipulate(
'DELETE FROM frm_drafts_history WHERE ' .
$ilDB->in(
'draft_id', $draft_ids,
false,
'integer'));
594 'DELETE FROM frm_posts_drafts WHERE post_author_id = %s',
605 if (!isset(self::$drafts_settings_cache[
'save_post_drafts'])) {
607 self::$drafts_settings_cache[
'save_post_drafts'] = (bool) $DIC->settings()->get(
'save_post_drafts',
false);
609 return self::$drafts_settings_cache[
'save_post_drafts'];
617 if (!self::isSavePostDraftAllowed()) {
621 if (!isset(self::$drafts_settings_cache[
'autosave_drafts'])) {
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);
627 return self::$drafts_settings_cache[
'autosave_drafts'];
632 if (self::isAutoSavePostDraftAllowed()) {
633 return self::$drafts_settings_cache[
'autosave_drafts_ival'];
645 $ilDB = $DIC->database();
648 if (!isset(self::$forum_statistics_cache[$ref_id][
$ilUser->getId()])) {
653 SELECT COUNT(draft_id) num_drafts, thread_id FROM frm_posts_drafts 654 WHERE forum_id = %s AND post_author_id = %s 656 array(
'integer',
'integer'),
657 array($forumId,
$ilUser->getId())
660 $num_drafts_total = 0;
663 $num_drafts_total +=
$row[
'num_drafts'];
664 self::$forum_statistics_cache[$ref_id][
$ilUser->getId()][
$row[
'thread_id']] = $row[
'num_drafts'];
667 self::$forum_statistics_cache[$ref_id][
$ilUser->getId()][
'total'] = $num_drafts_total;
669 return self::$forum_statistics_cache[$ref_id][
$ilUser->getId()];
679 $ilDB = $DIC->database();
683 array(
'thread_id' => array(
'integer', $target_thread_id)),
684 array(
'thread_id' => array(
'integer', $source_thread_id))
696 $ilDB = $DIC->database();
703 UPDATE frm_posts_drafts 706 AND ' .
$ilDB->in(
'thread_id', $thread_ids,
false,
'integer'),
707 array(
'integer',
'integer'),
708 array($target_forum_id, $source_forum_id)
720 $ilDB = $DIC->database();
723 'SELECT * FROM frm_posts_drafts 724 WHERE post_author_id = %s 728 ORDER BY post_date DESC',
729 array(
'integer',
'integer',
'integer',
'integer'),
732 $draft_data = array();
735 self::populateWithDatabaseRecord($tmp_obj,
$row);
736 $draft_data[] = array(
'subject' => $tmp_obj->getPostSubject(),
'post_update' => $tmp_obj->getPostUpdate(),
'draft_id' => $tmp_obj->getDraftId());
747 $ilDB = $DIC->database();
750 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
757 self::populateWithDatabaseRecord($tmp_obj,
$row);
761 $history_obj->deleteHistoryByDraftIds(array($draft_id));
763 $history_obj->setDraftId($draft_id);
764 $history_obj->setPostSubject($tmp_obj->getPostSubject());
765 $history_obj->setPostMessage($tmp_obj->getPostMessage());
766 $history_obj->addDraftToHistory();
769 $tmp_obj->getPostMessage(),
770 self::MEDIAOBJECT_TYPE,
773 $history_obj->getHistoryId()
static getDraftInstancesByUserId($user_id)
static getThreadDraftData($post_author_id, $forum_id)
deleteDraftsByDraftIds(array $draft_ids=array())
setPostUserAlias($post_user_alias)
static getInstancesByUserIdAndThreadId($user_id, $thread_id)
static lookupForumIdByRefId($ref_id)
setPostDisplayUserId($post_display_user_id)
__construct($user_id=0, $post_id=0, $draft_id=0)
ilForumPostDraft constructor.
static lookupAutosaveInterval()
static moveMediaObjects($post_message, $source_type, $source_id, $target_type, $target_id, $direction=0)
This class handles all operations on files for the drafts of a forum object.
setPostNotify($post_notify)
static readDrafts($user_id)
Class ilForumDraftHistory.
static populateWithDatabaseRecord(ilForumPostDraft $draft, array $row)
static createDraftBackup($draft_id)
static moveDraftsByMergedThreads($source_thread_id, $target_thread_id)
foreach($_POST as $key=> $value) $res
static isAutoSavePostDraftAllowed()
static deleteMobsOfDraft($draft_id)
deleteDraftsByPostIds(array $post_ids=array())
setUpdateUserId($update_user_id)
setPostMessage($post_message)
static newInstanceByDraftId($draft_id)
static $drafts_settings_cache
setPostSubject($post_subject)
setPostAuthorId($post_author_id)
static moveDraftsByMovedThread($thread_ids, $source_ref_id, $target_ref_id)
static newInstanceByHistorytId($history_id)
static isSavePostDraftAllowed()
static deleteDraftsByUserId($user_id)
static $forum_statistics_cache
setPostUpdate($post_update)
static getDraftsStatisticsByRefId($ref_id)