BxTimelineModule.php 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup Timeline Timeline
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolAcl');
  12. bx_import('BxBaseModNotificationsModule');
  13. define('BX_TIMELINE_TYPE_ITEM', 'view_item');
  14. define('BX_TIMELINE_TYPE_DEFAULT', BX_BASE_MOD_NTFS_TYPE_OWNER);
  15. define('BX_TIMELINE_FILTER_ALL', 'all');
  16. define('BX_TIMELINE_FILTER_OWNER', 'owner');
  17. define('BX_TIMELINE_FILTER_OTHER', 'other');
  18. define('BX_TIMELINE_PARSE_TYPE_POST', 'post');
  19. define('BX_TIMELINE_PARSE_TYPE_SHARE', 'share');
  20. define('BX_TIMELINE_PARSE_TYPE_DEFAULT', BX_TIMELINE_PARSE_TYPE_POST);
  21. define('BX_TIMELINE_MEDIA_PHOTO', 'photo');
  22. define('BX_TIMELINE_MEDIA_VIDEO', 'video');
  23. class BxTimelineModule extends BxBaseModNotificationsModule
  24. {
  25. protected $_sJsPostObject;
  26. protected $_sJsViewObject;
  27. protected $_aPostElements;
  28. protected $_sJsOutlineObject;
  29. protected $_sDividerTemplate;
  30. protected $_sBalloonTemplate;
  31. protected $_sCmtPostTemplate;
  32. protected $_sCmtViewTemplate;
  33. protected $_sCmtTemplate;
  34. /**
  35. * Constructor
  36. */
  37. function __construct($aModule)
  38. {
  39. parent::__construct($aModule);
  40. }
  41. /**
  42. * ACTION METHODS
  43. */
  44. public function actionPost()
  45. {
  46. $sType = bx_process_input($_POST['type']);
  47. $sMethod = 'getForm' . ucfirst($sType);
  48. if(!method_exists($this, $sMethod)) {
  49. echoJson(array());
  50. return;
  51. }
  52. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  53. $mixedAllowed = $this->isAllowedPost(true);
  54. if($mixedAllowed !== true) {
  55. echoJson(array('msg' => strip_tags($mixedAllowed)));
  56. return;
  57. }
  58. $aResult = $this->$sMethod();
  59. echoJson($aResult);
  60. }
  61. function actionDelete()
  62. {
  63. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  64. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  65. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  66. $mixedAllowed = $this->isAllowedDelete($aEvent, true);
  67. if($mixedAllowed !== true) {
  68. echoJson(array('code' => 1, 'msg' => strip_tags($mixedAllowed)));
  69. return;
  70. }
  71. if(!$this->deleteEvent($aEvent))
  72. echoJson(array('code' => 2));
  73. else
  74. echoJson(array('code' => 0, 'id' => $iId));
  75. }
  76. public function actionShare()
  77. {
  78. $iAuthorId = $this->getUserId();
  79. $iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  80. $aContent = array(
  81. 'type' => bx_process_input(bx_get('type'), BX_DATA_TEXT),
  82. 'action' => bx_process_input(bx_get('action'), BX_DATA_TEXT),
  83. 'object_id' => bx_process_input(bx_get('object_id'), BX_DATA_INT),
  84. );
  85. $aShared = $this->_oDb->getShared($aContent['type'], $aContent['action'], $aContent['object_id']);
  86. if(empty($aShared) || !is_array($aShared)) {
  87. echoJson(array('code' => 1, 'msg' => _t('_bx_timeline_txt_err_cannot_share')));
  88. return;
  89. }
  90. $mixedAllowed = $this->isAllowedShare($aShared, true);
  91. if($mixedAllowed !== true) {
  92. echoJson(array('code' => 2, 'msg' => strip_tags($mixedAllowed)));
  93. return;
  94. }
  95. $bShared = $this->_oDb->isShared($aShared['id'], $iOwnerId, $iAuthorId);
  96. if($bShared) {
  97. echoJson(array('code' => 3, 'msg' => _t('_bx_timeline_txt_err_already_shared')));
  98. return;
  99. }
  100. $iId = $this->_oDb->insertEvent(array(
  101. 'owner_id' => $iOwnerId,
  102. 'type' => $this->_oConfig->getPrefix('common_post') . 'share',
  103. 'action' => '',
  104. 'object_id' => $iAuthorId,
  105. 'object_privacy_view' => $this->_oConfig->getPrivacyViewDefault('object'),
  106. 'content' => serialize($aContent),
  107. 'title' => '',
  108. 'description' => ''
  109. ));
  110. if(empty($iId)) {
  111. echoJson(array('code' => 4, 'msg' => _t('_bx_timeline_txt_err_cannot_share')));
  112. return;
  113. }
  114. $this->onShare($iId, $aShared);
  115. $aShared = $this->_oDb->getShared($aContent['type'], $aContent['action'], $aContent['object_id']);
  116. $sCounter = $this->_oTemplate->getShareCounter($aShared);
  117. echoJson(array(
  118. 'code' => 0,
  119. 'msg' => _t('_bx_timeline_txt_msg_success_share'),
  120. 'count' => $aShared['shares'],
  121. 'counter' => $sCounter,
  122. 'disabled' => !$bShared
  123. ));
  124. }
  125. function actionGetPost()
  126. {
  127. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  128. $iEvent = bx_process_input(bx_get('id'), BX_DATA_INT);
  129. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iEvent));
  130. echoJson(array('item' => $this->_oTemplate->getPost($aEvent, array('type' => 'owner', 'owner_id' => $this->_iOwnerId, 'dynamic_mode' => true))));
  131. }
  132. function actionGetPosts()
  133. {
  134. $aParams = $this->_prepareParamsGet();
  135. list($sItems, $sLoadMore, $sBack) = $this->_oTemplate->getPosts($aParams);
  136. echoJson(array('items' => $sItems, 'load_more' => $sLoadMore, 'back' => $sBack));
  137. }
  138. public function actionGetPostForm($sType)
  139. {
  140. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  141. $sMethod = 'getForm' . ucfirst($sType);
  142. if(!method_exists($this, $sMethod)) {
  143. echoJson(array());
  144. return;
  145. }
  146. $aResult = $this->$sMethod();
  147. echoJson($aResult);
  148. }
  149. public function actionGetComments()
  150. {
  151. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  152. $sSystem = bx_process_input(bx_get('system'), BX_DATA_TEXT);
  153. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  154. $sComments = $this->_oTemplate->getComments($sSystem, $iId);
  155. echoJson(array('content' => $sComments));
  156. }
  157. public function actionAddAttachLink()
  158. {
  159. $aResult = $this->getFormAttachLink();
  160. echoJson($aResult);
  161. }
  162. public function actionDeleteAttachLink()
  163. {
  164. $iUserId = $this->getUserId();
  165. $iLinkId = bx_process_input(bx_get('id'), BX_DATA_INT);
  166. if(empty($iLinkId)) {
  167. echoJson(array());
  168. return;
  169. }
  170. $aLink = $this->_oDb->getUnusedLinks($iUserId, $iLinkId);
  171. if(empty($aLink) || !is_array($aLink)) {
  172. echoJson(array());
  173. return;
  174. }
  175. if(!empty($aLink['media_id']))
  176. BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'))->deleteFile($aLink['media_id']);
  177. $aResult = array();
  178. if($this->_oDb->deleteUnusedLinks($iUserId, $iLinkId))
  179. $aResult = array('code' => 0);
  180. else
  181. $aResult = array('code' => 1, 'msg' => _t('_bx_timeline_form_post_input_link_err_delete'));
  182. echoJson($aResult);
  183. }
  184. public function actionGetAttachLinkForm()
  185. {
  186. echo $this->_oTemplate->getAttachLinkForm();
  187. }
  188. public function actionGetSharedBy()
  189. {
  190. $iSharedId = bx_process_input(bx_get('id'), BX_DATA_INT);
  191. echo $this->_oTemplate->getSharedBy($iSharedId);
  192. }
  193. function actionRss($iOwnerId)
  194. {
  195. list($sUserName) = $this->getUserInfo($iOwnerId);
  196. $sRssCaption = _t('_bx_timeline_txt_rss_caption', $sUserName);
  197. $sRssLink = $this->_oConfig->getViewUrl($iOwnerId);
  198. $aParams = $this->_prepareParams('owner', $iOwnerId, 0, $this->_oConfig->getRssLength(), '', array(), 0);
  199. $aEvents = $this->_oDb->getEvents($aParams);
  200. $aRssData = array();
  201. foreach($aEvents as $aEvent) {
  202. if(empty($aEvent['title'])) continue;
  203. $aRssData[$aEvent['id']] = array(
  204. 'UnitID' => $aEvent['id'],
  205. 'UnitTitle' => $aEvent['title'],
  206. 'UnitLink' => $this->_oConfig->getItemViewUrl($aEvent),
  207. 'UnitDesc' => $aEvent['description'],
  208. 'UnitDateTimeUTS' => $aEvent['date'],
  209. );
  210. }
  211. $oRss = new BxDolRssFactory();
  212. header('Content-Type: application/xml; charset=utf-8');
  213. echo $oRss->GenRssByData($aRssData, $sRssCaption, $sRssLink);
  214. }
  215. /**
  216. * SERVICE METHODS
  217. *
  218. * Get Post block for a separate page.
  219. */
  220. public function serviceGetBlockPost($iProfileId = 0)
  221. {
  222. if(empty($iProfileId) && bx_get('profile_id') !== false)
  223. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  224. if(empty($iProfileId) && isLogged())
  225. $iProfileId = bx_get_logged_profile_id();
  226. return $this->getBlockPost($iProfileId);
  227. }
  228. public function serviceGetBlockPostProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0)
  229. {
  230. if(empty($sProfileModule))
  231. return array();
  232. if(empty($iProfileContentId) && bx_get('id') !== false)
  233. $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  234. $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
  235. if(empty($oProfile))
  236. return array();
  237. return $this->getBlockPost($oProfile->id());
  238. }
  239. /*
  240. * Get View block for a separate page. Will return a block with "Empty" message if nothing found.
  241. */
  242. public function serviceGetBlockView($iProfileId = 0)
  243. {
  244. if(empty($iProfileId) && bx_get('profile_id') !== false)
  245. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  246. if(empty($iProfileId) && isLogged())
  247. $iProfileId = bx_get_logged_profile_id();
  248. $aBlock = $this->getBlockView($iProfileId);
  249. if(!empty($aBlock))
  250. return $aBlock;
  251. return array('content' => MsgBox(_t('_bx_timeline_txt_msg_no_results')));
  252. }
  253. public function serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  254. {
  255. if(empty($sProfileModule))
  256. return array();
  257. if(empty($iProfileContentId) && bx_get('id') !== false)
  258. $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  259. $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
  260. if(empty($oProfile))
  261. return array();
  262. return $this->getBlockView($oProfile->id(), $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  263. }
  264. public function serviceGetBlockViewAccount($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  265. {
  266. $aParams = $this->_prepareParams(BX_BASE_MOD_NTFS_TYPE_CONNECTIONS, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  267. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage('account');
  268. $this->_iOwnerId = $aParams['owner_id'];
  269. $sContent = $this->_oTemplate->getViewBlock($aParams);
  270. return array('content' => $sContent);
  271. }
  272. public function serviceGetBlockViewHome($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  273. {
  274. $aParams = $this->_prepareParams(BX_BASE_MOD_NTFS_TYPE_PUBLIC, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  275. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage('home');
  276. $this->_iOwnerId = $aParams['owner_id'];
  277. $sContent = $this->_oTemplate->getViewBlock($aParams);
  278. return array('content' => $sContent);
  279. }
  280. public function serviceGetBlockItem()
  281. {
  282. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  283. if(!$iItemId)
  284. return array();
  285. return array('content' => $this->_oTemplate->getItemBlock($iItemId));
  286. }
  287. /**
  288. * Data for Notifications module
  289. */
  290. public function serviceGetNotificationsData()
  291. {
  292. $sModule = $this->_aModule['name'];
  293. return array(
  294. 'handlers' => array(
  295. array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'post_common', 'module_name' => $sModule, 'module_method' => 'get_notifications_post', 'module_class' => 'Module'),
  296. array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete'),
  297. array('group' => $sModule . '_comment', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'commentPost', 'module_name' => $sModule, 'module_method' => 'get_notifications_comment', 'module_class' => 'Module'),
  298. array('group' => $sModule . '_comment', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'commentRemoved'),
  299. array('group' => $sModule . '_vote', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_vote', 'module_class' => 'Module'),
  300. array('group' => $sModule . '_vote', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'undoVote'),
  301. ),
  302. 'alerts' => array(
  303. array('unit' => $sModule, 'action' => 'post_common'),
  304. array('unit' => $sModule, 'action' => 'deleted'),
  305. array('unit' => $sModule, 'action' => 'commentPost'),
  306. array('unit' => $sModule, 'action' => 'commentRemoved'),
  307. array('unit' => $sModule, 'action' => 'doVote'),
  308. array('unit' => $sModule, 'action' => 'undoVote'),
  309. )
  310. );
  311. }
  312. public function serviceGetNotificationsPost($aEvent)
  313. {
  314. $CNF = &$this->_oConfig->CNF;
  315. $iContent = (int)$aEvent['object_id'];
  316. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  317. if(empty($aContent) || !is_array($aContent))
  318. return array();
  319. $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : strmaxtextlen($aContent['description'], 20, '...');
  320. return array(
  321. 'entry_sample' => $CNF['T']['txt_sample_single_ext'],
  322. 'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
  323. 'entry_caption' => $sEntryCaption,
  324. 'entry_author' => $aContent['owner_id'],
  325. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  326. );
  327. }
  328. public function serviceGetNotificationsComment($aEvent)
  329. {
  330. $CNF = &$this->_oConfig->CNF;
  331. $iContent = (int)$aEvent['object_id'];
  332. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  333. if(empty($aContent) || !is_array($aContent))
  334. return array();
  335. $oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContent);
  336. if(!$oComment || !$oComment->isEnabled())
  337. return array();
  338. $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : strmaxtextlen($aContent['description'], 20, '...');
  339. return array(
  340. 'entry_sample' => $CNF['T']['txt_sample_single'],
  341. 'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
  342. 'entry_caption' => $sEntryCaption,
  343. 'entry_author' => $aContent['owner_id'],
  344. 'subentry_sample' => $CNF['T']['txt_sample_comment_single'],
  345. 'subentry_url' => $oComment->getViewUrl((int)$aEvent['subobject_id']),
  346. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  347. );
  348. }
  349. public function serviceGetNotificationsVote($aEvent)
  350. {
  351. $CNF = &$this->_oConfig->CNF;
  352. $iContent = (int)$aEvent['object_id'];
  353. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  354. if(empty($aContent) || !is_array($aContent))
  355. return array();
  356. $oVote = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContent);
  357. if(!$oVote || !$oVote->isEnabled())
  358. return array();
  359. $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : strmaxtextlen($aContent['description'], 20, '...');
  360. return array(
  361. 'entry_sample' => $CNF['T']['txt_sample_single'],
  362. 'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
  363. 'entry_caption' => $sEntryCaption,
  364. 'entry_author' => $aContent['owner_id'],
  365. 'subentry_sample' => $CNF['T']['txt_sample_vote_single'],
  366. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  367. );
  368. }
  369. public function serviceGetShareElementBlock($iOwnerId, $sType, $sAction, $iObjectId, $aParams = array())
  370. {
  371. if(!$this->isEnabled())
  372. return '';
  373. $aParams = array_merge($this->_oConfig->getShareDefaults(), $aParams);
  374. return $this->_oTemplate->getShareElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams);
  375. }
  376. public function serviceGetShareCounter($sType, $sAction, $iObjectId)
  377. {
  378. if(!$this->isEnabled())
  379. return '';
  380. $aShared = $this->_oDb->getShared($sType, $sAction, $iObjectId);
  381. return $this->_oTemplate->getShareCounter($aShared);
  382. }
  383. public function serviceGetShareJsScript()
  384. {
  385. if(!$this->isEnabled())
  386. return '';
  387. return $this->_oTemplate->getShareJsScript();
  388. }
  389. public function serviceGetShareJsClick($iOwnerId, $sType, $sAction, $iObjectId)
  390. {
  391. if(!$this->isEnabled())
  392. return '';
  393. return $this->_oTemplate->getShareJsClick($iOwnerId, $sType, $sAction, $iObjectId);
  394. }
  395. public function serviceGetMenuItemAddonComment($sSystem, $iObjectId)
  396. {
  397. if(empty($sSystem) || empty($iObjectId))
  398. return '';
  399. $oCmts = $this->getCmtsObject($sSystem, $iObjectId);
  400. if($oCmts === false)
  401. return '';
  402. $iCounter = (int)$oCmts->getCommentsCount();
  403. return $this->_oTemplate->parseHtmlByName('bx_a.html', array(
  404. 'href' => 'javascript:void(0)',
  405. 'title' => _t('_bx_timeline_menu_item_title_item_comment'),
  406. 'bx_repeat:attrs' => array(
  407. array('key' => 'onclick', 'value' => "javascript:" . $this->_oConfig->getJsObject('view') . ".commentItem(this, '" . $sSystem . "', " . $iObjectId . ")")
  408. ),
  409. 'content' => $iCounter > 0 ? $iCounter : ''
  410. ));
  411. }
  412. public function serviceGetSettingsCheckerHelper()
  413. {
  414. bx_import('FormCheckerHelper', $this->_aModule);
  415. return 'BxTimelineFormCheckerHelper';
  416. }
  417. /*
  418. * COMMON METHODS
  419. */
  420. public function getBlockPost($iProfileId)
  421. {
  422. if(!$iProfileId)
  423. return array();
  424. $this->_iOwnerId = $iProfileId;
  425. if($this->isAllowedPost() !== true)
  426. return array();
  427. $sContent = $this->_oTemplate->getPostBlock($this->_iOwnerId);
  428. return array('content' => $sContent);
  429. }
  430. public function getBlockView($iProfileId, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  431. {
  432. if(!$iProfileId)
  433. return array();
  434. $sJsObject = $this->_oConfig->getJsObject('view');
  435. $aParams = $this->_prepareParams(BX_BASE_MOD_NTFS_TYPE_OWNER, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  436. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage('profile');
  437. $this->_iOwnerId = $aParams['owner_id'];
  438. list($sUserName, $sUserUrl) = $this->getUserInfo($aParams['owner_id']);
  439. $aMenu = array(
  440. array('id' => 'timeline-view-all', 'name' => 'timeline-view-all', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_all'), 'active' => 1),
  441. array('id' => 'timeline-view-owner', 'name' => 'timeline-view-owner', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_owner', $sUserName)),
  442. array('id' => 'timeline-view-other', 'name' => 'timeline-view-other', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_other')),
  443. array('id' => 'timeline-get-rss', 'name' => 'timeline-get-rss', 'class' => '', 'link' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . $iProfileId . '/', 'target' => '_blank', 'title' => _t('_bx_timeline_menu_item_get_rss')),
  444. );
  445. $sContent = '';
  446. $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
  447. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view', $this->_iOwnerId, $this->getUserId(), array('override_content' => &$sContent, 'params' => &$aParams, 'menu' => &$aMenu));
  448. $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> 'timeline-view-all', 'menu_items' => $aMenu));
  449. $oMenu->setSelected('', 'timeline-view-all');
  450. if (!$sContent)
  451. $sContent = $this->_oTemplate->getViewBlock($aParams);
  452. return array('content' => $sContent, 'menu' => $oMenu);
  453. }
  454. public function deleteEvent($aEvent)
  455. {
  456. if(empty($aEvent) || !is_array($aEvent) || !$this->_oDb->deleteEvent(array('id' => (int)$aEvent['id'])))
  457. return false;
  458. $this->onDelete($aEvent);
  459. return true;
  460. }
  461. public function getFormAttachLink()
  462. {
  463. $iUserId = $this->getUserId();
  464. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_attach_link'), $this->_oConfig->getObject('form_display_attach_link_add'), $this->_oTemplate);
  465. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'add_attach_link/';
  466. $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url');
  467. $oForm->initChecker();
  468. if($oForm->isSubmittedAndValid()) {
  469. $sLink = $oForm->getCleanValue('url');
  470. $aMatches = array();
  471. preg_match($this->_oConfig->getPregPattern('url'), $sLink, $aMatches);
  472. $sLink = (empty($aMatches[2]) ? 'http://' : '') . $aMatches[0];
  473. $aSiteInfo = bx_get_site_info($sLink, array(
  474. 'thumbnailUrl' => array('tag' => 'link', 'content_attr' => 'href'),
  475. 'OGImage' => array('name_attr' => 'property', 'name' => 'og:image'),
  476. ));
  477. $sTitle = !empty($aSiteInfo['title']) ? $aSiteInfo['title'] : _t('_Empty');
  478. $sDescription = !empty($aSiteInfo['description']) ? $aSiteInfo['description'] : _t('_Empty');
  479. $sMediaUrl = '';
  480. if(!empty($aSiteInfo['thumbnailUrl']))
  481. $sMediaUrl = $aSiteInfo['thumbnailUrl'];
  482. else if(!empty($aSiteInfo['OGImage']))
  483. $sMediaUrl = $aSiteInfo['OGImage'];
  484. $iMediaId = 0;
  485. $oStorage = null;
  486. if(!empty($sMediaUrl)) {
  487. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . BX_TIMELINE_MEDIA_PHOTO . 's'));
  488. $iMediaId = $oStorage->storeFileFromUrl($sMediaUrl, true, $iUserId);
  489. }
  490. $iId = (int)$oForm->insert(array('profile_id' => $iUserId, 'media_id' => $iMediaId, 'url' => $sLink, 'title' => $sTitle, 'text' => $sDescription, 'added' => time()));
  491. if(!empty($iId)) {
  492. if(!empty($oStorage) && !empty($iMediaId))
  493. $oStorage->afterUploadCleanup($iMediaId, $iUserId);
  494. return array('item' => $this->_oTemplate->getAttachLinkItem($iUserId, $iId));
  495. }
  496. return array('msg' => _t('_bx_timeline_txt_err_cannot_perform_action'));
  497. }
  498. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  499. }
  500. public function getFormPost()
  501. {
  502. $iUserId = $this->getUserId();
  503. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_post'), $this->_oConfig->getObject('form_display_post_add'), $this->_oTemplate);
  504. $oForm->initChecker();
  505. if($oForm->isSubmittedAndValid()) {
  506. list($sUserName) = $this->getUserInfo($iUserId);
  507. $sType = $oForm->getCleanValue('type');
  508. $sType = $this->_oConfig->getPrefix('common_post') . $sType;
  509. BxDolForm::setSubmittedValue('type', $sType, $oForm->aFormAttrs['method']);
  510. $aContent = array();
  511. //--- Process Text ---//
  512. $sText = $oForm->getCleanValue('text');
  513. unset($oForm->aInputs['text']);
  514. $aContent['text'] = $this->_prepareTextForSave($sText);
  515. //--- Process Link ---//
  516. $aLinkIds = $oForm->getCleanValue('link');
  517. //--- Process Media ---//
  518. $aPhotoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_PHOTO);
  519. $aVideoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_VIDEO);
  520. $sTitle = _t('_bx_timeline_txt_user_added_sample', $sUserName, _t('_bx_timeline_txt_sample'));
  521. $sDescription = !empty($aContent['text']) ? $aContent['text'] : '';
  522. $iId = $oForm->insert(array(
  523. 'object_id' => $iUserId,
  524. 'object_privacy_view' => $this->_oConfig->getPrivacyViewDefault('object'),
  525. 'content' => serialize($aContent),
  526. 'title' => $sTitle,
  527. 'description' => $sDescription,
  528. 'date' => time()
  529. ));
  530. if(!empty($iId)) {
  531. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  532. $oMetatags->keywordsAdd($iId, $aContent['text']);
  533. $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
  534. //--- Process Link ---//
  535. if(!empty($aLinkIds) && is_array($aLinkIds))
  536. foreach($aLinkIds as $iLinkId)
  537. $this->_oDb->saveLink($iId, $iLinkId);
  538. //--- Process Media ---//
  539. $this->_saveMedia(BX_TIMELINE_MEDIA_PHOTO, $iId, $aPhotoIds);
  540. $this->_saveMedia(BX_TIMELINE_MEDIA_VIDEO, $iId, $aVideoIds);
  541. $this->onPost($iId);
  542. return array('id' => $iId);
  543. }
  544. return array('msg' => _t('_bx_timeline_txt_err_cannot_perform_action'));
  545. }
  546. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  547. }
  548. public function getCmtsObject($sSystem, $iId)
  549. {
  550. if(empty($sSystem) || (int)$iId == 0)
  551. return false;
  552. $oCmts = BxDolCmts::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  553. if(!$oCmts->isEnabled())
  554. return false;
  555. return $oCmts;
  556. }
  557. public function getVoteObject($sSystem, $iId)
  558. {
  559. if(empty($sSystem) || (int)$iId == 0)
  560. return false;
  561. $oVote = BxDolVote::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  562. if(!$oVote->isEnabled())
  563. return false;
  564. return $oVote;
  565. }
  566. public function getReportObject($sSystem, $iId)
  567. {
  568. if(empty($sSystem) || (int)$iId == 0)
  569. return false;
  570. $oReport = BxDolReport::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  571. if(!$oReport->isEnabled())
  572. return false;
  573. return $oReport;
  574. }
  575. public function getAttachmentsMenuObject()
  576. {
  577. $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_post_attachments'), $this->_oTemplate);
  578. $oMenu->addMarkers(array(
  579. 'js_object' => $this->_oConfig->getJsObject('post'),
  580. ));
  581. return $oMenu;
  582. }
  583. public function getManageMenuObject()
  584. {
  585. return BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_manage'), $this->_oTemplate);
  586. }
  587. //--- Check permissions methods ---//
  588. public function isAllowedPost($bPerform = false)
  589. {
  590. if(isAdmin())
  591. return true;
  592. $iUserId = $this->getUserId();
  593. if($this->_iOwnerId == $this->getUserId())
  594. return true;
  595. $aCheckResult = checkActionModule($iUserId, 'post', $this->getName(), $bPerform);
  596. if ($oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId))
  597. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_post', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  598. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  599. }
  600. public function isAllowedDelete($aEvent, $bPerform = false)
  601. {
  602. if(isAdmin())
  603. return true;
  604. $iUserId = (int)$this->getUserId();
  605. if((int)$aEvent['owner_id'] == $iUserId && $this->_oConfig->isAllowDelete())
  606. return true;
  607. $aCheckResult = checkActionModule($iUserId, 'delete', $this->getName(), $bPerform);
  608. if ($oProfileOwner = BxDolProfile::getInstance((int)$aEvent['owner_id']))
  609. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_delete', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  610. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  611. }
  612. public function isAllowedComment($aEvent, $bPerform = false)
  613. {
  614. $mixedComments = $this->getCommentsData($aEvent['comments']);
  615. if($mixedComments === false)
  616. return false;
  617. list($sSystem, $iObjectId) = $mixedComments;
  618. $oCmts = $this->getCmtsObject($sSystem, $iObjectId);
  619. $oCmts->addCssJs();
  620. $bResult = isAdmin() ? true : false;
  621. if ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']))
  622. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_comment', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  623. return $bResult;
  624. }
  625. public function isAllowedVote($aEvent, $bPerform = false)
  626. {
  627. $mixedVotes = $this->getVotesData($aEvent['votes']);
  628. if($mixedVotes === false)
  629. return false;
  630. list($sSystem, $iObjectId) = $mixedVotes;
  631. $oVote = $this->getVoteObject($sSystem, $iObjectId);
  632. $oVote->addCssJs();
  633. $bResult = isAdmin() ? true : false;
  634. if ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']))
  635. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  636. return $bResult;
  637. }
  638. public function isAllowedReport($aEvent, $bPerform = false)
  639. {
  640. $mixedReports = $this->getReportsData($aEvent['reports']);
  641. if($mixedReports === false)
  642. return false;
  643. list($sSystem, $iObjectId) = $mixedReports;
  644. $oReport = $this->getReportObject($sSystem, $iObjectId);
  645. $oReport->addCssJs();
  646. $bResult = isAdmin() ? true : false;
  647. if ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']))
  648. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_report', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  649. return $bResult;
  650. }
  651. public function isAllowedShare($aEvent, $bPerform = false)
  652. {
  653. if(isAdmin())
  654. return true;
  655. $iUserId = (int)$this->getUserId();
  656. if($iUserId == 0)
  657. return false;
  658. $aCheckResult = checkActionModule($iUserId, 'share', $this->getName(), $bPerform);
  659. if ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']))
  660. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_share', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  661. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  662. }
  663. public function isAllowedMore($aEvent, $bPerform = false)
  664. {
  665. $oMoreMenu = $this->getManageMenuObject();
  666. $oMoreMenu->setEventId($aEvent['id']);
  667. return $oMoreMenu->isVisible();
  668. }
  669. public function onPost($iId)
  670. {
  671. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  672. if($this->_oConfig->isSystem($aEvent['type'], $aEvent['action'])) {
  673. $sPostType = 'system';
  674. $iSenderId = $aEvent['owner_id'];
  675. } else {
  676. $sPostType = 'common';
  677. $iSenderId = $aEvent['object_id'];
  678. }
  679. //--- Event -> Post for Alerts Engine ---//
  680. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'post_' . $sPostType, $iId, $iSenderId, array(
  681. 'object_author_id' => $aEvent['owner_id']
  682. ));
  683. $oAlert->alert();
  684. //--- Event -> Post for Alerts Engine ---//
  685. }
  686. public function onShare($iId, $aShared = array())
  687. {
  688. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  689. if(empty($aShared)) {
  690. $aContent = unserialize($aEvent['content']);
  691. $aShared = $this->_oDb->getShared($aContent['type'], $aContent['action'], $aContent['object_id']);
  692. if(empty($aShared) || !is_array($aShared))
  693. return;
  694. }
  695. $iUserId = $this->getUserId();
  696. $this->_oDb->insertShareTrack($aEvent['id'], $iUserId, $this->getUserIp(), $aShared['id']);
  697. $this->_oDb->updateShareCounter($aShared['id'], $aShared['shares']);
  698. //--- Timeline -> Update for Alerts Engine ---//
  699. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'share', $aShared['id'], $iUserId);
  700. $oAlert->alert();
  701. //--- Timeline -> Update for Alerts Engine ---//
  702. }
  703. public function onDelete($aEvent)
  704. {
  705. $sCommonPostPrefix = $this->_oConfig->getPrefix('common_post');
  706. //--- Delete attached photos, videos and links when common event was deleted.
  707. if($aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_POST) {
  708. $this->_deleteMedia(BX_TIMELINE_MEDIA_PHOTO, $aEvent['id']);
  709. $this->_deleteMedia(BX_TIMELINE_MEDIA_VIDEO, $aEvent['id']);
  710. $this->_deleteLinks($aEvent['id']);
  711. }
  712. //--- Update parent event when share event was deleted.
  713. if($aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_SHARE) {
  714. $this->_oDb->deleteShareTrack($aEvent['id']);
  715. $aContent = unserialize($aEvent['content']);
  716. $aShared = $this->_oDb->getShared($aContent['type'], $aContent['action'], $aContent['object_id']);
  717. if(!empty($aShared) && is_array($aShared))
  718. $this->_oDb->updateShareCounter($aShared['id'], $aShared['shares'], -1);
  719. }
  720. //--- Find and delete share events when parent event was deleted.
  721. $bSystem = $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']);
  722. $aShareEvents = $this->_oDb->getEvents(array('browse' => 'shared_by_descriptor', 'type' => $aEvent['type']));
  723. foreach($aShareEvents as $aShareEvent) {
  724. $aContent = unserialize($aShareEvent['content']);
  725. if(isset($aContent['type']) && $aContent['type'] == $aEvent['type'] && isset($aContent['object_id']) && (($bSystem && (int)$aContent['object_id'] == (int)$aEvent['object_id']) || (!$bSystem && (int)$aContent['object_id'] == (int)$aEvent['id'])))
  726. $this->_oDb->deleteEvent(array('id' => (int)$aShareEvent['id']));
  727. }
  728. //--- Delete associated meta.
  729. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  730. $oMetatags->onDeleteContent($aEvent['id']);
  731. //--- Event -> Delete for Alerts Engine ---//
  732. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'delete', $aEvent['id'], $this->getUserId());
  733. $oAlert->alert();
  734. //--- Event -> Delete for Alerts Engine ---//
  735. }
  736. public function getVotesData(&$aVotes)
  737. {
  738. if(empty($aVotes) || !is_array($aVotes))
  739. return false;
  740. $sSystem = isset($aVotes['system']) ? $aVotes['system'] : '';
  741. $iObjectId = isset($aVotes['object_id']) ? (int)$aVotes['object_id'] : 0;
  742. $iCount = isset($aVotes['count']) ? (int)$aVotes['count'] : 0;
  743. if($sSystem == '' || $iObjectId == 0)
  744. return false;
  745. return array($sSystem, $iObjectId, $iCount);
  746. }
  747. public function getReportsData(&$aReports)
  748. {
  749. if(empty($aReports) || !is_array($aReports))
  750. return false;
  751. $sSystem = isset($aReports['system']) ? $aReports['system'] : '';
  752. $iObjectId = isset($aReports['object_id']) ? (int)$aReports['object_id'] : 0;
  753. $iCount = isset($aReports['count']) ? (int)$aReports['count'] : 0;
  754. if($sSystem == '' || $iObjectId == 0)
  755. return false;
  756. return array($sSystem, $iObjectId, $iCount);
  757. }
  758. public function getCommentsData(&$aComments)
  759. {
  760. if(empty($aComments) || !is_array($aComments))
  761. return false;
  762. $sSystem = isset($aComments['system']) ? $aComments['system'] : '';
  763. $iObjectId = isset($aComments['object_id']) ? (int)$aComments['object_id'] : 0;
  764. $iCount = isset($aComments['count']) ? (int)$aComments['count'] : 0;
  765. if($sSystem == '' || $iObjectId == 0 || ($iCount == 0 && !isLogged()))
  766. return false;
  767. return array($sSystem, $iObjectId, $iCount);
  768. }
  769. protected function _deleteLinks($iId)
  770. {
  771. $aLinks = $this->_oDb->getLinks($iId);
  772. if(empty($aLinks) || !is_array($aLinks))
  773. return;
  774. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'));
  775. foreach($aLinks as $aLink)
  776. if(!empty($aLink['media_id']))
  777. $oStorage->deleteFile($aLink['media_id']);
  778. $this->_oDb->deleteLinks($iId);
  779. }
  780. protected function _saveMedia($sType, $iId, $aItemIds)
  781. {
  782. if(empty($aItemIds) || !is_array($aItemIds))
  783. return;
  784. $iUserId = $this->getUserId();
  785. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
  786. foreach($aItemIds as $iItemId)
  787. if($this->_oDb->saveMedia($sType, $iId, $iItemId))
  788. $oStorage->afterUploadCleanup($iItemId, $iUserId);
  789. }
  790. protected function _deleteMedia($sType, $iId)
  791. {
  792. $aItems = $this->_oDb->getMedia($sType, $iId);
  793. if(empty($aItems) || !is_array($aItems))
  794. return;
  795. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
  796. foreach($aItems as $iItemId)
  797. $oStorage->deleteFile($iItemId);
  798. $this->_oDb->deleteMedia($sType, $iId);
  799. }
  800. protected function _prepareParams($sType, $iOwnerId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline)
  801. {
  802. $aParams = array();
  803. $aParams['browse'] = 'list';
  804. $aParams['type'] = !empty($sType) ? $sType : BX_TIMELINE_TYPE_DEFAULT;
  805. $aParams['owner_id'] = (int)$iOwnerId != 0 ? $iOwnerId : $this->getUserId();
  806. $aParams['start'] = (int)$iStart > 0 ? $iStart : 0;
  807. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage();
  808. $aParams['filter'] = !empty($sFilter) ? $sFilter : BX_TIMELINE_FILTER_ALL;
  809. $aParams['modules'] = is_array($aModules) && !empty($aModules) ? $aModules : array();
  810. $aParams['timeline'] = (int)$iTimeline > 0 ? $iTimeline : 0;
  811. $aParams['active'] = 1;
  812. $aParams['hidden'] = 0;
  813. return $aParams;
  814. }
  815. protected function _prepareParamsGet()
  816. {
  817. $aParams = array();
  818. $aParams['browse'] = 'list';
  819. $aParams['dynamic_mode'] = true;
  820. $sType = bx_get('type');
  821. $aParams['type'] = $sType !== false ? bx_process_input($sType, BX_DATA_TEXT) : BX_TIMELINE_TYPE_DEFAULT;
  822. $aParams['owner_id'] = $sType !== false ? bx_process_input(bx_get('owner_id'), BX_DATA_INT) : $this->getUserId();
  823. $iStart = bx_get('start');
  824. $aParams['start'] = $iStart !== false ? bx_process_input($iStart, BX_DATA_INT) : 0;
  825. $iPerPage = bx_get('per_page');
  826. $aParams['per_page'] = $iPerPage !== false ? bx_process_input($iPerPage, BX_DATA_INT) : $this->_oConfig->getPerPage();
  827. $sFilter = bx_get('filter');
  828. $aParams['filter'] = $sFilter !== false ? bx_process_input($sFilter, BX_DATA_TEXT) : BX_TIMELINE_FILTER_ALL;
  829. $aModules = bx_get('modules');
  830. $aParams['modules'] = $aModules !== false ? bx_process_input($aModules, BX_DATA_TEXT) : array();
  831. $iTimeline = bx_get('timeline');
  832. $aParams['timeline'] = $iTimeline !== false ? bx_process_input($iTimeline, BX_DATA_INT) : 0;
  833. $aParams['active'] = 1;
  834. $aParams['hidden'] = 0;
  835. return $aParams;
  836. }
  837. protected function _prepareTextForSave($s)
  838. {
  839. return bx_process_input($s, BX_DATA_TEXT_MULTILINE);
  840. }
  841. }
  842. /** @} */