1
0

BxSpacesModule.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 serviceEntityDelete ($iContentId = 0)
  23. {
  24. $iContentId = $this->_getContent($iContentId, false);
  25. if($iContentId === false)
  26. return false;
  27. $iCount = $this->_oDb->getCountEntriesByParent($iContentId);
  28. if ($iCount > 0)
  29. return MsgBox(_t('_bx_spaces_err_delete_child_presend'));
  30. return $this->_serviceEntityForm ('deleteDataForm', $iContentId);
  31. }
  32. public function serviceEntityParent ($iContentId = 0)
  33. {
  34. return $this->_serviceTemplateFunc ('entryParent', $iContentId);
  35. }
  36. public function serviceEntityChilds ($iContentId = 0)
  37. {
  38. return $this->_serviceTemplateFunc ('entryChilds', $iContentId);
  39. }
  40. public function serviceBrowseTopLevel ($bDisplayEmptyMsg = false)
  41. {
  42. return $this->_serviceBrowse ('top_level', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg);
  43. }
  44. /**
  45. * Get possible recipients for start conversation form
  46. */
  47. public function actionAjaxGetParentSpace ()
  48. {
  49. $sTerm = bx_get('term');
  50. $iContentId = bx_get('id');
  51. $a = $this->getListSpacesForParent($sTerm, $iContentId, 10);
  52. header('Content-Type:text/javascript; charset=utf-8');
  53. echo(json_encode($a));
  54. }
  55. public function checkAllowedSubscribeAdd (&$aDataEntry, $isPerformAction = false)
  56. {
  57. return parent::_checkAllowedSubscribeAdd ($aDataEntry, $isPerformAction);
  58. }
  59. public function getListSpacesForParent ($sTerm, $iContentId, $iLimit)
  60. {
  61. $CNF = &$this->_oConfig->CNF;
  62. if (!isLogged())
  63. return false;
  64. $iLevelsLimit = BX_SPS_LEVELS_LIMIT;
  65. if(getParam($CNF['PARAM_MULTILEVEL_HIERARCHY']) == 'on')
  66. $iLevelsLimit = 0;
  67. $aRv = array();
  68. $aTmp = $this->_oDb->searchByTermForParentSpace(bx_get_logged_profile_id(), $iContentId, $iLevelsLimit, $sTerm, $iLimit);
  69. foreach ($aTmp as $aSpace) {
  70. $oProfile = BxDolProfile::getInstance($aSpace['profile_id']);
  71. $aRv[] = array (
  72. 'label' => $this->serviceProfileName($aSpace['content_id']),
  73. 'value' => $aSpace['profile_id'],
  74. 'url' => $oProfile->getUrl(),
  75. 'thumb' => $oProfile->getThumb(),
  76. 'unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info'))
  77. );
  78. }
  79. return $aRv;
  80. }
  81. }
  82. /** @} */