ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilForumPostDraft Class Reference

Class ilForumPostDraft. More...

+ Collaboration diagram for ilForumPostDraft:

Public Member Functions

 getPostNotify ()
 
 setPostNotify ($post_notify)
 
 getDraftId ()
 
 setDraftId ($draft_id)
 
 getPostId ()
 
 setPostId ($post_id)
 
 getForumId ()
 
 setForumId ($forum_id)
 
 getThreadId ()
 
 setThreadId ($thread_id)
 
 getPostSubject ()
 
 setPostSubject ($post_subject)
 
 getPostMessage ()
 
 setPostMessage ($post_message)
 
 getPostDate ()
 
 setPostDate ($post_date)
 
 getPostUpdate ()
 
 setPostUpdate ($post_update)
 
 getUpdateUserId ()
 
 setUpdateUserId ($update_user_id)
 
 getPostUserAlias ()
 
 setPostUserAlias ($post_user_alias)
 
 getPostAuthorId ()
 
 setPostAuthorId ($post_author_id)
 
 getPostDisplayUserId ()
 
 setPostDisplayUserId ($post_display_user_id)
 
 getNotify ()
 
 setNotify ($notify)
 
 __construct ($user_id=0, $post_id=0, $draft_id=0)
 ilForumPostDraft constructor. More...
 
 saveDraft ()
 
 updateDraft ()
 
 deleteDraft ()
 
 deleteDraftsByPostIds (array $post_ids=array())
 
 deleteDraftsByDraftIds (array $draft_ids=array())
 

Static Public Member Functions

static getSortedDrafts (int $usrId, int $threadId, int $sorting=ilForumProperties::VIEW_DATE_ASC)
 
static getDraftInstancesByUserId ($user_id)
 
static getInstancesByUserIdAndThreadId ($user_id, $thread_id)
 
static newInstanceByDraftId ($draft_id)
 
static newInstanceByHistorytId ($history_id)
 
static deleteMobsOfDraft ($draft_id)
 
static deleteDraftsByUserId ($user_id)
 
static isSavePostDraftAllowed ()
 
static isAutoSavePostDraftAllowed ()
 
static lookupAutosaveInterval ()
 
static getDraftsStatisticsByRefId ($ref_id)
 
static moveDraftsByMergedThreads ($source_thread_id, $target_thread_id)
 
static moveDraftsByMovedThread ($thread_ids, $source_ref_id, $target_ref_id)
 
static getThreadDraftData ($post_author_id, $forum_id)
 
static createDraftBackup ($draft_id)
 

Data Fields

const MEDIAOBJECT_TYPE = 'frm~d:html'
 

Protected Member Functions

 readDraft ()
 

Static Protected Member Functions

static populateWithDatabaseRecord (ilForumPostDraft $draft, array $row)
 
static readDrafts ($user_id)
 

Protected Attributes

 $draft_id = 0
 
 $post_id = 0
 
 $forum_id = 0
 
 $thread_id = 0
 
 $post_subject = ''
 
 $post_message = ''
 
 $post_date = '0000-00-00 00:00:00'
 
 $post_update = '0000-00-00 00:00:00'
 
 $update_user_id = 0
 
 $post_user_alias = ''
 
 $post_author_id = 0
 
 $post_display_user_id = 0
 
 $notify = 0
 
 $post_notify = 0
 

Static Protected Attributes

static $forum_statistics_cache = array()
 
static $drafts_settings_cache = array()
 

Static Private Attributes

static $instances = array()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilForumPostDraft::__construct (   $user_id = 0,
  $post_id = 0,
  $draft_id = 0 
)

ilForumPostDraft constructor.

Parameters
int$user_id
int$post_id

Definition at line 335 of file class.ilForumPostDraft.php.

References $DIC, $draft_id, $post_id, readDraft(), setDraftId(), setPostAuthorId(), and setPostId().

336  {
337  global $DIC;
338 
339  $this->db = $DIC->database();
340 
341  if ($user_id && $post_id && $draft_id) {
342  $this->setPostAuthorId($user_id);
343  $this->setPostId($post_id);
344  $this->setDraftId($draft_id);
345  $this->readDraft();
346  }
347  }
setPostAuthorId($post_author_id)
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ createDraftBackup()

static ilForumPostDraft::createDraftBackup (   $draft_id)
static
Parameters
$draft_id

Definition at line 797 of file class.ilForumPostDraft.php.

References $DIC, $draft_id, $ilDB, $res, ilForumDraftsHistory\MEDIAOBJECT_TYPE, and ilForumUtil\moveMediaObjects().

Referenced by ilObjForumGUI\doHistoryCheck(), and ilObjForumGUI\restoreFromHistoryObject().

