BxBaseServices.php 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722
  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 $this->_serviceProfileFunc('getPicture', $iContentId);
  510. }
  511. public function serviceProfileAvatar ($iContentId)
  512. {
  513. return $this->_serviceProfileFunc('getAvatar', $iContentId);
  514. }
  515. public function serviceProfileAvatarBig ($iContentId)
  516. {
  517. return $this->_serviceProfileFunc('getAvatarBig', $iContentId);
  518. }
  519. public function serviceProfileCover ($iContentId)
  520. {
  521. return '';
  522. }
  523. public function serviceProfileEditUrl ($iContentId)
  524. {
  525. return bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=account-settings-info'));
  526. }
  527. public function serviceProfileThumb ($iContentId)
  528. {
  529. return $this->_serviceProfileFunc('getThumb', $iContentId);
  530. }
  531. public function serviceProfileIcon ($iContentId)
  532. {
  533. return $this->_serviceProfileFunc('getIcon', $iContentId);
  534. }
  535. public function serviceProfileName ($iContentId)
  536. {
  537. return $this->_serviceProfileFunc('getDisplayName', $iContentId);
  538. }
  539. public function serviceProfileUrl ($iContentId)
  540. {
  541. return $this->_serviceProfileFunc('getUrl', $iContentId);
  542. }
  543. /**
  544. * @see iBxDolProfileService::serviceCheckAllowedProfileView
  545. */
  546. public function serviceCheckAllowedProfileView($iContentId)
  547. {
  548. return _t('_Access denied');
  549. }
  550. /**
  551. * @see iBxDolProfileService::serviceCheckAllowedProfileContact
  552. */
  553. public function serviceCheckAllowedProfileContact($iContentId)
  554. {
  555. return _t('_Access denied');
  556. }
  557. /**
  558. * @see iBxDolProfileService::serviceCheckAllowedPostInProfile
  559. */
  560. public function serviceCheckAllowedPostInProfile($iContentId, $sPostModule = '')
  561. {
  562. return _t('_Access denied');
  563. }
  564. /**
  565. * @see iBxDolProfileService::serviceCheckAllowedModuleActionInProfile
  566. */
  567. public function serviceCheckAllowedModuleActionInProfile($iContentId, $sPostModule, $sActionName)
  568. {
  569. return _t('_Access denied');
  570. }
  571. /**
  572. * @see iBxDolProfileService::serviceGetSpaceTitle
  573. */
  574. public function serviceGetSpaceTitle()
  575. {
  576. return '';
  577. }
  578. /**
  579. * @see iBxDolProfileService::serviceGetParticipatingProfiles
  580. */
  581. public function serviceGetParticipatingProfiles($iProfileId, $aConnectionObject = false)
  582. {
  583. return array();
  584. }
  585. /**
  586. * @page service Service Calls
  587. * @section bx_system_general System Services
  588. * @subsection bx_system_general-general General
  589. * @subsubsection bx_system_general-get_create_post_form get_create_post_form
  590. *
  591. * @code bx_srv('system', 'get_create_post_form', [false, "bx_posts"], 'TemplServices'); @endcode
  592. * @code {{~system:get_create_post_form:TemplServices[false,"bx_posts"]~}} @endcode
  593. *
  594. * Get United Create Post form.
  595. * @param $mixedContextId - context which the post will be created in:
  596. * - false = 'Public' post form;
  597. * - 0 = 'Profile' post form, which allows to post in your own profile and connections;
  598. * - n = 'Context' post form, which allows to post in context (3d party profile, group, event, etc).
  599. * @param $sDefault - tab selected by default.
  600. * @param $aCustom - an array with custom paramaters.
  601. * @return string with form content
  602. *
  603. * @see BxBaseServices::serviceGetCreatePostForm
  604. */
  605. /**
  606. * @ref bx_system_general-get_create_post_form "get_create_post_form"
  607. */
  608. public function serviceGetCreatePostForm($mixedContextId = false, $sDefault = '', $aCustom = array())
  609. {
  610. if(!isLogged() || ($mixedContextId !== false && !is_numeric($mixedContextId)))
  611. return '';
  612. $oProfile = BxDolProfile::getInstance();
  613. if(!$oProfile)
  614. return '';
  615. if($mixedContextId !== false)
  616. $mixedContextId = (int)(!empty($mixedContextId) ? -$mixedContextId : $oProfile->id());
  617. $oMenu = BxDolMenu::getObjectInstance('sys_create_post');
  618. if(!$oMenu)
  619. return '';
  620. $oMenu->setContextId($mixedContextId);
  621. $aMenuItems = $oMenu->getMenuItems();
  622. if(empty($aMenuItems) || !is_array($aMenuItems))
  623. return '';
  624. if(empty($sDefault)) {
  625. $aDefault = array_shift($aMenuItems);
  626. $sDefault = !empty($aDefault['module']) ? $aDefault['module'] : $aDefault['name'];
  627. }
  628. $oMenu->setSelected($sDefault, $sDefault);
  629. $oContext = false;
  630. $bContext = $mixedContextId !== false;
  631. if($bContext && ($oContext = BxDolProfile::getInstance(abs($mixedContextId))) !== false)
  632. if(bx_srv($oContext->getModule(), 'check_allowed_post_in_profile', [$oContext->getContentId(), $sDefault]) !== CHECK_ACTION_RESULT_ALLOWED)
  633. return '';
  634. $sTitle = '_sys_page_block_title_create_post';
  635. if(!$bContext)
  636. $sTitle = _t($sTitle . '_public');
  637. else if($mixedContextId < 0) {
  638. $sTitle = _t($sTitle . '_context');
  639. if($oContext)
  640. $sTitle = bx_replace_markers($sTitle, [
  641. 'display_name' => $oContext->getDisplayName()
  642. ]);
  643. }
  644. else
  645. $sTitle = _t($sTitle);
  646. $sPlaceholder = _t('_sys_txt_create_post_placeholder', $oProfile->getDisplayName());
  647. $oDbModules = BxDolModuleQuery::getInstance();
  648. $oTemplate = BxDolTemplate::getInstance();
  649. $oTemplate->addJs(['BxDolCreatePost.js']);
  650. $aPreloadingList = [];
  651. $aModules = explode(',', getParam('sys_create_post_form_preloading_list'));
  652. if(!empty($aModules))
  653. foreach($aModules as $sModule) {
  654. $aModule = $oDbModules->getModuleByName($sModule);
  655. if(empty($aModule) || !is_array($aModule))
  656. continue;
  657. $aPreloadingList[$sModule] = $aModule['uri'];
  658. }
  659. if(bx_is_api()) {
  660. return [
  661. 'title' => $sTitle,
  662. 'content' => [
  663. bx_api_get_block('get_create_post_form', [
  664. 'menu' => $oMenu->getCodeAPI(),
  665. 'params' => ['context_id' => $mixedContextId]])
  666. ]
  667. ];
  668. }
  669. $sJsObject = 'oBxDolCreatePost';
  670. $sJsContent = $oTemplate->_wrapInTagJsCode("var " . $sJsObject . " = new BxDolCreatePost(" . json_encode([
  671. 'sObjName' => $sJsObject,
  672. 'sRootUrl' => BX_DOL_URL_ROOT,
  673. 'sDefault' => $sDefault,
  674. 'iContextId' => $bContext ? $mixedContextId : 0,
  675. 'oPreloadingList' => $aPreloadingList,
  676. 'oCustom' => $aCustom
  677. ]) . ");");
  678. return [
  679. 'title' => $sTitle,
  680. 'content' => $oTemplate->parseHtmlByName('create_post_form.html', [
  681. 'default' => $sDefault,
  682. 'placeholder' => $sPlaceholder,
  683. 'user_thumb' => $oProfile->getUnit(0, ['template' => 'unit_wo_info_links']),
  684. 'form' => bx_srv($sDefault, 'get_create_post_form', [[
  685. 'context_id' => $mixedContextId,
  686. 'ajax_mode' => true,
  687. 'absolute_action_url' => true,
  688. 'custom' => $aCustom
  689. ]]),
  690. 'js_object' => $sJsObject,
  691. 'js_content' => $sJsContent
  692. ]),
  693. 'menu' => $oMenu->getMenuItemsCount() > 1 ? $oMenu : ''
  694. ];
  695. }
  696. public function serviceGetOptionsCreatePostFormPreloadingList()
  697. {
  698. $oMenu = BxDolMenu::getObjectInstance('sys_create_post');
  699. if(!$oMenu)
  700. return [];
  701. $aMenuItems = $oMenu->getMenuItems();
  702. $aResult = [];
  703. foreach($aMenuItems as $aMenuItem) {
  704. $sModule = !empty($aMenuItem['module']) ? $aMenuItem['module'] : $aMenuItem['name'];
  705. if(!bx_srv('system', 'is_module_enabled', [$sModule]))
  706. continue;
  707. $aResult[] = [
  708. 'key' => $sModule,
  709. 'value' => _t('_' . $sModule)
  710. ];
  711. }
  712. return $aResult;
  713. }
  714. public function serviceGetBlockAuthor($sModule, $iContentId = 0)
  715. {
  716. if(!$iContentId && bx_get('id') !== false)
  717. $iContentId = (int)bx_get('id');
  718. $sMethodGetAuthor = 'get_author';
  719. if(!$sModule || !$iContentId || !BxDolRequest::serviceExists($sModule, $sMethodGetAuthor))
  720. return '';
  721. $iAuthor = bx_srv($sModule, $sMethodGetAuthor, [$iContentId]);
  722. if(!$iAuthor)
  723. return '';
  724. $oAuthor = BxDolProfile::getInstance($iAuthor);
  725. if(!$oAuthor)
  726. return '';
  727. $sModuleAuthor = $oAuthor->getModule();
  728. $sMethodGetCover = 'entity_cover';
  729. if(!BxDolRequest::serviceExists($sModuleAuthor, $sMethodGetCover))
  730. return '';
  731. return bx_srv($sModuleAuthor, $sMethodGetCover, [$oAuthor->getContentId(), [
  732. 'use_as_author' => true,
  733. 'show_text' => false
  734. ]]);
  735. }
  736. public function serviceGetBlockAskAssistant($aParams = [])
  737. {
  738. $iAssistant = BxDolAI::getAssistantForAskBlock();
  739. if(!$iAssistant)
  740. return '';
  741. return BxDolAIAssistant::getObjectInstance($iAssistant)->getAskBlock($aParams);
  742. }
  743. public function serviceGetMenu($aParams)
  744. {
  745. $bIsApi = bx_is_api();
  746. $mixedResulEmpty = $bIsApi ? [] : '';
  747. if($bIsApi && is_string($aParams))
  748. $aParams = bx_api_get_browse_params($aParams);
  749. if(!isset($aParams['object']))
  750. return $mixedResulEmpty;
  751. $oMenu = BxDolMenu::getObjectInstance($aParams['object']);
  752. if(!$oMenu)
  753. return $mixedResulEmpty;
  754. if(!empty($aParams['params']) && is_array($aParams['params']))
  755. $oMenu->setContentParams($aParams['params']);
  756. return $bIsApi ? $oMenu->getCodeAPI() : $oMenu->getCode();
  757. }
  758. /**
  759. * @page service Service Calls
  760. * @section bx_system_general System Services
  761. * @subsection bx_system_general-general General
  762. * @subsubsection bx_system_general-get_site_submenu get_site_submenu
  763. *
  764. * @code bx_srv('system', 'get_site_submenu', [], 'TemplServices'); @endcode
  765. * @code {{~system:get_site_submenu:TemplServices[]~}} @endcode
  766. *
  767. * Get Site Submenu code.
  768. * @see BxBaseServices::serviceGetSiteSubmenu
  769. */
  770. /**
  771. * @ref bx_system_general-get_site_submenu "get_site_submenu"
  772. */
  773. public function serviceGetSiteSubmenu()
  774. {
  775. $oMenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  776. return $oMenu ? $oMenu->getCode() : '';
  777. }
  778. /**
  779. * @page service Service Calls
  780. * @section bx_system_general System Services
  781. * @subsection bx_system_general-general General
  782. * @subsubsection bx_system_general-get_products_names get_products_names
  783. *
  784. * @code bx_srv('system', 'get_products_names', [], 'TemplServices');
  785. *
  786. * @code http://example.com/m/oauth2/com/get_products_names?module=system&class=BaseServices @endcode
  787. * @code http://hihi.una.io/modules/?r=oauth2/com/get_products_names&module=system&class=BaseServices @endcode
  788. *
  789. * Get an array of products names from all modules with payments functionality.
  790. * @param $iVendorId filter products by vendor ID.
  791. * @param $iLimit limit number of records from one module.
  792. * @return array of products where key id product name and value is module name
  793. *
  794. * @see BxBaseServices::serviceGetProductsNames
  795. */
  796. /**
  797. * @ref bx_system_general-get_products_names "get_products_names"
  798. */
  799. public function serviceGetProductsNames($iVendorId = 0, $iLimit = 1000)
  800. {
  801. $o = BxDolPayments::getInstance();
  802. if (!$o)
  803. return array();
  804. return $o->getProductsNames($iVendorId, $iLimit);
  805. }
  806. /**
  807. * @see iBxDolProfileService::serviceCheckSpacePrivacy
  808. */
  809. public function serviceCheckSpacePrivacy($iContentId)
  810. {
  811. return _t('_Access denied');
  812. }
  813. public function serviceFormsHelper ()
  814. {
  815. return new BxTemplAccountForms();
  816. }
  817. public function serviceActAsProfile ()
  818. {
  819. return false;
  820. }
  821. public function serviceGetModerators($iContentId)
  822. {
  823. $aModerators = BxDolAclQuery::getInstance()->getProfilesByMembership([
  824. MEMBERSHIP_ID_MODERATOR,
  825. MEMBERSHIP_ID_ADMINISTRATOR
  826. ]);
  827. $aIds = [];
  828. array_walk($aModerators, function ($aItem, $iKey, $aParams) {
  829. if(!empty($aItem['id']))
  830. $aParams[0][] = (int)$aItem['id'];
  831. }, [&$aIds]);
  832. return $aIds;
  833. }
  834. public function servicePrepareFields ($aFieldsProfile)
  835. {
  836. return $aFieldsProfile;
  837. }
  838. public function serviceProfilesSearch ($sTerm, $iLimit)
  839. {
  840. $oDb = BxDolAccountQuery::getInstance();
  841. $aRet = array();
  842. $a = $oDb->searchByTerm($sTerm, $iLimit);
  843. foreach ($a as $r)
  844. $aRet[] = array ('label' => $this->serviceProfileName($r['content_id']), 'value' => $r['profile_id']);
  845. return $aRet;
  846. }
  847. /**
  848. * @page service Service Calls
  849. * @section bx_system_general System Services
  850. * @subsection bx_system_general-general General
  851. * @subsubsection bx_system_general-keyword_search keyword_search
  852. *
  853. * @code bx_srv('system', 'keyword_search', ["bx_posts", ["keyword" => "test"}], 'TemplServices'); @endcode
  854. *
  855. * @code {{~system:keyword_search:TemplServices["bx_posts", {"keyword":"test"}]~}} @endcode
  856. * @code {{~system:keyword_search:TemplServices["bx_albums", {"meta_type": "location_country", "keyword": "AU"}, "unit.html"]~}} @endcode
  857. * @code {{~system:keyword_search:TemplServices["bx_albums", {"meta_type": "location_country_state", "state":"NSW", "keyword": "AU"}, "unit.html"]~}} @endcode
  858. * @code {{~system:keyword_search:TemplServices["bx_albums", {"meta_type": "location_country_city", "state":"NSW", "city":"Manly", "keyword": "AU"}, "unit.html"]~}} @endcode
  859. * @code {{~system:keyword_search:TemplServices["bx_posts", {"meta_type": "mention", "keyword": 2}, "unit_gallery.html"]~}} @endcode
  860. * @code {{~system:keyword_search:TemplServices["bx_posts", {"cat": "bx_posts_cats", "keyword": 3}, "unit_gallery.html"]~}} @endcode
  861. *
  862. * Search by keyword
  863. * @param $sSection - search object to search in, usually module name, for example: bx_posts
  864. * @param $aCondition - condition for search, supported conditions:
  865. * - search by keyword: ["keyword" => "test"]
  866. * - search by country: ["meta_type" => "location_country", "keyword" => "AU"]
  867. * - search by country and state: ["meta_type": "location_country_state", "state":"NSW", "keyword": "AU"]
  868. * - search by country, state and city: ["meta_type": "location_country_city", "state":"NSW", "city":"Manly", "keyword": "AU"]
  869. * - search for mentions: ["meta_type" => "mention", "keyword" => 2]
  870. * - search in category: ["cat": "bx_posts_cats", "keyword": 3]
  871. * @param $sTemplate - template for displaying search results, for example: unit.html
  872. * @param $iStart - paginate, display records starting from this number
  873. * @param $iPerPage - paginate, display this number of records per page
  874. * @param $bLiveSearch - search results like in live search
  875. *
  876. * @see BxBaseServices::serviceKeywordSearch
  877. */
  878. /**
  879. * @ref bx_system_general-keyword_search "keyword_search"
  880. */
  881. public function serviceKeywordSearch ($sSection, $aCondition, $sTemplate = '', $iStart = 0, $iPerPage = 0, $bLiveSearch = 0, $bPaginate = false)
  882. {
  883. if (!$sSection || !isset($aCondition['keyword']))
  884. return '';
  885. $sClass = 'BxTemplSearch';
  886. $sElsName = 'bx_elasticsearch';
  887. $sElsMethod = 'is_configured';
  888. if(BxDolRequest::serviceExists($sElsName, $sElsMethod) && BxDolService::call($sElsName, $sElsMethod)) {
  889. $oModule = BxDolModule::getInstance($sElsName);
  890. bx_import('Search', $oModule->_aModule);
  891. $sClass = 'BxElsSearch';
  892. }
  893. $oSearch = new $sClass(array($sSection));
  894. $oSearch->setLiveSearch($bLiveSearch);
  895. $oSearch->setMetaType(isset($aCondition['meta_type']) ? $aCondition['meta_type'] : '');
  896. $oSearch->setCategoryObject(isset($aCondition['cat']) ? $aCondition['cat'] : '');
  897. $oSearch->setCustomSearchCondition($aCondition);
  898. if (!$bPaginate)
  899. $oSearch->setRawProcessing(true);
  900. $oSearch->setCustomCurrentCondition(array(
  901. 'paginate' => array (
  902. 'start' => $iStart,
  903. 'perPage' => $iPerPage ? $iPerPage : BX_DOL_SEARCH_RESULTS_PER_PAGE_DEFAULT,
  904. )));
  905. if ($sTemplate)
  906. $oSearch->setUnitTemplate($sTemplate);
  907. return $oSearch->response();
  908. }
  909. /**
  910. * @page service Service Calls
  911. * @section bx_system_general System Services
  912. * @subsection bx_system_general-general General
  913. * @subsubsection bx_system_general-keyword_search keyword_search
  914. *
  915. * @code bx_srv('system', 'search_keyword_form', 'TemplServices'); @endcode
  916. *
  917. * Block with Search by Keywords Form
  918. *
  919. * @see BxBaseServices::serviceSearchKeywordForm
  920. */
  921. /**
  922. * @ref bx_system_general-keyword_search "keyword_search"
  923. */
  924. public function serviceSearchKeywordForm ()
  925. {
  926. return $this->_getSearchObject()->getForm(BX_DB_PADDING_DEF, false, true);
  927. }
  928. /**
  929. * @page service Service Calls
  930. * @section bx_system_general System Services
  931. * @subsection bx_system_general-general General
  932. * @subsubsection bx_system_general-keyword_search keyword_search
  933. *
  934. * @code bx_srv('system', 'search_keyword_result', 'TemplServices'); @endcode
  935. *
  936. * Block with Search by Keywords Results
  937. *
  938. * @see BxBaseServices::serviceSearchKeywordResult
  939. */
  940. /**
  941. * @ref bx_system_general-keyword_search "keyword_search"
  942. */
  943. public function serviceSearchKeywordResult ()
  944. {
  945. $sType = bx_process_input(bx_get('type'));
  946. $sKeyword = bx_process_input(bx_get('keyword'));
  947. $bKeyword = $sKeyword !== false;
  948. if(bx_is_api())
  949. return $this->serviceGetDataSearchApi(['params' => [
  950. 'type' => $sType,
  951. 'keyword' => $sKeyword,
  952. 'section' => bx_process_input(bx_get('section')),
  953. 'cat' => bx_process_input(bx_get('cat'))
  954. ]]);
  955. $sCode = '';
  956. if($bKeyword) {
  957. $oSearch = $this->_getSearchObject();
  958. if(($sCode = $oSearch->response()))
  959. $sCode = BxDolTemplate::getInstance()->parseHtmlByName('search_result_block.html', [
  960. 'html_id' => 'bx-search-results-keyword',
  961. 'class' => 'bx-search-results-container',
  962. 'attrs' => '',
  963. 'content' => $sCode,
  964. 'bx_if:do_center' => [
  965. 'condition' => false,
  966. 'content' => [
  967. 'html_id' => '',
  968. 'selector_content' => ''
  969. ]
  970. ]
  971. ]);
  972. else
  973. $sCode = $oSearch->getEmptyResult();
  974. }
  975. return $sCode;
  976. }
  977. /**
  978. * @ref bx_system_general-get_date_search_api "get_date_search_api"
  979. * @api @ref bx_system_general-get_date_search_api "get_date_search_api"
  980. */
  981. public function serviceGetDataSearchApi ($aParams)
  982. {
  983. if(!bx_is_api())
  984. return false;
  985. if(is_string($aParams))
  986. $aParams = bx_api_get_browse_params($aParams);
  987. $bForceAll = ($aParams['params']['type'] ?? '') == 'keyword';
  988. $aSectionsAvail = explode(',', getParam('sys_api_search_sections'));
  989. $aSectionsAll = BxDolDb::getInstance()->fromCache(
  990. 'sys_global_search_pairs',
  991. 'getPairs',
  992. 'SELECT `ObjectName` AS `name`, `Title` AS `title` FROM `sys_objects_search` WHERE `GlobalSearch`=\'1\' ORDER BY `Order` ASC',
  993. 'name', 'title'
  994. );
  995. $aSections = [];
  996. foreach($aSectionsAll as $sSectionName => $sSectionTitle)
  997. if(in_array($sSectionName, $aSectionsAvail) || $bForceAll)
  998. $aSections[$sSectionName] = [
  999. 'name' => $sSectionName,
  1000. 'title' => _t($sSectionTitle)
  1001. ];
  1002. $aParamsBrowse = array_merge([
  1003. 'keyword' => '',
  1004. 'section' => '',
  1005. 'sections' => array_values($aSections),
  1006. 'start' => 0,
  1007. 'per_page' => 12
  1008. ], !empty($aParams['params']) && is_array($aParams['params']) ? $aParams['params'] : []);
  1009. if(empty($aParamsBrowse['section']))
  1010. $aParamsBrowse['section'] = array_keys($aSections);
  1011. else if(is_string($aParamsBrowse['section']))
  1012. $aParamsBrowse['section'] = explode(',', $aParamsBrowse['section']);
  1013. $sClass = 'BxTemplSearch';
  1014. $sSections = $aParamsBrowse['section'];
  1015. if ($aParamsBrowse['live'] !== true && count($sSections) > 1){
  1016. $aParamsBrowse['section'] = [];
  1017. $aParamsBrowse['sections'] = [];
  1018. $aDataRv = [];
  1019. foreach ($sSections as $sSection) {
  1020. $oSearch = new $sClass($sSection);
  1021. $oSearch->setLiveSearch(true);
  1022. $oSearch->setDataProcessing(true);
  1023. $oSearch->setCustomSearchCondition(['keyword' => $aParamsBrowse['keyword']]);
  1024. $oSearch->setCustomCurrentCondition([
  1025. 'paginate' => [
  1026. 'forceStart' => $aParamsBrowse['start'],
  1027. 'perPage' => $aParamsBrowse['per_page'],
  1028. ]
  1029. ]);
  1030. $aData = $oSearch->response();
  1031. if(count($aData) > $aParamsBrowse['per_page'])
  1032. $aData = array_slice($aData, $aParamsBrowse['start'], $aParamsBrowse['per_page']);
  1033. if (count($aData) > 0) {
  1034. $oSearchResult = $oSearch->getSearchResultObject($sSection);
  1035. $sSectionTitle = $oSearchResult->aCurrent['title'];
  1036. $aParamsBrowse['section'][] = $sSection;
  1037. $aParamsBrowse['sections'][] = ['name' => $sSection, 'title' => $sSectionTitle];
  1038. $aDataRv[] = [
  1039. 'section' => $sSection,
  1040. 'section_name' => $sSectionTitle,
  1041. 'data' => $aData,
  1042. 'is_profile' => bx_srv('system', 'is_module_profile', [$oSearchResult->aCurrent['module_name']])
  1043. ];
  1044. }
  1045. }
  1046. return [bx_api_get_block('search_sections', [
  1047. 'data' => $aDataRv,
  1048. 'params' => $aParamsBrowse
  1049. ])];
  1050. }
  1051. else{
  1052. $oSearch = new $sClass($aParamsBrowse['section']);
  1053. $oSearch->setLiveSearch(true);
  1054. $oSearch->setDataProcessing(true);
  1055. $oSearch->setCustomSearchCondition(['keyword' => $aParamsBrowse['keyword']]);
  1056. $oSearch->setCustomCurrentCondition([
  1057. 'paginate' => [
  1058. 'forceStart' => $aParamsBrowse['start'],
  1059. 'perPage' => $aParamsBrowse['per_page'],
  1060. ]
  1061. ]);
  1062. $aData = $oSearch->response();
  1063. if(count($aData) > $aParamsBrowse['per_page'])
  1064. $aData = array_slice($aData, $aParamsBrowse['start'], $aParamsBrowse['per_page']);
  1065. return [
  1066. bx_api_get_block('browse', [
  1067. 'unit' => 'search-results',
  1068. 'request_url' => '/api.php?r=system/get_data_search_api/TemplServices&params[]=',
  1069. 'params' => $aParamsBrowse,
  1070. 'data' => $aData
  1071. ])
  1072. ];
  1073. }
  1074. }
  1075. /**
  1076. * @page service Service Calls
  1077. * @section bx_system_general System Services
  1078. * @subsection bx_system_general-general General
  1079. * @subsubsection bx_system_general-cmts cmts
  1080. *
  1081. * @code bx_srv('system', 'cmts', ["sys_blocks", 1], 'TemplServices'); @endcode
  1082. *
  1083. * @code {{~system:cmts:TemplServices["sys_blocks", 1]~}} @endcode
  1084. *
  1085. * Comments block
  1086. * @param $sObject - comments object name
  1087. * @param $sId - content id assiciated tith the comments
  1088. *
  1089. * @see BxBaseServices::serviceCmts
  1090. */
  1091. /**
  1092. * @ref bx_system_general-cmts "cmts"
  1093. */
  1094. public function serviceCmts ($sObject, $sId)
  1095. {
  1096. $o = BxDolCmts::getObjectInstance($sObject, $sId);
  1097. if (!$o || !$o->isEnabled())
  1098. return '';
  1099. return $o->getCommentsBlock(array(), array('in_designbox' => false, 'show_empty' => true));
  1100. }
  1101. public function _serviceProfileFunc ($sFunc, $iContentId, $aParams = array())
  1102. {
  1103. if (!$iContentId)
  1104. return false;
  1105. if (!($oAccount = BxDolAccount::getInstance($iContentId)))
  1106. return false;
  1107. return $oAccount->$sFunc(false, $aParams);
  1108. }
  1109. public function serviceAlertResponseProcessInstalled()
  1110. {
  1111. BxDolTranscoderImage::registerHandlersSystem();
  1112. }
  1113. public function serviceAlertResponseProcessStorageChange ($oAlert)
  1114. {
  1115. if ('sys_storage_default' != $oAlert->aExtras['option'])
  1116. return;
  1117. $aStorages = BxDolStorageQuery::getStorageObjects();
  1118. foreach ($aStorages as $r) {
  1119. if (0 == $r['current_size'] && 0 == $r['current_number'] && ($oStorage = BxDolStorage::getObjectInstance($r['object'])))
  1120. $oStorage->changeStorageEngine($oAlert->aExtras['value']);
  1121. }
  1122. }
  1123. public function serviceGetOptionsProfileBot()
  1124. {
  1125. $aResult = array(
  1126. array('key' => '', 'value' => _t('_Select_one'))
  1127. );
  1128. $aAccountsIds = BxDolAccountQuery::getInstance()->getOperators();
  1129. foreach($aAccountsIds as $iAccountId) {
  1130. $aProfilesIds = BxDolAccount::getInstance($iAccountId)->getProfilesIds(true, false);
  1131. foreach($aProfilesIds as $iProfileId) {
  1132. $oProfile = BxDolProfile::getInstance($iProfileId);
  1133. $aResult[] = array(
  1134. 'key' => $iProfileId,
  1135. 'value' => _t('_sys_profile_with_type', $oProfile->getDisplayName(), $oProfile->getModule()),
  1136. );
  1137. }
  1138. }
  1139. return $aResult;
  1140. }
  1141. public function serviceGetOptionsModuleListForPrivacySelector()
  1142. {
  1143. $aResult = array();
  1144. $BxDolModuleQuery = BxDolModuleQuery::getInstance();
  1145. $aModules = $BxDolModuleQuery->getModulesBy(array('type' => 'modules', 'active' => 1));
  1146. foreach($aModules as $aModule){
  1147. $oModule = BxDolModule::getInstance($aModule['name']);
  1148. if($oModule instanceof iBxDolContentInfoService){
  1149. if (!BxDolRequest::serviceExists($aModule['name'], 'act_as_profile'))
  1150. continue;
  1151. $aResult[$aModule['name']] = $aModule['title'];
  1152. }
  1153. }
  1154. return $aResult;
  1155. }
  1156. public function serviceGetOptionsCaptchaDefault()
  1157. {
  1158. $aResults = [];
  1159. $aObjects = BxDolCaptchaQuery::getObjects();
  1160. foreach($aObjects as $aObject)
  1161. $aResults[$aObject['object']] = $aObject['title'];
  1162. return $aResults;
  1163. }
  1164. public function serviceGetOptionsEmbedDefault()
  1165. {
  1166. $aResults = array(
  1167. '' => _t('_None')
  1168. );
  1169. $aObjects = BxDolEmbedQuery::getObjects();
  1170. foreach($aObjects as $aObject)
  1171. $aResults[$aObject['object']] = _t($aObject['title']);
  1172. return $aResults;
  1173. }
  1174. public function serviceGetOptionsLocationFieldDefault()
  1175. {
  1176. $aResults = array();
  1177. $aObjects = BxDolLocationFieldQuery::getObjects();
  1178. foreach($aObjects as $aObject)
  1179. $aResults[$aObject['object']] = _t($aObject['title']);
  1180. return $aResults;
  1181. }
  1182. public function serviceGetOptionsLocationMapDefault()
  1183. {
  1184. $aResults = array();
  1185. $aObjects = BxDolLocationMapQuery::getObjects();
  1186. foreach($aObjects as $aObject)
  1187. $aResults[$aObject['object']] = _t($aObject['title']);
  1188. return $aResults;
  1189. }
  1190. public function serviceGetOptionsPushDefault()
  1191. {
  1192. $aResults = [
  1193. '' => _t('_None')
  1194. ];
  1195. $aObjects = BxDolPushQuery::getObjects();
  1196. foreach($aObjects as $aObject)
  1197. $aResults[$aObject['object']] = $aObject['title'];
  1198. return $aResults;
  1199. }
  1200. public function serviceGetOptionsSmsDefault()
  1201. {
  1202. $aResults = [
  1203. '' => _t('_None')
  1204. ];
  1205. $aObjects = BxDolSmsQuery::getObjects();
  1206. foreach($aObjects as $aObject)
  1207. $aResults[$aObject['object']] = $aObject['title'];
  1208. return $aResults;
  1209. }
  1210. public function serviceGetOptionsSocketsFieldDefault()
  1211. {
  1212. $aResults = [];
  1213. $aObjects = ['sys_sockets_disabled', 'sys_sockets_soketi'];
  1214. foreach($aObjects as $sObject)
  1215. $aResults[$sObject] = _t('_adm_stg_cpt_option_sys_sockets_type_' . $sObject);
  1216. return $aResults;
  1217. }
  1218. public function serviceGetOptionsLocationLeafletGetProviders()
  1219. {
  1220. return BxDolLocationMapLeaflet::getProviders();
  1221. }
  1222. public function serviceGetOptionsRelations()
  1223. {
  1224. $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
  1225. $aProfiles = array();
  1226. foreach($aModules as $aModule) {
  1227. $sMethod = 'act_as_profile';
  1228. if(!BxDolRequest::serviceExists($aModule['name'], $sMethod) || !BxDolService::call($aModule['name'], $sMethod))
  1229. continue;
  1230. $aProfiles[$aModule['name']] = _t('_' . $aModule['name']);
  1231. }
  1232. $aResults = array();
  1233. foreach($aProfiles as $sName1 => $sTitle1)
  1234. foreach($aProfiles as $sName2 => $sTitle2)
  1235. $aResults[$sName1 . '_' . $sName2] = $sTitle1 . ' - ' . $sTitle2;
  1236. return $aResults;
  1237. }
  1238. public function serviceGetOptionsCfProhibited()
  1239. {
  1240. return BxDolFormQuery::getDataItems('sys_content_filter');
  1241. }
  1242. public function serviceGetOptionsCfUnauthenticated()
  1243. {
  1244. return BxDolFormQuery::getDataItems('sys_content_filter');
  1245. }
  1246. public function serviceGetOptionsTaiwindDefault()
  1247. {
  1248. $sPath = BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'tailwind/css';
  1249. $aExcludes = ['.', '..', 'tailwind.css'];
  1250. $aResults = [];
  1251. if(($oHandle = opendir($sPath)) !== false) {
  1252. while(($sFile = readdir($oHandle)) !== false) {
  1253. if(in_array($sFile, $aExcludes))
  1254. continue;
  1255. if(($oHandlerFile = fopen($sPath . '/' . $sFile, 'r')) === false)
  1256. continue;
  1257. if(($sContent = fread($oHandlerFile, 1024)) !== false && strpos($sContent, '@tailwind base') === false)
  1258. $aResults[$sFile] = $sFile;
  1259. fclose($oHandlerFile);
  1260. }
  1261. closedir($oHandle);
  1262. }
  1263. /**
  1264. * Disabled for now, because CDN and custom compiled build with own styles
  1265. * don't work correctly together.
  1266. *
  1267. * $aResults['cdn'] = _t('_adm_stg_cpt_option_sys_css_tailwind_default_cdn');
  1268. */
  1269. return $aResults;
  1270. }
  1271. public function serviceGetOptionsIconsetDefault()
  1272. {
  1273. $aObjects = BxDolIconsetQuery::getObjects();
  1274. foreach($aObjects as $aObject)
  1275. $aResults[$aObject['object']] = $aObject['title'];
  1276. return $aResults;
  1277. }
  1278. public function serviceGetOptionsApiMenuTop()
  1279. {
  1280. $aMenus = BxDolMenuQuery::getMenuObjects();
  1281. $aResults = ['' => _t('_sys_please_select')];
  1282. foreach($aMenus as $aMenu)
  1283. if($aMenu['module'] == 'system')
  1284. $aResults[$aMenu['object']] = _t($aMenu['title']);
  1285. return $aResults;
  1286. }
  1287. public function serviceGetOptionsApiContextSwitcher()
  1288. {
  1289. $aContexts = bx_srv('system', 'get_modules_by_type', ['context']);
  1290. $aResults = ['' => _t('_None')];
  1291. foreach($aContexts as $aContext)
  1292. $aResults[$aContext['name']] = _t('_' . $aContext['name']);
  1293. return $aResults;
  1294. }
  1295. public function serviceGetOptionsApiContextConnection()
  1296. {
  1297. $aConnections = ['subscriptions', 'fans', 'participants'];
  1298. $aResults = ['' => _t('_sys_please_select')];
  1299. foreach($aConnections as $sConnection)
  1300. $aResults[$sConnection] = _t('_adm_stg_cpt_option_sys_api_cnt_cnn_' . $sConnection);
  1301. return $aResults;
  1302. }
  1303. public function serviceGetOptionsAgentsModel()
  1304. {
  1305. return ['' => _t('_Select_one')] + BxDolAI::getInstance()->getModels(['active' => true, 'hidden' => false]);
  1306. }
  1307. public function serviceGetOptionsAgentsProfile($bSelectOne = true)
  1308. {
  1309. $aResult = [];
  1310. if($bSelectOne)
  1311. $aResult[] = ['key' => '', 'value' => _t('_Select_one')];
  1312. $aAccountsIds = BxDolAccountQuery::getInstance()->getOperators();
  1313. foreach($aAccountsIds as $iAccountId) {
  1314. $aProfilesIds = BxDolAccount::getInstance($iAccountId)->getProfilesIds(true, false);
  1315. foreach($aProfilesIds as $iProfileId)
  1316. if(($oProfile = BxDolProfile::getInstance($iProfileId)) !== false && ($sProfileModule = $oProfile->getModule()) != 'system')
  1317. $aResult[] = [
  1318. 'key' => $iProfileId,
  1319. 'value' => _t('_sys_profile_with_type', $oProfile->getDisplayName(), _t('_' . $sProfileModule))
  1320. ];
  1321. }
  1322. return $aResult;
  1323. }
  1324. public function serviceGetOptionsStudioAssistant()
  1325. {
  1326. return ['' => _t('_Select_one')] + BxDolAI::getInstance()->getAssistants(['active' => true, 'hidden' => false]);
  1327. }
  1328. public function serviceGetOptionsLiveSearchAssistant()
  1329. {
  1330. return ['' => _t('_Select_one')] + BxDolAI::getInstance()->getAssistants(['active' => true, 'hidden' => false]);
  1331. }
  1332. public function serviceGetOptionsAskBlockAssistant()
  1333. {
  1334. return ['' => _t('_Select_one')] + BxDolAI::getInstance()->getAssistants(['active' => true, 'hidden' => false]);
  1335. }
  1336. public function serviceRedirect($sUrl = false)
  1337. {
  1338. if (!getParam('sys_confirmation_before_redirect')) {
  1339. BxDolTemplate::getInstance()->displayPageNotFound();
  1340. exit;
  1341. }
  1342. if (false === $sUrl)
  1343. $sUrl = bx_get('url');
  1344. if (!$sUrl || !preg_match('@^https?://@', $sUrl)) {
  1345. http_response_code(500);
  1346. return MsgBox(_t('_error occured'));
  1347. }
  1348. else {
  1349. $bSpam = null;
  1350. /**
  1351. * @hooks
  1352. * @hookdef hook-system-check_spam_url 'system', 'check_spam_url' - hook to override sClass for search
  1353. * - $unit_name - equals `system`
  1354. * - $action - equals `check_spam_url`
  1355. * - $object_id - not used
  1356. * - $sender_id - logged account id
  1357. * - $extra_params - array of additional params with the following array keys:
  1358. * - `is_spam` - [bool] by ref, spam url or not, can be overridden in hook processing
  1359. * - `content` - [string] by ref, url of link, can be overridden in hook processing
  1360. * - `where` - [string] equal redirect
  1361. * @hook @ref hook-system-check_spam_url
  1362. */
  1363. bx_alert('system', 'check_spam_url', 0, getLoggedId(), array('is_spam' => &$bSpam, 'content' => &$sUrl, 'where' => 'redirect'));
  1364. $sLangKey = $bSpam ? '_sys_redirect_confirmation_harmful' : '_sys_redirect_confirmation';
  1365. return BxDolTemplate::getInstance()->parseHtmlByName('redirect.html', [
  1366. 'text' => _t($sLangKey, bx_process_output($sUrl), getParam('site_title')),
  1367. 'url' => bx_js_string($sUrl, BX_ESCAPE_STR_APOS),
  1368. ]);
  1369. }
  1370. }
  1371. public function serviceSetBadges($iContentId, $sBadgesIds, $sModule)
  1372. {
  1373. $aSelectedBadges = explode(",", $sBadgesIds);
  1374. $iPerformerId = bx_get_logged_profile_id();
  1375. $aCheck = checkActionModule($iPerformerId, 'set badge', 'system', false);
  1376. if(!isAdmin() && $aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  1377. return false;
  1378. $oBadges = BxDolBadges::getInstance();
  1379. $aBadges = $oBadges->getData(array('type' => 'by_module&object', 'object_id' => $iContentId, 'module' => $sModule));
  1380. foreach ($aBadges as $aBadge) {
  1381. if (isset($aBadge['badge_id'])){
  1382. $oBadges->delete($aBadge['badge_id']);
  1383. }
  1384. }
  1385. foreach ($aSelectedBadges as $iSelectedBadge) {
  1386. $oBadges->add($iSelectedBadge, $iContentId, $sModule);
  1387. }
  1388. checkActionModule($iPerformerId, 'set badge', 'system', true); // perform action
  1389. return true;
  1390. }
  1391. public function serviceGetBadge($aBadge, $bIsCompact = false)
  1392. {
  1393. $sClass = '';
  1394. $sStyleFont = '';
  1395. $sStyleBg = '';
  1396. if ($aBadge['color'] == '')
  1397. $aBadge['color'] = 'purple-600';
  1398. if ($bIsCompact && $aBadge['icon'] != ''){
  1399. $aBadge['is_icon_only'] = 1;
  1400. }
  1401. if ($aBadge['is_icon_only'] == 1){
  1402. $sClass .= ' bx-badge-compact';
  1403. if (substr_count($aBadge['color'], 'rgb('))
  1404. $sStyleFont = 'color: ' . $aBadge['color'];
  1405. else
  1406. $sClass .= ' text-' . $aBadge['color'];
  1407. }
  1408. else{
  1409. if (substr_count($aBadge['color'], 'rgb('))
  1410. $sStyleBg = 'background-color: ' . $aBadge['color'];
  1411. else
  1412. $sClass .= ' bg-' . $aBadge['color'];
  1413. }
  1414. return BxDolTemplate::getInstance()->parseHtmlByName('badge.html', array(
  1415. 'bx_if:content' => array(
  1416. 'condition' => $aBadge['is_icon_only'] != '1',
  1417. 'content' => array('content' => _t($aBadge['text'])),
  1418. ),
  1419. 'bx_if:icon' => array(
  1420. 'condition' => $aBadge['icon'] != '',
  1421. 'content' => array('content' => BxDolTemplate::getInstance()->getIcon($aBadge['icon'], array('class' => 'bx-badge-icon sys-colored', 'style' => $sStyleFont))),
  1422. ),
  1423. 'title' => $aBadge['text'],
  1424. 'style_font' => $sStyleFont,
  1425. 'style_bg' => $sStyleBg,
  1426. 'class' => $sClass,
  1427. )
  1428. );
  1429. }
  1430. public function serviceGetFooter()
  1431. {
  1432. return BxDolTemplate::getInstance()->parseHtmlByName('footer.html', []);
  1433. }
  1434. private function _getSearchObject()
  1435. {
  1436. $sClass = 'BxTemplSearch';
  1437. $sElsName = 'bx_elasticsearch';
  1438. $sElsMethod = 'is_configured';
  1439. if(BxDolRequest::serviceExists($sElsName, $sElsMethod) && BxDolService::call($sElsName, $sElsMethod) && !bx_get('cat') && !bx_get('type')) {
  1440. $oModule = BxDolModule::getInstance($sElsName);
  1441. bx_import('Search', $oModule->_aModule);
  1442. $sClass = 'BxElsSearch';
  1443. }
  1444. /**
  1445. * @hooks
  1446. * @hookdef hook-system-search_keyword 'system', 'search_keyword' - hook to override sClass for search
  1447. * - $unit_name - equals `system`
  1448. * - $action - equals `search_keyword`
  1449. * - $object_id - not used
  1450. * - $sender_id - not used
  1451. * - $extra_params - array of additional params with the following array keys:
  1452. * - `override_result` - [string] by ref, class name for search, can be overridden in hook processing
  1453. * @hook @ref hook-system-search_keyword
  1454. */
  1455. bx_alert('system', 'search_keyword', 0, 0, array('class' => &$sClass));
  1456. $oSearch = new $sClass(bx_get('section'));
  1457. $oSearch->setLiveSearch(bx_get('live_search') ? 1 : 0);
  1458. $oSearch->setMetaType(bx_process_input(bx_get('type')));
  1459. $oSearch->setCategoryObject(bx_process_input(bx_get('cat')));
  1460. return $oSearch;
  1461. }
  1462. public function serviceHomeRedirect()
  1463. {
  1464. header("Location:" . BX_DOL_URL_ROOT, true, 301);
  1465. exit;
  1466. }
  1467. public function serviceProcessEmbed()
  1468. {
  1469. BxDolEmbed::getObjectInstance()->process();
  1470. }
  1471. }
  1472. /** @} */