ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 
 populateWithFirstAutosaveByDraftId (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

readonly 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.

87 {
88 global $DIC;
89
90 $this->db = $DIC->database();
91
92 if ($history_id > 0) {
94 }
95 }
global $DIC
Definition: shib_login.php:26

References $DIC, $history_id, and readByHistoryId().

+ Here is the call graph for this function:

Member Function Documentation

◆ addDraftToHistory()

ilForumDraftsHistory::addDraftToHistory ( )

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

195 : void
196 {
197 $next_id = $this->db->nextId('frm_drafts_history');
198 $this->db->insert(
199 'frm_drafts_history',
200 [
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")]
206 ]
207 );
208 $this->setHistoryId($next_id);
209 }

◆ delete()

ilForumDraftsHistory::delete ( )

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

152 : void
153 {
154 $this->db->manipulateF(
155 'DELETE FROM frm_drafts_history WHERE history_id = %s',
156 ['integer'],
157 [$this->getHistoryId()]
158 );
159 }

◆ deleteHistoryByDraftIds()

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

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

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

References $res.

◆ deleteHistoryByPostIds()

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

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

247 : array
248 {
249 $draft_ids = [];
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'));
256
257 while ($row = $this->db->fetchAssoc($res)) {
258 $draft_ids[] = (int) $row['draft_id'];
259 }
260
261 $this->deleteHistoryByDraftIds($draft_ids);
262 }
263
264 return $draft_ids;
265 }
deleteHistoryByDraftIds(array $draft_ids=[])

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

+ Here is the call graph for this function:

◆ deleteMobs()

ilForumDraftsHistory::deleteMobs ( )

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

211 : void
212 {
213 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~h:html', $this->getHistoryId());
214 foreach ($oldMediaObjects as $oldMob) {
215 if (ilObjMediaObject::_exists($oldMob)) {
216 ilObjMediaObject::_removeUsage($oldMob, 'frm~h:html', $this->getHistoryId());
217 $mob_obj = new ilObjMediaObject($oldMob);
218 $mob_obj->delete();
219 }
220 }
221 }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
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.

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

+ Here is the call graph for this function:

◆ getDraftDate()

ilForumDraftsHistory::getDraftDate ( )

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

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

References $draft_date.

◆ getDraftId()

ilForumDraftsHistory::getDraftId ( )

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

46 : int
47 {
48 return $this->draft_id;
49 }

References $draft_id.

◆ getHistoryId()

ilForumDraftsHistory::getHistoryId ( )

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

36 : int
37 {
38 return $this->history_id;
39 }

References $history_id.

◆ getInstancesByDraftId()

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

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

117 : array
118 {
119 global $DIC;
120
121 $ilDB = $DIC->database();
122
123 $res = $ilDB->queryF(
124 'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY draft_date DESC',
125 ['integer'],
126 [$draft_id]
127 );
128 $instances = [];
129 while ($row = $ilDB->fetchAssoc($res)) {
130 $draftHistory = new self();
131 $draftHistory = self::populateWithDatabaseRecord($draftHistory, $row);
132
133 $instances[] = $draftHistory;
134 }
135
136 return $instances;
137 }
static populateWithDatabaseRecord(ilForumDraftsHistory $history_draft, array $row)

References $DIC, $draft_id, $ilDB, $res, and populateWithDatabaseRecord().

Referenced by ilObjForumGUI\doHistoryCheck().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastAutosaveByDraftId()

ilForumDraftsHistory::getLastAutosaveByDraftId ( int  $draft_id)

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

178 : void
179 {
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',
183 ['integer'],
184 [$draft_id]
185 );
186
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']);
192 }
193 }
setPostSubject(string $post_subject)
setPostMessage(string $post_message)

References $res.

◆ getPostMessage()

ilForumDraftsHistory::getPostMessage ( )

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

66 : string
67 {
69 }

References $post_message.

◆ getPostSubject()

ilForumDraftsHistory::getPostSubject ( )

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

56 : string
57 {
59 }

References $post_subject.

◆ populateWithDatabaseRecord()

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

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

143 $history_draft->setHistoryId((int) $row['history_id']);
144 $history_draft->setDraftId((int) $row['draft_id']);
145 $history_draft->setPostMessage($row['post_message']);
146 $history_draft->setPostSubject($row['post_subject']);
147 $history_draft->setDraftDate($row['draft_date']);
148
149 return $history_draft;
150 }
Class ilForumDraftHistory.
setDraftDate(string $draft_date)

Referenced by getInstancesByDraftId().

+ Here is the caller graph for this function:

◆ populateWithFirstAutosaveByDraftId()

ilForumDraftsHistory::populateWithFirstAutosaveByDraftId ( int  $draft_id)

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

161 : void
162 {
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',
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 }

References $res.

◆ readByHistoryId()

ilForumDraftsHistory::readByHistoryId ( int  $history_id)
private

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

97 : void
98 {
99 $res = $this->db->queryF(
100 'SELECT * FROM frm_drafts_history WHERE history_id = %s',
101 ['integer'],
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 }

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rollbackAutosave()

ilForumDraftsHistory::rollbackAutosave ( )

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

224 {
226 $draft->setPostSubject($this->getPostSubject());
227 $draft->setPostMessage($this->getPostMessage());
228
230 $this->getPostMessage(),
231 self::MEDIAOBJECT_TYPE,
232 $this->getHistoryId(),
234 $draft->getDraftId()
235 );
236
237 $draft->updateDraft();
238 $this->deleteHistoryByDraftIds([$draft->getDraftId()]);
239
240 return $draft;
241 }
Class ilForumPostDraft.
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)

References ilForumPostDraft\MEDIAOBJECT_TYPE, ilForumUtil\moveMediaObjects(), and ilForumPostDraft\newInstanceByDraftId().

+ Here is the call graph for this function:

◆ setDraftDate()

ilForumDraftsHistory::setDraftDate ( string  $draft_date)

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

81 : void
82 {
83 $this->draft_date = $draft_date;
84 }

References $draft_date.

Referenced by readByHistoryId().

+ Here is the caller graph for this function:

◆ setDraftId()

ilForumDraftsHistory::setDraftId ( int  $draft_id)

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

51 : void
52 {
53 $this->draft_id = $draft_id;
54 }

References $draft_id.

Referenced by readByHistoryId().

+ Here is the caller graph for this function:

◆ setHistoryId()

ilForumDraftsHistory::setHistoryId ( int  $history_id)

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

41 : void
42 {
43 $this->history_id = $history_id;
44 }

References $history_id.

Referenced by readByHistoryId().

+ Here is the caller graph for this function:

◆ setPostMessage()

ilForumDraftsHistory::setPostMessage ( string  $post_message)

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

71 : void
72 {
73 $this->post_message = $post_message;
74 }

References $post_message.

Referenced by readByHistoryId().

+ Here is the caller graph for this function:

◆ setPostSubject()

ilForumDraftsHistory::setPostSubject ( string  $post_subject)

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

61 : void
62 {
63 $this->post_subject = $post_subject;
64 }

References $post_subject.

Referenced by readByHistoryId().

+ Here is the caller graph for this function:

Field Documentation

◆ $db

readonly 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(), getInstancesByDraftId(), and setDraftId().

◆ $history_id

int ilForumDraftsHistory::$history_id = 0
private

◆ $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: