BxForumFormEntry.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Forum Forum
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Create/Edit entry form
  13. */
  14. class BxForumFormEntry extends BxBaseModTextFormEntry
  15. {
  16. protected $_sGhostTemplateCover = 'form_ghost_template_cover.html';
  17. public function __construct($aInfo, $oTemplate = false)
  18. {
  19. $this->MODULE = 'bx_forum';
  20. parent::__construct($aInfo, $oTemplate);
  21. }
  22. public function insert($aValsToAdd = [], $isIgnore = false)
  23. {
  24. $CNF = $this->_oModule->_oConfig->CNF;
  25. return parent::insert(array_merge($aValsToAdd, [
  26. 'lr_timestamp' => time(),
  27. 'lr_profile_id' => (isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && $this->getCleanValue($CNF['FIELD_ANONYMOUS']) ? -1 : 1) * bx_get_logged_profile_id()
  28. ]), $isIgnore);
  29. }
  30. public function update ($iContentId, $aValsToAdd = [], &$aTrackTextFieldsChanges = null)
  31. {
  32. $CNF = $this->_oModule->_oConfig->CNF;
  33. $aContentInfo = $this->_oModule->_oDb->getContentInfoById ($iContentId);
  34. if (isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && !$aContentInfo['lr_comment_id'])
  35. $aValsToAdd['lr_profile_id'] = ($this->getCleanValue($CNF['FIELD_ANONYMOUS']) ? -1 : 1) * abs($aContentInfo['lr_profile_id']);
  36. return parent::update ($iContentId, $aValsToAdd, $aTrackTextFieldsChanges);
  37. }
  38. public function delete ($iContentId, $aContentInfo = array())
  39. {
  40. $CNF = &$this->_oModule->_oConfig->CNF;
  41. $mixedResult = parent::delete($iContentId, $aContentInfo);
  42. if($mixedResult !== false) {
  43. if(!empty($CNF['OBJECT_CONNECTION_SUBSCRIBERS']))
  44. BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION_SUBSCRIBERS'])->onDeleteContent($iContentId);
  45. }
  46. return $mixedResult;
  47. }
  48. }
  49. /** @} */