BxBaseModProfileMenuView.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 BaseProfile Base classes for profile modules
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * View profile entry menu
  13. */
  14. class BxBaseModProfileMenuView extends BxBaseModGeneralMenuView
  15. {
  16. protected $_oProfile;
  17. protected $_aContentInfo;
  18. protected $_aProfileInfo;
  19. public function __construct($aObject, $oTemplate = false)
  20. {
  21. parent::__construct($aObject, $oTemplate);
  22. $CNF = $this->_oModule->_oConfig->CNF;
  23. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  24. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  25. if ($iProfileId)
  26. $this->_oProfile = BxDolProfile::getInstance($iProfileId);
  27. if (!$this->_oProfile && $iContentId)
  28. $this->_oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->MODULE);
  29. if ($this->_oProfile) {
  30. $this->_aProfileInfo = $this->_oProfile->getInfo();
  31. $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_aProfileInfo['content_id']);
  32. $this->addMarkers($this->_aProfileInfo);
  33. $this->addMarkers(array('profile_id' => $this->_oProfile->id()));
  34. if (isLogged()) {
  35. $oConn = BxDolConnection::getObjectInstance('sys_profiles_friends');
  36. if ($oConn->isConnectedNotMutual(bx_get_logged_profile_id(), $this->_oProfile->id())) {
  37. $this->addMarkers(array(
  38. 'title_add_friend' => _t($CNF['T']['menu_item_title_befriend_sent']),
  39. 'title_remove_friend' => _t($CNF['T']['menu_item_title_unfriend_cancel_request']),
  40. ));
  41. } elseif ($oConn->isConnectedNotMutual($this->_oProfile->id(), bx_get_logged_profile_id())) {
  42. $this->addMarkers(array(
  43. 'title_add_friend' => _t($CNF['T']['menu_item_title_befriend_confirm']),
  44. 'title_remove_friend' => _t($CNF['T']['menu_item_title_unfriend_reject_request']),
  45. ));
  46. } else {
  47. $this->addMarkers(array(
  48. 'title_add_friend' => _t($CNF['T']['menu_item_title_befriend']),
  49. 'title_remove_friend' => _t($CNF['T']['menu_item_title_unfriend']),
  50. ));
  51. }
  52. }
  53. }
  54. }
  55. }
  56. /** @} */