BxBaseServices.php 62 KB

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