BxBaseServices.php 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712
  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 serviceIsPublicService($s)
  19. {
  20. $sService = bx_gen_method_name($s);
  21. $aServices = $this->serviceGetPublicServices();
  22. return isset($aServices[$sService]);
  23. }
  24. public function serviceGetPublicServices()
  25. {
  26. return array (
  27. 'GetProductsNames' => 'BxBaseServices',
  28. 'GetPageByRequest' => 'BxBaseServicePages',
  29. );
  30. }
  31. public function serviceIsSafeService($s)
  32. {
  33. $sService = bx_gen_method_name($s);
  34. $aSafeServices = $this->serviceGetSafeServices();
  35. return isset($aSafeServices[$sService]);
  36. }
  37. public function serviceGetSafeServices()
  38. {
  39. return array(
  40. 'GetMenu' => 'BxBaseServices',
  41. 'GetCreatePostForm' => 'BxBaseServices',
  42. 'GetProductsNames' => 'BxBaseServices',
  43. 'KeywordSearch' => 'BxBaseServices',
  44. 'GetDataSearchApi' => 'BxBaseServices',
  45. 'Cmts' => 'BxBaseServices',
  46. 'GetFooter' => 'BxBaseServices',
  47. 'SetBadges' => 'BxBaseServices',
  48. 'GetPageContentByRequest' => 'BxBaseServicePages',
  49. 'GetPageBlockData' => 'BxBaseServicePages',
  50. 'SetPageBlockData' => 'BxBaseServicePages',
  51. 'GetUrlInfo' => 'BxBaseServicePages',
  52. 'CreateAccountForm' => 'BxBaseServiceAccount',
  53. 'AccountSettingsEmail' => 'BxBaseServiceAccount',
  54. 'AccountSettingsPassword' => 'BxBaseServiceAccount',
  55. 'AccountSettingsDelAccount' => 'BxBaseServiceAccount',
  56. 'AccountSettingsInfo' => 'BxBaseServiceAccount',
  57. 'ForgotPassword' => 'BxBaseServiceAccount',
  58. 'SwitchProfile' => 'BxBaseServiceAccount',
  59. 'AccountProfileSwitcher' => 'BxBaseServiceAccount',
  60. 'EmailConfirmation' => 'BxBaseServiceAccount',
  61. 'ConfirmEmail' => 'BxBaseServiceAccount',
  62. 'CategoriesList' => 'BxBaseServiceCategory',
  63. 'Test' => 'BxBaseServiceLogin',
  64. 'MemberAuthCode' => 'BxBaseServiceLogin',
  65. 'LoginForm' => 'BxBaseServiceLogin',
  66. 'LoginFormOnly' => 'BxBaseServiceLogin',
  67. 'Logout' => 'BxBaseServiceLogin',
  68. 'KeywordsCloud' => 'BxBaseServiceMetatags',
  69. 'AccountProfileSwitcher' => 'BxBaseServiceProfiles',
  70. 'ProfileMembership' => 'BxBaseServiceProfiles',
  71. 'ProfileNotifications' => 'BxBaseServiceProfiles',
  72. 'GetCountOnlineProfiles' => 'BxBaseServiceProfiles',
  73. 'BrowseRecommendationsFriends' => 'BxBaseServiceProfiles',
  74. 'BrowseRecommendationsSubscriptions' => 'BxBaseServiceProfiles',
  75. 'BrowseFriends' => 'BxBaseServiceProfiles',
  76. 'SetMembership' => 'BxBaseServiceProfiles',
  77. 'BrowseFriendRequests' => 'BxBaseServiceProfiles',
  78. 'BrowseFriendRequested' => 'BxBaseServiceProfiles',
  79. 'BrowseSubscribedMe' => 'BxBaseServiceProfiles',
  80. 'BrowseSubscriptions' => 'BxBaseServiceProfiles',
  81. 'BrowseMembers' => 'BxBaseServiceProfiles',
  82. 'BrowseInvitations' => 'BxBaseServiceProfiles',
  83. 'UpdateSettings' => 'BxBaseServiceProfiles',
  84. 'Befriend' => 'BxBaseServiceProfiles',
  85. 'ProfileCounters' => 'BxBaseServiceProfiles',
  86. 'ProfileInfo' => 'BxBaseServiceProfiles',
  87. 'GetChartGrowth' => 'BxBaseChartServices',
  88. 'GetChartStats' => 'BxBaseChartServices',
  89. 'GetDataByInterval' => 'BxBaseChartServices',
  90. 'GetCartItemsCount' => 'BxBasePaymentsServices',
  91. 'GetOrdersCount' => 'BxBasePaymentsServices',
  92. 'Do' => 'BxBaseReportServices',
  93. 'GetPerformedBy' => 'BxBaseReportServices',
  94. 'Do' => 'BxBaseVoteServices',
  95. 'GetPerformedBy' => 'BxBaseVoteServices',
  96. 'Perform' => 'BxBaseFeatureServices',
  97. 'Perform' => 'BxBaseFavoriteServices',
  98. 'GetPerformedBy' => 'BxBaseFavoriteServices',
  99. 'Perform' => 'BxBaseServiceConnections',
  100. 'Perform' => 'BxBaseServiceRecommendations',
  101. 'GetDataApi' => 'BxBaseCmtsServices',
  102. 'GetDataApi' => 'BxBaseUploaderServices',
  103. 'GetStatBlock' => 'BxBaseDashboardServices',
  104. 'PerfomActionApi' => 'BxBaseServiceGrid',
  105. 'GetLabels' => 'BxBaseLabelsServices',
  106. 'GetForm' => 'BxBaseSearchExtendedServices',
  107. 'GetResults' => 'BxBaseSearchExtendedServices'
  108. );
  109. }
  110. public function serviceGetPreloaderContent($sName) {
  111. $sResult = '';
  112. switch($sName) {
  113. case 'icons_css':
  114. if(($sCss = BxDolIconset::getObjectInstance()->getPreloaderCss()) !== false)
  115. $sResult = $sCss;
  116. break;
  117. case 'icons_js':
  118. if(($sJs = BxDolIconset::getObjectInstance()->getPreloaderJs()) !== false)
  119. $sResult = $sJs;
  120. break;
  121. case 'tailwind':
  122. $sFile = getParam('sys_css_tailwind_default');
  123. if(empty($sFile))
  124. $sFile = 'tailwind.min.css';
  125. $sPath = '{dir_plugins_public}tailwind/css/|';
  126. if($sFile == 'cdn')
  127. $sResult = [
  128. 'https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4',
  129. $sPath . 'tailwind.min.css' //TODO: Replace this with correct file name.
  130. ];
  131. else
  132. $sResult = $sPath . $sFile;
  133. break;
  134. }
  135. return $sResult;
  136. }
  137. /**
  138. * @page service Service Calls
  139. * @section bx_system_general System Services
  140. * @subsection bx_system_general-general General
  141. * @subsubsection bx_system_general-module_check_for_update module_check_for_update
  142. *
  143. * @code bx_srv('system', 'module_check_for_update', ["bx_posts"]); @endcode
  144. * @code bx_srv('system', 'module_check_for_update', ["bx_posts"], 'TemplServices'); @endcode
  145. * @code {{~system:module_check_for_update:TemplServices["bx_posts"]~}} @endcode
  146. *
  147. * Checks whether an update is available for requested module or not.
  148. * @param $mixedModule - module ID/name to check the updates for.
  149. * @return array with information about the update, false if nothing was found
  150. *
  151. * @see BxBaseServices::serviceModuleCheckForUpdate
  152. */
  153. /**
  154. * @ref bx_system_general-module_check_for_update "module_check_for_update"
  155. */
  156. public function serviceModuleCheckForUpdate($mixedModule)
  157. {
  158. $aModule = BxDolModuleQuery::getInstance()->{'getModuleBy' . (is_numeric($mixedModule) ? 'Id' : 'Name')}($mixedModule, false);
  159. if(empty($aModule) || !is_array($aModule))
  160. return false;
  161. $aUpdates = BxDolStudioInstallerUtils::getInstance()->checkUpdatesByModule($aModule['name']);
  162. if(empty($aUpdates) || !is_array($aUpdates))
  163. return false;
  164. $aUpdate = array_shift($aUpdates);
  165. return array(
  166. 'version_from' => $aUpdate['file_version'],
  167. 'version_to' => $aUpdate['file_version_to'],
  168. 'file_id' => $aUpdate['file_id']
  169. );
  170. }
  171. /**
  172. * @page service Service Calls
  173. * @section bx_system_general System Services
  174. * @subsection bx_system_general-general General
  175. * @subsubsection bx_system_general-module_update module_update
  176. *
  177. * @code bx_srv('system', 'module_update', ["bx_posts"]); @endcode
  178. * @code bx_srv('system', 'module_update', ["bx_posts"], 'TemplServices'); @endcode
  179. * @code {{~system:module_update:TemplServices["bx_posts"]~}} @endcode
  180. *
  181. * Download and install an update for requested module. The operation may be performed
  182. * immediately or by Transient Cron task. The second way is more common.
  183. * @param $mixedModule - module ID/name to check the updates for.
  184. * @return integer value determining the result of the operation. It can be one of the following values:
  185. * BX_DOL_STUDIO_IU_RC_SUCCESS, BX_DOL_STUDIO_IU_RC_FAILED or BX_DOL_STUDIO_IU_RC_SCHEDULED.
  186. *
  187. * @see BxBaseServices::serviceModuleUpdate
  188. */
  189. /**
  190. * @ref bx_system_general-module_update "module_update"
  191. */
  192. public function serviceModuleUpdate($mixedModule)
  193. {
  194. $aModule = BxDolModuleQuery::getInstance()->{'getModuleBy' . (is_numeric($mixedModule) ? 'Id' : 'Name')}($mixedModule, false);
  195. if(empty($aModule) || !is_array($aModule))
  196. return BX_DOL_STUDIO_IU_RC_FAILED;
  197. $aResult = BxDolStudioInstallerUtils::getInstance()->downloadUpdatePublic($aModule['name'], true);
  198. return $aResult['code'];
  199. }
  200. /**
  201. * @page service Service Calls
  202. * @section bx_system_general System Services
  203. * @subsection bx_system_general-general General
  204. * @subsubsection bx_system_general-module_delete module_delete
  205. *
  206. * @code bx_srv('system', 'module_delete', ["bx_posts"]); @endcode
  207. * @code bx_srv('system', 'module_delete', ["bx_posts", true], 'TemplServices'); @endcode
  208. * @code {{~system:module_delete:TemplServices["bx_posts"]~}} @endcode
  209. *
  210. * Delete the requested module. By default only uninstalled module can be deleted.
  211. * The operation may be performed immediately or by Transient Cron task. The second way is more common.
  212. * @param $sModule - module name to delete.
  213. * @param $bForceUninstall - if 'true' is passed the module will be uninstalled before deletion.
  214. * @return integer value determining the result of the operation. It can be one of the following values:
  215. * BX_DOL_STUDIO_IU_RC_SUCCESS, BX_DOL_STUDIO_IU_RC_FAILED or BX_DOL_STUDIO_IU_RC_SCHEDULED.
  216. *
  217. * @see BxBaseServices::serviceModuleDelete
  218. */
  219. /**
  220. * @ref bx_system_general-module_delete "module_delete"
  221. */
  222. public function serviceModuleDelete($sModule, $bForceUninstall = false)
  223. {
  224. $sModulePath = '';
  225. $oInstallerUtils = BxDolStudioInstallerUtils::getInstance();
  226. $aModule = BxDolModuleQuery::getInstance()->getModuleByName($sModule, false);
  227. if(!empty($aModule) && is_array($aModule)) {
  228. if(!$bForceUninstall)
  229. return BX_DOL_STUDIO_IU_RC_FAILED;
  230. $sModulePath = $aModule['path'];
  231. $aResult = $oInstallerUtils->perform($sModulePath, 'uninstall', array('auto_disable' => $bForceUninstall));
  232. if($aResult['code'] != BX_DOL_STUDIO_IU_RC_SUCCESS)
  233. return BX_DOL_STUDIO_IU_RC_FAILED;
  234. }
  235. else {
  236. $aModules = $oInstallerUtils->getModules(false);
  237. if(!isset($aModules[$sModule]))
  238. return BX_DOL_STUDIO_IU_RC_FAILED;
  239. $sModulePath = $aModules[$sModule]['dir'];
  240. }
  241. $aResult = $oInstallerUtils->perform($sModulePath, 'delete');
  242. return $aResult['code'];
  243. }
  244. /**
  245. * @page service Service Calls
  246. * @section bx_system_general System Services
  247. * @subsection bx_system_general-general General
  248. * @subsubsection bx_system_general-module_install module_install
  249. *
  250. * @code bx_srv('system', 'module_install', ["bx_posts"]); @endcode
  251. * @code bx_srv('system', 'module_install', ["bx_posts", true], 'TemplServices'); @endcode
  252. * @code {{~system:module_install:TemplServices["bx_posts"]~}} @endcode
  253. *
  254. * Install the requested module. By default the module will be installed only.
  255. * @param $sModule - module name to install.
  256. * @param $bForceEnable - if 'true' is passed the module will be automatically enabled after installation.
  257. * @return boolean value determining the result of the operation.
  258. *
  259. * @see BxBaseServices::serviceModuleInstall
  260. */
  261. /**
  262. * @ref bx_system_general-module_install "module_install"
  263. */
  264. public function serviceModuleInstall($sModule, $bForceEnable = false)
  265. {
  266. $oInstallerUtils = BxDolStudioInstallerUtils::getInstance();
  267. $aModules = $oInstallerUtils->getModules(false);
  268. if(!isset($aModules[$sModule]))
  269. return false;
  270. $aResult = $oInstallerUtils->perform($aModules[$sModule]['dir'], 'install', array('auto_enable' => $bForceEnable));
  271. if($aResult['code'] != BX_DOL_STUDIO_IU_RC_SUCCESS)
  272. return false;
  273. return true;
  274. }
  275. /**
  276. * @page service Service Calls
  277. * @section bx_system_general System Services
  278. * @subsection bx_system_general-general General
  279. * @subsubsection bx_system_general-module_uninstall module_uninstall
  280. *
  281. * @code bx_srv('system', 'module_uninstall', ["bx_posts"]); @endcode
  282. * @code bx_srv('system', 'module_uninstall', ["bx_posts", true], 'TemplServices'); @endcode
  283. * @code {{~system:module_uninstall:TemplServices["bx_posts"]~}} @endcode
  284. *
  285. * Uninstall the requested module. By default only disabled module can be uninstalled.
  286. * @param $mixedModule - module ID/name to uninstall.
  287. * @param $bForceDisable - if 'true' is passed the module will be automatically disabled before uninstallation.
  288. * @return boolean value determining the result of the operation.
  289. *
  290. * @see BxBaseServices::serviceModuleUninstall
  291. */
  292. /**
  293. * @ref bx_system_general-module_uninstall "module_uninstall"
  294. */
  295. public function serviceModuleUninstall($mixedModule, $bForceDisable = false)
  296. {
  297. $aModule = BxDolModuleQuery::getInstance()->{'getModuleBy' . (is_numeric($mixedModule) ? 'Id' : 'Name')}($mixedModule, false);
  298. if(empty($aModule) || !is_array($aModule))
  299. return false;
  300. if((int)$aModule['enabled'] != 0 && !$bForceDisable)
  301. return false;
  302. $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall', array('auto_disable' => $bForceDisable));
  303. if($aResult['code'] != BX_DOL_STUDIO_IU_RC_SUCCESS)
  304. return false;
  305. return true;
  306. }
  307. /**
  308. * @page service Service Calls
  309. * @section bx_system_general System Services
  310. * @subsection bx_system_general-general General
  311. * @subsubsection bx_system_general-module_enable module_enable
  312. *
  313. * @code bx_srv('system', 'module_enable', ["bx_posts"]); @endcode
  314. * @code bx_srv('system', 'module_enable', ["bx_posts"], 'TemplServices'); @endcode
  315. * @code {{~system:module_enable:TemplServices["bx_posts"]~}} @endcode
  316. *
  317. * Enable the requested module.
  318. * @param $mixedModule - module ID/name to enable.
  319. * @return boolean value determining the result of the operation.
  320. *
  321. * @see BxBaseServices::serviceModuleEnable
  322. */
  323. /**
  324. * @ref bx_system_general-module_enable "module_enable"
  325. */
  326. public function serviceModuleEnable($mixedModule)
  327. {
  328. $aModule = BxDolModuleQuery::getInstance()->{'getModuleBy' . (is_numeric($mixedModule) ? 'Id' : 'Name')}($mixedModule, false);
  329. if(empty($aModule) || !is_array($aModule))
  330. return false;
  331. if((int)$aModule['enabled'] != 0)
  332. return false;
  333. $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'enable');
  334. if($aResult['code'] != BX_DOL_STUDIO_IU_RC_SUCCESS)
  335. return false;
  336. return true;
  337. }
  338. /**
  339. * @page service Service Calls
  340. * @section bx_system_general System Services
  341. * @subsection bx_system_general-general General
  342. * @subsubsection bx_system_general-module_disable module_disable
  343. *
  344. * @code bx_srv('system', 'module_disable', ["bx_posts"]); @endcode
  345. * @code bx_srv('system', 'module_disable', ["bx_posts"], 'TemplServices'); @endcode
  346. * @code {{~system:module_disable:TemplServices["bx_posts"]~}} @endcode
  347. *
  348. * Disable the requested module.
  349. * @param $mixedModule - module ID/name to disable.
  350. * @return boolean value determining the result of the operation.
  351. *
  352. * @see BxBaseServices::serviceModuleDisable
  353. */
  354. /**
  355. * @ref bx_system_general-module_disable "module_disable"
  356. */
  357. public function serviceModuleDisable($mixedModule)
  358. {
  359. $aModule = BxDolModuleQuery::getInstance()->{'getModuleBy' . (is_numeric($mixedModule) ? 'Id' : 'Name')}($mixedModule, false);
  360. if(empty($aModule) || !is_array($aModule))
  361. return false;
  362. if((int)$aModule['enabled'] == 0)
  363. return false;
  364. $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'disable');
  365. if($aResult['code'] != BX_DOL_STUDIO_IU_RC_SUCCESS)
  366. return false;
  367. return true;
  368. }
  369. /**
  370. * @page service Service Calls
  371. * @section bx_system_general System Services
  372. * @subsection bx_system_general-general General
  373. * @subsubsection bx_system_general-is_module_installed is_module_installed
  374. *
  375. * @code bx_srv('system', 'is_module_installed', ["bx_posts"]); @endcode
  376. * @code bx_srv('system', 'is_module_installed', ["bx_posts"], 'TemplServices'); @endcode
  377. * @code {{~system:is_module_installed:TemplServices["bx_posts"]~}} @endcode
  378. *
  379. * Checks whether the requested module is installed or not.
  380. * @param $mixedModule - module ID/name to check.
  381. * @return boolean value determining the result of the operation.
  382. *
  383. * @see BxBaseServices::serviceIsModuleInstalled
  384. */
  385. /**
  386. * @ref bx_system_general-is_module_installed "is_module_installed"
  387. */
  388. public function serviceIsModuleInstalled($mixedModule)
  389. {
  390. $aModule = BxDolModuleQuery::getInstance()->{'getModuleBy' . (is_numeric($mixedModule) ? 'Id' : 'Name')}($mixedModule, false);
  391. return !empty($aModule) && is_array($aModule);
  392. }
  393. /**
  394. * @page service Service Calls
  395. * @section bx_system_general System Services
  396. * @subsection bx_system_general-general General
  397. * @subsubsection bx_system_general-is_module_enabled is_module_enabled
  398. *
  399. * @code bx_srv('system', 'is_module_enabled', ["bx_posts"]); @endcode
  400. * @code bx_srv('system', 'is_module_enabled', ["bx_posts"], 'TemplServices'); @endcode
  401. * @code {{~system:is_module_enabled:TemplServices["bx_posts"]~}} @endcode
  402. *
  403. * Checks whether the requested module is enabled or not.
  404. * @param $mixedModule - module ID/name to check.
  405. * @return boolean value determining the result of the operation.
  406. *
  407. * @see BxBaseServices::serviceIsModuleEnabled
  408. */
  409. /**
  410. * @ref bx_system_general-is_module_enabled "is_module_enabled"
  411. */
  412. public function serviceIsModuleEnabled($mixedModule)
  413. {
  414. $aModule = BxDolModuleQuery::getInstance()->{'getModuleBy' . (is_numeric($mixedModule) ? 'Id' : 'Name')}($mixedModule, false);
  415. return !empty($aModule) && is_array($aModule) && (int)$aModule['enabled'] != 0;
  416. }
  417. /**
  418. * Checks whether a module is a 'Content' module or not.
  419. *
  420. * @param string $mixedModule - module name or an instance of Module class.
  421. * @return boolean result of operation.
  422. */
  423. public function serviceIsModuleContent($mixedModule)
  424. {
  425. if($mixedModule instanceof BxDolModule)
  426. $mixedModule = $mixedModule->getName();
  427. return BxDolModuleQuery::getInstance()->isModuleContent($mixedModule);
  428. }
  429. /**
  430. * Checks whether a module is a 'Context' module or not.
  431. *
  432. * @param string $mixedModule - module name or an instance of Module class.
  433. * @return boolean result of operation.
  434. */
  435. public function serviceIsModuleContext($mixedModule)
  436. {
  437. if($mixedModule instanceof BxDolModule)
  438. $mixedModule = $mixedModule->getName();
  439. return BxDolModuleQuery::getInstance()->isModuleContext($mixedModule);
  440. }
  441. /**
  442. * Checks whether a module is a 'Profile' module or not.
  443. *
  444. * @param string $mixedModule - module name or an instance of Module class.
  445. * @return boolean result of operation.
  446. */
  447. public function serviceIsModuleProfile($mixedModule)
  448. {
  449. if($mixedModule instanceof BxDolModule)
  450. $mixedModule = $mixedModule->getName();
  451. return BxDolModuleQuery::getInstance()->isModuleProfile($mixedModule);
  452. }
  453. /**
  454. * Get modules by type. Available types are 'content', 'context', 'profile'.
  455. *
  456. * @param type $sType - string with type.
  457. * @return array of modules.
  458. */
  459. public function serviceGetModulesByType($sType, $aParams = [])
  460. {
  461. $oModuleQuery = BxDolModuleQuery::getInstance();
  462. if(!$oModuleQuery->checkModulesSubtypes()) {
  463. $oInstallerUtils = new BxDolInstallerUtils();
  464. $aModules = $oModuleQuery->getModulesBy(['type' => 'modules']);
  465. foreach($aModules as $aModule)
  466. if(($iModuleSubtypes = $oInstallerUtils->getSubtypes($aModule['name'])) != 0)
  467. $oModuleQuery->updateModule(['subtypes' => $iModuleSubtypes], ['id' => $aModule['id']]);
  468. }
  469. $iSubtypes = 0;
  470. switch($sType) {
  471. case 'content';
  472. $iSubtypes = BX_DOL_MODULE_SUBTYPE_TEXT;
  473. break;
  474. case 'context';
  475. $iSubtypes = BX_DOL_MODULE_SUBTYPE_CONTEXT;
  476. break;
  477. case 'profile';
  478. $iSubtypes = BX_DOL_MODULE_SUBTYPE_PROFILE;
  479. break;
  480. }
  481. $aResults = $oModuleQuery->getModulesBy(array_merge([
  482. 'type' => 'modules_subtypes',
  483. 'value' => $iSubtypes,
  484. 'active' => 1
  485. ], array_intersect_key($aParams, array_flip(['id_as_key', 'name_as_key']))));
  486. return $aResults;
  487. }
  488. public function serviceGetModulesBySubtypeSimple($sType)
  489. {
  490. $a = $this->serviceGetModulesByType($sType, ['name_as_key' => true]);
  491. return array_map(function ($r) {
  492. return $r['title'];
  493. }, $a);
  494. }
  495. public function serviceProfileUnit ($iContentId, $aParams = array())
  496. {
  497. return $this->_serviceProfileFunc('getUnit', $iContentId, $aParams);
  498. }
  499. public function serviceProfileUnitApi ($iContentId, $aParams = [])
  500. {
  501. return $this->_serviceProfileFunc('getUnitApi', $iContentId, $aParams);
  502. }
  503. public function serviceHasImage ($iContentId)
  504. {
  505. return false;
  506. }
  507. public function serviceProfilePicture ($iContentId)
  508. {
  509. return BxDolTemplate::getInstance()->getImageUrl('account.svg');
  510. }
  511. public function serviceProfileAvatar ($iContentId)
  512. {
  513. return BxDolTemplate::getInstance()->getImageUrl('account.svg');
  514. }
  515. public function serviceProfileCover ($iContentId)
  516. {
  517. return '';
  518. }
  519. public function serviceProfileEditUrl ($iContentId)
  520. {
  521. return bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=account-settings-info'));
  522. }
  523. public function serviceProfileThumb ($iContentId)
  524. {
  525. return $this->_serviceProfileFunc('getThumb', $iContentId);
  526. }
  527. public function serviceProfileIcon ($iContentId)
  528. {
  529. return $this->_serviceProfileFunc('getIcon', $iContentId);
  530. }
  531. public function serviceProfileName ($iContentId)
  532. {
  533. return $this->_serviceProfileFunc('getDisplayName', $iContentId);
  534. }
  535. public function serviceProfileUrl ($iContentId)
  536. {
  537. return $this->_serviceProfileFunc('getUrl', $iContentId);
  538. }
  539. /**
  540. * @see iBxDolProfileService::serviceCheckAllowedProfileView
  541. */
  542. public function serviceCheckAllowedProfileView($iContentId)
  543. {
  544. return _t('_Access denied');
  545. }
  546. /**
  547. * @see iBxDolProfileService::serviceCheckAllowedProfileContact
  548. */
  549. public function serviceCheckAllowedProfileContact($iContentId)
  550. {
  551. return _t('_Access denied');
  552. }
  553. /**
  554. * @see iBxDolProfileService::serviceCheckAllowedPostInProfile
  555. */
  556. public function serviceCheckAllowedPostInProfile($iContentId, $sPostModule = '')
  557. {
  558. return _t('_Access denied');
  559. }
  560. /**
  561. * @see iBxDolProfileService::serviceCheckAllowedModuleActionInProfile
  562. */
  563. public function serviceCheckAllowedModuleActionInProfile($iContentId, $sPostModule, $sActionName)
  564. {
  565. return _t('_Access denied');
  566. }
  567. /**
  568. * @see iBxDolProfileService::serviceGetSpaceTitle
  569. */
  570. public function serviceGetSpaceTitle()
  571. {
  572. return '';
  573. }
  574. /**
  575. * @see iBxDolProfileService::serviceGetParticipatingProfiles
  576. */
  577. public function serviceGetParticipatingProfiles($iProfileId, $aConnectionObject = false)
  578. {
  579. return array();
  580. }
  581. /**
  582. * @page service Service Calls
  583. * @section bx_system_general System Services
  584. * @subsection bx_system_general-general General
  585. * @subsubsection bx_system_general-get_create_post_form get_create_post_form
  586. *
  587. * @code bx_srv('system', 'get_create_post_form', [false, "bx_posts"], 'TemplServices'); @endcode
  588. * @code {{~system:get_create_post_form:TemplServices[false,"bx_posts"]~}} @endcode
  589. *
  590. * Get United Create Post form.
  591. * @param $mixedContextId - context which the post will be created in:
  592. * - false = 'Public' post form;
  593. * - 0 = 'Profile' post form, which allows to post in your own profile and connections;
  594. * - n = 'Context' post form, which allows to post in context (3d party profile, group, event, etc).
  595. * @param $sDefault - tab selected by default.
  596. * @param $aCustom - an array with custom paramaters.
  597. * @return string with form content
  598. *
  599. * @see BxBaseServices::serviceGetCreatePostForm
  600. */
  601. /**
  602. * @ref bx_system_general-get_create_post_form "get_create_post_form"
  603. */
  604. public function serviceGetCreatePostForm($mixedContextId = false, $sDefault = '', $aCustom = array())
  605. {
  606. if(!isLogged() || ($mixedContextId !== false && !is_numeric($mixedContextId)))
  607. return '';
  608. $oProfile = BxDolProfile::getInstance();
  609. if(!$oProfile)
  610. return '';
  611. if($mixedContextId !== false)
  612. $mixedContextId = (int)(!empty($mixedContextId) ? -$mixedContextId : $oProfile->id());
  613. $oMenu = BxDolMenu::getObjectInstance('sys_create_post');
  614. if(!$oMenu)
  615. return '';
  616. $oMenu->setContextId($mixedContextId);
  617. $aMenuItems = $oMenu->getMenuItems();
  618. if(empty($aMenuItems) || !is_array($aMenuItems))
  619. return '';
  620. if(empty($sDefault)) {
  621. $aDefault = array_shift($aMenuItems);
  622. $sDefault = !empty($aDefault['module']) ? $aDefault['module'] : $aDefault['name'];
  623. }
  624. $oMenu->setSelected($sDefault, $sDefault);
  625. $oContext = false;
  626. $bContext = $mixedContextId !== false;
  627. if($bContext && ($oContext = BxDolProfile::getInstance(abs($mixedContextId))) !== false)
  628. if(bx_srv($oContext->getModule(), 'check_allowed_post_in_profile', [$oContext->getContentId(), $sDefault]) !== CHECK_ACTION_RESULT_ALLOWED)
  629. return '';
  630. $sTitle = '_sys_page_block_title_create_post';
  631. if(!$bContext)
  632. $sTitle = _t($sTitle . '_public');
  633. else if($mixedContextId < 0) {
  634. $sTitle = _t($sTitle . '_context');
  635. if($oContext)
  636. $sTitle = bx_replace_markers($sTitle, [
  637. 'display_name' => $oContext->getDisplayName()
  638. ]);
  639. }
  640. else
  641. $sTitle = _t($sTitle);
  642. $sPlaceholder = _t('_sys_txt_create_post_placeholder', $oProfile->getDisplayName());
  643. $oDbModules = BxDolModuleQuery::getInstance();
  644. $oTemplate = BxDolTemplate::getInstance();
  645. $oTemplate->addJs(['BxDolCreatePost.js']);
  646. $aPreloadingList = [];
  647. $aModules = explode(',', getParam('sys_create_post_form_preloading_list'));
  648. if(!empty($aModules))
  649. foreach($aModules as $sModule) {
  650. $aModule = $oDbModules->getModuleByName($sModule);
  651. if(empty($aModule) || !is_array($aModule))
  652. continue;
  653. $aPreloadingList[$sModule] = $aModule['uri'];
  654. }
  655. if(bx_is_api()) {
  656. return [
  657. 'title' => $sTitle,
  658. 'content' => [
  659. bx_api_get_block('get_create_post_form', [
  660. 'menu' => $oMenu->getCodeAPI(),
  661. 'params' => ['context_id' => $mixedContextId]])
  662. ]
  663. ];
  664. }
  665. $sJsObject = 'oBxDolCreatePost';
  666. $sJsContent = $oTemplate->_wrapInTagJsCode("var " . $sJsObject . " = new BxDolCreatePost(" . json_encode([
  667. 'sObjName' => $sJsObject,
  668. 'sRootUrl' => BX_DOL_URL_ROOT,
  669. 'sDefault' => $sDefault,
  670. 'iContextId' => $bContext ? $mixedContextId : 0,
  671. 'oPreloadingList' => $aPreloadingList,
  672. 'oCustom' => $aCustom
  673. ]) . ");");
  674. return [
  675. 'title' => $sTitle,
  676. 'content' => $oTemplate->parseHtmlByName('create_post_form.html', [
  677. 'default' => $sDefault,
  678. 'placeholder' => $sPlaceholder,
  679. 'user_thumb' => $oProfile->getUnit(0, ['template' => 'unit_wo_info_links']),
  680. 'form' => bx_srv($sDefault, 'get_create_post_form', [[
  681. 'context_id' => $mixedContextId,
  682. 'ajax_mode' => true,
  683. 'absolute_action_url' => true,
  684. 'custom' => $aCustom
  685. ]]),
  686. 'js_object' => $sJsObject,
  687. 'js_content' => $sJsContent
  688. ]),
  689. 'menu' => $oMenu->getMenuItemsCount() > 1 ? $oMenu : ''
  690. ];
  691. }
  692. public function serviceGetOptionsCreatePostFormPreloadingList()
  693. {
  694. $oMenu = BxDolMenu::getObjectInstance('sys_create_post');
  695. if(!$oMenu)
  696. return [];
  697. $aMenuItems = $oMenu->getMenuItems();
  698. $aResult = [];
  699. foreach($aMenuItems as $aMenuItem) {
  700. $sModule = !empty($aMenuItem['module']) ? $aMenuItem['module'] : $aMenuItem['name'];
  701. if(!bx_srv('system', 'is_module_enabled', [$sModule]))
  702. continue;
  703. $aResult[] = [
  704. 'key' => $sModule,
  705. 'value' => _t('_' . $sModule)
  706. ];
  707. }
  708. return $aResult;
  709. }
  710. public function serviceGetBlockAuthor($sModule, $iContentId = 0)
  711. {
  712. if(!$iContentId && bx_get('id') !== false)
  713. $iContentId = (int)bx_get('id');
  714. $sMethodGetAuthor = 'get_author';
  715. if(!$sModule || !$iContentId || !BxDolRequest::serviceExists($sModule, $sMethodGetAuthor))
  716. return '';
  717. $iAuthor = bx_srv($sModule, $sMethodGetAuthor, [$iContentId]);
  718. if(!$iAuthor)
  719. return '';
  720. $oAuthor = BxDolProfile::getInstance($iAuthor);
  721. if(!$oAuthor)
  722. return '';
  723. $sModuleAuthor = $oAuthor->getModule();
  724. $sMethodGetCover = 'entity_cover';
  725. if(!BxDolRequest::serviceExists($sModuleAuthor, $sMethodGetCover))
  726. return '';
  727. return bx_srv($sModuleAuthor, $sMethodGetCover, [$oAuthor->getContentId(), [
  728. 'use_as_author' => true,
  729. 'show_text' => false
  730. ]]);
  731. }
  732. public function serviceGetBlockAskAssistant($aParams = [])
  733. {
  734. $iAssistant = BxDolAI::getAssistantForAskBlock();
  735. if(!$iAssistant)
  736. return '';
  737. return BxDolAIAssistant::getObjectInstance($iAssistant)->getAskBlock($aParams);
  738. }
  739. public function serviceGetMenu($aParams)
  740. {
  741. $bIsApi = bx_is_api();
  742. $mixedResulEmpty = $bIsApi ? [] : '';
  743. if($bIsApi && is_string($aParams))
  744. $aParams = bx_api_get_browse_params($aParams);
  745. if(!isset($aParams['object']))
  746. return $mixedResulEmpty;
  747. $oMenu = BxDolMenu::getObjectInstance($aParams['object']);
  748. if(!$oMenu)
  749. return $mixedResulEmpty;
  750. if(!empty($aParams['params']) && is_array($aParams['params']))
  751. $oMenu->setContentParams($aParams['params']);
  752. return $bIsApi ? $oMenu->getCodeAPI() : $oMenu->getCode();
  753. }
  754. /**
  755. * @page service Service Calls
  756. * @section bx_system_general System Services
  757. * @subsection bx_system_general-general General
  758. * @subsubsection bx_system_general-get_site_submenu get_site_submenu
  759. *
  760. * @code bx_srv('system', 'get_site_submenu', [], 'TemplServices'); @endcode
  761. * @code {{~system:get_site_submenu:TemplServices[]~}} @endcode
  762. *
  763. * Get Site Submenu code.
  764. * @see BxBaseServices::serviceGetSiteSubmenu
  765. */
  766. /**
  767. * @ref bx_system_general-get_site_submenu "get_site_submenu"
  768. */
  769. public function serviceGetSiteSubmenu()
  770. {
  771. $oMenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  772. return $oMenu ? $oMenu->getCode() : '';
  773. }
  774. /**
  775. * @page service Service Calls
  776. * @section bx_system_general System Services
  777. * @subsection bx_system_general-general General
  778. * @subsubsection bx_system_general-get_products_names get_products_names
  779. *
  780. * @code bx_srv('system', 'get_products_names', [], 'TemplServices');
  781. *
  782. * @code http://example.com/m/oauth2/com/get_products_names?module=system&class=BaseServices @endcode
  783. * @code http://hihi.una.io/modules/?r=oauth2/com/get_products_names&module=system&class=BaseServices @endcode
  784. *
  785. * Get an array of products names from all modules with payments functionality.
  786. * @param $iVendorId filter products by vendor ID.
  787. * @param $iLimit limit number of records from one module.
  788. * @return array of products where key id product name and value is module name
  789. *
  790. * @see BxBaseServices::serviceGetProductsNames
  791. */
  792. /**
  793. * @ref bx_system_general-get_products_names "get_products_names"
  794. */
  795. public function serviceGetProductsNames($iVendorId = 0, $iLimit = 1000)
  796. {
  797. $o = BxDolPayments::getInstance();
  798. if (!$o)
  799. return array();
  800. return $o->getProductsNames($iVendorId, $iLimit);
  801. }
  802. /**
  803. * @see iBxDolProfileService::serviceCheckSpacePrivacy
  804. */
  805. public function serviceCheckSpacePrivacy($iContentId)
  806. {
  807. return _t('_Access denied');
  808. }
  809. public function serviceFormsHelper ()
  810. {
  811. return new BxTemplAccountForms();
  812. }
  813. public function serviceActAsProfile ()
  814. {
  815. return false;
  816. }
  817. public function serviceGetModerators($iContentId)
  818. {
  819. $aModerators = BxDolAclQuery::getInstance()->getProfilesByMembership([
  820. MEMBERSHIP_ID_MODERATOR,
  821. MEMBERSHIP_ID_ADMINISTRATOR
  822. ]);
  823. $aIds = [];
  824. array_walk($aModerators, function ($aItem, $iKey, $aParams) {
  825. if(!empty($aItem['id']))
  826. $aParams[0][] = (int)$aItem['id'];
  827. }, [&$aIds]);
  828. return $aIds;
  829. }
  830. public function servicePrepareFields ($aFieldsProfile)
  831. {
  832. return $aFieldsProfile;
  833. }
  834. public function serviceProfilesSearch ($sTerm, $iLimit)
  835. {
  836. $oDb = BxDolAccountQuery::getInstance();
  837. $aRet = array();
  838. $a = $oDb->searchByTerm($sTerm, $iLimit);
  839. foreach ($a as $r)
  840. $aRet[] = array ('label' => $this->serviceProfileName($r['content_id']), 'value' => $r['profile_id']);
  841. return $aRet;
  842. }
  843. /**
  844. * @page service Service Calls
  845. * @section bx_system_general System Services
  846. * @subsection bx_system_general-general General
  847. * @subsubsection bx_system_general-keyword_search keyword_search
  848. *
  849. * @code bx_srv('system', 'keyword_search', ["bx_posts", ["keyword" => "test"}], 'TemplServices'); @endcode
  850. *
  851. * @code {{~system:keyword_search:TemplServices["bx_posts", {"keyword":"test"}]~}} @endcode
  852. * @code {{~system:keyword_search:TemplServices["bx_albums", {"meta_type": "location_country", "keyword": "AU"}, "unit.html"]~}} @endcode
  853. * @code {{~system:keyword_search:TemplServices["bx_albums", {"meta_type": "location_country_state", "state":"NSW", "keyword": "AU"}, "unit.html"]~}} @endcode
  854. * @code {{~system:keyword_search:TemplServices["bx_albums", {"meta_type": "location_country_city", "state":"NSW", "city":"Manly", "keyword": "AU"}, "unit.html"]~}} @endcode
  855. * @code {{~system:keyword_search:TemplServices["bx_posts", {"meta_type": "mention", "keyword": 2}, "unit_gallery.html"]~}} @endcode
  856. * @code {{~system:keyword_search:TemplServices["bx_posts", {"cat": "bx_posts_cats", "keyword": 3}, "unit_gallery.html"]~}} @endcode
  857. *
  858. * Search by keyword
  859. * @param $sSection - search object to search in, usually module name, for example: bx_posts
  860. * @param $aCondition - condition for search, supported conditions:
  861. * - search by keyword: ["keyword" => "test"]
  862. * - search by country: ["meta_type" => "location_country", "keyword" => "AU"]
  863. * - search by country and state: ["meta_type": "location_country_state", "state":"NSW", "keyword": "AU"]
  864. * - search by country, state and city: ["meta_type": "location_country_city", "state":"NSW", "city":"Manly", "keyword": "AU"]
  865. * - search for mentions: ["meta_type" => "mention", "keyword" => 2]
  866. * - search in category: ["cat": "bx_posts_cats", "keyword": 3]
  867. * @param $sTemplate - template for displaying search results, for example: unit.html
  868. * @param $iStart - paginate, display records starting from this number
  869. * @param $iPerPage - paginate, display this number of records per page
  870. * @param $bLiveSearch - search results like in live search
  871. *
  872. * @see BxBaseServices::serviceKeywordSearch
  873. */
  874. /**
  875. * @ref bx_system_general-keyword_search "keyword_search"
  876. */
  877. public function serviceKeywordSearch ($sSection, $aCondition, $sTemplate = '', $iStart = 0, $iPerPage = 0, $bLiveSearch = 0, $bPaginate = false)
  878. {
  879. if (!$sSection || !isset($aCondition['keyword']))
  880. return '';
  881. $sClass = 'BxTemplSearch';
  882. $sElsName = 'bx_elasticsearch';
  883. $sElsMethod = 'is_configured';
  884. if(BxDolRequest::serviceExists($sElsName, $sElsMethod) && BxDolService::call($sElsName, $sElsMethod)) {
  885. $oModule = BxDolModule::getInstance($sElsName);
  886. bx_import('Search', $oModule->_aModule);
  887. $sClass = 'BxElsSearch';
  888. }
  889. $oSearch = new $sClass(array($sSection));
  890. $oSearch->setLiveSearch($bLiveSearch);
  891. $oSearch->setMetaType(isset($aCondition['meta_type']) ? $aCondition['meta_type'] : '');
  892. $oSearch->setCategoryObject(isset($aCondition['cat']) ? $aCondition['cat'] : '');
  893. $oSearch->setCustomSearchCondition($aCondition);
  894. if (!$bPaginate)
  895. $oSearch->setRawProcessing(true);
  896. $oSearch->setCustomCurrentCondition(array(
  897. 'paginate' => array (
  898. 'start' => $iStart,
  899. 'perPage' => $iPerPage ? $iPerPage : BX_DOL_SEARCH_RESULTS_PER_PAGE_DEFAULT,
  900. )));
  901. if ($sTemplate)
  902. $oSearch->setUnitTemplate($sTemplate);
  903. return $oSearch->response();
  904. }
  905. /**
  906. * @page service Service Calls
  907. * @section bx_system_general System Services
  908. * @subsection bx_system_general-general General
  909. * @subsubsection bx_system_general-keyword_search keyword_search
  910. *
  911. * @code bx_srv('system', 'search_keyword_form', 'TemplServices'); @endcode
  912. *
  913. * Block with Search by Keywords Form
  914. *
  915. * @see BxBaseServices::serviceSearchKeywordForm
  916. */
  917. /**
  918. * @ref bx_system_general-keyword_search "keyword_search"
  919. */
  920. public function serviceSearchKeywordForm ()
  921. {
  922. return $this->_getSearchObject()->getForm(BX_DB_PADDING_DEF, false, true);
  923. }
  924. /**
  925. * @page service Service Calls
  926. * @section bx_system_general System Services
  927. * @subsection bx_system_general-general General
  928. * @subsubsection bx_system_general-keyword_search keyword_search
  929. *
  930. * @code bx_srv('system', 'search_keyword_result', 'TemplServices'); @endcode
  931. *
  932. * Block with Search by Keywords Results
  933. *
  934. * @see BxBaseServices::serviceSearchKeywordResult
  935. */
  936. /**
  937. * @ref bx_system_general-keyword_search "keyword_search"
  938. */
  939. public function serviceSearchKeywordResult ()
  940. {
  941. $sType = bx_process_input(bx_get('type'));
  942. $sKeyword = bx_process_input(bx_get('keyword'));
  943. $bKeyword = $sKeyword !== false;
  944. if(bx_is_api())
  945. return $this->serviceGetDataSearchApi(['params' => [
  946. 'type' => $sType,
  947. 'keyword' => $sKeyword,
  948. 'section' => bx_process_input(bx_get('section')),
  949. 'cat' => bx_process_input(bx_get('cat'))
  950. ]]);
  951. $sCode = '';
  952. if($bKeyword) {
  953. $oSearch = $this->_getSearchObject();
  954. if(($sCode = $oSearch->response()))
  955. $sCode = BxDolTemplate::getInstance()->parseHtmlByName('search_result_block.html', [
  956. 'html_id' => 'bx-search-results-keyword',
  957. 'class' => 'bx-search-results-container',
  958. 'attrs' => '',
  959. 'content' => $sCode,
  960. 'bx_if:do_center' => [
  961. 'condition' => false,
  962. 'content' => [
  963. 'html_id' => '',
  964. 'selector_content' => ''
  965. ]
  966. ]
  967. ]);
  968. else
  969. $sCode = $oSearch->getEmptyResult();
  970. }
  971. return $sCode;
  972. }
  973. /**
  974. * @ref bx_system_general-get_date_search_api "get_date_search_api"
  975. * @api @ref bx_system_general-get_date_search_api "get_date_search_api"
  976. */
  977. public function serviceGetDataSearchApi ($aParams)
  978. {
  979. if(!bx_is_api())
  980. return false;
  981. if(is_string($aParams))
  982. $aParams = bx_api_get_browse_params($aParams);
  983. $bForceAll = ($aParams['params']['type'] ?? '') == 'keyword';
  984. $aSectionsAvail = explode(',', getParam('sys_api_search_sections'));
  985. $aSectionsAll = BxDolDb::getInstance()->fromCache(
  986. 'sys_global_search_pairs',
  987. 'getPairs',
  988. 'SELECT `ObjectName` AS `name`, `Title` AS `title` FROM `sys_objects_search` WHERE `GlobalSearch`=\'1\' ORDER BY `Order` ASC',
  989. 'name', 'title'
  990. );
  991. $aSections = [];
  992. foreach($aSectionsAll as $sSectionName => $sSectionTitle)
  993. if(in_array($sSectionName, $aSectionsAvail) || $bForceAll)
  994. $aSections[$sSectionName] = [
  995. 'name' => $sSectionName,
  996. 'title' => _t($sSectionTitle)
  997. ];
  998. $aParamsBrowse = array_merge([
  999. 'keyword' => '',
  1000. 'section' => '',
  1001. 'sections' => array_values($aSections),
  1002. 'start' => 0,
  1003. 'per_page' => 12
  1004. ], !empty($aParams['params']) && is_array($aParams['params']) ? $aParams['params'] : []);
  1005. if(empty($aParamsBrowse['section']))
  1006. $aParamsBrowse['section'] = array_keys($aSections);
  1007. else if(is_string($aParamsBrowse['section']))
  1008. $aParamsBrowse['section'] = explode(',', $aParamsBrowse['section']);
  1009. $sClass = 'BxTemplSearch';
  1010. $sSections = $aParamsBrowse['section'];
  1011. if ($aParamsBrowse['live'] !== true && count($sSections) > 1){
  1012. $aParamsBrowse['section'] = [];
  1013. $aParamsBrowse['sections'] = [];
  1014. $aDataRv = [];
  1015. foreach ($sSections as $sSection) {
  1016. $oSearch = new $sClass($sSection);
  1017. $oSearch->setLiveSearch(true);
  1018. $oSearch->setDataProcessing(true);
  1019. $oSearch->setCustomSearchCondition(['keyword' => $aParamsBrowse['keyword']]);
  1020. $oSearch->setCustomCurrentCondition([
  1021. 'paginate' => [
  1022. 'forceStart' => $aParamsBrowse['start'],
  1023. 'perPage' => $aParamsBrowse['per_page'],
  1024. ]
  1025. ]);
  1026. $aData = $oSearch->response();
  1027. if(count($aData) > $aParamsBrowse['per_page'])
  1028. $aData = array_slice($aData, $aParamsBrowse['start'], $aParamsBrowse['per_page']);
  1029. if (count($aData) > 0) {
  1030. $oSearchResult = $oSearch->getSearchResultObject($sSection);
  1031. $sSectionTitle = $oSearchResult->aCurrent['title'];
  1032. $aParamsBrowse['section'][] = $sSection;
  1033. $aParamsBrowse['sections'][] = ['name' => $sSection, 'title' => $sSectionTitle];
  1034. $aDataRv[] = [
  1035. 'section' => $sSection,
  1036. 'section_name' => $sSectionTitle,
  1037. 'data' => $aData,
  1038. 'is_profile' => bx_srv('system', 'is_module_profile', [$oSearchResult->aCurrent['module_name']])
  1039. ];
  1040. }
  1041. }
  1042. return [bx_api_get_block('search_sections', [
  1043. 'data' => $aDataRv,
  1044. 'params' => $aParamsBrowse
  1045. ])];
  1046. }
  1047. else{
  1048. $oSearch = new $sClass($aParamsBrowse['section']);
  1049. $oSearch->setLiveSearch(true);
  1050. $oSearch->setDataProcessing(true);
  1051. $oSearch->setCustomSearchCondition(['keyword' => $aParamsBrowse['keyword']]);
  1052. $oSearch->setCustomCurrentCondition([
  1053. 'paginate' => [
  1054. 'forceStart' => $aParamsBrowse['start'],
  1055. 'perPage' => $aParamsBrowse['per_page'],
  1056. ]
  1057. ]);
  1058. $aData = $oSearch->response();
  1059. if(count($aData) > $aParamsBrowse['per_page'])
  1060. $aData = array_slice($aData, $aParamsBrowse['start'], $aParamsBrowse['per_page']);
  1061. return [
  1062. bx_api_get_block('browse', [
  1063. 'unit' => 'search-results',
  1064. 'request_url' => '/api.php?r=system/get_data_search_api/TemplServices&params[]=',
  1065. 'params' => $aParamsBrowse,
  1066. 'data' => $aData
  1067. ])
  1068. ];
  1069. }
  1070. }
  1071. /**
  1072. * @page service Service Calls
  1073. * @section bx_system_general System Services
  1074. * @subsection bx_system_general-general General
  1075. * @subsubsection bx_system_general-cmts cmts
  1076. *
  1077. * @code bx_srv('system', 'cmts', ["sys_blocks", 1], 'TemplServices'); @endcode
  1078. *
  1079. * @code {{~system:cmts:TemplServices["sys_blocks", 1]~}} @endcode
  1080. *
  1081. * Comments block
  1082. * @param $sObject - comments object name
  1083. * @param $sId - content id assiciated tith the comments
  1084. *
  1085. * @see BxBaseServices::serviceCmts
  1086. */
  1087. /**
  1088. * @ref bx_system_general-cmts "cmts"
  1089. */
  1090. public function serviceCmts ($sObject, $sId)
  1091. {
  1092. $o = BxDolCmts::getObjectInstance($sObject, $sId);
  1093. if (!$o || !$o->isEnabled())
  1094. return '';
  1095. return $o->getCommentsBlock(array(), array('in_designbox' => false, 'show_empty' => true));
  1096. }
  1097. public function _serviceProfileFunc ($sFunc, $iContentId, $aParams = array())
  1098. {
  1099. if (!$iContentId)
  1100. return false;
  1101. if (!($oAccount = BxDolAccount::getInstance($iContentId)))
  1102. return false;
  1103. return $oAccount->$sFunc(false, $aParams);
  1104. }
  1105. public function serviceAlertResponseProcessInstalled()
  1106. {
  1107. BxDolTranscoderImage::registerHandlersSystem();
  1108. }
  1109. public function serviceAlertResponseProcessStorageChange ($oAlert)
  1110. {
  1111. if ('sys_storage_default' != $oAlert->aExtras['option'])
  1112. return;
  1113. $aStorages = BxDolStorageQuery::getStorageObjects();
  1114. foreach ($aStorages as $r) {
  1115. if (0 == $r['current_size'] && 0 == $r['current_number'] && ($oStorage = BxDolStorage::getObjectInstance($r['object'])))
  1116. $oStorage->changeStorageEngine($oAlert->aExtras['value']);
  1117. }
  1118. }
  1119. public function serviceGetOptionsProfileBot()
  1120. {
  1121. $aResult = array(
  1122. array('key' => '', 'value' => _t('_Select_one'))
  1123. );
  1124. $aAccountsIds = BxDolAccountQuery::getInstance()->getOperators();
  1125. foreach($aAccountsIds as $iAccountId) {
  1126. $aProfilesIds = BxDolAccount::getInstance($iAccountId)->getProfilesIds(true, false);
  1127. foreach($aProfilesIds as $iProfileId) {
  1128. $oProfile = BxDolProfile::getInstance($iProfileId);
  1129. $aResult[] = array(
  1130. 'key' => $iProfileId,
  1131. 'value' => _t('_sys_profile_with_type', $oProfile->getDisplayName(), $oProfile->getModule()),
  1132. );
  1133. }
  1134. }
  1135. return $aResult;
  1136. }
  1137. public function serviceGetOptionsModuleListForPrivacySelector()
  1138. {
  1139. $aResult = array();
  1140. $BxDolModuleQuery = BxDolModuleQuery::getInstance();
  1141. $aModules = $BxDolModuleQuery->getModulesBy(array('type' => 'modules', 'active' => 1));
  1142. foreach($aModules as $aModule){
  1143. $oModule = BxDolModule::getInstance($aModule['name']);
  1144. if($oModule instanceof iBxDolContentInfoService){
  1145. if (!BxDolRequest::serviceExists($aModule['name'], 'act_as_profile'))
  1146. continue;
  1147. $aResult[$aModule['name']] = $aModule['title'];
  1148. }
  1149. }
  1150. return $aResult;
  1151. }
  1152. public function serviceGetOptionsCaptchaDefault()
  1153. {
  1154. $aResults = [];
  1155. $aObjects = BxDolCaptchaQuery::getObjects();
  1156. foreach($aObjects as $aObject)
  1157. $aResults[$aObject['object']] = $aObject['title'];
  1158. return $aResults;
  1159. }
  1160. public function serviceGetOptionsEmbedDefault()
  1161. {
  1162. $aResults = array(
  1163. '' => _t('_None')
  1164. );
  1165. $aObjects = BxDolEmbedQuery::getObjects();
  1166. foreach($aObjects as $aObject)
  1167. $aResults[$aObject['object']] = _t($aObject['title']);
  1168. return $aResults;
  1169. }
  1170. public function serviceGetOptionsLocationFieldDefault()
  1171. {
  1172. $aResults = array();
  1173. $aObjects = BxDolLocationFieldQuery::getObjects();
  1174. foreach($aObjects as $aObject)
  1175. $aResults[$aObject['object']] = _t($aObject['title']);
  1176. return $aResults;
  1177. }
  1178. public function serviceGetOptionsLocationMapDefault()
  1179. {
  1180. $aResults = array();
  1181. $aObjects = BxDolLocationMapQuery::getObjects();
  1182. foreach($aObjects as $aObject)
  1183. $aResults[$aObject['object']] = _t($aObject['title']);
  1184. return $aResults;
  1185. }
  1186. public function serviceGetOptionsPushDefault()
  1187. {
  1188. $aResults = [
  1189. '' => _t('_None')
  1190. ];
  1191. $aObjects = BxDolPushQuery::getObjects();
  1192. foreach($aObjects as $aObject)
  1193. $aResults[$aObject['object']] = $aObject['title'];
  1194. return $aResults;
  1195. }
  1196. public function serviceGetOptionsSmsDefault()
  1197. {
  1198. $aResults = [
  1199. '' => _t('_None')
  1200. ];
  1201. $aObjects = BxDolSmsQuery::getObjects();
  1202. foreach($aObjects as $aObject)
  1203. $aResults[$aObject['object']] = $aObject['title'];
  1204. return $aResults;
  1205. }
  1206. public function serviceGetOptionsSocketsFieldDefault()
  1207. {
  1208. $aResults = [];
  1209. $aObjects = ['sys_sockets_disabled', 'sys_sockets_soketi'];
  1210. foreach($aObjects as $sObject)
  1211. $aResults[$sObject] = _t('_adm_stg_cpt_option_sys_sockets_type_' . $sObject);
  1212. return $aResults;
  1213. }
  1214. public function serviceGetOptionsLocationLeafletGetProviders()
  1215. {
  1216. return BxDolLocationMapLeaflet::getProviders();
  1217. }
  1218. public function serviceGetOptionsRelations()
  1219. {
  1220. $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
  1221. $aProfiles = array();
  1222. foreach($aModules as $aModule) {
  1223. $sMethod = 'act_as_profile';
  1224. if(!BxDolRequest::serviceExists($aModule['name'], $sMethod) || !BxDolService::call($aModule['name'], $sMethod))
  1225. continue;
  1226. $aProfiles[$aModule['name']] = _t('_' . $aModule['name']);
  1227. }
  1228. $aResults = array();
  1229. foreach($aProfiles as $sName1 => $sTitle1)
  1230. foreach($aProfiles as $sName2 => $sTitle2)
  1231. $aResults[$sName1 . '_' . $sName2] = $sTitle1 . ' - ' . $sTitle2;
  1232. return $aResults;
  1233. }
  1234. public function serviceGetOptionsCfProhibited()
  1235. {
  1236. return BxDolFormQuery::getDataItems('sys_content_filter');
  1237. }
  1238. public function serviceGetOptionsCfUnauthenticated()
  1239. {
  1240. return BxDolFormQuery::getDataItems('sys_content_filter');
  1241. }
  1242. public function serviceGetOptionsTaiwindDefault()
  1243. {
  1244. $sPath = BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'tailwind/css';
  1245. $aExcludes = ['.', '..', 'tailwind.css'];
  1246. $aResults = [];
  1247. if(($oHandle = opendir($sPath)) !== false) {
  1248. while(($sFile = readdir($oHandle)) !== false) {
  1249. if(in_array($sFile, $aExcludes))
  1250. continue;
  1251. if(($oHandlerFile = fopen($sPath . '/' . $sFile, 'r')) === false)
  1252. continue;
  1253. if(($sContent = fread($oHandlerFile, 1024)) !== false && strpos($sContent, '@tailwind base') === false)
  1254. $aResults[$sFile] = $sFile;
  1255. fclose($oHandlerFile);
  1256. }
  1257. closedir($oHandle);
  1258. }
  1259. $aResults['cdn'] = _t('_adm_stg_cpt_option_sys_css_tailwind_default_cdn');
  1260. return $aResults;
  1261. }
  1262. public function serviceGetOptionsIconsetDefault()
  1263. {
  1264. $aObjects = BxDolIconsetQuery::getObjects();
  1265. foreach($aObjects as $aObject)
  1266. $aResults[$aObject['object']] = $aObject['title'];
  1267. return $aResults;
  1268. }
  1269. public function serviceGetOptionsApiMenuTop()
  1270. {
  1271. $aMenus = BxDolMenuQuery::getMenuObjects();
  1272. $aResults = ['' => _t('_sys_please_select')];
  1273. foreach($aMenus as $aMenu)
  1274. if($aMenu['module'] == 'system')
  1275. $aResults[$aMenu['object']] = _t($aMenu['title']);
  1276. return $aResults;
  1277. }
  1278. public function serviceGetOptionsApiContextSwitcher()
  1279. {
  1280. $aContexts = bx_srv('system', 'get_modules_by_type', ['context']);
  1281. $aResults = ['' => _t('_None')];
  1282. foreach($aContexts as $aContext)
  1283. $aResults[$aContext['name']] = _t('_' . $aContext['name']);
  1284. return $aResults;
  1285. }
  1286. public function serviceGetOptionsApiContextConnection()
  1287. {
  1288. $aConnections = ['subscriptions', 'fans', 'participants'];
  1289. $aResults = ['' => _t('_sys_please_select')];
  1290. foreach($aConnections as $sConnection)
  1291. $aResults[$sConnection] = _t('_adm_stg_cpt_option_sys_api_cnt_cnn_' . $sConnection);
  1292. return $aResults;
  1293. }
  1294. public function serviceGetOptionsAgentsModel()
  1295. {
  1296. return ['' => _t('_Select_one')] + BxDolAI::getInstance()->getModels(['active' => true, 'hidden' => false]);
  1297. }
  1298. public function serviceGetOptionsAgentsProfile($bSelectOne = true)
  1299. {
  1300. $aResult = [];
  1301. if($bSelectOne)
  1302. $aResult[] = ['key' => '', 'value' => _t('_Select_one')];
  1303. $aAccountsIds = BxDolAccountQuery::getInstance()->getOperators();
  1304. foreach($aAccountsIds as $iAccountId) {
  1305. $aProfilesIds = BxDolAccount::getInstance($iAccountId)->getProfilesIds(true, false);
  1306. foreach($aProfilesIds as $iProfileId)
  1307. if(($oProfile = BxDolProfile::getInstance($iProfileId)) !== false && ($sProfileModule = $oProfile->getModule()) != 'system')
  1308. $aResult[] = [
  1309. 'key' => $iProfileId,
  1310. 'value' => _t('_sys_profile_with_type', $oProfile->getDisplayName(), _t('_' . $sProfileModule))
  1311. ];
  1312. }
  1313. return $aResult;
  1314. }
  1315. public function serviceGetOptionsStudioAssistant()
  1316. {
  1317. return ['' => _t('_Select_one')] + BxDolAI::getInstance()->getAssistants(['active' => true, 'hidden' => false]);
  1318. }
  1319. public function serviceGetOptionsLiveSearchAssistant()
  1320. {
  1321. return ['' => _t('_Select_one')] + BxDolAI::getInstance()->getAssistants(['active' => true, 'hidden' => false]);
  1322. }
  1323. public function serviceGetOptionsAskBlockAssistant()
  1324. {
  1325. return ['' => _t('_Select_one')] + BxDolAI::getInstance()->getAssistants(['active' => true, 'hidden' => false]);
  1326. }
  1327. public function serviceRedirect($sUrl = false)
  1328. {
  1329. if (!getParam('sys_confirmation_before_redirect')) {
  1330. BxDolTemplate::getInstance()->displayPageNotFound();
  1331. exit;
  1332. }
  1333. if (false === $sUrl)
  1334. $sUrl = bx_get('url');
  1335. if (!$sUrl || !preg_match('@^https?://@', $sUrl)) {
  1336. http_response_code(500);
  1337. return MsgBox(_t('_error occured'));
  1338. }
  1339. else {
  1340. $bSpam = null;
  1341. /**
  1342. * @hooks
  1343. * @hookdef hook-system-check_spam_url 'system', 'check_spam_url' - hook to override sClass for search
  1344. * - $unit_name - equals `system`
  1345. * - $action - equals `check_spam_url`
  1346. * - $object_id - not used
  1347. * - $sender_id - logged account id
  1348. * - $extra_params - array of additional params with the following array keys:
  1349. * - `is_spam` - [bool] by ref, spam url or not, can be overridden in hook processing
  1350. * - `content` - [string] by ref, url of link, can be overridden in hook processing
  1351. * - `where` - [string] equal redirect
  1352. * @hook @ref hook-system-check_spam_url
  1353. */
  1354. bx_alert('system', 'check_spam_url', 0, getLoggedId(), array('is_spam' => &$bSpam, 'content' => &$sUrl, 'where' => 'redirect'));
  1355. $sLangKey = $bSpam ? '_sys_redirect_confirmation_harmful' : '_sys_redirect_confirmation';
  1356. return BxDolTemplate::getInstance()->parseHtmlByName('redirect.html', [
  1357. 'text' => _t($sLangKey, bx_process_output($sUrl), getParam('site_title')),
  1358. 'url' => bx_js_string($sUrl, BX_ESCAPE_STR_APOS),
  1359. ]);
  1360. }
  1361. }
  1362. public function serviceSetBadges($iContentId, $sBadgesIds, $sModule)
  1363. {
  1364. $aSelectedBadges = explode(",", $sBadgesIds);
  1365. $iPerformerId = bx_get_logged_profile_id();
  1366. $aCheck = checkActionModule($iPerformerId, 'set badge', 'system', false);
  1367. if(!isAdmin() && $aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  1368. return false;
  1369. $oBadges = BxDolBadges::getInstance();
  1370. $aBadges = $oBadges->getData(array('type' => 'by_module&object', 'object_id' => $iContentId, 'module' => $sModule));
  1371. foreach ($aBadges as $aBadge) {
  1372. if (isset($aBadge['badge_id'])){
  1373. $oBadges->delete($aBadge['badge_id']);
  1374. }
  1375. }
  1376. foreach ($aSelectedBadges as $iSelectedBadge) {
  1377. $oBadges->add($iSelectedBadge, $iContentId, $sModule);
  1378. }
  1379. checkActionModule($iPerformerId, 'set badge', 'system', true); // perform action
  1380. return true;
  1381. }
  1382. public function serviceGetBadge($aBadge, $bIsCompact = false)
  1383. {
  1384. $sClass = '';
  1385. $sStyleFont = '';
  1386. $sStyleBg = '';
  1387. if ($aBadge['color'] == '')
  1388. $aBadge['color'] = 'purple-600';
  1389. if ($bIsCompact && $aBadge['icon'] != ''){
  1390. $aBadge['is_icon_only'] = 1;
  1391. }
  1392. if ($aBadge['is_icon_only'] == 1){
  1393. $sClass .= ' bx-badge-compact';
  1394. if (substr_count($aBadge['color'], 'rgb('))
  1395. $sStyleFont = 'color: ' . $aBadge['color'];
  1396. else
  1397. $sClass .= ' text-' . $aBadge['color'];
  1398. }
  1399. else{
  1400. if (substr_count($aBadge['color'], 'rgb('))
  1401. $sStyleBg = 'background-color: ' . $aBadge['color'];
  1402. else
  1403. $sClass .= ' bg-' . $aBadge['color'];
  1404. }
  1405. return BxDolTemplate::getInstance()->parseHtmlByName('badge.html', array(
  1406. 'bx_if:content' => array(
  1407. 'condition' => $aBadge['is_icon_only'] != '1',
  1408. 'content' => array('content' => _t($aBadge['text'])),
  1409. ),
  1410. 'bx_if:icon' => array(
  1411. 'condition' => $aBadge['icon'] != '',
  1412. 'content' => array('content' => BxDolTemplate::getInstance()->getIcon($aBadge['icon'], array('class' => 'bx-badge-icon sys-colored', 'style' => $sStyleFont))),
  1413. ),
  1414. 'title' => $aBadge['text'],
  1415. 'style_font' => $sStyleFont,
  1416. 'style_bg' => $sStyleBg,
  1417. 'class' => $sClass,
  1418. )
  1419. );
  1420. }
  1421. public function serviceGetFooter()
  1422. {
  1423. return BxDolTemplate::getInstance()->parseHtmlByName('footer.html', []);
  1424. }
  1425. private function _getSearchObject()
  1426. {
  1427. $sClass = 'BxTemplSearch';
  1428. $sElsName = 'bx_elasticsearch';
  1429. $sElsMethod = 'is_configured';
  1430. if(BxDolRequest::serviceExists($sElsName, $sElsMethod) && BxDolService::call($sElsName, $sElsMethod) && !bx_get('cat') && !bx_get('type')) {
  1431. $oModule = BxDolModule::getInstance($sElsName);
  1432. bx_import('Search', $oModule->_aModule);
  1433. $sClass = 'BxElsSearch';
  1434. }
  1435. /**
  1436. * @hooks
  1437. * @hookdef hook-system-search_keyword 'system', 'search_keyword' - hook to override sClass for search
  1438. * - $unit_name - equals `system`
  1439. * - $action - equals `search_keyword`
  1440. * - $object_id - not used
  1441. * - $sender_id - not used
  1442. * - $extra_params - array of additional params with the following array keys:
  1443. * - `override_result` - [string] by ref, class name for search, can be overridden in hook processing
  1444. * @hook @ref hook-system-search_keyword
  1445. */
  1446. bx_alert('system', 'search_keyword', 0, 0, array('class' => &$sClass));
  1447. $oSearch = new $sClass(bx_get('section'));
  1448. $oSearch->setLiveSearch(bx_get('live_search') ? 1 : 0);
  1449. $oSearch->setMetaType(bx_process_input(bx_get('type')));
  1450. $oSearch->setCategoryObject(bx_process_input(bx_get('cat')));
  1451. return $oSearch;
  1452. }
  1453. public function serviceHomeRedirect()
  1454. {
  1455. header("Location:" . BX_DOL_URL_ROOT, true, 301);
  1456. exit;
  1457. }
  1458. public function serviceProcessEmbed()
  1459. {
  1460. BxDolEmbed::getObjectInstance()->process();
  1461. }
  1462. }
  1463. /** @} */