19 declare(strict_types=1);
90 $this->db = $DIC->database();
92 if ($history_id > 0) {
99 $res = $this->db->queryF(
100 'SELECT * FROM frm_drafts_history WHERE history_id = %s',
105 while ($row = $this->db->fetchAssoc(
$res)) {
121 $ilDB = $DIC->database();
124 'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY draft_date DESC',
130 $draftHistory =
new self();
131 $draftHistory = self::populateWithDatabaseRecord($draftHistory, $row);
133 $instances[] = $draftHistory;
144 $history_draft->
setDraftId((
int) $row[
'draft_id']);
149 return $history_draft;
152 public function delete():
void 154 $this->db->manipulateF(
155 'DELETE FROM frm_drafts_history WHERE history_id = %s',
163 $this->db->setLimit(1);
164 $res = $this->db->queryF(
165 'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY history_id ASC',
170 if ($row = $this->db->fetchAssoc(
$res)) {
180 $this->db->setLimit(1);
181 $res = $this->db->queryF(
182 'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY history_id DESC',
187 while ($row = $this->db->fetchAssoc(
$res)) {
197 $next_id = $this->db->nextId(
'frm_drafts_history');
199 'frm_drafts_history',
201 'history_id' => [
'integer', $next_id],
202 'draft_id' => [
'integer', $this->
getDraftId()],
205 'draft_date' => [
'timestamp', date(
"Y-m-d H:i:s")]
214 foreach ($oldMediaObjects as $oldMob) {
231 self::MEDIAOBJECT_TYPE,
237 $draft->updateDraft();
250 if ($post_ids !== []) {
251 $res = $this->db->query(
' 252 SELECT frm_drafts_history.history_id, frm_drafts_history.draft_id 253 FROM frm_posts_drafts 254 INNER JOIN frm_drafts_history ON frm_posts_drafts.draft_id 255 WHERE ' . $this->db->in(
'post_id', $post_ids,
false,
'integer'));
257 while ($row = $this->db->fetchAssoc(
$res)) {
258 $draft_ids[] = (
int) $row[
'draft_id'];
272 if ($draft_ids !== []) {
273 $res = $this->db->query(
274 'SELECT history_id FROM frm_drafts_history WHERE ' . $this->db->in(
'draft_id', $draft_ids,
false,
'integer')
277 while ($row = $this->db->fetchAssoc(
$res)) {
282 $this->db->manipulate(
283 'DELETE FROM frm_drafts_history WHERE ' . $this->db->in(
'draft_id', $draft_ids,
false,
'integer')
static getInstancesByDraftId(int $draft_id)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
readByHistoryId(int $history_id)
deleteHistoryByPostIds(array $post_ids=[])
getLastAutosaveByDraftId(int $draft_id)
setDraftDate(string $draft_date)
populateWithFirstAutosaveByDraftId(int $draft_id)
setHistoryId(int $history_id)
Class ilForumDraftHistory.
setPostSubject(string $post_subject)
deleteHistoryByDraftIds(array $draft_ids=[])
setPostMessage(string $post_message)
readonly ilDBInterface $db
setDraftId(int $draft_id)
static newInstanceByDraftId(int $draft_id)
static populateWithDatabaseRecord(ilForumDraftsHistory $history_draft, array $row)
__construct(int $history_id=0)