BxTimelineModule.php 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081
  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 Timeline Timeline
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolAcl');
  12. bx_import('BxBaseModNotificationsModule');
  13. define('BX_TIMELINE_TYPE_ITEM', 'view_item');
  14. define('BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS', 'owner_and_connections');
  15. define('BX_TIMELINE_TYPE_DEFAULT', BX_BASE_MOD_NTFS_TYPE_OWNER);
  16. define('BX_TIMELINE_VIEW_ITEM', 'item');
  17. define('BX_TIMELINE_VIEW_TIMELINE', 'timeline');
  18. define('BX_TIMELINE_VIEW_OUTLINE', 'outline');
  19. define('BX_TIMELINE_VIEW_SEARCH', 'search');
  20. define('BX_TIMELINE_VIEW_DEFAULT', BX_TIMELINE_VIEW_OUTLINE);
  21. define('BX_TIMELINE_FILTER_ALL', 'all');
  22. define('BX_TIMELINE_FILTER_OWNER', 'owner');
  23. define('BX_TIMELINE_FILTER_OTHER', 'other');
  24. define('BX_TIMELINE_PARSE_TYPE_POST', 'post');
  25. define('BX_TIMELINE_PARSE_TYPE_REPOST', 'repost');
  26. define('BX_TIMELINE_PARSE_TYPE_DEFAULT', BX_TIMELINE_PARSE_TYPE_POST);
  27. define('BX_TIMELINE_MEDIA_PHOTO', 'photo');
  28. define('BX_TIMELINE_MEDIA_VIDEO', 'video');
  29. class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolContentInfoService
  30. {
  31. protected $_sJsPostObject;
  32. protected $_sJsViewObject;
  33. protected $_aPostElements;
  34. protected $_sJsOutlineObject;
  35. protected $_sDividerTemplate;
  36. protected $_sBalloonTemplate;
  37. protected $_sCmtPostTemplate;
  38. protected $_sCmtViewTemplate;
  39. protected $_sCmtTemplate;
  40. /**
  41. * Constructor
  42. */
  43. function __construct($aModule)
  44. {
  45. parent::__construct($aModule);
  46. }
  47. /**
  48. * ACTION METHODS
  49. */
  50. public function actionPost()
  51. {
  52. $sType = bx_process_input($_POST['type']);
  53. $sMethod = 'getForm' . ucfirst($sType);
  54. if(!method_exists($this, $sMethod)) {
  55. echoJson(array());
  56. return;
  57. }
  58. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  59. $mixedAllowed = $this->isAllowedPost(true);
  60. if($mixedAllowed !== true) {
  61. echoJson(array('message' => strip_tags($mixedAllowed)));
  62. return;
  63. }
  64. $aResult = $this->$sMethod();
  65. echoJson($aResult);
  66. }
  67. function actionPin()
  68. {
  69. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  70. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  71. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  72. $mixedAllowed = $this->{'isAllowed' . ((int)$aEvent['pinned'] == 0 ? 'Pin' : 'Unpin')}($aEvent, true);
  73. if($mixedAllowed !== true)
  74. return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
  75. $aEvent['pinned'] = (int)$aEvent['pinned'] == 0 ? time() : 0;
  76. if(!$this->_oDb->updateEvent(array('pinned' => $aEvent['pinned']), array('id' => $iId)))
  77. return echoJson(array('code' => 2));
  78. echoJson(array(
  79. 'code' => 0,
  80. 'id' => $iId,
  81. 'eval' => $this->_oConfig->getJsObject('view') . '.onPinPost(oData)'
  82. ));
  83. }
  84. function actionDelete()
  85. {
  86. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  87. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => bx_process_input(bx_get('id'), BX_DATA_INT)));
  88. $mixedAllowed = $this->isAllowedDelete($aEvent, true);
  89. if($mixedAllowed !== true)
  90. return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
  91. if(!$this->deleteEvent($aEvent))
  92. return echoJson(array('code' => 2));
  93. echoJson(array(
  94. 'code' => 0,
  95. 'id' => $aEvent['id'],
  96. 'eval' => $this->_oConfig->getJsObject('view') . '.onDeletePost(oData)'
  97. ));
  98. }
  99. public function actionRepost()
  100. {
  101. $iAuthorId = $this->getUserId();
  102. $iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  103. $aContent = array(
  104. 'type' => bx_process_input(bx_get('type'), BX_DATA_TEXT),
  105. 'action' => bx_process_input(bx_get('action'), BX_DATA_TEXT),
  106. 'object_id' => bx_process_input(bx_get('object_id'), BX_DATA_INT),
  107. );
  108. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  109. if(empty($aReposted) || !is_array($aReposted)) {
  110. echoJson(array('code' => 1, 'message' => _t('_bx_timeline_txt_err_cannot_repost')));
  111. return;
  112. }
  113. $mixedAllowed = $this->isAllowedRepost($aReposted, true);
  114. if($mixedAllowed !== true) {
  115. echoJson(array('code' => 2, 'message' => strip_tags($mixedAllowed)));
  116. return;
  117. }
  118. $bReposted = $this->_oDb->isReposted($aReposted['id'], $iOwnerId, $iAuthorId);
  119. if($bReposted) {
  120. echoJson(array('code' => 3, 'message' => _t('_bx_timeline_txt_err_already_reposted')));
  121. return;
  122. }
  123. $iId = $this->_oDb->insertEvent(array(
  124. 'owner_id' => $iOwnerId,
  125. 'type' => $this->_oConfig->getPrefix('common_post') . 'repost',
  126. 'action' => '',
  127. 'object_id' => $iAuthorId,
  128. 'object_privacy_view' => $this->_oConfig->getPrivacyViewDefault('object'),
  129. 'content' => serialize($aContent),
  130. 'title' => '',
  131. 'description' => ''
  132. ));
  133. if(empty($iId)) {
  134. echoJson(array('code' => 4, 'message' => _t('_bx_timeline_txt_err_cannot_repost')));
  135. return;
  136. }
  137. $this->onRepost($iId, $aReposted);
  138. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  139. $sCounter = $this->_oTemplate->getRepostCounter($aReposted);
  140. echoJson(array(
  141. 'code' => 0,
  142. 'message' => _t('_bx_timeline_txt_msg_success_repost'),
  143. 'count' => $aReposted['reposts'],
  144. 'counter' => $sCounter,
  145. 'disabled' => !$bReposted
  146. ));
  147. }
  148. function actionGetPost()
  149. {
  150. $sView = bx_process_input(bx_get('view'));
  151. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  152. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => bx_process_input(bx_get('id'), BX_DATA_INT)));
  153. if(empty($aEvent) || !is_array($aEvent))
  154. return echoJson(array());
  155. echoJson(array(
  156. 'id' => $aEvent['id'],
  157. 'view' => $sView,
  158. 'item' => $this->_oTemplate->getPost($aEvent, array(
  159. 'view' => $sView,
  160. 'type' => 'owner',
  161. 'owner_id' => $this->_iOwnerId,
  162. 'dynamic_mode' => true
  163. )),
  164. 'eval' => $this->_oConfig->getJsObject('post') . "._onGetPost(oData)"
  165. ));
  166. }
  167. function actionGetPosts()
  168. {
  169. $aParams = $this->_prepareParamsGet();
  170. list($sItems, $sLoadMore, $sBack, $sEmpty) = $this->_oTemplate->getPosts($aParams);
  171. echoJson(array(
  172. 'view' => $aParams['view'],
  173. 'items' => $sItems,
  174. 'load_more' => $sLoadMore,
  175. 'back' => $sBack,
  176. 'empty' => $sEmpty,
  177. 'eval' => $this->_oConfig->getJsObject('view') . "._onGetPosts(oData)"
  178. ));
  179. }
  180. public function actionGetPostForm($sType)
  181. {
  182. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  183. $sMethod = 'getForm' . ucfirst($sType);
  184. if(!method_exists($this, $sMethod)) {
  185. echoJson(array());
  186. return;
  187. }
  188. $aResult = $this->$sMethod();
  189. echoJson($aResult);
  190. }
  191. public function actionGetComments()
  192. {
  193. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  194. $sSystem = bx_process_input(bx_get('system'), BX_DATA_TEXT);
  195. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  196. $sComments = $this->_oTemplate->getComments($sSystem, $iId, true);
  197. echoJson(array('content' => $sComments));
  198. }
  199. public function actionAddAttachLink()
  200. {
  201. $aResult = $this->getFormAttachLink();
  202. echoJson($aResult);
  203. }
  204. public function actionDeleteAttachLink()
  205. {
  206. $iUserId = $this->getUserId();
  207. $iLinkId = bx_process_input(bx_get('id'), BX_DATA_INT);
  208. if(empty($iLinkId)) {
  209. echoJson(array());
  210. return;
  211. }
  212. $aLink = $this->_oDb->getUnusedLinks($iUserId, $iLinkId);
  213. if(empty($aLink) || !is_array($aLink)) {
  214. echoJson(array());
  215. return;
  216. }
  217. if(!empty($aLink['media_id']))
  218. BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'))->deleteFile($aLink['media_id']);
  219. $aResult = array();
  220. if($this->_oDb->deleteUnusedLinks($iUserId, $iLinkId))
  221. $aResult = array('code' => 0);
  222. else
  223. $aResult = array('code' => 1, 'message' => _t('_bx_timeline_form_post_input_link_err_delete'));
  224. echoJson($aResult);
  225. }
  226. public function actionGetAttachLinkForm()
  227. {
  228. echo $this->_oTemplate->getAttachLinkForm();
  229. }
  230. public function actionGetRepostedBy()
  231. {
  232. $iRepostedId = bx_process_input(bx_get('id'), BX_DATA_INT);
  233. echo $this->_oTemplate->getRepostedBy($iRepostedId);
  234. }
  235. function actionRss()
  236. {
  237. $aArgs = func_get_args();
  238. $sType = array_shift($aArgs);
  239. $iOwnerId = 0;
  240. switch($sType) {
  241. case BX_BASE_MOD_NTFS_TYPE_OWNER:
  242. $iOwnerId = array_shift($aArgs);
  243. list($sUserName) = $this->getUserInfo($iOwnerId);
  244. $sRssCaption = _t('_bx_timeline_txt_rss_caption', $sUserName);
  245. $sRssLink = $this->_oConfig->getViewUrl($iOwnerId);
  246. break;
  247. case BX_BASE_MOD_NTFS_TYPE_PUBLIC:
  248. $sRssCaption = _t('_bx_timeline_page_title_view_home');
  249. $sRssLink = $this->_oConfig->getHomeViewUrl();
  250. break;
  251. }
  252. $aParams = $this->_prepareParams(BX_TIMELINE_VIEW_DEFAULT, $sType, $iOwnerId, 0, $this->_oConfig->getRssLength(), '', array(), 0);
  253. $aEvents = $this->_oDb->getEvents($aParams);
  254. $aRssData = array();
  255. foreach($aEvents as $aEvent) {
  256. if(empty($aEvent['title'])) continue;
  257. $aRssData[$aEvent['id']] = array(
  258. 'UnitID' => $aEvent['id'],
  259. 'UnitTitle' => $aEvent['title'],
  260. 'UnitLink' => $this->_oConfig->getItemViewUrl($aEvent),
  261. 'UnitDesc' => $aEvent['description'],
  262. 'UnitDateTimeUTS' => $aEvent['date'],
  263. );
  264. }
  265. $oRss = new BxDolRssFactory();
  266. header('Content-Type: application/xml; charset=utf-8');
  267. echo $oRss->GenRssByData($aRssData, $sRssCaption, $sRssLink);
  268. }
  269. /**
  270. * SERVICE METHODS
  271. */
  272. /**
  273. * @page service Service Calls
  274. * @section bx_timeline Timeline
  275. * @subsection bx_timeline-other Other
  276. * @subsubsection bx_timeline-get_author get_author
  277. *
  278. * @code bx_srv('bx_timeline', 'get_author', [...]); @endcode
  279. *
  280. * Get author ID from content info by content ID. Is used in "Content Info Objects" system.
  281. *
  282. * @param $iContentId integer value with content ID.
  283. * @return integer value with author ID.
  284. *
  285. * @see BxTimelineModule::serviceGetAuthor
  286. */
  287. /**
  288. * @ref bx_timeline-get_author "get_author"
  289. */
  290. public function serviceGetAuthor ($iContentId)
  291. {
  292. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  293. if(empty($aEvent) || !is_array($aEvent))
  294. return 0;
  295. return $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? (int)$aEvent['owner_id'] : (int)$aEvent['object_id'];
  296. }
  297. /**
  298. * @page service Service Calls
  299. * @section bx_timeline Timeline
  300. * @subsection bx_timeline-other Other
  301. * @subsubsection bx_timeline-get_date_changed get_date_changed
  302. *
  303. * @code bx_srv('bx_timeline', 'get_date_changed', [...]); @endcode
  304. *
  305. * Get date when the content was changed last time. Is used in "Content Info Objects" system.
  306. * Note. In case of Timeline event 0 is returned everytime.
  307. *
  308. * @param $iContentId integer value with content ID.
  309. * @return integer value with changing date.
  310. *
  311. * @see BxTimelineModule::serviceGetDateChanged
  312. */
  313. /**
  314. * @ref bx_timeline-get_date_changed "get_date_changed"
  315. */
  316. public function serviceGetDateChanged ($iContentId)
  317. {
  318. return 0;
  319. }
  320. /**
  321. * @page service Service Calls
  322. * @section bx_timeline Timeline
  323. * @subsection bx_timeline-other Other
  324. * @subsubsection bx_timeline-get_link get_link
  325. *
  326. * @code bx_srv('bx_timeline', 'get_link', [...]); @endcode
  327. *
  328. * Get content view page link. Is used in "Content Info Objects" system.
  329. *
  330. * @param $iContentId integer value with content ID.
  331. * @return string value with view page link.
  332. *
  333. * @see BxTimelineModule::serviceGetLink
  334. */
  335. /**
  336. * @ref bx_timeline-get_link "get_link"
  337. */
  338. public function serviceGetLink ($iContentId)
  339. {
  340. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  341. if(empty($aEvent) || !is_array($aEvent))
  342. return '';
  343. return $this->_oConfig->getItemViewUrl($aEvent);
  344. }
  345. /**
  346. * @page service Service Calls
  347. * @section bx_timeline Timeline
  348. * @subsection bx_timeline-other Other
  349. * @subsubsection bx_timeline-get_thumb get_thumb
  350. *
  351. * @code bx_srv('bx_timeline', 'get_thumb', [...]); @endcode
  352. *
  353. * Get content thumbnail link. Is used in "Content Info Objects" system.
  354. * Note. In case of Timeline event an empty string is returned everytime.
  355. *
  356. * @param $iContentId integer value with content ID.
  357. * @param $sTranscoder (optional) string value with transcoder name which should be applied to thumbnail image.
  358. * @return string value with thumbnail link.
  359. *
  360. * @see BxTimelineModule::serviceGetThumb
  361. */
  362. /**
  363. * @ref bx_timeline-get_thumb "get_thumb"
  364. */
  365. public function serviceGetThumb ($iContentId, $sTranscoder = '')
  366. {
  367. return '';
  368. }
  369. /**
  370. * @page service Service Calls
  371. * @section bx_timeline Timeline
  372. * @subsection bx_timeline-other Other
  373. * @subsubsection bx_timeline-get_info get_info
  374. *
  375. * @code bx_srv('bx_timeline', 'get_info', [...]); @endcode
  376. *
  377. * Get content info by content ID. Is used in "Content Info Objects" system.
  378. *
  379. * @param $iContentId integer value with content ID.
  380. * @param $bSearchableFieldsOnly (optional) boolean value determining all info or "searchable fields" only will be returned.
  381. * @return an array with content info. Empty array is returned if something is wrong.
  382. *
  383. * @see BxTimelineModule::serviceGetInfo
  384. */
  385. /**
  386. * @ref bx_timeline-get_info "get_info"
  387. */
  388. public function serviceGetInfo ($iContentId, $bSearchableFieldsOnly = true)
  389. {
  390. $aContentInfo = $this->_oDb->getEvents(array(
  391. 'browse' => 'id',
  392. 'value' => $iContentId)
  393. );
  394. return BxDolContentInfo::formatFields($aContentInfo);
  395. }
  396. /**
  397. * @page service Service Calls
  398. * @section bx_timeline Timeline
  399. * @subsection bx_timeline-other Other
  400. * @subsubsection bx_timeline-get_search_result_unit get_search_result_unit
  401. *
  402. * @code bx_srv('bx_timeline', 'get_search_result_unit', [...]); @endcode
  403. *
  404. * Get search result unit by content ID. Is used in "Content Info Objects" system.
  405. *
  406. * @param $iContentId integer value with content ID.
  407. * @param $sUnitTemplate (optional) string value with template name.
  408. * @return HTML string with search result unit. Empty string is returned if something is wrong.
  409. *
  410. * @see BxTimelineModule::serviceGetSearchResultUnit
  411. */
  412. /**
  413. * @ref bx_timeline-get_search_result_unit "get_search_result_unit"
  414. */
  415. public function serviceGetSearchResultUnit ($iContentId, $sUnitTemplate = '')
  416. {
  417. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  418. if(empty($aEvent) || !is_array($aEvent))
  419. return '';
  420. if(empty($sUnitTemplate))
  421. $sUnitTemplate = 'unit.html';
  422. return $this->_oTemplate->unit($aEvent, true, $sUnitTemplate);
  423. }
  424. /**
  425. * @page service Service Calls
  426. * @section bx_timeline Timeline
  427. * @subsection bx_timeline-page_blocks Page Blocks
  428. * @subsubsection bx_timeline-get_block_post get_block_post
  429. *
  430. * @code bx_srv('bx_timeline', 'get_block_post', [...]); @endcode
  431. *
  432. * Get Post block for a separate page.
  433. *
  434. * @param $iProfileId (optional) profile ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  435. * @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.
  436. *
  437. * @see BxTimelineModule::serviceGetBlockPost
  438. */
  439. /**
  440. * @ref bx_timeline-get_block_post "get_block_post"
  441. */
  442. public function serviceGetBlockPost($iProfileId = 0)
  443. {
  444. if(empty($iProfileId) && bx_get('profile_id') !== false)
  445. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  446. if(empty($iProfileId) && isLogged())
  447. $iProfileId = bx_get_logged_profile_id();
  448. if(!$iProfileId)
  449. return array();
  450. return $this->_getBlockPost($iProfileId);
  451. }
  452. /**
  453. * @page service Service Calls
  454. * @section bx_timeline Timeline
  455. * @subsection bx_timeline-page_blocks Page Blocks
  456. * @subsubsection bx_timeline-get_block_post_profile get_block_post_profile
  457. *
  458. * @code bx_srv('bx_timeline', 'get_block_post_profile', [...]); @endcode
  459. *
  460. * Get Post block for the Profile page.
  461. *
  462. * @param $sProfileModule (optional) string value with profile based module name. Persons module is used by default.
  463. * @param $iProfileContentId (optional) profile's content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  464. * @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.
  465. *
  466. * @see BxTimelineModule::serviceGetBlockPostProfile
  467. */
  468. /**
  469. * @ref bx_timeline-get_block_post_profile "get_block_post_profile"
  470. */
  471. public function serviceGetBlockPostProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0)
  472. {
  473. if(empty($sProfileModule))
  474. return array();
  475. if(empty($iProfileContentId) && bx_get('id') !== false)
  476. $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  477. $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
  478. if(empty($oProfile))
  479. return array();
  480. return $this->_getBlockPost($oProfile->id());
  481. }
  482. /**
  483. * @page service Service Calls
  484. * @section bx_timeline Timeline
  485. * @subsection bx_timeline-page_blocks Page Blocks
  486. * @subsubsection bx_timeline-get_block_post_home get_block_post_home
  487. *
  488. * @code bx_srv('bx_timeline', 'get_block_post_home', [...]); @endcode
  489. *
  490. * Get Post block for site's Home page.
  491. *
  492. * @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.
  493. *
  494. * @see BxTimelineModule::serviceGetBlockPostHome
  495. */
  496. /**
  497. * @ref bx_timeline-get_block_post_home "get_block_post_home"
  498. */
  499. public function serviceGetBlockPostHome()
  500. {
  501. $iProfileId = 0;
  502. return $this->_getBlockPost($iProfileId, array(
  503. 'form_display' => 'form_display_post_add_public'
  504. ));
  505. }
  506. /**
  507. * @page service Service Calls
  508. * @section bx_timeline Timeline
  509. * @subsection bx_timeline-page_blocks Page Blocks
  510. * @subsubsection bx_timeline-get_block_post_account get_block_post_account
  511. *
  512. * @code bx_srv('bx_timeline', 'get_block_post_account', [...]); @endcode
  513. *
  514. * Get Post block for the Dashboard page.
  515. *
  516. * @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.
  517. *
  518. * @see BxTimelineModule::serviceGetBlockPostAccount
  519. */
  520. /**
  521. * @ref bx_timeline-get_block_post_account "get_block_post_account"
  522. */
  523. public function serviceGetBlockPostAccount()
  524. {
  525. if(!isLogged())
  526. return '';
  527. $iProfileId = $this->getProfileId();
  528. return $this->_getBlockPost($iProfileId);
  529. }
  530. /**
  531. * @page service Service Calls
  532. * @section bx_timeline Timeline
  533. * @subsection bx_timeline-page_blocks Page Blocks
  534. * @subsubsection bx_timeline-get_block_view get_block_view
  535. *
  536. * @code bx_srv('bx_timeline', 'get_block_view', [...]); @endcode
  537. *
  538. * Get Timeline View block for a separate page.
  539. *
  540. * @param $iProfileId (optional) profile ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  541. * @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.
  542. *
  543. * @see BxTimelineModule::serviceGetBlockView
  544. */
  545. /**
  546. * @ref bx_timeline-get_block_view "get_block_view"
  547. */
  548. public function serviceGetBlockView($iProfileId = 0)
  549. {
  550. return $this->_serviceGetBlockView($iProfileId, BX_TIMELINE_VIEW_TIMELINE);
  551. }
  552. /**
  553. * @page service Service Calls
  554. * @section bx_timeline Timeline
  555. * @subsection bx_timeline-page_blocks Page Blocks
  556. * @subsubsection bx_timeline-get_block_view_outline get_block_view_outline
  557. *
  558. * @code bx_srv('bx_timeline', 'get_block_view_outline', [...]); @endcode
  559. *
  560. * Get Outline View block for a separate page.
  561. *
  562. * @param $iProfileId (optional) profile ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  563. * @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.
  564. *
  565. * @see BxTimelineModule::serviceGetBlockViewOutline
  566. */
  567. /**
  568. * @ref bx_timeline-get_block_view_outline "get_block_view_outline"
  569. */
  570. public function serviceGetBlockViewOutline($iProfileId = 0)
  571. {
  572. return $this->_serviceGetBlockView($iProfileId, BX_TIMELINE_VIEW_OUTLINE);
  573. }
  574. /**
  575. * @page service Service Calls
  576. * @section bx_timeline Timeline
  577. * @subsection bx_timeline-page_blocks Page Blocks
  578. * @subsubsection bx_timeline-get_block_view_profile get_block_view_profile
  579. *
  580. * @code bx_srv('bx_timeline', 'get_block_view_profile', [...]); @endcode
  581. *
  582. * Get Timeline View block for the Profile page.
  583. *
  584. * @param $sProfileModule (optional) string value with profile based module name. Persons module is used by default.
  585. * @param $iProfileContentId (optional) profile's content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  586. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  587. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  588. * @param $sFilter (optional) string value with filter name.
  589. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  590. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  591. * @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.
  592. *
  593. * @see BxTimelineModule::serviceGetBlockViewProfile
  594. */
  595. /**
  596. * @ref bx_timeline-get_block_view_profile "get_block_view_profile"
  597. */
  598. public function serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  599. {
  600. $sView = BX_TIMELINE_VIEW_TIMELINE;
  601. return $this->_serviceGetBlockViewProfile($sProfileModule, $iProfileContentId, $sView, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  602. }
  603. /**
  604. * @page service Service Calls
  605. * @section bx_timeline Timeline
  606. * @subsection bx_timeline-page_blocks Page Blocks
  607. * @subsubsection bx_timeline-get_block_view_profile_outline get_block_view_profile_outline
  608. *
  609. * @code bx_srv('bx_timeline', 'get_block_view_profile_outline', [...]); @endcode
  610. *
  611. * Get Outline View block for the Profile page.
  612. *
  613. * @param $sProfileModule (optional) string value with profile based module name. Persons module is used by default.
  614. * @param $iProfileContentId (optional) profile's content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  615. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  616. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  617. * @param $sFilter (optional) string value with filter name.
  618. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  619. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  620. * @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.
  621. *
  622. * @see BxTimelineModule::serviceGetBlockViewProfileOutline
  623. */
  624. /**
  625. * @ref bx_timeline-get_block_view_profile_outline "get_block_view_profile_outline"
  626. */
  627. public function serviceGetBlockViewProfileOutline($sProfileModule = 'bx_persons', $iProfileContentId = 0, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  628. {
  629. $sView = BX_TIMELINE_VIEW_OUTLINE;
  630. return $this->_serviceGetBlockViewProfile($sProfileModule, $iProfileContentId, $sView, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  631. }
  632. /**
  633. * @page service Service Calls
  634. * @section bx_timeline Timeline
  635. * @subsection bx_timeline-page_blocks Page Blocks
  636. * @subsubsection bx_timeline-get_block_view_home get_block_view_home
  637. *
  638. * @code bx_srv('bx_timeline', 'get_block_view_home', [...]); @endcode
  639. *
  640. * Get Timeline View block for site's Home page.
  641. *
  642. * @param $iProfileId (optional) profile ID. 0 should be used here.
  643. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  644. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  645. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  646. * @param $sFilter (optional) string value with filter name.
  647. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  648. * @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.
  649. *
  650. * @see BxTimelineModule::serviceGetBlockViewHome
  651. */
  652. /**
  653. * @ref bx_timeline-get_block_view_home "get_block_view_home"
  654. */
  655. public function serviceGetBlockViewHome($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  656. {
  657. return $this->_serviceGetBlockViewHome($iProfileId, BX_TIMELINE_VIEW_TIMELINE, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
  658. }
  659. /**
  660. * @page service Service Calls
  661. * @section bx_timeline Timeline
  662. * @subsection bx_timeline-page_blocks Page Blocks
  663. * @subsubsection bx_timeline-get_block_view_home_outline get_block_view_home_outline
  664. *
  665. * @code bx_srv('bx_timeline', 'get_block_view_home_outline', [...]); @endcode
  666. *
  667. * Get Outline View block for site's Home page.
  668. *
  669. * @param $iProfileId (optional) profile ID. 0 should be used here.
  670. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  671. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  672. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  673. * @param $sFilter (optional) string value with filter name.
  674. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  675. * @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.
  676. *
  677. * @see BxTimelineModule::serviceGetBlockViewHomeOutline
  678. */
  679. /**
  680. * @ref bx_timeline-get_block_view_home_outline "get_block_view_home_outline"
  681. */
  682. public function serviceGetBlockViewHomeOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  683. {
  684. return $this->_serviceGetBlockViewHome($iProfileId, BX_TIMELINE_VIEW_OUTLINE, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
  685. }
  686. /**
  687. * @page service Service Calls
  688. * @section bx_timeline Timeline
  689. * @subsection bx_timeline-page_blocks Page Blocks
  690. * @subsubsection bx_timeline-get_block_view_account get_block_view_account
  691. *
  692. * @code bx_srv('bx_timeline', 'get_block_view_account', [...]); @endcode
  693. *
  694. * Get Timeline View block for the Dashboard page.
  695. *
  696. * @param $iProfileId (optional) profile ID. 0 should be used here.
  697. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  698. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  699. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  700. * @param $sFilter (optional) string value with filter name.
  701. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  702. * @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.
  703. *
  704. * @see BxTimelineModule::serviceGetBlockViewAccount
  705. */
  706. /**
  707. * @ref bx_timeline-get_block_view_account "get_block_view_account"
  708. */
  709. public function serviceGetBlockViewAccount($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  710. {
  711. if(!isLogged())
  712. return '';
  713. return $this->_serviceGetBlockViewByType($iProfileId, BX_TIMELINE_VIEW_TIMELINE, BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS, $iStart, $iPerPage, $this->_oConfig->getPerPage('account'), $iTimeline, $sFilter, $aModules);
  714. }
  715. /**
  716. * @page service Service Calls
  717. * @section bx_timeline Timeline
  718. * @subsection bx_timeline-page_blocks Page Blocks
  719. * @subsubsection bx_timeline-get_block_view_account_outline get_block_view_account_outline
  720. *
  721. * @code bx_srv('bx_timeline', 'get_block_view_account_outline', [...]); @endcode
  722. *
  723. * Get Outline View block for the Dashboard page.
  724. *
  725. * @param $iProfileId (optional) profile ID. 0 should be used here.
  726. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  727. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  728. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  729. * @param $sFilter (optional) string value with filter name.
  730. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  731. * @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.
  732. *
  733. * @see BxTimelineModule::serviceGetBlockViewAccountOutline
  734. */
  735. /**
  736. * @ref bx_timeline-get_block_view_account_outline "get_block_view_account_outline"
  737. */
  738. public function serviceGetBlockViewAccountOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  739. {
  740. if(!isLogged())
  741. return '';
  742. return $this->_serviceGetBlockViewByType($iProfileId, BX_TIMELINE_VIEW_OUTLINE, BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS, $iStart, $iPerPage, $this->_oConfig->getPerPage('account'), $iTimeline, $sFilter, $aModules);
  743. }
  744. /**
  745. * @page service Service Calls
  746. * @section bx_timeline Timeline
  747. * @subsection bx_timeline-page_blocks Page Blocks
  748. * @subsubsection bx_timeline-get_block_item get_block_item
  749. *
  750. * @code bx_srv('bx_timeline', 'get_block_item', [...]); @endcode
  751. *
  752. * Get View Item block.
  753. *
  754. * @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.
  755. *
  756. * @see BxTimelineModule::serviceGetBlockItem
  757. */
  758. /**
  759. * @ref bx_timeline-get_block_item "get_block_item"
  760. */
  761. public function serviceGetBlockItem()
  762. {
  763. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  764. if(!$iItemId)
  765. return array();
  766. return $this->_oTemplate->getItemBlock($iItemId);
  767. }
  768. /**
  769. * @page service Service Calls
  770. * @section bx_timeline Timeline
  771. * @subsection bx_timeline-integration_notifications Integration with Notifications
  772. * @subsubsection bx_timeline-get_notifications_data get_notifications_data
  773. *
  774. * @code bx_srv('bx_timeline', 'get_notifications_data', [...]); @endcode
  775. *
  776. * Data for Notifications module.
  777. *
  778. * @return an array with special format.
  779. *
  780. * @see BxTimelineModule::serviceGetNotificationsData
  781. */
  782. /**
  783. * @ref bx_timeline-get_notifications_data "get_notifications_data"
  784. */
  785. public function serviceGetNotificationsData()
  786. {
  787. $sModule = $this->_aModule['name'];
  788. return array(
  789. 'handlers' => array(
  790. array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'post_common', 'module_name' => $sModule, 'module_method' => 'get_notifications_post', 'module_class' => 'Module'),
  791. array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete'),
  792. array('group' => $sModule . '_repost', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'repost', 'module_name' => $sModule, 'module_method' => 'get_notifications_repost', 'module_class' => 'Module'),
  793. array('group' => $sModule . '_repost', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete_repost'),
  794. array('group' => $sModule . '_comment', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'commentPost', 'module_name' => $sModule, 'module_method' => 'get_notifications_comment', 'module_class' => 'Module'),
  795. array('group' => $sModule . '_comment', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'commentRemoved'),
  796. array('group' => $sModule . '_vote', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_vote', 'module_class' => 'Module'),
  797. array('group' => $sModule . '_vote', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'undoVote'),
  798. ),
  799. 'alerts' => array(
  800. array('unit' => $sModule, 'action' => 'post_common'),
  801. array('unit' => $sModule, 'action' => 'delete'),
  802. array('unit' => $sModule, 'action' => 'repost'),
  803. array('unit' => $sModule, 'action' => 'delete_repost'),
  804. array('unit' => $sModule, 'action' => 'commentPost'),
  805. array('unit' => $sModule, 'action' => 'commentRemoved'),
  806. array('unit' => $sModule, 'action' => 'doVote'),
  807. array('unit' => $sModule, 'action' => 'undoVote'),
  808. )
  809. );
  810. }
  811. /**
  812. * @page service Service Calls
  813. * @section bx_timeline Timeline
  814. * @subsection bx_timeline-integration_notifications Integration with Notifications
  815. * @subsubsection bx_timeline-get_notifications_repost get_notifications_repost
  816. *
  817. * @code bx_srv('bx_timeline', 'get_notifications_repost', [...]); @endcode
  818. *
  819. * Get data for Repost event to display in Notifications module.
  820. *
  821. * @param $aEvent an array with event description.
  822. * @return an array with special format.
  823. *
  824. * @see BxTimelineModule::serviceGetNotificationsRepost
  825. */
  826. /**
  827. * @ref bx_timeline-get_notifications_repost "get_notifications_repost"
  828. */
  829. public function serviceGetNotificationsRepost($aEvent)
  830. {
  831. $aResult = $this->serviceGetNotificationsPost($aEvent);
  832. $aResult['lang_key'] = '_bx_timeline_txt_object_reposted';
  833. return $aResult;
  834. }
  835. /**
  836. * @page service Service Calls
  837. * @section bx_timeline Timeline
  838. * @subsection bx_timeline-integration_notifications Integration with Notifications
  839. * @subsubsection bx_timeline-get_notifications_post get_notifications_post
  840. *
  841. * @code bx_srv('bx_timeline', 'get_notifications_post', [...]); @endcode
  842. *
  843. * Get data for Post event to display in Notifications module.
  844. *
  845. * @param $aEvent an array with event description.
  846. * @return an array with special format.
  847. *
  848. * @see BxTimelineModule::serviceGetNotificationsPost
  849. */
  850. /**
  851. * @ref bx_timeline-get_notifications_post "get_notifications_post"
  852. */
  853. public function serviceGetNotificationsPost($aEvent)
  854. {
  855. $CNF = &$this->_oConfig->CNF;
  856. $iContent = (int)$aEvent['object_id'];
  857. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  858. if(empty($aContent) || !is_array($aContent))
  859. return array();
  860. $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description']);
  861. return array(
  862. 'entry_sample' => $CNF['T']['txt_sample_single_ext'],
  863. 'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
  864. 'entry_caption' => $sEntryCaption,
  865. 'entry_author' => $aContent['owner_id'],
  866. 'lang_key' => '_bx_timeline_ntfs_txt_object_added', //may be empty or not specified. In this case the default one from Notification module will be used.
  867. );
  868. }
  869. /**
  870. * @page service Service Calls
  871. * @section bx_timeline Timeline
  872. * @subsection bx_timeline-integration_notifications Integration with Notifications
  873. * @subsubsection bx_timeline-get_notifications_comment get_notifications_comment
  874. *
  875. * @code bx_srv('bx_timeline', 'get_notifications_comment', [...]); @endcode
  876. *
  877. * Get data for Post Comment event to display in Notifications module.
  878. *
  879. * @param $aEvent an array with event description.
  880. * @return an array with special format.
  881. *
  882. * @see BxTimelineModule::serviceGetNotificationsComment
  883. */
  884. /**
  885. * @ref bx_timeline-get_notifications_comment "get_notifications_comment"
  886. */
  887. public function serviceGetNotificationsComment($aEvent)
  888. {
  889. $CNF = &$this->_oConfig->CNF;
  890. $iContent = (int)$aEvent['object_id'];
  891. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  892. if(empty($aContent) || !is_array($aContent))
  893. return array();
  894. $oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContent);
  895. if(!$oComment || !$oComment->isEnabled())
  896. return array();
  897. $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description']);
  898. return array(
  899. 'entry_sample' => $CNF['T']['txt_sample_single'],
  900. 'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
  901. 'entry_caption' => $sEntryCaption,
  902. 'entry_author' => $aContent['owner_id'],
  903. 'subentry_sample' => $CNF['T']['txt_sample_comment_single'],
  904. 'subentry_url' => $oComment->getViewUrl((int)$aEvent['subobject_id']),
  905. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  906. );
  907. }
  908. /**
  909. * @page service Service Calls
  910. * @section bx_timeline Timeline
  911. * @subsection bx_timeline-integration_notifications Integration with Notifications
  912. * @subsubsection bx_timeline-get_notifications_vote get_notifications_vote
  913. *
  914. * @code bx_srv('bx_timeline', 'get_notifications_vote', [...]); @endcode
  915. *
  916. * Get data for Vote event to display in Notifications module.
  917. *
  918. * @param $aEvent an array with event description.
  919. * @return an array with special format.
  920. *
  921. * @see BxTimelineModule::serviceGetNotificationsVote
  922. */
  923. /**
  924. * @ref bx_timeline-get_notifications_vote "get_notifications_vote"
  925. */
  926. public function serviceGetNotificationsVote($aEvent)
  927. {
  928. $CNF = &$this->_oConfig->CNF;
  929. $iContent = (int)$aEvent['object_id'];
  930. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  931. if(empty($aContent) || !is_array($aContent))
  932. return array();
  933. $oVote = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContent);
  934. if(!$oVote || !$oVote->isEnabled())
  935. return array();
  936. $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description']);
  937. return array(
  938. 'entry_sample' => $CNF['T']['txt_sample_single'],
  939. 'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
  940. 'entry_caption' => $sEntryCaption,
  941. 'entry_author' => $aContent['owner_id'],
  942. 'subentry_sample' => $CNF['T']['txt_sample_vote_single'],
  943. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  944. );
  945. }
  946. /**
  947. * @page service Service Calls
  948. * @section bx_timeline Timeline
  949. * @subsection bx_timeline-repost Repost
  950. * @subsubsection bx_timeline-get_repost_element_block get_repost_element_block
  951. *
  952. * @code bx_srv('bx_timeline', 'get_repost_element_block', [...]); @endcode
  953. *
  954. * Get repost element for content based modules.
  955. *
  956. * @param $iOwnerId integer value with owner profile ID.
  957. * @param $sType string value with type (module name).
  958. * @param $sAction string value with action (module action).
  959. * @param $iObjectId integer value with object ID to be reposted.
  960. * @param $aParams (optional) an array with additional params.
  961. * @return HTML string with repost element to display on the site, all necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  962. *
  963. * @see BxTimelineModule::serviceGetRepostElementBlock
  964. */
  965. /**
  966. * @ref bx_timeline-get_repost_element_block "get_repost_element_block"
  967. */
  968. public function serviceGetRepostElementBlock($iOwnerId, $sType, $sAction, $iObjectId, $aParams = array())
  969. {
  970. if(!$this->isEnabled())
  971. return '';
  972. $aParams = array_merge($this->_oConfig->getRepostDefaults(), $aParams);
  973. return $this->_oTemplate->getRepostElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams);
  974. }
  975. /**
  976. * @page service Service Calls
  977. * @section bx_timeline Timeline
  978. * @subsection bx_timeline-repost Repost
  979. * @subsubsection bx_timeline-get_repost_counter get_repost_counter
  980. *
  981. * @code bx_srv('bx_timeline', 'get_repost_counter', [...]); @endcode
  982. *
  983. * Get repost counter.
  984. *
  985. * @param $sType string value with type (module name).
  986. * @param $sAction string value with action (module action).
  987. * @param $iObjectId integer value with object ID to be reposted.
  988. * @return HTML string with repost counter to display on the site, all necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  989. *
  990. * @see BxTimelineModule::serviceGetRepostCounter
  991. */
  992. /**
  993. * @ref bx_timeline-get_repost_counter "get_repost_counter"
  994. */
  995. public function serviceGetRepostCounter($sType, $sAction, $iObjectId)
  996. {
  997. if(!$this->isEnabled())
  998. return '';
  999. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  1000. return $this->_oTemplate->getRepostCounter($aReposted);
  1001. }
  1002. /**
  1003. * @page service Service Calls
  1004. * @section bx_timeline Timeline
  1005. * @subsection bx_timeline-repost Repost
  1006. * @subsubsection bx_timeline-get_repost_js_script get_repost_js_script
  1007. *
  1008. * @code bx_srv('bx_timeline', 'get_repost_js_script', [...]); @endcode
  1009. *
  1010. * Get repost JavaScript code.
  1011. *
  1012. * @return HTML string with JavaScript code to display on the site, all necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  1013. *
  1014. * @see BxTimelineModule::serviceGetRepostJsScript
  1015. */
  1016. /**
  1017. * @ref bx_timeline-get_repost_js_script "get_repost_js_script"
  1018. */
  1019. public function serviceGetRepostJsScript()
  1020. {
  1021. if(!$this->isEnabled())
  1022. return '';
  1023. return $this->_oTemplate->getRepostJsScript();
  1024. }
  1025. /**
  1026. * @page service Service Calls
  1027. * @section bx_timeline Timeline
  1028. * @subsection bx_timeline-repost Repost
  1029. * @subsubsection bx_timeline-get_repost_js_click get_repost_js_click
  1030. *
  1031. * @code bx_srv('bx_timeline', 'get_repost_js_click', [...]); @endcode
  1032. *
  1033. * Get repost JavaScript code for OnClick event.
  1034. *
  1035. * @param $iOwnerId integer value with owner profile ID.
  1036. * @param $sType string value with type (module name).
  1037. * @param $sAction string value with action (module action).
  1038. * @param $iObjectId integer value with object ID to be reposted.
  1039. * @return HTML string with JavaScript code to display in OnClick events of HTML elements.
  1040. *
  1041. * @see BxTimelineModule::serviceGetRepostJsClick
  1042. */
  1043. /**
  1044. * @ref bx_timeline-get_repost_js_click "get_repost_js_click"
  1045. */
  1046. public function serviceGetRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId)
  1047. {
  1048. if(!$this->isEnabled())
  1049. return '';
  1050. return $this->_oTemplate->getRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId);
  1051. }
  1052. /**
  1053. * @page service Service Calls
  1054. * @section bx_timeline Timeline
  1055. * @subsection bx_timeline-other Other
  1056. * @subsubsection bx_timeline-get_menu_item_addon_comment get_menu_item_addon_comment
  1057. *
  1058. * @code bx_srv('bx_timeline', 'get_menu_item_addon_comment', [...]); @endcode
  1059. *
  1060. * Get addon for Comment menu item.
  1061. *
  1062. * @param $sSystem string value with comments engine system.
  1063. * @param $iObjectId integer value with object ID.
  1064. * @return HTML string to display in menu item.
  1065. *
  1066. * @see BxTimelineModule::serviceGetMenuItemAddonComment
  1067. */
  1068. /**
  1069. * @ref bx_timeline-get_menu_item_addon_comment "get_menu_item_addon_comment"
  1070. */
  1071. public function serviceGetMenuItemAddonComment($sSystem, $iObjectId)
  1072. {
  1073. if(empty($sSystem) || empty($iObjectId))
  1074. return '';
  1075. $oCmts = $this->getCmtsObject($sSystem, $iObjectId);
  1076. if($oCmts === false)
  1077. return '';
  1078. $iCounter = (int)$oCmts->getCommentsCount();
  1079. return $this->_oTemplate->parseLink('javascript:void(0)', $iCounter > 0 ? $iCounter : '', array(
  1080. 'title' => _t('_bx_timeline_menu_item_title_item_comment'),
  1081. 'onclick' => "javascript:" . $this->_oConfig->getJsObject('view') . ".commentItem(this, '" . $sSystem . "', " . $iObjectId . ")"
  1082. ));
  1083. }
  1084. /**
  1085. * @page service Service Calls
  1086. * @section bx_timeline Timeline
  1087. * @subsection bx_timeline-other Other
  1088. * @subsubsection bx_timeline-get_settings_checker_helper get_settings_checker_helper
  1089. *
  1090. * @code bx_srv('bx_timeline', 'get_settings_checker_helper', [...]); @endcode
  1091. *
  1092. * Get Checker Helper class name for Forms engine.
  1093. *
  1094. * @return string with Checker Helper class name.
  1095. *
  1096. * @see BxTimelineModule::serviceGetSettingsCheckerHelper
  1097. */
  1098. /**
  1099. * @ref bx_timeline-get_settings_checker_helper "get_settings_checker_helper"
  1100. */
  1101. public function serviceGetSettingsCheckerHelper()
  1102. {
  1103. bx_import('FormCheckerHelper', $this->_aModule);
  1104. return 'BxTimelineFormCheckerHelper';
  1105. }
  1106. /*
  1107. * COMMON METHODS
  1108. */
  1109. public function deleteEvent($aEvent)
  1110. {
  1111. if(empty($aEvent) || !is_array($aEvent) || !$this->_oDb->deleteEvent(array('id' => (int)$aEvent['id'])))
  1112. return false;
  1113. $this->onDelete($aEvent);
  1114. return true;
  1115. }
  1116. public function getFormAttachLink()
  1117. {
  1118. $iUserId = $this->getUserId();
  1119. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_attach_link'), $this->_oConfig->getObject('form_display_attach_link_add'), $this->_oTemplate);
  1120. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'add_attach_link/';
  1121. $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url');
  1122. $oForm->initChecker();
  1123. if($oForm->isSubmittedAndValid()) {
  1124. $sLink = $oForm->getCleanValue('url');
  1125. $aMatches = array();
  1126. preg_match($this->_oConfig->getPregPattern('url'), $sLink, $aMatches);
  1127. $sLink = (empty($aMatches[2]) ? 'http://' : '') . $aMatches[0];
  1128. $aSiteInfo = bx_get_site_info($sLink, array(
  1129. 'thumbnailUrl' => array('tag' => 'link', 'content_attr' => 'href'),
  1130. 'OGImage' => array('name_attr' => 'property', 'name' => 'og:image'),
  1131. ));
  1132. $sTitle = !empty($aSiteInfo['title']) ? $aSiteInfo['title'] : _t('_Empty');
  1133. $sDescription = !empty($aSiteInfo['description']) ? $aSiteInfo['description'] : _t('_Empty');
  1134. $sMediaUrl = '';
  1135. if(!empty($aSiteInfo['thumbnailUrl']))
  1136. $sMediaUrl = $aSiteInfo['thumbnailUrl'];
  1137. else if(!empty($aSiteInfo['OGImage']))
  1138. $sMediaUrl = $aSiteInfo['OGImage'];
  1139. $iMediaId = 0;
  1140. $oStorage = null;
  1141. if(!empty($sMediaUrl)) {
  1142. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . BX_TIMELINE_MEDIA_PHOTO . 's'));
  1143. $iMediaId = $oStorage->storeFileFromUrl($sMediaUrl, true, $iUserId);
  1144. }
  1145. $iId = (int)$oForm->insert(array('profile_id' => $iUserId, 'media_id' => $iMediaId, 'url' => $sLink, 'title' => $sTitle, 'text' => $sDescription, 'added' => time()));
  1146. if(!empty($iId)) {
  1147. if(!empty($oStorage) && !empty($iMediaId))
  1148. $oStorage->afterUploadCleanup($iMediaId, $iUserId);
  1149. return array('item' => $this->_oTemplate->getAttachLinkItem($iUserId, $iId));
  1150. }
  1151. return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
  1152. }
  1153. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  1154. }
  1155. public function getFormPost($aParams = array())
  1156. {
  1157. $iUserId = $this->getUserId();
  1158. $sFormObject = !empty($aParams['form_object']) ? $aParams['form_object'] : 'form_post';
  1159. $sFormDisplay = !empty($aParams['form_display']) ? $aParams['form_display'] : 'form_display_post_add';
  1160. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject($sFormObject), $this->_oConfig->getObject($sFormDisplay), $this->_oTemplate);
  1161. $oForm->initChecker();
  1162. if($oForm->isSubmittedAndValid()) {
  1163. list($sUserName) = $this->getUserInfo($iUserId);
  1164. $sType = $oForm->getCleanValue('type');
  1165. $sType = $this->_oConfig->getPrefix('common_post') . $sType;
  1166. BxDolForm::setSubmittedValue('type', $sType, $oForm->aFormAttrs['method']);
  1167. $aContent = array();
  1168. //--- Process Text ---//
  1169. $sText = $oForm->getCleanValue('text');
  1170. $sText = $this->_prepareTextForSave($sText);
  1171. $bText = !empty($sText);
  1172. unset($oForm->aInputs['text']);
  1173. if($bText)
  1174. $aContent['text'] = $sText;
  1175. //--- Process Privacy ---//
  1176. $iObjectPrivacyView = (int)$oForm->getCleanValue('object_privacy_view');
  1177. if(empty($iObjectPrivacyView))
  1178. $iObjectPrivacyView = $this->_oConfig->getPrivacyViewDefault('object');
  1179. //--- Process Link ---//
  1180. $aLinkIds = $oForm->getCleanValue('link');
  1181. $bLinkIds = !empty($aLinkIds) && is_array($aLinkIds);
  1182. //--- Process Media ---//
  1183. $aPhotoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_PHOTO);
  1184. $bPhotoIds = !empty($aPhotoIds) && is_array($aPhotoIds);
  1185. $aVideoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_VIDEO);
  1186. $bVideoIds = !empty($aVideoIds) && is_array($aVideoIds);
  1187. if(!$bText && !$bLinkIds && !$bPhotoIds && !$bVideoIds)
  1188. return array('message' => _t('_bx_timeline_txt_err_empty_post'));
  1189. $sTitle = $bText ? $this->_oConfig->getTitle($sText) : $this->_oTemplate->getItemIcon($bText, $bLinkIds, $bPhotoIds, $bVideoIds);
  1190. $sDescription = _t('_bx_timeline_txt_user_added_sample', $sUserName, _t('_bx_timeline_txt_sample_with_article'));
  1191. $iId = $oForm->insert(array(
  1192. 'object_id' => $iUserId,
  1193. 'object_privacy_view' => $iObjectPrivacyView,
  1194. 'content' => serialize($aContent),
  1195. 'title' => $sTitle,
  1196. 'description' => $sDescription,
  1197. 'date' => time()
  1198. ));
  1199. if(!empty($iId)) {
  1200. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  1201. if($bText)
  1202. $oMetatags->keywordsAdd($iId, $sText);
  1203. $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
  1204. //--- Process Link ---//
  1205. if($bLinkIds)
  1206. foreach($aLinkIds as $iLinkId)
  1207. $this->_oDb->saveLink($iId, $iLinkId);
  1208. //--- Process Media ---//
  1209. if($bPhotoIds)
  1210. $this->_saveMedia(BX_TIMELINE_MEDIA_PHOTO, $iId, $aPhotoIds);
  1211. if($bVideoIds)
  1212. $this->_saveMedia(BX_TIMELINE_MEDIA_VIDEO, $iId, $aVideoIds);
  1213. $this->onPost($iId);
  1214. return array('id' => $iId);
  1215. }
  1216. return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
  1217. }
  1218. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  1219. }
  1220. public function getCmtsObject($sSystem, $iId)
  1221. {
  1222. if(empty($sSystem) || (int)$iId == 0)
  1223. return false;
  1224. $oCmts = BxDolCmts::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1225. if(!$oCmts || !$oCmts->isEnabled())
  1226. return false;
  1227. return $oCmts;
  1228. }
  1229. public function getViewObject($sSystem, $iId)
  1230. {
  1231. if(empty($sSystem) || (int)$iId == 0)
  1232. return false;
  1233. $oView = BxDolView::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1234. if(!$oView || !$oView->isEnabled())
  1235. return false;
  1236. return $oView;
  1237. }
  1238. public function getVoteObject($sSystem, $iId)
  1239. {
  1240. if(empty($sSystem) || (int)$iId == 0)
  1241. return false;
  1242. $oVote = BxDolVote::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1243. if(!$oVote || !$oVote->isEnabled())
  1244. return false;
  1245. return $oVote;
  1246. }
  1247. public function getReportObject($sSystem, $iId)
  1248. {
  1249. if(empty($sSystem) || (int)$iId == 0)
  1250. return false;
  1251. $oReport = BxDolReport::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1252. if(!$oReport || !$oReport->isEnabled())
  1253. return false;
  1254. return $oReport;
  1255. }
  1256. public function getAttachmentsMenuObject()
  1257. {
  1258. $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_post_attachments'), $this->_oTemplate);
  1259. $oMenu->addMarkers(array(
  1260. 'js_object' => $this->_oConfig->getJsObject('post'),
  1261. ));
  1262. return $oMenu;
  1263. }
  1264. public function getManageMenuObject()
  1265. {
  1266. return BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_manage'), $this->_oTemplate);
  1267. }
  1268. //--- Check permissions methods ---//
  1269. public function isAllowedPost($bPerform = false)
  1270. {
  1271. if(isAdmin())
  1272. return true;
  1273. $iUserId = $this->getUserId();
  1274. $aCheckResult = checkActionModule($iUserId, 'post', $this->getName(), $bPerform);
  1275. $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
  1276. if($oProfileOwner !== false) {
  1277. if($oProfileOwner->checkAllowedPostInProfile() !== CHECK_ACTION_RESULT_ALLOWED)
  1278. return _t('_sys_txt_access_denied');
  1279. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_post', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1280. }
  1281. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1282. }
  1283. public function isAllowedView($aEvent, $bPerform = false)
  1284. {
  1285. $CNF = $this->_oConfig->CNF;
  1286. $mixedResult = BxDolProfile::getInstance($aEvent[$CNF['FIELD_OWNER_ID']])->checkAllowedProfileView();
  1287. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  1288. return false;
  1289. return true;
  1290. }
  1291. public function isAllowedDelete($aEvent, $bPerform = false)
  1292. {
  1293. if(!isLogged())
  1294. return false;
  1295. if(isAdmin())
  1296. return true;
  1297. $iUserId = (int)$this->getUserId();
  1298. if((int)$aEvent['owner_id'] == $iUserId && $this->_oConfig->isAllowDelete())
  1299. return true;
  1300. $aCheckResult = checkActionModule($iUserId, 'delete', $this->getName(), $bPerform);
  1301. $oProfileOwner = BxDolProfile::getInstance((int)$aEvent['owner_id']);
  1302. if($oProfileOwner !== false)
  1303. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_delete', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1304. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1305. }
  1306. public function isAllowedComment($aEvent, $bPerform = false)
  1307. {
  1308. $mixedComments = $this->getCommentsData($aEvent['comments']);
  1309. if($mixedComments === false)
  1310. return false;
  1311. list($sSystem, $iObjectId) = $mixedComments;
  1312. $oCmts = $this->getCmtsObject($sSystem, $iObjectId);
  1313. $oCmts->addCssJs();
  1314. $bResult = true;
  1315. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1316. if($oProfileOwner !== false) {
  1317. if($oProfileOwner->checkAllowedPostInProfile() !== CHECK_ACTION_RESULT_ALLOWED)
  1318. return false;
  1319. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_comment', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1320. }
  1321. return $bResult;
  1322. }
  1323. public function isAllowedViewCounter($aEvent, $bPerform = false)
  1324. {
  1325. $mixedViews = $this->getViewsData($aEvent['views']);
  1326. if($mixedViews === false)
  1327. return false;
  1328. list($sSystem, $iObjectId) = $mixedViews;
  1329. $oView = $this->getViewObject($sSystem, $iObjectId);
  1330. $bResult = true;
  1331. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1332. if($oProfileOwner !== false)
  1333. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view_counter', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1334. return $bResult;
  1335. }
  1336. public function isAllowedVote($aEvent, $bPerform = false)
  1337. {
  1338. $mixedVotes = $this->getVotesData($aEvent['votes']);
  1339. if($mixedVotes === false)
  1340. return false;
  1341. list($sSystem, $iObjectId) = $mixedVotes;
  1342. $oVote = $this->getVoteObject($sSystem, $iObjectId);
  1343. $oVote->addCssJs();
  1344. $bResult = true;
  1345. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1346. if($oProfileOwner !== false)
  1347. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1348. return $bResult;
  1349. }
  1350. public function isAllowedReport($aEvent, $bPerform = false)
  1351. {
  1352. $mixedReports = $this->getReportsData($aEvent['reports']);
  1353. if($mixedReports === false)
  1354. return false;
  1355. list($sSystem, $iObjectId) = $mixedReports;
  1356. $oReport = $this->getReportObject($sSystem, $iObjectId);
  1357. $oReport->addCssJs();
  1358. $bResult = true;
  1359. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1360. if($oProfileOwner !== false)
  1361. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_report', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1362. return $bResult;
  1363. }
  1364. public function isAllowedRepost($aEvent, $bPerform = false)
  1365. {
  1366. if(isAdmin())
  1367. return true;
  1368. $iUserId = (int)$this->getUserId();
  1369. if($iUserId == 0)
  1370. return false;
  1371. $aCheckResult = checkActionModule($iUserId, 'repost', $this->getName(), $bPerform);
  1372. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1373. if($oProfileOwner !== false)
  1374. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_repost', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1375. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1376. }
  1377. public function isAllowedSend($aEvent, $bPerform = false)
  1378. {
  1379. if(isAdmin())
  1380. return true;
  1381. $iUserId = (int)$this->getUserId();
  1382. if($iUserId == 0)
  1383. return false;
  1384. $aCheckResult = checkActionModule($iUserId, 'send', $this->getName(), $bPerform);
  1385. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1386. if($oProfileOwner !== false)
  1387. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_send', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1388. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1389. }
  1390. public function isAllowedPin($aEvent, $bPerform = false)
  1391. {
  1392. if((int)$aEvent['pinned'] != 0)
  1393. return false;
  1394. return $this->_isAllowedPin($aEvent, $bPerform);
  1395. }
  1396. public function isAllowedUnpin($aEvent, $bPerform = false)
  1397. {
  1398. if((int)$aEvent['pinned'] == 0)
  1399. return false;
  1400. return $this->_isAllowedPin($aEvent, $bPerform);
  1401. }
  1402. public function isAllowedMore($aEvent, $bPerform = false)
  1403. {
  1404. $oMoreMenu = $this->getManageMenuObject();
  1405. $oMoreMenu->setEventId($aEvent['id']);
  1406. return $oMoreMenu->isVisible();
  1407. }
  1408. public function checkAllowedView ($aContentInfo, $isPerformAction = false)
  1409. {
  1410. if(!$this->isAllowedView($aContentInfo, $isPerformAction))
  1411. return _t('_sys_txt_access_denied');
  1412. return CHECK_ACTION_RESULT_ALLOWED;
  1413. }
  1414. public function checkAllowedCommentsView ($aContentInfo, $isPerformAction = false)
  1415. {
  1416. $CNF = $this->_oConfig->CNF;
  1417. $mixedResult = BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_OWNER_ID']])->checkAllowedProfileView();
  1418. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  1419. return $mixedResult;
  1420. return CHECK_ACTION_RESULT_ALLOWED;
  1421. }
  1422. public function checkAllowedCommentsPost ($aContentInfo, $isPerformAction = false)
  1423. {
  1424. $sError = '_sys_txt_access_denied';
  1425. $aContentInfo = $this->_oTemplate->getData($aContentInfo);
  1426. if($aContentInfo === false)
  1427. return _t($sError);
  1428. if(!$this->isAllowedComment($aContentInfo, $isPerformAction))
  1429. return _t($sError);
  1430. return CHECK_ACTION_RESULT_ALLOWED;
  1431. }
  1432. public function onPost($iId)
  1433. {
  1434. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  1435. if($this->_oConfig->isSystem($aEvent['type'], $aEvent['action'])) {
  1436. //--- Request event's data from content module and update it in the Timeline DB.
  1437. $this->_oTemplate->getData($aEvent);
  1438. $sPostType = 'system';
  1439. $iSenderId = $aEvent['owner_id'];
  1440. } else {
  1441. $sPostType = 'common';
  1442. $iSenderId = $aEvent['object_id'];
  1443. }
  1444. //--- Event -> Post for Alerts Engine ---//
  1445. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'post_' . $sPostType, $iId, $iSenderId, array(
  1446. 'privacy_view' => $aEvent['object_privacy_view'],
  1447. 'object_author_id' => $aEvent['owner_id'],
  1448. ));
  1449. $oAlert->alert();
  1450. //--- Event -> Post for Alerts Engine ---//
  1451. }
  1452. public function onRepost($iId, $aReposted = array())
  1453. {
  1454. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  1455. if(empty($aReposted)) {
  1456. $aContent = unserialize($aEvent['content']);
  1457. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  1458. if(empty($aReposted) || !is_array($aReposted))
  1459. return;
  1460. }
  1461. $iUserId = $this->getUserId();
  1462. $this->_oDb->insertRepostTrack($aEvent['id'], $iUserId, $this->getUserIp(), $aReposted['id']);
  1463. $this->_oDb->updateRepostCounter($aReposted['id'], $aReposted['reposts']);
  1464. //--- Timeline -> Update for Alerts Engine ---//
  1465. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'repost', $aReposted['id'], $iUserId, array(
  1466. 'privacy_view' => $aEvent['object_privacy_view'],
  1467. 'object_author_id' => $aReposted['owner_id'],
  1468. 'repost_id' => $iId,
  1469. ));
  1470. $oAlert->alert();
  1471. //--- Timeline -> Update for Alerts Engine ---//
  1472. }
  1473. public function onDelete($aEvent)
  1474. {
  1475. $iUserId = $this->getUserId();
  1476. $sCommonPostPrefix = $this->_oConfig->getPrefix('common_post');
  1477. //--- Delete attached photos, videos and links when common event was deleted.
  1478. if($aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_POST) {
  1479. $this->_deleteMedia(BX_TIMELINE_MEDIA_PHOTO, $aEvent['id']);
  1480. $this->_deleteMedia(BX_TIMELINE_MEDIA_VIDEO, $aEvent['id']);
  1481. $this->_deleteLinks($aEvent['id']);
  1482. }
  1483. //--- Update parent event when repost event was deleted.
  1484. $bRepost = $aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_REPOST;
  1485. if($bRepost) {
  1486. $this->_oDb->deleteRepostTrack($aEvent['id']);
  1487. $aContent = unserialize($aEvent['content']);
  1488. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  1489. if(!empty($aReposted) && is_array($aReposted))
  1490. $this->_oDb->updateRepostCounter($aReposted['id'], $aReposted['reposts'], -1);
  1491. }
  1492. //--- Find and delete repost events when parent event was deleted.
  1493. $bSystem = $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']);
  1494. $aRepostEvents = $this->_oDb->getEvents(array('browse' => 'reposted_by_descriptor', 'type' => $aEvent['type']));
  1495. foreach($aRepostEvents as $aRepostEvent) {
  1496. $aContent = unserialize($aRepostEvent['content']);
  1497. 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'])) && (int)$this->_oDb->deleteEvent(array('id' => (int)$aRepostEvent['id'])) > 0) {
  1498. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'delete_repost', $aEvent['id'], $iUserId, array(
  1499. 'repost_id' => $aRepostEvent['id'],
  1500. ));
  1501. $oAlert->alert();
  1502. }
  1503. }
  1504. //--- Delete associated meta.
  1505. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  1506. $oMetatags->onDeleteContent($aEvent['id']);
  1507. //--- Event -> Delete for Alerts Engine ---//
  1508. if($bRepost)
  1509. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'delete_repost', $aReposted['id'], $iUserId, array(
  1510. 'repost_id' => $aEvent['id'],
  1511. ));
  1512. else
  1513. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'delete', $aEvent['id'], $iUserId);
  1514. $oAlert->alert();
  1515. //--- Event -> Delete for Alerts Engine ---//
  1516. }
  1517. public function getParams($sView = '', $sType = '', $iOwnerId = 0, $iStart = 0, $iPerPage = 0, $sFilter = '', $aModules = array(), $iTimeline = 0)
  1518. {
  1519. return $this->_prepareParams($sView, $sType, $iOwnerId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  1520. }
  1521. public function getViewsData(&$aViews)
  1522. {
  1523. if(empty($aViews) || !is_array($aViews))
  1524. return false;
  1525. $sSystem = isset($aViews['system']) ? $aViews['system'] : '';
  1526. $iObjectId = isset($aViews['object_id']) ? (int)$aViews['object_id'] : 0;
  1527. $iCount = isset($aViews['count']) ? (int)$aViews['count'] : 0;
  1528. if($sSystem == '' || $iObjectId == 0)
  1529. return false;
  1530. return array($sSystem, $iObjectId, $iCount);
  1531. }
  1532. public function getVotesData(&$aVotes)
  1533. {
  1534. if(empty($aVotes) || !is_array($aVotes))
  1535. return false;
  1536. $sSystem = isset($aVotes['system']) ? $aVotes['system'] : '';
  1537. $iObjectId = isset($aVotes['object_id']) ? (int)$aVotes['object_id'] : 0;
  1538. $iCount = isset($aVotes['count']) ? (int)$aVotes['count'] : 0;
  1539. if($sSystem == '' || $iObjectId == 0)
  1540. return false;
  1541. return array($sSystem, $iObjectId, $iCount);
  1542. }
  1543. public function getReportsData(&$aReports)
  1544. {
  1545. if(empty($aReports) || !is_array($aReports))
  1546. return false;
  1547. $sSystem = isset($aReports['system']) ? $aReports['system'] : '';
  1548. $iObjectId = isset($aReports['object_id']) ? (int)$aReports['object_id'] : 0;
  1549. $iCount = isset($aReports['count']) ? (int)$aReports['count'] : 0;
  1550. if($sSystem == '' || $iObjectId == 0)
  1551. return false;
  1552. return array($sSystem, $iObjectId, $iCount);
  1553. }
  1554. public function getCommentsData(&$aComments)
  1555. {
  1556. if(empty($aComments) || !is_array($aComments))
  1557. return false;
  1558. $sSystem = isset($aComments['system']) ? $aComments['system'] : '';
  1559. $iObjectId = isset($aComments['object_id']) ? (int)$aComments['object_id'] : 0;
  1560. $iCount = isset($aComments['count']) ? (int)$aComments['count'] : 0;
  1561. if($sSystem == '' || $iObjectId == 0 || ($iCount == 0 && !isLogged()))
  1562. return false;
  1563. return array($sSystem, $iObjectId, $iCount);
  1564. }
  1565. /**
  1566. * Protected Methods
  1567. */
  1568. protected function _serviceGetBlockView($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT)
  1569. {
  1570. if(empty($iProfileId) && bx_get('profile_id') !== false)
  1571. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  1572. if(empty($iProfileId) && isLogged())
  1573. $iProfileId = bx_get_logged_profile_id();
  1574. $aBlock = $this->_getBlockView($iProfileId, $sView);
  1575. if(!empty($aBlock))
  1576. return $aBlock;
  1577. return array('content' => MsgBox(_t('_bx_timeline_txt_msg_no_results')));
  1578. }
  1579. protected function _serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  1580. {
  1581. if(empty($sProfileModule))
  1582. return array();
  1583. if(empty($iProfileContentId) && bx_get('id') !== false)
  1584. $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1585. $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
  1586. if(empty($oProfile))
  1587. return array();
  1588. return $this->_getBlockView($oProfile->id(), $sView, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  1589. }
  1590. protected function _serviceGetBlockViewHome($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $iPerPageDefault = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  1591. {
  1592. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_BASE_MOD_NTFS_TYPE_PUBLIC . '/';
  1593. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view_home'), $sRssUrl);
  1594. return $this->_serviceGetBlockViewByType($iProfileId, $sView, BX_BASE_MOD_NTFS_TYPE_PUBLIC, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
  1595. }
  1596. protected function _serviceGetBlockViewByType($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $sType = BX_TIMELINE_TYPE_DEFAULT, $iStart = -1, $iPerPage = -1, $iPerPageDefault = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  1597. {
  1598. $aParams = $this->_prepareParams($sView, $sType, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  1599. $aParams['view'] = $sView;
  1600. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : ((int)$iPerPageDefault > 0 ? $iPerPageDefault : $this->_oConfig->getPerPage());
  1601. $this->_iOwnerId = $aParams['owner_id'];
  1602. $sContent = $this->_oTemplate->getViewBlock($aParams);
  1603. return array('content' => $sContent);
  1604. }
  1605. protected function _getBlockPost($iProfileId, $aParams = array())
  1606. {
  1607. $this->_iOwnerId = $iProfileId;
  1608. if($this->isAllowedPost() !== true)
  1609. return array();
  1610. $sContent = $this->_oTemplate->getPostBlock($this->_iOwnerId, $aParams);
  1611. return array('content' => $sContent);
  1612. }
  1613. protected function _getBlockView($iProfileId, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  1614. {
  1615. if(!$iProfileId)
  1616. return array();
  1617. $aParams = $this->_prepareParams($sView, BX_BASE_MOD_NTFS_TYPE_OWNER, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  1618. $aParams['view'] = $sView;
  1619. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage('profile');
  1620. $this->_iOwnerId = $aParams['owner_id'];
  1621. $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
  1622. $mixedResult = $oProfileOwner->checkAllowedProfileView();
  1623. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  1624. return array('content' => MsgBox($mixedResult));
  1625. list($sUserName, $sUserUrl) = $this->getUserInfo($aParams['owner_id']);
  1626. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_BASE_MOD_NTFS_TYPE_OWNER . '/' . $iProfileId . '/';
  1627. $sJsObject = $this->_oConfig->getJsObject('view');
  1628. $aMenu = array(
  1629. array('id' => $sView . '-view-all', 'name' => $sView . '-view-all', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_all'), 'active' => 1),
  1630. array('id' => $sView . '-view-owner', 'name' => $sView . '-view-owner', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_owner', $sUserName)),
  1631. array('id' => $sView . '-view-other', 'name' => $sView . '-view-other', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_other')),
  1632. array('id' => $sView . '-get-rss', 'name' => $sView . '-get-rss', 'class' => '', 'link' => $sRssUrl, 'target' => '_blank', 'title' => _t('_bx_timeline_menu_item_get_rss')),
  1633. );
  1634. $sContent = '';
  1635. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view', $this->_iOwnerId, $this->getUserId(), array('override_content' => &$sContent, 'params' => &$aParams, 'menu' => &$aMenu));
  1636. $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> $sView . '-view-all', 'menu_items' => $aMenu));
  1637. $oMenu->setSelected('', $sView . '-view-all');
  1638. if (!$sContent)
  1639. $sContent = $this->_oTemplate->getViewBlock($aParams);
  1640. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view'), $sRssUrl);
  1641. return array('content' => $sContent, 'menu' => $oMenu);
  1642. }
  1643. protected function _isAllowedPin($aEvent, $bPerform = false)
  1644. {
  1645. if(isAdmin())
  1646. return true;
  1647. $iUserId = (int)$this->getUserId();
  1648. if($iUserId == 0)
  1649. return false;
  1650. if((int)$aEvent['owner_id'] == $iUserId)
  1651. return true;
  1652. $aCheckResult = checkActionModule($iUserId, 'pin', $this->getName(), $bPerform);
  1653. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1654. if($oProfileOwner !== false)
  1655. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_pin', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1656. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1657. }
  1658. protected function _deleteLinks($iId)
  1659. {
  1660. $aLinks = $this->_oDb->getLinks($iId);
  1661. if(empty($aLinks) || !is_array($aLinks))
  1662. return;
  1663. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'));
  1664. foreach($aLinks as $aLink)
  1665. if(!empty($aLink['media_id']))
  1666. $oStorage->deleteFile($aLink['media_id']);
  1667. $this->_oDb->deleteLinks($iId);
  1668. }
  1669. protected function _saveMedia($sType, $iId, $aItemIds)
  1670. {
  1671. if(empty($aItemIds) || !is_array($aItemIds))
  1672. return;
  1673. $iUserId = $this->getUserId();
  1674. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
  1675. foreach($aItemIds as $iItemId)
  1676. if($this->_oDb->saveMedia($sType, $iId, $iItemId))
  1677. $oStorage->afterUploadCleanup($iItemId, $iUserId);
  1678. }
  1679. protected function _deleteMedia($sType, $iId)
  1680. {
  1681. $aItems = $this->_oDb->getMedia($sType, $iId);
  1682. if(empty($aItems) || !is_array($aItems))
  1683. return;
  1684. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
  1685. foreach($aItems as $iItemId)
  1686. $oStorage->deleteFile($iItemId);
  1687. $this->_oDb->deleteMedia($sType, $iId);
  1688. }
  1689. protected function _prepareParams($sView, $sType, $iOwnerId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline)
  1690. {
  1691. return array(
  1692. 'view' => !empty($sView) ? $sView : BX_TIMELINE_VIEW_DEFAULT,
  1693. 'browse' => 'list',
  1694. 'type' => !empty($sType) ? $sType : BX_TIMELINE_TYPE_DEFAULT,
  1695. 'owner_id' => (int)$iOwnerId != 0 ? $iOwnerId : $this->getUserId(),
  1696. 'filter' => !empty($sFilter) ? $sFilter : BX_TIMELINE_FILTER_ALL,
  1697. 'modules' => is_array($aModules) && !empty($aModules) ? $aModules : array(),
  1698. 'timeline' => (int)$iTimeline > 0 ? $iTimeline : 0,
  1699. 'active' => 1,
  1700. 'hidden' => 0,
  1701. 'start' => (int)$iStart > 0 ? $iStart : 0,
  1702. 'per_page' => (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage(),
  1703. );
  1704. }
  1705. protected function _prepareParamsGet()
  1706. {
  1707. $aParams = array(
  1708. 'browse' => 'list',
  1709. 'dynamic_mode' => true,
  1710. );
  1711. $aParams['view'] = bx_get('view');
  1712. $aParams['view'] = $aParams['view'] !== false ? bx_process_input($aParams['view'], BX_DATA_TEXT) : BX_TIMELINE_VIEW_DEFAULT;
  1713. $aParams['type'] = bx_get('type');
  1714. $aParams['type'] = $aParams['type'] !== false ? bx_process_input($aParams['type'], BX_DATA_TEXT) : BX_TIMELINE_TYPE_DEFAULT;
  1715. $aParams['owner_id'] = bx_get('owner_id');
  1716. $aParams['owner_id'] = $aParams['owner_id'] !== false ? bx_process_input($aParams['owner_id'], BX_DATA_INT) : $this->getUserId();
  1717. $aParams['start'] = bx_get('start');
  1718. $aParams['start'] = $aParams['start'] !== false ? bx_process_input($aParams['start'], BX_DATA_INT) : 0;
  1719. $aParams['per_page'] = bx_get('per_page');
  1720. $aParams['per_page'] = $aParams['per_page'] !== false ? bx_process_input($aParams['per_page'], BX_DATA_INT) : $this->_oConfig->getPerPage();
  1721. $aParams['filter'] = bx_get('filter');
  1722. $aParams['filter'] = $aParams['filter'] !== false ? bx_process_input($aParams['filter'], BX_DATA_TEXT) : BX_TIMELINE_FILTER_ALL;
  1723. $aParams['modules'] = bx_get('modules');
  1724. $aParams['modules'] = $aParams['modules'] !== false ? bx_process_input($aParams['modules'], BX_DATA_TEXT) : array();
  1725. $aParams['timeline'] = bx_get('timeline');
  1726. $aParams['timeline'] = $aParams['timeline'] !== false ? bx_process_input($aParams['timeline'], BX_DATA_INT) : 0;
  1727. $aParams['active'] = 1;
  1728. $aParams['hidden'] = 0;
  1729. return $aParams;
  1730. }
  1731. protected function _prepareTextForSave($s)
  1732. {
  1733. return bx_process_input($s, BX_DATA_TEXT_MULTILINE);
  1734. }
  1735. protected function _getFieldValue($sField, $iContentId)
  1736. {
  1737. $CNF = &$this->_oConfig->CNF;
  1738. if(empty($CNF[$sField]))
  1739. return false;
  1740. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  1741. if(empty($aEvent) || empty($aEvent[$CNF[$sField]]))
  1742. return false;
  1743. return $aEvent[$CNF[$sField]];
  1744. }
  1745. }
  1746. /** @} */