ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilForumDraftsHistory Class Reference

Class ilForumDraftHistory. More...

+ Collaboration diagram for ilForumDraftsHistory:

Public Member Functions

 getHistoryId ()
 
 setHistoryId ($history_id)
 
 getDraftId ()
 
 setDraftId ($draft_id)
 
 getPostSubject ()
 
 setPostSubject ($post_subject)
 
 getPostMessage ()
 
 setPostMessage ($post_message)
 
 getDraftDate ()
 
 setDraftDate ($draft_date)
 
 __construct ($history_id=0)
 ilForumDraftsHistory constructor. More...
 
 delete ()
 
 getFirstAutosaveByDraftId ($draft_id)
 
 getLastAutosaveByDraftId ($draft_id)
 
 addDraftToHistory ()
 
 addMobsToDraftsHistory ($message)
 
 deleteMobs ()
 
 rollbackAutosave ()
 
 deleteHistoryByPostIds ($post_ids=array())
 
 deleteHistoryByDraftIds ($draft_ids=array())
 

Static Public Member Functions

static getInstancesByDraftId ($draft_id)
 

Data Fields

const MEDIAOBJECT_TYPE = 'frm~h:html'
 
 $db
 

Static Protected Member Functions

static populateWithDatabaseRecord (ilForumDraftsHistory $history_draft, array $row)
 

Protected Attributes

 $history_id = 0
 
 $draft_id = 0
 
 $post_subject = ''
 
 $post_message = ''
 
 $draft_date = '0000-00-00 00:00:00'
 

Private Member Functions

 readByHistoryId ($history_id)
 

Detailed Description

Class ilForumDraftHistory.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilForumDraftsHistory::__construct (   $history_id = 0)

ilForumDraftsHistory constructor.

Parameters
int$history_id

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

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

