BxDolProfileUndefined.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 UnaCore UNA Core
  7. * @{
  8. */
  9. /**
  10. * When profile is not available (for example profile is deleted) then use this special class.
  11. *
  12. * @section example Example of usage
  13. *
  14. * @code
  15. * $oProfile = BxDolProfile::getInstance($iId);
  16. * if (!$oProfile)
  17. * $oProfile = BxDolProfileUndefined::getInstance();
  18. * @endcode
  19. */
  20. class BxDolProfileUndefined extends BxDolFactory implements iBxDolSingleton, iBxDolProfile
  21. {
  22. /**
  23. * Constructor
  24. */
  25. protected function __construct ()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Prevent cloning the instance
  31. */
  32. public function __clone()
  33. {
  34. $sClass = get_class($this);
  35. if (isset($GLOBALS['bxDolClasses'][$sClass]))
  36. trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
  37. }
  38. /**
  39. * Get singleton instance of the class
  40. */
  41. public static function getInstance()
  42. {
  43. $sClass = __CLASS__;
  44. if(!isset($GLOBALS['bxDolClasses'][$sClass]))
  45. $GLOBALS['bxDolClasses'][$sClass] = new $sClass();
  46. return $GLOBALS['bxDolClasses'][$sClass];
  47. }
  48. /**
  49. * Get profile id
  50. */
  51. public function id()
  52. {
  53. return 0;
  54. }
  55. /**
  56. * Get profile display name
  57. */
  58. public function getDisplayName()
  59. {
  60. return _t('_uknown');
  61. }
  62. /**
  63. * Get profile url
  64. */
  65. public function getUrl()
  66. {
  67. return 'javascript:void(0);';
  68. }
  69. /**
  70. * Get profile unit
  71. */
  72. public function getUnit($iProfileId = 0, $aParams = array())
  73. {
  74. $sTemplate = 'profile_' . (!empty($aParams['template']) ? $aParams['template'] : 'unit') . '.html';
  75. return BxDolTemplate::getInstance()->parseHtmlByName($sTemplate, array(
  76. 'thumb_url' => $this->getThumb(),
  77. 'title' => $this->getDisplayName()
  78. ));
  79. }
  80. /**
  81. * Check whether a profile has real image uploaded by user.
  82. */
  83. public function hasImage()
  84. {
  85. return false;
  86. }
  87. /**
  88. * Get picture url
  89. */
  90. public function getPicture()
  91. {
  92. return BxDolTemplate::getInstance()->getImageUrl('account-picture.png');
  93. }
  94. /**
  95. * Get profile avatar
  96. */
  97. public function getAvatar()
  98. {
  99. return BxDolTemplate::getInstance()->getImageUrl('account-avatar.png');
  100. }
  101. /**
  102. * Get profile cover
  103. */
  104. public function getCover()
  105. {
  106. return BxDolTemplate::getInstance()->getImageUrl('cover.jpg');
  107. }
  108. /**
  109. * Get profile thumb
  110. */
  111. public function getThumb()
  112. {
  113. return BxDolTemplate::getInstance()->getImageUrl('account-thumb.png');
  114. }
  115. /**
  116. * Get profile icon
  117. */
  118. public function getIcon()
  119. {
  120. return BxDolTemplate::getInstance()->getImageUrl('account-icon.png');
  121. }
  122. /**
  123. * Get module icon
  124. */
  125. public function getIconModule($iProfileId = 0)
  126. {
  127. return 'user';
  128. }
  129. /**
  130. * Get profile edit url
  131. */
  132. public function getEditUrl()
  133. {
  134. return '';
  135. }
  136. /**
  137. * @see iBxDolProfile::checkAllowedProfileView
  138. */
  139. public function checkAllowedProfileView($iProfileId = 0)
  140. {
  141. return CHECK_ACTION_RESULT_ALLOWED;
  142. }
  143. /**
  144. * @see iBxDolProfile::checkAllowedPostInProfile
  145. */
  146. public function checkAllowedPostInProfile($iProfileId = 0)
  147. {
  148. return _t('_sys_txt_access_denied');
  149. }
  150. /**
  151. * Check if profile is active
  152. */
  153. public function isActive($iProfileId = false)
  154. {
  155. return true;
  156. }
  157. /**
  158. * Is profile online
  159. */
  160. public function isOnline($iProfileId = false)
  161. {
  162. return false;
  163. }
  164. }
  165. /** @} */