ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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'
 

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 117 of file class.ilForumDraftsHistory.php.

References $history_id, and readByHistoryId().

118  {
119  if(isset($history_id) && $history_id > 0 )
120  {
121  $this->readByHistoryId($history_id);
122  }
123  }
+ Here is the call graph for this function:

Member Function Documentation

◆ addDraftToHistory()

ilForumDraftsHistory::addDraftToHistory ( )

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

References $ilDB, array, date, getDraftId(), getPostMessage(), getPostSubject(), and setHistoryId().

227  {
228  global $ilDB;
229 
230  $next_id = $ilDB->nextId('frm_drafts_history');
231  $ilDB->insert('frm_drafts_history',
232  array('history_id' => array('integer', $next_id),
233  'draft_id' => array('integer', $this->getDraftId()),
234  'post_subject' => array('text', $this->getPostSubject()),
235  'post_message' => array('text', $this->getPostMessage()),
236  'draft_date' => array('timestamp', date("Y-m-d H:i:s"))
237  ));
238  $this->setHistoryId($next_id);
239  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ addMobsToDraftsHistory()

ilForumDraftsHistory::addMobsToDraftsHistory (   $message)

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

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

242  {
243  // copy temporary media objects (frm~)
244  include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
245  $mediaObjects = ilRTE::_getMediaObjects($this->getPostMessage(), 0);
246 
247  $myMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~h:html', $this->getHistoryId());
248  foreach($mediaObjects as $mob)
249  {
250  foreach($myMediaObjects as $myMob)
251  {
252  if($mob == $myMob)
253  {
254  // change usage
255  ilObjMediaObject::_removeUsage($mob, 'frm~h:html', $this->getHistoryId());
256  break;
257  }
258  }
259  ilObjMediaObject::_saveUsage($mob, 'frm~h:html', $this->getHistoryId());
260  }
261  }
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 179 of file class.ilForumDraftsHistory.php.

References $ilDB, array, and getHistoryId().

180  {
181  global $ilDB;
182 
183  $ilDB->manipulatef('DELETE FROM frm_drafts_history WHERE history_id = %s',
184  array('integer'), array($this->getHistoryId()));
185  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ deleteHistoryByDraftIds()

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

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

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

Referenced by deleteHistoryByPostIds(), and rollbackAutosave().

322  {
323  global $ilDB;
324 
325  if(count($draft_ids) > 0)
326  {
327  $res = $ilDB->query('SELECT history_id FROM frm_drafts_history
328  WHERE ' . $ilDB->in('draft_id', $draft_ids, false, 'integer'));
329 
330  while($row = $ilDB->fetchAssoc($res))
331  {
332  $this->setHistoryId($row['history_id']);
333  $this->deleteMobs();
334  }
335 
336  $ilDB->manipulate('DELETE FROM frm_drafts_history WHERE '
337  . $ilDB->in('draft_id', $draft_ids, false, 'integer'));
338  }
339  }
global $ilDB
+ 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 298 of file class.ilForumDraftsHistory.php.

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

299  {
300  $draft_ids = array();
301  if(count($post_ids) > 0)
302  {
303  global $ilDB;
304 
305  $res = $ilDB->query('
306  SELECT frm_drafts_history.history_id, frm_drafts_history.draft_id
307  FROM frm_posts_drafts
308  INNER JOIN frm_drafts_history ON frm_posts_drafts.draft_id
309  WHERE ' . $ilDB->in('post_id', $post_ids, false, 'integer'));
310 
311  while($row = $ilDB->fetchAssoc($res))
312  {
313  $draft_ids[] = $row['draft_id'];
314  }
315 
316  $this->deleteHistoryByDraftIds($draft_ids);
317  }
318  return $draft_ids;
319  }
Create styles array
The data for the language used.
deleteHistoryByDraftIds($draft_ids=array())
global $ilDB
+ Here is the call graph for this function:

◆ deleteMobs()

ilForumDraftsHistory::deleteMobs ( )

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

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

Referenced by deleteHistoryByDraftIds().

264  {
265  require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
266  // delete mobs of draft history
267  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~h:html', $this->getHistoryId());
268  foreach($oldMediaObjects as $oldMob)
269  {
270  if(ilObjMediaObject::_exists($oldMob))
271  {
272  ilObjMediaObject::_removeUsage($oldMob, 'frm~h:html', $this->getHistoryId());
273  $mob_obj = new ilObjMediaObject($oldMob);
274  $mob_obj->delete();
275  }
276  }
277  }
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _exists($a_id, $a_reference=false, $a_type=NULL)
checks wether a lm content object with specified id exists or not
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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDraftDate()

ilForumDraftsHistory::getDraftDate ( )
Returns
string

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

References $draft_date.

101  {
102  return $this->draft_date;
103  }

◆ getDraftId()

ilForumDraftsHistory::getDraftId ( )
Returns
int

Definition at line 52 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 190 of file class.ilForumDraftsHistory.php.

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

191  {
192  global $ilDB;
193 
194  $res = $ilDB->queryF('SELECT * FROM frm_drafts_history WHERE draft_id = %s
195  ORDER BY history_id ASC',
196  array('integer'), array((int)$draft_id));
197 
198  if($row = $ilDB->fetchAssoc($res))
199  {
200  $this->setHistoryId($row['history_id']);
201  $this->setDraftId($row['draft_id']);
202  $this->setPostSubject($row['post_subject']);
203  $this->setPostMessage($row['post_message']);
204  }
205  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ getHistoryId()

ilForumDraftsHistory::getHistoryId ( )
Returns
int

Definition at line 36 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 146 of file class.ilForumDraftsHistory.php.

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

Referenced by ilObjForumGUI\doHistoryCheck().

147  {
148  global $ilDB;
149 
150  $res = $ilDB->queryF('SELECT * FROM frm_drafts_history WHERE draft_id = %s ORDER BY draft_date DESC',
151  array('integer'), array((int) $draft_id));
152  $instances = array();
153  while($row = $ilDB->fetchAssoc($res))
154  {
155  $tmp_obj = new self;
156  $tmp_obj = self::populateWithDatabaseRecord($tmp_obj, $row);
157 
158  $instances[] = $tmp_obj;
159  }
160  unset($tmp_obj);
161  return $instances;
162  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getLastAutosaveByDraftId()

ilForumDraftsHistory::getLastAutosaveByDraftId (   $draft_id)
Parameters
$draft_id

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

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

210  {
211  global $ilDB;
212 
213  $res = $ilDB->queryF('SELECT * FROM frm_drafts_history WHERE draft_id = %s
214  ORDER BY history_id DESC',
215  array('integer'), array($draft_id));
216 
217  while($row = $ilDB->fetchAssoc($res))
218  {
219  $this->setHistoryId($row['history_id']);
220  $this->setDraftId($row['draft_id']);
221  $this->setPostSubject($row['post_subject']);
222  $this->setPostMessage($row['post_message']);
223  }
224  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ getPostMessage()

ilForumDraftsHistory::getPostMessage ( )
Returns
string

Definition at line 84 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 68 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
$draftilForumPostDraft
$rowarray

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

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

169  {
170  $history_draft->setHistoryId($row['history_id']);
171  $history_draft->setDraftId($row['draft_id']);
172  $history_draft->setPostMessage($row['post_message']);
173  $history_draft->setPostSubject($row['post_subject']);
174  $history_draft->setDraftDate($row['draft_date']);
175 
176  return $history_draft;
177  }
+ Here is the call graph for this function:

◆ readByHistoryId()

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

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

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

Referenced by __construct().

130  {
131  global $ilDB;
132 
133  $res = $ilDB->queryF('SELECT * FROM frm_drafts_history WHERE history_id = %s',
134  array('integer'), array((int)$history_id));
135 
136  while($row = $ilDB->fetchAssoc($res))
137  {
138  $this->setHistoryId($row['history_id']);
139  $this->setDraftId($row['draft_id']);
140  $this->setPostMessage($row['post_message']);
141  $this->setPostSubject($row['post_subject']);
142  $this->setDraftDate($row['draft_date']);
143  }
144  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rollbackAutosave()

ilForumDraftsHistory::rollbackAutosave ( )

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

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

280  {
281  $draft = ilForumPostDraft::newInstanceByDraftId($this->getDraftId());
282  $draft->setPostSubject($this->getPostSubject());
283  $draft->setPostMessage($this->getPostMessage());
284 
286  self::MEDIAOBJECT_TYPE, $this->getHistoryId(),
287  ilForumPostDraft::MEDIAOBJECT_TYPE, $draft->getDraftId());
288 
289  $draft->updateDraft();
290  $this->deleteHistoryByDraftIds(array($draft->getDraftId()));
291 
292  return $draft;
293  }
static moveMediaObjects($post_message, $source_type, $source_id, $target_type, $target_id, $direction=0)
Create styles array
The data for the language used.
deleteHistoryByDraftIds($draft_ids=array())
+ Here is the call graph for this function:

◆ setDraftDate()

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

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

References $draft_date.

Referenced by populateWithDatabaseRecord(), and readByHistoryId().

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

◆ setDraftId()

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

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

References $draft_id.

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

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

◆ setHistoryId()

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

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

References $history_id.

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

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

◆ setPostMessage()

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

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

References $post_message.

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

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

◆ setPostSubject()

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

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

References $post_subject.

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

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

Field Documentation

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


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