1
0

BxBaseModProfileMenuView.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 menu
  13. */
  14. class BxBaseModProfileMenuView 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. $this->addMarkers($this->_aProfileInfo);
  37. $this->addMarkers(array(
  38. 'profile_id' => $this->_oProfile->id()
  39. ));
  40. $aTitles = $this->_oModule->serviceGetConnectionButtonsTitles($this->_oProfile->id());
  41. if($aTitles) {
  42. $this->addMarkers(array(
  43. 'title_add_friend' => $aTitles['add'],
  44. 'title_remove_friend' => $aTitles['remove'],
  45. ));
  46. }
  47. }
  48. }
  49. /** @} */