3 require_once
'./Modules/Forum/classes/class.ilFileDataForumDrafts.php';
337 $this->db = $DIC->database();
352 $res = $this->db->queryF(
353 'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s AND post_id = %s AND draft_id = %s',
354 array(
'integer',
'integer',
'integer'),
358 while (
$row = $this->db->fetchAssoc(
$res)) {
359 self::populateWithDatabaseRecord($this,
$row);
369 $ilDB = $DIC->database();
372 'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s',
377 self::$instances[$user_id] =
array();
380 self::populateWithDatabaseRecord($tmp_obj,
$row);
381 self::$instances[$user_id][
$row[
'thread_id']][$tmp_obj->getPostId()][] = $tmp_obj;
382 self::$instances[$user_id][
'draft_ids'][$tmp_obj->getDraftId()] = $tmp_obj;
393 if (!self::$instances[$user_id]) {
394 self::readDrafts($user_id);
397 return self::$instances[$user_id][
'draft_ids'];
407 if (!self::$instances[$user_id]) {
408 self::readDrafts($user_id);
411 if (isset(self::$instances[$user_id][
$thread_id])) {
412 return self::$instances[$user_id][
$thread_id];
425 $ilDB = $DIC->database();
428 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
435 self::populateWithDatabaseRecord($tmp_obj,
$row);
448 $ilDB = $DIC->database();
451 'SELECT * FROM frm_drafts_history WHERE history_id = %s',
458 self::populateWithDatabaseRecord($tmp_obj,
$row);
462 throw new ilException(sprintf(
"Could not find history object for id %s", $history_id));
467 $draft_id = $this->db->nextId(
'frm_posts_drafts');
470 $this->db->insert(
'frm_posts_drafts',
array(
499 'post_update' =>
array(
'timestamp',
date(
"Y-m-d H:i:s")),
510 $this->db->manipulateF(
511 'DELETE FROM frm_posts_drafts WHERE draft_id = %s',
522 require_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php';
525 foreach ($oldMediaObjects as $oldMob) {
539 $draft_ids =
array();
540 $res = $this->db->query(
'SELECT draft_id FROM frm_posts_drafts WHERE ' . $this->db->in(
'post_id', $post_ids,
false,
'integer'));
541 while (
$row = $this->db->fetchAssoc(
$res)) {
542 $draft_ids[] =
$row[
'draft_id'];
546 self::deleteMobsOfDraft($draft_id);
550 $objFileDataForumDrafts->delete();
552 $this->db->manipulate(
'DELETE FROM frm_drafts_history WHERE ' . $this->db->in(
'draft_id', $draft_ids,
false,
'integer'));
553 $this->db->manipulate(
'DELETE FROM frm_posts_drafts WHERE ' . $this->db->in(
'draft_id', $draft_ids,
false,
'integer'));
562 self::deleteMobsOfDraft($draft_id);
566 $objFileDataForumDrafts->delete();
568 $this->db->manipulate(
'DELETE FROM frm_drafts_history WHERE ' . $this->db->in(
'draft_id', $draft_ids,
false,
'integer'));
569 $this->db->manipulate(
'DELETE FROM frm_posts_drafts WHERE ' . $this->db->in(
'draft_id', $draft_ids,
false,
'integer'));
578 $ilDB = $DIC->database();
581 'SELECT draft_id FROM frm_posts_drafts WHERE post_author_id = %s',
586 $draft_ids =
array();
588 $draft_ids[] =
$row[
'draft_id'];
592 self::deleteMobsOfDraft($draft_id);
596 $objFileDataForumDrafts->delete();
599 $ilDB->manipulate(
'DELETE FROM frm_drafts_history WHERE ' .
$ilDB->in(
'draft_id', $draft_ids,
false,
'integer'));
601 'DELETE FROM frm_posts_drafts WHERE post_author_id = %s',
612 if (!isset(self::$drafts_settings_cache[
'save_post_drafts'])) {
614 self::$drafts_settings_cache[
'save_post_drafts'] = (bool) $DIC->settings()->get(
'save_post_drafts',
false);
616 return self::$drafts_settings_cache[
'save_post_drafts'];
624 if (!self::isSavePostDraftAllowed()) {
628 if (!isset(self::$drafts_settings_cache[
'autosave_drafts'])) {
631 self::$drafts_settings_cache[
'autosave_drafts'] = (bool) $DIC->settings()->get(
'autosave_drafts',
false);
632 self::$drafts_settings_cache[
'autosave_drafts_ival'] = (int) $DIC->settings()->get(
'autosave_drafts_ival', 30);
634 return self::$drafts_settings_cache[
'autosave_drafts'];
639 if (self::isAutoSavePostDraftAllowed()) {
640 return self::$drafts_settings_cache[
'autosave_drafts_ival'];
652 $ilDB = $DIC->database();
655 if (!isset(self::$forum_statistics_cache[$ref_id][
$ilUser->getId()])) {
660 SELECT COUNT(draft_id) num_drafts, thread_id FROM frm_posts_drafts 661 WHERE forum_id = %s AND post_author_id = %s 663 array(
'integer',
'integer'),
667 $num_drafts_total = 0;
670 $num_drafts_total +=
$row[
'num_drafts'];
671 self::$forum_statistics_cache[$ref_id][
$ilUser->getId()][
$row[
'thread_id']] = $row[
'num_drafts'];
674 self::$forum_statistics_cache[$ref_id][
$ilUser->getId()][
'total'] = $num_drafts_total;
676 return self::$forum_statistics_cache[$ref_id][
$ilUser->getId()];
686 $ilDB = $DIC->database();
690 array(
'thread_id' =>
array(
'integer', $target_thread_id)),
691 array(
'thread_id' =>
array(
'integer', $source_thread_id))
703 $ilDB = $DIC->database();
710 UPDATE frm_posts_drafts 713 AND ' .
$ilDB->in(
'thread_id', $thread_ids,
false,
'integer'),
714 array(
'integer',
'integer'),
715 array($target_forum_id, $source_forum_id)
727 $ilDB = $DIC->database();
730 'SELECT * FROM frm_posts_drafts 731 WHERE post_author_id = %s 735 ORDER BY post_date DESC',
736 array(
'integer',
'integer',
'integer',
'integer'),
739 $draft_data =
array();
742 self::populateWithDatabaseRecord($tmp_obj,
$row);
743 $draft_data[] =
array(
'subject'=> $tmp_obj->getPostSubject(),
'post_update' => $tmp_obj->getPostUpdate(),
'draft_id' => $tmp_obj->getDraftId());
754 $ilDB = $DIC->database();
757 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
764 self::populateWithDatabaseRecord($tmp_obj,
$row);
768 $history_obj->deleteHistoryByDraftIds(
array($draft_id));
770 $history_obj->setDraftId($draft_id);
771 $history_obj->setPostSubject($tmp_obj->getPostSubject());
772 $history_obj->setPostMessage($tmp_obj->getPostMessage());
773 $history_obj->addDraftToHistory();
776 $tmp_obj->getPostMessage(),
777 self::MEDIAOBJECT_TYPE,
780 $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)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
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)
Create styles array
The data for the language used.
static newInstanceByHistorytId($history_id)
static isSavePostDraftAllowed()
static deleteDraftsByUserId($user_id)
static $forum_statistics_cache
setPostUpdate($post_update)
static getDraftsStatisticsByRefId($ref_id)