1
0

BxBaseModProfileMenuViewActions.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 BaseProfile Base classes for profile modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * View profile entry actions menu
  13. */
  14. class BxBaseModProfileMenuViewActions extends BxBaseModGeneralMenuView
  15. {
  16. protected $_oProfile;
  17. protected $_aProfileInfo;
  18. public function __construct($aObject, $oTemplate = false)
  19. {
  20. parent::__construct($aObject, $oTemplate);
  21. $CNF = $this->_oModule->_oConfig->CNF;
  22. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  23. if(empty($iContentId) && bx_get('profile_id') !== false)
  24. $iContentId = BxDolProfile::getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT))->getContentId();
  25. if(!empty($iContentId))
  26. $this->setContentId($iContentId);
  27. }
  28. public function setContentId($iContentId)
  29. {
  30. $this->_iContentId = (int)$iContentId;
  31. $this->_oProfile = BxDolProfile::getInstanceByContentAndType($this->_iContentId, $this->MODULE);
  32. if(!$this->_oProfile)
  33. return;
  34. $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iContentId);
  35. $this->_aProfileInfo = $this->_oProfile->getInfo();
  36. $aMarkers = [
  37. 'profile_id' => $this->_oProfile->id()
  38. ];
  39. $aTitles = $this->_oModule->getMenuItemTitleByConnection('sys_profiles_friends', '', $this->_oProfile->id());
  40. if($aTitles)
  41. $aMarkers = array_merge($aMarkers, [
  42. 'title_add_friend' => $aTitles['add'],
  43. 'title_remove_friend' => $aTitles['remove'],
  44. ]);
  45. $this->addMarkers($this->_aProfileInfo);
  46. $this->addMarkers($aMarkers);
  47. }
  48. }
  49. /** @} */