19declare(strict_types=1);
90 $this->db =
$DIC->database();
99 $res = $this->db->queryF(
100 'SELECT * FROM frm_drafts_history WHERE history_id = %s',
105 while ($row = $this->db->fetchAssoc(
$res)) {
125 'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY draft_date DESC',
131 $draftHistory =
new self();
134 $instances[] = $draftHistory;
145 $history_draft->
setDraftId((
int) $row[
'draft_id']);
150 return $history_draft;
153 public function delete():
void
155 $this->db->manipulateF(
156 'DELETE FROM frm_drafts_history WHERE history_id = %s',
158 [$this->getHistoryId()]
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)) {
171 $this->setHistoryId((
int) $row[
'history_id']);
172 $this->setDraftId((
int) $row[
'draft_id']);
173 $this->setPostSubject($row[
'post_subject']);
174 $this->setPostMessage($row[
'post_message']);
180 $res = $this->db->queryF(
181 'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY history_id DESC',
186 while ($row = $this->db->fetchAssoc(
$res)) {
187 $this->setHistoryId((
int) $row[
'history_id']);
188 $this->setDraftId((
int) $row[
'draft_id']);
189 $this->setPostSubject($row[
'post_subject']);
190 $this->setPostMessage($row[
'post_message']);
196 $next_id = $this->db->nextId(
'frm_drafts_history');
198 'frm_drafts_history',
200 'history_id' => [
'integer', $next_id],
201 'draft_id' => [
'integer', $this->getDraftId()],
202 'post_subject' => [
'text', $this->getPostSubject()],
203 'post_message' => [
'text', $this->getPostMessage()],
204 'draft_date' => [
'timestamp', date(
"Y-m-d H:i:s")]
207 $this->setHistoryId($next_id);
213 foreach ($oldMediaObjects as $oldMob) {
225 $draft->setPostSubject($this->getPostSubject());
226 $draft->setPostMessage($this->getPostMessage());
229 $this->getPostMessage(),
230 self::MEDIAOBJECT_TYPE,
231 $this->getHistoryId(),
236 $draft->updateDraft();
237 $this->deleteHistoryByDraftIds([$draft->getDraftId()]);
249 if ($post_ids !== []) {
250 $res = $this->db->query(
'
251 SELECT frm_drafts_history.history_id, frm_drafts_history.draft_id
252 FROM frm_posts_drafts
253 INNER JOIN frm_drafts_history ON frm_posts_drafts.draft_id
254 WHERE ' . $this->db->in(
'post_id', $post_ids,
false,
'integer'));
256 while ($row = $this->db->fetchAssoc(
$res)) {
257 $draft_ids[] = (
int) $row[
'draft_id'];
260 $this->deleteHistoryByDraftIds($draft_ids);
271 if ($draft_ids !== []) {
272 $res = $this->db->query(
273 'SELECT history_id FROM frm_drafts_history WHERE ' . $this->db->in(
'draft_id', $draft_ids,
false,
'integer')
276 while ($row = $this->db->fetchAssoc(
$res)) {
277 $this->setHistoryId((
int) $row[
'history_id']);
281 $this->db->manipulate(
282 'DELETE FROM frm_drafts_history WHERE ' . $this->db->in(
'draft_id', $draft_ids,
false,
'integer')
Class ilForumDraftHistory.
deleteHistoryByPostIds(array $post_ids=[])
deleteHistoryByDraftIds(array $draft_ids=[])
setDraftDate(string $draft_date)
__construct(int $history_id=0)
setPostSubject(string $post_subject)
setPostMessage(string $post_message)
static populateWithDatabaseRecord(ilForumDraftsHistory $history_draft, array $row)
getFirstAutosaveByDraftId(int $draft_id)
setHistoryId(int $history_id)
getLastAutosaveByDraftId(int $draft_id)
setDraftId(int $draft_id)
readByHistoryId(int $history_id)
static getInstancesByDraftId(int $draft_id)
static newInstanceByDraftId(int $draft_id)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)