BxTimelineModule.php 120 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081
  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. if(empty($iCounter))
  1463. return '';
  1464. return $this->_oTemplate->parseLink('javascript:void(0)', $iCounter, array(
  1465. 'class' => 'bx-menu-item-addon',
  1466. 'title' => _t('_bx_timeline_menu_item_title_item_comment'),
  1467. 'onclick' => "javascript:" . $this->_oConfig->getJsObject('view') . ".commentItem(this, '" . $sSystem . "', " . $iObjectId . ")"
  1468. ));
  1469. }
  1470. /**
  1471. * @page service Service Calls
  1472. * @section bx_timeline Timeline
  1473. * @subsection bx_timeline-other Other
  1474. * @subsubsection bx_timeline-get_settings_checker_helper get_settings_checker_helper
  1475. *
  1476. * @code bx_srv('bx_timeline', 'get_settings_checker_helper', [...]); @endcode
  1477. *
  1478. * Get Checker Helper class name for Forms engine.
  1479. *
  1480. * @return string with Checker Helper class name.
  1481. *
  1482. * @see BxTimelineModule::serviceGetSettingsCheckerHelper
  1483. */
  1484. /**
  1485. * @ref bx_timeline-get_settings_checker_helper "get_settings_checker_helper"
  1486. */
  1487. public function serviceGetSettingsCheckerHelper()
  1488. {
  1489. bx_import('FormCheckerHelper', $this->_aModule);
  1490. return 'BxTimelineFormCheckerHelper';
  1491. }
  1492. /**
  1493. * @page service Service Calls
  1494. * @section bx_timeline Timeline
  1495. * @subsection bx_timeline-other Other
  1496. * @subsubsection bx_timeline-get_options_videos_autoplay get_options_videos_autoplay
  1497. *
  1498. * @code bx_srv('bx_timeline', 'get_options_videos_autoplay', [...]); @endcode
  1499. *
  1500. * Get an array with available options for 'Videos autoplay in Timeline' setting.
  1501. *
  1502. * @return an array with available options represented as key => value pairs.
  1503. *
  1504. * @see BxTimelineModule::serviceGetOptionsVideosAutoplay
  1505. */
  1506. /**
  1507. * @ref bx_timeline-get_options_videos_autoplay "get_options_videos_autoplay"
  1508. */
  1509. public function serviceGetOptionsVideosAutoplay()
  1510. {
  1511. $aOptions = array(BX_TIMELINE_VAP_OFF, BX_TIMELINE_VAP_ON_MUTE, BX_TIMELINE_VAP_ON);
  1512. $aResult = array();
  1513. foreach($aOptions as $sOption)
  1514. $aResult[] = array(
  1515. 'key' => $sOption,
  1516. 'value' => _t('_bx_timeline_option_videos_autoplay_' . $sOption)
  1517. );
  1518. return $aResult;
  1519. }
  1520. /**
  1521. * @page service Service Calls
  1522. * @section bx_timeline Timeline
  1523. * @subsection bx_timeline-other Other
  1524. * @subsubsection bx_timeline-get_live_updates get_live_updates
  1525. *
  1526. * @code bx_srv('bx_timeline', 'get_live_updates', [...]); @endcode
  1527. *
  1528. * Get an array with actual Live Update info.
  1529. *
  1530. * @return an array with Live Update info.
  1531. *
  1532. * @see BxTimelineModule::serviceGetLiveUpdates
  1533. */
  1534. /**
  1535. * @ref bx_timeline-get_live_updates "get_live_updates"
  1536. */
  1537. public function serviceGetLiveUpdates($sType, $iOwnerId, $iProfileId, $iCount = 0, $iInit = 0)
  1538. {
  1539. $sKey = $this->_oConfig->getLiveUpdateKey($sType, $iOwnerId);
  1540. bx_import('BxDolSession');
  1541. if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
  1542. return false;
  1543. $aParams = $this->_prepareParams(BX_TIMELINE_VIEW_DEFAULT, $sType, $iOwnerId, false, false, BX_TIMELINE_FILTER_OTHER_VIEWER);
  1544. $aParams['count'] = true;
  1545. $iCountNew = $this->_oDb->getEvents($aParams);
  1546. if($iCountNew == $iCount)
  1547. return false;
  1548. if((int)$iInit != 0)
  1549. return array('count' => $iCountNew);
  1550. return array(
  1551. 'count' => $iCountNew, // required (for initialization and visualization)
  1552. 'method' => $this->_oConfig->getJsObject('view') . '.showLiveUpdate(oData)', // required (for visualization)
  1553. 'data' => array(
  1554. 'code' => $this->_oTemplate->getLiveUpdateNotification($sType, $iOwnerId, $iProfileId, $iCount, $iCountNew)
  1555. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  1556. );
  1557. }
  1558. /**
  1559. * @page service Service Calls
  1560. * @section bx_timeline Accounts
  1561. * @subsection bx_timeline-other Other
  1562. * @subsubsection bx_timeline-get_menu_addon_manage_tools get_menu_addon_manage_tools
  1563. *
  1564. * @code bx_srv('bx_timeline', 'get_menu_addon_manage_tools', [...]); @endcode
  1565. *
  1566. * Get number of 'hidden' events for User End -> Dasboard page -> Manage block.
  1567. *
  1568. * @return integer number of 'hidden' events
  1569. *
  1570. * @see BxTimelineModule::serviceGetMenuAddonManageTools
  1571. */
  1572. /**
  1573. * @ref bx_timeline-get_menu_addon_manage_tools "get_menu_addon_manage_tools"
  1574. */
  1575. public function serviceGetMenuAddonManageTools()
  1576. {
  1577. bx_import('SearchResult', $this->_aModule);
  1578. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  1579. $o = new $sClass();
  1580. $o->fillFilters(array(
  1581. 'active' => 0
  1582. ));
  1583. $o->unsetPaginate();
  1584. return $o->getNum();
  1585. }
  1586. /*
  1587. * COMMON METHODS
  1588. */
  1589. public function deleteEvent($aEvent)
  1590. {
  1591. if(empty($aEvent) || !is_array($aEvent) || !$this->_oDb->deleteEvent(array('id' => (int)$aEvent['id'])))
  1592. return false;
  1593. $this->onDelete($aEvent);
  1594. return true;
  1595. }
  1596. public function addAttachLink($aValues, $sDisplay = false)
  1597. {
  1598. $CNF = &$this->_oConfig->CNF;
  1599. if(!$sDisplay)
  1600. $sDisplay = $this->_oConfig->getObject('form_display_attach_link_add');
  1601. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_attach_link'), $sDisplay, $this->_oTemplate);
  1602. if(!$oForm)
  1603. return array('message' => '_sys_txt_error_occured');
  1604. $oForm->aFormAttrs['method'] = BX_DOL_FORM_METHOD_SPECIFIC;
  1605. $oForm->aParams['csrf']['disable'] = true;
  1606. if(!empty($oForm->aParams['db']['submit_name'])) {
  1607. $sSubmitName = $oForm->aParams['db']['submit_name'];
  1608. if(!isset($oForm->aInputs[$sSubmitName])) {
  1609. if(isset($oForm->aInputs[$CNF['FIELD_CONTROLS']]))
  1610. foreach($oForm->aInputs[$CNF['FIELD_CONTROLS']] as $mixedIndex => $aInput) {
  1611. if(!is_numeric($mixedIndex) || empty($aInput['name']) || $aInput['name'] != $sSubmitName)
  1612. continue;
  1613. $aValues[$sSubmitName] = $aInput['value'];
  1614. }
  1615. }
  1616. else
  1617. $aValues[$sSubmitName] = $oForm->aInputs[$sSubmitName]['value'];
  1618. }
  1619. $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url');
  1620. $oForm->initChecker(array(), $aValues);
  1621. if(!$oForm->isSubmittedAndValid())
  1622. return array('message' => '_sys_txt_error_occured');
  1623. return $this->_addLink($oForm);
  1624. }
  1625. public function getFormAttachLink()
  1626. {
  1627. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_attach_link'), $this->_oConfig->getObject('form_display_attach_link_add'), $this->_oTemplate);
  1628. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'submit_attach_link_form/';
  1629. $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url');
  1630. $oForm->initChecker();
  1631. if($oForm->isSubmittedAndValid())
  1632. return $this->_addLink($oForm);
  1633. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  1634. }
  1635. public function getFormPost($aParams = array())
  1636. {
  1637. $iUserId = $this->getUserId();
  1638. $oForm = $this->getFormPostObject($aParams);
  1639. $oForm->initChecker();
  1640. $bAjaxMode = $oForm->isAjaxMode();
  1641. $bDynamicMode = $bAjaxMode;
  1642. if($oForm->isSubmittedAndValid()) {
  1643. list($sUserName) = $this->getUserInfo($iUserId);
  1644. $sType = $oForm->getCleanValue('type');
  1645. $sType = $this->_oConfig->getPrefix('common_post') . $sType;
  1646. BxDolForm::setSubmittedValue('type', $sType, $oForm->aFormAttrs['method']);
  1647. $aContent = array();
  1648. //--- Process Text ---//
  1649. $sText = $oForm->getCleanValue('text');
  1650. $sText = $this->_prepareTextForSave($sText);
  1651. $bText = !empty($sText);
  1652. if($bText)
  1653. $aContent['text'] = $sText;
  1654. //--- Process Context and Privacy ---//
  1655. $iOwnerId = (int)$oForm->getCleanValue('owner_id');
  1656. $iObjectPrivacyView = (int)$oForm->getCleanValue('object_privacy_view');
  1657. $iObjectPrivacyViewDefault = $this->_oConfig->getPrivacyViewDefault('object');
  1658. if(empty($iObjectPrivacyView))
  1659. $iObjectPrivacyView = $iObjectPrivacyViewDefault;
  1660. else if($iObjectPrivacyView < 0)
  1661. $iOwnerId = abs($iObjectPrivacyView);
  1662. //--- Process Link ---//
  1663. $aLinkIds = $oForm->getCleanValue('link');
  1664. $bLinkIds = !empty($aLinkIds) && is_array($aLinkIds);
  1665. //--- Process Media ---//
  1666. $aPhotoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_PHOTO);
  1667. $bPhotoIds = !empty($aPhotoIds) && is_array($aPhotoIds);
  1668. $aVideoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_VIDEO);
  1669. $bVideoIds = !empty($aVideoIds) && is_array($aVideoIds);
  1670. if(!$bText && !$bLinkIds && !$bPhotoIds && !$bVideoIds) {
  1671. $oForm->aInputs['text']['error'] = _t('_bx_timeline_txt_err_empty_post');
  1672. $oForm->setValid(false);
  1673. return $this->_prepareResponse(array('form' => $oForm->getCode($bDynamicMode), 'form_id' => $oForm->id), $bAjaxMode);
  1674. }
  1675. $sTitle = $bText ? $this->_oConfig->getTitle($sText) : $this->_oConfig->getTitleDefault($bLinkIds, $bPhotoIds, $bVideoIds);
  1676. $sDescription = _t('_bx_timeline_txt_user_added_sample', '{profile_name}', _t('_bx_timeline_txt_sample_with_article'));
  1677. //--- Process Date ---//
  1678. $iDate = 0;
  1679. if(isset($oForm->aInputs['date']))
  1680. $iDate = $oForm->getCleanValue('date');
  1681. if(empty($iDate))
  1682. $iDate = time();
  1683. /**
  1684. * Unset 'text' input because its data was already processed
  1685. * and will be saved via additional values which were passed
  1686. * to BxDolForm::insert method.
  1687. */
  1688. unset($oForm->aInputs['text']);
  1689. $iId = $oForm->insert(array(
  1690. 'owner_id' => $iOwnerId,
  1691. 'object_id' => $iUserId,
  1692. 'object_privacy_view' => $iObjectPrivacyView,
  1693. 'content' => serialize($aContent),
  1694. 'title' => $sTitle,
  1695. 'description' => $sDescription,
  1696. 'date' => $iDate
  1697. ));
  1698. if(!empty($iId)) {
  1699. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  1700. if($bText)
  1701. $oMetatags->metaAdd($iId, $sText);
  1702. $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
  1703. //--- Process Link ---//
  1704. if($bLinkIds)
  1705. foreach($aLinkIds as $iLinkId)
  1706. $this->_oDb->saveLink($iId, $iLinkId);
  1707. //--- Process Media ---//
  1708. if($bPhotoIds)
  1709. $this->_saveMedia(BX_TIMELINE_MEDIA_PHOTO, $iId, $aPhotoIds);
  1710. if($bVideoIds)
  1711. $this->_saveMedia(BX_TIMELINE_MEDIA_VIDEO, $iId, $aVideoIds);
  1712. $this->onPost($iId);
  1713. return $this->_prepareResponse(array('id' => $iId), $bAjaxMode, array(
  1714. 'redirect' => $this->_oConfig->getItemViewUrl(array('id' => $iId))
  1715. ));
  1716. }
  1717. return $this->_prepareResponse(array('message' => _t('_bx_timeline_txt_err_cannot_perform_action')), $bAjaxMode);
  1718. }
  1719. return $this->_prepareResponse(array('form' => $oForm->getCode($bDynamicMode), 'form_id' => $oForm->id), $bAjaxMode && $oForm->isSubmitted());
  1720. }
  1721. public function getFormEdit($iId, $aParams = array())
  1722. {
  1723. $CNF = &$this->_oConfig->CNF;
  1724. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  1725. if(empty($aEvent) || !is_array($aEvent))
  1726. return array();
  1727. $aContent = unserialize($aEvent['content']);
  1728. if(is_array($aContent) && !empty($aContent['text']))
  1729. $aEvent['text'] = $aContent['text'];
  1730. $bDynamicMode = isset($aParams['dynamic_mode']) ? (bool)$aParams['dynamic_mode'] : false;
  1731. $sFormObject = !empty($aParams['form_object']) ? $aParams['form_object'] : 'form_post';
  1732. $sFormDisplay = !empty($aParams['form_display']) ? $aParams['form_display'] : 'form_display_post_edit';
  1733. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject($sFormObject), $this->_oConfig->getObject($sFormDisplay), $this->_oTemplate);
  1734. $oForm->setId($this->_oConfig->getHtmlIds('view', 'edit_form') . $iId);
  1735. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'edit/' . $iId ;
  1736. foreach($oForm->aInputs[$CNF['FIELD_CONTROLS']] as $mixedIndex => $aInput) {
  1737. if(!is_numeric($mixedIndex))
  1738. continue;
  1739. $oForm->aInputs[$CNF['FIELD_CONTROLS']][$mixedIndex]['attrs'] = bx_replace_markers($aInput['attrs'], array(
  1740. 'js_object_view' => $this->_oConfig->getJsObject('view'),
  1741. 'content_id' => $iId
  1742. ));
  1743. }
  1744. $oForm->initChecker($aEvent);
  1745. if($oForm->isSubmittedAndValid()) {
  1746. $aContent = array();
  1747. //--- Process Text ---//
  1748. $sText = $oForm->getCleanValue('text');
  1749. $sText = $this->_prepareTextForSave($sText);
  1750. $bText = !empty($sText);
  1751. unset($oForm->aInputs['text']);
  1752. if($bText)
  1753. $aContent['text'] = $sText;
  1754. $aValsToAdd = array(
  1755. 'content' => serialize($aContent)
  1756. );
  1757. //--- Process Privacy ---//
  1758. $iObjectPrivacyView = (int)$oForm->getCleanValue('object_privacy_view');
  1759. $iObjectPrivacyViewDefault = $this->_oConfig->getPrivacyViewDefault('object');
  1760. if(empty($iObjectPrivacyView))
  1761. $aValsToAdd = array_merge($aValsToAdd, array(
  1762. 'object_privacy_view' => $iObjectPrivacyViewDefault
  1763. ));
  1764. else if($iObjectPrivacyView < 0)
  1765. $aValsToAdd = array_merge($aValsToAdd, array(
  1766. 'owner_id' => abs($iObjectPrivacyView),
  1767. 'object_privacy_view' => $iObjectPrivacyViewDefault
  1768. ));
  1769. //--- Process Date ---//
  1770. if(isset($oForm->aInputs['date'])) {
  1771. $iDate = $oForm->getCleanValue('date');
  1772. if(empty($iDate))
  1773. $iDate = time();
  1774. $aValsToAdd['date'] = $iDate;
  1775. }
  1776. if(!$oForm->update($iId, $aValsToAdd))
  1777. return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
  1778. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  1779. if($bText)
  1780. $oMetatags->metaAdd($iId, $sText);
  1781. $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
  1782. return array(
  1783. 'id' => $iId,
  1784. 'eval' => $this->_oConfig->getJsObject('view') . '.onEditPostSubmit(oData)'
  1785. );
  1786. }
  1787. return array(
  1788. 'id' => $iId,
  1789. 'form' => $oForm->getCode($bDynamicMode),
  1790. 'form_id' => $oForm->id,
  1791. 'eval' => $this->_oConfig->getJsObject('view') . '.onEditPost(oData)'
  1792. );
  1793. }
  1794. public function getFormPostObject($aParams)
  1795. {
  1796. $sFormObject = !empty($aParams['form_object']) ? $aParams['form_object'] : 'form_post';
  1797. $sFormDisplay = !empty($aParams['form_display']) ? $aParams['form_display'] : 'form_display_post_add';
  1798. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject($sFormObject), $this->_oConfig->getObject($sFormDisplay), $this->_oTemplate);
  1799. $sParamsKey = 'ajax_mode';
  1800. if(isset($aParams[$sParamsKey]) && is_bool($aParams[$sParamsKey]))
  1801. $oForm->setAjaxMode((bool)$aParams[$sParamsKey]);
  1802. $sParamsKey = 'visibility_autoselect';
  1803. if(isset($aParams[$sParamsKey]) && is_bool($aParams[$sParamsKey]))
  1804. $oForm->setVisibilityAutoselect((bool)$aParams[$sParamsKey]);
  1805. $oForm->init();
  1806. return $oForm;
  1807. }
  1808. public function getCmtsObject($sSystem, $iId)
  1809. {
  1810. if(empty($sSystem) || (int)$iId == 0)
  1811. return false;
  1812. $oCmts = BxDolCmts::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1813. if(!$oCmts || !$oCmts->isEnabled())
  1814. return false;
  1815. return $oCmts;
  1816. }
  1817. public function getViewObject($sSystem, $iId)
  1818. {
  1819. if(empty($sSystem) || (int)$iId == 0)
  1820. return false;
  1821. $oView = BxDolView::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1822. if(!$oView || !$oView->isEnabled())
  1823. return false;
  1824. return $oView;
  1825. }
  1826. public function getVoteObject($sSystem, $iId)
  1827. {
  1828. if(empty($sSystem) || (int)$iId == 0)
  1829. return false;
  1830. $oVote = BxDolVote::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1831. if(!$oVote || !$oVote->isEnabled())
  1832. return false;
  1833. return $oVote;
  1834. }
  1835. public function getScoreObject($sSystem, $iId)
  1836. {
  1837. if(empty($sSystem) || (int)$iId == 0)
  1838. return false;
  1839. $oScore = BxDolScore::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1840. if(!$oScore || !$oScore->isEnabled())
  1841. return false;
  1842. return $oScore;
  1843. }
  1844. public function getReportObject($sSystem, $iId)
  1845. {
  1846. if(empty($sSystem) || (int)$iId == 0)
  1847. return false;
  1848. $oReport = BxDolReport::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  1849. if(!$oReport || !$oReport->isEnabled())
  1850. return false;
  1851. return $oReport;
  1852. }
  1853. public function getAttachmentsMenuObject()
  1854. {
  1855. $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_post_attachments'), $this->_oTemplate);
  1856. $oMenu->addMarkers(array(
  1857. 'js_object' => $this->_oConfig->getJsObject('post'),
  1858. ));
  1859. return $oMenu;
  1860. }
  1861. public function getManageMenuObject()
  1862. {
  1863. return BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_manage'), $this->_oTemplate);
  1864. }
  1865. //--- Check permissions methods ---//
  1866. public function isModerator()
  1867. {
  1868. $sModule = $this->getName();
  1869. $iUserId = (int)$this->getUserId();
  1870. $aCheckResult = checkActionModule($iUserId, 'edit', $sModule);
  1871. if($aCheckResult[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  1872. return true;
  1873. $aCheckResult = checkActionModule($iUserId, 'delete', $sModule);
  1874. if($aCheckResult[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  1875. return true;
  1876. return false;
  1877. }
  1878. public function isAllowedPost($bPerform = false)
  1879. {
  1880. if(isAdmin())
  1881. return true;
  1882. $iUserId = $this->getUserId();
  1883. $aCheckResult = checkActionModule($iUserId, 'post', $this->getName(), $bPerform);
  1884. $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
  1885. if($oProfileOwner !== false) {
  1886. if($oProfileOwner->checkAllowedPostInProfile() !== CHECK_ACTION_RESULT_ALLOWED)
  1887. return _t('_sys_txt_access_denied');
  1888. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_post', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1889. }
  1890. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1891. }
  1892. public function isAllowedView($aEvent, $bPerform = false)
  1893. {
  1894. $CNF = $this->_oConfig->CNF;
  1895. $mixedResult = BxDolProfile::getInstance($aEvent[$CNF['FIELD_OWNER_ID']])->checkAllowedProfileView();
  1896. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  1897. return false;
  1898. return true;
  1899. }
  1900. public function isAllowedEdit($aEvent, $bPerform = false)
  1901. {
  1902. if(!isLogged())
  1903. return false;
  1904. //--- System posts and Reposts cannot be edited at all.
  1905. if(!$this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) || $aEvent['type'] == $this->_oConfig->getPrefix('common_post') . 'repost')
  1906. return false;
  1907. if(isAdmin())
  1908. return true;
  1909. $iUserId = (int)$this->getUserId();
  1910. $iOwnerId = (int)$aEvent['owner_id'];
  1911. $iObjectId = abs((int)$aEvent['object_id']);
  1912. if($iObjectId == $iUserId && $this->_oConfig->isAllowEdit())
  1913. return true;
  1914. $aCheckResult = checkActionModule($iUserId, 'edit', $this->getName(), $bPerform);
  1915. $oProfileOwner = BxDolProfile::getInstance($iOwnerId);
  1916. if($oProfileOwner !== false)
  1917. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_edit', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1918. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1919. }
  1920. public function isAllowedDelete($aEvent, $bPerform = false)
  1921. {
  1922. if(!isLogged())
  1923. return false;
  1924. if(isAdmin())
  1925. return true;
  1926. $iUserId = (int)$this->getUserId();
  1927. $iOwnerId = (int)$aEvent['owner_id'];
  1928. $iObjectId = abs((int)$aEvent['object_id']);
  1929. if((($iOwnerId == $iUserId && $this->_oConfig->isAllowDelete()) || ($this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) && $iObjectId == $iUserId)))
  1930. return true;
  1931. $aCheckResult = checkActionModule($iUserId, 'delete', $this->getName(), $bPerform);
  1932. $oProfileOwner = BxDolProfile::getInstance($iOwnerId);
  1933. if($oProfileOwner !== false)
  1934. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_delete', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  1935. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  1936. }
  1937. public function isAllowedComment($aEvent, $bPerform = false)
  1938. {
  1939. $mixedComments = $this->getCommentsData($aEvent['comments']);
  1940. if($mixedComments === false)
  1941. return false;
  1942. list($sSystem, $iObjectId) = $mixedComments;
  1943. $oCmts = $this->getCmtsObject($sSystem, $iObjectId);
  1944. $oCmts->addCssJs();
  1945. $bResult = true;
  1946. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1947. if($oProfileOwner !== false) {
  1948. if($oProfileOwner->checkAllowedPostInProfile() !== CHECK_ACTION_RESULT_ALLOWED)
  1949. return false;
  1950. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_comment', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1951. }
  1952. return $bResult;
  1953. }
  1954. public function isAllowedViewCounter($aEvent, $bPerform = false)
  1955. {
  1956. $mixedViews = $this->getViewsData($aEvent['views']);
  1957. if($mixedViews === false)
  1958. return false;
  1959. list($sSystem, $iObjectId) = $mixedViews;
  1960. $oView = $this->getViewObject($sSystem, $iObjectId);
  1961. if(!$oView->isAllowedViewView($bPerform))
  1962. return false;
  1963. $bResult = true;
  1964. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1965. if($oProfileOwner !== false)
  1966. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view_counter', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1967. return $bResult;
  1968. }
  1969. public function isAllowedVote($aEvent, $bPerform = false)
  1970. {
  1971. $mixedVotes = $this->getVotesData($aEvent['votes']);
  1972. if($mixedVotes === false)
  1973. return false;
  1974. list($sSystem, $iObjectId) = $mixedVotes;
  1975. $oVote = $this->getVoteObject($sSystem, $iObjectId);
  1976. if(!$oVote->isAllowedVote($bPerform))
  1977. return false;
  1978. $bResult = true;
  1979. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1980. if($oProfileOwner !== false)
  1981. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1982. return $bResult;
  1983. }
  1984. public function isAllowedScore($aEvent, $bPerform = false)
  1985. {
  1986. $mixedScores = $this->getScoresData($aEvent['scores']);
  1987. if($mixedScores === false)
  1988. return false;
  1989. list($sSystem, $iObjectId) = $mixedScores;
  1990. $oScore = $this->getScoreObject($sSystem, $iObjectId);
  1991. if(!$oScore->isAllowedVote($bPerform))
  1992. return false;
  1993. $bResult = true;
  1994. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  1995. if($oProfileOwner !== false)
  1996. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_score', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  1997. return $bResult;
  1998. }
  1999. public function isAllowedReport($aEvent, $bPerform = false)
  2000. {
  2001. $mixedReports = $this->getReportsData($aEvent['reports']);
  2002. if($mixedReports === false)
  2003. return false;
  2004. list($sSystem, $iObjectId) = $mixedReports;
  2005. $oReport = $this->getReportObject($sSystem, $iObjectId);
  2006. if(!$oReport->isAllowedReport($bPerform))
  2007. return false;
  2008. $bResult = true;
  2009. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2010. if($oProfileOwner !== false)
  2011. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_report', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  2012. return $bResult;
  2013. }
  2014. public function isAllowedRepost($aEvent, $bPerform = false)
  2015. {
  2016. $iUserId = (int)$this->getUserId();
  2017. if($iUserId == 0)
  2018. return false;
  2019. $iPrivacy = $this->getObjectPrivacyView(is_array($aEvent['content']) ? $aEvent['content'] : unserialize($aEvent['content']));
  2020. if(!in_array($iPrivacy, array(BX_DOL_PG_ALL, BX_DOL_PG_MEMBERS)))
  2021. return false;
  2022. if(isAdmin())
  2023. return true;
  2024. $aCheckResult = checkActionModule($iUserId, 'repost', $this->getName(), $bPerform);
  2025. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2026. if($oProfileOwner !== false)
  2027. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_repost', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  2028. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  2029. }
  2030. public function isAllowedSend($aEvent, $bPerform = false)
  2031. {
  2032. if(!$this->_oDb->isEnabledByName('bx_convos'))
  2033. return false;
  2034. if(isAdmin())
  2035. return true;
  2036. $iUserId = (int)$this->getUserId();
  2037. if($iUserId == 0)
  2038. return false;
  2039. $aCheckResult = checkActionModule($iUserId, 'send', $this->getName(), $bPerform);
  2040. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2041. if($oProfileOwner !== false)
  2042. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_send', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  2043. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  2044. }
  2045. /**
  2046. * Pin - "Pin here" - pin the post on Profile Timeline for profile owner.
  2047. * Can be done by profile owner for himself or by admin for profile owner to see.
  2048. * @param type $aEvent
  2049. * @param type $bPerform
  2050. * @return boolean
  2051. */
  2052. public function isAllowedPin($aEvent, $bPerform = false)
  2053. {
  2054. if((int)$aEvent['pinned'] != 0)
  2055. return false;
  2056. return $this->_isAllowedPin($aEvent, $bPerform);
  2057. }
  2058. public function isAllowedUnpin($aEvent, $bPerform = false)
  2059. {
  2060. if((int)$aEvent['pinned'] == 0)
  2061. return false;
  2062. return $this->_isAllowedPin($aEvent, $bPerform);
  2063. }
  2064. /**
  2065. * Stick - "Pin for All" - pin the post on Public Timeline for everybody to see.
  2066. * Is available for Administrators/Moderators only.
  2067. * @param type $aEvent
  2068. * @param type $bPerform
  2069. * @return boolean
  2070. */
  2071. public function isAllowedStick($aEvent, $bPerform = false)
  2072. {
  2073. if((int)$aEvent['sticked'] != 0)
  2074. return false;
  2075. return $this->_isAllowedStick($aEvent, $bPerform);
  2076. }
  2077. public function isAllowedUnstick($aEvent, $bPerform = false)
  2078. {
  2079. if((int)$aEvent['sticked'] == 0)
  2080. return false;
  2081. return $this->_isAllowedStick($aEvent, $bPerform);
  2082. }
  2083. public function isAllowedPromote($aEvent, $bPerform = false)
  2084. {
  2085. if((int)$aEvent['promoted'] != 0)
  2086. return false;
  2087. return $this->_isAllowedPromote($aEvent, $bPerform);
  2088. }
  2089. public function isAllowedUnpromote($aEvent, $bPerform = false)
  2090. {
  2091. if((int)$aEvent['promoted'] == 0)
  2092. return false;
  2093. return $this->_isAllowedPromote($aEvent, $bPerform);
  2094. }
  2095. public function isAllowedMore($aEvent, $bPerform = false)
  2096. {
  2097. $oMoreMenu = $this->getManageMenuObject();
  2098. $oMoreMenu->setEventById($aEvent['id']);
  2099. return $oMoreMenu->isVisible();
  2100. }
  2101. public function checkAllowedView ($aContentInfo, $isPerformAction = false)
  2102. {
  2103. if(!$this->isAllowedView($aContentInfo, $isPerformAction))
  2104. return _t('_sys_txt_access_denied');
  2105. return CHECK_ACTION_RESULT_ALLOWED;
  2106. }
  2107. public function checkAllowedCommentsView ($aContentInfo, $isPerformAction = false)
  2108. {
  2109. $CNF = $this->_oConfig->CNF;
  2110. $iOwner = (int)$aContentInfo[$CNF['FIELD_OWNER_ID']];
  2111. if($iOwner == 0) //--- in case of Public Timeline.
  2112. return CHECK_ACTION_RESULT_ALLOWED;
  2113. $oOwner = BxDolProfile::getInstance($iOwner);
  2114. if(!$oOwner) //--- in case of non-existed Timeline owner.
  2115. return _t('_sys_txt_access_denied');
  2116. $mixedResult = $oOwner->checkAllowedProfileView();
  2117. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  2118. return $mixedResult;
  2119. return CHECK_ACTION_RESULT_ALLOWED;
  2120. }
  2121. public function checkAllowedCommentsPost ($aContentInfo, $isPerformAction = false)
  2122. {
  2123. $sError = '_sys_txt_access_denied';
  2124. $aContentInfo = $this->_oTemplate->getData($aContentInfo);
  2125. if($aContentInfo === false)
  2126. return _t($sError);
  2127. if(!$this->isAllowedComment($aContentInfo, $isPerformAction))
  2128. return _t($sError);
  2129. return CHECK_ACTION_RESULT_ALLOWED;
  2130. }
  2131. public function onPost($iId)
  2132. {
  2133. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  2134. if($this->_oConfig->isSystem($aEvent['type'], $aEvent['action'])) {
  2135. //--- Request event's data from content module and update it in the Timeline DB.
  2136. $this->_oTemplate->getData($aEvent);
  2137. $sPostType = 'system';
  2138. $iSenderId = $aEvent['owner_id'];
  2139. } else {
  2140. $sPostType = 'common';
  2141. $iSenderId = $aEvent['object_id'];
  2142. }
  2143. //--- Event -> Post for Alerts Engine ---//
  2144. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'post_' . $sPostType, $iId, $iSenderId, array(
  2145. 'privacy_view' => $aEvent['object_privacy_view'],
  2146. 'object_author_id' => $aEvent['owner_id'],
  2147. ));
  2148. $oAlert->alert();
  2149. //--- Event -> Post for Alerts Engine ---//
  2150. }
  2151. public function onRepost($iId, $aReposted = array())
  2152. {
  2153. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  2154. if(empty($aReposted)) {
  2155. $aContent = unserialize($aEvent['content']);
  2156. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  2157. if(empty($aReposted) || !is_array($aReposted))
  2158. return;
  2159. }
  2160. $iUserId = $this->getUserId();
  2161. $this->_oDb->insertRepostTrack($aEvent['id'], $iUserId, $this->getUserIp(), $aReposted['id']);
  2162. $this->_oDb->updateRepostCounter($aReposted['id'], $aReposted['reposts']);
  2163. //--- Timeline -> Update for Alerts Engine ---//
  2164. $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'repost', $aReposted['id'], $iUserId, array(
  2165. 'privacy_view' => $aEvent['object_privacy_view'],
  2166. 'object_author_id' => $aReposted['owner_id'],
  2167. 'repost_id' => $iId,
  2168. ));
  2169. $oAlert->alert();
  2170. //--- Timeline -> Update for Alerts Engine ---//
  2171. }
  2172. public function onDelete($aEvent)
  2173. {
  2174. $iUserId = $this->getUserId();
  2175. $sCommonPostPrefix = $this->_oConfig->getPrefix('common_post');
  2176. $sCommonPostComment = $this->_oConfig->getObject('comment');
  2177. //--- Delete comments for Common posts.
  2178. if($this->_oConfig->isCommon($aEvent['type'], $aEvent['action'])) {
  2179. $oComments = $this->getCmtsObject($sCommonPostComment, $aEvent['id']);
  2180. if($oComments !== false)
  2181. $oComments->onObjectDelete($aEvent['id']);
  2182. }
  2183. //--- Delete attached photos, videos and links when common event was deleted.
  2184. if($aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_POST) {
  2185. $this->_deleteMedia(BX_TIMELINE_MEDIA_PHOTO, $aEvent['id']);
  2186. $this->_deleteMedia(BX_TIMELINE_MEDIA_VIDEO, $aEvent['id']);
  2187. $this->_deleteLinks($aEvent['id']);
  2188. }
  2189. //--- Update parent event when repost event was deleted.
  2190. $bRepost = $aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_REPOST;
  2191. if($bRepost) {
  2192. $this->_oDb->deleteRepostTrack($aEvent['id']);
  2193. $aContent = unserialize($aEvent['content']);
  2194. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  2195. if(!empty($aReposted) && is_array($aReposted))
  2196. $this->_oDb->updateRepostCounter($aReposted['id'], $aReposted['reposts'], -1);
  2197. }
  2198. //--- Find and delete repost events when parent event was deleted.
  2199. $bSystem = $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']);
  2200. $aRepostEvents = $this->_oDb->getEvents(array('browse' => 'reposted_by_descriptor', 'type' => $aEvent['type']));
  2201. foreach($aRepostEvents as $aRepostEvent) {
  2202. $aContent = unserialize($aRepostEvent['content']);
  2203. 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) {
  2204. $oComments = $this->getCmtsObject($sCommonPostComment, $aRepostEvent['id']);
  2205. if($oComments !== false)
  2206. $oComments->onObjectDelete($aRepostEvent['id']);
  2207. bx_alert($this->_oConfig->getObject('alert'), 'delete_repost', $aEvent['id'], $iUserId, array(
  2208. 'repost_id' => $aRepostEvent['id'],
  2209. ));
  2210. }
  2211. }
  2212. //--- Delete associated meta.
  2213. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  2214. $oMetatags->onDeleteContent($aEvent['id']);
  2215. //--- Event -> Delete for Alerts Engine ---//
  2216. if($bRepost)
  2217. bx_alert($this->_oConfig->getObject('alert'), 'delete_repost', $aReposted['id'], $iUserId, array(
  2218. 'repost_id' => $aEvent['id'],
  2219. ));
  2220. else
  2221. bx_alert($this->_oConfig->getObject('alert'), 'delete', $aEvent['id'], $iUserId);
  2222. //--- Event -> Delete for Alerts Engine ---//
  2223. }
  2224. public function getParams($sView = '', $sType = '', $iOwnerId = 0, $iStart = 0, $iPerPage = 0, $sFilter = BX_TIMELINE_FILTER_ALL, $aModules = array(), $iTimeline = 0)
  2225. {
  2226. return $this->_prepareParams($sView, $sType, $iOwnerId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  2227. }
  2228. public function getViewsData(&$aViews)
  2229. {
  2230. if(empty($aViews) || !is_array($aViews))
  2231. return false;
  2232. $sSystem = isset($aViews['system']) ? $aViews['system'] : '';
  2233. $iObjectId = isset($aViews['object_id']) ? (int)$aViews['object_id'] : 0;
  2234. $iCount = isset($aViews['count']) ? (int)$aViews['count'] : 0;
  2235. if($sSystem == '' || $iObjectId == 0)
  2236. return false;
  2237. return array($sSystem, $iObjectId, $iCount);
  2238. }
  2239. public function getVotesData(&$aVotes)
  2240. {
  2241. if(empty($aVotes) || !is_array($aVotes))
  2242. return false;
  2243. $sSystem = isset($aVotes['system']) ? $aVotes['system'] : '';
  2244. $iObjectId = isset($aVotes['object_id']) ? (int)$aVotes['object_id'] : 0;
  2245. $iCount = isset($aVotes['count']) ? (int)$aVotes['count'] : 0;
  2246. if($sSystem == '' || $iObjectId == 0)
  2247. return false;
  2248. return array($sSystem, $iObjectId, $iCount);
  2249. }
  2250. public function getScoresData(&$aScores)
  2251. {
  2252. if(empty($aScores) || !is_array($aScores))
  2253. return false;
  2254. $sSystem = isset($aScores['system']) ? $aScores['system'] : '';
  2255. $iObjectId = isset($aScores['object_id']) ? (int)$aScores['object_id'] : 0;
  2256. $iScore = isset($aScores['score']) ? (int)$aScores['score'] : 0;
  2257. if($sSystem == '' || $iObjectId == 0)
  2258. return false;
  2259. return array($sSystem, $iObjectId, $iScore);
  2260. }
  2261. public function getReportsData(&$aReports)
  2262. {
  2263. if(empty($aReports) || !is_array($aReports))
  2264. return false;
  2265. $sSystem = isset($aReports['system']) ? $aReports['system'] : '';
  2266. $iObjectId = isset($aReports['object_id']) ? (int)$aReports['object_id'] : 0;
  2267. $iCount = isset($aReports['count']) ? (int)$aReports['count'] : 0;
  2268. if($sSystem == '' || $iObjectId == 0)
  2269. return false;
  2270. return array($sSystem, $iObjectId, $iCount);
  2271. }
  2272. public function getCommentsData(&$aComments)
  2273. {
  2274. if(empty($aComments) || !is_array($aComments))
  2275. return false;
  2276. $sSystem = isset($aComments['system']) ? $aComments['system'] : '';
  2277. $iObjectId = isset($aComments['object_id']) ? (int)$aComments['object_id'] : 0;
  2278. $iCount = isset($aComments['count']) ? (int)$aComments['count'] : 0;
  2279. if($sSystem == '' || $iObjectId == 0 || ($iCount == 0 && !isLogged()))
  2280. return false;
  2281. return array($sSystem, $iObjectId, $iCount);
  2282. }
  2283. public function getUserInfo($iUserId = 0)
  2284. {
  2285. $iLoggedId = $this->getUserId();
  2286. $iUserId = (int)$iUserId;
  2287. return parent::getUserInfo($iUserId);
  2288. }
  2289. /**
  2290. * Protected Methods
  2291. */
  2292. protected function _serviceGetBlockView($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT)
  2293. {
  2294. if(empty($iProfileId) && bx_get('profile_id') !== false)
  2295. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  2296. if(empty($iProfileId) && isLogged())
  2297. $iProfileId = bx_get_logged_profile_id();
  2298. $aBlock = $this->_getBlockView($iProfileId, $sView);
  2299. if(!empty($aBlock))
  2300. return $aBlock;
  2301. return array('content' => MsgBox(_t('_bx_timeline_txt_msg_no_results')));
  2302. }
  2303. protected function _serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  2304. {
  2305. if(empty($sProfileModule))
  2306. return array();
  2307. if(empty($iProfileContentId) && bx_get('id') !== false)
  2308. $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  2309. $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
  2310. if(empty($oProfile))
  2311. return array();
  2312. return $this->_getBlockView($oProfile->id(), $sView, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  2313. }
  2314. protected function _serviceGetBlockViewHome($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $iPerPageDefault = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  2315. {
  2316. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_BASE_MOD_NTFS_TYPE_PUBLIC . '/';
  2317. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view_home'), $sRssUrl);
  2318. return $this->_serviceGetBlockViewByType($iProfileId, $sView, BX_BASE_MOD_NTFS_TYPE_PUBLIC, $iStart, $iPerPage, $iPerPageDefault, $iTimeline, $sFilter, $aModules);
  2319. }
  2320. protected function _serviceGetBlockViewHot($iProfileId = 0, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $iPerPageDefault = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  2321. {
  2322. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_TIMELINE_TYPE_HOT . '/';
  2323. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view_hot'), $sRssUrl);
  2324. return $this->_serviceGetBlockViewByType($iProfileId, $sView, BX_TIMELINE_TYPE_HOT, $iStart, $iPerPage, $iPerPageDefault, $iTimeline, $sFilter, $aModules);
  2325. }
  2326. 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())
  2327. {
  2328. $aParams = $this->_prepareParams($sView, $sType, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  2329. $aParams['view'] = $sView;
  2330. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : ((int)$iPerPageDefault > 0 ? $iPerPageDefault : $this->_oConfig->getPerPage());
  2331. $this->_iOwnerId = $aParams['owner_id'];
  2332. $sContent = $this->_oTemplate->getViewBlock($aParams);
  2333. return array('content' => $sContent);
  2334. }
  2335. protected function _getBlockPost($iProfileId, $aParams = array())
  2336. {
  2337. $this->_iOwnerId = $iProfileId;
  2338. if($this->isAllowedPost() !== true)
  2339. return array();
  2340. $sContent = $this->_oTemplate->getPostBlock($this->_iOwnerId, $aParams);
  2341. return array('content' => $sContent);
  2342. }
  2343. protected function _getBlockView($iProfileId, $sView = BX_TIMELINE_VIEW_DEFAULT, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  2344. {
  2345. if(!$iProfileId)
  2346. return array();
  2347. $aParams = $this->_prepareParams($sView, BX_BASE_MOD_NTFS_TYPE_OWNER, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
  2348. $aParams['view'] = $sView;
  2349. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage('profile');
  2350. $this->_iOwnerId = $aParams['owner_id'];
  2351. $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
  2352. $mixedResult = $oProfileOwner->checkAllowedProfileView();
  2353. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  2354. return array('content' => MsgBox($mixedResult));
  2355. list($sUserName, $sUserUrl) = $this->getUserInfo($aParams['owner_id']);
  2356. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_BASE_MOD_NTFS_TYPE_OWNER . '/' . $iProfileId . '/';
  2357. $sJsObject = $this->_oConfig->getJsObject('view');
  2358. $aMenu = array(
  2359. 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),
  2360. 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)),
  2361. 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')),
  2362. array('id' => $sView . '-get-rss', 'name' => $sView . '-get-rss', 'class' => '', 'link' => $sRssUrl, 'target' => '_blank', 'title' => _t('_bx_timeline_menu_item_get_rss')),
  2363. );
  2364. $sContent = '';
  2365. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view', $this->_iOwnerId, $this->getUserId(), array('override_content' => &$sContent, 'params' => &$aParams, 'menu' => &$aMenu));
  2366. $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> $sView . '-view-all', 'menu_items' => $aMenu));
  2367. $oMenu->setSelected('', $sView . '-view-all');
  2368. if (!$sContent)
  2369. $sContent = $this->_oTemplate->getViewBlock($aParams);
  2370. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view'), $sRssUrl);
  2371. return array('content' => $sContent, 'menu' => $oMenu);
  2372. }
  2373. protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
  2374. {
  2375. $CNF = &$this->_oConfig->CNF;
  2376. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  2377. $sText = '';
  2378. if(isset($aContentInfo['content'])){
  2379. $aTmp = unserialize($aContentInfo['content']);
  2380. if(isset($aTmp['text']))
  2381. $sText = $aTmp['text'];
  2382. }
  2383. if(empty($sText) && !empty($aContentInfo[$CNF['FIELD_TITLE']]))
  2384. $sText = $aContentInfo[$CNF['FIELD_TITLE']];
  2385. if(!empty($CNF['OBJECT_METATAGS']) && !empty($sText)) {
  2386. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  2387. $sText = $oMetatags->metaParse($aContentInfo[$CNF['FIELD_ID']], $sText);
  2388. }
  2389. return array(
  2390. 'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
  2391. 'sample_wo_article' => $CNF['T']['txt_sample_single'],
  2392. 'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
  2393. 'url' => $sUrl,
  2394. 'title' => '',
  2395. 'text' => $sText,
  2396. 'images' => array(),
  2397. 'videos' => array()
  2398. );
  2399. }
  2400. protected function _isAllowedPin($aEvent, $bPerform = false)
  2401. {
  2402. $iUserId = (int)$this->getUserId();
  2403. if($iUserId == 0)
  2404. return false;
  2405. if(isAdmin() || (int)$aEvent['owner_id'] == $iUserId || ((int)$aEvent['owner_id'] == 0 && $this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) && (int)$aEvent['object_id'] == $iUserId))
  2406. return true;
  2407. $aCheckResult = checkActionModule($iUserId, 'pin', $this->getName(), $bPerform);
  2408. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2409. if($oProfileOwner !== false)
  2410. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_pin', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  2411. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  2412. }
  2413. protected function _isAllowedStick($aEvent, $bPerform = false)
  2414. {
  2415. $iUserId = (int)$this->getUserId();
  2416. if($iUserId == 0)
  2417. return false;
  2418. if(isAdmin())
  2419. return true;
  2420. $aCheckResult = checkActionModule($iUserId, 'stick', $this->getName(), $bPerform);
  2421. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2422. if($oProfileOwner !== false)
  2423. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_stick', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  2424. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  2425. }
  2426. protected function _isAllowedPromote($aEvent, $bPerform = false)
  2427. {
  2428. if(isAdmin())
  2429. return true;
  2430. $iUserId = (int)$this->getUserId();
  2431. if($iUserId == 0)
  2432. return false;
  2433. $aCheckResult = checkActionModule($iUserId, 'promote', $this->getName(), $bPerform);
  2434. $oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id']);
  2435. if($oProfileOwner !== false)
  2436. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_promote', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  2437. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  2438. }
  2439. protected function _addLink(&$oForm)
  2440. {
  2441. $iUserId = $this->getUserId();
  2442. $sLink = $oForm->getCleanValue('url');
  2443. $aMatches = array();
  2444. preg_match($this->_oConfig->getPregPattern('url'), $sLink, $aMatches);
  2445. $sLink = (empty($aMatches[2]) ? 'http://' : '') . $aMatches[0];
  2446. $aSiteInfo = bx_get_site_info($sLink, array(
  2447. 'thumbnailUrl' => array('tag' => 'link', 'content_attr' => 'href'),
  2448. 'OGImage' => array('name_attr' => 'property', 'name' => 'og:image'),
  2449. ));
  2450. $sTitle = !empty($aSiteInfo['title']) ? $aSiteInfo['title'] : _t('_Empty');
  2451. $sDescription = !empty($aSiteInfo['description']) ? $aSiteInfo['description'] : _t('_Empty');
  2452. $sMediaUrl = '';
  2453. if(!empty($aSiteInfo['thumbnailUrl']))
  2454. $sMediaUrl = $aSiteInfo['thumbnailUrl'];
  2455. else if(!empty($aSiteInfo['OGImage']))
  2456. $sMediaUrl = $aSiteInfo['OGImage'];
  2457. $iMediaId = 0;
  2458. $oStorage = null;
  2459. if(!empty($sMediaUrl)) {
  2460. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . BX_TIMELINE_MEDIA_PHOTO . 's'));
  2461. $iMediaId = $oStorage->storeFileFromUrl($sMediaUrl, true, $iUserId);
  2462. }
  2463. $iId = (int)$oForm->insert(array('profile_id' => $iUserId, 'media_id' => $iMediaId, 'url' => $sLink, 'title' => $sTitle, 'text' => $sDescription, 'added' => time()));
  2464. if(!empty($iId)) {
  2465. if(!empty($oStorage) && !empty($iMediaId))
  2466. $oStorage->afterUploadCleanup($iMediaId, $iUserId);
  2467. return array('id' => $iId, 'item' => $this->_oTemplate->getAttachLinkItem($iUserId, $iId));
  2468. }
  2469. return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
  2470. }
  2471. protected function _deleteLinks($iId)
  2472. {
  2473. $aLinks = $this->_oDb->getLinks($iId);
  2474. if(empty($aLinks) || !is_array($aLinks))
  2475. return;
  2476. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'));
  2477. foreach($aLinks as $aLink)
  2478. if(!empty($aLink['media_id']))
  2479. $oStorage->deleteFile($aLink['media_id']);
  2480. $this->_oDb->deleteLinks($iId);
  2481. }
  2482. protected function _saveMedia($sType, $iId, $aItemIds)
  2483. {
  2484. if(empty($aItemIds) || !is_array($aItemIds))
  2485. return;
  2486. $iUserId = $this->getUserId();
  2487. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
  2488. foreach($aItemIds as $iItemId)
  2489. if($this->_oDb->saveMedia($sType, $iId, $iItemId))
  2490. $oStorage->afterUploadCleanup($iItemId, $iUserId);
  2491. }
  2492. protected function _deleteMedia($sType, $iId)
  2493. {
  2494. $aItems = $this->_oDb->getMedia($sType, $iId);
  2495. if(empty($aItems) || !is_array($aItems))
  2496. return;
  2497. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
  2498. foreach($aItems as $iItemId)
  2499. $oStorage->deleteFile($iItemId);
  2500. $this->_oDb->deleteMedia($sType, $iId);
  2501. }
  2502. protected function _prepareParams($sView, $sType, $iOwnerId, $iStart, $iPerPage, $sFilter = BX_TIMELINE_FILTER_ALL, $aModules = array(), $iTimeline = 0, $aBlink = array())
  2503. {
  2504. $aParams = array(
  2505. 'view' => !empty($sView) ? $sView : BX_TIMELINE_VIEW_DEFAULT,
  2506. 'browse' => 'list',
  2507. 'type' => !empty($sType) ? $sType : BX_TIMELINE_TYPE_DEFAULT,
  2508. 'owner_id' => (int)$iOwnerId != 0 ? $iOwnerId : $this->getUserId(),
  2509. 'filter' => !empty($sFilter) ? $sFilter : BX_TIMELINE_FILTER_ALL,
  2510. 'modules' => is_array($aModules) && !empty($aModules) ? $aModules : array(),
  2511. 'timeline' => (int)$iTimeline > 0 ? $iTimeline : 0,
  2512. 'blink' => is_array($aBlink) && !empty($aBlink) ? $aBlink : array(),
  2513. 'active' => 1,
  2514. 'hidden' => 0
  2515. );
  2516. if($iStart !== false)
  2517. $aParams['start'] = (int)$iStart > 0 ? $iStart : 0;
  2518. if($iPerPage !== false)
  2519. $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage();
  2520. if($this->_oConfig->isHot())
  2521. $aParams['hot'] = $this->_oDb->getHot();
  2522. return $aParams;
  2523. }
  2524. protected function _prepareParamsGet()
  2525. {
  2526. $aParams = array(
  2527. 'browse' => 'list',
  2528. 'dynamic_mode' => true,
  2529. );
  2530. $aParams['view'] = bx_get('view');
  2531. $aParams['view'] = $aParams['view'] !== false ? bx_process_input($aParams['view'], BX_DATA_TEXT) : BX_TIMELINE_VIEW_DEFAULT;
  2532. $aParams['type'] = bx_get('type');
  2533. $aParams['type'] = $aParams['type'] !== false ? bx_process_input($aParams['type'], BX_DATA_TEXT) : BX_TIMELINE_TYPE_DEFAULT;
  2534. $aParams['owner_id'] = bx_get('owner_id');
  2535. $aParams['owner_id'] = $aParams['owner_id'] !== false ? bx_process_input($aParams['owner_id'], BX_DATA_INT) : $this->getUserId();
  2536. $aParams['start'] = bx_get('start');
  2537. $aParams['start'] = $aParams['start'] !== false ? bx_process_input($aParams['start'], BX_DATA_INT) : 0;
  2538. $aParams['per_page'] = bx_get('per_page');
  2539. $aParams['per_page'] = $aParams['per_page'] !== false ? bx_process_input($aParams['per_page'], BX_DATA_INT) : $this->_oConfig->getPerPage();
  2540. $aParams['filter'] = bx_get('filter');
  2541. $aParams['filter'] = $aParams['filter'] !== false ? bx_process_input($aParams['filter'], BX_DATA_TEXT) : BX_TIMELINE_FILTER_ALL;
  2542. $aParams['modules'] = bx_get('modules');
  2543. $aParams['modules'] = $aParams['modules'] !== false ? bx_process_input($aParams['modules'], BX_DATA_TEXT) : array();
  2544. $aParams['timeline'] = bx_get('timeline');
  2545. $aParams['timeline'] = $aParams['timeline'] !== false ? bx_process_input($aParams['timeline'], BX_DATA_INT) : 0;
  2546. $aParams['blink'] = bx_get('blink');
  2547. $aParams['blink'] = $aParams['blink'] !== false ? explode(',', bx_process_input($aParams['blink'], BX_DATA_TEXT)) : array();
  2548. $aParams['active'] = 1;
  2549. $aParams['hidden'] = 0;
  2550. if($this->_oConfig->isHot())
  2551. $aParams['hot'] = $this->_oDb->getHot();
  2552. return $aParams;
  2553. }
  2554. protected function _prepareTextForSave($s)
  2555. {
  2556. return bx_process_input($s, BX_DATA_HTML);
  2557. }
  2558. protected function _getFieldValue($sField, $iContentId)
  2559. {
  2560. $CNF = &$this->_oConfig->CNF;
  2561. if(empty($CNF[$sField]))
  2562. return false;
  2563. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  2564. if(empty($aEvent) || empty($aEvent[$CNF[$sField]]))
  2565. return false;
  2566. return $aEvent[$CNF[$sField]];
  2567. }
  2568. }
  2569. /** @} */