BxNtfsModule.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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 Notifications Notifications
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxBaseModNotificationsModule');
  12. define('BX_NTFS_TYPE_OBJECT_OWNER_AND_CONNECTIONS', 'obj_own_and_con');
  13. define('BX_NTFS_TYPE_DEFAULT', BX_NTFS_TYPE_OBJECT_OWNER_AND_CONNECTIONS);
  14. /**
  15. * STYPE - Setting Type:
  16. * 1. personal - related to you;
  17. * 2. follow_member - related to members you follow;
  18. * 3. follow_context - related to contexts you follow;
  19. * 4. other - others.
  20. */
  21. define('BX_NTFS_STYPE_PERSONAL', 'personal');
  22. define('BX_NTFS_STYPE_FOLLOW_MEMBER', 'follow_member');
  23. define('BX_NTFS_STYPE_FOLLOW_CONTEXT', 'follow_context');
  24. define('BX_NTFS_STYPE_OTHER', 'other');
  25. /**
  26. * SLTMODE - Silent mode:
  27. * It is needed for alert sending module to tell that the alert should be ignored
  28. * with Notifications module completely or partially. Available values:
  29. * 1. disabled (global, value = 0) - all notifications are available;
  30. * 2. absolute (global, value = 1) - alert isn't registered which means that there is no notifications at all;
  31. * 3. absolute (for Notifications only, value = 11) - the same as global absolute.
  32. * 3. on-site only (value = 12) - alert is registered. It means that on-site notification is available while the others are disabled.
  33. * 4. on-site + email (value = 13) - alert is registered (on-site) and notification via 'email' is enabled.
  34. * 5. on-site + push (value = 14) - alert is registered (on-site) and notification via 'push' is enabled.
  35. *
  36. * @see BxNtfsResponse::response - 'silent_mode' parameter in Alerts Extras array.
  37. */
  38. define('BX_NTFS_SLTMODE_ABSOLUTE', 11);
  39. define('BX_NTFS_SLTMODE_SITE', 12);
  40. define('BX_NTFS_SLTMODE_SITE_EMAIL', 13);
  41. define('BX_NTFS_SLTMODE_SITE_PUSH', 14);
  42. class BxNtfsModule extends BxBaseModNotificationsModule
  43. {
  44. /**
  45. * Constructor
  46. */
  47. function __construct($aModule)
  48. {
  49. parent::__construct($aModule);
  50. $this->_iOwnerId = $this->getUserId();
  51. }
  52. /**
  53. * ACTION METHODS
  54. */
  55. function actionGetPosts()
  56. {
  57. $aParams = $this->_prepareParamsGet();
  58. if(empty($aParams['owner_id']) || (int)$aParams['owner_id'] != $this->_iOwnerId)
  59. return echoJson([]);
  60. echoJson([
  61. 'events' => $this->_oTemplate->getPosts($aParams)
  62. ]);
  63. }
  64. /**
  65. * SERVICE METHODS
  66. */
  67. public function serviceGetSafeServices()
  68. {
  69. return [
  70. 'GetBlockView' => '',
  71. ];
  72. }
  73. /**
  74. * @page service Service Calls
  75. * @section bx_notifications Invitations
  76. * @subsection bx_notifications-other Other
  77. * @subsubsection bx_notifications-get_include get_include
  78. *
  79. * @code bx_srv('bx_notifications', 'get_include', [...]); @endcode
  80. *
  81. * Get all necessary CSS and JS files to include in a page.
  82. *
  83. * @return string with all necessary CSS and JS files.
  84. *
  85. * @see BxInvModule::serviceGetInclude
  86. */
  87. /**
  88. * @ref bx_notifications-get_include "get_include"
  89. */
  90. public function serviceGetInclude($bIncludeCss = true, $mixedIncludeJs = false)
  91. {
  92. return $this->_oTemplate->getInclude($bIncludeCss, $mixedIncludeJs);
  93. }
  94. /**
  95. * @page service Service Calls
  96. * @section bx_notifications Notifications
  97. * @subsection bx_notifications-page_blocks Page Blocks
  98. * @subsubsection bx_notifications-get_block_settings get_block_settings
  99. *
  100. * @code bx_srv('bx_notifications', 'get_block_settings', [...]); @endcode
  101. *
  102. * Get Settings block for a separate page.
  103. *
  104. * @return a string with block content to display on the site. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  105. *
  106. * @see BxNtfsModule::serviceGetBlockSettings
  107. */
  108. /**
  109. * @ref bx_notifications-get_block_settings "get_block_settings"
  110. */
  111. public function serviceGetBlockSettings($sDeliveryType = '', $aParams = array())
  112. {
  113. if(!isLogged())
  114. return '';
  115. if(empty($sDeliveryType) && bx_get('delivery') !== false)
  116. $sDeliveryType = bx_process_input(bx_get('delivery'));
  117. if(empty($sDeliveryType))
  118. $sDeliveryType = BX_BASE_MOD_NTFS_DTYPE_SITE;
  119. $iUserId = bx_get_logged_profile_id();
  120. if(!empty($aParams['user_id']))
  121. $iUserId = (int)$aParams['user_id'];
  122. else
  123. $aParams['user_id'] = $iUserId;
  124. $this->_oDb->initSettingUser($iUserId);
  125. return array(
  126. 'content' => $this->getBlockSettings($sDeliveryType, $aParams),
  127. );
  128. }
  129. /**
  130. * @page service Service Calls
  131. * @section bx_notifications Notifications
  132. * @subsection bx_notifications-page_blocks Page Blocks
  133. * @subsubsection bx_notifications-get_block_view get_block_view
  134. *
  135. * @code bx_srv('bx_notifications', 'get_block_view', [...]); @endcode
  136. *
  137. * Get View block for a separate page. Will return a block with "Empty" message if nothing found.
  138. *
  139. * @return an array describing a block to display on the site. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  140. *
  141. * @see BxNtfsModule::serviceGetBlockView
  142. */
  143. /**
  144. * @ref bx_notifications-get_block_view "get_block_view"
  145. */
  146. public function serviceGetBlockView($sType = '', $iStart = -1, $iPerPage = -1, $aModules = array())
  147. {
  148. $aBrowseTypes = array(BX_NTFS_TYPE_OBJECT_OWNER_AND_CONNECTIONS, BX_BASE_MOD_NTFS_TYPE_CONNECTIONS, BX_BASE_MOD_NTFS_TYPE_OBJECT_OWNER);
  149. if(empty($sType)) {
  150. $mixedType = bx_get('type');
  151. if($mixedType !== false && in_array($mixedType, $aBrowseTypes))
  152. $sType = $mixedType;
  153. if(empty($sType))
  154. $sType = BX_NTFS_TYPE_DEFAULT;
  155. }
  156. $iOwnerId = $this->getUserId();
  157. if(!$iOwnerId)
  158. return array('content' => MsgBox(_t('_bx_ntfs_txt_msg_no_results')));
  159. $aParams = $this->_prepareParams($sType, $iOwnerId, $iStart, $iPerPage, $aModules);
  160. $sContent = $this->_oTemplate->getViewBlock($aParams);
  161. $aParams['browse'] = 'first';
  162. $aEvent = $this->_oDb->getEvents($aParams);
  163. if(!empty($aEvent))
  164. $this->_oDb->markAsRead($iOwnerId, $aEvent['id']);
  165. $sModule = $this->_oConfig->getName();
  166. $sJsObject = $this->_oConfig->getJsObject('view');
  167. return array('content' => $sContent);
  168. }
  169. /**
  170. * @page service Service Calls
  171. * @section bx_notifications Notifications
  172. * @subsection bx_notifications-browsing Browsing
  173. * @subsubsection bx_notifications-get_event_by_id get_event_by_id
  174. *
  175. * @code bx_srv('bx_notifications', 'get_event_by_id', [...]); @endcode
  176. *
  177. * Get event's data by event ID.
  178. *
  179. * @return an array with event's data.
  180. *
  181. * @see BxNtfsModule::serviceGetEventById
  182. */
  183. /**
  184. * @ref bx_notifications-get_event_by_id "get_event_by_id"
  185. */
  186. public function serviceGetEventById($iId)
  187. {
  188. $aParams = array(
  189. 'browse' => 'id',
  190. 'value' => $iId,
  191. );
  192. return $this->_oDb->getEvents($aParams);
  193. }
  194. /**
  195. * @page service Service Calls
  196. * @section bx_notifications Notifications
  197. * @subsection bx_notifications-other Other
  198. * @subsubsection bx_notifications-get_notifications get_notifications
  199. *
  200. * @code bx_srv('bx_notifications', 'get_notifications', [...]); @endcode
  201. *
  202. * Get notifications by params.
  203. *
  204. * @return array with notifications.
  205. *
  206. * @see BxNtfsModule::serviceGetNotifications
  207. */
  208. /**
  209. * @ref bx_notifications-get_notifications "get_notifications"
  210. */
  211. public function serviceGetNotifications($iOwnerId = 0, $aBrowseParams = array())
  212. {
  213. if(!$iOwnerId)
  214. $iOwnerId = $this->getUserId();
  215. if(!$iOwnerId)
  216. return 0;
  217. $aParams = $this->_prepareParams(BX_NTFS_TYPE_DEFAULT, $iOwnerId);
  218. if(!empty($aBrowseParams) && is_array($aBrowseParams))
  219. $aParams = array_merge($aParams, $aBrowseParams);
  220. $aEvents = $this->_oDb->getEvents($aParams);
  221. if($this->_oConfig->isEventsGrouped())
  222. $this->groupEvents($aEvents);
  223. // returns parsed content for React Jot
  224. if (!is_array($aBrowseParams) && $aBrowseParams === 'return_parsed_content')
  225. foreach ($aEvents as &$aContent)
  226. $this->_oTemplate->getPost($aContent, array('return_parsed_content'));
  227. return $aEvents;
  228. }
  229. /**
  230. * @page service Service Calls
  231. * @section bx_notifications Notifications
  232. * @subsection bx_notifications-other Other
  233. * @subsubsection bx_notifications-get_unread_notifications get_unread_notifications
  234. *
  235. * @code bx_srv('bx_notifications', 'get_unread_notifications', [...]); @endcode
  236. *
  237. * Get unread notifications.
  238. *
  239. * @return array with unread notifications.
  240. *
  241. * @see BxNtfsModule::serviceGetUnreadNotifications
  242. */
  243. /**
  244. * @ref bx_notifications-get_unread_notifications "get_unread_notifications"
  245. */
  246. public function serviceGetUnreadNotifications($iOwnerId = 0)
  247. {
  248. return $this->serviceGetNotifications($iOwnerId, array('new' => 1));
  249. }
  250. /**
  251. * @page service Service Calls
  252. * @section bx_notifications Notifications
  253. * @subsection bx_notifications-other Other
  254. * @subsubsection bx_notifications-get_unread_notifications_num get_unread_notifications_num
  255. *
  256. * @code bx_srv('bx_notifications', 'get_unread_notifications_num', [...]); @endcode
  257. *
  258. * Get number of unread notifications.
  259. *
  260. * @return integer value with number of unread notifications.
  261. *
  262. * @see BxNtfsModule::serviceGetUnreadNotificationsNum
  263. */
  264. /**
  265. * @ref bx_notifications-get_unread_notifications_num "get_unread_notifications_num"
  266. */
  267. public function serviceGetUnreadNotificationsNum($iOwnerId = 0)
  268. {
  269. if(!$iOwnerId)
  270. $iOwnerId = $this->getUserId();
  271. if(!$iOwnerId)
  272. return 0;
  273. $aParams = $this->_prepareParams(BX_NTFS_TYPE_DEFAULT, $iOwnerId, 0, PHP_INT_MAX);
  274. $sParamCheck = 'perform_privacy_check';
  275. $sParamCheckFor = 'perform_privacy_check_for';
  276. $iEvents = 0;
  277. if($this->_oConfig->isEventsGrouped()) {
  278. $aEvents = $this->_oDb->getEvents($aParams);
  279. $this->groupEvents($aEvents);
  280. $iCount = 0;
  281. $iLastRead = $this->_oDb->getLastRead((int)$aParams['owner_id']);
  282. foreach($aEvents as $aEvent)
  283. if($aEvent['id'] > $iLastRead)
  284. $iCount++;
  285. $aEvents = array_slice($aEvents, 0, $iCount);
  286. }
  287. else {
  288. $aParams = array_merge($aParams, [
  289. 'new' => 1,
  290. ]);
  291. $aEvents = $this->_oDb->getEvents($aParams);
  292. }
  293. foreach($aEvents as $aEvent) {
  294. if(isset($aBrowseParams[$sParamCheck]) && $aBrowseParams[$sParamCheck] !== true)
  295. continue;
  296. $iViewerId = !empty($aBrowseParams[$sParamCheckFor]) ? (int)$aBrowseParams[$sParamCheckFor] : 0;
  297. $oPrivacyInt = BxDolPrivacy::getObjectInstance($this->_oConfig->getObject('privacy_view'));
  298. if(!$oPrivacyInt->check($aEvent['id'], $iViewerId))
  299. continue;
  300. $oPrivacyExt = $this->_oConfig->getPrivacyObject($aEvent['type'] . '_' . $aEvent['action']);
  301. if($oPrivacyExt !== false && !$oPrivacyExt->check($aEvent['id'], $iViewerId))
  302. continue;
  303. $sSrvModule = $this->_oConfig->getContentModule($aEvent);
  304. $sSrvMethod = 'check_allowed_with_content_for_profile';
  305. if($sSrvModule && BxDolRequest::serviceExists($sSrvModule, $sSrvMethod) && BxDolService::call($sSrvModule, $sSrvMethod, array('view', $this->_oConfig->getContentObjectId($aEvent), $iViewerId)) !== CHECK_ACTION_RESULT_ALLOWED)
  306. continue;
  307. $iEvents++;
  308. }
  309. return $iEvents;
  310. }
  311. /**
  312. * @page service Service Calls
  313. * @section bx_notifications Notifications
  314. * @subsection bx_notifications-other Other
  315. * @subsubsection bx_notifications-get_live_updates get_live_updates
  316. *
  317. * @code bx_srv('bx_notifications', 'get_live_updates', [...]); @endcode
  318. *
  319. * Get data for Live Updates system.
  320. *
  321. * @return an array with special format.
  322. *
  323. * @see BxNtfsModule::serviceGetLiveUpdates
  324. */
  325. /**
  326. * @ref bx_notifications-get_live_updates "get_live_updates"
  327. */
  328. public function serviceGetLiveUpdates($aMenuItemParent, $aMenuItemChild, $iCount = 0)
  329. {
  330. $iOwnerId = $this->getUserId();
  331. $iCountNew = $this->serviceGetUnreadNotificationsNum($iOwnerId);
  332. if($iCountNew == $iCount)
  333. return false;
  334. return array(
  335. 'count' => $iCountNew, // required
  336. 'method' => 'bx_menu_show_live_update(oData)', // required
  337. 'data' => array(
  338. 'code' => BxDolTemplate::getInstance()->parseHtmlByTemplateName('menu_item_addon', array(
  339. 'content' => '{count}'
  340. )),
  341. 'mi_parent' => $aMenuItemParent,
  342. 'mi_child' => $aMenuItemChild
  343. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  344. );
  345. }
  346. /*
  347. * COMMON METHODS
  348. */
  349. public function getBlockSettings($sDeliveryType, $aParams = array())
  350. {
  351. return $this->_oTemplate->getSettingsBlock($sDeliveryType, $aParams);
  352. }
  353. public function setSubmenu($sSelected)
  354. {
  355. $oSubmenuSystem = BxDolMenu::getObjectInstance('sys_site_submenu');
  356. if(!$oSubmenuSystem)
  357. return;
  358. $CNF = &$this->_oConfig->CNF;
  359. $oSubmenuSystem->setObjectSubmenu($CNF['OBJECT_MENU_SUBMENU'], array (
  360. 'title' => _t('_bx_ntfs'),
  361. 'link' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']),
  362. 'icon' => '',
  363. ));
  364. $oSubmenuModule = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SUBMENU']);
  365. if($oSubmenuModule)
  366. $oSubmenuModule->setSelected($this->_oConfig->getName(), $sSelected);
  367. }
  368. public function onPost($iId)
  369. {
  370. //--- Event -> Post for Alerts Engine ---//
  371. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'post', $iId);
  372. $oAlert->alert();
  373. //--- Event -> Post for Alerts Engine ---//
  374. }
  375. public function enableSettingsLike($iId, $bValue, $bAdministration = false)
  376. {
  377. $aSetting = $this->_oDb->getSetting(array(
  378. 'by' => $bAdministration ? 'id' : 'tsu_id',
  379. 'id' => (int)$iId
  380. ));
  381. if(empty($aSetting) || !is_array($aSetting))
  382. return false;
  383. $aSettingsIds = $this->_oDb->getSetting(array(
  384. 'by' => 'group_type_delivery',
  385. 'group' => $aSetting['group'],
  386. 'delivery' => $aSetting['delivery'],
  387. 'type' => $aSetting['type'],
  388. 'active' => !$bAdministration
  389. ));
  390. if(empty($aSettingsIds) || !is_array($aSettingsIds))
  391. return false;
  392. $iUserId = bx_get_logged_profile_id();
  393. $mixedResult = false;
  394. if($bAdministration)
  395. $mixedResult = $this->_oDb->activateSettingById($bValue, $aSettingsIds);
  396. else
  397. $mixedResult = $this->_oDb->activateSettingByIdUser($bValue, $iUserId, $aSettingsIds);
  398. return $mixedResult;
  399. }
  400. public function _changeSettingsValueLike($iId, $sField, $mixedValue, $bAdministration = false)
  401. {
  402. $aSetting = $this->_oDb->getSetting(array(
  403. 'by' => $bAdministration ? 'id' : 'tsu_id',
  404. 'id' => (int)$iId
  405. ));
  406. if(empty($aSetting) || !is_array($aSetting))
  407. return false;
  408. $aSettingsIds = $this->_oDb->getSetting(array(
  409. 'by' => 'group_type_delivery',
  410. 'group' => $aSetting['group'],
  411. 'delivery' => $aSetting['delivery'],
  412. 'type' => $aSetting['type'],
  413. 'active' => !$bAdministration
  414. ));
  415. if(empty($aSettingsIds) || !is_array($aSettingsIds))
  416. return false;
  417. $iUserId = bx_get_logged_profile_id();
  418. $mixedResult = false;
  419. if($bAdministration)
  420. $mixedResult = $this->_oDb->changeSettingById($sField, $mixedValue, $aSettingsIds);
  421. else
  422. $mixedResult = $this->_oDb->changeSettingByIdUser($sField, $mixedValue, $iUserId, $aSettingsIds);
  423. return $mixedResult;
  424. }
  425. public function sendNotificationEmail($iProfile, $aNotification)
  426. {
  427. if(!$iProfile)
  428. return false;
  429. $aSettings = &$aNotification['settings'];
  430. $sTemplate = !empty($aSettings['template']) ? $aSettings['template'] : 'bx_notifications_new_event';
  431. $aTemplateMarkers = array('content' => $aNotification['content']);
  432. if(!empty($aSettings['markers']) && is_array($aSettings['markers']))
  433. $aTemplateMarkers = array_merge($aTemplateMarkers, $aSettings['markers']);
  434. $aTemplate = null;
  435. bx_alert($this->_aModule['name'], 'before_parse_email_template', 0, 0, array('profile_id' => $iProfile, 'template' => $sTemplate, 'markers' => $aTemplateMarkers, 'notification' => $aNotification, 'override_result' => &$aTemplate));
  436. if(is_null($aTemplate))
  437. $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate($sTemplate, $aTemplateMarkers, 0, $iProfile);
  438. if(!$aTemplate)
  439. return false;
  440. $sEmail = BxDolProfileQuery::getInstance()->getEmailById($iProfile);
  441. $sSubject = !empty($aSettings['subject']) ? $aSettings['subject'] : $aTemplate['Subject'];
  442. return sendMail($sEmail, $sSubject, $aTemplate['Body'], 0, array(), BX_EMAIL_NOTIFY, 'html', false, array(), true);
  443. }
  444. public function sendNotificationPush($iProfile, $aNotification)
  445. {
  446. if(!$iProfile)
  447. return false;
  448. $aContent = &$aNotification['content'];
  449. $aSettings = &$aNotification['settings'];
  450. $sSubject = !empty($aSettings['subject']) ? $aSettings['subject'] : _t('_bx_ntfs_push_new_event_subject', getParam('site_title'));
  451. bx_alert($this->_aModule['name'], 'before_send_notification_push', 0, 0, array('profile_id' => $iProfile, 'content' => &$aContent, 'setting' => &$aSettings, 'subject' => &$sSubject));
  452. return BxDolPush::getInstance()->send($iProfile, array(
  453. 'contents' => array(
  454. 'en' => $aContent['message']
  455. ),
  456. 'headings' => array(
  457. 'en' => $sSubject
  458. ),
  459. 'url' => $aContent['url'],
  460. 'icon' => $aContent['icon']
  461. ), true);
  462. }
  463. public function groupEvents(&$aEvents)
  464. {
  465. //--- Check for Visual Grouping
  466. $aGroups = [];
  467. foreach($aEvents as $iIndex => $aEvent) {
  468. if(empty($aEvent['source']))
  469. continue;
  470. $sSource = $aEvent['source'];
  471. if(!isset($aGroups[$sSource]))
  472. $aGroups[$sSource] = [];
  473. $aGroups[$sSource][$iIndex] = $aEvent['priority'];
  474. }
  475. //--- Perform Visual Grouping
  476. foreach($aGroups as $sSource => $aGroup) {
  477. if(!is_array($aGroup) || count($aGroup) < 2)
  478. continue;
  479. arsort($aGroup);
  480. $iPriorityMax = reset($aGroup);
  481. foreach($aGroup as $iIndex => $iPriority)
  482. if($iPriority != $iPriorityMax)
  483. unset($aEvents[$iIndex]);
  484. }
  485. }
  486. /*
  487. * INTERNAL METHODS
  488. */
  489. protected function _prepareParams($sType = '', $iOwnerId = 0, $iStart = -1, $iPerPage = -1, $aModules = array())
  490. {
  491. $aParams = array();
  492. $aParams['browse'] = 'list';
  493. $aParams['type'] = !empty($sType) ? $sType : BX_NTFS_TYPE_DEFAULT;
  494. $aParams['owner_id'] = (int)$iOwnerId != 0 ? $iOwnerId : $this->getUserId();
  495. $aParams['start'] = (int)$iStart > 0 ? $iStart : 0;
  496. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage();
  497. $aParams['modules'] = is_array($aModules) && !empty($aModules) ? $aModules : array();
  498. $aParams['last_read'] = $this->_oDb->getLastRead($aParams['owner_id']);
  499. $aParams['active'] = 1;
  500. return $aParams;
  501. }
  502. protected function _prepareParamsGet()
  503. {
  504. $aParams = array();
  505. $aParams['browse'] = 'list';
  506. $sType = bx_get('type');
  507. $aParams['type'] = $sType !== false ? bx_process_input($sType, BX_DATA_TEXT) : BX_NTFS_TYPE_DEFAULT;
  508. $aParams['owner_id'] = $sType !== false ? bx_process_input(bx_get('owner_id'), BX_DATA_INT) : $this->getUserId();
  509. $iStart = bx_get('start');
  510. $aParams['start'] = $iStart !== false ? bx_process_input($iStart, BX_DATA_INT) : 0;
  511. $iPerPage = bx_get('per_page');
  512. $aParams['per_page'] = $iPerPage !== false ? bx_process_input($iPerPage, BX_DATA_INT) : $this->_oConfig->getPerPage();
  513. $aModules = bx_get('modules');
  514. $aParams['modules'] = $aModules !== false ? bx_process_input($aModules, BX_DATA_TEXT) : array();
  515. $aParams['active'] = 1;
  516. return $aParams;
  517. }
  518. }
  519. /** @} */