BxBaseServices.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * System services.
  11. */
  12. class BxBaseServices extends BxDol implements iBxDolProfileService
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. public function serviceProfileUnit ($iContentId)
  19. {
  20. return $this->_serviceProfileFunc('getUnit', $iContentId);
  21. }
  22. public function serviceProfilePicture ($iContentId)
  23. {
  24. return $this->_serviceProfileFunc('getPicture', $iContentId);
  25. }
  26. public function serviceProfileAvatar ($iContentId)
  27. {
  28. return $this->_serviceProfileFunc('getAvatar', $iContentId);
  29. }
  30. public function serviceProfileEditUrl ($iContentId)
  31. {
  32. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=account-settings-info');
  33. }
  34. public function serviceProfileThumb ($iContentId)
  35. {
  36. return $this->_serviceProfileFunc('getThumb', $iContentId);
  37. }
  38. public function serviceProfileIcon ($iContentId)
  39. {
  40. return $this->_serviceProfileFunc('getIcon', $iContentId);
  41. }
  42. public function serviceProfileName ($iContentId)
  43. {
  44. return $this->_serviceProfileFunc('getDisplayName', $iContentId);
  45. }
  46. public function serviceProfileUrl ($iContentId)
  47. {
  48. return $this->_serviceProfileFunc('getUrl', $iContentId);
  49. }
  50. public function serviceFormsHelper ()
  51. {
  52. return new BxTemplAccountForms();
  53. }
  54. public function serviceActAsProfile ()
  55. {
  56. return false;
  57. }
  58. public function servicePrepareFields ($aFieldsProfile)
  59. {
  60. return $aFieldsProfile;
  61. }
  62. public function serviceProfilesSearch ($sTerm, $iLimit)
  63. {
  64. $oDb = BxDolAccountQuery::getInstance();
  65. $aRet = array();
  66. $a = $oDb->searchByTerm($sTerm, $iLimit);
  67. foreach ($a as $r)
  68. $aRet[] = array ('label' => $this->serviceProfileName($r['content_id']), 'value' => $r['profile_id']);
  69. return $aRet;
  70. }
  71. public function _serviceProfileFunc ($sFunc, $iContentId)
  72. {
  73. if (!$iContentId)
  74. return false;
  75. if (!($oAccount = BxDolAccount::getInstance($iContentId)))
  76. return false;
  77. return $oAccount->$sFunc();
  78. }
  79. public function serviceAlertResponseProcessStorageChange ($oAlert)
  80. {
  81. if ('sys_storage_default' != $oAlert->aExtras['option'])
  82. return;
  83. $aStorages = BxDolStorageQuery::getStorageObjects();
  84. foreach ($aStorages as $r) {
  85. if (0 == $r['current_size'] && 0 == $r['current_number'] && ($oStorage = BxDolStorage::getObjectInstance($r['object'])))
  86. $oStorage->changeStorageEngine($oAlert->aExtras['value']);
  87. }
  88. }
  89. }
  90. /** @} */