BxFilesFormsEntryHelper.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 Files Files
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Entry forms helper functions
  13. */
  14. class BxFilesFormsEntryHelper extends BxBaseModFilesFormsEntryHelper
  15. {
  16. public function __construct($oModule)
  17. {
  18. $this->_sDisplayForFormAdd ='bx_files_entry_upload';
  19. $this->_sObjectNameForFormAdd ='bx_files_upload';
  20. parent::__construct($oModule);
  21. }
  22. public function addDataForm ($sDisplay = false, $sCheckFunction = false)
  23. {
  24. $sKey = 'need_redirect_after_action';
  25. $mixedContent = $this->addDataFormAction($sDisplay, $sCheckFunction);
  26. if(is_array($mixedContent) && !empty($mixedContent[$sKey])) {
  27. $sUrl = $this->getRedirectUrlAfterAdd($mixedContent);
  28. if($this->_bAjaxMode) {
  29. echoJson($this->prepareResponse($sUrl, $this->_bAjaxMode, 'redirect'));
  30. exit;
  31. }
  32. else
  33. $this->_redirectAndExit($sUrl);
  34. }
  35. else
  36. return $mixedContent;
  37. }
  38. protected function redirectAfterDelete($aContentInfo)
  39. {
  40. $CNF = &$this->_oModule->_oConfig->CNF;
  41. $oProfile = BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_AUTHOR']]);
  42. if ($oProfile)
  43. $this->_redirectAndExit('page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id=' . $oProfile->id());
  44. else
  45. $this->_redirectAndExit($CNF['URL_HOME'], true, array(
  46. 'account_id' => getLoggedId(),
  47. 'profile_id' => bx_get_logged_profile_id(),
  48. ));
  49. }
  50. }
  51. /** @} */