BxSpacesModule.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. /**
  41. * Get possible recipients for start conversation form
  42. */
  43. public function actionAjaxGetParentSpace ()
  44. {
  45. $sTerm = bx_get('term');
  46. $iContentId = bx_get('id');
  47. $a = $this->getListSpacesForParent($sTerm, $iContentId, 10);
  48. header('Content-Type:text/javascript; charset=utf-8');
  49. echo(json_encode($a));
  50. }
  51. public function checkAllowedSubscribeAdd (&$aDataEntry, $isPerformAction = false)
  52. {
  53. return parent::_checkAllowedSubscribeAdd ($aDataEntry, $isPerformAction);
  54. }
  55. public function getListSpacesForParent ($sTerm, $iContentId, $iLimit)
  56. {
  57. if (!isLogged())
  58. return false;
  59. $aRv = array();
  60. $aTmp = $this->_oDb->searchByTermForParentSpace(bx_get_logged_profile_id(), $iContentId, BX_SPS_LEVELS_LIMIT, $sTerm, $iLimit);
  61. foreach ($aTmp as $aSpace) {
  62. $oProfile = BxDolProfile::getInstance($aSpace['profile_id']);
  63. $aRv[] = array (
  64. 'label' => $this->serviceProfileName($aSpace['content_id']),
  65. 'value' => $aSpace['profile_id'],
  66. 'url' => $oProfile->getUrl(),
  67. 'thumb' => $oProfile->getThumb(),
  68. 'unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info'))
  69. );
  70. }
  71. return $aRv;
  72. }
  73. }
  74. /** @} */