120  {
121  global $DIC;
122  $this->db = $DIC->database();
123 
124  if (isset($history_id) && $history_id > 0) {
126  }
127  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

Member Function Documentation

◆ addDraftToHistory()

ilForumDraftsHistory::addDraftToHistory ( )

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

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

236  {
237  $next_id = $this->db->nextId('frm_drafts_history');
238  $this->db->insert(
239  'frm_drafts_history',
240  array('history_id' => array('integer', $next_id),
241  'draft_id' => array('integer', $this->getDraftId()),
242  'post_subject' => array('text', $this->getPostSubject()),
243  'post_message' => array('text', $this->getPostMessage()),
244  'draft_date' => array('timestamp', date("Y-m-d H:i:s"))
245  )
246  );
247  $this->setHistoryId($next_id);
248  }
+ Here is the call graph for this function:

◆ addMobsToDraftsHistory()

ilForumDraftsHistory::addMobsToDraftsHistory (   $message)

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

References ilRTE\_getMediaObjects(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilObjMediaObject\_saveUsage(), getHistoryId(), and getPostMessage().

251  {
252  // copy temporary media objects (frm~)
253  $mediaObjects = ilRTE::_getMediaObjects($this->getPostMessage(), 0);
254 
255  $myMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~h:html', $this->getHistoryId());
256  foreach ($mediaObjects as $mob) {
257  foreach ($myMediaObjects as $myMob) {
258  if ($mob == $myMob) {
259  // change usage
260  ilObjMediaObject::_removeUsage($mob, 'frm~h:html', $this->getHistoryId());
261  break;
262  }
263  }
264  ilObjMediaObject::_saveUsage($mob, 'frm~h:html', $this->getHistoryId());
265  }
266  }
static _getMediaObjects($a_text, $a_direction=0)
Returns all media objects found in the passed string.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
+ Here is the call graph for this function:

◆ delete()

ilForumDraftsHistory::delete ( )

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

References getHistoryId().

188  {
189  $this->db->manipulatef(
190  'DELETE FROM frm_drafts_history WHERE history_id = %s',
191  array('integer'),
192  array($this->getHistoryId())
193  );
194  }
+ Here is the call graph for this function:

◆ deleteHistoryByDraftIds()

ilForumDraftsHistory::deleteHistoryByDraftIds (   $draft_ids = array())

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

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

Referenced by deleteHistoryByPostIds(), and rollbackAutosave().

324  {
325  if (count($draft_ids) > 0) {
326  $res = $this->db->query('SELECT history_id FROM frm_drafts_history
327  WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
328 
329  while ($row = $this->db->fetchAssoc($res)) {
330  $this->setHistoryId($row['history_id']);
331  $this->deleteMobs();
332  }
333 
334  $this->db->manipulate('DELETE FROM frm_drafts_history WHERE '
335  . $this->db->in('draft_id', $draft_ids, false, 'integer'));
336  }
337  }
foreach($_POST as $key=> $value) $res
$row
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteHistoryByPostIds()

ilForumDraftsHistory::deleteHistoryByPostIds (   $post_ids = array())
Parameters
array$post_ids

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

References $res, $row, and deleteHistoryByDraftIds().

305  {
306  $draft_ids = array();
307  if (count($post_ids) > 0) {
308  $res = $this->db->query('
309  SELECT frm_drafts_history.history_id, frm_drafts_history.draft_id
310  FROM frm_posts_drafts
311  INNER JOIN frm_drafts_history ON frm_posts_drafts.draft_id
312  WHERE ' . $this->db->in('post_id', $post_ids, false, 'integer'));
313 
314  while ($row = $this->db->fetchAssoc($res)) {
315  $draft_ids[] = $row['draft_id'];
316  }
317 
318  $this->deleteHistoryByDraftIds($draft_ids);
319  }
320  return $draft_ids;
321  }
foreach($_POST as $key=> $value) $res
$row
deleteHistoryByDraftIds($draft_ids=array())
+ Here is the call graph for this function:

◆ deleteMobs()

ilForumDraftsHistory::deleteMobs ( )

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

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

Referenced by deleteHistoryByDraftIds().

269  {
270  // delete mobs of draft history
271  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~h:html', $this->getHistoryId());
272  foreach ($oldMediaObjects as $oldMob) {
273  if (ilObjMediaObject::_exists($oldMob)) {
274  ilObjMediaObject::_removeUsage($oldMob, 'frm~h:html', $this->getHistoryId());
275  $mob_obj = new ilObjMediaObject($oldMob);
276  $mob_obj->delete();
277  }
278  }
279  }
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
Class ilObjMediaObject.
static _exists($a_id, $a_reference=false, $a_type=null)
checks wether a lm content object with specified id exists or not
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDraftDate()

ilForumDraftsHistory::getDraftDate ( )
Returns
string

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

References $draft_date.

103  {
104  return $this->draft_date;
105  }

◆ getDraftId()

ilForumDraftsHistory::getDraftId ( )
Returns
int

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

References $draft_id.

Referenced by addDraftToHistory(), and rollbackAutosave().

+ Here is the caller graph for this function:

◆ getFirstAutosaveByDraftId()

ilForumDraftsHistory::getFirstAutosaveByDraftId (   $draft_id)
Parameters
$draft_id

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

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

200  {
201  $res = $this->db->queryF(
202  'SELECT * FROM frm_drafts_history WHERE draft_id = %s
203  ORDER BY history_id ASC',
204  array('integer'),
205  array((int) $draft_id)
206  );
207 
208  if ($row = $this->db->fetchAssoc($res)) {
209  $this->setHistoryId($row['history_id']);
210  $this->setDraftId($row['draft_id']);
211  $this->setPostSubject($row['post_subject']);
212  $this->setPostMessage($row['post_message']);
213  }
214  }
foreach($_POST as $key=> $value) $res
$row
+ Here is the call graph for this function:

◆ getHistoryId()

ilForumDraftsHistory::getHistoryId ( )
Returns
int

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

References $history_id.

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

+ Here is the caller graph for this function:

◆ getInstancesByDraftId()

static ilForumDraftsHistory::getInstancesByDraftId (   $draft_id)
static

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

References $DIC, $draft_id, $ilDB, $res, and $row.

Referenced by ilObjForumGUI\doHistoryCheck().

151  {
152  global $DIC;
153  $ilDB = $DIC->database();
154 
155  $res = $ilDB->queryF(
156  'SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY draft_date DESC',
157  array('integer'),
158  array((int) $draft_id)
159  );
160  $instances = array();
161  while ($row = $ilDB->fetchAssoc($res)) {
162  $tmp_obj = new self;
163  $tmp_obj = self::populateWithDatabaseRecord($tmp_obj, $row);
164 
165  $instances[] = $tmp_obj;
166  }
167  unset($tmp_obj);
168  return $instances;
169  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getLastAutosaveByDraftId()

ilForumDraftsHistory::getLastAutosaveByDraftId (   $draft_id)
Parameters
$draft_id

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

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

219  {
220  $res = $this->db->queryF(
221  'SELECT * FROM frm_drafts_history WHERE draft_id = %s
222  ORDER BY history_id DESC',
223  array('integer'),
224  array($draft_id)
225  );
226 
227  while ($row = $this->db->fetchAssoc($res)) {
228  $this->setHistoryId($row['history_id']);
229  $this->setDraftId($row['draft_id']);
230  $this->setPostSubject($row['post_subject']);
231  $this->setPostMessage($row['post_message']);
232  }
233  }
foreach($_POST as $key=> $value) $res
$row
+ Here is the call graph for this function:

◆ getPostMessage()

ilForumDraftsHistory::getPostMessage ( )
Returns
string

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

References $post_message.

Referenced by addDraftToHistory(), addMobsToDraftsHistory(), and rollbackAutosave().

+ Here is the caller graph for this function:

◆ getPostSubject()

ilForumDraftsHistory::getPostSubject ( )
Returns
string

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

References $post_subject.

Referenced by addDraftToHistory(), and rollbackAutosave().

+ Here is the caller graph for this function:

◆ populateWithDatabaseRecord()

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

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

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

177  {
178  $history_draft->setHistoryId($row['history_id']);
179  $history_draft->setDraftId($row['draft_id']);
180  $history_draft->setPostMessage($row['post_message']);
181  $history_draft->setPostSubject($row['post_subject']);
182  $history_draft->setDraftDate($row['draft_date']);
183 
184  return $history_draft;
185  }
$row
+ Here is the call graph for this function:

◆ readByHistoryId()

ilForumDraftsHistory::readByHistoryId (   $history_id)
private
Parameters
$history_id
Returns
ilForumDraftsHistory

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

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

Referenced by __construct().

134  {
135  $res = $this->db->queryF(
136  'SELECT * FROM frm_drafts_history WHERE history_id = %s',
137  array('integer'),
138  array((int) $history_id)
139  );
140 
141  while ($row = $this->db->fetchAssoc($res)) {
142  $this->setHistoryId($row['history_id']);
143  $this->setDraftId($row['draft_id']);
144  $this->setPostMessage($row['post_message']);
145  $this->setPostSubject($row['post_subject']);
146  $this->setDraftDate($row['draft_date']);
147  }
148  }
foreach($_POST as $key=> $value) $res
$row
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rollbackAutosave()

ilForumDraftsHistory::rollbackAutosave ( )

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

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

282  {
284  $draft->setPostSubject($this->getPostSubject());
285  $draft->setPostMessage($this->getPostMessage());
286 
288  $this->getPostMessage(),
289  self::MEDIAOBJECT_TYPE,
290  $this->getHistoryId(),
292  $draft->getDraftId()
293  );
294 
295  $draft->updateDraft();
296  $this->deleteHistoryByDraftIds(array($draft->getDraftId()));
297 
298  return $draft;
299  }
static moveMediaObjects($post_message, $source_type, $source_id, $target_type, $target_id, $direction=0)
static newInstanceByDraftId($draft_id)
deleteHistoryByDraftIds($draft_ids=array())
+ Here is the call graph for this function:

◆ setDraftDate()

ilForumDraftsHistory::setDraftDate (   $draft_date)
Parameters
string$draft_date

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

References $draft_date.

Referenced by populateWithDatabaseRecord(), and readByHistoryId().

111  {
112  $this->draft_date = $draft_date;
113  }
+ Here is the caller graph for this function:

◆ setDraftId()

ilForumDraftsHistory::setDraftId (   $draft_id)
Parameters
int$draft_id

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

References $draft_id.

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

63  {
64  $this->draft_id = $draft_id;
65  }
+ Here is the caller graph for this function:

◆ setHistoryId()

ilForumDraftsHistory::setHistoryId (   $history_id)
Parameters
int$history_id

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

References $history_id.

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

47  {
48  $this->history_id = $history_id;
49  }
+ Here is the caller graph for this function:

◆ setPostMessage()

ilForumDraftsHistory::setPostMessage (   $post_message)
Parameters
string$post_message

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

References $post_message.

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

95  {
96  $this->post_message = $post_message;
97  }
+ Here is the caller graph for this function:

◆ setPostSubject()

ilForumDraftsHistory::setPostSubject (   $post_subject)
Parameters
string$post_subject

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

References $post_subject.

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

79  {
80  $this->post_subject = $post_subject;
81  }
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilForumDraftsHistory::$db

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

◆ $draft_date

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

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

Referenced by getDraftDate(), and setDraftDate().

◆ $draft_id

ilForumDraftsHistory::$draft_id = 0
protected

◆ $history_id

ilForumDraftsHistory::$history_id = 0
protected

◆ $post_message

ilForumDraftsHistory::$post_message = ''
protected

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

Referenced by getPostMessage(), and setPostMessage().

◆ $post_subject

ilForumDraftsHistory::$post_subject = ''
protected

Definition at line 22 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: