BxTimelineModule.php 119 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065
  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_HOT', 'hot');
  16. define('BX_TIMELINE_TYPE_DEFAULT', BX_BASE_MOD_NTFS_TYPE_OWNER);
  17. define('BX_TIMELINE_VIEW_ITEM', 'item');
  18. define('BX_TIMELINE_VIEW_TIMELINE', 'timeline');
  19. define('BX_TIMELINE_VIEW_OUTLINE', 'outline');
  20. define('BX_TIMELINE_VIEW_SEARCH', 'search');
  21. define('BX_TIMELINE_VIEW_DEFAULT', BX_TIMELINE_VIEW_OUTLINE);
  22. define('BX_TIMELINE_FILTER_ALL', 'all');
  23. define('BX_TIMELINE_FILTER_OWNER', 'owner');
  24. define('BX_TIMELINE_FILTER_OTHER', 'other');
  25. define('BX_TIMELINE_FILTER_OTHER_VIEWER', 'other_viewer');
  26. define('BX_TIMELINE_PARSE_TYPE_POST', 'post');
  27. define('BX_TIMELINE_PARSE_TYPE_REPOST', 'repost');
  28. define('BX_TIMELINE_PARSE_TYPE_DEFAULT', BX_TIMELINE_PARSE_TYPE_POST);
  29. define('BX_TIMELINE_MEDIA_PHOTO', 'photo');
  30. define('BX_TIMELINE_MEDIA_VIDEO', 'video');
  31. //--- Video Auto Play
  32. define('BX_TIMELINE_VAP_OFF', 'off');
  33. define('BX_TIMELINE_VAP_ON_MUTE', 'on_mute');
  34. define('BX_TIMELINE_VAP_ON', 'on');
  35. class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolContentInfoService
  36. {
  37. protected $_sJsPostObject;
  38. protected $_sJsViewObject;
  39. protected $_aPostElements;
  40. protected $_sJsOutlineObject;
  41. protected $_sDividerTemplate;
  42. protected $_sBalloonTemplate;
  43. protected $_sCmtPostTemplate;
  44. protected $_sCmtViewTemplate;
  45. protected $_sCmtTemplate;
  46. /**
  47. * Constructor
  48. */
  49. function __construct($aModule)
  50. {
  51. parent::__construct($aModule);
  52. }
  53. /**
  54. * ACTION METHODS
  55. */
  56. public function actionVideo($iEventId, $iVideoId)
  57. {
  58. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iEventId));
  59. if(empty($aEvent) || !is_array($aEvent))
  60. return;
  61. $aData = $this->_oTemplate->getData($aEvent);
  62. if($aData === false || !isset($aData['content']['videos'][$iVideoId]))
  63. return;
  64. $oTemplate = $this->_oTemplate;
  65. $oTemplate->setPageNameIndex (BX_PAGE_CLEAR);
  66. $oTemplate->setPageContent ('page_main_code', $this->_oTemplate->getVideo($aEvent, $aData['content']['videos'][$iVideoId]));
  67. $oTemplate->getPageCode();
  68. }
  69. public function actionPost()
  70. {
  71. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  72. $mixedAllowed = $this->isAllowedPost(true);
  73. if($mixedAllowed !== true)
  74. return echoJson(array('message' => strip_tags($mixedAllowed)));
  75. echoJson($this->getFormPost());
  76. }
  77. public function actionEdit($iId)
  78. {
  79. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  80. $mixedAllowed = $this->isAllowedPost(true);
  81. if($mixedAllowed !== true)
  82. return echoJson(array('message' => strip_tags($mixedAllowed)));
  83. echoJson($this->getFormEdit($iId, array('dynamic_mode' => true)));
  84. }
  85. function actionPin()
  86. {
  87. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  88. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  89. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  90. $mixedAllowed = $this->{'isAllowed' . ((int)$aEvent['pinned'] == 0 ? 'Pin' : 'Unpin')}($aEvent, true);
  91. if($mixedAllowed !== true)
  92. return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
  93. $aEvent['pinned'] = (int)$aEvent['pinned'] == 0 ? time() : 0;
  94. if(!$this->_oDb->updateEvent(array('pinned' => $aEvent['pinned']), array('id' => $iId)))
  95. return echoJson(array('code' => 2));
  96. echoJson(array(
  97. 'code' => 0,
  98. 'id' => $iId,
  99. 'eval' => $this->_oConfig->getJsObject('view') . '.onPinPost(oData)'
  100. ));
  101. }
  102. function actionStick()
  103. {
  104. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  105. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  106. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  107. $mixedAllowed = $this->{'isAllowed' . ((int)$aEvent['sticked'] == 0 ? 'Stick' : 'Unstick')}($aEvent, true);
  108. if($mixedAllowed !== true)
  109. return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
  110. $aEvent['sticked'] = (int)$aEvent['sticked'] == 0 ? time() : 0;
  111. if(!$this->_oDb->updateEvent(array('sticked' => $aEvent['sticked']), array('id' => $iId)))
  112. return echoJson(array('code' => 2));
  113. echoJson(array(
  114. 'code' => 0,
  115. 'id' => $iId,
  116. 'eval' => $this->_oConfig->getJsObject('view') . '.onStickPost(oData)'
  117. ));
  118. }
  119. function actionPromote()
  120. {
  121. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  122. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  123. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  124. $mixedAllowed = $this->{'isAllowed' . ((int)$aEvent['promoted'] == 0 ? 'Promote' : 'Unpromote')}($aEvent, true);
  125. if($mixedAllowed !== true)
  126. return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
  127. $aEvent['promoted'] = (int)$aEvent['promoted'] == 0 ? time() : 0;
  128. if(!$this->_oDb->updateEvent(array('promoted' => $aEvent['promoted']), array('id' => $iId)))
  129. return echoJson(array('code' => 2));
  130. echoJson(array(
  131. 'code' => 0,
  132. 'message' => _t('_bx_timeline_txt_msg_performed_action')
  133. ));
  134. }
  135. function actionDelete()
  136. {
  137. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  138. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => bx_process_input(bx_get('id'), BX_DATA_INT)));
  139. $mixedAllowed = $this->isAllowedDelete($aEvent, true);
  140. if($mixedAllowed !== true)
  141. return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
  142. if(!$this->deleteEvent($aEvent))
  143. return echoJson(array('code' => 2));
  144. echoJson(array(
  145. 'code' => 0,
  146. 'id' => $aEvent['id'],
  147. 'eval' => $this->_oConfig->getJsObject('view') . '.onDeletePost(oData)'
  148. ));
  149. }
  150. public function actionRepost()
  151. {
  152. $iAuthorId = $this->getUserId();
  153. $iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  154. $sType = bx_process_input(bx_get('type'), BX_DATA_TEXT);
  155. $sAction = bx_process_input(bx_get('action'), BX_DATA_TEXT);
  156. $iObjectId = bx_process_input(bx_get('object_id'), BX_DATA_INT);
  157. $aResult = $this->serviceRepost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId);
  158. if(!empty($aResult) && is_array($aResult))
  159. return echoJson($aResult);
  160. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  161. $sCounter = $this->_oTemplate->getRepostCounter($aReposted);
  162. echoJson(array(
  163. 'code' => 0,
  164. 'message' => _t('_bx_timeline_txt_msg_success_repost'),
  165. 'count' => $aReposted['reposts'],
  166. 'countf' => (int)$aReposted['reposts'] > 0 ? $this->_oTemplate->getRepostCounterLabel($aReposted['reposts']) : '',
  167. 'counter' => $sCounter,
  168. 'disabled' => true
  169. ));
  170. }
  171. function actionGetPost()
  172. {
  173. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  174. $sJsObject = bx_process_input(bx_get('js_object'));
  175. if(empty($sJsObject))
  176. $sJsObject = $this->_oConfig->getJsObject('post');
  177. $sView = bx_process_input(bx_get('view'));
  178. $sType = bx_process_input(bx_get('type'));
  179. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  180. $bAfpsLoading = (int)bx_get('afps_loading') === 1;
  181. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  182. if(empty($aEvent) || !is_array($aEvent))
  183. return echoJson(array());
  184. /**
  185. * Note. Disabled for now, because Own posts on Timelines of Following members
  186. * became visible on posts' author Dashboard Timeline.
  187. */
  188. //if($bAfpsLoading && $this->_iOwnerId != $aEvent['owner_id'])
  189. // return echoJson(array('message' => _t('_bx_timeline_txt_msg_posted')));
  190. echoJson(array(
  191. 'id' => $aEvent['id'],
  192. 'view' => $sView,
  193. 'item' => $this->_oTemplate->getPost($aEvent, array(
  194. 'view' => $sView,
  195. 'type' => !empty($sType) ? $sType : BX_TIMELINE_TYPE_DEFAULT,
  196. 'owner_id' => $this->_iOwnerId,
  197. 'dynamic_mode' => true
  198. )),
  199. 'eval' => $sJsObject . "._onGetPost(oData)"
  200. ));
  201. }
  202. function actionGetPosts()
  203. {
  204. $aParams = $this->_prepareParamsGet();
  205. list($sItems, $sLoadMore, $sBack, $sEmpty) = $this->_oTemplate->getPosts($aParams);
  206. echoJson(array(
  207. 'view' => $aParams['view'],
  208. 'items' => $sItems,
  209. 'load_more' => $sLoadMore,
  210. 'back' => $sBack,
  211. 'empty' => $sEmpty,
  212. 'eval' => $this->_oConfig->getJsObject('view') . "._onGetPosts(oData)"
  213. ));
  214. }
  215. public function actionGetPostForm()
  216. {
  217. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  218. $sType = bx_process_input(bx_get('type'));
  219. echoJson($this->getFormPost(array(
  220. 'type' => $sType,
  221. 'form_display' => $this->_oConfig->getPostFormDisplay($sType)
  222. )));
  223. }
  224. public function actionGetEditForm($iId)
  225. {
  226. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  227. echoJson($this->getFormEdit($iId, array('dynamic_mode' => true)));
  228. }
  229. public function actionGetComments()
  230. {
  231. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  232. $sSystem = bx_process_input(bx_get('system'), BX_DATA_TEXT);
  233. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  234. $sComments = $this->_oTemplate->getComments($sSystem, $iId, array('dynamic_mode' => true));
  235. echoJson(array('content' => $sComments));
  236. }
  237. public function actionAddAttachLink()
  238. {
  239. $sUrl = bx_process_input(bx_get('url'));
  240. if(empty($sUrl))
  241. return echoJson(array());
  242. echoJson($this->addAttachLink(array(
  243. 'url' => $sUrl
  244. )));
  245. }
  246. public function actionDeleteAttachLink()
  247. {
  248. $iUserId = $this->getUserId();
  249. $iLinkId = bx_process_input(bx_get('id'), BX_DATA_INT);
  250. if(empty($iLinkId)) {
  251. echoJson(array());
  252. return;
  253. }
  254. $aLink = $this->_oDb->getUnusedLinks($iUserId, $iLinkId);
  255. if(empty($aLink) || !is_array($aLink)) {
  256. echoJson(array());
  257. return;
  258. }
  259. if(!empty($aLink['media_id']))
  260. BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'))->deleteFile($aLink['media_id']);
  261. $aResult = array();
  262. if($this->_oDb->deleteUnusedLinks($iUserId, $iLinkId))
  263. $aResult = array('code' => 0);
  264. else
  265. $aResult = array('code' => 1, 'message' => _t('_bx_timeline_form_post_input_link_err_delete'));
  266. echoJson($aResult);
  267. }
  268. public function actionGetAttachLinkForm()
  269. {
  270. echo $this->_oTemplate->getAttachLinkForm();
  271. }
  272. public function actionSubmitAttachLinkForm()
  273. {
  274. echoJson($this->getFormAttachLink());
  275. }
  276. public function actionGetRepostedBy()
  277. {
  278. $iRepostedId = bx_process_input(bx_get('id'), BX_DATA_INT);
  279. echo $this->_oTemplate->getRepostedBy($iRepostedId);
  280. }
  281. public function actionGetItemBrief()
  282. {
  283. echo BxDolPage::getObjectInstance($this->_oConfig->getObject('page_item_brief'), $this->_oTemplate)->getCode();
  284. }
  285. public function actionResumeLiveUpdate($sType, $iOwnerId)
  286. {
  287. $sKey = $this->_oConfig->getLiveUpdateKey($sType, $iOwnerId);
  288. bx_import('BxDolSession');
  289. BxDolSession::getInstance()->unsetValue($sKey, $iOwnerId);
  290. }
  291. public function actionPauseLiveUpdate($sType, $iOwnerId)
  292. {
  293. $sKey = $this->_oConfig->getLiveUpdateKey($sType, $iOwnerId);
  294. bx_import('BxDolSession');
  295. BxDolSession::getInstance()->setValue($sKey, 1);
  296. }
  297. function actionRss()
  298. {
  299. $aArgs = func_get_args();
  300. $sType = array_shift($aArgs);
  301. $iOwnerId = 0;
  302. switch($sType) {
  303. case BX_BASE_MOD_NTFS_TYPE_OWNER:
  304. $iOwnerId = array_shift($aArgs);
  305. list($sUserName) = $this->getUserInfo($iOwnerId);
  306. $sRssCaption = _t('_bx_timeline_txt_rss_caption', $sUserName);
  307. $sRssLink = $this->_oConfig->getViewUrl($iOwnerId);
  308. break;
  309. case BX_BASE_MOD_NTFS_TYPE_PUBLIC:
  310. $sRssCaption = _t('_bx_timeline_page_title_view_home');
  311. $sRssLink = $this->_oConfig->getHomeViewUrl();
  312. break;
  313. }
  314. $aParams = $this->_prepareParams(BX_TIMELINE_VIEW_DEFAULT, $sType, $iOwnerId, 0, $this->_oConfig->getRssLength(), '', array(), 0);
  315. $aEvents = $this->_oDb->getEvents($aParams);
  316. $aRssData = array();
  317. foreach($aEvents as $aEvent) {
  318. if(empty($aEvent['title']))
  319. continue;
  320. $iOwner = $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? $aEvent['owner_id'] : $aEvent['object_id'];
  321. $oOwner = BxDolProfile::getInstanceMagic($iOwner);
  322. $aRssData[$aEvent['id']] = array(
  323. 'UnitID' => $aEvent['id'],
  324. 'UnitTitle' => $aEvent['title'],
  325. 'UnitLink' => $this->_oConfig->getItemViewUrl($aEvent),
  326. 'UnitDesc' => bx_replace_markers($aEvent['description'], array(
  327. 'profile_name' => $oOwner->getDisplayName()
  328. )),
  329. 'UnitDateTimeUTS' => $aEvent['date'],
  330. );
  331. }
  332. $oRss = new BxDolRssFactory();
  333. header('Content-Type: application/xml; charset=utf-8');
  334. echo $oRss->GenRssByData($aRssData, $sRssCaption, $sRssLink);
  335. }
  336. /**
  337. * SERVICE METHODS
  338. */
  339. /**
  340. * @page service Service Calls
  341. * @section bx_timeline Timeline
  342. * @subsection bx_timeline-other Other
  343. * @subsubsection bx_timeline-get_create_post_form get_create_post_form
  344. *
  345. * @code bx_srv('bx_timeline', 'get_create_post_form', [...]); @endcode
  346. *
  347. * Get form code for add content. Is needed for United Post Form.
  348. *
  349. * @param $aParams optional array with parameters(display name, etc)
  350. * @return form code or error
  351. *
  352. * @see BxTimelineModule::serviceGetCreatePostForm
  353. */
  354. /**
  355. * @ref bx_timeline-get_create_post_form "get_create_post_form"
  356. */
  357. public function serviceGetCreatePostForm($aParams = array())
  358. {
  359. $aParams = array_merge($this->_aFormParams, $aParams);
  360. $this->_iOwnerId = $aParams['context_id'];
  361. $oForm = $this->serviceGetObjectForm('add', $aParams);
  362. if(!$oForm)
  363. return '';
  364. if(!empty($aParams['display']))
  365. $aParams['form_display'] = $aParams['display'];
  366. else if(isset($aParams['context_id'])) {
  367. if((int)$aParams['context_id'] == 0)
  368. $aParams['form_display'] = 'form_display_post_add_public';
  369. else
  370. $aParams['form_display'] = 'form_display_post_add_profile';
  371. }
  372. $aResult = $this->getFormPost($aParams);
  373. if(!empty($aResult['form'])) {
  374. $bDynamicMode = isset($aParams['dynamic_mode']) && $aParams['dynamic_mode'];
  375. $sCode = '';
  376. $sCode .= $this->_oTemplate->getCssJs($bDynamicMode);
  377. $sCode .= $this->_oTemplate->getJsCodePost($this->_iOwnerId);
  378. $sCode .= $aResult['form'];
  379. return $sCode;
  380. }
  381. if(!empty($aResult['message']))
  382. return $aResult['message'];
  383. return '';
  384. }
  385. /**
  386. * @page service Service Calls
  387. * @section bx_timeline Timeline
  388. * @subsection bx_timeline-other Other
  389. * @subsubsection bx_timeline-get_object_form get_object_form
  390. *
  391. * @code bx_srv('bx_timeline', 'get_object_form', [...]); @endcode
  392. *
  393. * Get form object for add, edit, view or delete the content.
  394. *
  395. * @param $sType 'add' is supported only
  396. * @param $aParams optional array with parameters(display name, etc)
  397. * @return form object or false on error
  398. *
  399. * @see BxTimelineModule::serviceGetObjectForm
  400. */
  401. /**
  402. * @ref bx_timeline-get_object_form "get_object_form"
  403. */
  404. public function serviceGetObjectForm ($sType, $aParams = array())
  405. {
  406. if (!in_array($sType, array('add')))
  407. return false;
  408. $CNF = &$this->_oConfig->CNF;
  409. if(!empty($aParams['display']))
  410. $aParams['form_display'] = $aParams['display'];
  411. else if(isset($aParams['context_id'])) {
  412. if((int)$aParams['context_id'] == 0)
  413. $aParams['form_display'] = 'form_display_post_add_public';
  414. else
  415. $aParams['form_display'] = 'form_display_post_add_profile';
  416. }
  417. return $this->getFormPostObject($aParams);
  418. }
  419. /**
  420. * @page service Service Calls
  421. * @section bx_timeline Timeline
  422. * @subsection get_timeline_post
  423. * @see BxTimelineModule::serviceGetTimelinePost
  424. *
  425. * Get Timeline post. It's needed for Timeline module.
  426. *
  427. * @param $aEvent timeline event array from Timeline module
  428. * @return array in special format which is needed specifically for Timeline module to display the data.
  429. */
  430. public function serviceGetTimelinePost($aEvent, $aBrowseParams = array())
  431. {
  432. $CNF = &$this->_oConfig->CNF;
  433. /*
  434. * Note. For 'Direct Timeline Posts' FIELD_OBJECT_ID contains post's author profile ID.
  435. */
  436. $CNF['FIELD_AUTHOR'] = $CNF['FIELD_OBJECT_ID'];
  437. return parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
  438. }
  439. /**
  440. * @page service Service Calls
  441. * @section bx_timeline Timeline
  442. * @subsection bx_timeline-other Other
  443. * @subsubsection bx_timeline-get_author get_author
  444. *
  445. * @code bx_srv('bx_timeline', 'get_author', [...]); @endcode
  446. *
  447. * Get author ID from content info by content ID. Is used in "Content Info Objects" system.
  448. *
  449. * @param $iContentId integer value with content ID.
  450. * @return integer value with author ID.
  451. *
  452. * @see BxTimelineModule::serviceGetAuthor
  453. */
  454. /**
  455. * @ref bx_timeline-get_author "get_author"
  456. */
  457. public function serviceGetAuthor ($iContentId)
  458. {
  459. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  460. if(empty($aEvent) || !is_array($aEvent))
  461. return 0;
  462. return $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? (int)$aEvent['owner_id'] : (int)$aEvent['object_id'];
  463. }
  464. /**
  465. * @page service Service Calls
  466. * @section bx_timeline Timeline
  467. * @subsection bx_timeline-other Other
  468. * @subsubsection bx_timeline-get_date_changed get_date_changed
  469. *
  470. * @code bx_srv('bx_timeline', 'get_date_changed', [...]); @endcode
  471. *
  472. * Get date when the content was changed last time. Is used in "Content Info Objects" system.
  473. * Note. In case of Timeline event 0 is returned everytime.
  474. *
  475. * @param $iContentId integer value with content ID.
  476. * @return integer value with changing date.
  477. *
  478. * @see BxTimelineModule::serviceGetDateChanged
  479. */
  480. /**
  481. * @ref bx_timeline-get_date_changed "get_date_changed"
  482. */
  483. public function serviceGetDateChanged ($iContentId)
  484. {
  485. return 0;
  486. }
  487. /**
  488. * @page service Service Calls
  489. * @section bx_timeline Timeline
  490. * @subsection bx_timeline-other Other
  491. * @subsubsection bx_timeline-get_link get_link
  492. *
  493. * @code bx_srv('bx_timeline', 'get_link', [...]); @endcode
  494. *
  495. * Get content view page link. Is used in "Content Info Objects" system.
  496. *
  497. * @param $iContentId integer value with content ID.
  498. * @return string value with view page link.
  499. *
  500. * @see BxTimelineModule::serviceGetLink
  501. */
  502. /**
  503. * @ref bx_timeline-get_link "get_link"
  504. */
  505. public function serviceGetLink ($iContentId)
  506. {
  507. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  508. if(empty($aEvent) || !is_array($aEvent))
  509. return '';
  510. return $this->_oConfig->getItemViewUrl($aEvent);
  511. }
  512. /**
  513. * @page service Service Calls
  514. * @section bx_timeline Timeline
  515. * @subsection bx_timeline-other Other
  516. * @subsubsection bx_timeline-get_thumb get_thumb
  517. *
  518. * @code bx_srv('bx_timeline', 'get_thumb', [...]); @endcode
  519. *
  520. * Get content thumbnail link. Is used in "Content Info Objects" system.
  521. * Note. In case of Timeline event an empty string is returned everytime.
  522. *
  523. * @param $iContentId integer value with content ID.
  524. * @param $sTranscoder (optional) string value with transcoder name which should be applied to thumbnail image.
  525. * @return string value with thumbnail link.
  526. *
  527. * @see BxTimelineModule::serviceGetThumb
  528. */
  529. /**
  530. * @ref bx_timeline-get_thumb "get_thumb"
  531. */
  532. public function serviceGetThumb ($iContentId, $sTranscoder = '')
  533. {
  534. return '';
  535. }
  536. /**
  537. * @page service Service Calls
  538. * @section bx_timeline Timeline
  539. * @subsection bx_timeline-other Other
  540. * @subsubsection bx_timeline-get_info get_info
  541. *
  542. * @code bx_srv('bx_timeline', 'get_info', [...]); @endcode
  543. *
  544. * Get content info by content ID. Is used in "Content Info Objects" system.
  545. *
  546. * @param $iContentId integer value with content ID.
  547. * @param $bSearchableFieldsOnly (optional) boolean value determining all info or "searchable fields" only will be returned.
  548. * @return an array with content info. Empty array is returned if something is wrong.
  549. *
  550. * @see BxTimelineModule::serviceGetInfo
  551. */
  552. /**
  553. * @ref bx_timeline-get_info "get_info"
  554. */
  555. public function serviceGetInfo ($iContentId, $bSearchableFieldsOnly = true)
  556. {
  557. $aContentInfo = $this->_oDb->getEvents(array(
  558. 'browse' => 'id',
  559. 'value' => $iContentId)
  560. );
  561. return BxDolContentInfo::formatFields($aContentInfo);
  562. }
  563. /**
  564. * @page service Service Calls
  565. * @section bx_timeline Timeline
  566. * @subsection bx_timeline-other Other
  567. * @subsubsection bx_timeline-get_search_result_unit get_search_result_unit
  568. *
  569. * @code bx_srv('bx_timeline', 'get_search_result_unit', [...]); @endcode
  570. *
  571. * Get search result unit by content ID. Is used in "Content Info Objects" system.
  572. *
  573. * @param $iContentId integer value with content ID.
  574. * @param $sUnitTemplate (optional) string value with template name.
  575. * @return HTML string with search result unit. Empty string is returned if something is wrong.
  576. *
  577. * @see BxTimelineModule::serviceGetSearchResultUnit
  578. */
  579. /**
  580. * @ref bx_timeline-get_search_result_unit "get_search_result_unit"
  581. */
  582. public function serviceGetSearchResultUnit ($iContentId, $sUnitTemplate = '')
  583. {
  584. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  585. if(empty($aEvent) || !is_array($aEvent))
  586. return '';
  587. if(empty($sUnitTemplate))
  588. $sUnitTemplate = 'unit.html';
  589. return $this->_oTemplate->unit($aEvent, true, $sUnitTemplate);
  590. }
  591. /**
  592. * @page service Service Calls
  593. * @section bx_timeline Timeline
  594. * @subsection bx_timeline-page_blocks Page Blocks
  595. * @subsubsection bx_timeline-get_block_post get_block_post
  596. *
  597. * @code bx_srv('bx_timeline', 'get_block_post', [...]); @endcode
  598. *
  599. * Get Post block for a separate page.
  600. *
  601. * @param $iProfileId (optional) profile ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  602. * @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.
  603. *
  604. * @see BxTimelineModule::serviceGetBlockPost
  605. */
  606. /**
  607. * @ref bx_timeline-get_block_post "get_block_post"
  608. */
  609. public function serviceGetBlockPost($iProfileId = 0)
  610. {
  611. if(empty($iProfileId) && bx_get('profile_id') !== false)
  612. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  613. if(empty($iProfileId) && isLogged())
  614. $iProfileId = bx_get_logged_profile_id();
  615. if(!$iProfileId)
  616. return array();
  617. $sType = BX_BASE_MOD_NTFS_TYPE_OWNER;
  618. return $this->_getBlockPost($iProfileId, array(
  619. 'type' => $sType,
  620. 'form_display' => $this->_oConfig->getPostFormDisplay($sType)
  621. ));
  622. }
  623. /**
  624. * @page service Service Calls
  625. * @section bx_timeline Timeline
  626. * @subsection bx_timeline-page_blocks Page Blocks
  627. * @subsubsection bx_timeline-get_block_post_profile get_block_post_profile
  628. *
  629. * @code bx_srv('bx_timeline', 'get_block_post_profile', [...]); @endcode
  630. *
  631. * Get Post block for the Profile page.
  632. *
  633. * @param $sProfileModule (optional) string value with profile based module name. Persons module is used by default.
  634. * @param $iProfileContentId (optional) profile's content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  635. * @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.
  636. *
  637. * @see BxTimelineModule::serviceGetBlockPostProfile
  638. */
  639. /**
  640. * @ref bx_timeline-get_block_post_profile "get_block_post_profile"
  641. */
  642. public function serviceGetBlockPostProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0)
  643. {
  644. if(empty($sProfileModule))
  645. return array();
  646. if(empty($iProfileContentId) && bx_get('id') !== false)
  647. $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  648. $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
  649. if(empty($oProfile))
  650. return array();
  651. $iProfileId = $oProfile->id();
  652. $sType = BX_BASE_MOD_NTFS_TYPE_OWNER;
  653. return $this->_getBlockPost($iProfileId, array(
  654. 'type' => $sType,
  655. 'form_display' => $this->_oConfig->getPostFormDisplay($sType)
  656. ));
  657. }
  658. /**
  659. * @page service Service Calls
  660. * @section bx_timeline Timeline
  661. * @subsection bx_timeline-page_blocks Page Blocks
  662. * @subsubsection bx_timeline-get_block_post_home get_block_post_home
  663. *
  664. * @code bx_srv('bx_timeline', 'get_block_post_home', [...]); @endcode
  665. *
  666. * Get Post block for site's Home page.
  667. *
  668. * @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.
  669. *
  670. * @see BxTimelineModule::serviceGetBlockPostHome
  671. */
  672. /**
  673. * @ref bx_timeline-get_block_post_home "get_block_post_home"
  674. */
  675. public function serviceGetBlockPostHome()
  676. {
  677. $iProfileId = 0;
  678. $sType = BX_BASE_MOD_NTFS_TYPE_PUBLIC;
  679. return $this->_getBlockPost($iProfileId, array(
  680. 'type' => $sType,
  681. 'form_display' => $this->_oConfig->getPostFormDisplay($sType)
  682. ));
  683. }
  684. /**
  685. * @page service Service Calls
  686. * @section bx_timeline Timeline
  687. * @subsection bx_timeline-page_blocks Page Blocks
  688. * @subsubsection bx_timeline-get_block_post_account get_block_post_account
  689. *
  690. * @code bx_srv('bx_timeline', 'get_block_post_account', [...]); @endcode
  691. *
  692. * Get Post block for the Dashboard page.
  693. *
  694. * @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.
  695. *
  696. * @see BxTimelineModule::serviceGetBlockPostAccount
  697. */
  698. /**
  699. * @ref bx_timeline-get_block_post_account "get_block_post_account"
  700. */
  701. public function serviceGetBlockPostAccount()
  702. {
  703. if(!isLogged())
  704. return '';
  705. $iProfileId = $this->getProfileId();
  706. $sType = BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS;
  707. return $this->_getBlockPost($iProfileId, array(
  708. 'type' => $sType,
  709. 'form_display' => $this->_oConfig->getPostFormDisplay($sType)
  710. ));
  711. }
  712. /**
  713. * @page service Service Calls
  714. * @section bx_timeline Timeline
  715. * @subsection bx_timeline-page_blocks Page Blocks
  716. * @subsubsection bx_timeline-get_block_view get_block_view
  717. *
  718. * @code bx_srv('bx_timeline', 'get_block_view', [...]); @endcode
  719. *
  720. * Get Timeline View block for a separate page.
  721. *
  722. * @param $iProfileId (optional) profile ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  723. * @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.
  724. *
  725. * @see BxTimelineModule::serviceGetBlockView
  726. */
  727. /**
  728. * @ref bx_timeline-get_block_view "get_block_view"
  729. */
  730. public function serviceGetBlockView($iProfileId = 0)
  731. {
  732. return $this->_serviceGetBlockView($iProfileId, BX_TIMELINE_VIEW_TIMELINE);
  733. }
  734. /**
  735. * @page service Service Calls
  736. * @section bx_timeline Timeline
  737. * @subsection bx_timeline-page_blocks Page Blocks
  738. * @subsubsection bx_timeline-get_block_view_outline get_block_view_outline
  739. *
  740. * @code bx_srv('bx_timeline', 'get_block_view_outline', [...]); @endcode
  741. *
  742. * Get Outline View block for a separate page.
  743. *
  744. * @param $iProfileId (optional) profile ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  745. * @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.
  746. *
  747. * @see BxTimelineModule::serviceGetBlockViewOutline
  748. */
  749. /**
  750. * @ref bx_timeline-get_block_view_outline "get_block_view_outline"
  751. */
  752. public function serviceGetBlockViewOutline($iProfileId = 0)
  753. {
  754. return $this->_serviceGetBlockView($iProfileId, BX_TIMELINE_VIEW_OUTLINE);
  755. }
  756. /**
  757. * @page service Service Calls
  758. * @section bx_timeline Timeline
  759. * @subsection bx_timeline-page_blocks Page Blocks
  760. * @subsubsection bx_timeline-get_block_view_profile get_block_view_profile
  761. *
  762. * @code bx_srv('bx_timeline', 'get_block_view_profile', [...]); @endcode
  763. *
  764. * Get Timeline View block for the Profile page.
  765. *
  766. * @param $sProfileModule (optional) string value with profile based module name. Persons module is used by default.
  767. * @param $iProfileContentId (optional) profile's content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  768. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  769. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  770. * @param $sFilter (optional) string value with filter name.
  771. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  772. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  773. * @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.
  774. *
  775. * @see BxTimelineModule::serviceGetBlockViewProfile
  776. */
  777. /**
  778. * @ref bx_timeline-get_block_view_profile "get_block_view_profile"
  779. */
  780. public function serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  781. {
  782. $sView = BX_TIMELINE_VIEW_TIMELINE;
  783. return $this->_serviceGetBlockViewProfile($sProfileModule, $iProfileContentId, $sView, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  784. }
  785. /**
  786. * @page service Service Calls
  787. * @section bx_timeline Timeline
  788. * @subsection bx_timeline-page_blocks Page Blocks
  789. * @subsubsection bx_timeline-get_block_view_profile_outline get_block_view_profile_outline
  790. *
  791. * @code bx_srv('bx_timeline', 'get_block_view_profile_outline', [...]); @endcode
  792. *
  793. * Get Outline View block for the Profile page.
  794. *
  795. * @param $sProfileModule (optional) string value with profile based module name. Persons module is used by default.
  796. * @param $iProfileContentId (optional) profile's content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  797. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  798. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  799. * @param $sFilter (optional) string value with filter name.
  800. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  801. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  802. * @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.
  803. *
  804. * @see BxTimelineModule::serviceGetBlockViewProfileOutline
  805. */
  806. /**
  807. * @ref bx_timeline-get_block_view_profile_outline "get_block_view_profile_outline"
  808. */
  809. public function serviceGetBlockViewProfileOutline($sProfileModule = 'bx_persons', $iProfileContentId = 0, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  810. {
  811. $sView = BX_TIMELINE_VIEW_OUTLINE;
  812. return $this->_serviceGetBlockViewProfile($sProfileModule, $iProfileContentId, $sView, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  813. }
  814. /**
  815. * @page service Service Calls
  816. * @section bx_timeline Timeline
  817. * @subsection bx_timeline-page_blocks Page Blocks
  818. * @subsubsection bx_timeline-get_block_view_home get_block_view_home
  819. *
  820. * @code bx_srv('bx_timeline', 'get_block_view_home', [...]); @endcode
  821. *
  822. * Get Timeline View block for site's Home page.
  823. *
  824. * @param $iProfileId (optional) profile ID. 0 should be used here.
  825. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  826. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  827. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  828. * @param $sFilter (optional) string value with filter name.
  829. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  830. * @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.
  831. *
  832. * @see BxTimelineModule::serviceGetBlockViewHome
  833. */
  834. /**
  835. * @ref bx_timeline-get_block_view_home "get_block_view_home"
  836. */
  837. public function serviceGetBlockViewHome($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  838. {
  839. return $this->_serviceGetBlockViewHome($iProfileId, BX_TIMELINE_VIEW_TIMELINE, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
  840. }
  841. /**
  842. * @page service Service Calls
  843. * @section bx_timeline Timeline
  844. * @subsection bx_timeline-page_blocks Page Blocks
  845. * @subsubsection bx_timeline-get_block_view_home_outline get_block_view_home_outline
  846. *
  847. * @code bx_srv('bx_timeline', 'get_block_view_home_outline', [...]); @endcode
  848. *
  849. * Get Outline View block for site's Home page.
  850. *
  851. * @param $iProfileId (optional) profile ID. 0 should be used here.
  852. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  853. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  854. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  855. * @param $sFilter (optional) string value with filter name.
  856. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  857. * @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.
  858. *
  859. * @see BxTimelineModule::serviceGetBlockViewHomeOutline
  860. */
  861. /**
  862. * @ref bx_timeline-get_block_view_home_outline "get_block_view_home_outline"
  863. */
  864. public function serviceGetBlockViewHomeOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  865. {
  866. return $this->_serviceGetBlockViewHome($iProfileId, BX_TIMELINE_VIEW_OUTLINE, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
  867. }
  868. /**
  869. * @page service Service Calls
  870. * @section bx_timeline Timeline
  871. * @subsection bx_timeline-page_blocks Page Blocks
  872. * @subsubsection bx_timeline-get_block_view_hot get_block_view_hot
  873. *
  874. * @code bx_srv('bx_timeline', 'get_block_view_hot', [...]); @endcode
  875. *
  876. * Get Timeline View block with Hot public events.
  877. *
  878. * @param $iProfileId (optional) profile ID. 0 should be used here.
  879. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  880. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  881. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  882. * @param $sFilter (optional) string value with filter name.
  883. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  884. * @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.
  885. *
  886. * @see BxTimelineModule::serviceGetBlockViewHot
  887. */
  888. /**
  889. * @ref bx_timeline-get_block_view_hot "get_block_view_hot"
  890. */
  891. public function serviceGetBlockViewHot($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  892. {
  893. return $this->_serviceGetBlockViewHot($iProfileId, BX_TIMELINE_VIEW_TIMELINE, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
  894. }
  895. /**
  896. * @page service Service Calls
  897. * @section bx_timeline Timeline
  898. * @subsection bx_timeline-page_blocks Page Blocks
  899. * @subsubsection bx_timeline-get_block_view_hot_outline get_block_view_hot_outline
  900. *
  901. * @code bx_srv('bx_timeline', 'get_block_view_hot_outline', [...]); @endcode
  902. *
  903. * Get Outline View block with Hot public events.
  904. *
  905. * @param $iProfileId (optional) profile ID. 0 should be used here.
  906. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  907. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  908. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  909. * @param $sFilter (optional) string value with filter name.
  910. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  911. * @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.
  912. *
  913. * @see BxTimelineModule::serviceGetBlockViewHotOutline
  914. */
  915. /**
  916. * @ref bx_timeline-get_block_view_hot_outline "get_block_view_hot_outline"
  917. */
  918. public function serviceGetBlockViewHotOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  919. {
  920. return $this->_serviceGetBlockViewHot($iProfileId, BX_TIMELINE_VIEW_OUTLINE, $iStart, $iPerPage, $this->_oConfig->getPerPage('home'), $iTimeline, $sFilter, $aModules);
  921. }
  922. /**
  923. * @page service Service Calls
  924. * @section bx_timeline Timeline
  925. * @subsection bx_timeline-page_blocks Page Blocks
  926. * @subsubsection bx_timeline-get_block_view_account get_block_view_account
  927. *
  928. * @code bx_srv('bx_timeline', 'get_block_view_account', [...]); @endcode
  929. *
  930. * Get Timeline View block for the Dashboard page.
  931. *
  932. * @param $iProfileId (optional) profile ID. 0 should be used here.
  933. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  934. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  935. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  936. * @param $sFilter (optional) string value with filter name.
  937. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  938. * @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.
  939. *
  940. * @see BxTimelineModule::serviceGetBlockViewAccount
  941. */
  942. /**
  943. * @ref bx_timeline-get_block_view_account "get_block_view_account"
  944. */
  945. public function serviceGetBlockViewAccount($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  946. {
  947. if(!isLogged())
  948. return '';
  949. return $this->_serviceGetBlockViewByType($iProfileId, BX_TIMELINE_VIEW_TIMELINE, BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS, $iStart, $iPerPage, $this->_oConfig->getPerPage('account'), $iTimeline, $sFilter, $aModules);
  950. }
  951. /**
  952. * @page service Service Calls
  953. * @section bx_timeline Timeline
  954. * @subsection bx_timeline-page_blocks Page Blocks
  955. * @subsubsection bx_timeline-get_block_view_account_outline get_block_view_account_outline
  956. *
  957. * @code bx_srv('bx_timeline', 'get_block_view_account_outline', [...]); @endcode
  958. *
  959. * Get Outline View block for the Dashboard page.
  960. *
  961. * @param $iProfileId (optional) profile ID. 0 should be used here.
  962. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  963. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  964. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  965. * @param $sFilter (optional) string value with filter name.
  966. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  967. * @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.
  968. *
  969. * @see BxTimelineModule::serviceGetBlockViewAccountOutline
  970. */
  971. /**
  972. * @ref bx_timeline-get_block_view_account_outline "get_block_view_account_outline"
  973. */
  974. public function serviceGetBlockViewAccountOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  975. {
  976. if(!isLogged())
  977. return '';
  978. return $this->_serviceGetBlockViewByType($iProfileId, BX_TIMELINE_VIEW_OUTLINE, BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS, $iStart, $iPerPage, $this->_oConfig->getPerPage('account'), $iTimeline, $sFilter, $aModules);
  979. }
  980. /**
  981. * @page service Service Calls
  982. * @section bx_timeline Timeline
  983. * @subsection bx_timeline-page_blocks Page Blocks
  984. * @subsubsection bx_timeline-get_block_item get_block_item
  985. *
  986. * @code bx_srv('bx_timeline', 'get_block_item', [...]); @endcode
  987. *
  988. * Get View Item block.
  989. *
  990. * @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.
  991. *
  992. * @see BxTimelineModule::serviceGetBlockItem
  993. */
  994. /**
  995. * @ref bx_timeline-get_block_item "get_block_item"
  996. */
  997. public function serviceGetBlockItem()
  998. {
  999. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1000. if(!$iItemId)
  1001. return array();
  1002. return $this->_oTemplate->getItemBlock($iItemId);
  1003. }
  1004. public function serviceGetBlockItemContent()
  1005. {
  1006. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1007. $sMode = bx_process_input(bx_get('mode'));
  1008. if(!$iItemId || !$sMode)
  1009. return '';
  1010. return $this->_oTemplate->getItemBlockContent($iItemId, $sMode);
  1011. }
  1012. public function serviceGetBlockItemInfo()
  1013. {
  1014. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1015. if(!$iItemId)
  1016. return '';
  1017. return $this->_oTemplate->getItemBlockInfo($iItemId);
  1018. }
  1019. public function serviceGetBlockItemComments()
  1020. {
  1021. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1022. if(!$iItemId)
  1023. return '';
  1024. return $this->_oTemplate->getItemBlockComments($iItemId);
  1025. }
  1026. /**
  1027. * @page service Service Calls
  1028. * @section bx_timeline Timeline
  1029. * @subsection bx_timeline-integration_notifications Integration with Notifications
  1030. * @subsubsection bx_timeline-get_notifications_data get_notifications_data
  1031. *
  1032. * @code bx_srv('bx_timeline', 'get_notifications_data', [...]); @endcode
  1033. *
  1034. * Data for Notifications module.
  1035. *
  1036. * @return an array with special format.
  1037. *
  1038. * @see BxTimelineModule::serviceGetNotificationsData
  1039. */
  1040. /**
  1041. * @ref bx_timeline-get_notifications_data "get_notifications_data"
  1042. */
  1043. public function serviceGetNotificationsData()
  1044. {
  1045. $sModule = $this->_aModule['name'];
  1046. return array(
  1047. 'handlers' => array(
  1048. array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'post_common', 'module_name' => $sModule, 'module_method' => 'get_notifications_post', 'module_class' => 'Module'),
  1049. array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete'),
  1050. array('group' => $sModule . '_repost', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'repost', 'module_name' => $sModule, 'module_method' => 'get_notifications_repost', 'module_class' => 'Module'),
  1051. array('group' => $sModule . '_repost', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete_repost'),
  1052. array('group' => $sModule . '_comment', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'commentPost', 'module_name' => $sModule, 'module_method' => 'get_notifications_comment', 'module_class' => 'Module'),
  1053. array('group' => $sModule . '_comment', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'commentRemoved'),
  1054. array('group' => $sModule . '_vote', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_vote', 'module_class' => 'Module'),
  1055. array('group' => $sModule . '_vote', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'undoVote'),
  1056. ),
  1057. 'settings' => array(
  1058. array('group' => 'content', 'unit' => $sModule, 'action' => 'post_common', 'types' => array('personal', 'follow_member', 'follow_context')),
  1059. array('group' => 'content', 'unit' => $sModule, 'action' => 'repost', 'types' => array('follow_member', 'follow_context')),
  1060. array('group' => 'comment', 'unit' => $sModule, 'action' => 'commentPost', 'types' => array('personal', 'follow_member', 'follow_context')),
  1061. array('group' => 'vote', 'unit' => $sModule, 'action' => 'doVote', 'types' => array('personal', 'follow_member', 'follow_context'))
  1062. ),
  1063. 'alerts' => array(
  1064. array('unit' => $sModule, 'action' => 'post_common'),
  1065. array('unit' => $sModule, 'action' => 'delete'),
  1066. array('unit' => $sModule, 'action' => 'repost'),
  1067. array('unit' => $sModule, 'action' => 'delete_repost'),
  1068. array('unit' => $sModule, 'action' => 'commentPost'),
  1069. array('unit' => $sModule, 'action' => 'commentRemoved'),
  1070. array('unit' => $sModule, 'action' => 'doVote'),
  1071. array('unit' => $sModule, 'action' => 'undoVote'),
  1072. )
  1073. );
  1074. }
  1075. /**
  1076. * @page service Service Calls
  1077. * @section bx_timeline Timeline
  1078. * @subsection bx_timeline-integration_notifications Integration with Notifications
  1079. * @subsubsection bx_timeline-get_notifications_repost get_notifications_repost
  1080. *
  1081. * @code bx_srv('bx_timeline', 'get_notifications_repost', [...]); @endcode
  1082. *
  1083. * Get data for Repost event to display in Notifications module.
  1084. *
  1085. * @param $aEvent an array with event description.
  1086. * @return an array with special format.
  1087. *
  1088. * @see BxTimelineModule::serviceGetNotificationsRepost
  1089. */
  1090. /**
  1091. * @ref bx_timeline-get_notifications_repost "get_notifications_repost"
  1092. */
  1093. public function serviceGetNotificationsRepost($aEvent)
  1094. {
  1095. $aResult = $this->serviceGetNotificationsPost($aEvent);
  1096. $aResult['lang_key'] = '_bx_timeline_txt_object_reposted';
  1097. return $aResult;
  1098. }
  1099. /**
  1100. * @page service Service Calls
  1101. * @section bx_timeline Timeline
  1102. * @subsection bx_timeline-integration_notifications Integration with Notifications
  1103. * @subsubsection bx_timeline-get_notifications_post get_notifications_post
  1104. *
  1105. * @code bx_srv('bx_timeline', 'get_notifications_post', [...]); @endcode
  1106. *
  1107. * Get data for Post event to display in Notifications module.
  1108. *
  1109. * @param $aEvent an array with event description.
  1110. * @return an array with special format.
  1111. *
  1112. * @see BxTimelineModule::serviceGetNotificationsPost
  1113. */
  1114. /**
  1115. * @ref bx_timeline-get_notifications_post "get_notifications_post"
  1116. */
  1117. public function serviceGetNotificationsPost($aEvent)
  1118. {
  1119. $CNF = &$this->_oConfig->CNF;
  1120. $iContent = (int)$aEvent['object_id'];
  1121. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  1122. if(empty($aContent) || !is_array($aContent))
  1123. return array();
  1124. $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description'], $aContent['object_id']);
  1125. return array(
  1126. 'entry_sample' => $CNF['T']['txt_sample_single_ext'],
  1127. 'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
  1128. 'entry_caption' => $sEntryCaption,
  1129. 'entry_author' => $aContent['owner_id'],
  1130. '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.
  1131. );
  1132. }
  1133. /**
  1134. * @page service Service Calls
  1135. * @section bx_timeline Timeline
  1136. * @subsection bx_timeline-integration_notifications Integration with Notifications
  1137. * @subsubsection bx_timeline-get_notifications_comment get_notifications_comment
  1138. *
  1139. * @code bx_srv('bx_timeline', 'get_notifications_comment', [...]); @endcode
  1140. *
  1141. * Get data for Post Comment event to display in Notifications module.
  1142. *
  1143. * @param $aEvent an array with event description.
  1144. * @return an array with special format.
  1145. *
  1146. * @see BxTimelineModule::serviceGetNotificationsComment
  1147. */
  1148. /**
  1149. * @ref bx_timeline-get_notifications_comment "get_notifications_comment"
  1150. */
  1151. public function serviceGetNotificationsComment($aEvent)
  1152. {
  1153. $CNF = &$this->_oConfig->CNF;
  1154. $iContent = (int)$aEvent['object_id'];
  1155. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  1156. if(empty($aContent) || !is_array($aContent))
  1157. return array();
  1158. $oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContent);
  1159. if(!$oComment || !$oComment->isEnabled())
  1160. return array();
  1161. $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description'], $aContent['object_id']);
  1162. return array(
  1163. 'entry_sample' => $CNF['T']['txt_sample_single'],
  1164. 'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
  1165. 'entry_caption' => $sEntryCaption,
  1166. 'entry_author' => $aContent['owner_id'],
  1167. 'subentry_sample' => $CNF['T']['txt_sample_comment_single'],
  1168. 'subentry_url' => $oComment->getViewUrl((int)$aEvent['subobject_id']),
  1169. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  1170. );
  1171. }
  1172. /**
  1173. * @page service Service Calls
  1174. * @section bx_timeline Timeline
  1175. * @subsection bx_timeline-integration_notifications Integration with Notifications
  1176. * @subsubsection bx_timeline-get_notifications_vote get_notifications_vote
  1177. *
  1178. * @code bx_srv('bx_timeline', 'get_notifications_vote', [...]); @endcode
  1179. *
  1180. * Get data for Vote event to display in Notifications module.
  1181. *
  1182. * @param $aEvent an array with event description.
  1183. * @return an array with special format.
  1184. *
  1185. * @see BxTimelineModule::serviceGetNotificationsVote
  1186. */
  1187. /**
  1188. * @ref bx_timeline-get_notifications_vote "get_notifications_vote"
  1189. */
  1190. public function serviceGetNotificationsVote($aEvent)
  1191. {
  1192. $CNF = &$this->_oConfig->CNF;
  1193. $iContent = (int)$aEvent['object_id'];
  1194. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  1195. if(empty($aContent) || !is_array($aContent))
  1196. return array();
  1197. $oVote = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContent);
  1198. if(!$oVote || !$oVote->isEnabled())
  1199. return array();
  1200. $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description'], $aContent['object_id']);
  1201. return array(
  1202. 'entry_sample' => $CNF['T']['txt_sample_single'],
  1203. 'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
  1204. 'entry_caption' => $sEntryCaption,
  1205. 'entry_author' => $aContent['owner_id'],
  1206. 'subentry_sample' => $CNF['T']['txt_sample_vote_single'],
  1207. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  1208. );
  1209. }
  1210. /**
  1211. * @page service Service Calls
  1212. * @section bx_timeline Timeline
  1213. * @subsection bx_timeline-repost Repost
  1214. * @subsubsection bx_timeline-get_repost_element_block get_repost_element_block
  1215. *
  1216. * @code bx_srv('bx_timeline', 'get_repost_element_block', [...]); @endcode
  1217. *
  1218. * Get repost element for content based modules.
  1219. *
  1220. * @param $iOwnerId integer value with owner profile ID.
  1221. * @param $sType string value with type (module name).
  1222. * @param $sAction string value with action (module action).
  1223. * @param $iObjectId integer value with object ID to be reposted.
  1224. * @param $aParams (optional) an array with additional params.
  1225. * @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.
  1226. *
  1227. * @see BxTimelineModule::serviceGetRepostElementBlock
  1228. */
  1229. /**
  1230. * @ref bx_timeline-get_repost_element_block "get_repost_element_block"
  1231. */
  1232. public function serviceGetRepostElementBlock($iOwnerId, $sType, $sAction, $iObjectId, $aParams = array())
  1233. {
  1234. if(!$this->isEnabled())
  1235. return '';
  1236. $aParams = array_merge($this->_oConfig->getRepostDefaults(), $aParams);
  1237. return $this->_oTemplate->getRepostElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams);
  1238. }
  1239. /**
  1240. * @page service Service Calls
  1241. * @section bx_timeline Timeline
  1242. * @subsection bx_timeline-repost Repost
  1243. * @subsubsection bx_timeline-get_repost_counter get_repost_counter
  1244. *
  1245. * @code bx_srv('bx_timeline', 'get_repost_counter', [...]); @endcode
  1246. *
  1247. * Get repost counter.
  1248. *
  1249. * @param $sType string value with type (module name).
  1250. * @param $sAction string value with action (module action).
  1251. * @param $iObjectId integer value with object ID to be reposted.
  1252. * @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.
  1253. *
  1254. * @see BxTimelineModule::serviceGetRepostCounter
  1255. */
  1256. /**
  1257. * @ref bx_timeline-get_repost_counter "get_repost_counter"
  1258. */
  1259. public function serviceGetRepostCounter($sType, $sAction, $iObjectId)
  1260. {
  1261. if(!$this->isEnabled())
  1262. return '';
  1263. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  1264. return $this->_oTemplate->getRepostCounter($aReposted);
  1265. }
  1266. /**
  1267. * @page service Service Calls
  1268. * @section bx_timeline Timeline
  1269. * @subsection bx_timeline-repost Repost
  1270. * @subsubsection bx_timeline-get_repost_js_script get_repost_js_script
  1271. *
  1272. * @code bx_srv('bx_timeline', 'get_repost_js_script', [...]); @endcode
  1273. *
  1274. * Get repost JavaScript code.
  1275. *
  1276. * @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.
  1277. *
  1278. * @see BxTimelineModule::serviceGetRepostJsScript
  1279. */
  1280. /**
  1281. * @ref bx_timeline-get_repost_js_script "get_repost_js_script"
  1282. */
  1283. public function serviceGetRepostJsScript()
  1284. {
  1285. if(!$this->isEnabled())
  1286. return '';
  1287. return $this->_oTemplate->getRepostJsScript();
  1288. }
  1289. /**
  1290. * @page service Service Calls
  1291. * @section bx_timeline Timeline
  1292. * @subsection bx_timeline-repost Repost
  1293. * @subsubsection bx_timeline-get_repost_js_click get_repost_js_click
  1294. *
  1295. * @code bx_srv('bx_timeline', 'get_repost_js_click', [...]); @endcode
  1296. *
  1297. * Get repost JavaScript code for OnClick event.
  1298. *
  1299. * @param $iOwnerId integer value with owner profile ID.
  1300. * @param $sType string value with type (module name).
  1301. * @param $sAction string value with action (module action).
  1302. * @param $iObjectId integer value with object ID to be reposted.
  1303. * @return HTML string with JavaScript code to display in OnClick events of HTML elements.
  1304. *
  1305. * @see BxTimelineModule::serviceGetRepostJsClick
  1306. */
  1307. /**
  1308. * @ref bx_timeline-get_repost_js_click "get_repost_js_click"
  1309. */
  1310. public function serviceGetRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId)
  1311. {
  1312. if(!$this->isEnabled())
  1313. return '';
  1314. return $this->_oTemplate->getRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId);
  1315. }
  1316. /**
  1317. * @page service Service Calls
  1318. * @section bx_timeline Timeline
  1319. * @subsection bx_timeline-repost Repost
  1320. * @subsubsection bx_timeline-repost repost
  1321. *
  1322. * @code bx_srv('bx_timeline', 'repost', [...]); @endcode
  1323. *
  1324. * Perform repost action.
  1325. *
  1326. * @param $iAuthorId integer value with performer profile ID.
  1327. * @param $iOwnerId integer value with repost event owner profile ID.
  1328. * @param $sType string value with type (module name).
  1329. * @param $sAction string value with action (module action).
  1330. * @param $iObjectId integer value with object ID to be reposted.
  1331. * @parem $bForce boolean value force reposting without ACL check.
  1332. * @return an array with error (code and message) or integer with newly created repost event ID.
  1333. *
  1334. * @see BxTimelineModule::serviceRepost
  1335. */
  1336. /**
  1337. * @ref bx_timeline-repost "repost"
  1338. */
  1339. public function serviceRepost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, $bForce = false)
  1340. {
  1341. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  1342. if(empty($aReposted) || !is_array($aReposted))
  1343. return array('code' => 1, 'message' => _t('_bx_timeline_txt_err_cannot_repost'));
  1344. $mixedAllowed = $this->isAllowedRepost($aReposted, true);
  1345. if(!$bForce && $mixedAllowed !== true)
  1346. return array('code' => 2, 'message' => strip_tags($mixedAllowed));
  1347. $bReposted = $this->_oDb->isReposted($aReposted['id'], $iOwnerId, $iAuthorId);
  1348. if($bReposted)
  1349. return array('code' => 3, 'message' => _t('_bx_timeline_txt_err_already_reposted'));
  1350. $iId = $this->_oDb->insertEvent(array(
  1351. 'owner_id' => $iOwnerId,
  1352. 'type' => $this->_oConfig->getPrefix('common_post') . 'repost',
  1353. 'action' => '',
  1354. 'object_id' => $iAuthorId,
  1355. 'object_privacy_view' => $this->_oConfig->getPrivacyViewDefault('object'),
  1356. 'content' => serialize(array(
  1357. 'type' => $sType,
  1358. 'action' => $sAction,
  1359. 'object_id' => $iObjectId,
  1360. )),
  1361. 'title' => '',
  1362. 'description' => ''
  1363. ));
  1364. if(empty($iId))
  1365. return array('code' => 4, 'message' => _t('_bx_timeline_txt_err_cannot_repost'));
  1366. $this->onRepost($iId, $aReposted);
  1367. return $iId;
  1368. }
  1369. /**
  1370. * @page service Service Calls
  1371. * @section bx_timeline Timeline
  1372. * @subsection bx_timeline-repost Repost
  1373. * @subsubsection bx_timeline-repost_by_id repost_by_id
  1374. *
  1375. * @code bx_srv('bx_timeline', 'repost_by_id', [...]); @endcode
  1376. *
  1377. * Perform repost action by Timeline event ID.
  1378. *
  1379. * @param $iAuthorId integer value with performer profile ID.
  1380. * @param $iOwnerId integer value with repost event owner profile ID.
  1381. * @param $iEventId integer value with event ID which will be reposted.
  1382. * @parem $bForce boolean value force reposting without ACL check.
  1383. * @return an array with error (code and message) or integer with newly created repost event ID.
  1384. *
  1385. * @see BxTimelineModule::serviceRepostById
  1386. */
  1387. /**
  1388. * @ref bx_timeline-repost_by_id "repost_by_id"
  1389. */
  1390. public function serviceRepostById($iAuthorId, $iOwnerId, $iEventId, $bForce = false)
  1391. {
  1392. $aEvent = $this->_oDb->getEntriesBy(array('type' => 'id', 'id' => $iEventId));
  1393. if(empty($aEvent) || !is_array($aEvent))
  1394. return array('code' => 1, 'message' => _t('_bx_timeline_txt_err_cannot_repost'));
  1395. $sType = $aEvent['type'];
  1396. $sAction = $aEvent['action'];
  1397. $iObjectId = $this->_oConfig->isSystem($sType, $sAction) ? $aEvent['object_id'] : $aEvent['id'];
  1398. $sCommonPrefix = $this->_oConfig->getPrefix('common_post');
  1399. if(str_replace($sCommonPrefix, '', $sType) == BX_TIMELINE_PARSE_TYPE_REPOST) {
  1400. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  1401. if(empty($aReposted) || !is_array($aReposted))
  1402. return array('code' => 1, 'message' => _t('_bx_timeline_txt_err_cannot_repost'));
  1403. $aRepostedData = unserialize($aEvent['content']);
  1404. $sType = $aRepostedData['type'];
  1405. $sAction = $aRepostedData['action'];
  1406. $iObjectId = $aRepostedData['object_id'];
  1407. }
  1408. return $this->serviceRepost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, $bForce);
  1409. }
  1410. /**
  1411. * @page service Service Calls
  1412. * @section bx_timeline Timeline
  1413. * @subsection bx_timeline-other Other
  1414. * @subsubsection bx_timeline-update update
  1415. *
  1416. * @code bx_srv('bx_timeline', 'update', [...]); @endcode
  1417. *
  1418. * Update timeline event by ID.
  1419. *
  1420. * @param $iEventId integer value with event ID.
  1421. * @param $aSet an array with key=>value pairs for fields which should be updated.
  1422. * @return boolean value with the result of operation.
  1423. *
  1424. * @see BxTimelineModule::serviceUpdate
  1425. */
  1426. /**
  1427. * @ref bx_timeline-update "update"
  1428. */
  1429. public function serviceUpdate($iEventId, $aSet)
  1430. {
  1431. if(empty($iEventId))
  1432. return false;
  1433. return (int)$this->_oDb->updateEvent($aSet, array('id' => $iEventId)) > 0;
  1434. }
  1435. /**
  1436. * @page service Service Calls
  1437. * @section bx_timeline Timeline
  1438. * @subsection bx_timeline-other Other
  1439. * @subsubsection bx_timeline-get_menu_item_addon_comment get_menu_item_addon_comment
  1440. *
  1441. * @code bx_srv('bx_timeline', 'get_menu_item_addon_comment', [...]); @endcode
  1442. *
  1443. * Get addon for Comment menu item.
  1444. *
  1445. * @param $sSystem string value with comments engine system.
  1446. * @param $iObjectId integer value with object ID.
  1447. * @return HTML string to display in menu item.
  1448. *
  1449. * @see BxTimelineModule::serviceGetMenuItemAddonComment
  1450. */
  1451. /**
  1452. * @ref bx_timeline-get_menu_item_addon_comment "get_menu_item_addon_comment"
  1453. */
  1454. public function serviceGetMenuItemAddonComment($sSystem, $iObjectId)
  1455. {
  1456. if(empty($sSystem) || empty($iObjectId))
  1457. return '';
  1458. $oCmts = $this->getCmtsObject($sSystem, $iObjectId);
  1459. if($oCmts === false)
  1460. return '';
  1461. $iCounter = (int)$oCmts->getCommentsCount();
  1462. return $this->_oTemplate->parseLink('javascript:void(0)', $iCounter > 0 ? $iCounter : '', array(
  1463. 'title' => _t('_bx_timeline_menu_item_title_item_comment'),
  1464. 'onclick' => "javascript:" . $this->_oConfig->getJsObject('view') . ".commentItem(this, '" . $sSystem . "', " . $iObjectId . ")"
  1465. ));
  1466. }
  1467. /**
  1468. * @page service Service Calls
  1469. * @section bx_timeline Timeline
  1470. * @subsection bx_timeline-other Other
  1471. * @subsubsection bx_timeline-get_settings_checker_helper get_settings_checker_helper
  1472. *
  1473. * @code bx_srv('bx_timeline', 'get_settings_checker_helper', [...]); @endcode
  1474. *
  1475. * Get Checker Helper class name for Forms engine.
  1476. *
  1477. * @return string with Checker Helper class name.
  1478. *
  1479. * @see BxTimelineModule::serviceGetSettingsCheckerHelper
  1480. */
  1481. /**
  1482. * @ref bx_timeline-get_settings_checker_helper "get_settings_checker_helper"
  1483. */
  1484. public function serviceGetSettingsCheckerHelper()
  1485. {
  1486. bx_import('FormCheckerHelper', $this->_aModule);
  1487. return 'BxTimelineFormCheckerHelper';
  1488. }
  1489. /**
  1490. * @page service Service Calls
  1491. * @section bx_timeline Timeline
  1492. * @subsection bx_timeline-other Other
  1493. * @subsubsection bx_timeline-get_options_videos_autoplay get_options_videos_autoplay
  1494. *
  1495. * @code bx_srv('bx_timeline', 'get_options_videos_autoplay', [...]); @endcode
  1496. *
  1497. * Get an array with available options for 'Videos autoplay in Timeline' setting.
  1498. *
  1499. * @return an array with available options represented as key => value pairs.
  1500. *
  1501. * @see BxTimelineModule::serviceGetOptionsVideosAutoplay
  1502. */
  1503. /**
  1504. * @ref bx_timeline-get_options_videos_autoplay "get_options_videos_autoplay"
  1505. */
  1506. public function serviceGetOptionsVideosAutoplay()
  1507. {
  1508. $aOptions = array(BX_TIMELINE_VAP_OFF, BX_TIMELINE_VAP_ON_MUTE, BX_TIMELINE_VAP_ON);
  1509. $aResult = array();
  1510. foreach($aOptions as $sOption)
  1511. $aResult[] = array(
  1512. 'key' => $sOption,
  1513. 'value' => _t('_bx_timeline_option_videos_autoplay_' . $sOption)
  1514. );
  1515. return $aResult;
  1516. }
  1517. /**
  1518. * @page service Service Calls
  1519. * @section bx_timeline Timeline
  1520. * @subsection bx_timeline-other Other
  1521. * @subsubsection bx_timeline-get_live_updates get_live_updates
  1522. *
  1523. * @code bx_srv('bx_timeline', 'get_live_updates', [...]); @endcode
  1524. *
  1525. * Get an array with actual Live Update info.
  1526. *
  1527. * @return an array with Live Update info.
  1528. *
  1529. * @see BxTimelineModule::serviceGetLiveUpdates
  1530. */
  1531. /**
  1532. * @ref bx_timeline-get_live_updates "get_live_updates"
  1533. */
  1534. public function serviceGetLiveUpdates($sType, $iOwnerId, $iProfileId, $iCount = 0, $iInit = 0)
  1535. {
  1536. $sKey = $this->_oConfig->getLiveUpdateKey($sType, $iOwnerId);
  1537. bx_import('BxDolSession');
  1538. if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
  1539. return false;
  1540. $aParams = $this->_prepareParams(BX_TIMELINE_VIEW_DEFAULT, $sType, $iOwnerId, false, false, BX_TIMELINE_FILTER_OTHER_VIEWER);
  1541. $aParams['count'] = true;
  1542. $iCountNew = $this->_oDb->getEvents($aParams);
  1543. if($iCountNew == $iCount)
  1544. return false;
  1545. if((int)$iInit != 0)
  1546. return array('count' => $iCountNew);
  1547. return array(
  1548. 'count' => $iCountNew, // required (for initialization and visualization)
  1549. 'method' => $this->_oConfig->getJsObject('view') . '.showLiveUpdate(oData)', // required (for visualization)
  1550. 'data' => array(
  1551. 'code' => $this->_oTemplate->getLiveUpdateNotification($sType, $iOwnerId, $iProfileId, $iCount, $iCountNew)
  1552. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  1553. );
  1554. }
  1555. /**
  1556. * @page service Service Calls
  1557. * @section bx_timeline Accounts
  1558. * @subsection bx_timeline-other Other
  1559. * @subsubsection bx_timeline-get_menu_addon_manage_tools get_menu_addon_manage_tools
  1560. *
  1561. * @code bx_srv('bx_timeline', 'get_menu_addon_manage_tools', [...]); @endcode
  1562. *
  1563. * Get number of 'hidden' events for User End -> Dasboard page -> Manage block.
  1564. *
  1565. * @return integer number of 'hidden' events
  1566. *
  1567. * @see BxTimelineModule::serviceGetMenuAddonManageTools
  1568. */
  1569. /**
  1570. * @ref bx_timeline-get_menu_addon_manage_tools "get_menu_addon_manage_tools"
  1571. */
  1572. public function serviceGetMenuAddonManageTools()
  1573. {
  1574. bx_import('SearchResult', $this->_aModule);
  1575. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  1576. $o = new $sClass();
  1577. $o->fillFilters(array(
  1578. 'active' => 0
  1579. ));
  1580. $o->unsetPaginate();
  1581. return $o->getNum();
  1582. }
  1583. /*
  1584. * COMMON METHODS
  1585. */
  1586. public function deleteEvent($aEvent)
  1587. {
  1588. if(empty($aEvent) || !is_array($aEvent) || !$this->_oDb->deleteEvent(array('id' => (int)$aEvent['id'])))
  1589. return false;
  1590. $this->onDelete($aEvent);
  1591. return true;
  1592. }
  1593. public function addAttachLink($aValues, $sDisplay = false)
  1594. {
  1595. $CNF = &$this->_oConfig->CNF;
  1596. if(!$sDisplay)
  1597. $sDisplay = $this->_oConfig->getObject('form_display_attach_link_add');
  1598. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_attach_link'), $sDisplay, $this->_oTemplate);
  1599. if(!$oForm)
  1600. return array('message' => '_sys_txt_error_occured');
  1601. $oForm->aFormAttrs['method'] = BX_DOL_FORM_METHOD_SPECIFIC;
  1602. $oForm->aParams['csrf']['disable'] = true;
  1603. if(!empty($oForm->aParams['db']['submit_name'])) {
  1604. $sSubmitName = $oForm->aParams['db']['submit_name'];
  1605. if(!isset($oForm->aInputs[$sSubmitName])) {
  1606. if(isset($oForm->aInputs[$CNF['FIELD_CONTROLS']]))
  1607. foreach($oForm->aInputs[$CNF['FIELD_CONTROLS']] as $mixedIndex => $aInput) {
  1608. if(!is_numeric($mixedIndex) || empty($aInput['name']) || $aInput['name'] != $sSubmitName)
  1609. continue;
  1610. $aValues[$sSubmitName] = $aInput['value'];
  1611. }
  1612. }
  1613. else
  1614. $aValues[$sSubmitName] = $oForm->aInputs[$sSubmitName]['value'];
  1615. }
  1616. $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url');
  1617. $oForm->initChecker(array(), $aValues);
  1618. if(!$oForm->isSubmittedAndValid())
  1619. return array('message' => '_sys_txt_error_occured');
  1620. return $this->_addLink($oForm);
  1621. }
  1622. public function getFormAttachLink()
  1623. {
  1624. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_attach_link'), $this->_oConfig->getObject('form_display_attach_link_add'), $this->_oTemplate);
  1625. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'submit_attach_link_form/';
  1626. $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url');
  1627. $oForm->initChecker();
  1628. if($oForm->isSubmittedAndValid())
  1629. return $this->_addLink($oForm);
  1630. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  1631. }
  1632. public function getFormPost($aParams = array())
  1633. {
  1634. $iUserId = $this->getUserId();
  1635. $oForm = $this->getFormPostObject($aParams);
  1636. $oForm->initChecker();
  1637. $bAjaxMode = $oForm->isAjaxMode();
  1638. $bDynamicMode = $bAjaxMode;
  1639. if($oForm->isSubmittedAndValid()) {
  1640. list($sUserName) = $this->getUserInfo($iUserId);
  1641. $sType = $oForm->getCleanValue('type');
  1642. $sType = $this->_oConfig->getPrefix('common_post') . $sType;
  1643. BxDolForm::setSubmittedValue('type', $sType, $oForm->aFormAttrs['method']);
  1644. $aContent = array();
  1645. //--- Process Text ---//
  1646. $sText = $oForm->getCleanValue('text');
  1647. $sText = $this->_prepareTextForSave($sText);
  1648. $bText = !empty($sText);
  1649. if($bText)
  1650. $aContent['text'] = $sText;
  1651. //--- Process Context and Privacy ---//
  1652. $iOwnerId = (int)$oForm->getCleanValue('owner_id');
  1653. $iObjectPrivacyView = (int)$oForm->getCleanValue('object_privacy_view');
  1654. $iObjectPrivacyViewDefault = $this->_oConfig->getPrivacyViewDefault('object');
  1655. if(empty($iObjectPrivacyView))
  1656. $iObjectPrivacyView = $iObjectPrivacyViewDefault;
  1657. else if($iObjectPrivacyView < 0)
  1658. $iOwnerId = abs($iObjectPrivacyView);
  1659. //--- Process Link ---//
  1660. $aLinkIds = $oForm->getCleanValue('link');
  1661. $bLinkIds = !empty($aLinkIds) && is_array($aLinkIds);
  1662. //--- Process Media ---//
  1663. $aPhotoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_PHOTO);
  1664. $bPhotoIds = !empty($aPhotoIds) && is_array($aPhotoIds);
  1665. $aVideoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_VIDEO);
  1666. $bVideoIds = !empty($aVideoIds) && is_array($aVideoIds);
  1667. if(!$bText && !$bLinkIds && !$bPhotoIds && !$bVideoIds) {
  1668. $oForm->aInputs['text']['error'] = _t('_bx_timeline_txt_err_empty_post');
  1669. $oForm->setValid(false);
  1670. return $this->_prepareResponse(array('form' => $oForm->getCode($bDynamicMode), 'form_id' => $oForm->id), $bAjaxMode);
  1671. }
  1672. $sTitle = $bText ? $this->_oConfig->getTitle($sText) : $this->_oConfig->getTitleDefault($bLinkIds, $bPhotoIds, $bVideoIds);
  1673. $sDescription = _t('_bx_timeline_txt_user_added_sample', '{profile_name}', _t('_bx_timeline_txt_sample_with_article'));
  1674. //--- Process Date ---//
  1675. $iDate = 0;
  1676. if(isset($oForm->aInputs['date']))
  1677. $iDate = $oForm->getCleanValue('date');
  1678. if(empty($iDate))
  1679. $iDate = time();
  1680. /**
  1681. * Unset 'text' input because its data was already processed
  1682. * and will be saved via additional values which were passed
  1683. * to BxDolForm::insert method.
  1684. */
  1685. unset($oForm->aInputs['text']);
  1686. $iId = $oForm->insert(array(
  1687. 'owner_id' => $iOwnerId,
  1688. 'object_id' => $iUserId,
  1689. 'object_privacy_view' => $iObjectPrivacyView,
  1690. 'content' => serialize($aContent),
  1691. 'title' => $sTitle,
  1692. 'description' => $sDescription,
  1693. 'date' => $iDate
  1694. ));
  1695. if(!empty($iId)) {
  1696. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  1697. if($bText)
  1698. $oMetatags->metaAdd($iId, $sText);
  1699. $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
  1700. //--- Process Link ---//
  1701. if($bLinkIds)
  1702. foreach($aLinkIds as $iLinkId)
  1703. $this->_oDb->saveLink($iId, $iLinkId);
  1704. //--- Process Media ---//
  1705. if($bPhotoIds)
  1706. $this->_saveMedia(BX_TIMELINE_MEDIA_PHOTO, $iId, $aPhotoIds);
  1707. if($bVideoIds)
  1708. $this->_saveMedia(BX_TIMELINE_MEDIA_VIDEO, $iId, $aVideoIds);
  1709. $this->onPost($iId);
  1710. return $this->_prepareResponse(array('id' => $iId), $bAjaxMode, array(
  1711. 'redirect' => $this->_oConfig->getItemViewUrl(array('id' => $iId))
  1712. ));
  1713. }
  1714. return $this->_prepareResponse(array('message' => _t('_bx_timeline_txt_err_cannot_perform_action')), $bAjaxMode);
  1715. }
  1716. return $this->_prepareResponse(array('form' => $oForm->getCode($bDynamicMode), 'form_id' => $oForm->id), $bAjaxMode && $oForm->isSubmitted());
  1717. }
  1718. public function getFormEdit($iId, $aParams = array())
  1719. {
  1720. $CNF = &$this->_oConfig->CNF;
  1721. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  1722. if(empty($aEvent) || !is_array($aEvent))
  1723. return array();
  1724. $aContent = unserialize($aEvent['content']);
  1725. if(is_array($aContent) && !empty($aContent['text']))
  1726. $aEvent['text'] = $aContent['text'];
  1727. $bDynamicMode = isset($aParams['dynamic_mode']) ? (bool)$aParams['dynamic_mode'] : false;
  1728. $sFormObject = !empty($aParams['form_object']) ? $aParams['form_object'] : 'form_post';
  1729. $sFormDisplay = !empty($aParams['form_display']) ? $aParams['form_display'] : 'form_display_post_edit';
  1730. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject($sFormObject), $this->_oConfig->getObject($sFormDisplay), $this->_oTemplate);
  1731. $oForm->setId($this->_oConfig->getHtmlIds('view', 'edit_form') . $iId);
  1732. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'edit/' . $iId ;
  1733. foreach($oForm->aInputs[$CNF['FIELD_CONTROLS']] as $mixedIndex => $aInput) {
  1734. if(!is_numeric($mixedIndex))
  1735. continue;
  1736. $oForm->aInputs[$CNF['FIELD_CONTROLS']][$mixedIndex]['attrs'] = bx_replace_markers($aInput['attrs'], array(
  1737. 'js_object_view' => $this->_oConfig->getJsObject('view'),
  1738. 'content_id' => $iId
  1739. ));
  1740. }
  1741. $oForm->initChecker($aEvent);
  1742. if($oForm->isSubmittedAndValid()) {
  1743. $aContent = array();
  1744. //--- Process Text ---//
  1745. $sText = $oForm->getCleanValue('text');
  1746. $sText = $this->_prepareTextForSave($sText);
  1747. $bText = !empty($sText);
  1748. unset($oForm->aInputs['text']);
  1749. if($bText)
  1750. $aContent['text'] = $sText;
  1751. $aValsToAdd = array(
  1752. 'content' => serialize($aContent)
  1753. );
  1754. //--- Process Privacy ---//
  1755. $iObjectPrivacyView = (int)$oForm->getCleanValue('object_privacy_view');
  1756. $iObjectPrivacyViewDefault = $this->_oConfig->getPrivacyViewDefault('object');
  1757. if(empty($iObjectPrivacyView))
  1758. $aValsToAdd = array_merge($aValsToAdd, array(
  1759. 'object_privacy_view' => $iObjectPrivacyViewDefault
  1760. ));
  1761. else if($iObjectPrivacyView < 0)
  1762. $aValsToAdd = array_merge($aValsToAdd, array(
  1763. 'owner_id' => abs($iObjectPrivacyView),
  1764. 'object_privacy_view' => $iObjectPrivacyViewDefault
  1765. ));
  1766. //--- Process Date ---//
  1767. if(isset($oForm->aInputs['date'])) {
  1768. $iDate = $oForm->getCleanValue('date');
  1769. if(empty($iDate))
  1770. $iDate = time();
  1771. $aValsToAdd['date'] = $iDate;
  1772. }
  1773. if(!$oForm->update($iId, $aValsToAdd))
  1774. return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
  1775. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  1776. if($bText)
  1777. $oMetatags->metaAdd($iId, $sText);
  1778. $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
  1779. return array(
  1780. 'id' => $iId,
  1781. 'eval' => $this->_oConfig->getJsObject('view') . '.onEditPostSubmit(oData)'
  1782. );
  1783. }
  1784. return array(
  1785. 'id' => $iId,
  1786. 'form' => $oForm->getCode($bDynamicMode),
  1787. 'form_id' => $oForm->id,
  1788. 'eval' => $this->_oConfig->getJsObject('view') . '.onEditPost(oData)'
  1789. );
  1790. }
  1791. public function getFormPostObject($aParams)
  1792. {
  1793. $sFormObject = !empty($aParams['form_object']) ? $aParams['form_object'] : 'form_post';
  1794. $sFormDisplay = !empty($aParams['form_display']) ? $aParams['form_display'] : 'form_display_post_add';
  1795. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject($sFormObject), $this->_oConfig->getObject($sFormDisplay), $this->_oTemplate);
  1796. $sParamsKey = 'ajax_mode';
  1797. if(isset($aParams[$sParamsKey]) && is_bool($aParams[$sParamsKey]))
  1798. $oForm->setAjaxMode((bool)$aParams[$sParamsKey]);
  1799. $sParamsKey = 'visibility_autoselect';
  1800. if(isset($aParams[$sParamsKey]) && is_bool($aParams[$sParamsKey]))
  1801. $oForm->setVisibilityAutoselect((bool)$aParams[$sParamsKey]);
  1802. $oForm->init();
  1803. return $oForm;
  1804. }
  1805. public function getCmtsObject($sSystem, $iId)
  1806. {
  1807. if(empty($sSystem) || (int)$iId == 0)
  1808. return false;
  1809. $oCmts = BxDolCmts::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1810. if(!$oCmts || !$oCmts->isEnabled())
  1811. return false;
  1812. return $oCmts;
  1813. }
  1814. public function getViewObject($sSystem, $iId)
  1815. {
  1816. if(empty($sSystem) || (int)$iId == 0)
  1817. return false;
  1818. $oView = BxDolView::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1819. if(!$oView || !$oView->isEnabled())
  1820. return false;
  1821. return $oView;
  1822. }
  1823. public function getVoteObject($sSystem, $iId)
  1824. {
  1825. if(empty($sSystem) || (int)$iId == 0)
  1826. return false;
  1827. $oVote = BxDolVote::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1828. if(!$oVote || !$oVote->isEnabled())
  1829. return false;
  1830. return $oVote;
  1831. }
  1832. public function getScoreObject($sSystem, $iId)
  1833. {
  1834. if(empty($sSystem) || (int)$iId == 0)
  1835. return false;
  1836. $oScore = BxDolScore::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1837. if(!$oScore || !$oScore->isEnabled())
  1838. return false;
  1839. return $oScore;
  1840. }
  1841. public function getReportObject($sSystem, $iId)
  1842. {
  1843. if(empty($sSystem) || (int)$iId == 0)
  1844. return false;
  1845. $oReport = BxDolReport::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1846. if(!$oReport || !$oReport->isEnabled())
  1847. return false;
  1848. return $oReport;
  1849. }
  1850. public function getAttachmentsMenuObject()
  1851. {
  1852. $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_post_attachments'), $this->_oTemplate);
  1853. $oMenu->addMarkers(array(
  1854. 'js_object' => $this->_oConfig->getJsObject('post'),
  1855. ));
  1856. return $oMenu;
  1857. }
  1858. public function getManageMenuObject()
  1859. {
  1860. return BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_manage'), $this->_oTemplate);
  1861. }
  1862. //--- Check permissions methods ---//
  1863. public function isModerator()
  1864. {
  1865. $sModule = $this->getName();
  1866. $iUserId = (int)$this->getUserId();
  1867. $aCheckResult = checkActionModule($iUserId, 'edit', $sModule);
  1868. if($aCheckResult[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  1869. return true;
  1870. $aCheckResult = checkActionModule($iUserId, 'delete', $sModule);
  1871. if($aCheckResult[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  1872. return true;
  1873. return false;
  1874. }
  1875. public function isAllowedPost($bPerform = false)
  1876. {
  1877. if(isAdmin())
  1878. return true;
  1879. $iUserId = $this->getUserId();
  1880. $aCheckResult = checkActionModule($iUserId, 'post', $this->getName(), $bPerform);
  1881. $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
  1882. if($oProfileOwner !== false) {
  1883. if($oProfileOwner->checkAllowedPostInProfile() !== CHECK_ACTION_RESULT_ALLOWED)
  1884. return _t('_sys_txt_access_denied');
  1885. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_post', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1886. }
  1887. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1888. }
  1889. public function isAllowedView($aEvent, $bPerform = false)
  1890. {
  1891. $CNF = $this->_oConfig->CNF;
  1892. $mixedResult = BxDolProfile::getInstance($aEvent[$CNF['FIELD_OWNER_ID']])->checkAllowedProfileView();
  1893. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  1894. return false;
  1895. return true;
  1896. }
  1897. public function isAllowedEdit($aEvent, $bPerform = false)
  1898. {
  1899. if(!isLogged())
  1900. return false;
  1901. //--- System posts and Reposts cannot be edited at all.
  1902. if(!$this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) || $aEvent['type'] == $this->_oConfig->getPrefix('common_post') . 'repost')
  1903. return false;
  1904. if(isAdmin())
  1905. return true;
  1906. $iUserId = (int)$this->getUserId();
  1907. $iOwnerId = (int)$aEvent['owner_id'];
  1908. $iObjectId = abs((int)$aEvent['object_id']);
  1909. if($iObjectId == $iUserId && $this->_oConfig->isAllowEdit())
  1910. return true;
  1911. $aCheckResult = checkActionModule($iUserId, 'edit', $this->getName(), $bPerform);
  1912. $oProfileOwner = BxDolProfile::getInstance($iOwnerId);
  1913. if($oProfileOwner !== false)
  1914. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_edit', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1915. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1916. }
  1917. public function isAllowedDelete($aEvent, $bPerform = false)
  1918. {
  1919. if(!isLogged())
  1920. return false;
  1921. if(isAdmin())
  1922. return true;
  1923. $iUserId = (int)$this->getUserId();
  1924. $iOwnerId = (int)$aEvent['owner_id'];
  1925. $iObjectId = abs((int)$aEvent['object_id']);
  1926. if((($iOwnerId == $iUserId && $this->_oConfig->isAllowDelete()) || ($this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) && $iObjectId == $iUserId)))
  1927. return true;
  1928. $aCheckResult = checkActionModule($iUserId, 'delete', $this->getName(), $bPerform);
  1929. $oProfileOwner = BxDolProfile::getInstance($iOwnerId);
  1930. if($oProfileOwner !== false)
  1931. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_delete', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1932. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1933. }
  1934. public function isAllowedComment($aEvent, $bPerform = false)
  1935. {
  1936. $mixedComments = $this->getCommentsData($aEvent['comments']);
  1937. if($mixedComments === false)
  1938. return false;
  1939. list($sSystem, $iObjectId) = $mixedComments;
  1940. $oCmts = $this->getCmtsObject($sSystem, $iObjectId);
  1941. $oCmts->addCssJs();
  1942. $bResult = true;
  1943. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1944. if($oProfileOwner !== false) {
  1945. if($oProfileOwner->checkAllowedPostInProfile() !== CHECK_ACTION_RESULT_ALLOWED)
  1946. return false;
  1947. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_comment', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1948. }
  1949. return $bResult;
  1950. }
  1951. public function isAllowedViewCounter($aEvent, $bPerform = false)
  1952. {
  1953. $mixedViews = $this->getViewsData($aEvent['views']);
  1954. if($mixedViews === false)
  1955. return false;
  1956. list($sSystem, $iObjectId) = $mixedViews;
  1957. $oView = $this->getViewObject($sSystem, $iObjectId);
  1958. if(!$oView->isAllowedViewView($bPerform))
  1959. return false;
  1960. $bResult = true;
  1961. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1962. if($oProfileOwner !== false)
  1963. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view_counter', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1964. return $bResult;
  1965. }
  1966. public function isAllowedVote($aEvent, $bPerform = false)
  1967. {
  1968. $mixedVotes = $this->getVotesData($aEvent['votes']);
  1969. if($mixedVotes === false)
  1970. return false;
  1971. list($sSystem, $iObjectId) = $mixedVotes;
  1972. $oVote = $this->getVoteObject($sSystem, $iObjectId);
  1973. if(!$oVote->isAllowedVote($bPerform))
  1974. return false;
  1975. $bResult = true;
  1976. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1977. if($oProfileOwner !== false)
  1978. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1979. return $bResult;
  1980. }
  1981. public function isAllowedScore($aEvent, $bPerform = false)
  1982. {
  1983. $mixedScores = $this->getScoresData($aEvent['scores']);
  1984. if($mixedScores === false)
  1985. return false;
  1986. list($sSystem, $iObjectId) = $mixedScores;
  1987. $oScore = $this->getScoreObject($sSystem, $iObjectId);
  1988. if(!$oScore->isAllowedVote($bPerform))
  1989. return false;
  1990. $bResult = true;
  1991. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1992. if($oProfileOwner !== false)
  1993. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_score', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1994. return $bResult;
  1995. }
  1996. public function isAllowedReport($aEvent, $bPerform = false)
  1997. {
  1998. $mixedReports = $this->getReportsData($aEvent['reports']);
  1999. if($mixedReports === false)
  2000. return false;
  2001. list($sSystem, $iObjectId) = $mixedReports;
  2002. $oReport = $this->getReportObject($sSystem, $iObjectId);
  2003. if(!$oReport->isAllowedReport($bPerform))
  2004. return false;
  2005. $bResult = true;
  2006. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2007. if($oProfileOwner !== false)
  2008. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_report', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  2009. return $bResult;
  2010. }
  2011. public function isAllowedRepost($aEvent, $bPerform = false)
  2012. {
  2013. if(isAdmin())
  2014. return true;
  2015. $iUserId = (int)$this->getUserId();
  2016. if($iUserId == 0)
  2017. return false;
  2018. $aCheckResult = checkActionModule($iUserId, 'repost', $this->getName(), $bPerform);
  2019. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2020. if($oProfileOwner !== false)
  2021. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_repost', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  2022. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  2023. }
  2024. public function isAllowedSend($aEvent, $bPerform = false)
  2025. {
  2026. if(!$this->_oDb->isEnabledByName('bx_convos'))
  2027. return false;
  2028. if(isAdmin())
  2029. return true;
  2030. $iUserId = (int)$this->getUserId();
  2031. if($iUserId == 0)
  2032. return false;
  2033. $aCheckResult = checkActionModule($iUserId, 'send', $this->getName(), $bPerform);
  2034. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2035. if($oProfileOwner !== false)
  2036. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_send', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  2037. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  2038. }
  2039. /**
  2040. * Pin - "Pin here" - pin the post on Profile Timeline for profile owner.
  2041. * Can be done by profile owner for himself or by admin for profile owner to see.
  2042. * @param type $aEvent
  2043. * @param type $bPerform
  2044. * @return boolean
  2045. */
  2046. public function isAllowedPin($aEvent, $bPerform = false)
  2047. {
  2048. if((int)$aEvent['pinned'] != 0)
  2049. return false;
  2050. return $this->_isAllowedPin($aEvent, $bPerform);
  2051. }
  2052. public function isAllowedUnpin($aEvent, $bPerform = false)
  2053. {
  2054. if((int)$aEvent['pinned'] == 0)
  2055. return false;
  2056. return $this->_isAllowedPin($aEvent, $bPerform);
  2057. }
  2058. /**
  2059. * Stick - "Pin for All" - pin the post on Public Timeline for everybody to see.
  2060. * Is available for Administrators/Moderators only.
  2061. * @param type $aEvent
  2062. * @param type $bPerform
  2063. * @return boolean
  2064. */
  2065. public function isAllowedStick($aEvent, $bPerform = false)
  2066. {
  2067. if((int)$aEvent['sticked'] != 0)
  2068. return false;
  2069. return $this->_isAllowedStick($aEvent, $bPerform);
  2070. }
  2071. public function isAllowedUnstick($aEvent, $bPerform = false)
  2072. {
  2073. if((int)$aEvent['sticked'] == 0)
  2074. return false;
  2075. return $this->_isAllowedStick($aEvent, $bPerform);
  2076. }
  2077. public function isAllowedPromote($aEvent, $bPerform = false)
  2078. {
  2079. if((int)$aEvent['promoted'] != 0)
  2080. return false;
  2081. return $this->_isAllowedPromote($aEvent, $bPerform);
  2082. }
  2083. public function isAllowedUnpromote($aEvent, $bPerform = false)
  2084. {
  2085. if((int)$aEvent['promoted'] == 0)
  2086. return false;
  2087. return $this->_isAllowedPromote($aEvent, $bPerform);
  2088. }
  2089. public function isAllowedMore($aEvent, $bPerform = false)
  2090. {
  2091. $oMoreMenu = $this->getManageMenuObject();
  2092. $oMoreMenu->setEventById($aEvent['id']);
  2093. return $oMoreMenu->isVisible();
  2094. }
  2095. public function checkAllowedView ($aContentInfo, $isPerformAction = false)
  2096. {
  2097. if(!$this->isAllowedView($aContentInfo, $isPerformAction))
  2098. return _t('_sys_txt_access_denied');
  2099. return CHECK_ACTION_RESULT_ALLOWED;
  2100. }
  2101. public function checkAllowedCommentsView ($aContentInfo, $isPerformAction = false)
  2102. {
  2103. $CNF = $this->_oConfig->CNF;
  2104. $mixedResult = BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_OWNER_ID']])->checkAllowedProfileView();
  2105. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  2106. return $mixedResult;
  2107. return CHECK_ACTION_RESULT_ALLOWED;
  2108. }
  2109. public function checkAllowedCommentsPost ($aContentInfo, $isPerformAction = false)
  2110. {
  2111. $sError = '_sys_txt_access_denied';
  2112. $aContentInfo = $this->_oTemplate->getData($aContentInfo);
  2113. if($aContentInfo === false)
  2114. return _t($sError);
  2115. if(!$this->isAllowedComment($aContentInfo, $isPerformAction))
  2116. return _t($sError);
  2117. return CHECK_ACTION_RESULT_ALLOWED;
  2118. }
  2119. public function onPost($iId)
  2120. {
  2121. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  2122. if($this->_oConfig->isSystem($aEvent['type'], $aEvent['action'])) {
  2123. //--- Request event's data from content module and update it in the Timeline DB.
  2124. $this->_oTemplate->getData($aEvent);
  2125. $sPostType = 'system';
  2126. $iSenderId = $aEvent['owner_id'];
  2127. } else {
  2128. $sPostType = 'common';
  2129. $iSenderId = $aEvent['object_id'];
  2130. }
  2131. //--- Event -> Post for Alerts Engine ---//
  2132. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'post_' . $sPostType, $iId, $iSenderId, array(
  2133. 'privacy_view' => $aEvent['object_privacy_view'],
  2134. 'object_author_id' => $aEvent['owner_id'],
  2135. ));
  2136. $oAlert->alert();
  2137. //--- Event -> Post for Alerts Engine ---//
  2138. }
  2139. public function onRepost($iId, $aReposted = array())
  2140. {
  2141. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  2142. if(empty($aReposted)) {
  2143. $aContent = unserialize($aEvent['content']);
  2144. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  2145. if(empty($aReposted) || !is_array($aReposted))
  2146. return;
  2147. }
  2148. $iUserId = $this->getUserId();
  2149. $this->_oDb->insertRepostTrack($aEvent['id'], $iUserId, $this->getUserIp(), $aReposted['id']);
  2150. $this->_oDb->updateRepostCounter($aReposted['id'], $aReposted['reposts']);
  2151. //--- Timeline -> Update for Alerts Engine ---//
  2152. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'repost', $aReposted['id'], $iUserId, array(
  2153. 'privacy_view' => $aEvent['object_privacy_view'],
  2154. 'object_author_id' => $aReposted['owner_id'],
  2155. 'repost_id' => $iId,
  2156. ));
  2157. $oAlert->alert();
  2158. //--- Timeline -> Update for Alerts Engine ---//
  2159. }
  2160. public function onDelete($aEvent)
  2161. {
  2162. $iUserId = $this->getUserId();
  2163. $sCommonPostPrefix = $this->_oConfig->getPrefix('common_post');
  2164. $sCommonPostComment = $this->_oConfig->getObject('comment');
  2165. //--- Delete comments for Common posts.
  2166. if($this->_oConfig->isCommon($aEvent['type'], $aEvent['action'])) {
  2167. $oComments = $this->getCmtsObject($sCommonPostComment, $aEvent['id']);
  2168. if($oComments !== false)
  2169. $oComments->onObjectDelete($aEvent['id']);
  2170. }
  2171. //--- Delete attached photos, videos and links when common event was deleted.
  2172. if($aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_POST) {
  2173. $this->_deleteMedia(BX_TIMELINE_MEDIA_PHOTO, $aEvent['id']);
  2174. $this->_deleteMedia(BX_TIMELINE_MEDIA_VIDEO, $aEvent['id']);
  2175. $this->_deleteLinks($aEvent['id']);
  2176. }
  2177. //--- Update parent event when repost event was deleted.
  2178. $bRepost = $aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_REPOST;
  2179. if($bRepost) {
  2180. $this->_oDb->deleteRepostTrack($aEvent['id']);
  2181. $aContent = unserialize($aEvent['content']);
  2182. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  2183. if(!empty($aReposted) && is_array($aReposted))
  2184. $this->_oDb->updateRepostCounter($aReposted['id'], $aReposted['reposts'], -1);
  2185. }
  2186. //--- Find and delete repost events when parent event was deleted.
  2187. $bSystem = $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']);
  2188. $aRepostEvents = $this->_oDb->getEvents(array('browse' => 'reposted_by_descriptor', 'type' => $aEvent['type']));
  2189. foreach($aRepostEvents as $aRepostEvent) {
  2190. $aContent = unserialize($aRepostEvent['content']);
  2191. 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) {
  2192. $oComments = $this->getCmtsObject($sCommonPostComment, $aRepostEvent['id']);
  2193. if($oComments !== false)
  2194. $oComments->onObjectDelete($aRepostEvent['id']);
  2195. bx_alert($this->_oConfig->getObject('alert'), 'delete_repost', $aEvent['id'], $iUserId, array(
  2196. 'repost_id' => $aRepostEvent['id'],
  2197. ));
  2198. }
  2199. }
  2200. //--- Delete associated meta.
  2201. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  2202. $oMetatags->onDeleteContent($aEvent['id']);
  2203. //--- Event -> Delete for Alerts Engine ---//
  2204. if($bRepost)
  2205. bx_alert($this->_oConfig->getObject('alert'), 'delete_repost', $aReposted['id'], $iUserId, array(
  2206. 'repost_id' => $aEvent['id'],
  2207. ));
  2208. else
  2209. bx_alert($this->_oConfig->getObject('alert'), 'delete', $aEvent['id'], $iUserId);
  2210. //--- Event -> Delete for Alerts Engine ---//
  2211. }
  2212. public function getParams($sView = '', $sType = '', $iOwnerId = 0, $iStart = 0, $iPerPage = 0, $sFilter = BX_TIMELINE_FILTER_ALL, $aModules = array(), $iTimeline = 0)
  2213. {
  2214. return $this->_prepareParams($sView, $sType, $iOwnerId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  2215. }
  2216. public function getViewsData(&$aViews)
  2217. {
  2218. if(empty($aViews) || !is_array($aViews))
  2219. return false;
  2220. $sSystem = isset($aViews['system']) ? $aViews['system'] : '';
  2221. $iObjectId = isset($aViews['object_id']) ? (int)$aViews['object_id'] : 0;
  2222. $iCount = isset($aViews['count']) ? (int)$aViews['count'] : 0;
  2223. if($sSystem == '' || $iObjectId == 0)
  2224. return false;
  2225. return array($sSystem, $iObjectId, $iCount);
  2226. }
  2227. public function getVotesData(&$aVotes)
  2228. {
  2229. if(empty($aVotes) || !is_array($aVotes))
  2230. return false;
  2231. $sSystem = isset($aVotes['system']) ? $aVotes['system'] : '';
  2232. $iObjectId = isset($aVotes['object_id']) ? (int)$aVotes['object_id'] : 0;
  2233. $iCount = isset($aVotes['count']) ? (int)$aVotes['count'] : 0;
  2234. if($sSystem == '' || $iObjectId == 0)
  2235. return false;
  2236. return array($sSystem, $iObjectId, $iCount);
  2237. }
  2238. public function getScoresData(&$aScores)
  2239. {
  2240. if(empty($aScores) || !is_array($aScores))
  2241. return false;
  2242. $sSystem = isset($aScores['system']) ? $aScores['system'] : '';
  2243. $iObjectId = isset($aScores['object_id']) ? (int)$aScores['object_id'] : 0;
  2244. $iScore = isset($aScores['score']) ? (int)$aScores['score'] : 0;
  2245. if($sSystem == '' || $iObjectId == 0)
  2246. return false;
  2247. return array($sSystem, $iObjectId, $iScore);
  2248. }
  2249. public function getReportsData(&$aReports)
  2250. {
  2251. if(empty($aReports) || !is_array($aReports))
  2252. return false;
  2253. $sSystem = isset($aReports['system']) ? $aReports['system'] : '';
  2254. $iObjectId = isset($aReports['object_id']) ? (int)$aReports['object_id'] : 0;
  2255. $iCount = isset($aReports['count']) ? (int)$aReports['count'] : 0;
  2256. if($sSystem == '' || $iObjectId == 0)
  2257. return false;
  2258. return array($sSystem, $iObjectId, $iCount);
  2259. }
  2260. public function getCommentsData(&$aComments)
  2261. {
  2262. if(empty($aComments) || !is_array($aComments))
  2263. return false;
  2264. $sSystem = isset($aComments['system']) ? $aComments['system'] : '';
  2265. $iObjectId = isset($aComments['object_id']) ? (int)$aComments['object_id'] : 0;
  2266. $iCount = isset($aComments['count']) ? (int)$aComments['count'] : 0;
  2267. if($sSystem == '' || $iObjectId == 0 || ($iCount == 0 && !isLogged()))
  2268. return false;
  2269. return array($sSystem, $iObjectId, $iCount);
  2270. }
  2271. public function getUserInfo($iUserId = 0)
  2272. {
  2273. $iLoggedId = $this->getUserId();
  2274. $iUserId = (int)$iUserId;
  2275. return parent::getUserInfo($iUserId);
  2276. }
  2277. /**
  2278. * Protected Methods
  2279. */
  2280. protected function _serviceGetBlockView($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT)
  2281. {
  2282. if(empty($iProfileId) && bx_get('profile_id') !== false)
  2283. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  2284. if(empty($iProfileId) && isLogged())
  2285. $iProfileId = bx_get_logged_profile_id();
  2286. $aBlock = $this->_getBlockView($iProfileId, $sView);
  2287. if(!empty($aBlock))
  2288. return $aBlock;
  2289. return array('content' => MsgBox(_t('_bx_timeline_txt_msg_no_results')));
  2290. }
  2291. protected function _serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  2292. {
  2293. if(empty($sProfileModule))
  2294. return array();
  2295. if(empty($iProfileContentId) && bx_get('id') !== false)
  2296. $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  2297. $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
  2298. if(empty($oProfile))
  2299. return array();
  2300. return $this->_getBlockView($oProfile->id(), $sView, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  2301. }
  2302. protected function _serviceGetBlockViewHome($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $iPerPageDefault = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  2303. {
  2304. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_BASE_MOD_NTFS_TYPE_PUBLIC . '/';
  2305. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view_home'), $sRssUrl);
  2306. return $this->_serviceGetBlockViewByType($iProfileId, $sView, BX_BASE_MOD_NTFS_TYPE_PUBLIC, $iStart, $iPerPage, $iPerPageDefault, $iTimeline, $sFilter, $aModules);
  2307. }
  2308. protected function _serviceGetBlockViewHot($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $iPerPageDefault = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  2309. {
  2310. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_TIMELINE_TYPE_HOT . '/';
  2311. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view_hot'), $sRssUrl);
  2312. return $this->_serviceGetBlockViewByType($iProfileId, $sView, BX_TIMELINE_TYPE_HOT, $iStart, $iPerPage, $iPerPageDefault, $iTimeline, $sFilter, $aModules);
  2313. }
  2314. 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())
  2315. {
  2316. $aParams = $this->_prepareParams($sView, $sType, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  2317. $aParams['view'] = $sView;
  2318. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : ((int)$iPerPageDefault > 0 ? $iPerPageDefault : $this->_oConfig->getPerPage());
  2319. $this->_iOwnerId = $aParams['owner_id'];
  2320. $sContent = $this->_oTemplate->getViewBlock($aParams);
  2321. return array('content' => $sContent);
  2322. }
  2323. protected function _getBlockPost($iProfileId, $aParams = array())
  2324. {
  2325. $this->_iOwnerId = $iProfileId;
  2326. if($this->isAllowedPost() !== true)
  2327. return array();
  2328. $sContent = $this->_oTemplate->getPostBlock($this->_iOwnerId, $aParams);
  2329. return array('content' => $sContent);
  2330. }
  2331. protected function _getBlockView($iProfileId, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  2332. {
  2333. if(!$iProfileId)
  2334. return array();
  2335. $aParams = $this->_prepareParams($sView, BX_BASE_MOD_NTFS_TYPE_OWNER, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  2336. $aParams['view'] = $sView;
  2337. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage('profile');
  2338. $this->_iOwnerId = $aParams['owner_id'];
  2339. $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
  2340. $mixedResult = $oProfileOwner->checkAllowedProfileView();
  2341. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  2342. return array('content' => MsgBox($mixedResult));
  2343. list($sUserName, $sUserUrl) = $this->getUserInfo($aParams['owner_id']);
  2344. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_BASE_MOD_NTFS_TYPE_OWNER . '/' . $iProfileId . '/';
  2345. $sJsObject = $this->_oConfig->getJsObject('view');
  2346. $aMenu = array(
  2347. 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),
  2348. 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)),
  2349. 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')),
  2350. array('id' => $sView . '-get-rss', 'name' => $sView . '-get-rss', 'class' => '', 'link' => $sRssUrl, 'target' => '_blank', 'title' => _t('_bx_timeline_menu_item_get_rss')),
  2351. );
  2352. $sContent = '';
  2353. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view', $this->_iOwnerId, $this->getUserId(), array('override_content' => &$sContent, 'params' => &$aParams, 'menu' => &$aMenu));
  2354. $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> $sView . '-view-all', 'menu_items' => $aMenu));
  2355. $oMenu->setSelected('', $sView . '-view-all');
  2356. if (!$sContent)
  2357. $sContent = $this->_oTemplate->getViewBlock($aParams);
  2358. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view'), $sRssUrl);
  2359. return array('content' => $sContent, 'menu' => $oMenu);
  2360. }
  2361. protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
  2362. {
  2363. $CNF = &$this->_oConfig->CNF;
  2364. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  2365. $sText = '';
  2366. if(isset($aContentInfo['content'])){
  2367. $aTmp = unserialize($aContentInfo['content']);
  2368. if(isset($aTmp['text']))
  2369. $sText = $aTmp['text'];
  2370. }
  2371. if(empty($sText) && !empty($aContentInfo[$CNF['FIELD_TITLE']]))
  2372. $sText = $aContentInfo[$CNF['FIELD_TITLE']];
  2373. if(!empty($CNF['OBJECT_METATAGS']) && !empty($sText)) {
  2374. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  2375. $sText = $oMetatags->metaParse($aContentInfo[$CNF['FIELD_ID']], $sText);
  2376. }
  2377. return array(
  2378. 'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
  2379. 'sample_wo_article' => $CNF['T']['txt_sample_single'],
  2380. 'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
  2381. 'url' => $sUrl,
  2382. 'title' => '',
  2383. 'text' => $sText,
  2384. 'images' => array(),
  2385. 'videos' => array()
  2386. );
  2387. }
  2388. protected function _isAllowedPin($aEvent, $bPerform = false)
  2389. {
  2390. $iUserId = (int)$this->getUserId();
  2391. if($iUserId == 0)
  2392. return false;
  2393. if(isAdmin() || (int)$aEvent['owner_id'] == $iUserId || ((int)$aEvent['owner_id'] == 0 && $this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) && (int)$aEvent['object_id'] == $iUserId))
  2394. return true;
  2395. $aCheckResult = checkActionModule($iUserId, 'pin', $this->getName(), $bPerform);
  2396. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2397. if($oProfileOwner !== false)
  2398. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_pin', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  2399. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  2400. }
  2401. protected function _isAllowedStick($aEvent, $bPerform = false)
  2402. {
  2403. $iUserId = (int)$this->getUserId();
  2404. if($iUserId == 0)
  2405. return false;
  2406. if(isAdmin())
  2407. return true;
  2408. $aCheckResult = checkActionModule($iUserId, 'stick', $this->getName(), $bPerform);
  2409. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2410. if($oProfileOwner !== false)
  2411. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_stick', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  2412. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  2413. }
  2414. protected function _isAllowedPromote($aEvent, $bPerform = false)
  2415. {
  2416. if(isAdmin())
  2417. return true;
  2418. $iUserId = (int)$this->getUserId();
  2419. if($iUserId == 0)
  2420. return false;
  2421. $aCheckResult = checkActionModule($iUserId, 'promote', $this->getName(), $bPerform);
  2422. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2423. if($oProfileOwner !== false)
  2424. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_promote', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  2425. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  2426. }
  2427. protected function _addLink(&$oForm)
  2428. {
  2429. $iUserId = $this->getUserId();
  2430. $sLink = $oForm->getCleanValue('url');
  2431. $aMatches = array();
  2432. preg_match($this->_oConfig->getPregPattern('url'), $sLink, $aMatches);
  2433. $sLink = (empty($aMatches[2]) ? 'http://' : '') . $aMatches[0];
  2434. $aSiteInfo = bx_get_site_info($sLink, array(
  2435. 'thumbnailUrl' => array('tag' => 'link', 'content_attr' => 'href'),
  2436. 'OGImage' => array('name_attr' => 'property', 'name' => 'og:image'),
  2437. ));
  2438. $sTitle = !empty($aSiteInfo['title']) ? $aSiteInfo['title'] : _t('_Empty');
  2439. $sDescription = !empty($aSiteInfo['description']) ? $aSiteInfo['description'] : _t('_Empty');
  2440. $sMediaUrl = '';
  2441. if(!empty($aSiteInfo['thumbnailUrl']))
  2442. $sMediaUrl = $aSiteInfo['thumbnailUrl'];
  2443. else if(!empty($aSiteInfo['OGImage']))
  2444. $sMediaUrl = $aSiteInfo['OGImage'];
  2445. $iMediaId = 0;
  2446. $oStorage = null;
  2447. if(!empty($sMediaUrl)) {
  2448. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . BX_TIMELINE_MEDIA_PHOTO . 's'));
  2449. $iMediaId = $oStorage->storeFileFromUrl($sMediaUrl, true, $iUserId);
  2450. }
  2451. $iId = (int)$oForm->insert(array('profile_id' => $iUserId, 'media_id' => $iMediaId, 'url' => $sLink, 'title' => $sTitle, 'text' => $sDescription, 'added' => time()));
  2452. if(!empty($iId)) {
  2453. if(!empty($oStorage) && !empty($iMediaId))
  2454. $oStorage->afterUploadCleanup($iMediaId, $iUserId);
  2455. return array('id' => $iId, 'item' => $this->_oTemplate->getAttachLinkItem($iUserId, $iId));
  2456. }
  2457. return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
  2458. }
  2459. protected function _deleteLinks($iId)
  2460. {
  2461. $aLinks = $this->_oDb->getLinks($iId);
  2462. if(empty($aLinks) || !is_array($aLinks))
  2463. return;
  2464. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'));
  2465. foreach($aLinks as $aLink)
  2466. if(!empty($aLink['media_id']))
  2467. $oStorage->deleteFile($aLink['media_id']);
  2468. $this->_oDb->deleteLinks($iId);
  2469. }
  2470. protected function _saveMedia($sType, $iId, $aItemIds)
  2471. {
  2472. if(empty($aItemIds) || !is_array($aItemIds))
  2473. return;
  2474. $iUserId = $this->getUserId();
  2475. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
  2476. foreach($aItemIds as $iItemId)
  2477. if($this->_oDb->saveMedia($sType, $iId, $iItemId))
  2478. $oStorage->afterUploadCleanup($iItemId, $iUserId);
  2479. }
  2480. protected function _deleteMedia($sType, $iId)
  2481. {
  2482. $aItems = $this->_oDb->getMedia($sType, $iId);
  2483. if(empty($aItems) || !is_array($aItems))
  2484. return;
  2485. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
  2486. foreach($aItems as $iItemId)
  2487. $oStorage->deleteFile($iItemId);
  2488. $this->_oDb->deleteMedia($sType, $iId);
  2489. }
  2490. protected function _prepareParams($sView, $sType, $iOwnerId, $iStart, $iPerPage, $sFilter = BX_TIMELINE_FILTER_ALL, $aModules = array(), $iTimeline = 0, $aBlink = array())
  2491. {
  2492. $aParams = array(
  2493. 'view' => !empty($sView) ? $sView : BX_TIMELINE_VIEW_DEFAULT,
  2494. 'browse' => 'list',
  2495. 'type' => !empty($sType) ? $sType : BX_TIMELINE_TYPE_DEFAULT,
  2496. 'owner_id' => (int)$iOwnerId != 0 ? $iOwnerId : $this->getUserId(),
  2497. 'filter' => !empty($sFilter) ? $sFilter : BX_TIMELINE_FILTER_ALL,
  2498. 'modules' => is_array($aModules) && !empty($aModules) ? $aModules : array(),
  2499. 'timeline' => (int)$iTimeline > 0 ? $iTimeline : 0,
  2500. 'blink' => is_array($aBlink) && !empty($aBlink) ? $aBlink : array(),
  2501. 'active' => 1,
  2502. 'hidden' => 0
  2503. );
  2504. if($iStart !== false)
  2505. $aParams['start'] = (int)$iStart > 0 ? $iStart : 0;
  2506. if($iPerPage !== false)
  2507. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage();
  2508. if($this->_oConfig->isHot())
  2509. $aParams['hot'] = $this->_oDb->getHot();
  2510. return $aParams;
  2511. }
  2512. protected function _prepareParamsGet()
  2513. {
  2514. $aParams = array(
  2515. 'browse' => 'list',
  2516. 'dynamic_mode' => true,
  2517. );
  2518. $aParams['view'] = bx_get('view');
  2519. $aParams['view'] = $aParams['view'] !== false ? bx_process_input($aParams['view'], BX_DATA_TEXT) : BX_TIMELINE_VIEW_DEFAULT;
  2520. $aParams['type'] = bx_get('type');
  2521. $aParams['type'] = $aParams['type'] !== false ? bx_process_input($aParams['type'], BX_DATA_TEXT) : BX_TIMELINE_TYPE_DEFAULT;
  2522. $aParams['owner_id'] = bx_get('owner_id');
  2523. $aParams['owner_id'] = $aParams['owner_id'] !== false ? bx_process_input($aParams['owner_id'], BX_DATA_INT) : $this->getUserId();
  2524. $aParams['start'] = bx_get('start');
  2525. $aParams['start'] = $aParams['start'] !== false ? bx_process_input($aParams['start'], BX_DATA_INT) : 0;
  2526. $aParams['per_page'] = bx_get('per_page');
  2527. $aParams['per_page'] = $aParams['per_page'] !== false ? bx_process_input($aParams['per_page'], BX_DATA_INT) : $this->_oConfig->getPerPage();
  2528. $aParams['filter'] = bx_get('filter');
  2529. $aParams['filter'] = $aParams['filter'] !== false ? bx_process_input($aParams['filter'], BX_DATA_TEXT) : BX_TIMELINE_FILTER_ALL;
  2530. $aParams['modules'] = bx_get('modules');
  2531. $aParams['modules'] = $aParams['modules'] !== false ? bx_process_input($aParams['modules'], BX_DATA_TEXT) : array();
  2532. $aParams['timeline'] = bx_get('timeline');
  2533. $aParams['timeline'] = $aParams['timeline'] !== false ? bx_process_input($aParams['timeline'], BX_DATA_INT) : 0;
  2534. $aParams['blink'] = bx_get('blink');
  2535. $aParams['blink'] = $aParams['blink'] !== false ? explode(',', bx_process_input($aParams['blink'], BX_DATA_TEXT)) : array();
  2536. $aParams['active'] = 1;
  2537. $aParams['hidden'] = 0;
  2538. if($this->_oConfig->isHot())
  2539. $aParams['hot'] = $this->_oDb->getHot();
  2540. return $aParams;
  2541. }
  2542. protected function _prepareTextForSave($s)
  2543. {
  2544. return bx_process_input($s, BX_DATA_HTML);
  2545. }
  2546. protected function _getFieldValue($sField, $iContentId)
  2547. {
  2548. $CNF = &$this->_oConfig->CNF;
  2549. if(empty($CNF[$sField]))
  2550. return false;
  2551. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  2552. if(empty($aEvent) || empty($aEvent[$CNF[$sField]]))
  2553. return false;
  2554. return $aEvent[$CNF[$sField]];
  2555. }
  2556. }
  2557. /** @} */