BxBaseModGroupsMenuViewActionsAll.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. if(!empty($aDefault) && is_array($aDefault))
  34. $this->addMarkers([
  35. 'title_pay_and_join' => _t($CNF['T']['menu_item_title_pay_and_join'], $this->_oModule->_oConfig->getPriceTitle($this->_aContentInfo[$CNF['FIELD_AUTHOR']], $aDefault))
  36. ]);
  37. }
  38. }
  39. protected function _isContentPublic($iContentId, $aPublicGroups = [])
  40. {
  41. return parent::_isContentPublic($iContentId, [BX_DOL_PG_ALL, BX_DOL_PG_MEMBERS, 'c']);
  42. }
  43. protected function _getMenuItemProfileFans($aItem, $aParams = [])
  44. {
  45. $CNF = &$this->_oModule->_oConfig->CNF;
  46. if(empty($CNF['OBJECT_CONNECTIONS']))
  47. return false;
  48. return $this->_getMenuItemConnection($aItem, array_merge($aParams, [
  49. 'object' => $CNF['OBJECT_CONNECTIONS']
  50. ]));
  51. }
  52. protected function _getMenuItemProfileFanAdd($aItem)
  53. {
  54. $CNF = &$this->_oModule->_oConfig->CNF;
  55. $mixedResult = $this->_getMenuItemByNameActions($aItem);
  56. if(!$mixedResult)
  57. return $mixedResult;
  58. if($this->_bIsApi && $CNF['OBJECT_CONNECTIONS'])
  59. return $this->_getMenuItemConnectionApi($CNF['OBJECT_CONNECTIONS'], 'add', $aItem);
  60. return $mixedResult;
  61. }
  62. protected function _getMenuItemProfileFanAddPaid($aItem)
  63. {
  64. return $this->_getMenuItemByNameActions($aItem);
  65. }
  66. protected function _getMenuItemProfileFanRemove($aItem)
  67. {
  68. $CNF = &$this->_oModule->_oConfig->CNF;
  69. $mixedResult = $this->_getMenuItemByNameActions($aItem);
  70. if(!$mixedResult)
  71. return $mixedResult;
  72. if($this->_bIsApi && $CNF['OBJECT_CONNECTIONS'])
  73. return $this->_getMenuItemConnectionApi($CNF['OBJECT_CONNECTIONS'], 'remove', $aItem);
  74. return $mixedResult;
  75. }
  76. }
  77. /** @} */