1
0

BxFilesFormsEntryHelper.php 2.1 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 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. $mixedContent = $this->addDataFormAction($sDisplay, $sCheckFunction);
  25. if (is_array($mixedContent) && $mixedContent['need_redirect_after_action']) {
  26. $CNF = &$this->_oModule->_oConfig->CNF;
  27. $aContentIds = $mixedContent['content_ids_array'];
  28. $iContentId = array_pop($aContentIds);
  29. $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
  30. $oProfile = BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_AUTHOR']]);
  31. $sUrl = 'page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id=' . ($oProfile ? $oProfile->id() : bx_get_logged_profile_id());
  32. if($this->_bAjaxMode) {
  33. echoJson($this->prepareResponse($sUrl, $this->_bAjaxMode, 'redirect'));
  34. exit;
  35. }
  36. else
  37. $this->_redirectAndExit($sUrl);
  38. }
  39. else {
  40. return $mixedContent;
  41. }
  42. }
  43. protected function redirectAfterDelete($aContentInfo)
  44. {
  45. $CNF = &$this->_oModule->_oConfig->CNF;
  46. $oProfile = BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_AUTHOR']]);
  47. if ($oProfile)
  48. $this->_redirectAndExit('page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id=' . $oProfile->id());
  49. else
  50. $this->_redirectAndExit($CNF['URL_HOME'], true, array(
  51. 'account_id' => getLoggedId(),
  52. 'profile_id' => bx_get_logged_profile_id(),
  53. ));
  54. }
  55. }
  56. /** @} */