BxOrgsFormsEntryHelper.php 1.7 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 Organizations Organizations
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Organization profile forms functions
  13. */
  14. class BxOrgsFormsEntryHelper extends BxBaseModGroupsFormsEntryHelper
  15. {
  16. public function __construct($oModule)
  17. {
  18. parent::__construct($oModule);
  19. }
  20. public function onDataAddAfter($iAccountId, $iContentId)
  21. {
  22. $CNF = &$this->_oModule->_oConfig->CNF;
  23. if($s = parent::onDataAddAfter($iAccountId, $iContentId))
  24. return $s;
  25. $aInvitedMembers = bx_get('initial_members');
  26. if(empty($aInvitedMembers) || !is_array($aInvitedMembers))
  27. return '';
  28. $sGroupModule = $this->_oModule->_oConfig->getName();
  29. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $sGroupModule);
  30. if(!$oGroupProfile)
  31. return '';
  32. $aGroupContentInfo = bx_srv($sGroupModule, 'get_info', array($iContentId, false));
  33. if(empty($aGroupContentInfo) || !is_array($aGroupContentInfo) || !in_array($aGroupContentInfo[$CNF['FIELD_AUTHOR']], $aInvitedMembers))
  34. return '';
  35. $oGroupAuthor = BxDolProfile::getInstance($aGroupContentInfo[$CNF['FIELD_AUTHOR']]);
  36. if(!$oGroupAuthor)
  37. return '';
  38. $sGroupAuthorModule = $oGroupAuthor->getModule();
  39. if(!BxDolRequest::serviceExists($sGroupAuthorModule, 'act_as_profile') || !bx_srv($sGroupAuthorModule, 'act_as_profile'))
  40. return '';
  41. $this->makeAdmin($oGroupAuthor->id(), $oGroupProfile, $aInvitedMembers);
  42. return '';
  43. }
  44. }
  45. /** @} */