BxTemplServiceProfiles.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 UnaTemplate UNA Template Classes
  7. * @{
  8. */
  9. /**
  10. * @see BxBaseServiceProfiles
  11. */
  12. class BxTemplServiceProfiles extends BxBaseServiceProfiles
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. public function serviceProfileStats ($iProfileId = 0)
  19. {
  20. if (!$iProfileId && !($iProfileId = bx_get_logged_profile_id()))
  21. return '';
  22. $oProfile = BxDolProfile::getInstance($iProfileId);
  23. if(!$oProfile)
  24. return '';
  25. $oMenu = BxDolMenu::getObjectInstance('sys_profile_stats');
  26. if(!$oMenu)
  27. return '';
  28. $oAcl = BxDolAcl::getInstance();
  29. $aAcl = $oAcl->getMemberMembershipInfo($iProfileId);
  30. $aAclInfo = $oAcl->getMembershipInfo($aAcl['id']);
  31. list ($sIcon, $sIconUrl, $sIconA, $sIconHtml) = $this->_getIcon($aAclInfo['icon']);
  32. $aVars = array(
  33. 'profile_id' => $oProfile->id(),
  34. 'profile_url' => $oProfile->getUrl(),
  35. 'profile_edit_url' => $oProfile->getEditUrl(),
  36. 'profile_title' => $oProfile->getDisplayName(),
  37. 'profile_title_attr' => bx_html_attribute($oProfile->getDisplayName()),
  38. 'profile_ava_url' => $oProfile->getAvatar(),
  39. 'profile_unit' => $oProfile->getUnit(0, array('template' => array(
  40. 'name' => 'unit_wo_info',
  41. 'size' => 'thumb'
  42. ))),
  43. 'profile_acl_title' => _t($aAclInfo['name']),
  44. 'menu' => $oMenu->getCode(),
  45. );
  46. $aVars['bx_if:image'] = array (
  47. 'condition' => (bool)$sIconUrl,
  48. 'content' => array('icon_url' => $sIconUrl),
  49. );
  50. $aVars['bx_if:image_inline'] = array (
  51. 'condition' => false,
  52. 'content' => array('image' => ''),
  53. );
  54. $aVars['bx_if:icon'] = array (
  55. 'condition' => (bool)$sIcon,
  56. 'content' => array('icon' => $sIcon),
  57. );
  58. $aVars['bx_if:icon-html'] = array (
  59. 'condition' => (bool)$sIconHtml,
  60. 'content' => array('icon' => $sIconHtml),
  61. );
  62. $aVars['bx_if:icon-a'] = array (
  63. 'condition' => (bool)$sIconA,
  64. 'content' => array('icon-a' => $sIconA),
  65. );
  66. return BxDolTemplate::getInstance()->parseHtmlByName('profile_stats.html', $aVars);
  67. }
  68. }
  69. /** @} */