BxSpacesModule.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. * @defdroup Spaces Spaces
  7. * @indroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Spaces profiles module.
  13. */
  14. define('BX_SPS_LEVELS_LIMIT', 1);
  15. class BxSpacesModule extends BxBaseModGroupsModule
  16. {
  17. function __construct(&$aModule)
  18. {
  19. parent::__construct($aModule);
  20. $this->_aSearchableNamesExcept[] = $this->_oConfig->CNF['FIELD_JOIN_CONFIRMATION'];
  21. }
  22. public function serviceGetSafeServices()
  23. {
  24. $a = parent::serviceGetSafeServices();
  25. return array_merge($a, array (
  26. 'BrowseTopLevel' => '',
  27. ));
  28. }
  29. public function serviceEntityDelete ($iContentId = 0)
  30. {
  31. $iContentId = $this->_getContent($iContentId, false);
  32. if($iContentId === false)
  33. return false;
  34. $iCount = $this->_oDb->getCountEntriesByParent($iContentId);
  35. if ($iCount > 0)
  36. return MsgBox(_t('_bx_spaces_err_delete_child_presend'));
  37. return $this->_serviceEntityForm ('deleteDataForm', $iContentId);
  38. }
  39. public function serviceEntityParent ($iContentId = 0, $aParams = [])
  40. {
  41. return $this->_serviceTemplateFuncEx ('entryParent', $iContentId, $aParams);
  42. }
  43. public function serviceEntityChilds ($iContentId = 0, $aParams = [])
  44. {
  45. return $this->_serviceTemplateFuncEx ('entryChilds', $iContentId, $aParams);
  46. }
  47. public function serviceBrowseTopLevel ($bDisplayEmptyMsg = false)
  48. {
  49. return $this->_serviceBrowse ('top_level', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg);
  50. }
  51. /**
  52. * Get possible recipients for start conversation form
  53. */
  54. public function actionAjaxGetParentSpace ()
  55. {
  56. $sTerm = bx_get('term');
  57. $iContentId = bx_get('id');
  58. $a = $this->getListSpacesForParent($sTerm, $iContentId, 10);
  59. header('Content-Type:text/javascript; charset=utf-8');
  60. echo(json_encode($a));
  61. }
  62. public function getListSpacesForParent ($sTerm, $iContentId, $iLimit)
  63. {
  64. $CNF = &$this->_oConfig->CNF;
  65. if (!isLogged())
  66. return false;
  67. $iLevelsLimit = BX_SPS_LEVELS_LIMIT;
  68. if(getParam($CNF['PARAM_MULTILEVEL_HIERARCHY']) == 'on')
  69. $iLevelsLimit = 0;
  70. $aRv = array();
  71. $aTmp = $this->_oDb->searchByTermForParentSpace(bx_get_logged_profile_id(), $iContentId, $iLevelsLimit, $sTerm, $iLimit);
  72. foreach ($aTmp as $aSpace) {
  73. $oProfile = BxDolProfile::getInstance($aSpace['profile_id']);
  74. $aRv[] = array (
  75. 'label' => $this->serviceProfileName($aSpace['content_id']),
  76. 'value' => $aSpace['profile_id'],
  77. 'url' => $oProfile->getUrl(),
  78. 'thumb' => $oProfile->getThumb(),
  79. 'unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info'))
  80. );
  81. }
  82. return $aRv;
  83. }
  84. public function _modGroupsCheckAllowedSubscribeAdd(&$aDataEntry, $isPerformAction = false)
  85. {
  86. return parent::_modProfileCheckAllowedSubscribeAdd($aDataEntry, $isPerformAction);
  87. }
  88. }
  89. /** @} */