BxForumModule.php 42 KB

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