BxGroupsFormsEntryHelper.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup Groups Groups
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Group profile forms functions
  13. */
  14. class BxGroupsFormsEntryHelper extends BxBaseModProfileFormsEntryHelper
  15. {
  16. public function __construct($oModule)
  17. {
  18. parent::__construct($oModule);
  19. }
  20. protected function _processPermissionsCheckForViewDataForm ($aContentInfo, $oProfile)
  21. {
  22. $sMsg = parent::_processPermissionsCheckForViewDataForm ($aContentInfo, $oProfile);
  23. if ($sMsg && 'c' == $aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']])
  24. return '';
  25. return $sMsg;
  26. }
  27. public function onDataAddAfter ($iAccountId, $iContentId)
  28. {
  29. if ($s = parent::onDataAddAfter($iAccountId, $iContentId))
  30. return $s;
  31. if (!($oGroupProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->_oModule->_oConfig->getName())))
  32. return '';
  33. // insert invited members, so they will join without confirmation
  34. $aInitialProfiles = bx_get('initial_members');
  35. foreach ($aInitialProfiles as $iProfileId) {
  36. if (!($oProfile = BxDolProfile::getInstance($iProfileId)))
  37. continue;
  38. $this->_oModule->serviceAddMutualConnection ($oGroupProfile->id(), $oProfile->id(), true);
  39. }
  40. return '';
  41. }
  42. public function onDataDeleteAfter ($iContentId, $aContentInfo, $oProfile)
  43. {
  44. $CNF = &$this->_oModule->_oConfig->CNF;
  45. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->_oModule->_oConfig->getName());
  46. if ($oGroupProfile)
  47. $this->_oModule->_oDb->deleteAdminsByGroupId($oGroupProfile->id());
  48. if (isset($CNF['OBJECT_CONNECTIONS']) && $oGroupProfile && ($oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS'])))
  49. $oConnection->onDeleteInitiatorAndContent($oGroupProfile->id());
  50. return '';
  51. }
  52. }
  53. /** @} */