BxBaseAcl.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 TridentCore Trident Core
  7. * @{
  8. */
  9. /**
  10. * Acl representation.
  11. * @see BxDolAcl
  12. */
  13. class BxBaseAcl extends BxDolAcl
  14. {
  15. public function __construct ()
  16. {
  17. parent::__construct ();
  18. }
  19. public function getProfileMembership ($iProfileId)
  20. {
  21. $aLevel = $this->getMemberMembershipInfo($iProfileId);
  22. if(empty($aLevel) || !is_array($aLevel))
  23. return '';
  24. $aLevelInfo = $this->getMembershipInfo($aLevel['id']);
  25. $oTemplate = BxDolTemplate::getInstance();
  26. $oTemplate->addCss(array('acl.css'));
  27. return $oTemplate->parseHtmlByName('acl_membership.html', array(
  28. 'level' => _t($aLevel['name']),
  29. 'thumbnail' => $oTemplate->getImage($aLevelInfo['icon'], array('class' => 'bx-acl-m-thumbnail bx-def-border')),
  30. 'bx_if:show_private_info' => array(
  31. 'condition' => $iProfileId == bx_get_logged_profile_id(),
  32. 'content' => array(
  33. 'date_start' => bx_time_js($aLevel['date_starts']),
  34. 'date_expire' => (int)$aLevel['date_expires'] > 0 ? bx_time_js($aLevel['date_expires']) : _t('_sys_acl_expire_never')
  35. )
  36. )
  37. ));
  38. }
  39. /**
  40. * Print code for membership status
  41. * $iProfileId - ID of profile
  42. * $offer_upgrade - will this code be printed at [c]ontrol [p]anel
  43. */
  44. function GetMembershipStatus($iProfileId, $bOfferUpgrade = true)
  45. {
  46. $aMembershipInfo = $this->getMemberMembershipInfo($iProfileId);
  47. $sViewMembershipActions = "<br />(<a onclick=\"javascript:window.open('explanation.php?explain=membership&amp;type=".$aMembershipInfo['ID']."', '', 'width=660, height=500, menubar=no, status=no, resizable=no, scrollbars=yes, toolbar=no, location=no');\" href=\"javascript:void(0);\">"._t("_VIEW_MEMBERSHIP_ACTIONS")."</a>)<br />";
  48. // Show colored membership name
  49. $ret = '';
  50. if ( $aMembershipInfo['ID'] == MEMBERSHIP_ID_STANDARD || $aMembershipInfo['ID'] == MEMBERSHIP_ID_AUTHENTICATED) {
  51. $ret .= _t( "_MEMBERSHIP_STANDARD" ). $sViewMembershipActions;
  52. if ( $bOfferUpgrade )
  53. $ret .= " ". _t( "_MEMBERSHIP_UPGRADE_FROM_STANDARD" );
  54. } else {
  55. $ret .= "<font color=\"red\">{$aMembershipInfo['Name']}</font>$sViewMembershipActions";
  56. $days_left = (int)( ($aMembershipInfo['DateExpires'] - time()) / (24 * 3600) );
  57. if(!is_null($aMembershipInfo['DateExpires'])) {
  58. $ret .= ( $days_left > 0 ) ? _t( "_MEMBERSHIP_EXPIRES_IN_DAYS", $days_left ) : _t( "_MEMBERSHIP_EXPIRES_TODAY", date( "H:i", $aMembershipInfo['DateExpires'] ), date( "H:i" ) );
  59. } else {
  60. $ret.= _t("_MEMBERSHIP_EXPIRES_NEVER");
  61. }
  62. }
  63. return $ret;
  64. }
  65. }
  66. /** @} */