ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilForumDraftsHistory Class Reference

Class ilForumDraftHistory. More...

+ Collaboration diagram for ilForumDraftsHistory:

Public Member Functions

 getHistoryId ()
 
 setHistoryId (int $history_id)
 
 getDraftId ()
 
 setDraftId (int $draft_id)
 
 getPostSubject ()
 
 setPostSubject (string $post_subject)
 
 getPostMessage ()
 
 setPostMessage (string $post_message)
 
 getDraftDate ()
 
 setDraftDate (string $draft_date)
 
 __construct (int $history_id=0)
 
 delete ()
 
 getFirstAutosaveByDraftId (int $draft_id)
 
 getLastAutosaveByDraftId (int $draft_id)
 
 addDraftToHistory ()
 
 deleteMobs ()
 
 rollbackAutosave ()
 
 deleteHistoryByPostIds (array $post_ids=[])
 
 deleteHistoryByDraftIds (array $draft_ids=[])
 

Static Public Member Functions

static getInstancesByDraftId (int $draft_id)
 

Data Fields

const MEDIAOBJECT_TYPE = 'frm~h:html'
 

Static Protected Member Functions

static populateWithDatabaseRecord (ilForumDraftsHistory $history_draft, array $row)
 

Protected Attributes

string $draft_date = '0000-00-00 00:00:00'
 

Private Member Functions

 readByHistoryId (int $history_id)
 

Private Attributes

ilDBInterface $db
 
int $history_id = 0
 
int $draft_id = 0
 
string $post_subject = ''
 
string $post_message = ''
 

Detailed Description

Class ilForumDraftHistory.

Author
Nadia Matuschek nmatu.nosp@m.sche.nosp@m.k@dat.nosp@m.abay.nosp@m..de

Definition at line 25 of file class.ilForumDraftsHistory.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumDraftsHistory::__construct ( int  $history_id = 0)

Definition at line 86 of file class.ilForumDraftsHistory.php.

References $DIC, and readByHistoryId().

87  {
88  global $DIC;
89 
90  $this->db = $DIC->database();
91 
92  if ($history_id > 0) {
94  }
95  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addDraftToHistory()

ilForumDraftsHistory::addDraftToHistory ( )

Definition at line 194 of file class.ilForumDraftsHistory.php.

References getDraftId(), getPostMessage(), getPostSubject(), and setHistoryId().

194  : void
195  {
196  $next_id = $this->db->nextId('frm_drafts_history');
197  $this->db->insert(
198  'frm_drafts_history',
199  [
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")]
205  ]
206  );
207  $this->setHistoryId($next_id);
208  }
+ Here is the call graph for this function:

◆ delete()

ilForumDraftsHistory::delete ( )

Definition at line 153 of file class.ilForumDraftsHistory.php.

References getHistoryId().

153  : void
154  {
155  $this->db->manipulateF(
156  'DELETE FROM frm_drafts_history WHERE history_id = %s',
157  ['integer'],
158  [$this->getHistoryId()]
159  );
160  }
+ Here is the call graph for this function:

◆ deleteHistoryByDraftIds()

ilForumDraftsHistory::deleteHistoryByDraftIds ( array  $draft_ids = [])
Parameters
int[]$draft_ids

Definition at line 269 of file class.ilForumDraftsHistory.php.

References $res, deleteMobs(), and setHistoryId().

Referenced by deleteHistoryByPostIds(), and rollbackAutosave().

269  : void
270  {
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')
274  );
275 
276  while ($row = $this->db->fetchAssoc($res)) {
277  $this->setHistoryId((int) $row['history_id']);
278  $this->deleteMobs();
279  }
280 
281  $this->db->manipulate(
282  'DELETE FROM frm_drafts_history WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer')
283  );
284  }
285  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteHistoryByPostIds()

ilForumDraftsHistory::deleteHistoryByPostIds ( array  $post_ids = [])
Parameters
int[]$post_ids
Returns
int[] A list of deleted draft ids

