BxForumModule.php 42 KB

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