798  {
799  global $DIC;
800  $ilDB = $DIC->database();
801 
802  $res = $ilDB->queryF(
803  'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
804  array('integer'),
805  array((int) $draft_id)
806  );
807 
808  while ($row = $ilDB->fetchAssoc($res)) {
809  $tmp_obj = new self;
810  self::populateWithDatabaseRecord($tmp_obj, $row);
811  }
812 
813  $history_obj = new ilForumDraftsHistory();
814  $history_obj->deleteHistoryByDraftIds(array($draft_id));
815 
816  $history_obj->setDraftId($draft_id);
817  $history_obj->setPostSubject($tmp_obj->getPostSubject());
818  $history_obj->setPostMessage($tmp_obj->getPostMessage());
819  $history_obj->addDraftToHistory();
820 
822  $tmp_obj->getPostMessage(),
823  self::MEDIAOBJECT_TYPE,
824  $draft_id,
826  $history_obj->getHistoryId()
827  );
828  }
static moveMediaObjects($post_message, $source_type, $source_id, $target_type, $target_id, $direction=0)
Class ilForumDraftHistory.
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteDraft()

ilForumPostDraft::deleteDraft ( )

Definition at line 555 of file class.ilForumPostDraft.php.

References getDraftId().

Referenced by ilObjForumGUI\createThread(), and ilObjForumGUI\publishDraftObject().

