1
0

BxSpacesModule.php 3.6 KB

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