3require_once
'./Modules/Forum/classes/class.ilFileDataForumDrafts.php';
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))
370 $res =
$ilDB->queryF(
'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s',
371 array(
'integer'), array($user_id));
373 self::$instances[$user_id] = array();
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])
395 return self::$instances[$user_id][
'draft_ids'];
405 if(!self::$instances[$user_id])
412 return self::$instances[$user_id][
$thread_id];
420 public static function newInstanceByDraftId(
$draft_id)
428 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
446 public static function newInstanceByHistorytId($history_id)
454 'SELECT * FROM frm_drafts_history WHERE history_id = %s',
466 throw new ilException(
sprintf(
"Could not find history object for id %s", $history_id));
476 $ilDB->insert(
'frm_posts_drafts', array(
477 'draft_id' => array(
'integer',
$draft_id),
478 'post_id' => array(
'integer', $this->
getPostId()),
479 'thread_id' => array(
'integer', $this->
getThreadId()),
480 'forum_id' => array(
'integer', $this->
getForumId()),
484 'notify' => array(
'integer', $this->
getNotify()),
486 'post_date' => array(
'timestamp',
$post_date),
487 'post_update' => array(
'timestamp',
$post_date),
500 $ilDB->update(
'frm_posts_drafts', array(
503 'notify' => array(
'integer', $this->
getNotify()),
505 'post_update' => array(
'timestamp',
date(
"Y-m-d H:i:s")),
510 array(
'draft_id' => array(
'integer', $this->
getDraftId())));
517 $ilDB->manipulateF(
'DELETE FROM frm_posts_drafts WHERE draft_id = %s',
518 array(
'integer'), array($this->
getDraftId()));
526 require_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php';
529 foreach($oldMediaObjects as $oldMob)
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',
567 array(
'integer'), array($user_id));
569 $draft_ids = array();
572 $draft_ids[] =
$row[
'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',
586 array(
'integer'), array($user_id));
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()]))
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;
653 $num_drafts_total +=
$row[
'num_drafts'];
657 self::$forum_statistics_cache[
$ref_id][
$ilUser->getId()][
'total'] = $num_drafts_total;
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();
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',
733 array(
'integer'), array((
int)
$draft_id));
742 $history_obj->deleteHistoryByDraftIds(array(
$draft_id));
745 $history_obj->setPostSubject($tmp_obj->getPostSubject());
746 $history_obj->setPostMessage($tmp_obj->getPostMessage());
747 $history_obj->addDraftToHistory();
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
This class handles all operations on files for the drafts of a forum object.
Class ilForumDraftHistory.
setPostUserAlias($post_user_alias)
static moveDraftsByMergedThreads($source_thread_id, $target_thread_id)
static lookupAutosaveInterval()
deleteDraftsByDraftIds(array $draft_ids=array())
__construct($user_id=0, $post_id=0, $draft_id=0)
ilForumPostDraft constructor.
static isAutoSavePostDraftAllowed()
static populateWithDatabaseRecord(ilForumPostDraft $draft, array $row)
static isSavePostDraftAllowed()
static getInstancesByUserIdAndThreadId($user_id, $thread_id)
static readDrafts($user_id)
setPostMessage($post_message)
static moveDraftsByMovedThread($thread_ids, $source_ref_id, $target_ref_id)
static deleteDraftsByUserId($user_id)
static getDraftInstancesByUserId($user_id)
static createDraftBackup($draft_id)
static getThreadDraftData($post_author_id, $forum_id)
setPostUpdate($post_update)
setPostNotify($post_notify)
setPostSubject($post_subject)
setPostAuthorId($post_author_id)
static $drafts_settings_cache
static $forum_statistics_cache
setPostDisplayUserId($post_display_user_id)
static deleteMobsOfDraft($draft_id)
static getDraftsStatisticsByRefId($ref_id)
setUpdateUserId($update_user_id)
static moveMediaObjects($post_message, $source_type, $source_id, $target_type, $target_id, $direction=0)
static lookupForumIdByRefId($ref_id)