Definition at line 246 of file class.ilForumDraftsHistory.php.

References $res, deleteHistoryByDraftIds(), and ILIAS\Repository\int().

246  : array
247  {
248  $draft_ids = [];
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'));
255 
256  while ($row = $this->db->fetchAssoc($res)) {
257  $draft_ids[] = (int) $row['draft_id'];
258  }
259 
260  $this->deleteHistoryByDraftIds($draft_ids);
261  }
262 
263  return $draft_ids;
264  }
$res
Definition: ltiservices.php:69
deleteHistoryByDraftIds(array $draft_ids=[])
+ Here is the call graph for this function:

◆ deleteMobs()

ilForumDraftsHistory::deleteMobs ( )

Definition at line 210 of file class.ilForumDraftsHistory.php.

References ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), and getHistoryId().

Referenced by deleteHistoryByDraftIds().

210  : void
211  {
212  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~h:html', $this->getHistoryId());
213  foreach ($oldMediaObjects as $oldMob) {
214  if (ilObjMediaObject::_exists($oldMob)) {
215  ilObjMediaObject::_removeUsage($oldMob, 'frm~h:html', $this->getHistoryId());
216  $mob_obj = new ilObjMediaObject($oldMob);
217  $mob_obj->delete();
218  }
219  }
220  }
static _exists(int $id, bool $reference=false, ?string $type=null)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDraftDate()

ilForumDraftsHistory::getDraftDate ( )

Definition at line 76 of file class.ilForumDraftsHistory.php.

References $draft_date.

76  : string
77  {
78  return $this->draft_date;
79  }

◆ getDraftId()

ilForumDraftsHistory::getDraftId ( )

Definition at line 46 of file class.ilForumDraftsHistory.php.

References $draft_id.

Referenced by addDraftToHistory(), and rollbackAutosave().

46  : int
47  {
48  return $this->draft_id;
49  }
+ Here is the caller graph for this function:

◆ getFirstAutosaveByDraftId()

ilForumDraftsHistory::getFirstAutosaveByDraftId ( int  $draft_id)

Definition at line 162 of file class.ilForumDraftsHistory.php.

References $res, setDraftId(), setHistoryId(), setPostMessage(), and setPostSubject().

162  : void
163  {
164  $res = $this->db->queryF(
165  'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY history_id ASC',
166  ['integer'],
167  [$draft_id]
168  );
169 
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']);
175  }
176  }
$res
Definition: ltiservices.php:69
setPostSubject(string $post_subject)
setPostMessage(string $post_message)
+ Here is the call graph for this function:

◆ getHistoryId()

ilForumDraftsHistory::getHistoryId ( )

Definition at line 36 of file class.ilForumDraftsHistory.php.

References $history_id.

Referenced by delete(), deleteMobs(), and rollbackAutosave().

36  : int
37  {
38  return $this->history_id;
39  }
+ Here is the caller graph for this function:

◆ getInstancesByDraftId()

static ilForumDraftsHistory::getInstancesByDraftId ( int  $draft_id)
static
Parameters
int$draft_id
Returns
ilForumDraftsHistory[]

Definition at line 118 of file class.ilForumDraftsHistory.php.

References $DIC, $ilDB, and $res.

Referenced by ilObjForumGUI\doHistoryCheck().

