BxForumModule.php 43 KB

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