3require_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)) {
372 'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s',
377 self::$instances[$user_id] = array();
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]) {
397 return self::$instances[$user_id][
'draft_ids'];
407 if (!self::$instances[$user_id]) {
411 if (isset(self::$instances[$user_id][
$thread_id])) {
412 return self::$instances[$user_id][
$thread_id];
428 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
451 'SELECT * FROM frm_drafts_history WHERE history_id = %s',
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(
471 'draft_id' => array(
'integer',
$draft_id),
472 'post_id' => array(
'integer', $this->
getPostId()),
473 'thread_id' => array(
'integer', $this->
getThreadId()),
474 'forum_id' => array(
'integer', $this->
getForumId()),
478 'notify' => array(
'integer', $this->
getNotify()),
480 'post_date' => array(
'timestamp',
$post_date),
481 'post_update' => array(
'timestamp',
$post_date),
497 'notify' => array(
'integer', $this->
getNotify()),
499 'post_update' => array(
'timestamp',
date(
"Y-m-d H:i:s")),
504 array(
'draft_id' => array(
'integer', $this->
getDraftId()))
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'];
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'));
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'));
581 'SELECT draft_id FROM frm_posts_drafts WHERE post_author_id = %s',
586 $draft_ids = array();
588 $draft_ids[] =
$row[
'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'];
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'),
664 array($forumId,
$ilUser->getId())
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()];
690 array(
'thread_id' => array(
'integer', $target_thread_id)),
691 array(
'thread_id' => array(
'integer', $source_thread_id))
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)
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();
743 $draft_data[] = array(
'subject'=> $tmp_obj->getPostSubject(),
'post_update' => $tmp_obj->getPostUpdate(),
'draft_id' => $tmp_obj->getDraftId());
757 'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
768 $history_obj->deleteHistoryByDraftIds(array(
$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()
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 newInstanceByDraftId($draft_id)
static populateWithDatabaseRecord(ilForumPostDraft $draft, array $row)
static isSavePostDraftAllowed()
static getInstancesByUserIdAndThreadId($user_id, $thread_id)
static newInstanceByHistorytId($history_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
deleteDraftsByPostIds(array $post_ids=array())
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)
foreach($_POST as $key=> $value) $res