118  : array
119  {
120  global $DIC;
121 
122  $ilDB = $DIC->database();
123 
124  $res = $ilDB->queryF(
125  'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY draft_date DESC',
126  ['integer'],
127  [$draft_id]
128  );
129  $instances = [];
130  while ($row = $ilDB->fetchAssoc($res)) {
131  $draftHistory = new self();
132  $draftHistory = self::populateWithDatabaseRecord($draftHistory, $row);
133 
134  $instances[] = $draftHistory;
135  }
136 
137  return $instances;
138  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getLastAutosaveByDraftId()

ilForumDraftsHistory::getLastAutosaveByDraftId ( int  $draft_id)

Definition at line 178 of file class.ilForumDraftsHistory.php.

References $res, setDraftId(), setHistoryId(), setPostMessage(), and setPostSubject().

178  : void
179  {
180  $res = $this->db->queryF(
181  'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY history_id DESC',
182  ['integer'],
183  [$draft_id]
184  );
185 
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']);
191  }
192  }
$res
Definition: ltiservices.php:69
setPostSubject(string $post_subject)
setPostMessage(string $post_message)
+ Here is the call graph for this function:

◆ getPostMessage()

ilForumDraftsHistory::getPostMessage ( )

Definition at line 66 of file class.ilForumDraftsHistory.php.

References $post_message.

Referenced by addDraftToHistory(), and rollbackAutosave().

66  : string
67  {
68  return $this->post_message;
69  }
+ Here is the caller graph for this function:

◆ getPostSubject()

ilForumDraftsHistory::getPostSubject ( )

Definition at line 56 of file class.ilForumDraftsHistory.php.

References $post_subject.

Referenced by addDraftToHistory(), and rollbackAutosave().

56  : string
57  {
58  return $this->post_subject;
59  }
+ Here is the caller graph for this function:

◆ populateWithDatabaseRecord()

static ilForumDraftsHistory::populateWithDatabaseRecord ( ilForumDraftsHistory  $history_draft,
array  $row 
)
staticprotected

Definition at line 140 of file class.ilForumDraftsHistory.php.

References setDraftDate(), setDraftId(), setHistoryId(), setPostMessage(), and setPostSubject().

144  $history_draft->setHistoryId((int) $row['history_id']);
145  $history_draft->setDraftId((int) $row['draft_id']);
146  $history_draft->setPostMessage($row['post_message']);
147  $history_draft->setPostSubject($row['post_subject']);
148  $history_draft->setDraftDate($row['draft_date']);
149 
150  return $history_draft;
151  }
setDraftDate(string $draft_date)
Class ilForumDraftHistory.
setPostSubject(string $post_subject)
setPostMessage(string $post_message)
+ Here is the call graph for this function:

◆ readByHistoryId()

ilForumDraftsHistory::readByHistoryId ( int  $history_id)
private

Definition at line 97 of file class.ilForumDraftsHistory.php.

References $res, setDraftDate(), setDraftId(), setHistoryId(), setPostMessage(), and setPostSubject().

Referenced by __construct().

97  : void
98  {
99  $res = $this->db->queryF(
100  'SELECT * FROM frm_drafts_history WHERE history_id = %s',
101  ['integer'],
102  [$history_id]
103  );
104 
105  while ($row = $this->db->fetchAssoc($res)) {
106  $this->setHistoryId((int) $row['history_id']);
107  $this->setDraftId((int) $row['draft_id']);
108  $this->setPostMessage($row['post_message']);
109  $this->setPostSubject($row['post_subject']);
110  $this->setDraftDate($row['draft_date']);
111  }
112  }
$res
Definition: ltiservices.php:69
setDraftDate(string $draft_date)
setPostSubject(string $post_subject)
setPostMessage(string $post_message)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rollbackAutosave()

ilForumDraftsHistory::rollbackAutosave ( )

Definition at line 222 of file class.ilForumDraftsHistory.php.

References deleteHistoryByDraftIds(), getDraftId(), getHistoryId(), getPostMessage(), getPostSubject(), ilForumPostDraft\MEDIAOBJECT_TYPE, ilForumUtil\moveMediaObjects(), and ilForumPostDraft\newInstanceByDraftId().

