BxForumModule.php 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  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 Forum Forum
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxForumModule extends BxBaseModTextModule
  12. {
  13. function __construct(&$aModule)
  14. {
  15. parent::__construct($aModule);
  16. }
  17. public function decodeDataApi ($aData, $bExtended = false)
  18. {
  19. $CNF = $this->_oConfig->CNF;
  20. $aResult = parent::decodeDataApi($aData, $bExtended);
  21. $oCategory = BxDolCategory::getObjectInstance($CNF['OBJECT_CATEGORY']);
  22. if(!$oCategory)
  23. return false;
  24. $aCategoryData = $this->_oDb->getCategories(['type' => 'by_category', 'category' => $aData[$CNF['FIELD_CATEGORY']]]);
  25. if(!empty($aCategoryData) &&is_array($aCategoryData))
  26. $aResult['category'] = [
  27. 'name' => $oCategory->getCategoryTitle($aData[$CNF['FIELD_CATEGORY']]),
  28. 'icon' => $aCategoryData['icon']
  29. ];
  30. return $aResult;
  31. }
  32. public function sortParticipants ($aParticipants, $iProfileIdLastComment, $iProfileIdAuthor, $iProfileIdCurrent = 0)
  33. {
  34. if (!$iProfileIdCurrent)
  35. $iProfileIdCurrent = bx_get_logged_profile_id();
  36. $aMoveUp = array($iProfileIdCurrent, $iProfileIdLastComment, $iProfileIdAuthor);
  37. asort($aParticipants, SORT_NUMERIC);
  38. foreach ($aMoveUp as $iProfileId) {
  39. if (!isset($aParticipants[$iProfileId]))
  40. continue;
  41. $a = array($iProfileId => $aParticipants[$iProfileId]);
  42. unset($aParticipants[$iProfileId]);
  43. $aParticipants = $a + $aParticipants;
  44. }
  45. return $aParticipants;
  46. }
  47. /**
  48. * Action methods
  49. */
  50. public function actionUpdateStatus($sAction = '', $iContentId = 0)
  51. {
  52. if(empty($sAction) && bx_get('action') !== false)
  53. $sAction = bx_process_input(bx_get('action'));
  54. if(empty($iContentId) && bx_get('id') !== false)
  55. $iContentId = (int)bx_get('id');
  56. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  57. if(empty($aContentInfo) || !is_array($aContentInfo))
  58. return echoJson(array('code' => 1, 'message' => _t('_bx_forum_err_not_found')));
  59. $sMethodCheck = 'checkAllowed' . bx_gen_method_name($sAction) . 'AnyEntry';
  60. $sResult = $this->$sMethodCheck($aContentInfo);
  61. if($sResult !== CHECK_ACTION_RESULT_ALLOWED)
  62. return echoJson(array('code' => 2, 'message' => $sResult));
  63. bx_audit(
  64. $iContentId,
  65. $this->getName(),
  66. '_sys_audit_action_' . $sAction,
  67. $this->_prepareAuditParams($aContentInfo, false)
  68. );
  69. if(!$this->_oDb->updateStatus($sAction, $aContentInfo))
  70. return echoJson(array('code' => 3, 'message' => _t('_error occured')));
  71. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  72. $this->alertAfterEdit($aContentInfo);
  73. echoJson(array('code' => 0, 'id' => $iContentId, 'reload' => 1));
  74. }
  75. public function actionAjaxGetAuthors()
  76. {
  77. $aResult = BxDolService::call('system', 'profiles_search', array(bx_get('term')), 'TemplServiceProfiles');
  78. header('Content-Type:text/javascript; charset=utf-8');
  79. echo json_encode($aResult);
  80. }
  81. /**
  82. * Service methods
  83. */
  84. public function serviceGetSafeServices()
  85. {
  86. $a = parent::serviceGetSafeServices();
  87. return array_merge($a, array (
  88. 'BrowseNew' => '',
  89. 'BrowseLatest' => '',
  90. 'BrowseTop' => '',
  91. 'BrowsePopular' => '',
  92. 'BrowseUpdated' => '',
  93. 'BrowsePartaken' => '',
  94. 'BrowseIndex' => '',
  95. 'Search' => '',
  96. ));
  97. }
  98. /**
  99. * @page service Service Calls
  100. * @section bx_forum Discussions
  101. * @subsection bx_forum-other Other
  102. * @subsubsection bx_forum-get_searchable_fields get_searchable_fields
  103. *
  104. * @code bx_srv('bx_forum', 'get_searchable_fields', [...]); @endcode
  105. *
  106. * Get searchable fields for Studio settings.
  107. *
  108. * @return an array with key-value pairs to be used in settings dropdown field.
  109. *
  110. * @see BxForumModule::serviceGetSearchableFields
  111. */
  112. /**
  113. * @ref bx_forum-get_searchable_fields "get_searchable_fields"
  114. */
  115. public function serviceGetSearchableFields ($aInputsAdd = array())
  116. {
  117. $CNF = &$this->_oConfig->CNF;
  118. $aResult = parent::serviceGetSearchableFields($aInputsAdd);
  119. $aResult[$CNF['FIELD_TEXT_COMMENTS']] = _t('_bx_forum_form_entry_input_text_comments');
  120. return $aResult;
  121. }
  122. /**
  123. * Service methods
  124. */
  125. /**
  126. * @page service Service Calls
  127. * @section bx_forum Discussions
  128. * @subsection bx_forum-other Other
  129. * @subsubsection bx_forum-get_info get_info
  130. *
  131. * @code bx_srv('bx_forum', 'get_info', [...]); @endcode
  132. *
  133. * Get content info by content ID. Is used in "Content Info Objects" system.
  134. *
  135. * @param $iContentId integer value with content ID.
  136. * @param $bSearchableFieldsOnly (optional) boolean value determining all info or "searchable fields" only will be returned.
  137. * @return an array with content info. Empty array is returned if something is wrong.
  138. *
  139. * @see BxForumModule::serviceGetInfo
  140. */
  141. /**
  142. * @ref bx_forum-get_info "get_info"
  143. */
  144. public function serviceGetInfo ($iContentId, $bSearchableFieldsOnly = true)
  145. {
  146. $aContentInfo = $this->_getFields($iContentId);
  147. if(empty($aContentInfo))
  148. return array();
  149. return $aContentInfo;
  150. }
  151. /**
  152. * @page service Service Calls
  153. * @section bx_forum Discussions
  154. * @subsection bx_forum-page_blocks Page Blocks
  155. * @subsubsection bx_forum-browse_new browse_new
  156. *
  157. * @code bx_srv('bx_forum', 'browse_new', [...]); @endcode
  158. *
  159. * Get page block with a list of items ordered by newness and represented as table.
  160. *
  161. * @param $sUnitView (optional) string with unit view type.
  162. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  163. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  164. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  165. *
  166. * @see BxForumModule::serviceBrowseNew
  167. */
  168. /**
  169. * @ref bx_forum-browse_new "browse_new"
  170. */
  171. public function serviceBrowseNew ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true, $bShowHeader = false)
  172. {
  173. $sType = 'new';
  174. if($sUnitView != 'table')
  175. return $this->_serviceBrowse($sType, $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  176. return $this->_serviceBrowseTable(array(
  177. 'type' => $sType,
  178. 'empty_message' => $bEmptyMessage,
  179. 'ajax_paginate' => $bAjaxPaginate
  180. ), $bShowHeader);
  181. }
  182. /**
  183. * @page service Service Calls
  184. * @section bx_forum Discussions
  185. * @subsection bx_forum-page_blocks Page Blocks
  186. * @subsubsection bx_forum-browse_latest browse_latest
  187. *
  188. * @code bx_srv('bx_forum', 'browse_latest', [...]); @endcode
  189. *
  190. * Get page block with a list of items ordered by Recent Posts in them and represented as table.
  191. *
  192. * @param $sUnitView (optional) string with unit view type.
  193. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  194. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  195. * @param $bShowHeader (optional) boolean value determining whether a resulting table should have Header section or not.
  196. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  197. *
  198. * @see BxForumModule::serviceBrowseNew
  199. */
  200. /**
  201. * @ref bx_forum-browse_latest "browse_latest"
  202. */
  203. public function serviceBrowseLatest($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true, $bShowHeader = true)
  204. {
  205. $sType = 'latest';
  206. if($sUnitView != 'table')
  207. return $this->_serviceBrowse($sType, $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  208. return $this->_serviceBrowseTable(array(
  209. 'type' => $sType,
  210. 'empty_message' => $bEmptyMessage,
  211. 'ajax_paginate' => $bAjaxPaginate
  212. ), $bShowHeader);
  213. }
  214. /**
  215. * @page service Service Calls
  216. * @section bx_forum Discussions
  217. * @subsection bx_forum-page_blocks Page Blocks
  218. * @subsubsection bx_forum-browse_featured browse_featured
  219. *
  220. * @code bx_srv('bx_forum', 'browse_featured', [...]); @endcode
  221. *
  222. * Get page block with a list of featured items represented as table.
  223. *
  224. * @param $sUnitView (optional) string with unit view type.
  225. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  226. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  227. * @param $bShowHeader (optional) boolean value determining whether a resulting table should have Header section or not.
  228. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  229. *
  230. * @see BxForumModule::serviceBrowseFeatured
  231. */
  232. /**
  233. * @ref bx_forum-browse_featured "browse_featured"
  234. */
  235. public function serviceBrowseFeatured($sUnitView = false, $bEmptyMessage = false, $bAjaxPaginate = true, $bShowHeader = false)
  236. {
  237. $CNF = &$this->_oConfig->CNF;
  238. $sType = 'featured';
  239. if($sUnitView != 'table')
  240. return $this->_serviceBrowse($sType, $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  241. return $this->_serviceBrowseTable(array(
  242. 'type' => $sType,
  243. 'empty_message' => $bEmptyMessage,
  244. 'ajax_paginate' => $bAjaxPaginate
  245. ), $bShowHeader);
  246. }
  247. /**
  248. * @page service Service Calls
  249. * @section bx_forum Discussions
  250. * @subsection bx_forum-page_blocks Page Blocks
  251. * @subsubsection bx_forum-browse_top browse_top
  252. *
  253. * @code bx_srv('bx_forum', 'browse_top', [...]); @endcode
  254. *
  255. * Get page block with a list of items ordered by a number of comments and represented as table.
  256. *
  257. * @param $sUnitView (optional) string with unit view type.
  258. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  259. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  260. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  261. *
  262. * @see BxForumModule::serviceBrowseTop
  263. */
  264. /**
  265. * @ref bx_forum-browse_top "browse_top"
  266. */
  267. public function serviceBrowseTop($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true, $bShowHeader = true)
  268. {
  269. $sType = 'top';
  270. if($sUnitView != 'table')
  271. return $this->_serviceBrowse($sType, $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  272. return $this->_serviceBrowseTable(array(
  273. 'type' => $sType,
  274. 'empty_message' => $bEmptyMessage,
  275. 'ajax_paginate' => $bAjaxPaginate
  276. ), $bShowHeader);
  277. }
  278. /**
  279. * @page service Service Calls
  280. * @section bx_forum Discussions
  281. * @subsection bx_forum-page_blocks Page Blocks
  282. * @subsubsection bx_forum-browse_popular browse_popular
  283. *
  284. * @code bx_srv('bx_forum', 'browse_popular', [...]); @endcode
  285. *
  286. * Get page block with a list of items ordered by a number of views and represented as table.
  287. *
  288. * @param $sUnitView (optional) string with unit view type.
  289. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  290. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  291. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  292. *
  293. * @see BxForumModule::serviceBrowsePopular
  294. */
  295. /**
  296. * @ref bx_forum-browse_popular "browse_popular"
  297. */
  298. public function serviceBrowsePopular ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true, $bShowHeader = false)
  299. {
  300. $sType = 'popular';
  301. if($sUnitView != 'table')
  302. return $this->_serviceBrowse($sType, $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  303. return $this->_serviceBrowseTable(array(
  304. 'type' => $sType,
  305. 'empty_message' => $bEmptyMessage,
  306. 'ajax_paginate' => $bAjaxPaginate
  307. ), $bShowHeader);
  308. }
  309. /**
  310. * @page service Service Calls
  311. * @section bx_forum Discussions
  312. * @subsection bx_forum-page_blocks Page Blocks
  313. * @subsubsection bx_forum-browse_updated browse_updated
  314. *
  315. * @code bx_srv('bx_forum', 'browse_updated', [...]); @endcode
  316. *
  317. * Get page block with a list of updated items represented as table.
  318. *
  319. * @param $sUnitView (optional) string with unit view type.
  320. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  321. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  322. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  323. *
  324. * @see BxForumModule::serviceBrowseUpdated
  325. */
  326. /**
  327. * @ref bx_forum-browse_updated "browse_updated"
  328. */
  329. public function serviceBrowseUpdated ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true, $bShowHeader = false)
  330. {
  331. $sType = 'updated';
  332. if($sUnitView != 'table')
  333. return $this->_serviceBrowse($sType, $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  334. return $this->_serviceBrowseTable(array(
  335. 'type' => $sType,
  336. 'empty_message' => $bEmptyMessage,
  337. 'ajax_paginate' => $bAjaxPaginate
  338. ), $bShowHeader);
  339. }
  340. /**
  341. * @page service Service Calls
  342. * @section bx_forum Discussions
  343. * @subsection bx_forum-page_blocks Page Blocks
  344. * @subsubsection bx_forum-browse_partaken browse_partaken
  345. *
  346. * @code bx_srv('bx_forum', 'browse_partaken', [...]); @endcode
  347. *
  348. * Get page block with a list of partaken items represented as table.
  349. *
  350. * @param $sUnitView (optional) string with unit view type.
  351. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  352. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  353. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  354. *
  355. * @see BxForumModule::serviceBrowsePartaken
  356. */
  357. /**
  358. * @ref bx_forum-browse_partaken "browse_partaken"
  359. */
  360. public function serviceBrowsePartaken ($iProfileId = 0, $aParams = [])
  361. {
  362. $sType = 'partaken';
  363. if(!$iProfileId)
  364. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  365. if(!$iProfileId)
  366. $iProfileId = bx_get_logged_profile_id();
  367. $bEmptyMessage = true;
  368. if(isset($aParams['empty_message'])) {
  369. $bEmptyMessage = (bool)$aParams['empty_message'];
  370. unset($aParams['empty_message']);
  371. }
  372. $bAjaxPaginate = true;
  373. if(isset($aParams['ajax_paginate'])) {
  374. $bAjaxPaginate = (bool)$aParams['ajax_paginate'];
  375. unset($aParams['ajax_paginate']);
  376. }
  377. $bShowHeader = false;
  378. if(isset($aParams['show_header'])) {
  379. $bShowHeader = (bool)$aParams['show_header'];
  380. unset($aParams['show_header']);
  381. }
  382. if(isset($aParams['unit_view']) && $aParams['unit_view'] != 'table')
  383. return $this->_serviceBrowse($sType, array_merge(['author' => $iProfileId], $aParams), BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  384. return $this->_serviceBrowseTable([
  385. 'type' => $sType,
  386. 'author' => $iProfileId,
  387. 'include_contexts' => isset($aParams['include_contexts']) && $aParams['include_contexts'],
  388. 'empty_message' => $bEmptyMessage,
  389. 'ajax_paginate' => $bAjaxPaginate
  390. ], $bShowHeader);
  391. }
  392. /**
  393. * @page service Service Calls
  394. * @section bx_forum Discussions
  395. * @subsection bx_forum-page_blocks Page Blocks
  396. * @subsubsection bx_forum-browse_index browse_index
  397. *
  398. * @code bx_srv('bx_forum', 'browse_index', [...]); @endcode
  399. *
  400. * Get page block for Site's Home page with a list of items ordered by newness and represented as table.
  401. *
  402. * @param $sUnitView (optional) string with unit view type.
  403. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  404. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  405. * @param $bShowHeader (optional) boolean value determining whether a resulting table should have Header section or not.
  406. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  407. *
  408. * @see BxForumModule::serviceBrowseIndex
  409. */
  410. /**
  411. * @ref bx_forum-browse_index "browse_index"
  412. */
  413. public function serviceBrowseIndex($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true, $bShowHeader = false)
  414. {
  415. $sType = 'index';
  416. if($sUnitView != 'table')
  417. return $this->_serviceBrowse($sType, $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  418. return $this->_serviceBrowseTable(array(
  419. 'type' => $sType,
  420. 'per_page' => (int)$this->_oDb->getParam('bx_forum_per_page_index'),
  421. 'empty_message' => $bEmptyMessage,
  422. 'ajax_paginate' => $bAjaxPaginate
  423. ), $bShowHeader);
  424. }
  425. /**
  426. * @page service Service Calls
  427. * @section bx_forum Discussions
  428. * @subsection bx_forum-page_blocks Page Blocks
  429. * @subsubsection bx_forum-browse_author browse_author
  430. *
  431. * @code bx_srv('bx_forum', 'browse_author', [...]); @endcode
  432. *
  433. * Get page block with a list of items filtered by Author and represented as table.
  434. *
  435. * @param $iProfileId (optional) integer value with author ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  436. * @param $aParams (optional) an array of additional params. It's not used for now.
  437. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  438. *
  439. * @see BxForumModule::serviceBrowseAuthor
  440. */
  441. /**
  442. * @ref bx_forum-browse_author "browse_author"
  443. */
  444. public function serviceBrowseAuthor ($iProfileId = 0, $aParams = array())
  445. {
  446. if(!$iProfileId)
  447. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  448. if(!$iProfileId)
  449. return '';
  450. $bEmptyMessage = true;
  451. if(isset($aParams['empty_message'])) {
  452. $bEmptyMessage = (bool)$aParams['empty_message'];
  453. unset($aParams['empty_message']);
  454. }
  455. $bAjaxPaginate = true;
  456. if(isset($aParams['ajax_paginate'])) {
  457. $bAjaxPaginate = (bool)$aParams['ajax_paginate'];
  458. unset($aParams['ajax_paginate']);
  459. }
  460. if(isset($aParams['unit_view']) && $aParams['unit_view'] != 'table')
  461. return $this->_serviceBrowse('author', array_merge(array('author' => $iProfileId), $aParams), BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  462. return $this->_serviceBrowseTable(array(
  463. 'type' => 'author',
  464. 'author' => $iProfileId,
  465. 'where' => array('fld' => 'author', 'val' => $iProfileId, 'opr' => '='),
  466. 'per_page' => (int)$this->_oDb->getParam('bx_forum_per_page_profile'),
  467. 'empty_message' => $bEmptyMessage,
  468. 'ajax_paginate' => $bAjaxPaginate
  469. ), false);
  470. }
  471. /**
  472. * @page service Service Calls
  473. * @section bx_forum Discussions
  474. * @subsection bx_forum-page_blocks Page Blocks
  475. * @subsubsection bx_forum-browse_favorite browse_favorite
  476. *
  477. * @code bx_srv('bx_forum', 'browse_favorite', [...]); @endcode
  478. *
  479. * Get page block with a list of favorited items by some profile and represented as table.
  480. *
  481. * @param $iProfileId (optional) integer value with profile ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  482. * @param $aParams (optional) an array of additional params. It's not used for now.
  483. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  484. *
  485. * @see BxForumModule::serviceBrowseFavorite
  486. */
  487. /**
  488. * @ref bx_forum-browse_favorite "browse_favorite"
  489. */
  490. public function serviceBrowseFavorite ($iProfileId = 0, $aParams = array())
  491. {
  492. $CNF = &$this->_oConfig->CNF;
  493. $bEmptyMessage = false;
  494. if(isset($aParams['empty_message'])) {
  495. $bEmptyMessage = (bool)$aParams['empty_message'];
  496. unset($aParams['empty_message']);
  497. }
  498. $bAjaxPaginate = true;
  499. if(isset($aParams['ajax_paginate'])) {
  500. $bAjaxPaginate = (bool)$aParams['ajax_paginate'];
  501. unset($aParams['ajax_paginate']);
  502. }
  503. return $this->_serviceBrowseTable(array(
  504. 'type' => 'favorite',
  505. 'per_page' => (int)$this->_oDb->getParam('bx_forum_per_page_profile'),
  506. 'empty_message' => $bEmptyMessage,
  507. 'ajax_paginate' => $bAjaxPaginate
  508. ), false);
  509. }
  510. /**
  511. * @page service Service Calls
  512. * @section bx_forum Discussions
  513. * @subsection bx_forum-page_blocks Page Blocks
  514. * @subsubsection bx_forum-browse_category browse_category
  515. *
  516. * @code bx_srv('bx_forum', 'browse_category', [...]); @endcode
  517. *
  518. * Get page block with a list of items filter by some category and represented as table.
  519. *
  520. * @param $sUnitView (optional) string with unit view type.
  521. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  522. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  523. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  524. *
  525. * @see BxForumModule::serviceBrowseCategory
  526. */
  527. /**
  528. * @ref bx_forum-browse_category "browse_category"
  529. */
  530. public function serviceBrowseCategory($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true, $aParams = [])
  531. {
  532. if (bx_is_api()){
  533. return parent::serviceBrowseCategory($sUnitView, $bEmptyMessage, $bAjaxPaginate, []);
  534. }
  535. $sType = 'category';
  536. $iCategory = bx_process_input(bx_get('category'), BX_DATA_INT);
  537. $aCategory = $this->_oDb->getCategories(array('type' => 'by_category', 'category' => $iCategory));
  538. if(!empty($aCategory['visible_for_levels']) && !BxDolAcl::getInstance()->isMemberLevelInSet($aCategory['visible_for_levels']))
  539. return $bEmptyMessage ? MsgBox(_t('_sys_txt_access_denied')) : '';
  540. if($sUnitView != 'table') {
  541. $aParams = array_merge(['category' => $iCategory], $aParams);
  542. if($sUnitView)
  543. $aParams['unit_view'] = $sUnitView;
  544. return $this->_serviceBrowse($sType, $aParams, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  545. }
  546. return $this->_serviceBrowseTable(array(
  547. 'type' => $sType,
  548. 'where' => array('fld' => 'cat', 'val' => $iCategory, 'opr' => '='),
  549. 'empty_message' => $bEmptyMessage,
  550. 'ajax_paginate' => $bAjaxPaginate
  551. ), !isset($aParams['show_header']) || (bool)$aParams['show_header'] === true);
  552. }
  553. /**
  554. * @page service Service Calls
  555. * @section bx_forum Discussions
  556. * @subsection bx_forum-page_blocks Page Blocks
  557. * @subsubsection bx_forum-browse_keyword browse_keyword
  558. *
  559. * @code bx_srv('bx_forum', 'browse_keyword', [...]); @endcode
  560. *
  561. * Get page block with a list of items filter by some keyword and represented as table.
  562. *
  563. * @param $sUnitView (optional) string with unit view type.
  564. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  565. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  566. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  567. *
  568. * @see BxForumModule::serviceBrowseKeyword
  569. */
  570. /**
  571. * @ref bx_forum-browse_keyword "browse_keyword"
  572. */
  573. public function serviceBrowseKeyword($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true, $bShowHeader = false)
  574. {
  575. $sType = 'keyword';
  576. $sKeyword = bx_process_input(bx_get('keyword'));
  577. if($sUnitView != 'table')
  578. return $this->_serviceBrowse($sType, $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  579. return $this->_serviceBrowseTable(array(
  580. 'type' => $sType,
  581. 'where' => $this->_getSearchKeywordDescriptor('#' . $sKeyword),
  582. 'empty_message' => $bEmptyMessage,
  583. 'ajax_paginate' => $bAjaxPaginate
  584. ), $bShowHeader);
  585. }
  586. /**
  587. * @page service Service Calls
  588. * @section bx_forum Discussions
  589. * @subsection bx_forum-page_blocks Page Blocks
  590. * @subsubsection bx_forum-browse_search_results browse_search_results
  591. *
  592. * @code bx_srv('bx_forum', 'browse_search_results', [...]); @endcode
  593. *
  594. * Get page block with search results by Author(s), Category, Keyword represented as table.
  595. *
  596. * @param $sUnitView (optional) string with unit view type.
  597. * @param $bEmptyMessage (optional) boolean value determining whether an "Empty" message should be returned or not.
  598. * @param $bAjaxPaginate (optional) boolean value determining whether an Ajax based pagination should be used or not.
  599. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  600. *
  601. * @see BxForumModule::serviceBrowseSearchResults
  602. */
  603. /**
  604. * @ref bx_forum-browse_search_results "browse_search_results"
  605. */
  606. public function serviceBrowseSearchResults($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  607. {
  608. $sType = 'search';
  609. $aAuthors = bx_process_input(bx_get('author'));
  610. $iCategory = bx_process_input(bx_get('category'), BX_DATA_INT);
  611. $sKeyword = bx_process_input(bx_get('keyword'));
  612. $aCategory = $this->_oDb->getCategories(array('type' => 'by_category', 'category' => $iCategory));
  613. if(!empty($aCategory['visible_for_levels']) && !BxDolAcl::getInstance()->isMemberLevelInSet($aCategory['visible_for_levels']))
  614. return $bEmptyMessage ? MsgBox(_t('_sys_txt_access_denied')) : '';
  615. if($sUnitView != 'table')
  616. return $this->_serviceBrowse('', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  617. $aWhereGroupAnd = array('grp' => true, 'opr' => 'AND', 'cnds' => array());
  618. if(!empty($aAuthors) && is_array($aAuthors))
  619. $aWhereGroupAnd['cnds'][] = $this->_getSearchAuthorDescriptor($aAuthors);
  620. if(!empty($iCategory))
  621. $aWhereGroupAnd['cnds'][] = array('fld' => 'cat', 'val' => $iCategory, 'opr' => '=');
  622. if(!empty($sKeyword))
  623. $aWhereGroupAnd['cnds'][] = $this->_getSearchKeywordDescriptor($sKeyword);
  624. return $this->_serviceBrowseTable(array(
  625. 'type' => $sType,
  626. 'where' => $aWhereGroupAnd,
  627. 'empty_message' => $bEmptyMessage,
  628. 'ajax_paginate' => $bAjaxPaginate
  629. ), false);
  630. }
  631. /**
  632. * @page service Service Calls
  633. * @section bx_forum Discussions
  634. * @subsection bx_forum-other Other
  635. * @subsubsection bx_forum-get_discussions_num get_discussions_num
  636. *
  637. * @code bx_srv('bx_forum', 'get_discussions_num', [...]); @endcode
  638. *
  639. * Get number of discussions for some profile.
  640. *
  641. * @param $iProfileId (optional) profile to get discussions for, if omitted then currently logged in profile is used.
  642. * @return integer value with a number of discussions.
  643. *
  644. * @see BxForumModule::serviceGetDiscussionsNum
  645. */
  646. /**
  647. * @ref bx_forum-get_discussions_num "get_discussions_num"
  648. */
  649. public function serviceGetDiscussionsNum ($iProfileId = 0)
  650. {
  651. if (!$iProfileId)
  652. $iProfileId = bx_get_logged_profile_id();
  653. return $this->_oDb->getEntriesNumByAuthor((int)$iProfileId);
  654. }
  655. /**
  656. * @page service Service Calls
  657. * @section bx_forum Discussions
  658. * @subsection bx_forum-other Other
  659. * @subsubsection bx_forum-get_unreplied_discussions_num get_unreplied_discussions_num
  660. *
  661. * @code bx_srv('bx_forum', 'get_unreplied_discussions_num', [...]); @endcode
  662. *
  663. * Get number of unreplied discussions for some profile.
  664. *
  665. * @param $iProfileId (optional) profile to get unreplied discussions for, if omitted then currently logged is profile is used.
  666. * @return integer value with a number of discussions.
  667. *
  668. * @see BxForumModule::serviceGetUnrepliedDiscussionsNum
  669. */
  670. /**
  671. * @ref bx_forum-get_unreplied_discussions_num "get_unreplied_discussions_num"
  672. */
  673. public function serviceGetUnrepliedDiscussionsNum ($iProfileId = 0)
  674. {
  675. if (!$iProfileId)
  676. $iProfileId = bx_get_logged_profile_id();
  677. return $this->_oDb->getUnrepliedDiscussionsNum((int)$iProfileId);
  678. }
  679. /**
  680. *
  681. */
  682. /**
  683. * @page service Service Calls
  684. * @section bx_forum Discussions
  685. * @subsection bx_forum-other Other
  686. * @subsubsection bx_forum-trigger_comment_post trigger_comment_post
  687. *
  688. * @code bx_srv('bx_forum', 'trigger_comment_post', [...]); @endcode
  689. *
  690. * Update last comment time and author when new comment was added in the discussion.
  691. *
  692. * @param $iContentId integer value with content ID.
  693. * @param $iProfileId integer value with profile ID.
  694. * @param $iCommentId integer value with comment ID.
  695. * @param $iTimestamp (optional) date in UNIX Timestamp format, if omitted then current date is used.
  696. * @param $sCommentText (optional) string value with text of comment.
  697. * @return boolean value determining where the operation is successful or not.
  698. *
  699. * @see BxForumModule::serviceTriggerCommentPost
  700. */
  701. /**
  702. * @ref bx_forum-trigger_comment_post "trigger_comment_post"
  703. */
  704. public function serviceTriggerCommentPost ($iContentId, $iProfileId, $iCommentId, $iTimestamp = 0, $sCommentText = '')
  705. {
  706. $CNF = $this->_oConfig->CNF;
  707. $iContentId = (int)$iContentId;
  708. if(!$iContentId)
  709. return false;
  710. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  711. if(!$aContentInfo)
  712. return false;
  713. $oCmts = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContentId);
  714. if(!$oCmts)
  715. return false;
  716. if(!$iTimestamp)
  717. $iTimestamp = time();
  718. if(!$this->_oDb->updateLastCommentTimeProfile((int)$iContentId, (int)$iProfileId, $iCommentId, $iTimestamp))
  719. return false;
  720. // send notification to author
  721. if($iProfileId != $aContentInfo[$CNF['FIELD_AUTHOR']]) {
  722. $oProfile = BxDolProfile::getInstanceMagic($iProfileId);
  723. if($oProfile)
  724. sendMailTemplate('bx_forum_new_reply', 0, $aContentInfo[$CNF['FIELD_AUTHOR']], array(
  725. 'SenderDisplayName' => $oProfile->getDisplayName(),
  726. 'SenderUrl' => $oProfile->getUrl(),
  727. 'PageUrl' => $oCmts->getItemUrl($iCommentId),
  728. 'PageTitle' => $oCmts->getObjectTitle(),
  729. 'Message' => $sCommentText,
  730. ), BX_EMAIL_NOTIFY);
  731. }
  732. return true;
  733. }
  734. /**
  735. * @page service Service Calls
  736. * @section bx_forum Discussions
  737. * @subsection bx_forum-page_blocks Page Blocks
  738. * @subsubsection bx_forum-entity_author entity_author
  739. *
  740. * @code bx_srv('bx_forum', 'entity_author', [...]); @endcode
  741. *
  742. * Get page block with author.
  743. *
  744. * @param $iContentId (optional) content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  745. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  746. *
  747. * @see BxForumModule::serviceEntityAuthor
  748. */
  749. /**
  750. * @ref bx_forum-entity_author "entity_author"
  751. */
  752. public function serviceEntityAuthor ($iContentId = 0)
  753. {
  754. if (bx_is_api())
  755. return $this->_serviceTemplateFunc ('entryAuthor', $iContentId);
  756. return bx_srv('system', 'get_block_author', ['bx_forum', $iContentId], 'TemplServices');
  757. }
  758. /**
  759. * @page service Service Calls
  760. * @section bx_forum Discussions
  761. * @subsection bx_forum-page_blocks Page Blocks
  762. * @subsubsection bx_forum-entity_participants entity_participants
  763. *
  764. * @code bx_srv('bx_forum', 'entity_participants', [...]); @endcode
  765. *
  766. * Get page block with discussion's collaborators.
  767. *
  768. * @param $iContentId (optional) content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  769. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  770. *
  771. * @see BxForumModule::serviceEntityParticipants
  772. */
  773. /**
  774. * @ref bx_forum-entity_participants "entity_participants"
  775. */
  776. public function serviceEntityParticipants ($iContentId = 0)
  777. {
  778. if (!$iContentId)
  779. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  780. if (!$iContentId)
  781. return false;
  782. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  783. if (!$aContentInfo)
  784. return false;
  785. return $this->_oTemplate->entryParticipants ($aContentInfo, 5, 'right');
  786. }
  787. /**
  788. * @page service Service Calls
  789. * @section bx_forum Discussions
  790. * @subsection bx_forum-page_blocks Page Blocks
  791. * @subsubsection bx_forum-search search
  792. *
  793. * @code bx_srv('bx_forum', 'search', [...]); @endcode
  794. *
  795. * Get page block with search form.
  796. *
  797. * @return HTML string with block content to display on the site or false if something is wrong. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  798. *
  799. * @see BxForumModule::serviceSearch
  800. */
  801. /**
  802. * @ref bx_forum-search "search"
  803. */
  804. public function serviceSearch()
  805. {
  806. $CNF = $this->_oConfig->CNF;
  807. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_SEARCH'], $CNF['OBJECT_FORM_SEARCH_DISPLAY_FULL'], $this->_oTemplate);
  808. $oForm->initChecker();
  809. return $oForm->getCode();
  810. }
  811. public function checkAllowedSubscribe(&$aDataEntry, $isPerformAction = false)
  812. {
  813. $CNF = &$this->_oConfig->CNF;
  814. $sMsg = $this->checkAllowedView($aDataEntry);
  815. if($sMsg !== CHECK_ACTION_RESULT_ALLOWED)
  816. return $sMsg;
  817. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, $CNF['OBJECT_CONNECTION_SUBSCRIBERS'], false, false);
  818. }
  819. public function checkAllowedUnsubscribe(&$aDataEntry, $isPerformAction = false)
  820. {
  821. $CNF = &$this->_oConfig->CNF;
  822. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, $CNF['OBJECT_CONNECTION_SUBSCRIBERS'], false, true);
  823. }
  824. public function checkAllowedStickAnyEntry($aDataEntry, $isPerformAction = false)
  825. {
  826. $CNF = &$this->_oConfig->CNF;
  827. if((int)$aDataEntry[$CNF['FIELD_STICK']] != 0)
  828. return false;
  829. return $this->_checkAllowedAction('stick any entry', $aDataEntry, $isPerformAction);
  830. }
  831. public function checkAllowedUnstickAnyEntry($aDataEntry, $isPerformAction = false)
  832. {
  833. $CNF = $this->_oConfig->CNF;
  834. if((int)$aDataEntry[$CNF['FIELD_STICK']] != 1)
  835. return false;
  836. return $this->_checkAllowedAction('stick any entry', $aDataEntry, $isPerformAction);
  837. }
  838. public function checkAllowedResolveAnyEntry($aDataEntry, $isPerformAction = false)
  839. {
  840. $CNF = &$this->_oConfig->CNF;
  841. if((int)$aDataEntry[$CNF['FIELD_RESOLVABLE']] != 1 || (int)$aDataEntry[$CNF['FIELD_RESOLVE']] != 0)
  842. return false;
  843. if($aDataEntry[$CNF['FIELD_AUTHOR']] == bx_get_logged_profile_id())
  844. return CHECK_ACTION_RESULT_ALLOWED;
  845. return $this->_checkAllowedAction('resolve any entry', $aDataEntry, $isPerformAction);
  846. }
  847. public function checkAllowedUnresolveAnyEntry($aDataEntry, $isPerformAction = false)
  848. {
  849. $CNF = $this->_oConfig->CNF;
  850. if((int)$aDataEntry[$CNF['FIELD_RESOLVABLE']] != 1 || (int)$aDataEntry[$CNF['FIELD_RESOLVE']] != 1)
  851. return false;
  852. if($aDataEntry[$CNF['FIELD_AUTHOR']] == bx_get_logged_profile_id())
  853. return CHECK_ACTION_RESULT_ALLOWED;
  854. return $this->_checkAllowedAction('resolve any entry', $aDataEntry, $isPerformAction);
  855. }
  856. public function checkAllowedLockAnyEntry($aDataEntry, $isPerformAction = false)
  857. {
  858. $CNF = $this->_oConfig->CNF;
  859. if((int)$aDataEntry[$CNF['FIELD_LOCK']] != 0)
  860. return false;
  861. return $this->_checkAllowedAction('lock any entry', $aDataEntry, $isPerformAction);
  862. }
  863. public function checkAllowedUnlockAnyEntry($aDataEntry, $isPerformAction = false)
  864. {
  865. $CNF = $this->_oConfig->CNF;
  866. if((int)$aDataEntry[$CNF['FIELD_LOCK']] != 1)
  867. return false;
  868. return $this->_checkAllowedAction('lock any entry', $aDataEntry, $isPerformAction);
  869. }
  870. public function checkAllowedHideAnyEntry($aDataEntry, $isPerformAction = false)
  871. {
  872. $CNF = $this->_oConfig->CNF;
  873. if($aDataEntry[$CNF['FIELD_STATUS_ADMIN']] == 'hidden')
  874. return false;
  875. return $this->_checkAllowedAction('hide any entry', $aDataEntry, $isPerformAction);
  876. }
  877. public function checkAllowedUnhideAnyEntry($aDataEntry, $isPerformAction = false)
  878. {
  879. $CNF = &$this->_oConfig->CNF;
  880. if($aDataEntry[$CNF['FIELD_STATUS_ADMIN']] != 'hidden')
  881. return false;
  882. return $this->_checkAllowedAction('hide any entry', $aDataEntry, $isPerformAction);
  883. }
  884. protected function _checkAllowedConnect (&$aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult)
  885. {
  886. $CNF = &$this->_oConfig->CNF;
  887. if(!$this->_iProfileId)
  888. return _t('_sys_txt_access_denied');
  889. $isConnected = BxDolConnection::getObjectInstance($sObjConnection)->isConnected($this->_iProfileId, $aDataEntry[$CNF['FIELD_ID']], $isMutual);
  890. if($isInvertResult)
  891. $isConnected = !$isConnected;
  892. return $isConnected ? _t('_sys_txt_access_denied') : CHECK_ACTION_RESULT_ALLOWED;
  893. }
  894. /**
  895. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  896. */
  897. protected function _checkAllowedAction($sAction, $aDataEntry, $isPerformAction = false)
  898. {
  899. if($this->_isModerator($isPerformAction))
  900. return CHECK_ACTION_RESULT_ALLOWED;
  901. $aCheck = checkActionModule($this->_iProfileId, $sAction, $this->getName(), $isPerformAction);
  902. if($aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  903. return CHECK_ACTION_RESULT_ALLOWED;
  904. return _t('_sys_txt_access_denied');
  905. }
  906. protected function _serviceBrowseTable($aParams, $isDisplayHeader = true)
  907. {
  908. $sGrid = $this->_oConfig->CNF['OBJECT_GRID'];
  909. if(!empty($aParams['grid'])) {
  910. $sGrid = $aParams['grid'];
  911. unset($aParams['grid']);
  912. }
  913. $oGrid = BxDolGrid::getObjectInstance($sGrid);
  914. if(!$oGrid)
  915. return false;
  916. $oGrid->setBrowseParams($aParams);
  917. $this->_oTemplate->addJsTranslation(array('_sys_grid_search'));
  918. $this->_oTemplate->addCss(array('grid_tools.css'));
  919. return $oGrid->getCode($isDisplayHeader);
  920. }
  921. protected function _getSearchAuthorDescriptor($aAutor)
  922. {
  923. return array('grp' => true, 'opr' => 'OR', 'cnds' => array(
  924. array('fld' => 'author', 'val' => $aAutor, 'opr' => 'IN'),
  925. array('fld' => 'author_comment', 'val' => $aAutor, 'opr' => 'IN'),
  926. ));
  927. }
  928. protected function _getSearchKeywordDescriptor($sKeyword)
  929. {
  930. return array('grp' => true, 'opr' => 'OR', 'cnds' => array(
  931. array('fld' => 'title', 'val' => $sKeyword, 'opr' => 'LIKE'),
  932. array('fld' => 'text', 'val' => $sKeyword, 'opr' => 'LIKE'),
  933. array('fld' => 'text_comments', 'val' => $sKeyword, 'opr' => 'LIKE')
  934. ));
  935. }
  936. }
  937. /** @} */