| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup Forum Forum
- * @ingroup UnaModules
- *
- * @{
- */
- /**
- * Create/Edit entry form
- */
- class BxForumFormEntry extends BxBaseModTextFormEntry
- {
- protected $_sGhostTemplateCover = 'form_ghost_template_cover.html';
- public function __construct($aInfo, $oTemplate = false)
- {
- $this->MODULE = 'bx_forum';
- parent::__construct($aInfo, $oTemplate);
- }
- function initChecker ($aValues = array (), $aSpecificValues = array())
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- $bValues = $aValues && !empty($aValues['id']);
- $aContentInfo = $bValues ? $this->_oModule->_oDb->getContentInfoById($aValues['id']) : false;
- if (isset($CNF['FIELD_COVER']) && isset($this->aInputs[$CNF['FIELD_COVER']])) {
- if($bValues)
- $this->aInputs[$CNF['FIELD_COVER']]['content_id'] = $aValues['id'];
- $this->aInputs[$CNF['FIELD_COVER']]['ghost_template'] = $this->_oModule->_oTemplate->parseHtmlByName($this->_sGhostTemplateCover, $this->_getCoverGhostTmplVars($aContentInfo));
- }
- parent::initChecker ($aValues, $aSpecificValues);
- }
- public function insert($aValsToAdd = array(), $isIgnore = false)
- {
- $CNF = $this->_oModule->_oConfig->CNF;
- $aValsToAdd['lr_timestamp'] = time();
- $aValsToAdd['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();
- $iContentId = parent::insert($aValsToAdd, $isIgnore);
- if(!empty($iContentId)){
- $this->processFiles($CNF['FIELD_COVER'], $iContentId, true);
- }
- return $iContentId;
- }
- function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null)
- {
- $CNF = $this->_oModule->_oConfig->CNF;
- $aContentInfo = $this->_oModule->_oDb->getContentInfoById ($iContentId);
- if (isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && !$aContentInfo['lr_comment_id'])
- $aValsToAdd['lr_profile_id'] = ($this->getCleanValue($CNF['FIELD_ANONYMOUS']) ? -1 : 1) * abs($aContentInfo['lr_profile_id']);
- $iResult = parent::update ($iContentId, $aValsToAdd, $aTrackTextFieldsChanges);
- $this->processFiles($CNF['FIELD_COVER'], $iContentId, false);
- return $iResult;
- }
-
- public function delete ($iContentId, $aContentInfo = array())
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- $mixedResult = parent::delete($iContentId, $aContentInfo);
- if($mixedResult !== false) {
- if(!empty($CNF['OBJECT_CONNECTION_SUBSCRIBERS']))
- BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION_SUBSCRIBERS'])->onDeleteContent($iContentId);
- }
- return $mixedResult;
- }
- protected function _getCoverGhostTmplVars($aContentInfo = array())
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- return array (
- 'name' => $this->aInputs[$CNF['FIELD_COVER']]['name'],
- 'content_id' => $this->aInputs[$CNF['FIELD_COVER']]['content_id'],
- 'editor_id' => isset($CNF['FIELD_TEXT_ID']) ? $CNF['FIELD_TEXT_ID'] : '',
- 'thumb_id' => isset($CNF['FIELD_THUMB']) && isset($aContentInfo[$CNF['FIELD_THUMB']]) ? $aContentInfo[$CNF['FIELD_THUMB']] : 0,
- 'name_thumb' => isset($CNF['FIELD_THUMB']) ? $CNF['FIELD_THUMB'] : ''
- );
- }
- protected function _getPhotoGhostTmplVars($aContentInfo = array())
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- return array (
- 'name' => $this->aInputs[$CNF['FIELD_PHOTO']]['name'],
- 'content_id' => (int)$this->aInputs[$CNF['FIELD_PHOTO']]['content_id'],
- 'editor_id' => isset($CNF['FIELD_TEXT_ID']) ? $CNF['FIELD_TEXT_ID'] : '',
- 'bx_if:set_thumb' => [
- 'condition' => false,
- 'content' => []
- ],
- );
- }
- }
- /** @} */
|