223  {
225  $draft->setPostSubject($this->getPostSubject());
226  $draft->setPostMessage($this->getPostMessage());
227 
229  $this->getPostMessage(),
230  self::MEDIAOBJECT_TYPE,
231  $this->getHistoryId(),
233  $draft->getDraftId()
234  );
235 
236  $draft->updateDraft();
237  $this->deleteHistoryByDraftIds([$draft->getDraftId()]);
238 
239  return $draft;
240  }
Class ilForumPostDraft.
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
deleteHistoryByDraftIds(array $draft_ids=[])
static newInstanceByDraftId(int $draft_id)
+ Here is the call graph for this function:

◆ setDraftDate()

ilForumDraftsHistory::setDraftDate ( string  $draft_date)

Definition at line 81 of file class.ilForumDraftsHistory.php.

References $draft_date.

Referenced by populateWithDatabaseRecord(), and readByHistoryId().

81  : void
82  {
83  $this->draft_date = $draft_date;
84  }
+ Here is the caller graph for this function:

◆ setDraftId()

ilForumDraftsHistory::setDraftId ( int  $draft_id)

Definition at line 51 of file class.ilForumDraftsHistory.php.

References $draft_id.

Referenced by getFirstAutosaveByDraftId(), getLastAutosaveByDraftId(), populateWithDatabaseRecord(), and readByHistoryId().

51  : void
52  {
53  $this->draft_id = $draft_id;
54  }
+ Here is the caller graph for this function:

◆ setHistoryId()

ilForumDraftsHistory::setHistoryId ( int  $history_id)

Definition at line 41 of file class.ilForumDraftsHistory.php.

References $history_id.

Referenced by addDraftToHistory(), deleteHistoryByDraftIds(), getFirstAutosaveByDraftId(), getLastAutosaveByDraftId(), populateWithDatabaseRecord(), and readByHistoryId().

41  : void
42  {
43  $this->history_id = $history_id;
44  }
+ Here is the caller graph for this function:

◆ setPostMessage()

ilForumDraftsHistory::setPostMessage ( string  $post_message)

Definition at line 71 of file class.ilForumDraftsHistory.php.

References $post_message.

Referenced by getFirstAutosaveByDraftId(), getLastAutosaveByDraftId(), populateWithDatabaseRecord(), and readByHistoryId().

71  : void
72  {
73  $this->post_message = $post_message;
74  }
+ Here is the caller graph for this function:

◆ setPostSubject()

ilForumDraftsHistory::setPostSubject ( string  $post_subject)

Definition at line 61 of file class.ilForumDraftsHistory.php.

References $post_subject.

Referenced by getFirstAutosaveByDraftId(), getLastAutosaveByDraftId(), populateWithDatabaseRecord(), and readByHistoryId().

61  : void
62  {
63  $this->post_subject = $post_subject;
64  }
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilForumDraftsHistory::$db
private

Definition at line 29 of file class.ilForumDraftsHistory.php.

◆ $draft_date

string ilForumDraftsHistory::$draft_date = '0000-00-00 00:00:00'
protected

Definition at line 34 of file class.ilForumDraftsHistory.php.

Referenced by getDraftDate(), and setDraftDate().

◆ $draft_id

int ilForumDraftsHistory::$draft_id = 0
private

Definition at line 31 of file class.ilForumDraftsHistory.php.

Referenced by getDraftId(), and setDraftId().

◆ $history_id

int ilForumDraftsHistory::$history_id = 0
private

Definition at line 30 of file class.ilForumDraftsHistory.php.

Referenced by getHistoryId(), and setHistoryId().

◆ $post_message

string ilForumDraftsHistory::$post_message = ''
private

Definition at line 33 of file class.ilForumDraftsHistory.php.

Referenced by getPostMessage(), and setPostMessage().

◆ $post_subject

string ilForumDraftsHistory::$post_subject = ''
private

Definition at line 32 of file class.ilForumDraftsHistory.php.

Referenced by getPostSubject(), and setPostSubject().

◆ MEDIAOBJECT_TYPE

const ilForumDraftsHistory::MEDIAOBJECT_TYPE = 'frm~h:html'

The documentation for this class was generated from the following file: