BxFilesFormsEntryHelper.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. $sUri = $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id=' . ($oProfile ? $oProfile->id() : bx_get_logged_profile_id());
  32. $this->_redirectAndExit('page.php?i=' . $sUri);
  33. }
  34. else{
  35. return $mixedContent;
  36. }
  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. /** @} */