3 require_once
'./Modules/Forum/classes/class.ilFileDataForumDrafts.php';
351 $res = $ilDB->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 = $ilDB->fetchAssoc(
$res))
359 self::populateWithDatabaseRecord($this,
$row);
370 $res = $ilDB->queryF(
'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s',
373 self::$instances[$user_id] =
array();
374 while(
$row = $ilDB->fetchAssoc(
$res))
377 self::populateWithDatabaseRecord($tmp_obj,
$row);
378 self::$instances[$user_id][
$row[
'thread_id']][$tmp_obj->getPostId()][] = $tmp_obj;
379 self::$instances[$user_id][
'draft_ids'][$tmp_obj->getDraftId()] = $tmp_obj;
390 if(!self::$instances[$user_id])
392 self::readDrafts($user_id);
395 return self::$instances[$user_id][
'draft_ids'];
405 if(!self::$instances[$user_id])
407 self::readDrafts($user_id);
412 return self::$instances[$user_id][
$thread_id];
420 public static function newInstanceByDraftId(
$draft_id)
427 $res = $ilDB->queryF(
428 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
433 while(
$row = $ilDB->fetchAssoc(
$res))
436 self::populateWithDatabaseRecord($tmp_obj,
$row);
446 public static function newInstanceByHistorytId($history_id)
453 $res = $ilDB->queryF(
454 'SELECT * FROM frm_drafts_history WHERE history_id = %s',
459 while(
$row = $ilDB->fetchAssoc(
$res))
462 self::populateWithDatabaseRecord($tmp_obj,
$row);
466 throw new ilException(sprintf(
"Could not find history object for id %s", $history_id));
473 $draft_id = $ilDB->nextId(
'frm_posts_drafts');
476 $ilDB->insert(
'frm_posts_drafts',
array(
500 $ilDB->update(
'frm_posts_drafts',
array(
505 'post_update' =>
array(
'timestamp',
date(
"Y-m-d H:i:s")),
517 $ilDB->manipulateF(
'DELETE FROM frm_posts_drafts WHERE draft_id = %s',
526 require_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php';
529 foreach($oldMediaObjects as $oldMob)
549 self::deleteMobsOfDraft($draft_id);
553 $objFileDataForumDrafts->delete();
555 $ilDB->manipulate(
'DELETE FROM frm_drafts_history WHERE ' . $ilDB->in(
'draft_id', $draft_ids,
false,
'integer'));
556 $ilDB->manipulate(
'DELETE FROM frm_posts_drafts WHERE ' . $ilDB->in(
'draft_id', $draft_ids,
false,
'integer'));
566 $res = $ilDB->queryF(
'SELECT draft_id FROM frm_posts_drafts WHERE post_author_id = %s',
569 $draft_ids =
array();
570 while(
$row = $ilDB->fetchAssoc(
$res))
572 $draft_ids[] =
$row[
'draft_id'];
577 self::deleteMobsOfDraft($draft_id);
581 $objFileDataForumDrafts->delete();
584 $ilDB->manipulate(
'DELETE FROM frm_drafts_history WHERE ' . $ilDB->in(
'draft_id', $draft_ids,
false,
'integer'));
585 $ilDB->manipulateF(
'DELETE FROM frm_posts_drafts WHERE post_author_id = %s',
594 if(!isset(self::$drafts_settings_cache[
'save_post_drafts']))
597 self::$drafts_settings_cache[
'save_post_drafts'] = (bool)$ilSetting->get(
'save_post_drafts',
false);
599 return self::$drafts_settings_cache[
'save_post_drafts'];
607 if(!self::isSavePostDraftAllowed())
612 if(!isset(self::$drafts_settings_cache[
'autosave_drafts']))
616 self::$drafts_settings_cache[
'autosave_drafts'] = (bool)$ilSetting->get(
'autosave_drafts',
false);
617 self::$drafts_settings_cache[
'autosave_drafts_ival'] = (int)$ilSetting->get(
'autosave_drafts_ival', 30);
619 return self::$drafts_settings_cache[
'autosave_drafts'];
624 if(self::isAutoSavePostDraftAllowed())
626 return self::$drafts_settings_cache[
'autosave_drafts_ival'];
639 if(!isset(self::$forum_statistics_cache[
$ref_id][$ilUser->getId()]))
643 $res = $ilDB->queryF(
' 644 SELECT COUNT(draft_id) num_drafts, thread_id FROM frm_posts_drafts 645 WHERE forum_id = %s AND post_author_id = %s 647 array(
'integer',
'integer'),
array($forumId, $ilUser->getId()));
649 $num_drafts_total = 0;
651 while(
$row = $ilDB->fetchAssoc(
$res))
653 $num_drafts_total +=
$row[
'num_drafts'];
654 self::$forum_statistics_cache[
$ref_id][$ilUser->getId()][
$row[
'thread_id']] = $row[
'num_drafts'];
657 self::$forum_statistics_cache[
$ref_id][$ilUser->getId()][
'total'] = $num_drafts_total;
659 return self::$forum_statistics_cache[
$ref_id][$ilUser->getId()];
670 $ilDB->update(
'frm_posts_drafts',
671 array(
'thread_id' =>
array(
'integer', $target_thread_id)),
672 array(
'thread_id' =>
array(
'integer', $source_thread_id))
689 UPDATE frm_posts_drafts 692 AND '. $ilDB->in(
'thread_id', $thread_ids,
false,
'integer'),
693 array(
'integer',
'integer'),
694 array($target_forum_id, $source_forum_id)
707 $res = $ilDB->queryF(
'SELECT * FROM frm_posts_drafts 708 WHERE post_author_id = %s 712 ORDER BY post_date DESC',
713 array(
'integer',
'integer',
'integer',
'integer'),
715 $draft_data =
array();
716 while(
$row = $ilDB->fetchAssoc(
$res))
719 self::populateWithDatabaseRecord($tmp_obj,
$row);
720 $draft_data[] =
array(
'subject'=> $tmp_obj->getPostSubject(),
'post_update' => $tmp_obj->getPostUpdate(),
'draft_id' => $tmp_obj->getDraftId());
732 $res = $ilDB->queryF(
'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
735 while(
$row = $ilDB->fetchAssoc(
$res))
738 self::populateWithDatabaseRecord($tmp_obj,
$row);
742 $history_obj->deleteHistoryByDraftIds(
array($draft_id));
744 $history_obj->setDraftId($draft_id);
745 $history_obj->setPostSubject($tmp_obj->getPostSubject());
746 $history_obj->setPostMessage($tmp_obj->getPostMessage());
747 $history_obj->addDraftToHistory();
static getDraftInstancesByUserId($user_id)
static getThreadDraftData($post_author_id, $forum_id)
Base class for ILIAS Exception handling.
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)
static isAutoSavePostDraftAllowed()
static deleteMobsOfDraft($draft_id)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
setUpdateUserId($update_user_id)
setPostMessage($post_message)
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 isSavePostDraftAllowed()
static deleteDraftsByUserId($user_id)
static $forum_statistics_cache
setPostUpdate($post_update)
static getDraftsStatisticsByRefId($ref_id)