556  {
557  $this->db->manipulateF(
558  'DELETE FROM frm_posts_drafts WHERE draft_id = %s',
559  array('integer'),
560  array($this->getDraftId())
561  );
562  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteDraftsByDraftIds()

ilForumPostDraft::deleteDraftsByDraftIds ( array  $draft_ids = array())
Parameters
array$draft_ids

Definition at line 605 of file class.ilForumPostDraft.php.

References $draft_id.

606  {
607  foreach ($draft_ids as $draft_id) {
608  self::deleteMobsOfDraft($draft_id);
609 
610  // delete attachments of draft
611  $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
612  $objFileDataForumDrafts->delete();
613  }
614  $this->db->manipulate('DELETE FROM frm_drafts_history WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
615  $this->db->manipulate('DELETE FROM frm_posts_drafts WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
616  }
This class handles all operations on files for the drafts of a forum object.

◆ deleteDraftsByPostIds()

ilForumPostDraft::deleteDraftsByPostIds ( array  $post_ids = array())
Parameters
array$post_ids

Definition at line 583 of file class.ilForumPostDraft.php.

References $draft_id, and $res.

584  {
585  $draft_ids = array();
586  $res = $this->db->query('SELECT draft_id FROM frm_posts_drafts WHERE ' . $this->db->in('post_id', $post_ids, false, 'integer'));
587  while ($row = $this->db->fetchAssoc($res)) {
588  $draft_ids[] = $row['draft_id'];
589  }
590 
591  foreach ($draft_ids as $draft_id) {
592  self::deleteMobsOfDraft($draft_id);
593 
594  // delete attachments of draft
595  $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
596  $objFileDataForumDrafts->delete();
597  }
598  $this->db->manipulate('DELETE FROM frm_drafts_history WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
599  $this->db->manipulate('DELETE FROM frm_posts_drafts WHERE ' . $this->db->in('draft_id', $draft_ids, false, 'integer'));
600  }
This class handles all operations on files for the drafts of a forum object.
foreach($_POST as $key=> $value) $res

◆ deleteDraftsByUserId()

static ilForumPostDraft::deleteDraftsByUserId (   $user_id)
static
Parameters
int$user_id

Definition at line 621 of file class.ilForumPostDraft.php.

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

622  {
623  global $DIC;
624  $ilDB = $DIC->database();
625 
626  $res = $ilDB->queryF(
627  'SELECT draft_id FROM frm_posts_drafts WHERE post_author_id = %s',
628  array('integer'),
629  array($user_id)
630  );
631 
632  $draft_ids = array();
633  while ($row = $ilDB->fetchAssoc($res)) {
634  $draft_ids[] = $row['draft_id'];
635  }
636 
637  foreach ($draft_ids as $draft_id) {
638  self::deleteMobsOfDraft($draft_id);
639 
640  // delete attachments of draft
641  $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_id);
642  $objFileDataForumDrafts->delete();
643  }
644 
645  $ilDB->manipulate('DELETE FROM frm_drafts_history WHERE ' . $ilDB->in('draft_id', $draft_ids, false, 'integer'));
646  $ilDB->manipulateF(
647  'DELETE FROM frm_posts_drafts WHERE post_author_id = %s',
648  array('integer'),
649  array($user_id)
650  );
651  }
This class handles all operations on files for the drafts of a forum object.
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46

◆ deleteMobsOfDraft()

static ilForumPostDraft::deleteMobsOfDraft (   $draft_id)
static
Parameters
$draft_id

Definition at line 567 of file class.ilForumPostDraft.php.

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

568  {
569  // delete mobs of draft
570  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draft_id);
571  foreach ($oldMediaObjects as $oldMob) {
572  if (ilObjMediaObject::_exists($oldMob)) {
573  ilObjMediaObject::_removeUsage($oldMob, 'frm~d:html', $draft_id);
574  $mob_obj = new ilObjMediaObject($oldMob);
575  $mob_obj->delete();
576  }
577  }
578  }
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:

◆ getDraftId()

ilForumPostDraft::getDraftId ( )
Returns
int

Definition at line 125 of file class.ilForumPostDraft.php.

References $draft_id.

Referenced by ilObjForumGUI\createThread(), ilObjForumGUI\createTopLevelPostObject(), deleteDraft(), readDraft(), and updateDraft().

126  {
127  return $this->draft_id;
128  }
+ Here is the caller graph for this function:

◆ getDraftInstancesByUserId()

static ilForumPostDraft::getDraftInstancesByUserId (   $user_id)
static
Parameters
int$user_id
Returns
[]

Definition at line 443 of file class.ilForumPostDraft.php.

Referenced by ilObjForumGUI\confirmDeleteThreadDraftsObject(), ilObjForumGUI\deleteThreadDraftsObject(), and ilForumDraftsDerivedTaskProvider\getTasks().

443  : array
444  {
445  if (!self::$instances[$user_id]) {
446  self::readDrafts($user_id);
447  }
448 
449  return self::$instances[$user_id]['draft_ids'];
450  }
+ Here is the caller graph for this function:

◆ getDraftsStatisticsByRefId()

static ilForumPostDraft::getDraftsStatisticsByRefId (   $ref_id)
static
Parameters
$ref_id
Returns
mixed

Definition at line 695 of file class.ilForumPostDraft.php.

References $DIC, $ilDB, $ilUser, $res, and ilObjForum\lookupForumIdByRefId().

Referenced by ilForumTopicTableGUI\fillRow(), and ilObjForumListGUI\getProperties().

696  {
697  global $DIC;
698  $ilDB = $DIC->database();
699  $ilUser = $DIC->user();
700 
701  if (!isset(self::$forum_statistics_cache[$ref_id][$ilUser->getId()])) {
702  $forumId = ilObjForum::lookupForumIdByRefId($ref_id);
703 
704  $res = $ilDB->queryF(
705  '
706  SELECT COUNT(draft_id) num_drafts, thread_id FROM frm_posts_drafts
707  WHERE forum_id = %s AND post_author_id = %s
708  GROUP BY thread_id',
709  array('integer', 'integer'),
710  array($forumId, $ilUser->getId())
711  );
712 
713  $num_drafts_total = 0;
714 
715  while ($row = $ilDB->fetchAssoc($res)) {
716  $num_drafts_total += $row['num_drafts'];
717  self::$forum_statistics_cache[$ref_id][$ilUser->getId()][$row['thread_id']] = $row['num_drafts'];
718  }
719 
720  self::$forum_statistics_cache[$ref_id][$ilUser->getId()]['total'] = $num_drafts_total;
721  }
722  return self::$forum_statistics_cache[$ref_id][$ilUser->getId()];
723  }
static lookupForumIdByRefId($ref_id)
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getForumId()

ilForumPostDraft::getForumId ( )
Returns
int

Definition at line 157 of file class.ilForumPostDraft.php.

References $forum_id.

Referenced by saveDraft().

158  {
159  return $this->forum_id;
160  }
+ Here is the caller graph for this function:

◆ getInstancesByUserIdAndThreadId()

static ilForumPostDraft::getInstancesByUserIdAndThreadId (   $user_id,
  $thread_id 
)
static
Parameters
$user_id
$thread_id
Returns
[]

Definition at line 457 of file class.ilForumPostDraft.php.

References $thread_id.

457  : array
458  {
459  if (!self::$instances[$user_id]) {
460  self::readDrafts($user_id);
461  }
462 
463  if (isset(self::$instances[$user_id][$thread_id])) {
464  return self::$instances[$user_id][$thread_id];
465  }
466 
467  return [];
468  }

◆ getNotify()

ilForumPostDraft::getNotify ( )
Returns
int

Definition at line 317 of file class.ilForumPostDraft.php.

References $notify.

Referenced by ilObjForumGUI\createThread(), and saveDraft().

318  {
319  return $this->notify;
320  }
+ Here is the caller graph for this function:

◆ getPostAuthorId()

ilForumPostDraft::getPostAuthorId ( )
Returns
int

Definition at line 285 of file class.ilForumPostDraft.php.

References $post_author_id.

Referenced by ilObjForumGUI\createThread(), readDraft(), and saveDraft().

286  {
287  return $this->post_author_id;
288  }
+ Here is the caller graph for this function:

◆ getPostDate()

ilForumPostDraft::getPostDate ( )
Returns
string

Definition at line 221 of file class.ilForumPostDraft.php.

References $post_date.

222  {
223  return $this->post_date;
224  }

◆ getPostDisplayUserId()

ilForumPostDraft::getPostDisplayUserId ( )
Returns
int

Definition at line 301 of file class.ilForumPostDraft.php.

References $post_display_user_id.

Referenced by ilObjForumGUI\createThread(), and saveDraft().

302  {
304  }
+ Here is the caller graph for this function:

◆ getPostId()

ilForumPostDraft::getPostId ( )
Returns
int

Definition at line 141 of file class.ilForumPostDraft.php.

References $post_id.

Referenced by readDraft(), and saveDraft().

142  {
143  return $this->post_id;
144  }
+ Here is the caller graph for this function:

◆ getPostMessage()

ilForumPostDraft::getPostMessage ( )
Returns
string

Definition at line 205 of file class.ilForumPostDraft.php.

References $post_message.

Referenced by saveDraft(), and updateDraft().

206  {
207  return $this->post_message;
208  }
+ Here is the caller graph for this function:

◆ getPostNotify()

ilForumPostDraft::getPostNotify ( )
Returns
int

Definition at line 109 of file class.ilForumPostDraft.php.

References $post_notify.

Referenced by ilObjForumGUI\createThread(), and saveDraft().

110  {
111  return $this->post_notify;
112  }
+ Here is the caller graph for this function:

◆ getPostSubject()

ilForumPostDraft::getPostSubject ( )
Returns
string

Definition at line 189 of file class.ilForumPostDraft.php.

References $post_subject.

Referenced by saveDraft(), and updateDraft().

190  {
191  return $this->post_subject;
192  }
+ Here is the caller graph for this function:

◆ getPostUpdate()

ilForumPostDraft::getPostUpdate ( )
Returns
string

Definition at line 237 of file class.ilForumPostDraft.php.

References $post_update.

238  {
239  return $this->post_update;
240  }

◆ getPostUserAlias()

ilForumPostDraft::getPostUserAlias ( )
Returns
string

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

References $post_user_alias.

Referenced by ilObjForumGUI\createThread(), saveDraft(), and updateDraft().

270  {
271  return $this->post_user_alias;
272  }
+ Here is the caller graph for this function:

◆ getSortedDrafts()

static ilForumPostDraft::getSortedDrafts ( int  $usrId,
int  $threadId,
int  $sorting = ilForumProperties::VIEW_DATE_ASC 
)
static
Parameters
int$usrId
int$threadId
int$sorting
Returns
ilForumPostDraft[]|array<int, ilForumPostDraft[]>

Definition at line 397 of file class.ilForumPostDraft.php.

References $DIC, $ilDB, $res, ilForumProperties\VIEW_DATE_DESC, and ilForumProperties\VIEW_TREE.

Referenced by ilObjForumGUI\checkUsersViewMode().

401  : array {
402  global $DIC;
403  $ilDB = $DIC->database();
404 
405  $drafts = [];
406 
407  $orderColumn = ' ';
408  $orderDirection = ' ';
409 
410  if ($sorting !== ilForumProperties::VIEW_TREE) {
411  $orderColumn = ' ORDER BY post_date ';
412  $orderDirection = 'ASC';
413  if ($sorting === ilForumProperties::VIEW_DATE_DESC) {
414  $orderDirection = 'DESC';
415  }
416  }
417 
418  $res = $ilDB->queryF(
419  'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s AND thread_id = %s' .
420  $orderColumn . $orderDirection,
421  ['integer', 'integer'],
422  [$usrId, $threadId]
423  );
424 
425  while ($row = $ilDB->fetchAssoc($res)) {
426  $draft = new ilForumPostDraft();
427  self::populateWithDatabaseRecord($draft, $row);
428  $drafts[] = $draft;
429  self::$instances[$usrId][$threadId][$draft->getPostId()][] = $draft;
430  }
431 
432  if (ilForumProperties::VIEW_TREE === $sorting) {
433  return self::$instances[$usrId][$threadId] ?? [];
434  }
435 
436  return $drafts;
437  }
Class ilForumPostDraft.
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ getThreadDraftData()

static ilForumPostDraft::getThreadDraftData (   $post_author_id,
  $forum_id 
)
static
Parameters
$post_author_id
$forum_id
Returns
array

Definition at line 770 of file class.ilForumPostDraft.php.

References $DIC, $forum_id, $ilDB, $post_author_id, and $res.

Referenced by ilObjForumGUI\getContent().

771  {
772  global $DIC;
773  $ilDB = $DIC->database();
774 
775  $res = $ilDB->queryF(
776  'SELECT * FROM frm_posts_drafts
777  WHERE post_author_id = %s
778  AND forum_id = %s
779  AND thread_id = %s
780  AND post_id = %s
781  ORDER BY post_date DESC',
782  array('integer', 'integer', 'integer', 'integer'),
783  array($post_author_id, $forum_id, 0, 0)
784  );
785  $draft_data = array();
786  while ($row = $ilDB->fetchAssoc($res)) {
787  $tmp_obj = new self;
788  self::populateWithDatabaseRecord($tmp_obj, $row);
789  $draft_data[] = array('subject' => $tmp_obj->getPostSubject(), 'post_update' => $tmp_obj->getPostUpdate(), 'draft_id' => $tmp_obj->getDraftId());
790  }
791  return $draft_data;
792  }
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ getThreadId()

ilForumPostDraft::getThreadId ( )
Returns
int

Definition at line 173 of file class.ilForumPostDraft.php.

References $thread_id.

Referenced by saveDraft().

174  {
175  return $this->thread_id;
176  }
+ Here is the caller graph for this function:

◆ getUpdateUserId()

ilForumPostDraft::getUpdateUserId ( )
Returns
int

Definition at line 253 of file class.ilForumPostDraft.php.

References $update_user_id.

254  {
255  return $this->update_user_id;
256  }

◆ isAutoSavePostDraftAllowed()

static ilForumPostDraft::isAutoSavePostDraftAllowed ( )
static
Returns
bool

Definition at line 668 of file class.ilForumPostDraft.php.

References $DIC.

Referenced by ilObjForumGUI\cancelDraftObject(), ilObjForumGUI\decorateWithAutosave(), ilObjForumGUI\doHistoryCheck(), ilObjForumGUI\editDraftObject(), ilForumAutoSaveAsyncDraftAction\executeAndGetResponseObject(), ilObjForumGUI\getCensorshipFormHTML(), ilObjForumGUI\publishDraftObject(), and ilObjForumGUI\saveTopLevelDraftObject().

669  {
670  if (!self::isSavePostDraftAllowed()) {
671  // feature is globally deactivated
672  return false;
673  }
674  if (!isset(self::$drafts_settings_cache['autosave_drafts'])) {
675  global $DIC;
676 
677  self::$drafts_settings_cache['autosave_drafts'] = (bool) $DIC->settings()->get('autosave_drafts', false);
678  self::$drafts_settings_cache['autosave_drafts_ival'] = (int) $DIC->settings()->get('autosave_drafts_ival', 30);
679  }
680  return self::$drafts_settings_cache['autosave_drafts'];
681  }
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ isSavePostDraftAllowed()

static ilForumPostDraft::isSavePostDraftAllowed ( )
static
Returns
bool

Definition at line 656 of file class.ilForumPostDraft.php.

References $DIC.

Referenced by ilForumTopicTableGUI\__construct(), ilObjForumGUI\addThreadObject(), ilObjForumGUI\checkUsersViewMode(), ilObjForumGUI\createTopLevelPostObject(), ilObjForumGUI\deleteSelectedDraft(), ilObjForumGUI\editDraftObject(), ilObjForumGUI\editThreadDraftObject(), ilObjForumGUI\getCensorshipFormHTML(), ilObjForumGUI\getContent(), ilObjForumListGUI\getProperties(), ilForumThreadFormGUI\initForm(), ilObjForumGUI\publishDraftObject(), ilObjForumGUI\publishThreadDraftObject(), ilObjForumGUI\saveThreadAsDraftObject(), ilObjForumGUI\saveTopLevelDraftObject(), and ilObjForumGUI\updateThreadDraftObject().

657  {
658  if (!isset(self::$drafts_settings_cache['save_post_drafts'])) {
659  global $DIC;
660  self::$drafts_settings_cache['save_post_drafts'] = (bool) $DIC->settings()->get('save_post_drafts', false);
661  }
662  return self::$drafts_settings_cache['save_post_drafts'];
663  }
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ lookupAutosaveInterval()

static ilForumPostDraft::lookupAutosaveInterval ( )
static

Definition at line 683 of file class.ilForumPostDraft.php.

Referenced by ilObjForumGUI\decorateWithAutosave(), and ilObjForumGUI\getCensorshipFormHTML().

684  {
685  if (self::isAutoSavePostDraftAllowed()) {
686  return self::$drafts_settings_cache['autosave_drafts_ival'];
687  }
688  return 0;
689  }
+ Here is the caller graph for this function:

◆ moveDraftsByMergedThreads()

static ilForumPostDraft::moveDraftsByMergedThreads (   $source_thread_id,
  $target_thread_id 
)
static
Parameters
$source_thread_id
$target_thread_id

Definition at line 729 of file class.ilForumPostDraft.php.

References $DIC, and $ilDB.

730  {
731  global $DIC;
732  $ilDB = $DIC->database();
733 
734  $ilDB->update(
735  'frm_posts_drafts',
736  array('thread_id' => array('integer', $target_thread_id)),
737  array('thread_id' => array('integer', $source_thread_id))
738  );
739  }
global $ilDB
$DIC
Definition: xapitoken.php:46

◆ moveDraftsByMovedThread()

static ilForumPostDraft::moveDraftsByMovedThread (   $thread_ids,
  $source_ref_id,
  $target_ref_id 
)
static
Parameters
array$thread_ids
int$source_ref_id
int$target_ref_id

Definition at line 746 of file class.ilForumPostDraft.php.

References $DIC, $ilDB, and ilObjForum\lookupForumIdByRefId().

747  {
748  global $DIC;
749  $ilDB = $DIC->database();
750 
751  $source_forum_id = ilObjForum::lookupForumIdByRefId($source_ref_id);
752  $target_forum_id = ilObjForum::lookupForumIdByRefId($target_ref_id);
753 
754  $ilDB->manipulateF(
755  '
756  UPDATE frm_posts_drafts
757  SET forum_id = %s
758  WHERE forum_id = %s
759  AND ' . $ilDB->in('thread_id', $thread_ids, false, 'integer'),
760  array('integer', 'integer'),
761  array($target_forum_id, $source_forum_id)
762  );
763  }
static lookupForumIdByRefId($ref_id)
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ newInstanceByDraftId()

static ilForumPostDraft::newInstanceByDraftId (   $draft_id)
static
Parameters
$draft_id
Returns
self

Definition at line 474 of file class.ilForumPostDraft.php.

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

Referenced by ilObjForumGUI\addThreadObject(), ilObjForumGUI\cancelDraftObject(), ilObjForumGUI\cancelPostObject(), ilObjMediaObjectAccess\checkAccessMob(), ilObjForumGUI\checkDraftAccess(), ilObjForumGUI\deliverDraftZipFileObject(), ilFileDataForumDrafts\deliverZipFile(), ilForumAutoSaveAsyncDraftAction\executeAndGetResponseObject(), ilObjMediaObject\getParentObjectIdForUsage(), ilForumThreadFormGUI\initForm(), ilObjForumGUI\publishThreadDraftObject(), ilForumDraftsHistory\rollbackAutosave(), ilObjForumGUI\saveThreadAsDraftObject(), ilObjForumGUI\saveTopLevelDraftObject(), and ilObjForumGUI\updateThreadDraftObject().

475  {
476  global $DIC;
477  $ilDB = $DIC->database();
478 
479  $res = $ilDB->queryF(
480  'SELECT * FROM frm_posts_drafts WHERE draft_id = %s',
481  array('integer'),
482  array($draft_id)
483  );
484 
485  $tmp_obj = new ilForumPostDraft();
486  while ($row = $ilDB->fetchAssoc($res)) {
487  self::populateWithDatabaseRecord($tmp_obj, $row);
488  }
489  return $tmp_obj;
490  }
Class ilForumPostDraft.
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ newInstanceByHistorytId()

static ilForumPostDraft::newInstanceByHistorytId (   $history_id)
static
Parameters
$history_id
Returns
ilForumPostDraft
Exceptions
ilException

Definition at line 497 of file class.ilForumPostDraft.php.

References $DIC, $ilDB, and $res.

498  {
499  global $DIC;
500  $ilDB = $DIC->database();
501 
502  $res = $ilDB->queryF(
503  'SELECT * FROM frm_drafts_history WHERE history_id = %s',
504  array('integer'),
505  array($history_id)
506  );
507 
508  while ($row = $ilDB->fetchAssoc($res)) {
509  $tmp_obj = new ilForumPostDraft();
510  self::populateWithDatabaseRecord($tmp_obj, $row);
511  return $tmp_obj;
512  }
513 
514  throw new ilException(sprintf("Could not find history object for id %s", $history_id));
515  }
Class ilForumPostDraft.
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46

◆ populateWithDatabaseRecord()

static ilForumPostDraft::populateWithDatabaseRecord ( ilForumPostDraft  $draft,
array  $row 
)
staticprotected
Parameters
$draftilForumPostDraft
$rowarray

Definition at line 88 of file class.ilForumPostDraft.php.

References setDraftId(), setForumId(), setNotify(), setPostAuthorId(), setPostDate(), setPostDisplayUserId(), setPostId(), setPostMessage(), setPostNotify(), setPostSubject(), setPostUpdate(), setPostUserAlias(), setThreadId(), and setUpdateUserId().

89  {
90  $draft->setDraftId($row['draft_id']);
91  $draft->setForumId($row['forum_id']);
92  $draft->setPostAuthorId($row['post_author_id']);
93  $draft->setPostDate($row['post_date']);
94  $draft->setPostDisplayUserId($row['pos_display_usr_id']);
95  $draft->setPostId($row['post_id']);
96  $draft->setPostMessage($row['post_message']);
97  $draft->setPostSubject($row['post_subject']);
98  $draft->setPostUpdate($row['post_update']);
99  $draft->setPostUserAlias($row['post_user_alias']);
100  $draft->setThreadId($row['thread_id']);
101  $draft->setUpdateUserId($row['update_user_id']);
102  $draft->setNotify($row['notify']);
103  $draft->setPostNotify($row['post_notify']);
104  }
setPostUserAlias($post_user_alias)
setPostDisplayUserId($post_display_user_id)
setUpdateUserId($update_user_id)
setPostMessage($post_message)
setPostSubject($post_subject)
setPostAuthorId($post_author_id)
+ Here is the call graph for this function:

◆ readDraft()

ilForumPostDraft::readDraft ( )
protected

Definition at line 352 of file class.ilForumPostDraft.php.

References $res, getDraftId(), getPostAuthorId(), and getPostId().

Referenced by __construct().

353  {
354  $res = $this->db->queryF(
355  'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s AND post_id = %s AND draft_id = %s',
356  array('integer', 'integer','integer'),
357  array($this->getPostAuthorId(), $this->getPostId(), $this->getDraftId())
358  );
359 
360  while ($row = $this->db->fetchAssoc($res)) {
361  self::populateWithDatabaseRecord($this, $row);
362  }
363  }
foreach($_POST as $key=> $value) $res
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readDrafts()

static ilForumPostDraft::readDrafts (   $user_id)
staticprotected
Parameters
int$user_id

Definition at line 368 of file class.ilForumPostDraft.php.

References $DIC, $ilDB, and $res.

369  {
370  global $DIC;
371  $ilDB = $DIC->database();
372 
373  $res = $ilDB->queryF(
374  'SELECT * FROM frm_posts_drafts WHERE post_author_id = %s',
375  ['integer'],
376  [$user_id]
377  );
378 
379  self::$instances[$user_id] = [
380  'draft_ids' => [],
381  ];
382 
383  while ($row = $ilDB->fetchAssoc($res)) {
384  $tmp_obj = new ilForumPostDraft();
385  self::populateWithDatabaseRecord($tmp_obj, $row);
386  self::$instances[$user_id][$row['thread_id']][$tmp_obj->getPostId()][] = $tmp_obj;
387  self::$instances[$user_id]['draft_ids'][$tmp_obj->getDraftId()] = $tmp_obj;
388  }
389  }
Class ilForumPostDraft.
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46

◆ saveDraft()

ilForumPostDraft::saveDraft ( )

Definition at line 517 of file class.ilForumPostDraft.php.

References $draft_id, $post_date, getForumId(), getNotify(), getPostAuthorId(), getPostDisplayUserId(), getPostId(), getPostMessage(), getPostNotify(), getPostSubject(), getPostUserAlias(), getThreadId(), and setDraftId().

518  {
519  $draft_id = $this->db->nextId('frm_posts_drafts');
520  $post_date = date("Y-m-d H:i:s");
521 
522  $this->db->insert('frm_posts_drafts', array(
523  'draft_id' => array('integer', $draft_id),
524  'post_id' => array('integer', $this->getPostId()),
525  'thread_id' => array('integer', $this->getThreadId()),
526  'forum_id' => array('integer', $this->getForumId()),
527  'post_author_id' => array('integer', $this->getPostAuthorId()),
528  'post_subject' => array('text', $this->getPostSubject()),
529  'post_message' => array('clob', $this->getPostMessage()),
530  'notify' => array('integer', $this->getNotify()),
531  'post_notify' => array('integer', $this->getPostNotify()),
532  'post_date' => array('timestamp', $post_date),
533  'post_update' => array('timestamp', $post_date),
534 // 'update_user_id' => array('integer', $this->getUpdateUserId()),
535  'post_user_alias' => array('text', $this->getPostUserAlias()),
536  'pos_display_usr_id' => array('integer', $this->getPostDisplayUserId())
537  ));
538  $this->setDraftId($draft_id);
539  return $draft_id;
540  }
+ Here is the call graph for this function:

◆ setDraftId()

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

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

References $draft_id.

Referenced by __construct(), populateWithDatabaseRecord(), and saveDraft().

134  {
135  $this->draft_id = $draft_id;
136  }
+ Here is the caller graph for this function:

◆ setForumId()

ilForumPostDraft::setForumId (   $forum_id)
Parameters
int$forum_id

Definition at line 165 of file class.ilForumPostDraft.php.

References $forum_id.

Referenced by populateWithDatabaseRecord().

166  {
167  $this->forum_id = $forum_id;
168  }
+ Here is the caller graph for this function:

◆ setNotify()

ilForumPostDraft::setNotify (   $notify)
Parameters
int$notify

Definition at line 325 of file class.ilForumPostDraft.php.

References $notify.

Referenced by populateWithDatabaseRecord().

326  {
327  $this->notify = $notify;
328  }
+ Here is the caller graph for this function:

◆ setPostAuthorId()

ilForumPostDraft::setPostAuthorId (   $post_author_id)
Parameters
int$post_author_id

Definition at line 293 of file class.ilForumPostDraft.php.

References $post_author_id.

Referenced by __construct(), and populateWithDatabaseRecord().

294  {
295  $this->post_author_id = $post_author_id;
296  }
+ Here is the caller graph for this function:

◆ setPostDate()

ilForumPostDraft::setPostDate (   $post_date)
Parameters
string$post_date

Definition at line 229 of file class.ilForumPostDraft.php.

References $post_date.

Referenced by populateWithDatabaseRecord().

230  {
231  $this->post_date = $post_date;
232  }
+ Here is the caller graph for this function:

◆ setPostDisplayUserId()

ilForumPostDraft::setPostDisplayUserId (   $post_display_user_id)
Parameters
int$post_display_user_id

Definition at line 309 of file class.ilForumPostDraft.php.

References $post_display_user_id.

Referenced by populateWithDatabaseRecord().

310  {
311  $this->post_display_user_id = $post_display_user_id;
312  }
+ Here is the caller graph for this function:

◆ setPostId()

ilForumPostDraft::setPostId (   $post_id)
Parameters
int$post_id

Definition at line 149 of file class.ilForumPostDraft.php.

References $post_id.

Referenced by __construct(), and populateWithDatabaseRecord().

150  {
151  $this->post_id = $post_id;
152  }
+ Here is the caller graph for this function:

◆ setPostMessage()

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

Definition at line 213 of file class.ilForumPostDraft.php.

References $post_message.

Referenced by populateWithDatabaseRecord().

214  {
215  $this->post_message = $post_message;
216  }
+ Here is the caller graph for this function:

◆ setPostNotify()

ilForumPostDraft::setPostNotify (   $post_notify)
Parameters
int$post_notify

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

References $post_notify.

Referenced by populateWithDatabaseRecord().

118  {
119  $this->post_notify = $post_notify;
120  }
+ Here is the caller graph for this function:

◆ setPostSubject()

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

Definition at line 197 of file class.ilForumPostDraft.php.

References $post_subject.

Referenced by populateWithDatabaseRecord().

198  {
199  $this->post_subject = $post_subject;
200  }
+ Here is the caller graph for this function:

◆ setPostUpdate()

ilForumPostDraft::setPostUpdate (   $post_update)
Parameters
string$post_update

Definition at line 245 of file class.ilForumPostDraft.php.

References $post_update.

Referenced by populateWithDatabaseRecord().

246  {
247  $this->post_update = $post_update;
248  }
+ Here is the caller graph for this function:

◆ setPostUserAlias()

ilForumPostDraft::setPostUserAlias (   $post_user_alias)
Parameters
string$post_user_alias

Definition at line 277 of file class.ilForumPostDraft.php.

References $post_user_alias.

Referenced by populateWithDatabaseRecord().

278  {
279  $this->post_user_alias = $post_user_alias;
280  }
+ Here is the caller graph for this function:

◆ setThreadId()

ilForumPostDraft::setThreadId (   $thread_id)
Parameters
int$thread_id

Definition at line 181 of file class.ilForumPostDraft.php.

References $thread_id.

Referenced by populateWithDatabaseRecord().

182  {
183  $this->thread_id = $thread_id;
184  }
+ Here is the caller graph for this function:

◆ setUpdateUserId()

ilForumPostDraft::setUpdateUserId (   $update_user_id)
Parameters
int$update_user_id

Definition at line 261 of file class.ilForumPostDraft.php.

References $update_user_id.

Referenced by populateWithDatabaseRecord().

262  {
263  $this->update_user_id = $update_user_id;
264  }
+ Here is the caller graph for this function:

◆ updateDraft()

ilForumPostDraft::updateDraft ( )

Definition at line 542 of file class.ilForumPostDraft.php.

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

543  {
544  $this->db->update(
545  'frm_posts_drafts',
546  array(
547  'post_subject' => array('text', $this->getPostSubject()),
548  'post_message' => array('clob', $this->getPostMessage()),
549  'post_user_alias' => array('text', $this->getPostUserAlias())
550  ),
551  array('draft_id' => array('integer', $this->getDraftId()))
552  );
553  }
+ Here is the call graph for this function:

Field Documentation

◆ $draft_id

◆ $drafts_settings_cache

ilForumPostDraft::$drafts_settings_cache = array()
staticprotected

Definition at line 82 of file class.ilForumPostDraft.php.

◆ $forum_id

ilForumPostDraft::$forum_id = 0
protected

Definition at line 21 of file class.ilForumPostDraft.php.

Referenced by getForumId(), getThreadDraftData(), and setForumId().

◆ $forum_statistics_cache

ilForumPostDraft::$forum_statistics_cache = array()
staticprotected

Definition at line 77 of file class.ilForumPostDraft.php.

◆ $instances

ilForumPostDraft::$instances = array()
staticprivate

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

◆ $notify

ilForumPostDraft::$notify = 0
protected

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

Referenced by getNotify(), and setNotify().

◆ $post_author_id

ilForumPostDraft::$post_author_id = 0
protected

Definition at line 53 of file class.ilForumPostDraft.php.

Referenced by getPostAuthorId(), getThreadDraftData(), and setPostAuthorId().

◆ $post_date

ilForumPostDraft::$post_date = '0000-00-00 00:00:00'
protected

Definition at line 37 of file class.ilForumPostDraft.php.

Referenced by getPostDate(), saveDraft(), and setPostDate().

◆ $post_display_user_id

ilForumPostDraft::$post_display_user_id = 0
protected

Definition at line 57 of file class.ilForumPostDraft.php.

Referenced by getPostDisplayUserId(), and setPostDisplayUserId().

◆ $post_id

ilForumPostDraft::$post_id = 0
protected

Definition at line 17 of file class.ilForumPostDraft.php.

Referenced by __construct(), getPostId(), and setPostId().

◆ $post_message

ilForumPostDraft::$post_message = ''
protected

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

Referenced by getPostMessage(), and setPostMessage().

◆ $post_notify

ilForumPostDraft::$post_notify = 0
protected

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

Referenced by getPostNotify(), and setPostNotify().

◆ $post_subject

ilForumPostDraft::$post_subject = ''
protected

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

Referenced by getPostSubject(), and setPostSubject().

◆ $post_update

ilForumPostDraft::$post_update = '0000-00-00 00:00:00'
protected

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

Referenced by getPostUpdate(), and setPostUpdate().

◆ $post_user_alias

ilForumPostDraft::$post_user_alias = ''
protected

Definition at line 49 of file class.ilForumPostDraft.php.

Referenced by getPostUserAlias(), and setPostUserAlias().

◆ $thread_id

ilForumPostDraft::$thread_id = 0
protected

◆ $update_user_id

ilForumPostDraft::$update_user_id = 0
protected

Definition at line 45 of file class.ilForumPostDraft.php.

Referenced by getUpdateUserId(), and setUpdateUserId().

◆ MEDIAOBJECT_TYPE

const ilForumPostDraft::MEDIAOBJECT_TYPE = 'frm~d:html'

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