BxTimelineModule.php 82 KB

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