BxBaseModGroupsMenuViewActionsAll.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 BaseGroups Base classes for groups modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * View entry all actions menu
  13. */
  14. class BxBaseModGroupsMenuViewActionsAll extends BxBaseModProfileMenuViewActionsAll
  15. {
  16. public function __construct($aObject, $oTemplate = false)
  17. {
  18. parent::__construct($aObject, $oTemplate);
  19. $CNF = &$this->_oModule->_oConfig->CNF;
  20. if(isset($CNF['OBJECT_CONNECTIONS']))
  21. $this->_aConnectionToFunctionCheck[$CNF['OBJECT_CONNECTIONS']] = [
  22. 'fans' => 'checkAllowedFans',
  23. 'add' => 'checkAllowedFanAdd',
  24. 'remove' => 'checkAllowedFanRemove'
  25. ];
  26. if(($iContextPid = $this->_aContentInfo['profile_id']) && $this->_oModule->isPaidJoinByProfile($iContextPid)) {
  27. $aDefault = $this->_oModule->_oDb->getPrices(['type' => 'by_profile_id', 'profile_id' => $iContextPid, 'default' => true]);
  28. if(empty($aDefault) || !is_array($aDefault)) {
  29. $aPrices = $this->_oModule->_oDb->getPrices(['type' => 'by_profile_id', 'profile_id' => $iContextPid]);
  30. if(!empty($aPrices) && is_array($aPrices))
  31. $aDefault = reset($aPrices);
  32. }
  33. //TODO: Check markers parsing!
  34. if(!empty($aDefault) && is_array($aDefault))
  35. $this->addMarkers([
  36. 'title_pay_and_join' => _t('_bx_groups_menu_item_title_pay_and_join', $this->_oModule->_oConfig->getPriceTitle($this->_aContentInfo[$CNF['FIELD_AUTHOR']], $aDefault))
  37. ]);
  38. }
  39. }
  40. protected function _isContentPublic($iContentId, $aPublicGroups = [])
  41. {
  42. return parent::_isContentPublic($iContentId, [BX_DOL_PG_ALL, BX_DOL_PG_MEMBERS, 'c']);
  43. }
  44. protected function _getMenuItemProfileFans($aItem, $aParams = [])
  45. {
  46. $CNF = &$this->_oModule->_oConfig->CNF;
  47. if(empty($CNF['OBJECT_CONNECTIONS']))
  48. return false;
  49. return $this->_getMenuItemConnection($aItem, array_merge($aParams, [
  50. 'object' => $CNF['OBJECT_CONNECTIONS']
  51. ]));
  52. }
  53. protected function _getMenuItemProfileFanAdd($aItem)
  54. {
  55. $CNF = &$this->_oModule->_oConfig->CNF;
  56. $mixedResult = $this->_getMenuItemByNameActions($aItem);
  57. if(!$mixedResult)
  58. return $mixedResult;
  59. if($this->_bIsApi && $CNF['OBJECT_CONNECTIONS'])
  60. return $this->_getMenuItemConnectionApi($CNF['OBJECT_CONNECTIONS'], 'add', $aItem);
  61. return $mixedResult;
  62. }
  63. protected function _getMenuItemProfileFanAddPaid($aItem)
  64. {
  65. return $this->_getMenuItemByNameActions($aItem);
  66. }
  67. protected function _getMenuItemProfileFanRemove($aItem)
  68. {
  69. $CNF = &$this->_oModule->_oConfig->CNF;
  70. $mixedResult = $this->_getMenuItemByNameActions($aItem);
  71. if(!$mixedResult)
  72. return $mixedResult;
  73. if($this->_bIsApi && $CNF['OBJECT_CONNECTIONS'])
  74. return $this->_getMenuItemConnectionApi($CNF['OBJECT_CONNECTIONS'], 'remove', $aItem);
  75. return $mixedResult;
  76. }
  77. }
  78. /** @} */