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)) {
124 'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY draft_date DESC',
130 $draftHistory =
new self();
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',
157 [$this->getHistoryId()]
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)) {
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 $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)) {
188 $this->setHistoryId((
int) $row[
'history_id']);
189 $this->setDraftId((
int) $row[
'draft_id']);
190 $this->setPostSubject($row[
'post_subject']);
191 $this->setPostMessage($row[
'post_message']);
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()],
203 'post_subject' => [
'text', $this->getPostSubject()],
204 'post_message' => [
'text', $this->getPostMessage()],
205 'draft_date' => [
'timestamp', date(
"Y-m-d H:i:s")]
208 $this->setHistoryId($next_id);
214 foreach ($oldMediaObjects as $oldMob) {
226 $draft->setPostSubject($this->getPostSubject());
227 $draft->setPostMessage($this->getPostMessage());
230 $this->getPostMessage(),
231 self::MEDIAOBJECT_TYPE,
232 $this->getHistoryId(),
237 $draft->updateDraft();
238 $this->deleteHistoryByDraftIds([$draft->getDraftId()]);
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'];
261 $this->deleteHistoryByDraftIds($draft_ids);
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)) {
278 $this->setHistoryId((
int) $row[
'history_id']);
282 $this->db->manipulate(
283 'DELETE FROM frm_drafts_history WHERE ' . $this->db->in(
'draft_id', $draft_ids,
false,
'integer')
Class ilForumDraftHistory.
deleteHistoryByPostIds(array $post_ids=[])
readonly ilDBInterface $db
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)
populateWithFirstAutosaveByDraftId(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)