BxTimelineModule.php 215 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552
  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. /**
  14. * SLTMODE - Silent mode:
  15. * It is needed for alert sending module to tell that the alert should be ignored
  16. * with Timeline module completely or partially. Available values:
  17. * 1. disabled (global, value = 0) - all events are registered;
  18. * 2. absolute (global, value = 1) - alert isn't registered which means that event won't appear in timelines at all;
  19. * 3. absolute (for Timeline only, value = 21) - the same as global absolute.
  20. * 4. partial registration might be added in the future versions.
  21. *
  22. * @see BxBaseModNotificationsModule and BxTimelineResponse::response - 'silent_mode' parameter in Alerts Extras array.
  23. */
  24. define('BX_TIMELINE_SLTMODE_ABSOLUTE', 21);
  25. define('BX_TIMELINE_NAME_VIEWS_DB', 'views_db'); //--- Dynamic browsing feeds.
  26. define('BX_TIMELINE_TYPE_ITEM', 'view_item');
  27. define('BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS', 'owner_and_connections');
  28. define('BX_TIMELINE_TYPE_CHANNELS', 'channels'); //--- Followed channels only.
  29. define('BX_TIMELINE_TYPE_FEED', 'feed'); //--- Owner and folloved contexts excluding channels.
  30. define('BX_TIMELINE_TYPE_HOT', 'hot'); //--- Aggrigated hot content.
  31. define('BX_TIMELINE_TYPE_DEFAULT', BX_BASE_MOD_NTFS_TYPE_OWNER);
  32. define('BX_TIMELINE_VIEW_ITEM', 'item');
  33. define('BX_TIMELINE_VIEW_TIMELINE', 'timeline');
  34. define('BX_TIMELINE_VIEW_OUTLINE', 'outline');
  35. define('BX_TIMELINE_VIEW_SEARCH', 'search');
  36. define('BX_TIMELINE_VIEW_DEFAULT', BX_TIMELINE_VIEW_OUTLINE);
  37. define('BX_TIMELINE_FILTER_ALL', 'all');
  38. define('BX_TIMELINE_FILTER_OWNER', 'owner');
  39. define('BX_TIMELINE_FILTER_OTHER', 'other');
  40. define('BX_TIMELINE_FILTER_OTHER_VIEWER', 'other_viewer');
  41. define('BX_TIMELINE_PARSE_TYPE_POST', 'post');
  42. define('BX_TIMELINE_PARSE_TYPE_REPOST', 'repost');
  43. define('BX_TIMELINE_PARSE_TYPE_DEFAULT', BX_TIMELINE_PARSE_TYPE_POST);
  44. define('BX_TIMELINE_STATUS_ACTIVE', 'active');
  45. define('BX_TIMELINE_STATUS_PENDING', 'pending');
  46. define('BX_TIMELINE_STATUS_AWAITING', 'awaiting');
  47. define('BX_TIMELINE_STATUS_FAILED', 'failed');
  48. define('BX_TIMELINE_STATUS_HIDDEN', 'hidden');
  49. define('BX_TIMELINE_STATUS_DELETED', 'deleted');
  50. //--- Video Auto Play
  51. define('BX_TIMELINE_VAP_OFF', 'off');
  52. define('BX_TIMELINE_VAP_ON_MUTE', 'on_mute');
  53. define('BX_TIMELINE_VAP_ON', 'on');
  54. //--- Media Layouts
  55. define('BX_TIMELINE_ML_SINGLE', 'single');
  56. define('BX_TIMELINE_ML_GALLERY', 'gallery');
  57. define('BX_TIMELINE_ML_SHOWCASE', 'showcase');
  58. //--- Default Attachments Media Layout
  59. define('BX_TIMELINE_AML_DEFAULT', BX_TIMELINE_ML_GALLERY);
  60. //--- Hot Feed sources
  61. define('BX_TIMELINE_HFS_CONTENT', 'content');
  62. define('BX_TIMELINE_HFS_COMMENT', 'comment');
  63. define('BX_TIMELINE_HFS_VOTE', 'vote');
  64. class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolContentInfoService
  65. {
  66. protected $_sJsPostObject;
  67. protected $_sJsViewObject;
  68. protected $_aPostElements;
  69. protected $_sJsOutlineObject;
  70. protected $_sDividerTemplate;
  71. protected $_sBalloonTemplate;
  72. protected $_sCmtPostTemplate;
  73. protected $_sCmtViewTemplate;
  74. protected $_sCmtTemplate;
  75. /**
  76. * Constructor
  77. */
  78. function __construct($aModule)
  79. {
  80. parent::__construct($aModule);
  81. }
  82. /**
  83. * ACTION METHODS
  84. */
  85. public function actionGetContexts($iLimit = 20)
  86. {
  87. $oConnection = BxDolConnection::getObjectInstance('sys_profiles_subscriptions');
  88. if(!$oConnection)
  89. return echoJson(array());
  90. $iProfileId = bx_get_logged_profile_id();
  91. $aConnected = $oConnection->getConnectedContent($iProfileId);
  92. $sTerm = bx_get('term');
  93. if(!$sTerm)
  94. return array_slice($aConnected, 0, $iLimit);
  95. $aResults = array();
  96. $aModules = bx_srv('system', 'get_profiles_modules', array(false), 'TemplServiceProfiles');
  97. foreach($aModules as $aModule) {
  98. if(!BxDolRequest::serviceExists($aModule['name'], 'act_as_profile'))
  99. continue;
  100. $aContexts = bx_srv($aModule['name'], 'profiles_search', array($sTerm, PHP_INT_MAX));
  101. foreach($aContexts as $aContext) {
  102. if(!in_array($aContext['value'], $aConnected))
  103. continue;
  104. $aResults[] = $aContext;
  105. }
  106. }
  107. usort($aResults, function($r1, $r2) {
  108. return strcmp($r1['label'], $r2['label']);
  109. });
  110. echoJson(array_slice($aResults, 0, $iLimit));
  111. }
  112. public function actionVideo($iEventId, $iVideoId)
  113. {
  114. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iEventId));
  115. if(empty($aEvent) || !is_array($aEvent))
  116. return;
  117. $aData = $this->_oTemplate->getDataCached($aEvent);
  118. if($aData === false || !isset($aData['content']['videos'][$iVideoId]))
  119. return;
  120. $oTemplate = BxDolTemplate::getInstance();
  121. $oTemplate->addJs(array(
  122. 'embedly-player.min.js'
  123. ));
  124. $oTemplate->setPageNameIndex (BX_PAGE_EMBED);
  125. $oTemplate->setPageContent ('page_main_code', $this->_oTemplate->getVideo($aEvent, $aData['content']['videos'][$iVideoId]));
  126. $oTemplate->getPageCode();
  127. }
  128. public function actionPost()
  129. {
  130. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  131. $mixedAllowed = $this->isAllowedPost(true);
  132. if($mixedAllowed !== true)
  133. return echoJson(array('message' => strip_tags($mixedAllowed)));
  134. echoJson($this->getFormPost());
  135. }
  136. public function actionEdit($iId)
  137. {
  138. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  139. $aBrowseParams = [];
  140. if(bx_get('bp') !== false) {
  141. $aBrowseParams = $this->_oConfig->getBrowseParams(bx_process_input(bx_get('bp')));
  142. $aBrowseParams = $this->_prepareParamsGet($aBrowseParams);
  143. }
  144. $mixedAllowed = $this->isAllowedPost(true);
  145. if($mixedAllowed !== true)
  146. return echoJson(array('message' => strip_tags($mixedAllowed)));
  147. echoJson($this->getFormEdit($iId, array('dynamic_mode' => true), $aBrowseParams));
  148. }
  149. function actionPin()
  150. {
  151. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  152. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  153. if(empty($aEvent) || !is_array($aEvent))
  154. return echoJson(array('code' => 1));
  155. $aParams = $this->_prepareParamsGet();
  156. $this->_iOwnerId = $aParams['owner_id'];
  157. $mixedAllowed = $this->{'isAllowed' . ((int)$aEvent['pinned'] == 0 ? 'Pin' : 'Unpin')}($aEvent, true);
  158. if($mixedAllowed !== true)
  159. return echoJson(array('code' => 2, 'message' => strip_tags($mixedAllowed)));
  160. $aEvent['pinned'] = (int)$aEvent['pinned'] == 0 ? time() : 0;
  161. if(!$this->_oDb->updateEvent(array('pinned' => $aEvent['pinned']), array('id' => $iId)))
  162. return echoJson(array('code' => 3));
  163. echoJson(array(
  164. 'code' => 0,
  165. 'id' => $iId,
  166. 'eval' => $this->_oConfig->getJsObjectView($aParams) . '.onPinPost(oData)'
  167. ));
  168. }
  169. function actionStick()
  170. {
  171. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  172. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  173. if(empty($aEvent) || !is_array($aEvent))
  174. return echoJson(array('code' => 1));
  175. $aParams = $this->_prepareParamsGet();
  176. $this->_iOwnerId = $aParams['owner_id'];
  177. $mixedAllowed = $this->{'isAllowed' . ((int)$aEvent['sticked'] == 0 ? 'Stick' : 'Unstick')}($aEvent, true);
  178. if($mixedAllowed !== true)
  179. return echoJson(array('code' => 2, 'message' => strip_tags($mixedAllowed)));
  180. $aEvent['sticked'] = (int)$aEvent['sticked'] == 0 ? time() : 0;
  181. if(!$this->_oDb->updateEvent(array('sticked' => $aEvent['sticked']), array('id' => $iId)))
  182. return echoJson(array('code' => 3));
  183. bx_audit(
  184. $iId,
  185. $this->getName(),
  186. '_sys_audit_action_' . ((int)$aEvent['sticked'] == 0 ? 'stick' : 'unstick'),
  187. $this->_prepareAuditParams($aEvent, false)
  188. );
  189. echoJson(array(
  190. 'code' => 0,
  191. 'id' => $iId,
  192. 'eval' => $this->_oConfig->getJsObjectView($aParams) . '.onStickPost(oData)'
  193. ));
  194. }
  195. function actionPromote()
  196. {
  197. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  198. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  199. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  200. $sAction = (int)$aEvent['promoted'] == 0 ? 'promote' : 'unpromote';
  201. $mixedAllowed = $this->{'isAllowed' . ucfirst($sAction)}($aEvent, true);
  202. if($mixedAllowed !== true)
  203. return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
  204. $aEvent['promoted'] = (int)$aEvent['promoted'] == 0 ? time() : 0;
  205. if(!$this->_oDb->updateEvent(array('promoted' => $aEvent['promoted']), array('id' => $iId)))
  206. return echoJson(array('code' => 2));
  207. bx_alert($this->_oConfig->getObject('alert'), $sAction . 'd', $iId, (int)$this->getUserId(), array(
  208. 'owner_id' => $aEvent['owner_id'],
  209. 'object_id' => $aEvent['object_id'],
  210. 'object_author_id' => $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? $aEvent['owner_id'] : $aEvent['object_id']
  211. ));
  212. bx_audit(
  213. $iId,
  214. $this->getName(),
  215. '_sys_audit_action_' . ((int)$aEvent['promoted'] == 0 ? 'promote' : 'unpromote'),
  216. $this->_prepareAuditParams($aEvent, false)
  217. );
  218. echoJson(array(
  219. 'code' => 0,
  220. 'message' => _t('_bx_timeline_txt_msg_performed_action')
  221. ));
  222. }
  223. function actionMarkAsRead()
  224. {
  225. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  226. $aEvent = $this->_oDb->getEvents(['browse' => 'id', 'value' => $iId]);
  227. if(empty($aEvent) || !is_array($aEvent))
  228. return echoJson(['code' => 1]);
  229. $aParams = $this->_prepareParamsGet();
  230. if(!$this->_oDb->markAsRead($aParams['viewer_id'], $iId))
  231. return echoJson(['code' => 2]);
  232. echoJson([
  233. 'code' => 0,
  234. 'id' => $iId
  235. ]);
  236. }
  237. function actionMute()
  238. {
  239. $CNF = &$this->_oConfig->CNF;
  240. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  241. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  242. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  243. $mixedAllowed = $this->isAllowedMute($aEvent, true);
  244. if($mixedAllowed !== true)
  245. return echoJson(array('code' => 1, 'message' => strip_tags($mixedAllowed)));
  246. $iAuthor = (int)$aEvent[$CNF['FIELD_OWNER_ID']];
  247. if(!$this->_oConfig->isSystem($aEvent['type'], $aEvent['action']))
  248. $iAuthor = (int)$aEvent[$CNF['FIELD_OBJECT_ID']];
  249. if(!$this->getConnectionMuteObject()->addConnection($this->_iProfileId, $iAuthor))
  250. return echoJson(array('code' => 2));
  251. bx_alert($this->_oConfig->getObject('alert'), 'muted', $iAuthor, $this->_iProfileId, array(
  252. 'owner_id' => $aEvent['owner_id'],
  253. 'object_id' => $aEvent['object_id'],
  254. 'object_author_id' => $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? $aEvent['owner_id'] : $aEvent['object_id']
  255. ));
  256. echoJson(array('code' => 0, 'message' => _t('_bx_timeline_txt_msg_performed_action'), 'reload' => 1));
  257. }
  258. function actionDelete()
  259. {
  260. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  261. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  262. if(empty($aEvent) || !is_array($aEvent))
  263. return echoJson(array('code' => 1));
  264. $aParams = $this->_prepareParamsGet();
  265. $this->_iOwnerId = $aParams['owner_id'];
  266. $mixedAllowed = $this->isAllowedDelete($aEvent, true);
  267. if($mixedAllowed !== true)
  268. return echoJson(array('code' => 2, 'message' => strip_tags($mixedAllowed)));
  269. if(!$this->{$this->_oConfig->isHideUponDelete() ? 'hideEvent' : 'deleteEvent'}($aEvent))
  270. return echoJson(array('code' => 3));
  271. echoJson(array(
  272. 'code' => 0,
  273. 'id' => $aEvent['id'],
  274. 'eval' => $this->_oConfig->getJsObjectView($aParams) . '.onDeletePost(oData)'
  275. ));
  276. }
  277. public function actionRepost()
  278. {
  279. $iAuthorId = $this->getUserId();
  280. $iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  281. $sType = bx_process_input(bx_get('type'), BX_DATA_TEXT);
  282. $sAction = bx_process_input(bx_get('action'), BX_DATA_TEXT);
  283. $iObjectId = bx_process_input(bx_get('object_id'), BX_DATA_INT);
  284. $aResult = $this->repost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId);
  285. if(!empty($aResult) && is_array($aResult))
  286. return echoJson($aResult);
  287. $aParams = $this->_oConfig->getRepostDefaults();
  288. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  289. echoJson([
  290. 'code' => 0,
  291. 'message' => _t('_bx_timeline_txt_msg_success_repost'),
  292. 'count' => $aReposted['reposts'],
  293. 'countf' => (int)$aReposted['reposts'] > 0 ? $this->_oTemplate->getRepostCounterLabel($aReposted['reposts'], $aParams) : '',
  294. 'counter' => $this->_oTemplate->getRepostCounter($aReposted, $aParams),
  295. 'disabled' => true
  296. ]);
  297. }
  298. public function actionRepostWith()
  299. {
  300. if(($iReposterId = bx_get('reposter_id')) !== false)
  301. $iReposterId = bx_process_input($iReposterId, BX_DATA_INT);
  302. $iUserId = $this->getUserId();
  303. if(!$iReposterId || $iReposterId != $iUserId)
  304. $iReposterId = $iUserId;
  305. $iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  306. $sType = bx_process_input(bx_get('type'), BX_DATA_TEXT);
  307. $sAction = bx_process_input(bx_get('action'), BX_DATA_TEXT);
  308. $iObjectId = bx_process_input(bx_get('object_id'), BX_DATA_INT);
  309. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_repost'), $this->_oConfig->getObject('form_display_repost_with'));
  310. $oForm->initChecker(array(
  311. 'reposter_id' => $iReposterId,
  312. 'owner_id' => $iOwnerId,
  313. 'type' => $sType,
  314. 'action' => $sAction,
  315. 'object_id' => $iObjectId
  316. ));
  317. if($oForm->isSubmitted()) {
  318. if(!$oForm->isValid())
  319. return echoJson(array('popup' => array(
  320. 'html' => BxTemplFunctions::getInstance()->transBox($this->_oConfig->getHtmlIds('repost', 'with_popup'), $this->_oTemplate->getRepostWith($oForm)),
  321. 'options' => array('closeOnOuterClick' => false, 'removeOnClose' => true)
  322. )));
  323. $this->repost($iReposterId, $iOwnerId, $sType, $sAction, $iObjectId, ['text' => $oForm->getCleanValue('text')]);
  324. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  325. $sCounter = $this->_oTemplate->getRepostCounter($aReposted);
  326. return echoJson(array(
  327. 'code' => 0,
  328. 'message' => _t('_bx_timeline_txt_msg_success_repost'),
  329. 'count' => $aReposted['reposts'],
  330. 'countf' => (int)$aReposted['reposts'] > 0 ? $this->_oTemplate->getRepostCounterLabel($aReposted['reposts']) : '',
  331. 'counter' => $sCounter,
  332. ));
  333. }
  334. echo $this->_oTemplate->getRepostTo($oForm);
  335. }
  336. public function actionRepostTo()
  337. {
  338. $iReposterId = bx_process_input(bx_get('reposter_id'), BX_DATA_INT);
  339. if($iReposterId != $this->getUserId())
  340. return;
  341. $sType = bx_process_input(bx_get('type'), BX_DATA_TEXT);
  342. $sAction = bx_process_input(bx_get('action'), BX_DATA_TEXT);
  343. $iObjectId = bx_process_input(bx_get('object_id'), BX_DATA_INT);
  344. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_repost'), $this->_oConfig->getObject('form_display_repost_to'));
  345. $oForm->initChecker(array(
  346. 'reposter_id' => $iReposterId,
  347. 'type' => $sType,
  348. 'action' => $sAction,
  349. 'object_id' => $iObjectId
  350. ));
  351. if($oForm->isSubmitted()) {
  352. if(!$oForm->isValid())
  353. return echoJson(array('popup' => array(
  354. 'html' => BxTemplFunctions::getInstance()->transBox($this->_oConfig->getHtmlIds('repost', 'to_popup'), $this->_oTemplate->getRepostTo($oForm)),
  355. 'options' => array('closeOnOuterClick' => false, 'removeOnClose' => true)
  356. )));
  357. $aContexts = array();
  358. if(($aContextsSearch = $oForm->getCleanValue('search')) !== false)
  359. $aContexts = array_merge($aContexts, $aContextsSearch);
  360. if(($aContextsList = $oForm->getCleanValue('list')) !== false)
  361. $aContexts = array_merge($aContexts, $aContextsList);
  362. $aContexts = array_unique($aContexts);
  363. if(empty($aContexts) || !is_array($aContexts))
  364. return echoJson(array());
  365. foreach($aContexts as $iContextId)
  366. $this->repost($iReposterId, $iContextId, $sType, $sAction, $iObjectId);
  367. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  368. $sCounter = $this->_oTemplate->getRepostCounter($aReposted);
  369. return echoJson(array(
  370. 'code' => 0,
  371. 'message' => _t('_bx_timeline_txt_msg_success_repost'),
  372. 'count' => $aReposted['reposts'],
  373. 'countf' => (int)$aReposted['reposts'] > 0 ? $this->_oTemplate->getRepostCounterLabel($aReposted['reposts']) : '',
  374. 'counter' => $sCounter,
  375. ));
  376. }
  377. echo $this->_oTemplate->getRepostTo($oForm);
  378. }
  379. function actionGetView()
  380. {
  381. $aParams = $this->_prepareParamsGet();
  382. $this->_iOwnerId = $aParams['owner_id'];
  383. $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
  384. if(!$oProfileOwner)
  385. return echoJson([]);
  386. $mixedResult = $oProfileOwner->checkAllowedProfileView();
  387. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  388. return echoJson(['code' => 1, 'msg' => $mixedResult]);
  389. $sContent = $this->_oTemplate->getViewBlock($aParams);
  390. if(empty($sContent))
  391. return echoJson([]);
  392. if(!empty($aParams['type']))
  393. $this->_oConfig->setUserChoice(['type' => $aParams['type']]);
  394. echoJson([
  395. 'code' => 0,
  396. 'content' => $sContent,
  397. ]);
  398. }
  399. function actionGetViewFilters()
  400. {
  401. $aParams = $this->_prepareParamsGet();
  402. $sContent = $this->_oTemplate->getViewFilters($aParams);
  403. if(empty($sContent))
  404. return echoJson([]);
  405. echoJson([
  406. 'code' => 0,
  407. 'popup' => [
  408. 'html' => $sContent,
  409. 'options' => [
  410. 'closeOnOuterClick' => true,
  411. 'removeOnClose' => false,
  412. ]
  413. ],
  414. ]);
  415. }
  416. function actionGetPost()
  417. {
  418. $aParams = $this->_prepareParamsGet();
  419. $aParams['dynamic_mode'] = true;
  420. $this->_iOwnerId = $aParams['owner_id'];
  421. $sJsObject = '';
  422. if(bx_get('js_object') !== false)
  423. $sJsObject = $this->_oConfig->prepareParam('js_object');
  424. if(empty($sJsObject))
  425. $sJsObject = $this->_oConfig->getJsObject('post');
  426. $aEvent = $this->_oDb->getEvents(['browse' => 'id', 'value' => (int)bx_get('id')]);
  427. if(empty($aEvent) || !is_array($aEvent))
  428. return echoJson([]);
  429. /**
  430. * Note. Disabled for now, because Own posts on Timelines of Following members
  431. * became visible on posts' author Dashboard Timeline.
  432. *
  433. $bAfpsLoading = (int)bx_get('afps_loading') === 1;
  434. if($bAfpsLoading && $this->_iOwnerId != $aEvent['owner_id'])
  435. return echoJson(array('message' => _t('_bx_timeline_txt_msg_posted')));
  436. *
  437. */
  438. $aResult = [
  439. 'id' => (int)$aEvent['id'],
  440. 'name' => $aParams['name'],
  441. 'view' => $aParams['view'],
  442. 'type' => $aParams['type'],
  443. 'item' => $this->_oTemplate->getPost($aEvent, $aParams),
  444. 'eval' => $sJsObject . "._onGetPost(oData)"
  445. ];
  446. bx_alert($this->getName(), 'on_get_post', 0, 0, [
  447. 'params' => $aParams,
  448. 'override_result' => &$aResult,
  449. ]);
  450. echoJson($aResult);
  451. }
  452. function actionGetPosts()
  453. {
  454. $aParams = $this->_prepareParamsGet();
  455. list($sItems, $sLoadMore, $sBack, $sEmpty, $iEvent, $bEventsToLoad) = $this->_oTemplate->getPosts($aParams);
  456. echoJson(array(
  457. 'view' => $aParams['view'],
  458. 'items' => $sItems,
  459. 'load_more' => $sLoadMore,
  460. 'back' => $sBack,
  461. 'empty' => $sEmpty,
  462. 'events_to_load' => $bEventsToLoad,
  463. 'eval' => $this->_oConfig->getJsObjectView($aParams) . "._onGetPosts(oData)"
  464. ));
  465. }
  466. /**
  467. * @page service Service Calls
  468. * @section bx_timeline Timeline
  469. * @subsection bx_timeline-other Other
  470. * @subsubsection bx_timeline-get_posts get_posts
  471. *
  472. * @code bx_srv('bx_timeline', 'get_posts', [...]); @endcode
  473. *
  474. * Get a posts list for API.
  475. *
  476. * @return an array
  477. *
  478. * @see BxTimelineModule::serviceGetPosts
  479. */
  480. /**
  481. * @ref bx_timeline-get_posts "get_posts"
  482. * @api @ref bx_timeline-get_posts "get_posts"
  483. */
  484. function serviceGetPosts($aParams)
  485. {
  486. if(is_string($aParams)){
  487. $aParams = json_decode($aParams, true);
  488. }
  489. return $this->_serviceGetBlockViewByType($aParams['params']);
  490. }
  491. public function actionGetPostForm()
  492. {
  493. $CNF = &$this->_oConfig->CNF;
  494. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  495. $sType = bx_process_input(bx_get('type'));
  496. $aResult = $this->getFormPost([
  497. 'type' => $sType,
  498. 'form_display' => $this->_oConfig->getPostFormDisplay($sType)
  499. ]);
  500. if($this->_oConfig->isEditorAutoattach() && !empty($aResult['form_object'])) {
  501. $aUploadersInfo = $aResult['form_object']->getUploadersInfo($CNF['FIELD_PHOTO']);
  502. if(!empty($aUploadersInfo) && is_array($aUploadersInfo))
  503. $aResult = array_merge($aResult, ['options' => [
  504. 'sAutoUploader' => $aUploadersInfo['name'],
  505. 'sAutoUploaderId' => $aUploadersInfo['id']
  506. ]]);
  507. unset($aResult['form_object']);
  508. }
  509. echoJson($aResult);
  510. }
  511. public function actionGetEditForm($iId)
  512. {
  513. $aParams = $this->_prepareParamsGet();
  514. $this->_iOwnerId = $aParams['owner_id'];
  515. echoJson($this->getFormEdit($iId, array('dynamic_mode' => true), $aParams));
  516. }
  517. public function actionGetComments()
  518. {
  519. $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
  520. $sSystem = bx_process_input(bx_get('system'), BX_DATA_TEXT);
  521. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  522. $sComments = $this->_oTemplate->getComments($sSystem, $iId, array('dynamic_mode' => true));
  523. echoJson(array('content' => $sComments));
  524. }
  525. public function actionAddAttachLink()
  526. {
  527. $sUrl = bx_process_input(bx_get('url'));
  528. if(empty($sUrl))
  529. return echoJson([]);
  530. $sUrl = htmlspecialchars_decode($sUrl);
  531. $aHeaders = @get_headers($sUrl, 1);
  532. if($aHeaders === false)
  533. return echoJson([]);
  534. $sHeader = 'Content-Type';
  535. if(!empty($aHeaders[$sHeader])) {
  536. $mixedContentType = $aHeaders[$sHeader];
  537. if(!is_array($mixedContentType))
  538. $mixedContentType = [$mixedContentType];
  539. foreach($mixedContentType as $sContentType)
  540. if(strpos($sContentType, 'image') !== false)
  541. return echoJson([]);
  542. }
  543. $iEventId = 0;
  544. if(bx_get('event_id') !== false)
  545. $iEventId = (int)bx_get('event_id');
  546. echoJson($this->addAttachLink([
  547. 'event_id' => $iEventId,
  548. 'url' => $sUrl
  549. ]));
  550. }
  551. public function actionDeleteAttachLink()
  552. {
  553. $iUserId = $this->getUserId();
  554. $iLinkId = bx_process_input(bx_get('id'), BX_DATA_INT);
  555. if(empty($iLinkId))
  556. return echoJson([]);
  557. $aLink = $this->_oDb->getLinksBy(['type' => 'id', 'id' => $iLinkId, 'profile_id' => $iUserId]);
  558. if(empty($aLink) || !is_array($aLink))
  559. return echoJson([]);
  560. if(!empty($aLink['media_id']))
  561. BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'))->deleteFile($aLink['media_id']);
  562. $aResult = [];
  563. if($this->_oDb->deleteLink($iLinkId))
  564. $aResult = ['code' => 0, 'url' => $aLink['url']];
  565. else
  566. $aResult = ['code' => 1, 'message' => _t('_bx_timeline_form_post_input_link_err_delete')];
  567. echoJson($aResult);
  568. }
  569. public function actionGetAttachLinkForm()
  570. {
  571. $iEventId = 0;
  572. if(bx_get('event_id') !== false)
  573. $iEventId = (int)bx_get('event_id');
  574. echo $this->_oTemplate->getAttachLinkForm($iEventId);
  575. }
  576. public function actionSubmitAttachLinkForm()
  577. {
  578. echoJson($this->getFormAttachLink());
  579. }
  580. public function actionAutoAttachInsertion()
  581. {
  582. $sTxtError = _t('_bx_timeline_txt_err_cannot_perform_insertion');
  583. $sUploader = bx_process_input(bx_get('u'));
  584. $sResultContainerId = bx_process_input(bx_get('uid'));
  585. $sStorage = $this->_oConfig->getObject('storage_photos');
  586. $oUploader = BxDolUploader::getObjectInstance($sUploader, $sStorage, $sResultContainerId, $this->_oTemplate);
  587. if(!$oUploader)
  588. return echoJson(['code' => 1, 'msg' => $sTxtError]);
  589. ob_start();
  590. $oUploader->handleUploads(bx_get_logged_profile_id(), isset($_FILES['file']) ? $_FILES['file'] : null, true, false, false);
  591. ob_end_clean();
  592. $sError = $oUploader->getUploadErrorMessages();
  593. if(!empty($sError))
  594. return echoJson(['code' => 2, 'msg' => $sError]);
  595. return echoJson(['code' => 0, 'eval' => $oUploader->getNameJsInstanceUploader() . '.restoreGhosts()']);
  596. }
  597. public function actionGetRepostedBy()
  598. {
  599. $iRepostedId = bx_process_input(bx_get('id'), BX_DATA_INT);
  600. echo $this->_oTemplate->getRepostedBy($iRepostedId);
  601. }
  602. public function actionGetItemBrief()
  603. {
  604. $aParams = $this->_prepareParamsGet();
  605. $iEvent = bx_process_input(bx_get('id'), BX_DATA_INT);
  606. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iEvent));
  607. if(empty($aEvent) || !is_array($aEvent)) {
  608. echo MsgBox(_t('_Empty'));
  609. return;
  610. }
  611. if(!$this->isAllowedView($aEvent)) {
  612. echo MsgBox(_t('_sys_access_denied_to_private_content'));
  613. return;
  614. }
  615. $sName = $this->_oConfig->getHtmlIdView('item_popup', $aParams, array('whole' => false, 'hash' => false)) . $iEvent;
  616. $sTitle = _t('_bx_timeline_page_title_item_brief');
  617. $sContent = BxDolPage::getObjectInstance($this->_oConfig->getObject('page_item_brief'), $this->_oTemplate)->getCodeDynamic();
  618. echo PopupBox($sName, $sTitle, $sContent, true);
  619. }
  620. public function actionGetJumpTo()
  621. {
  622. $aParams = $this->_prepareParamsGet();
  623. $this->_iOwnerId = $aParams['owner_id'];
  624. $sJsObjectView = $this->_oConfig->getJsObjectView($aParams);
  625. echoJson(array(
  626. 'content' => $this->_oTemplate->getJumpTo($aParams),
  627. 'eval' => $sJsObjectView . '.onGetJumpTo(oData)'
  628. ));
  629. }
  630. public function actionResumeLiveUpdate()
  631. {
  632. $aParams = $this->_prepareParamsGet();
  633. $sKey = $this->_oConfig->getLiveUpdateKey($aParams);
  634. bx_import('BxDolSession');
  635. BxDolSession::getInstance()->unsetValue($sKey);
  636. }
  637. public function actionPauseLiveUpdate()
  638. {
  639. $aParams = $this->_prepareParamsGet();
  640. $sKey = $this->_oConfig->getLiveUpdateKey($aParams);
  641. bx_import('BxDolSession');
  642. BxDolSession::getInstance()->setValue($sKey, 1);
  643. }
  644. function actionRss()
  645. {
  646. $CNF = &$this->_oConfig->CNF;
  647. $iLength = $this->_oConfig->getRssLength();
  648. if(!$iLength)
  649. return;
  650. $iOwnerId = 0;
  651. $aArgs = func_get_args();
  652. $sType = array_shift($aArgs);
  653. switch($sType) {
  654. case BX_BASE_MOD_NTFS_TYPE_OWNER:
  655. $iOwnerId = array_shift($aArgs);
  656. $sOwnerName = $this->getObjectUser($iOwnerId)->getDisplayName();
  657. $sRssCaption = _t('_bx_timeline_txt_rss_caption', $sOwnerName);
  658. $sRssLink = $this->_oConfig->getViewUrl($iOwnerId);
  659. break;
  660. case BX_BASE_MOD_NTFS_TYPE_PUBLIC:
  661. $sRssCaption = _t('_bx_timeline_page_title_view_home');
  662. $sRssLink = $this->_oConfig->getHomeViewUrl();
  663. break;
  664. }
  665. $aParams = $this->_prepareParams(array(
  666. 'view' => BX_TIMELINE_VIEW_DEFAULT,
  667. 'type' => $sType,
  668. 'owner_id' => $iOwnerId,
  669. 'start' => 0,
  670. 'per_page' => $iLength,
  671. 'timeline' => 0,
  672. 'filter' => '',
  673. 'modules' => array()
  674. ));
  675. $aEvents = $this->_oDb->getEvents($aParams);
  676. $oPrivacy = BxDolPrivacy::getObjectInstance($this->_oConfig->getObject('privacy_view'));
  677. $aRssData = array();
  678. foreach($aEvents as $aEvent) {
  679. if(empty($aEvent['title']))
  680. continue;
  681. $iEventId = (int)$aEvent[$CNF['FIELD_ID']];
  682. $sEventFieldAuthor = $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? 'owner_id' : 'object_id';
  683. if($oPrivacy) {
  684. $oPrivacy->setTableFieldAuthor($sEventFieldAuthor);
  685. if(!$oPrivacy->check($iEventId))
  686. continue;
  687. }
  688. $iOwner = $aEvent[$sEventFieldAuthor];
  689. $oOwner = BxDolProfile::getInstanceMagic($iOwner);
  690. $aRssData[$iEventId] = array(
  691. 'UnitID' => $iEventId,
  692. 'UnitTitle' => $aEvent['title'],
  693. 'UnitLink' => $this->_oConfig->getItemViewUrl($aEvent),
  694. 'UnitDesc' => bx_replace_markers($aEvent['description'], array(
  695. 'profile_name' => $oOwner->getDisplayName()
  696. )),
  697. 'UnitDateTimeUTS' => $aEvent['date'],
  698. );
  699. }
  700. $oRss = new BxDolRssFactory();
  701. header('Content-Type: application/xml; charset=utf-8');
  702. echo $oRss->GenRssByData($aRssData, $sRssCaption, $sRssLink);
  703. }
  704. /**
  705. * SERVICE METHODS
  706. */
  707. public function serviceGetSafeServices()
  708. {
  709. $a = parent::serviceGetSafeServices();
  710. return array_merge($a, array (
  711. 'GetCreatePostForm' => '',
  712. 'GetSearchResultUnit' => '',
  713. 'GetBlockPost' => '',
  714. 'GetBlockPostProfile' => '',
  715. 'GetBlockPostHome' => '',
  716. 'GetBlockPostAccount' => '',
  717. 'GetBlockView' => '',
  718. 'GetBlockViewOutline' => '',
  719. 'GetBlockViewProfile' => '',
  720. 'GetBlockViewProfileOutline' => '',
  721. 'GetBlockViewsTimeline' => '',
  722. 'GetBlockViewsOutline' => '',
  723. 'GetBlockViewHome' => '',
  724. 'GetBlockViewHomeOutline' => '',
  725. 'GetBlockViewHot' => '',
  726. 'GetBlockViewHotOutline' => '',
  727. 'GetBlockViewAccount' => '',
  728. 'GetBlockViewAccountOutline' => '',
  729. 'GetPosts' => ''
  730. ));
  731. }
  732. /**
  733. * @page service Service Calls
  734. * @section bx_timeline Timeline
  735. * @subsection bx_timeline-other Other
  736. * @subsubsection bx_timeline-get_hot_sources_checklist get_hot_sources_checklist
  737. *
  738. * @code bx_srv('bx_timeline', 'get_hot_sources_checklist', [...]); @endcode
  739. *
  740. * Get a list of available sources for Hot feed. Is used in module settings in Studio.
  741. *
  742. * @return an array with available sources represented as key => value pairs.
  743. *
  744. * @see BxTimelineModule::serviceGetHotSourcesChecklist
  745. */
  746. /**
  747. * @ref bx_timeline-get_hot_sources_checklist "get_hot_sources_checklist"
  748. */
  749. function serviceGetHotSourcesChecklist()
  750. {
  751. $CNF = &$this->_oConfig->CNF;
  752. $aSources = $this->_oConfig->getHotSourcesList();
  753. $aResults = [];
  754. foreach($aSources as $sSource)
  755. $aResults[$sSource] = _t($CNF['T']['option_hs_' . $sSource]);
  756. return $aResults;
  757. }
  758. public function serviceManageTools($sType = 'common')
  759. {
  760. $sResult = parent::serviceManageTools($sType);
  761. if(!empty($sResult))
  762. $this->_oTemplate->addJsSystem(['modules/base/text/js/|manage_tools.js']);
  763. return $sResult;
  764. }
  765. public function serviceFeedsMenuAdd($mixedModule = false)
  766. {
  767. $sSetName = $this->_oConfig->getObject('menu_set_feeds');
  768. $iOrder = $this->_oDb->getMenuItemMaxOrder($sSetName);
  769. $aModules = !empty($mixedModule) ? [$this->_oDb->getModuleByName($mixedModule)] : bx_srv('system', 'get_modules_by_type', ['context']);
  770. foreach($aModules as $aModule) {
  771. $sModuleName = $aModule['name'];
  772. $sModuleUri = $aModule['uri'];
  773. if($sModuleName == 'system' && $sModuleUri == 'system')
  774. continue;
  775. $iMenuItem = $this->_oDb->getMenuItemId($sSetName, $sModuleUri);
  776. if(!empty($iMenuItem))
  777. continue;
  778. $sTitleKey = '_' . $sModuleName;
  779. if(strcmp($sTitleKey, _t($sTitleKey)) == 0)
  780. $sTitleKey = $aModule['title'];
  781. $this->_oDb->insertMenuItem($sSetName, $sModuleName, $sModuleUri, $sTitleKey, ++$iOrder);
  782. }
  783. return true;
  784. }
  785. public function serviceFeedsMenuDelete($mixedModule = false)
  786. {
  787. $sSetName = $this->_oConfig->getObject('menu_set_feeds');
  788. $aModules = !empty($mixedModule) ? [$this->_oDb->getModuleByName($mixedModule)] : bx_srv('system', 'get_modules_by_type', ['context']);
  789. foreach($aModules as $aModule)
  790. $this->_oDb->deleteMenuItem($sSetName, $aModule['uri']);
  791. return true;
  792. }
  793. /**
  794. * @page service Service Calls
  795. * @section bx_timeline Timeline
  796. * @subsection bx_timeline-other Other
  797. * @subsubsection bx_timeline-get_content_owner_profile_id get_content_owner_profile_id
  798. *
  799. * @code bx_srv('bx_timeline', 'get_content_owner_profile_id', [...]); @endcode
  800. *
  801. * Get event's owner profile id.
  802. *
  803. * @param $mixedEvent integer value with event ID or an array with event info.
  804. * @return event's owner profile id.
  805. *
  806. * @see BxTimelineModule::serviceGetContentOwnerProfileId
  807. */
  808. /**
  809. * @ref bx_timeline-get_content_owner_profile_id "get_content_owner_profile_id"
  810. */
  811. public function serviceGetContentOwnerProfileId($mixedEvent)
  812. {
  813. $CNF = &$this->_oConfig->CNF;
  814. $iProfile = (int)bx_get_logged_profile_id();
  815. if(empty($mixedEvent))
  816. return $iProfile;
  817. if(!is_array($mixedEvent))
  818. $mixedEvent = $this->_oDb->getContentInfoById((int)$mixedEvent);
  819. if(empty($mixedEvent) || !is_array($mixedEvent) || !isset($mixedEvent[$CNF['FIELD_SYSTEM']]))
  820. return $iProfile;
  821. if((int)$mixedEvent[$CNF['FIELD_SYSTEM']] == 0)
  822. return (int)$mixedEvent[$CNF['FIELD_OBJECT_ID']];
  823. if(!empty($mixedEvent['object_owner_id']))
  824. return (int)$mixedEvent['object_owner_id'];
  825. if(!empty($mixedEvent['content'])) {
  826. $aContent = unserialize($mixedEvent['content']);
  827. if(!empty($aContent) && is_array($aContent) && !empty($aContent['object_author_id']))
  828. return (int)$aContent['object_author_id'];
  829. }
  830. $aEventData = $this->_oTemplate->getData($mixedEvent);
  831. if(!empty($aEventData) && is_array($aEventData) && !empty($aEventData['object_owner_id']))
  832. return (int)$aEventData['object_owner_id'];
  833. return $iProfile;
  834. }
  835. /**
  836. * @page service Service Calls
  837. * @section bx_timeline Timeline
  838. * @subsection bx_timeline-other Other
  839. * @subsubsection bx_timeline-get_create_post_form get_create_post_form
  840. *
  841. * @code bx_srv('bx_timeline', 'get_create_post_form', [...]); @endcode
  842. *
  843. * Get form code for add content. Is needed for United Post Form.
  844. *
  845. * @param $aParams optional array with parameters(display name, etc)
  846. * @return form code or error
  847. *
  848. * @see BxTimelineModule::serviceGetCreatePostForm
  849. */
  850. /**
  851. * @ref bx_timeline-get_create_post_form "get_create_post_form"
  852. */
  853. public function serviceGetCreatePostForm($aParams = array())
  854. {
  855. $CNF = &$this->_oConfig->CNF;
  856. $aParams = array_merge($this->_aFormParams, $aParams);
  857. $bContext = $aParams['context_id'] !== false;
  858. $this->_iOwnerId = $bContext ? abs($aParams['context_id']) : 0;
  859. $oForm = $this->serviceGetObjectForm('add', $aParams);
  860. if(!$oForm)
  861. return '';
  862. $aParams['type'] = BX_BASE_MOD_NTFS_TYPE_PUBLIC;
  863. $aParams['form_display'] = 'form_display_post_add_public';
  864. if($bContext) {
  865. if($aParams['context_id'] < 0) {
  866. $aParams['type'] = BX_BASE_MOD_NTFS_TYPE_OWNER;
  867. $aParams['form_display'] = 'form_display_post_add_profile';
  868. }
  869. else {
  870. $aParams['type'] = BX_TIMELINE_TYPE_FEED;
  871. $aParams['form_display'] = 'form_display_post_add';
  872. }
  873. }
  874. if(!empty($aParams['display']))
  875. $aParams['form_display'] = $aParams['display'];
  876. $aResult = $this->getFormPost($aParams);
  877. if(!empty($aResult['form'])) {
  878. $bDynamicMode = isset($aParams['dynamic_mode']) && $aParams['dynamic_mode'];
  879. if($this->_oConfig->isEditorAutoattach() && !empty($aResult['form_object'])) {
  880. $aUploadersInfo = $aResult['form_object']->getUploadersInfo($CNF['FIELD_PHOTO']);
  881. if(!empty($aUploadersInfo) && is_array($aUploadersInfo))
  882. $aParams = [
  883. 'gparams' => ['sAutoUploader' => $aUploadersInfo['name'], 'sAutoUploaderId' => $aUploadersInfo['id']],
  884. 'rparams' => $aParams
  885. ];
  886. }
  887. $sCode = '';
  888. $sCode .= $this->_oTemplate->getJsCodePost($this->_iOwnerId, $aParams, true, $bDynamicMode);
  889. $sCode .= $aResult['form'];
  890. return $sCode;
  891. }
  892. if(!empty($aResult['message']))
  893. return $aResult['message'];
  894. return '';
  895. }
  896. /**
  897. * @page service Service Calls
  898. * @section bx_timeline Timeline
  899. * @subsection bx_timeline-other Other
  900. * @subsubsection bx_timeline-get_object_form get_object_form
  901. *
  902. * @code bx_srv('bx_timeline', 'get_object_form', [...]); @endcode
  903. *
  904. * Get form object for add, edit, view or delete the content.
  905. *
  906. * @param $sType 'add' is supported only
  907. * @param $aParams optional array with parameters(display name, etc)
  908. * @return form object or false on error
  909. *
  910. * @see BxTimelineModule::serviceGetObjectForm
  911. */
  912. /**
  913. * @ref bx_timeline-get_object_form "get_object_form"
  914. */
  915. public function serviceGetObjectForm ($sType, $aParams = array())
  916. {
  917. if(!in_array($sType, array('add')))
  918. return false;
  919. $bContext = $aParams['context_id'] !== false;
  920. if($bContext && ($oContextProfile = BxDolProfile::getInstance(abs($aParams['context_id']))) !== false)
  921. if($oContextProfile->checkAllowedPostInProfile() !== CHECK_ACTION_RESULT_ALLOWED)
  922. return false;
  923. $aParams['type'] = BX_BASE_MOD_NTFS_TYPE_PUBLIC;
  924. $aParams['form_display'] = 'form_display_post_add_public';
  925. if($bContext) {
  926. if($aParams['context_id'] < 0) {
  927. $aParams['type'] = BX_BASE_MOD_NTFS_TYPE_OWNER;
  928. $aParams['form_display'] = 'form_display_post_add_profile';
  929. }
  930. else {
  931. $aParams['type'] = BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS;
  932. $aParams['form_display'] = 'form_display_post_add';
  933. }
  934. }
  935. if(!empty($aParams['display']))
  936. $aParams['form_display'] = $aParams['display'];
  937. $oForm = $this->getFormPostObject($aParams);
  938. bx_alert('system', 'get_object_form', 0, 0, array(
  939. 'module' => $this->_oConfig->getName(),
  940. 'type' => $sType,
  941. 'params' => $aParams,
  942. 'form' => &$oForm
  943. ));
  944. return $oForm;
  945. }
  946. /**
  947. * @page service Service Calls
  948. * @section bx_timeline Timeline
  949. * @subsection get_timeline_post
  950. * @see BxTimelineModule::serviceGetTimelinePost
  951. *
  952. * Get Timeline post. It's needed for Timeline module.
  953. *
  954. * @param $aEvent timeline event array from Timeline module
  955. * @return array in special format which is needed specifically for Timeline module to display the data.
  956. */
  957. public function serviceGetTimelinePost($aEvent, $aBrowseParams = array())
  958. {
  959. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  960. if(empty($aContentInfo) || !is_array($aContentInfo))
  961. return false;
  962. $aEvent = array_merge($aEvent, array(
  963. 'owner_id' => $aContentInfo['owner_id'],
  964. 'object_privacy_view' => $aContentInfo['object_privacy_view']
  965. ));
  966. /*
  967. * Note. For 'Direct Timeline Posts' FIELD_OBJECT_ID contains post's author profile ID.
  968. */
  969. $this->_oConfig->CNF['FIELD_AUTHOR'] = $this->_oConfig->CNF['FIELD_OBJECT_ID'];
  970. return parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
  971. }
  972. /**
  973. * @page service Service Calls
  974. * @section bx_timeline Timeline
  975. * @subsection get_timeline_post
  976. * @see BxTimelineModule::serviceGetTimelinePostAllowedView
  977. *
  978. * Check Timeline post's visibility. It's needed for Timeline module, when its events
  979. * are accessed and checked from outside. For example, when they are referenced
  980. * from Channels module.
  981. *
  982. * @param $aEvent timeline event array from Timeline module
  983. * @return mixed value: CHECK_ACTION_RESULT_ALLOWED or text of some error message.
  984. */
  985. public function serviceGetTimelinePostAllowedView($aEvent)
  986. {
  987. $CNF = &$this->_oConfig->CNF;
  988. $iOwnerId = (int)$aEvent[$CNF['FIELD_OWNER_ID']];
  989. if($iOwnerId == 0)
  990. return CHECK_ACTION_RESULT_ALLOWED;
  991. $oOwner = BxDolProfile::getInstance($iOwnerId);
  992. if(!$oOwner)
  993. return CHECK_ACTION_RESULT_ALLOWED;
  994. $sModule = $oOwner->getModule();
  995. $aOwnerInfo = BxDolService::call($sModule, 'get_info', array($oOwner->getContentId(), false));
  996. if(empty($aOwnerInfo) || !is_array($aOwnerInfo))
  997. return CHECK_ACTION_RESULT_ALLOWED;
  998. return BxDolService::call($sModule, 'check_allowed_view_for_profile', array($aOwnerInfo));
  999. }
  1000. /**
  1001. * @page service Service Calls
  1002. * @section bx_timeline Timeline
  1003. * @subsection bx_timeline-other Other
  1004. * @subsubsection bx_timeline-get_author get_author
  1005. *
  1006. * @code bx_srv('bx_timeline', 'get_author', [...]); @endcode
  1007. *
  1008. * Get author ID from content info by content ID. Is used in "Content Info Objects" system.
  1009. *
  1010. * @param $iContentId integer value with content ID.
  1011. * @return integer value with author ID.
  1012. *
  1013. * @see BxTimelineModule::serviceGetAuthor
  1014. */
  1015. /**
  1016. * @ref bx_timeline-get_author "get_author"
  1017. */
  1018. public function serviceGetAuthor ($iContentId)
  1019. {
  1020. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  1021. if(empty($aEvent) || !is_array($aEvent))
  1022. return 0;
  1023. return $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? (int)$aEvent['owner_id'] : (int)$aEvent['object_id'];
  1024. }
  1025. /**
  1026. * @page service Service Calls
  1027. * @section bx_timeline Timeline
  1028. * @subsection bx_timeline-other Other
  1029. * @subsubsection bx_timeline-get_date_changed get_date_changed
  1030. *
  1031. * @code bx_srv('bx_timeline', 'get_date_changed', [...]); @endcode
  1032. *
  1033. * Get date when the content was changed last time. Is used in "Content Info Objects" system.
  1034. * Note. In case of Timeline event 0 is returned everytime.
  1035. *
  1036. * @param $iContentId integer value with content ID.
  1037. * @return integer value with changing date.
  1038. *
  1039. * @see BxTimelineModule::serviceGetDateChanged
  1040. */
  1041. /**
  1042. * @ref bx_timeline-get_date_changed "get_date_changed"
  1043. */
  1044. public function serviceGetDateChanged ($iContentId)
  1045. {
  1046. return 0;
  1047. }
  1048. /**
  1049. * @page service Service Calls
  1050. * @section bx_timeline Timeline
  1051. * @subsection bx_timeline-other Other
  1052. * @subsubsection bx_timeline-get_link get_link
  1053. *
  1054. * @code bx_srv('bx_timeline', 'get_link', [...]); @endcode
  1055. *
  1056. * Get content view page link. Is used in "Content Info Objects" system.
  1057. *
  1058. * @param $iContentId integer value with content ID.
  1059. * @return string value with view page link.
  1060. *
  1061. * @see BxTimelineModule::serviceGetLink
  1062. */
  1063. /**
  1064. * @ref bx_timeline-get_link "get_link"
  1065. */
  1066. public function serviceGetLink ($iContentId)
  1067. {
  1068. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  1069. if(empty($aEvent) || !is_array($aEvent))
  1070. return '';
  1071. return $this->_oConfig->getItemViewUrl($aEvent);
  1072. }
  1073. /**
  1074. * @page service Service Calls
  1075. * @section bx_timeline Timeline
  1076. * @subsection bx_timeline-other Other
  1077. * @subsubsection bx_timeline-get_thumb get_thumb
  1078. *
  1079. * @code bx_srv('bx_timeline', 'get_thumb', [...]); @endcode
  1080. *
  1081. * Get content thumbnail link. Is used in "Content Info Objects" system.
  1082. * Note. In case of Timeline event an empty string is returned everytime.
  1083. *
  1084. * @param $iContentId integer value with content ID.
  1085. * @param $sTranscoder (optional) string value with transcoder name which should be applied to thumbnail image.
  1086. * @return string value with thumbnail link.
  1087. *
  1088. * @see BxTimelineModule::serviceGetThumb
  1089. */
  1090. /**
  1091. * @ref bx_timeline-get_thumb "get_thumb"
  1092. */
  1093. public function serviceGetThumb ($iContentId, $sTranscoder = '')
  1094. {
  1095. return '';
  1096. }
  1097. /**
  1098. * @page service Service Calls
  1099. * @section bx_timeline Timeline
  1100. * @subsection bx_timeline-other Other
  1101. * @subsubsection bx_timeline-get_info get_info
  1102. *
  1103. * @code bx_srv('bx_timeline', 'get_info', [...]); @endcode
  1104. *
  1105. * Get content info by content ID. Is used in "Content Info Objects" system.
  1106. *
  1107. * @param $iContentId integer value with content ID.
  1108. * @param $bSearchableFieldsOnly (optional) boolean value determining all info or "searchable fields" only will be returned.
  1109. * @return an array with content info. Empty array is returned if something is wrong.
  1110. *
  1111. * @see BxTimelineModule::serviceGetInfo
  1112. */
  1113. /**
  1114. * @ref bx_timeline-get_info "get_info"
  1115. */
  1116. public function serviceGetInfo ($iContentId, $bSearchableFieldsOnly = true)
  1117. {
  1118. $aContentInfo = $this->_oDb->getEvents(array(
  1119. 'browse' => 'id',
  1120. 'value' => $iContentId)
  1121. );
  1122. return BxDolContentInfo::formatFields($aContentInfo);
  1123. }
  1124. /**
  1125. * @page service Service Calls
  1126. * @section bx_timeline Timeline
  1127. * @subsection bx_timeline-other Other
  1128. * @subsubsection bx_timeline-get_title get_title
  1129. *
  1130. * @code bx_srv('bx_timeline', 'get_title', [...]); @endcode
  1131. *
  1132. * Get content title by content ID. Is used in "Content Info Objects" system.
  1133. *
  1134. * @param $iContentId integer value with content ID.
  1135. * @return an array with content info. Empty array is returned if something is wrong.
  1136. *
  1137. * @see BxTimelineModule::serviceGetTitle
  1138. */
  1139. /**
  1140. * @ref bx_timeline-get_title "get_title"
  1141. */
  1142. public function serviceGetTitle ($iContentId)
  1143. {
  1144. $sResult = parent::serviceGetTitle($iContentId);
  1145. if($sResult != '' && get_mb_substr($sResult, 0, 1) == '_')
  1146. $sResult = _t($sResult);
  1147. return $sResult;
  1148. }
  1149. /**
  1150. * @page service Service Calls
  1151. * @section bx_timeline Timeline
  1152. * @subsection bx_timeline-other Other
  1153. * @subsubsection bx_timeline-get_search_result_unit get_search_result_unit
  1154. *
  1155. * @code bx_srv('bx_timeline', 'get_search_result_unit', [...]); @endcode
  1156. *
  1157. * Get search result unit by content ID. Is used in "Content Info Objects" system.
  1158. *
  1159. * @param $iContentId integer value with content ID.
  1160. * @param $sUnitTemplate (optional) string value with template name.
  1161. * @return HTML string with search result unit. Empty string is returned if something is wrong.
  1162. *
  1163. * @see BxTimelineModule::serviceGetSearchResultUnit
  1164. */
  1165. /**
  1166. * @ref bx_timeline-get_search_result_unit "get_search_result_unit"
  1167. */
  1168. public function serviceGetSearchResultUnit ($iContentId, $sUnitTemplate = '')
  1169. {
  1170. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  1171. if(empty($aEvent) || !is_array($aEvent))
  1172. return '';
  1173. if(empty($sUnitTemplate))
  1174. $sUnitTemplate = 'unit.html';
  1175. return $this->_oTemplate->unit($aEvent, true, $sUnitTemplate);
  1176. }
  1177. /**
  1178. * @page service Service Calls
  1179. * @section bx_timeline Timeline
  1180. * @subsection bx_timeline-page_blocks Page Blocks
  1181. * @subsubsection bx_timeline-get_block_post get_block_post
  1182. *
  1183. * @code bx_srv('bx_timeline', 'get_block_post', [...]); @endcode
  1184. *
  1185. * Get Post block for a separate page.
  1186. *
  1187. * @param $iProfileId (optional) profile ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  1188. * @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.
  1189. *
  1190. * @see BxTimelineModule::serviceGetBlockPost
  1191. */
  1192. /**
  1193. * @ref bx_timeline-get_block_post "get_block_post"
  1194. */
  1195. public function serviceGetBlockPost($iProfileId = 0)
  1196. {
  1197. if(empty($iProfileId) && bx_get('profile_id') !== false)
  1198. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  1199. if(empty($iProfileId) && isLogged())
  1200. $iProfileId = bx_get_logged_profile_id();
  1201. if(!$iProfileId)
  1202. return array();
  1203. $sType = BX_BASE_MOD_NTFS_TYPE_OWNER;
  1204. return $this->_getBlockPost($iProfileId, array(
  1205. 'type' => $sType,
  1206. 'form_display' => $this->_oConfig->getPostFormDisplay($sType)
  1207. ));
  1208. }
  1209. /**
  1210. * @page service Service Calls
  1211. * @section bx_timeline Timeline
  1212. * @subsection bx_timeline-page_blocks Page Blocks
  1213. * @subsubsection bx_timeline-get_block_post_profile get_block_post_profile
  1214. *
  1215. * @code bx_srv('bx_timeline', 'get_block_post_profile', [...]); @endcode
  1216. *
  1217. * Get Post block for the Profile page.
  1218. *
  1219. * @param $sProfileModule (optional) string value with profile based module name. Persons module is used by default.
  1220. * @param $iProfileContentId (optional) profile's content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  1221. * @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.
  1222. *
  1223. * @see BxTimelineModule::serviceGetBlockPostProfile
  1224. */
  1225. /**
  1226. * @ref bx_timeline-get_block_post_profile "get_block_post_profile"
  1227. */
  1228. public function serviceGetBlockPostProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0)
  1229. {
  1230. if(empty($sProfileModule))
  1231. return array();
  1232. if(empty($iProfileContentId) && bx_get('id') !== false)
  1233. $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1234. $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
  1235. if(empty($oProfile))
  1236. return array();
  1237. $iProfileId = $oProfile->id();
  1238. $sType = BX_BASE_MOD_NTFS_TYPE_OWNER;
  1239. return $this->_getBlockPost($iProfileId, array(
  1240. 'type' => $sType,
  1241. 'form_display' => $this->_oConfig->getPostFormDisplay($sType)
  1242. ));
  1243. }
  1244. /**
  1245. * @page service Service Calls
  1246. * @section bx_timeline Timeline
  1247. * @subsection bx_timeline-page_blocks Page Blocks
  1248. * @subsubsection bx_timeline-get_block_post_home get_block_post_home
  1249. *
  1250. * @code bx_srv('bx_timeline', 'get_block_post_home', [...]); @endcode
  1251. *
  1252. * Get Post block for site's Home page.
  1253. *
  1254. * @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.
  1255. *
  1256. * @see BxTimelineModule::serviceGetBlockPostHome
  1257. */
  1258. /**
  1259. * @ref bx_timeline-get_block_post_home "get_block_post_home"
  1260. */
  1261. public function serviceGetBlockPostHome()
  1262. {
  1263. $iProfileId = 0;
  1264. $sType = BX_BASE_MOD_NTFS_TYPE_PUBLIC;
  1265. return $this->_getBlockPost($iProfileId, array(
  1266. 'type' => $sType,
  1267. 'form_display' => $this->_oConfig->getPostFormDisplay($sType)
  1268. ));
  1269. }
  1270. /**
  1271. * @page service Service Calls
  1272. * @section bx_timeline Timeline
  1273. * @subsection bx_timeline-page_blocks Page Blocks
  1274. * @subsubsection bx_timeline-get_block_post_account get_block_post_account
  1275. *
  1276. * @code bx_srv('bx_timeline', 'get_block_post_account', [...]); @endcode
  1277. *
  1278. * Get Post block for the Dashboard page.
  1279. *
  1280. * @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.
  1281. *
  1282. * @see BxTimelineModule::serviceGetBlockPostAccount
  1283. */
  1284. /**
  1285. * @ref bx_timeline-get_block_post_account "get_block_post_account"
  1286. */
  1287. public function serviceGetBlockPostAccount()
  1288. {
  1289. if(!isLogged())
  1290. return '';
  1291. $iProfileId = $this->getProfileId();
  1292. $sType = BX_TIMELINE_TYPE_FEED;
  1293. return $this->_getBlockPost($iProfileId, array(
  1294. 'type' => $sType,
  1295. 'form_display' => $this->_oConfig->getPostFormDisplay($sType)
  1296. ));
  1297. }
  1298. /**
  1299. * @page service Service Calls
  1300. * @section bx_timeline Timeline
  1301. * @subsection bx_timeline-page_blocks Page Blocks
  1302. * @subsubsection bx_timeline-get_block_post_custom get_block_post_custom
  1303. *
  1304. * @code bx_srv('bx_timeline', 'get_block_post_custom', [...]); @endcode
  1305. *
  1306. * Get Post block for the Custom timeline.
  1307. *
  1308. * @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.
  1309. *
  1310. * @see BxTimelineModule::serviceGetBlockPostCustom
  1311. */
  1312. /**
  1313. * @ref bx_timeline-get_block_post_custom "get_block_post_custom"
  1314. */
  1315. public function serviceGetBlockPostCustom($aParams)
  1316. {
  1317. if(!isLogged())
  1318. return '';
  1319. $iProfileId = $this->getProfileId();
  1320. if (!isset($aParams['form_display']))
  1321. $aParams['form_display'] = $this->_oConfig->getPostFormDisplay($aParams['type']);
  1322. return $this->_getBlockPost($iProfileId, $aParams);
  1323. }
  1324. /**
  1325. * @page service Service Calls
  1326. * @section bx_timeline Timeline
  1327. * @subsection bx_timeline-page_blocks Page Blocks
  1328. * @subsubsection bx_timeline-get_block_view get_block_view
  1329. *
  1330. * @code bx_srv('bx_timeline', 'get_block_view', [...]); @endcode
  1331. *
  1332. * Get Timeline View block for a separate page.
  1333. *
  1334. * @param $iProfileId (optional) profile ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  1335. * @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.
  1336. *
  1337. * @see BxTimelineModule::serviceGetBlockView
  1338. */
  1339. /**
  1340. * @ref bx_timeline-get_block_view "get_block_view"
  1341. */
  1342. public function serviceGetBlockView($iProfileId = 0)
  1343. {
  1344. return $this->_serviceGetBlockView($iProfileId, array(
  1345. 'view' => BX_TIMELINE_VIEW_TIMELINE,
  1346. 'type' => BX_BASE_MOD_NTFS_TYPE_OWNER,
  1347. 'start' => -1,
  1348. 'per_page' => -1,
  1349. 'per_page_default' => $this->_oConfig->getPerPage('profile'),
  1350. 'timeline' => -1,
  1351. 'filter' => '',
  1352. 'modules' => array()
  1353. ));
  1354. }
  1355. /**
  1356. * @page service Service Calls
  1357. * @section bx_timeline Timeline
  1358. * @subsection bx_timeline-page_blocks Page Blocks
  1359. * @subsubsection bx_timeline-get_block_view_outline get_block_view_outline
  1360. *
  1361. * @code bx_srv('bx_timeline', 'get_block_view_outline', [...]); @endcode
  1362. *
  1363. * Get Outline View block for a separate page.
  1364. *
  1365. * @param $iProfileId (optional) profile ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  1366. * @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.
  1367. *
  1368. * @see BxTimelineModule::serviceGetBlockViewOutline
  1369. */
  1370. /**
  1371. * @ref bx_timeline-get_block_view_outline "get_block_view_outline"
  1372. */
  1373. public function serviceGetBlockViewOutline($iProfileId = 0)
  1374. {
  1375. return $this->_serviceGetBlockView($iProfileId, array(
  1376. 'view' => BX_TIMELINE_VIEW_OUTLINE,
  1377. 'type' => BX_BASE_MOD_NTFS_TYPE_OWNER,
  1378. 'start' => -1,
  1379. 'per_page' => -1,
  1380. 'per_page_default' => $this->_oConfig->getPerPage('profile'),
  1381. 'timeline' => -1,
  1382. 'filter' => '',
  1383. 'modules' => array()
  1384. ));
  1385. }
  1386. /**
  1387. * @page service Service Calls
  1388. * @section bx_timeline Timeline
  1389. * @subsection bx_timeline-page_blocks Page Blocks
  1390. * @subsubsection bx_timeline-get_block_view_profile get_block_view_profile
  1391. *
  1392. * @code bx_srv('bx_timeline', 'get_block_view_profile', [...]); @endcode
  1393. *
  1394. * Get Timeline View block for the Profile page.
  1395. *
  1396. * @param $sProfileModule (optional) string value with profile based module name. Persons module is used by default.
  1397. * @param $iProfileContentId (optional) profile's content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  1398. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  1399. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  1400. * @param $sFilter (optional) string value with filter name.
  1401. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  1402. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  1403. * @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.
  1404. *
  1405. * @see BxTimelineModule::serviceGetBlockViewProfile
  1406. */
  1407. /**
  1408. * @ref bx_timeline-get_block_view_profile "get_block_view_profile"
  1409. */
  1410. public function serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  1411. {
  1412. return $this->_serviceGetBlockViewProfile($sProfileModule, $iProfileContentId, array(
  1413. 'view' => BX_TIMELINE_VIEW_TIMELINE,
  1414. 'type' => BX_BASE_MOD_NTFS_TYPE_OWNER,
  1415. 'start' => $iStart,
  1416. 'per_page' => $iPerPage,
  1417. 'per_page_default' => $this->_oConfig->getPerPage('profile'),
  1418. 'timeline' => $iTimeline,
  1419. 'filter' => $sFilter,
  1420. 'modules' => $aModules
  1421. ));
  1422. }
  1423. /**
  1424. * @page service Service Calls
  1425. * @section bx_timeline Timeline
  1426. * @subsection bx_timeline-page_blocks Page Blocks
  1427. * @subsubsection bx_timeline-get_block_view_profile_outline get_block_view_profile_outline
  1428. *
  1429. * @code bx_srv('bx_timeline', 'get_block_view_profile_outline', [...]); @endcode
  1430. *
  1431. * Get Outline View block for the Profile page.
  1432. *
  1433. * @param $sProfileModule (optional) string value with profile based module name. Persons module is used by default.
  1434. * @param $iProfileContentId (optional) profile's content ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  1435. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  1436. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  1437. * @param $sFilter (optional) string value with filter name.
  1438. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  1439. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  1440. * @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.
  1441. *
  1442. * @see BxTimelineModule::serviceGetBlockViewProfileOutline
  1443. */
  1444. /**
  1445. * @ref bx_timeline-get_block_view_profile_outline "get_block_view_profile_outline"
  1446. */
  1447. public function serviceGetBlockViewProfileOutline($sProfileModule = 'bx_persons', $iProfileContentId = 0, $iStart = -1, $iPerPage = -1, $sFilter = '', $aModules = array(), $iTimeline = -1)
  1448. {
  1449. return $this->_serviceGetBlockViewProfile($sProfileModule, $iProfileContentId, array(
  1450. 'view' => BX_TIMELINE_VIEW_OUTLINE,
  1451. 'type' => BX_BASE_MOD_NTFS_TYPE_OWNER,
  1452. 'start' => $iStart,
  1453. 'per_page' => $iPerPage,
  1454. 'per_page_default' => $this->_oConfig->getPerPage('profile'),
  1455. 'timeline' => $iTimeline,
  1456. 'filter' => $sFilter,
  1457. 'modules' => $aModules
  1458. ));
  1459. }
  1460. public function serviceGetBlockViewsCustom($aParams = array())
  1461. {
  1462. $aParams = array_merge(array(
  1463. 'view' => BX_TIMELINE_VIEW_TIMELINE,
  1464. 'type' => BX_BASE_MOD_NTFS_TYPE_PUBLIC,
  1465. 'owner_id' => 0,
  1466. ), $aParams);
  1467. return $this->_serviceGetBlockViews($aParams);
  1468. }
  1469. public function serviceGetBlockViewsTimeline($sType = BX_BASE_MOD_NTFS_TYPE_PUBLIC, $iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  1470. {
  1471. return $this->_serviceGetBlockViews(array(
  1472. 'view' => BX_TIMELINE_VIEW_TIMELINE,
  1473. 'type' => $sType,
  1474. 'owner_id' => $iProfileId,
  1475. 'start' => $iStart,
  1476. 'per_page' => $iPerPage,
  1477. 'per_page_default' => $this->_oConfig->getPerPage(),
  1478. 'timeline' => $iTimeline,
  1479. 'filter' => $sFilter,
  1480. 'modules' => $aModules
  1481. ));
  1482. }
  1483. public function serviceGetBlockViewsOutline($sType = BX_BASE_MOD_NTFS_TYPE_PUBLIC, $iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  1484. {
  1485. return $this->_serviceGetBlockViews(array(
  1486. 'view' => BX_TIMELINE_VIEW_OUTLINE,
  1487. 'type' => $sType,
  1488. 'owner_id' => $iProfileId,
  1489. 'start' => $iStart,
  1490. 'per_page' => $iPerPage,
  1491. 'per_page_default' => $this->_oConfig->getPerPage(),
  1492. 'timeline' => $iTimeline,
  1493. 'filter' => $sFilter,
  1494. 'modules' => $aModules
  1495. ));
  1496. }
  1497. /**
  1498. * @page service Service Calls
  1499. * @section bx_timeline Timeline
  1500. * @subsection bx_timeline-page_blocks Page Blocks
  1501. * @subsubsection bx_timeline-get_block_view_home get_block_view_home
  1502. *
  1503. * @code bx_srv('bx_timeline', 'get_block_view_home', [...]); @endcode
  1504. *
  1505. * Get Timeline View block for site's Home page.
  1506. *
  1507. * @param $iProfileId (optional) profile ID. 0 should be used here.
  1508. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  1509. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  1510. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  1511. * @param $sFilter (optional) string value with filter name.
  1512. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  1513. * @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.
  1514. *
  1515. * @see BxTimelineModule::serviceGetBlockViewHome
  1516. */
  1517. /**
  1518. * @ref bx_timeline-get_block_view_home "get_block_view_home"
  1519. */
  1520. public function serviceGetBlockViewHome($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  1521. {
  1522. return $this->_serviceGetBlockViewHome(array(
  1523. 'view' => BX_TIMELINE_VIEW_TIMELINE,
  1524. 'type' => BX_BASE_MOD_NTFS_TYPE_PUBLIC,
  1525. 'owner_id' => $iProfileId,
  1526. 'start' => $iStart,
  1527. 'per_page' => $iPerPage,
  1528. 'per_page_default' => $this->_oConfig->getPerPage('home'),
  1529. 'timeline' => $iTimeline,
  1530. 'filter' => $sFilter,
  1531. 'modules' => $aModules
  1532. ));
  1533. }
  1534. /**
  1535. * @page service Service Calls
  1536. * @section bx_timeline Timeline
  1537. * @subsection bx_timeline-page_blocks Page Blocks
  1538. * @subsubsection bx_timeline-get_block_view_home_outline get_block_view_home_outline
  1539. *
  1540. * @code bx_srv('bx_timeline', 'get_block_view_home_outline', [...]); @endcode
  1541. *
  1542. * Get Outline View block for site's Home page.
  1543. *
  1544. * @param $iProfileId (optional) profile ID. 0 should be used here.
  1545. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  1546. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  1547. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  1548. * @param $sFilter (optional) string value with filter name.
  1549. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  1550. * @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.
  1551. *
  1552. * @see BxTimelineModule::serviceGetBlockViewHomeOutline
  1553. */
  1554. /**
  1555. * @ref bx_timeline-get_block_view_home_outline "get_block_view_home_outline"
  1556. */
  1557. public function serviceGetBlockViewHomeOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  1558. {
  1559. return $this->_serviceGetBlockViewHome(array(
  1560. 'view' => BX_TIMELINE_VIEW_OUTLINE,
  1561. 'type' => BX_BASE_MOD_NTFS_TYPE_PUBLIC,
  1562. 'owner_id' => $iProfileId,
  1563. 'start' => $iStart,
  1564. 'per_page' => $iPerPage,
  1565. 'per_page_default' => $this->_oConfig->getPerPage('home'),
  1566. 'timeline' => $iTimeline,
  1567. 'filter' => $sFilter,
  1568. 'modules' => $aModules
  1569. ));
  1570. }
  1571. /**
  1572. * @page service Service Calls
  1573. * @section bx_timeline Timeline
  1574. * @subsection bx_timeline-page_blocks Page Blocks
  1575. * @subsubsection bx_timeline-get_block_view_hot get_block_view_hot
  1576. *
  1577. * @code bx_srv('bx_timeline', 'get_block_view_hot', [...]); @endcode
  1578. *
  1579. * Get Timeline View block with Hot public events.
  1580. *
  1581. * @param $iProfileId (optional) profile ID. 0 should be used here.
  1582. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  1583. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  1584. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  1585. * @param $sFilter (optional) string value with filter name.
  1586. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  1587. * @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.
  1588. *
  1589. * @see BxTimelineModule::serviceGetBlockViewHot
  1590. */
  1591. /**
  1592. * @ref bx_timeline-get_block_view_hot "get_block_view_hot"
  1593. */
  1594. public function serviceGetBlockViewHot($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  1595. {
  1596. return $this->_serviceGetBlockViewHot(array(
  1597. 'view' => BX_TIMELINE_VIEW_TIMELINE,
  1598. 'type' => BX_TIMELINE_TYPE_HOT,
  1599. 'owner_id' => $iProfileId,
  1600. 'start' => $iStart,
  1601. 'per_page' => $iPerPage,
  1602. 'per_page_default' => $this->_oConfig->getPerPage('home'),
  1603. 'timeline' => $iTimeline,
  1604. 'filter' => $sFilter,
  1605. 'modules' => $aModules
  1606. ));
  1607. }
  1608. /**
  1609. * @page service Service Calls
  1610. * @section bx_timeline Timeline
  1611. * @subsection bx_timeline-page_blocks Page Blocks
  1612. * @subsubsection bx_timeline-get_block_view_hot_outline get_block_view_hot_outline
  1613. *
  1614. * @code bx_srv('bx_timeline', 'get_block_view_hot_outline', [...]); @endcode
  1615. *
  1616. * Get Outline View block with Hot public events.
  1617. *
  1618. * @param $iProfileId (optional) profile ID. 0 should be used here.
  1619. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  1620. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  1621. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  1622. * @param $sFilter (optional) string value with filter name.
  1623. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  1624. * @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.
  1625. *
  1626. * @see BxTimelineModule::serviceGetBlockViewHotOutline
  1627. */
  1628. /**
  1629. * @ref bx_timeline-get_block_view_hot_outline "get_block_view_hot_outline"
  1630. */
  1631. public function serviceGetBlockViewHotOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  1632. {
  1633. return $this->_serviceGetBlockViewHot(array(
  1634. 'view' => BX_TIMELINE_VIEW_OUTLINE,
  1635. 'type' => BX_TIMELINE_TYPE_HOT,
  1636. 'owner_id' => $iProfileId,
  1637. 'start' => $iStart,
  1638. 'per_page' => $iPerPage,
  1639. 'per_page_default' => $this->_oConfig->getPerPage('home'),
  1640. 'timeline' => $iTimeline,
  1641. 'filter' => $sFilter,
  1642. 'modules' => $aModules
  1643. ));
  1644. }
  1645. /**
  1646. * @page service Service Calls
  1647. * @section bx_timeline Timeline
  1648. * @subsection bx_timeline-page_blocks Page Blocks
  1649. * @subsubsection bx_timeline-get_block_view_account get_block_view_account
  1650. *
  1651. * @code bx_srv('bx_timeline', 'get_block_view_account', [...]); @endcode
  1652. *
  1653. * Get Timeline View block for the Dashboard page.
  1654. *
  1655. * @param $iProfileId (optional) profile ID. 0 should be used here.
  1656. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  1657. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  1658. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  1659. * @param $sFilter (optional) string value with filter name.
  1660. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  1661. * @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.
  1662. *
  1663. * @see BxTimelineModule::serviceGetBlockViewAccount
  1664. */
  1665. /**
  1666. * @ref bx_timeline-get_block_view_account "get_block_view_account"
  1667. */
  1668. public function serviceGetBlockViewAccount($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  1669. {
  1670. if(!isLogged())
  1671. return '';
  1672. return $this->_serviceGetBlockViewByType(array(
  1673. 'view' => BX_TIMELINE_VIEW_TIMELINE,
  1674. 'type' => BX_TIMELINE_TYPE_FEED,
  1675. 'owner_id' => $iProfileId,
  1676. 'start' => $iStart,
  1677. 'per_page' => $iPerPage,
  1678. 'per_page_default' => $this->_oConfig->getPerPage('account'),
  1679. 'timeline' => $iTimeline,
  1680. 'filter' => $sFilter,
  1681. 'modules' => $aModules
  1682. ));
  1683. }
  1684. /**
  1685. * @page service Service Calls
  1686. * @section bx_timeline Timeline
  1687. * @subsection bx_timeline-page_blocks Page Blocks
  1688. * @subsubsection bx_timeline-get_block_view_account_outline get_block_view_account_outline
  1689. *
  1690. * @code bx_srv('bx_timeline', 'get_block_view_account_outline', [...]); @endcode
  1691. *
  1692. * Get Outline View block for the Dashboard page.
  1693. *
  1694. * @param $iProfileId (optional) profile ID. 0 should be used here.
  1695. * @param $iStart (optional) integer value with a page number. Is used in pagination.
  1696. * @param $iPerPage (optional) integer value with a number of items per page. Is used in pagination.
  1697. * @param $iTimeline (optional) integer value determining whether the timeline should be displayed or not.
  1698. * @param $sFilter (optional) string value with filter name.
  1699. * @param $aModules (optional) an array of modules from which the events should be displayed. All available modules are used by default.
  1700. * @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.
  1701. *
  1702. * @see BxTimelineModule::serviceGetBlockViewAccountOutline
  1703. */
  1704. /**
  1705. * @ref bx_timeline-get_block_view_account_outline "get_block_view_account_outline"
  1706. */
  1707. public function serviceGetBlockViewAccountOutline($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
  1708. {
  1709. if(!isLogged())
  1710. return '';
  1711. return $this->_serviceGetBlockViewByType(array(
  1712. 'view' => BX_TIMELINE_VIEW_OUTLINE,
  1713. 'type' => BX_TIMELINE_TYPE_FEED,
  1714. 'owner_id' => $iProfileId,
  1715. 'start' => $iStart,
  1716. 'per_page' => $iPerPage,
  1717. 'per_page_default' => $this->_oConfig->getPerPage('account'),
  1718. 'timeline' => $iTimeline,
  1719. 'filter' => $sFilter,
  1720. 'modules' => $aModules
  1721. ));
  1722. }
  1723. /**
  1724. * @page service Service Calls
  1725. * @section bx_timeline Timeline
  1726. * @subsection bx_timeline-page_blocks Page Blocks
  1727. * @subsubsection bx_timeline-get_block_view_custom get_block_view_custom
  1728. *
  1729. * @code bx_srv('bx_timeline', 'get_block_view_custom', [...]); @endcode
  1730. *
  1731. * Get custom Timeline View block.
  1732. *
  1733. * @param $aParams (optional) an array with block parameneters.
  1734. * @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.
  1735. *
  1736. * @see BxTimelineModule::serviceGetBlockViewCustom
  1737. */
  1738. /**
  1739. * @ref bx_timeline-get_block_view_custom "get_block_view_custom"
  1740. */
  1741. public function serviceGetBlockViewCustom($aParams = array())
  1742. {
  1743. return $this->_serviceGetBlockViewByType($aParams);
  1744. }
  1745. public function serviceGetBlockMenuDb($aParams = array())
  1746. {
  1747. $aParams = $this->_prepareParams(array_merge([
  1748. 'name' => BX_TIMELINE_NAME_VIEWS_DB,
  1749. 'view' => BX_TIMELINE_VIEW_TIMELINE,
  1750. 'type' => BX_TIMELINE_TYPE_FEED,
  1751. 'owner_id' => $this->getProfileId()
  1752. ], $aParams));
  1753. if(($sType = $this->_oConfig->getUserChoice('type')) !== false)
  1754. $aParams['type'] = $sType;
  1755. $sMenu = $this->_oConfig->getObject('menu_feeds');
  1756. if(isset($aParams['menu_feeds'])) {
  1757. $sMenu = $aParams['menu_feeds'];
  1758. unset($aParams['menu_feeds']);
  1759. }
  1760. $oMenu = BxDolMenu::getObjectInstance($sMenu);
  1761. if(!$oMenu)
  1762. return '';
  1763. $sSelectedModule = $this->getName();
  1764. $sSelectedName = $aParams['type'];
  1765. if(($aModule = $this->_oDb->getModuleByName($aParams['type']))) {
  1766. $sSelectedModule = $aModule['name'];
  1767. $sSelectedName = $aModule['uri'];
  1768. }
  1769. $oMenu->setSelected($sSelectedModule, $sSelectedName);
  1770. $oMenu->setBrowseParams($aParams);
  1771. return $oMenu->getCode();
  1772. }
  1773. public function serviceGetBlockViewsDb($aParams = [])
  1774. {
  1775. if(!isset($aParams['viewer_id']))
  1776. $aParams['viewer_id'] = $this->getUserId();
  1777. if(!isset($aParams['owner_id']))
  1778. $aParams['owner_id'] = $this->getUserId();
  1779. if(!isset($aParams['type']) && ($sType = $this->_oConfig->getUserChoice('type', $aParams['viewer_id'])) !== false)
  1780. $aParams['type'] = $sType;
  1781. $aParams = $this->_prepareParams(array_merge([
  1782. 'name' => BX_TIMELINE_NAME_VIEWS_DB,
  1783. 'view' => BX_TIMELINE_VIEW_TIMELINE,
  1784. 'type' => BX_TIMELINE_TYPE_FEED,
  1785. ], $aParams));
  1786. $this->_iOwnerId = $aParams['owner_id'];
  1787. return $this->_oTemplate->getViewsDbBlock($aParams);
  1788. }
  1789. /**
  1790. * @page service Service Calls
  1791. * @section bx_timeline Timeline
  1792. * @subsection bx_timeline-page_blocks Page Blocks
  1793. * @subsubsection bx_timeline-get_block_item get_block_item
  1794. *
  1795. * @code bx_srv('bx_timeline', 'get_block_item', [...]); @endcode
  1796. *
  1797. * Get View Item block.
  1798. *
  1799. * @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.
  1800. *
  1801. * @see BxTimelineModule::serviceGetBlockItem
  1802. */
  1803. /**
  1804. * @ref bx_timeline-get_block_item "get_block_item"
  1805. */
  1806. public function serviceGetBlockItem()
  1807. {
  1808. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1809. if(!$iItemId)
  1810. return array();
  1811. $aParams = $this->_prepareParams(array(
  1812. 'view' => BX_TIMELINE_VIEW_ITEM,
  1813. 'type' => BX_TIMELINE_TYPE_ITEM
  1814. ));
  1815. $aItemData = $this->getItemData($iItemId, $aParams);
  1816. return $this->_oTemplate->getItemBlock($aItemData, $aParams);
  1817. }
  1818. public function serviceGetBlockItemContent()
  1819. {
  1820. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1821. $sMode = bx_process_input(bx_get('mode'));
  1822. if(!$iItemId || !$sMode)
  1823. return '';
  1824. return $this->_oTemplate->getItemBlockContent($iItemId, $sMode);
  1825. }
  1826. public function serviceGetBlockItemInfo()
  1827. {
  1828. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1829. if(!$iItemId)
  1830. return '';
  1831. return $this->_oTemplate->getItemBlockInfo($iItemId);
  1832. }
  1833. public function serviceGetBlockItemComments()
  1834. {
  1835. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1836. if(!$iItemId)
  1837. return '';
  1838. return $this->_oTemplate->getItemBlockComments($iItemId);
  1839. }
  1840. public function serviceGetBlockMuted($iProfileId = 0)
  1841. {
  1842. if(!isLogged())
  1843. return MsgBox(_t('_Access denied'));
  1844. if($iProfileId == 0)
  1845. $iProfileId = $this->_iProfileId;
  1846. $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->getObject('grid_mute'));
  1847. if(!$oGrid)
  1848. return MsgBox('_Empty');
  1849. $oGrid->setProfile($iProfileId);
  1850. return $oGrid->getCode();
  1851. }
  1852. public function serviceGetPost($mixedEvent, $aParams = array())
  1853. {
  1854. if(!empty($mixedEvent) && !is_array($mixedEvent))
  1855. $mixedEvent = $this->_oDb->getContentInfoById((int)$mixedEvent);
  1856. if(empty($mixedEvent) || !is_array($mixedEvent))
  1857. return '';
  1858. $aParams = $this->_prepareParams(array_merge(array(
  1859. 'view' => BX_TIMELINE_VIEW_ITEM,
  1860. 'type' => BX_TIMELINE_TYPE_ITEM
  1861. ), $aParams));
  1862. return $this->_oTemplate->getPost($mixedEvent, $aParams);
  1863. }
  1864. public function serviceGetTimelineRepostAllowedView($aEvent)
  1865. {
  1866. return isset($aEvent['content']['allowed_view']) ? $aEvent['content']['allowed_view'] : CHECK_ACTION_RESULT_ALLOWED;
  1867. }
  1868. /**
  1869. * @page service Service Calls
  1870. * @section bx_timeline Timeline
  1871. * @subsection bx_timeline-integration_notifications Integration with Notifications
  1872. * @subsubsection bx_timeline-get_notifications_data get_notifications_data
  1873. *
  1874. * @code bx_srv('bx_timeline', 'get_notifications_data', [...]); @endcode
  1875. *
  1876. * Data for Notifications module.
  1877. *
  1878. * @return an array with special format.
  1879. *
  1880. * @see BxTimelineModule::serviceGetNotificationsData
  1881. */
  1882. /**
  1883. * @ref bx_timeline-get_notifications_data "get_notifications_data"
  1884. */
  1885. public function serviceGetNotificationsData()
  1886. {
  1887. $sModule = $this->_aModule['name'];
  1888. return array(
  1889. 'handlers' => array(
  1890. array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'post_common', 'module_name' => $sModule, 'module_method' => 'get_notifications_post', 'module_class' => 'Module'),
  1891. array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete'),
  1892. array('group' => $sModule . '_object_publish_failed', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'publish_failed', 'module_name' => $sModule, 'module_method' => 'get_notifications_post_publish_failed', 'module_class' => 'Module'),
  1893. array('group' => $sModule . '_object_publish_succeeded', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'publish_succeeded', 'module_name' => $sModule, 'module_method' => 'get_notifications_post_publish_succeeded', 'module_class' => 'Module'),
  1894. array('group' => $sModule . '_repost', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'repost', 'module_name' => $sModule, 'module_method' => 'get_notifications_repost', 'module_class' => 'Module'),
  1895. array('group' => $sModule . '_repost', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete_repost'),
  1896. array('group' => $sModule . '_comment', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'commentPost', 'module_name' => $sModule, 'module_method' => 'get_notifications_comment', 'module_class' => 'Module'),
  1897. array('group' => $sModule . '_comment', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'commentRemoved'),
  1898. array('group' => $sModule . '_reply', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'replyPost', 'module_name' => $sModule, 'module_method' => 'get_notifications_reply', 'module_class' => 'Module'),
  1899. array('group' => $sModule . '_reply', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'replyRemoved'),
  1900. array('group' => $sModule . '_vote', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_vote', 'module_class' => 'Module'),
  1901. array('group' => $sModule . '_vote', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'undoVote'),
  1902. array('group' => $sModule . '_reaction', 'type' => 'insert', 'alert_unit' => $sModule . '_reactions', 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_reaction', 'module_class' => 'Module'),
  1903. array('group' => $sModule . '_reaction', 'type' => 'delete', 'alert_unit' => $sModule . '_reactions', 'alert_action' => 'undoVote'),
  1904. array('group' => $sModule . '_score_up', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVoteUp', 'module_name' => $sModule, 'module_method' => 'get_notifications_score_up', 'module_class' => 'Module'),
  1905. array('group' => $sModule . '_score_down', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVoteDown', 'module_name' => $sModule, 'module_method' => 'get_notifications_score_down', 'module_class' => 'Module'),
  1906. ),
  1907. 'settings' => array(
  1908. array('group' => 'content', 'unit' => $sModule, 'action' => 'post_common', 'types' => array('personal', 'follow_member', 'follow_context')),
  1909. array('group' => 'content', 'unit' => $sModule, 'action' => 'publish_failed', 'types' => array('personal')),
  1910. array('group' => 'content', 'unit' => $sModule, 'action' => 'publish_succeeded', 'types' => array('personal')),
  1911. array('group' => 'content', 'unit' => $sModule, 'action' => 'repost', 'types' => array('personal', 'follow_member', 'follow_context')),
  1912. array('group' => 'comment', 'unit' => $sModule, 'action' => 'commentPost', 'types' => array('personal', 'follow_member', 'follow_context')),
  1913. array('group' => 'reply', 'unit' => $sModule, 'action' => 'replyPost', 'types' => array('personal')),
  1914. array('group' => 'vote', 'unit' => $sModule, 'action' => 'doVote', 'types' => array('personal', 'follow_member', 'follow_context')),
  1915. array('group' => 'vote', 'unit' => $sModule . '_reactions', 'action' => 'doVote', 'types' => array('personal', 'follow_member', 'follow_context')),
  1916. array('group' => 'score_up', 'unit' => $sModule, 'action' => 'doVoteUp', 'types' => array('personal', 'follow_member', 'follow_context')),
  1917. array('group' => 'score_down', 'unit' => $sModule, 'action' => 'doVoteDown', 'types' => array('personal', 'follow_member', 'follow_context'))
  1918. ),
  1919. 'alerts' => array(
  1920. array('unit' => $sModule, 'action' => 'post_common'),
  1921. array('unit' => $sModule, 'action' => 'publish_failed'),
  1922. array('unit' => $sModule, 'action' => 'publish_succeeded'),
  1923. array('unit' => $sModule, 'action' => 'delete'),
  1924. array('unit' => $sModule, 'action' => 'repost'),
  1925. array('unit' => $sModule, 'action' => 'delete_repost'),
  1926. array('unit' => $sModule, 'action' => 'commentPost'),
  1927. array('unit' => $sModule, 'action' => 'commentRemoved'),
  1928. array('unit' => $sModule, 'action' => 'replyPost'),
  1929. array('unit' => $sModule, 'action' => 'replyRemoved'),
  1930. array('unit' => $sModule, 'action' => 'doVote'),
  1931. array('unit' => $sModule, 'action' => 'undoVote'),
  1932. array('unit' => $sModule . '_reactions', 'action' => 'doVote'),
  1933. array('unit' => $sModule . '_reactions', 'action' => 'undoVote'),
  1934. array('unit' => $sModule, 'action' => 'doVoteUp'),
  1935. array('unit' => $sModule, 'action' => 'doVoteDown'),
  1936. )
  1937. );
  1938. }
  1939. /**
  1940. * @page service Service Calls
  1941. * @section bx_timeline Timeline
  1942. * @subsection bx_timeline-integration_notifications Integration with Notifications
  1943. * @subsubsection bx_timeline-get_notifications_repost get_notifications_repost
  1944. *
  1945. * @code bx_srv('bx_timeline', 'get_notifications_repost', [...]); @endcode
  1946. *
  1947. * Get data for Repost event to display in Notifications module.
  1948. *
  1949. * @param $aEvent an array with event description.
  1950. * @return an array with special format.
  1951. *
  1952. * @see BxTimelineModule::serviceGetNotificationsRepost
  1953. */
  1954. /**
  1955. * @ref bx_timeline-get_notifications_repost "get_notifications_repost"
  1956. */
  1957. public function serviceGetNotificationsRepost($aEvent)
  1958. {
  1959. $aResult = $this->serviceGetNotificationsPost($aEvent);
  1960. $aResult['lang_key'] = '_bx_timeline_txt_object_reposted';
  1961. return $aResult;
  1962. }
  1963. /**
  1964. * @page service Service Calls
  1965. * @section bx_timeline Timeline
  1966. * @subsection bx_timeline-integration_notifications Integration with Notifications
  1967. * @subsubsection bx_timeline-get_notifications_post get_notifications_post
  1968. *
  1969. * @code bx_srv('bx_timeline', 'get_notifications_post', [...]); @endcode
  1970. *
  1971. * Get data for Post event to display in Notifications module.
  1972. *
  1973. * @param $aEvent an array with event description.
  1974. * @return an array with special format.
  1975. *
  1976. * @see BxTimelineModule::serviceGetNotificationsPost
  1977. */
  1978. /**
  1979. * @ref bx_timeline-get_notifications_post "get_notifications_post"
  1980. */
  1981. public function serviceGetNotificationsPost($aEvent)
  1982. {
  1983. $CNF = &$this->_oConfig->CNF;
  1984. $iContent = (int)$aEvent['object_id'];
  1985. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  1986. if(empty($aContent) || !is_array($aContent))
  1987. return array();
  1988. if($this->_oConfig->isSystem($aContent['type'], $aContent['action']))
  1989. $iEntryAuthor = (int)$aContent['owner_id'];
  1990. else
  1991. $iEntryAuthor = (int)$aContent['object_id'];
  1992. $sEntryCaption = call_user_func_array(array($this->_oConfig, 'getTitleShort'), !empty($aContent['title']) ? array($aContent['title']) : array($aContent['description'], $aContent['object_id']));
  1993. return array(
  1994. 'entry_sample' => $CNF['T']['txt_sample_single_ext'],
  1995. 'entry_url' => bx_absolute_url($this->_oConfig->getItemViewUrl($aContent, false), '{bx_url_root}'),
  1996. 'entry_caption' => $sEntryCaption,
  1997. 'entry_author' => $iEntryAuthor,
  1998. 'lang_key' => '' //may be empty or not specified. In this case the default one from Notification module will be used.
  1999. );
  2000. }
  2001. /**
  2002. * @page service Service Calls
  2003. * @section bx_timeline Timeline
  2004. * @subsection bx_timeline-integration_notifications Integration with Notifications
  2005. * @subsubsection bx_timeline-get_notifications_comment get_notifications_comment
  2006. *
  2007. * @code bx_srv('bx_timeline', 'get_notifications_comment', [...]); @endcode
  2008. *
  2009. * Get data for Post Comment event to display in Notifications module.
  2010. *
  2011. * @param $aEvent an array with event description.
  2012. * @return an array with special format.
  2013. *
  2014. * @see BxTimelineModule::serviceGetNotificationsComment
  2015. */
  2016. /**
  2017. * @ref bx_timeline-get_notifications_comment "get_notifications_comment"
  2018. */
  2019. public function serviceGetNotificationsComment($aEvent)
  2020. {
  2021. $CNF = &$this->_oConfig->CNF;
  2022. $iContent = (int)$aEvent['object_id'];
  2023. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  2024. if(empty($aContent) || !is_array($aContent))
  2025. return array();
  2026. $oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContent);
  2027. if(!$oComment || !$oComment->isEnabled())
  2028. return array();
  2029. $sEntryCaption = call_user_func_array(array($this->_oConfig, 'getTitleShort'), !empty($aContent['title']) ? array($aContent['title']) : array($aContent['description'], $aContent['object_id']));
  2030. return array(
  2031. 'entry_sample' => $CNF['T']['txt_sample_single'],
  2032. 'entry_url' => bx_absolute_url($this->_oConfig->getItemViewUrl($aContent, false), '{bx_url_root}'),
  2033. 'entry_caption' => $sEntryCaption,
  2034. 'entry_author' => $aContent['owner_id'],
  2035. 'subentry_sample' => $CNF['T']['txt_sample_comment_single'],
  2036. 'subentry_url' => bx_absolute_url($oComment->getViewUrl((int)$aEvent['subobject_id'], false), '{bx_url_root}'),
  2037. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  2038. );
  2039. }
  2040. /**
  2041. * @page service Service Calls
  2042. * @section bx_timeline Timeline
  2043. * @subsection bx_timeline-integration_notifications Integration with Notifications
  2044. * @subsubsection bx_timeline-get_notifications_reply get_notifications_reply
  2045. *
  2046. * @code bx_srv('bx_timeline', 'get_notifications_reply', [...]); @endcode
  2047. *
  2048. * Get data for Reply to Comment event to display in Notifications module.
  2049. *
  2050. * @param $aEvent an array with event description.
  2051. * @return an array with special format.
  2052. *
  2053. * @see BxTimelineModule::serviceGetNotificationsReply
  2054. */
  2055. /**
  2056. * @ref bx_timeline-get_notifications_reply "get_notifications_reply"
  2057. */
  2058. public function serviceGetNotificationsReply($aEvent)
  2059. {
  2060. $CNF = &$this->_oConfig->CNF;
  2061. $oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], 0, false);
  2062. if(!$oComment || !$oComment->isEnabled())
  2063. return array();
  2064. $iParentId = (int)$aEvent['object_id'];
  2065. $aParentInfo = $oComment->getQueryObject()->getCommentsBy(array('type' => 'id', 'id' => $iParentId));
  2066. if(empty($aParentInfo) || !is_array($aParentInfo))
  2067. return array();
  2068. $iObjectId = (int)$aParentInfo['cmt_object_id'];
  2069. $oComment->init($iObjectId);
  2070. return array(
  2071. 'object_id' => $iObjectId,
  2072. 'entry_sample' => '_cmt_txt_sample_comment_single',
  2073. 'entry_url' => bx_absolute_url($oComment->getViewUrl($iParentId, false), '{bx_url_root}'),
  2074. 'entry_caption' => strmaxtextlen($aParentInfo['cmt_text'], 20, '...'),
  2075. 'entry_author' => (int)$aParentInfo['cmt_author_id'],
  2076. 'subentry_sample' => '_cmt_txt_sample_reply_to',
  2077. 'subentry_url' => bx_absolute_url($oComment->getViewUrl((int)$aEvent['subobject_id'], false), '{bx_url_root}'),
  2078. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  2079. );
  2080. }
  2081. /**
  2082. * @page service Service Calls
  2083. * @section bx_timeline Timeline
  2084. * @subsection bx_timeline-integration_notifications Integration with Notifications
  2085. * @subsubsection bx_timeline-get_notifications_vote get_notifications_vote
  2086. *
  2087. * @code bx_srv('bx_timeline', 'get_notifications_vote', [...]); @endcode
  2088. *
  2089. * Get data for Vote event to display in Notifications module.
  2090. *
  2091. * @param $aEvent an array with event description.
  2092. * @return an array with special format.
  2093. *
  2094. * @see BxTimelineModule::serviceGetNotificationsVote
  2095. */
  2096. /**
  2097. * @ref bx_timeline-get_notifications_vote "get_notifications_vote"
  2098. */
  2099. public function serviceGetNotificationsVote($aEvent)
  2100. {
  2101. $CNF = &$this->_oConfig->CNF;
  2102. $iContent = (int)$aEvent['object_id'];
  2103. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  2104. if(empty($aContent) || !is_array($aContent))
  2105. return array();
  2106. $oVote = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContent);
  2107. if(!$oVote || !$oVote->isEnabled())
  2108. return array();
  2109. $sEntryCaption = call_user_func_array(array($this->_oConfig, 'getTitleShort'), !empty($aContent['title']) ? array($aContent['title']) : array($aContent['description'], $aContent['object_id']));
  2110. return array(
  2111. 'entry_sample' => $CNF['T']['txt_sample_single'],
  2112. 'entry_url' => bx_absolute_url($this->_oConfig->getItemViewUrl($aContent, false), '{bx_url_root}'),
  2113. 'entry_caption' => $sEntryCaption,
  2114. 'entry_author' => $aContent['owner_id'],
  2115. 'subentry_sample' => $CNF['T']['txt_sample_vote_single'],
  2116. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  2117. );
  2118. }
  2119. /**
  2120. * Entry post vote for Notifications module
  2121. */
  2122. public function serviceGetNotificationsReaction($aEvent)
  2123. {
  2124. $CNF = &$this->_oConfig->CNF;
  2125. $iContent = (int)$aEvent['object_id'];
  2126. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  2127. if(empty($aContent) || !is_array($aContent))
  2128. return array();
  2129. $oReaction = BxDolVote::getObjectInstance($CNF['OBJECT_REACTIONS'], $iContent);
  2130. if(!$oReaction || !$oReaction->isEnabled())
  2131. return array();
  2132. $aSubentry = $oReaction->getTrackBy(array('type' => 'id', 'id' => (int)$aEvent['subobject_id']));
  2133. if(empty($aSubentry) || !is_array($aSubentry))
  2134. return array();
  2135. $aSubentrySampleParams = array();
  2136. $aReaction = $oReaction->getReaction($aSubentry['reaction']);
  2137. if(!empty($aReaction['title']))
  2138. $aSubentrySampleParams[] = $aReaction['title'];
  2139. else
  2140. $aSubentrySampleParams[] = '_undefined';
  2141. $sEntryCaption = call_user_func_array(array($this->_oConfig, 'getTitleShort'), !empty($aContent['title']) ? array($aContent['title']) : array($aContent['description'], $aContent['object_id']));
  2142. return array(
  2143. 'entry_sample' => $CNF['T']['txt_sample_single'],
  2144. 'entry_url' => bx_absolute_url($this->_oConfig->getItemViewUrl($aContent, false), '{bx_url_root}'),
  2145. 'entry_caption' => $sEntryCaption,
  2146. 'entry_author' => $aContent['owner_id'],
  2147. 'subentry_sample' => $CNF['T']['txt_sample_reaction_single'],
  2148. 'subentry_sample_params' => $aSubentrySampleParams,
  2149. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  2150. );
  2151. }
  2152. /**
  2153. * @page service Service Calls
  2154. * @section bx_timeline Timeline
  2155. * @subsection bx_timeline-integration_notifications Integration with Notifications
  2156. * @subsubsection bx_timeline-get_notifications_score_up get_notifications_score_up
  2157. *
  2158. * @code bx_srv('bx_timeline', 'get_notifications_score_up', [...]); @endcode
  2159. *
  2160. * Get data for Score Up Vote event to display in Notifications module.
  2161. *
  2162. * @param $aEvent an array with event description.
  2163. * @return an array with special format.
  2164. *
  2165. * @see BxTimelineModule::serviceGetNotificationsScoreUp
  2166. */
  2167. /**
  2168. * @ref bx_timeline-get_notifications_score_up "get_notifications_score_up"
  2169. */
  2170. public function serviceGetNotificationsScoreUp($aEvent)
  2171. {
  2172. return $this->_serviceGetNotificationsScore('up', $aEvent);
  2173. }
  2174. /**
  2175. * @page service Service Calls
  2176. * @section bx_timeline Timeline
  2177. * @subsection bx_timeline-integration_notifications Integration with Notifications
  2178. * @subsubsection bx_timeline-get_notifications_score_down get_notifications_score_down
  2179. *
  2180. * @code bx_srv('bx_timeline', 'get_notifications_score_down', [...]); @endcode
  2181. *
  2182. * Get data for Score Down Vote event to display in Notifications module.
  2183. *
  2184. * @param $aEvent an array with event description.
  2185. * @return an array with special format.
  2186. *
  2187. * @see BxTimelineModule::serviceGetNotificationsScoreDown
  2188. */
  2189. /**
  2190. * @ref bx_timeline-get_notifications_score_down "get_notifications_score_down"
  2191. */
  2192. public function serviceGetNotificationsScoreDown($aEvent)
  2193. {
  2194. return $this->_serviceGetNotificationsScore('down', $aEvent);
  2195. }
  2196. protected function _serviceGetNotificationsScore($sType, $aEvent)
  2197. {
  2198. $CNF = &$this->_oConfig->CNF;
  2199. $iContent = (int)$aEvent['object_id'];
  2200. $aContent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContent));
  2201. if(empty($aContent) || !is_array($aContent))
  2202. return array();
  2203. $oScore = BxDolScore::getObjectInstance($CNF['OBJECT_SCORES'], $iContent);
  2204. if(!$oScore || !$oScore->isEnabled())
  2205. return array();
  2206. $sEntryCaption = call_user_func_array(array($this->_oConfig, 'getTitleShort'), !empty($aContent['title']) ? array($aContent['title']) : array($aContent['description'], $aContent['object_id']));
  2207. return array(
  2208. 'entry_sample' => $CNF['T']['txt_sample_single'],
  2209. 'entry_url' => bx_absolute_url($this->_oConfig->getItemViewUrl($aContent, false), '{bx_url_root}'),
  2210. 'entry_caption' => $sEntryCaption,
  2211. 'entry_author' => $aContent['owner_id'],
  2212. 'subentry_sample' => $CNF['T']['txt_sample_score_' . $sType . '_single'],
  2213. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  2214. );
  2215. }
  2216. /**
  2217. * @page service Service Calls
  2218. * @section bx_timeline Timeline
  2219. * @subsection bx_timeline-repost Repost
  2220. * @subsubsection bx_timeline-get_repost_element_block get_repost_element_block
  2221. *
  2222. * @code bx_srv('bx_timeline', 'get_repost_element_block', [...]); @endcode
  2223. *
  2224. * Get repost element for content based modules.
  2225. *
  2226. * @param $iOwnerId integer value with owner profile ID.
  2227. * @param $sType string value with type (module name).
  2228. * @param $sAction string value with action (module action).
  2229. * @param $iObjectId integer value with object ID to be reposted.
  2230. * @param $aParams (optional) an array with additional params.
  2231. * @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.
  2232. *
  2233. * @see BxTimelineModule::serviceGetRepostElementBlock
  2234. */
  2235. /**
  2236. * @ref bx_timeline-get_repost_element_block "get_repost_element_block"
  2237. */
  2238. public function serviceGetRepostElementBlock($iOwnerId, $sType, $sAction, $iObjectId, $aParams = [])
  2239. {
  2240. if(!$this->isEnabled())
  2241. return '';
  2242. $aParams = array_merge($this->_oConfig->getRepostDefaults(), $aParams);
  2243. return $this->_oTemplate->getRepostElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams);
  2244. }
  2245. /**
  2246. * @page service Service Calls
  2247. * @section bx_timeline Timeline
  2248. * @subsection bx_timeline-repost Repost
  2249. * @subsubsection bx_timeline-get_repost_counter get_repost_counter
  2250. *
  2251. * @code bx_srv('bx_timeline', 'get_repost_counter', [...]); @endcode
  2252. *
  2253. * Get repost counter.
  2254. *
  2255. * @param $sType string value with type (module name).
  2256. * @param $sAction string value with action (module action).
  2257. * @param $iObjectId integer value with object ID to be reposted.
  2258. * @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.
  2259. *
  2260. * @see BxTimelineModule::serviceGetRepostCounter
  2261. */
  2262. /**
  2263. * @ref bx_timeline-get_repost_counter "get_repost_counter"
  2264. */
  2265. public function serviceGetRepostCounter($sType, $sAction, $iObjectId, $aParams = [])
  2266. {
  2267. if(!$this->isEnabled())
  2268. return '';
  2269. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  2270. $aParams = array_merge($this->_oConfig->getRepostDefaults(), $aParams);
  2271. return $this->_oTemplate->getRepostCounter($aReposted, $aParams);
  2272. }
  2273. /**
  2274. * @page service Service Calls
  2275. * @section bx_timeline Timeline
  2276. * @subsection bx_timeline-repost Repost
  2277. * @subsubsection bx_timeline-get_repost_js_script get_repost_js_script
  2278. *
  2279. * @code bx_srv('bx_timeline', 'get_repost_js_script', [...]); @endcode
  2280. *
  2281. * Get repost JavaScript code.
  2282. *
  2283. * @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.
  2284. *
  2285. * @see BxTimelineModule::serviceGetRepostJsScript
  2286. */
  2287. /**
  2288. * @ref bx_timeline-get_repost_js_script "get_repost_js_script"
  2289. */
  2290. public function serviceGetRepostJsScript()
  2291. {
  2292. if(!$this->isEnabled())
  2293. return '';
  2294. return $this->_oTemplate->getRepostJsScript();
  2295. }
  2296. /**
  2297. * @page service Service Calls
  2298. * @section bx_timeline Timeline
  2299. * @subsection bx_timeline-repost Repost
  2300. * @subsubsection bx_timeline-get_repost_js_click get_repost_js_click
  2301. *
  2302. * @code bx_srv('bx_timeline', 'get_repost_js_click', [...]); @endcode
  2303. *
  2304. * Get repost JavaScript code for OnClick event.
  2305. *
  2306. * @param $iOwnerId integer value with owner profile ID.
  2307. * @param $sType string value with type (module name).
  2308. * @param $sAction string value with action (module action).
  2309. * @param $iObjectId integer value with object ID to be reposted.
  2310. * @return HTML string with JavaScript code to display in OnClick events of HTML elements.
  2311. *
  2312. * @see BxTimelineModule::serviceGetRepostJsClick
  2313. */
  2314. /**
  2315. * @ref bx_timeline-get_repost_js_click "get_repost_js_click"
  2316. */
  2317. public function serviceGetRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId)
  2318. {
  2319. if(!$this->isEnabled())
  2320. return '';
  2321. return $this->_oTemplate->getRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId);
  2322. }
  2323. /**
  2324. * @page service Service Calls
  2325. * @section bx_timeline Timeline
  2326. * @subsection bx_timeline-repost Repost
  2327. * @subsubsection bx_timeline-get_repost_with_js_click get_repost_with_js_click
  2328. *
  2329. * @code bx_srv('bx_timeline', 'get_repost_with_js_click', [...]); @endcode
  2330. *
  2331. * Get 'repost with' JavaScript code for OnClick event.
  2332. *
  2333. * @param $iReposterId integer value with reposter profile ID.
  2334. * @param $sType string value with type (module name).
  2335. * @param $sAction string value with action (module action).
  2336. * @param $iObjectId integer value with object ID to be reposted.
  2337. * @return HTML string with JavaScript code to display in OnClick events of HTML elements.
  2338. *
  2339. * @see BxTimelineModule::serviceGetRepostWithJsClick
  2340. */
  2341. /**
  2342. * @ref bx_timeline-get_repost_with_js_click "get_repost_with_js_click"
  2343. */
  2344. public function serviceGetRepostWithJsClick($iReposterId, $sType, $sAction, $iObjectId)
  2345. {
  2346. if(!$this->isEnabled())
  2347. return '';
  2348. return $this->_oTemplate->getRepostWithJsClick($iReposterId, $sType, $sAction, $iObjectId);
  2349. }
  2350. /**
  2351. * @page service Service Calls
  2352. * @section bx_timeline Timeline
  2353. * @subsection bx_timeline-repost Repost
  2354. * @subsubsection bx_timeline-get_repost_to_js_click get_repost_to_js_click
  2355. *
  2356. * @code bx_srv('bx_timeline', 'get_repost_to_js_click', [...]); @endcode
  2357. *
  2358. * Get 'repost to' JavaScript code for OnClick event.
  2359. *
  2360. * @param $iReposterId integer value with reposter profile ID.
  2361. * @param $sType string value with type (module name).
  2362. * @param $sAction string value with action (module action).
  2363. * @param $iObjectId integer value with object ID to be reposted.
  2364. * @return HTML string with JavaScript code to display in OnClick events of HTML elements.
  2365. *
  2366. * @see BxTimelineModule::serviceGetRepostToJsClick
  2367. */
  2368. /**
  2369. * @ref bx_timeline-get_repost_to_js_click "get_repost_to_js_click"
  2370. */
  2371. public function serviceGetRepostToJsClick($iReposterId, $sType, $sAction, $iObjectId)
  2372. {
  2373. if(!$this->isEnabled())
  2374. return '';
  2375. return $this->_oTemplate->getRepostToJsClick($iReposterId, $sType, $sAction, $iObjectId);
  2376. }
  2377. /**
  2378. * @page service Service Calls
  2379. * @section bx_timeline Timeline
  2380. * @subsection bx_timeline-repost Repost
  2381. * @subsubsection bx_timeline-repost repost
  2382. *
  2383. * @code bx_srv('bx_timeline', 'repost', [...]); @endcode
  2384. *
  2385. * Perform repost action.
  2386. *
  2387. * @param $iAuthorId integer value with performer profile ID.
  2388. * @param $iOwnerId integer value with repost event owner profile ID.
  2389. * @param $sType string value with type (module name).
  2390. * @param $sAction string value with action (module action).
  2391. * @param $iObjectId integer value with object ID to be reposted.
  2392. * @parem $bForce boolean value force reposting without ACL check.
  2393. * @return an array with error (code and message) or integer with newly created repost event ID.
  2394. *
  2395. * @see BxTimelineModule::serviceRepost
  2396. */
  2397. /**
  2398. * @ref bx_timeline-repost "repost"
  2399. */
  2400. public function serviceRepost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, $bForce = false)
  2401. {
  2402. return $this->repost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, false, $bForce);
  2403. }
  2404. /**
  2405. * @page service Service Calls
  2406. * @section bx_timeline Timeline
  2407. * @subsection bx_timeline-repost Repost
  2408. * @subsubsection bx_timeline-repost_with repost_with
  2409. *
  2410. * @code bx_srv('bx_timeline', 'repost_with', [...]); @endcode
  2411. *
  2412. * Perform repost action passing additional data.
  2413. *
  2414. * @param $iAuthorId integer value with performer profile ID.
  2415. * @param $iOwnerId integer value with repost event owner profile ID.
  2416. * @param $sType string value with type (module name).
  2417. * @param $sAction string value with action (module action).
  2418. * @param $iObjectId integer value with object ID to be reposted.
  2419. * @param $mixedData array with some data to attach to repost event or false.
  2420. * @parem $bForce boolean value force reposting without ACL check.
  2421. * @return an array with error (code and message) or integer with newly created repost event ID.
  2422. *
  2423. * @see BxTimelineModule::serviceRepostWith
  2424. */
  2425. /**
  2426. * @ref bx_timeline-repost_with "repost_with"
  2427. */
  2428. public function serviceRepostWith($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, $mixedData = false, $bForce = false)
  2429. {
  2430. return $this->repost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, $mixedData, $bForce);
  2431. }
  2432. /**
  2433. * @page service Service Calls
  2434. * @section bx_timeline Timeline
  2435. * @subsection bx_timeline-repost Repost
  2436. * @subsubsection bx_timeline-repost_by_id repost_by_id
  2437. *
  2438. * @code bx_srv('bx_timeline', 'repost_by_id', [...]); @endcode
  2439. *
  2440. * Perform repost action by Timeline event ID.
  2441. *
  2442. * @param $iAuthorId integer value with performer profile ID.
  2443. * @param $iOwnerId integer value with repost event owner profile ID.
  2444. * @param $iEventId integer value with event ID which will be reposted.
  2445. * @parem $bForce boolean value force reposting without ACL check.
  2446. * @return an array with error (code and message) or integer with newly created repost event ID.
  2447. *
  2448. * @see BxTimelineModule::serviceRepostById
  2449. */
  2450. /**
  2451. * @ref bx_timeline-repost_by_id "repost_by_id"
  2452. */
  2453. public function serviceRepostById($iAuthorId, $iOwnerId, $iEventId, $bForce = false)
  2454. {
  2455. $aEvent = $this->_oDb->getEntriesBy(array('type' => 'id', 'id' => $iEventId));
  2456. if(empty($aEvent) || !is_array($aEvent))
  2457. return array('code' => 1, 'message' => _t('_bx_timeline_txt_err_cannot_repost'));
  2458. $sType = $aEvent['type'];
  2459. $sAction = $aEvent['action'];
  2460. $iObjectId = $this->_oConfig->isSystem($sType, $sAction) ? $aEvent['object_id'] : $aEvent['id'];
  2461. $sCommonPrefix = $this->_oConfig->getPrefix('common_post');
  2462. if(str_replace($sCommonPrefix, '', $sType) == BX_TIMELINE_PARSE_TYPE_REPOST) {
  2463. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  2464. if(empty($aReposted) || !is_array($aReposted))
  2465. return array('code' => 1, 'message' => _t('_bx_timeline_txt_err_cannot_repost'));
  2466. $aRepostedData = unserialize($aEvent['content']);
  2467. $sType = $aRepostedData['type'];
  2468. $sAction = $aRepostedData['action'];
  2469. $iObjectId = $aRepostedData['object_id'];
  2470. }
  2471. return $this->repost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, false, $bForce);
  2472. }
  2473. public function repost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, $mixedData = false, $bForce = false)
  2474. {
  2475. $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
  2476. if(empty($aReposted) || !is_array($aReposted))
  2477. return array('code' => 1, 'message' => _t('_bx_timeline_txt_err_cannot_repost'));
  2478. $mixedAllowed = $this->isAllowedRepost($aReposted, true);
  2479. if(!$bForce && $mixedAllowed !== true)
  2480. return array('code' => 2, 'message' => strip_tags($mixedAllowed));
  2481. $bReposted = $this->_oDb->isReposted($aReposted['id'], $iOwnerId, $iAuthorId);
  2482. if($bReposted)
  2483. return array('code' => 3, 'message' => _t('_bx_timeline_txt_err_already_reposted'));
  2484. $iDate = time();
  2485. $iId = $this->_oDb->insertEvent([
  2486. 'owner_id' => $iOwnerId,
  2487. 'system' => 0,
  2488. 'type' => $this->_oConfig->getPrefix('common_post') . 'repost',
  2489. 'action' => '',
  2490. 'object_id' => $iAuthorId,
  2491. 'object_owner_id' => $iAuthorId,
  2492. 'object_privacy_view' => $this->_oConfig->getPrivacyViewDefault('object'),
  2493. 'content' => serialize([
  2494. 'type' => $sType,
  2495. 'action' => $sAction,
  2496. 'object_id' => $iObjectId,
  2497. 'rdata' => $mixedData
  2498. ]),
  2499. 'title' => '',
  2500. 'description' => '',
  2501. 'date' => $iDate,
  2502. 'reacted' => $iDate,
  2503. 'status_admin' => $this->getStatusAdmin()
  2504. ]);
  2505. if(empty($iId))
  2506. return array('code' => 4, 'message' => _t('_bx_timeline_txt_err_cannot_repost'));
  2507. $this->onRepost($iId, $aReposted);
  2508. return $iId;
  2509. }
  2510. /**
  2511. * @page service Service Calls
  2512. * @section bx_timeline Timeline
  2513. * @subsection bx_timeline-other Other
  2514. * @subsubsection bx_timeline-update update
  2515. *
  2516. * @code bx_srv('bx_timeline', 'update', [...]); @endcode
  2517. *
  2518. * Update timeline event by ID.
  2519. *
  2520. * @param $iEventId integer value with event ID.
  2521. * @param $aSet an array with key=>value pairs for fields which should be updated.
  2522. * @return boolean value with the result of operation.
  2523. *
  2524. * @see BxTimelineModule::serviceUpdate
  2525. */
  2526. /**
  2527. * @ref bx_timeline-update "update"
  2528. */
  2529. public function serviceUpdate($iEventId, $aSet)
  2530. {
  2531. if(empty($iEventId))
  2532. return false;
  2533. return (int)$this->_oDb->updateEvent($aSet, array('id' => $iEventId)) > 0;
  2534. }
  2535. /**
  2536. * @page service Service Calls
  2537. * @section bx_timeline Timeline
  2538. * @subsection bx_timeline-other Other
  2539. * @subsubsection bx_timeline-delete delete
  2540. *
  2541. * @code bx_srv('bx_timeline', 'delete', [...]); @endcode
  2542. *
  2543. * Delete timeline event by ID.
  2544. *
  2545. * @param $iId integer value with event ID.
  2546. * @return boolean value with the result of operation.
  2547. *
  2548. * @see BxTimelineModule::serviceDelete
  2549. */
  2550. /**
  2551. * @ref bx_timeline-delete "delete"
  2552. */
  2553. public function serviceDelete($iId)
  2554. {
  2555. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  2556. if(empty($aEvent) || !is_array($aEvent))
  2557. return true;
  2558. if($this->isAllowedDelete($aEvent, true) !== true || !$this->deleteEvent($aEvent))
  2559. return false;
  2560. $this->_oDb->deleteCache(array('event_id' => $iId));
  2561. return true;
  2562. }
  2563. /**
  2564. * @page service Service Calls
  2565. * @section bx_timeline Timeline
  2566. * @subsection bx_timeline-other Other
  2567. * @subsubsection bx_timeline-get_menu_item_addon_comment get_menu_item_addon_comment
  2568. *
  2569. * @code bx_srv('bx_timeline', 'get_menu_item_addon_comment', [...]); @endcode
  2570. *
  2571. * Get addon for Comment menu item.
  2572. * NOTE. The service isn't used for now because comment functionality in card was updated.
  2573. *
  2574. * @param $sSystem string value with comments engine system.
  2575. * @param $iObjectId integer value with object ID.
  2576. * @return HTML string to display in menu item.
  2577. *
  2578. * @see BxTimelineModule::serviceGetMenuItemAddonComment
  2579. */
  2580. /**
  2581. * @ref bx_timeline-get_menu_item_addon_comment "get_menu_item_addon_comment"
  2582. */
  2583. public function serviceGetMenuItemAddonComment($sSystem, $iObjectId, $aBrowseParams = array())
  2584. {
  2585. if(empty($sSystem) || empty($iObjectId))
  2586. return '';
  2587. $oCmts = $this->getCmtsObject($sSystem, $iObjectId);
  2588. if($oCmts === false)
  2589. return '';
  2590. $iCounter = (int)$oCmts->getCommentsCount();
  2591. if(empty($iCounter))
  2592. return '';
  2593. return $this->_oTemplate->parseLink('javascript:void(0)', $iCounter, array(
  2594. 'class' => 'bx-menu-item-addon',
  2595. 'title' => _t('_bx_timeline_menu_item_title_item_comment'),
  2596. 'onclick' => "javascript:" . $this->_oConfig->getJsObjectView($aBrowseParams) . ".commentItem(this, '" . $sSystem . "', " . $iObjectId . ")"
  2597. ));
  2598. }
  2599. /**
  2600. * @page service Service Calls
  2601. * @section bx_timeline Timeline
  2602. * @subsection bx_timeline-other Other
  2603. * @subsubsection bx_timeline-get_settings_checker_helper get_settings_checker_helper
  2604. *
  2605. * @code bx_srv('bx_timeline', 'get_settings_checker_helper', [...]); @endcode
  2606. *
  2607. * Get Checker Helper class name for Forms engine.
  2608. *
  2609. * @return string with Checker Helper class name.
  2610. *
  2611. * @see BxTimelineModule::serviceGetSettingsCheckerHelper
  2612. */
  2613. /**
  2614. * @ref bx_timeline-get_settings_checker_helper "get_settings_checker_helper"
  2615. */
  2616. public function serviceGetSettingsCheckerHelper()
  2617. {
  2618. bx_import('FormCheckerHelper', $this->_aModule);
  2619. return 'BxTimelineFormCheckerHelper';
  2620. }
  2621. /**
  2622. * @page service Service Calls
  2623. * @section bx_timeline Timeline
  2624. * @subsection bx_timeline-other Other
  2625. * @subsubsection bx_timeline-get_options_videos_preload get_options_videos_preload
  2626. *
  2627. * @code bx_srv('bx_timeline', 'get_options_videos_preload', [...]); @endcode
  2628. *
  2629. * Get an array with available options for 'Videos preload in Timeline' setting.
  2630. *
  2631. * @return an array with available options represented as key => value pairs.
  2632. *
  2633. * @see BxTimelineModule::serviceGetOptionsVideosPreload
  2634. */
  2635. /**
  2636. * @ref bx_timeline-get_options_videos_preload "get_options_videos_preload"
  2637. */
  2638. public function serviceGetOptionsVideosPreload()
  2639. {
  2640. $CNF = &$this->_oConfig->CNF;
  2641. $aOptions = array('auto', 'metadata', 'none');
  2642. $aResult = array();
  2643. foreach($aOptions as $sOption)
  2644. $aResult[] = array(
  2645. 'key' => $sOption,
  2646. 'value' => _t($CNF['T']['option_vp_' . $sOption])
  2647. );
  2648. return $aResult;
  2649. }
  2650. /**
  2651. * @page service Service Calls
  2652. * @section bx_timeline Timeline
  2653. * @subsection bx_timeline-other Other
  2654. * @subsubsection bx_timeline-get_options_videos_autoplay get_options_videos_autoplay
  2655. *
  2656. * @code bx_srv('bx_timeline', 'get_options_videos_autoplay', [...]); @endcode
  2657. *
  2658. * Get an array with available options for 'Videos autoplay in Timeline' setting.
  2659. *
  2660. * @return an array with available options represented as key => value pairs.
  2661. *
  2662. * @see BxTimelineModule::serviceGetOptionsVideosAutoplay
  2663. */
  2664. /**
  2665. * @ref bx_timeline-get_options_videos_autoplay "get_options_videos_autoplay"
  2666. */
  2667. public function serviceGetOptionsVideosAutoplay()
  2668. {
  2669. $CNF = &$this->_oConfig->CNF;
  2670. $aOptions = array(BX_TIMELINE_VAP_OFF, BX_TIMELINE_VAP_ON_MUTE, BX_TIMELINE_VAP_ON);
  2671. $aResult = array();
  2672. foreach($aOptions as $sOption)
  2673. $aResult[] = array(
  2674. 'key' => $sOption,
  2675. 'value' => _t($CNF['T']['option_vap_' . $sOption])
  2676. );
  2677. return $aResult;
  2678. }
  2679. /**
  2680. * @page service Service Calls
  2681. * @section bx_timeline Timeline
  2682. * @subsection bx_timeline-other Other
  2683. * @subsubsection bx_timeline-get_options_attachments_layout get_options_attachments_layout
  2684. *
  2685. * @code bx_srv('bx_timeline', 'get_options_attachments_layout', [...]); @endcode
  2686. *
  2687. * Get an array with available options for 'Show attachments as' setting.
  2688. *
  2689. * @return an array with available options represented as key => value pairs.
  2690. *
  2691. * @see BxTimelineModule::serviceGetOptionsAttachmentsLayout
  2692. */
  2693. /**
  2694. * @ref bx_timeline-get_options_attachments_layout "get_options_attachments_layout"
  2695. */
  2696. public function serviceGetOptionsAttachmentsLayout()
  2697. {
  2698. $CNF = &$this->_oConfig->CNF;
  2699. $aOptions = array(BX_TIMELINE_ML_GALLERY, BX_TIMELINE_ML_SHOWCASE);
  2700. $aResult = array();
  2701. foreach($aOptions as $sOption)
  2702. $aResult[] = array(
  2703. 'key' => $sOption,
  2704. 'value' => _t($CNF['T']['option_al_' . $sOption])
  2705. );
  2706. return $aResult;
  2707. }
  2708. /**
  2709. * @page service Service Calls
  2710. * @section bx_timeline Timeline
  2711. * @subsection bx_timeline-other Other
  2712. * @subsubsection bx_timeline-get_live_update get_live_update
  2713. *
  2714. * @code bx_srv('bx_timeline', 'get_live_update', [...]); @endcode
  2715. *
  2716. * Get an array with actual Live Update info. Only one live update notification for all new events.
  2717. *
  2718. * @return an array with Live Update info.
  2719. *
  2720. * @see BxTimelineModule::serviceGetLiveUpdate
  2721. */
  2722. /**
  2723. * @ref bx_timeline-get_live_update "get_live_update"
  2724. */
  2725. public function serviceGetLiveUpdate($aBrowseParams, $iProfileId, $iValue = 0, $iInit = 0)
  2726. {
  2727. $CNF = &$this->_oConfig->CNF;
  2728. $sKey = $this->_oConfig->getLiveUpdateKey($aBrowseParams);
  2729. bx_import('BxDolSession');
  2730. if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
  2731. return false;
  2732. $aParams = $this->_prepareParams($aBrowseParams);
  2733. $aParams = array_merge($aParams, array(
  2734. 'filter' => BX_TIMELINE_FILTER_OTHER_VIEWER
  2735. ));
  2736. $aEvents = $this->_oDb->getEvents($aParams);
  2737. if(empty($aEvents) || !is_array($aEvents))
  2738. return false;
  2739. $iValueNew = 0;
  2740. foreach($aEvents as $aEvent) {
  2741. if((int)$aEvent[$CNF['FIELD_STICKED']] != 0)
  2742. continue;
  2743. $sContent = $this->_oTemplate->getPost($aEvent, $aParams);
  2744. if(empty($sContent))
  2745. continue;
  2746. $iValueNew = $aEvent['id'];
  2747. break;
  2748. }
  2749. if($iValueNew == $iValue)
  2750. return false;
  2751. if((int)$iInit != 0)
  2752. return array('count' => $iValueNew);
  2753. return array(
  2754. 'count' => $iValueNew, // required (for initialization and visualization)
  2755. 'method' => $this->_oConfig->getJsObjectView($aBrowseParams) . '.showLiveUpdate(oData)', // required (for visualization)
  2756. 'data' => array(
  2757. 'code' => $this->_oTemplate->getLiveUpdate($aBrowseParams, $iProfileId, $iValue, $iValueNew)
  2758. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  2759. );
  2760. }
  2761. /**
  2762. * @page service Service Calls
  2763. * @section bx_timeline Timeline
  2764. * @subsection bx_timeline-other Other
  2765. * @subsubsection bx_timeline-get_live_updates get_live_updates
  2766. *
  2767. * @code bx_srv('bx_timeline', 'get_live_updates', [...]); @endcode
  2768. *
  2769. * Get an array with actual Live Update info. Separate live update notification for each new Event.
  2770. * Note. This method isn't used for now. @see BxTimelineModule::serviceGetLiveUpdate method instead.
  2771. *
  2772. * Note. This way to display live update notifications isn't used for now.
  2773. * See BxTimelineModule::serviceGetLiveUpdate method instead.
  2774. *
  2775. * @return an array with Live Update info.
  2776. *
  2777. * @see BxTimelineModule::serviceGetLiveUpdates
  2778. */
  2779. /**
  2780. * @ref bx_timeline-get_live_updates "get_live_updates"
  2781. */
  2782. public function serviceGetLiveUpdates($aBrowseParams, $iProfileId, $iCount = 0, $iInit = 0)
  2783. {
  2784. $sKey = $this->_oConfig->getLiveUpdateKey($aBrowseParams);
  2785. bx_import('BxDolSession');
  2786. if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
  2787. return false;
  2788. $aParams = $this->_prepareParams($aBrowseParams);
  2789. $aParams['filter'] = BX_TIMELINE_FILTER_OTHER_VIEWER;
  2790. $aParams['count'] = true;
  2791. $iCountNew = $this->_oDb->getEvents($aParams);
  2792. if($iCountNew == $iCount)
  2793. return false;
  2794. if((int)$iInit != 0)
  2795. return array('count' => $iCountNew);
  2796. return array(
  2797. 'count' => $iCountNew, // required (for initialization and visualization)
  2798. 'method' => $this->_oConfig->getJsObjectView($aBrowseParams) . '.showLiveUpdates(oData)', // required (for visualization)
  2799. 'data' => array(
  2800. 'code' => $this->_oTemplate->getLiveUpdates($aBrowseParams, $iProfileId, $iCount, $iCountNew)
  2801. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  2802. );
  2803. }
  2804. /**
  2805. * @page service Service Calls
  2806. * @section bx_timeline Accounts
  2807. * @subsection bx_timeline-other Other
  2808. * @subsubsection bx_timeline-get_menu_addon_manage_tools get_menu_addon_manage_tools
  2809. *
  2810. * @code bx_srv('bx_timeline', 'get_menu_addon_manage_tools', [...]); @endcode
  2811. *
  2812. * Get number of 'hidden' events for User End -> Dasboard page -> Manage block.
  2813. *
  2814. * @return integer number of 'hidden' events
  2815. *
  2816. * @see BxTimelineModule::serviceGetMenuAddonManageTools
  2817. */
  2818. /**
  2819. * @ref bx_timeline-get_menu_addon_manage_tools "get_menu_addon_manage_tools"
  2820. */
  2821. public function serviceGetMenuAddonManageTools()
  2822. {
  2823. $iNum1 = $this->_oDb->getEntriesNumByParams([
  2824. [
  2825. 'key' => 'status',
  2826. 'value' => BX_TIMELINE_STATUS_HIDDEN,
  2827. 'operator' => '='
  2828. ]
  2829. ]);
  2830. $iNum2 = $this->_oDb->getEntriesNumByParams([
  2831. [
  2832. 'key' => 'reports',
  2833. 'value' => '0',
  2834. 'operator' => '>'
  2835. ]
  2836. ]);
  2837. return array(
  2838. 'counter1_value' => $iNum1,
  2839. 'counter2_value' => $iNum2,
  2840. 'counter3_value' => 0
  2841. );
  2842. }
  2843. /**
  2844. * @page service Service Calls
  2845. * @section bx_timeline Accounts
  2846. * @subsection bx_timeline-other Other
  2847. * @subsubsection bx_timeline-get_menu_addon_profile_stats get_menu_addon_profile_stats
  2848. *
  2849. * @code bx_srv('bx_timeline', 'get_menu_addon_profile_stats', [...]); @endcode
  2850. *
  2851. * Get number of 'muted' events for currently logged in user. User End -> Profile Stats.
  2852. *
  2853. * @return integer number of 'muted' events
  2854. *
  2855. * @see BxTimelineModule::serviceGetMenuAddonProfileStats
  2856. */
  2857. /**
  2858. * @ref bx_timeline-get_menu_addon_profile_stats "get_menu_addon_profile_stats"
  2859. */
  2860. public function serviceGetMenuAddonProfileStats($iProfileId = 0)
  2861. {
  2862. if(empty($iProfileId))
  2863. $iProfileId = $this->_iProfileId;
  2864. return $this->getConnectionMuteObject()->getConnectedContentCount($iProfileId);
  2865. }
  2866. public function serviceGet($aParams)
  2867. {
  2868. $aParams = $this->_prepareParams($aParams);
  2869. $aParams['return_data_type'] = 'array';
  2870. return $this->_oTemplate->getPosts($aParams);
  2871. }
  2872. public function serviceAdd($aValues)
  2873. {
  2874. return $this->getFormPost(array(
  2875. 'values' => $aValues
  2876. ));
  2877. }
  2878. public function serviceEdit($iId, $aValues)
  2879. {
  2880. return $this->getFormEdit($iId, array(
  2881. 'values' => $aValues
  2882. ));
  2883. }
  2884. /**
  2885. * Delete content entry
  2886. * @param $iContentId content id
  2887. * @return error message or empty string on success
  2888. */
  2889. public function serviceDeleteEntity ($iContentId, $sFuncDelete = 'deleteData')
  2890. {
  2891. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  2892. if(empty($aEvent) || !is_array($aEvent))
  2893. return _t('_Empty');
  2894. if(!$this->deleteEvent($aEvent))
  2895. return _t('_bx_timeline_txt_err_cannot_perform_action');
  2896. return '';
  2897. }
  2898. /*
  2899. * COMMON METHODS
  2900. */
  2901. public function getStatusAdmin()
  2902. {
  2903. return $this->isModerator() || $this->_oConfig->isAutoApproveEnabled() ? BX_TIMELINE_STATUS_ACTIVE : BX_TIMELINE_STATUS_PENDING;
  2904. }
  2905. public function getItemData($iId, $aParams = array())
  2906. {
  2907. $CNF = &$this->_oConfig->CNF;
  2908. if(empty($aParams))
  2909. $aParams = $this->_prepareParams(array(
  2910. 'view' => BX_TIMELINE_VIEW_ITEM,
  2911. 'type' => BX_TIMELINE_TYPE_ITEM
  2912. ));
  2913. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
  2914. if(empty($aEvent))
  2915. return array('code' => 1, 'content' => _t('_Empty'));
  2916. $iProfile = (int)$aEvent[$CNF['FIELD_OWNER_ID']];
  2917. if(!empty($iProfile)) {
  2918. $oProfile = BxDolProfile::getInstance($iProfile);
  2919. if(!$oProfile)
  2920. return array('code' => 1, 'content' => _t('_Empty'));
  2921. $mixedResult = $oProfile->checkAllowedProfileView();
  2922. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  2923. return array('code' => 2, 'content' => $mixedResult);
  2924. }
  2925. $sContent = $this->_oTemplate->getPost($aEvent, $aParams);
  2926. if(empty($sContent))
  2927. return array('code' => 2, 'content' => _t('_Access denied'));
  2928. $sKey = 'allowed_view';
  2929. if(isset($aEvent[$sKey]) && $aEvent[$sKey] !== CHECK_ACTION_RESULT_ALLOWED)
  2930. return array('code' => 2, 'content' => $aEvent[$sKey]);
  2931. if($this->isAllowedView($aEvent) !== true)
  2932. return array('code' => 2, 'content' => _t('_Access denied'));
  2933. return array('code' => 0, 'content' => $sContent, 'event' => $aEvent);
  2934. }
  2935. public function hideEvent($aEvent)
  2936. {
  2937. if(empty($aEvent) || !is_array($aEvent) || !$this->_oDb->updateEvent(['status' => 'hidden'], ['id' => (int)$aEvent['id']]))
  2938. return false;
  2939. $this->onHide($aEvent);
  2940. return true;
  2941. }
  2942. public function deleteEvent($aEvent)
  2943. {
  2944. if(empty($aEvent) || !is_array($aEvent) || !$this->_oDb->deleteEvent(array('id' => (int)$aEvent['id'])))
  2945. return false;
  2946. $this->onDelete($aEvent);
  2947. return true;
  2948. }
  2949. public function addAttachLink($aValues, $sDisplay = false)
  2950. {
  2951. $CNF = &$this->_oConfig->CNF;
  2952. if(!$sDisplay)
  2953. $sDisplay = $this->_oConfig->getObject('form_display_attach_link_add');
  2954. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_attach_link'), $sDisplay, $this->_oTemplate);
  2955. if(!$oForm)
  2956. return array('message' => '_sys_txt_error_occured');
  2957. $oForm->aFormAttrs['method'] = BX_DOL_FORM_METHOD_SPECIFIC;
  2958. $oForm->aParams['csrf']['disable'] = true;
  2959. if(!empty($oForm->aParams['db']['submit_name'])) {
  2960. $sSubmitName = $oForm->aParams['db']['submit_name'];
  2961. if(!isset($oForm->aInputs[$sSubmitName])) {
  2962. if(isset($oForm->aInputs[$CNF['FIELD_CONTROLS']]))
  2963. foreach($oForm->aInputs[$CNF['FIELD_CONTROLS']] as $mixedIndex => $aInput) {
  2964. if(!is_numeric($mixedIndex) || empty($aInput['name']) || $aInput['name'] != $sSubmitName)
  2965. continue;
  2966. $aValues[$sSubmitName] = $aInput['value'];
  2967. }
  2968. }
  2969. else
  2970. $aValues[$sSubmitName] = $oForm->aInputs[$sSubmitName]['value'];
  2971. }
  2972. $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url');
  2973. $oForm->initChecker(array(), $aValues);
  2974. if(!$oForm->isSubmittedAndValid())
  2975. return array('message' => '_sys_txt_error_occured');
  2976. return $this->_addLink($oForm);
  2977. }
  2978. public function getFormAttachLink($iEventId = 0)
  2979. {
  2980. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_attach_link'), $this->_oConfig->getObject('form_display_attach_link_add'), $this->_oTemplate);
  2981. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'submit_attach_link_form/';
  2982. $oForm->aInputs['event_id']['value'] = $iEventId;
  2983. $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url');
  2984. $oForm->initChecker();
  2985. if($oForm->isSubmittedAndValid())
  2986. return $this->_addLink($oForm);
  2987. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  2988. }
  2989. public function getFormPost($aParams = [])
  2990. {
  2991. $CNF = &$this->_oConfig->CNF;
  2992. $iUserId = $this->getUserId();
  2993. $oForm = $this->getFormPostObject($aParams);
  2994. $aFormInitCheckerParams = [];
  2995. $bValues = !empty($aParams['values']) && is_array($aParams['values']);
  2996. if($bValues) {
  2997. $this->_prepareFormForAutoSubmit($oForm, $aParams['values']);
  2998. $aFormInitCheckerParams = [[], $aParams['values']];
  2999. unset($aParams['values']);
  3000. }
  3001. call_user_func_array([$oForm, 'initChecker'], $aFormInitCheckerParams);
  3002. $bAjaxMode = $oForm->isAjaxMode();
  3003. $bDynamicMode = $bAjaxMode;
  3004. if($oForm->isSubmittedAndValid()) {
  3005. $sType = $oForm->getCleanValue('type');
  3006. $sType = $this->_oConfig->getPrefix('common_post') . $sType;
  3007. BxDolForm::setSubmittedValue('type', $sType, $oForm->aFormAttrs['method']);
  3008. $aContent = [];
  3009. //--- Process Text ---//
  3010. $sText = $oForm->getCleanValue('text');
  3011. $sText = $this->_prepareTextForSave($sText);
  3012. $bText = !empty($sText);
  3013. if($bText)
  3014. $aContent['text'] = $sText;
  3015. //--- Process Context and Privacy ---//
  3016. $iOwnerId = (int)$oForm->getCleanValue('owner_id');
  3017. $iObjectPrivacyView = (int)$oForm->getCleanValue('object_privacy_view');
  3018. $iObjectPrivacyViewDefault = $this->_oConfig->getPrivacyViewDefault('object');
  3019. if(empty($iObjectPrivacyView))
  3020. $iObjectPrivacyView = $iObjectPrivacyViewDefault;
  3021. else if($iObjectPrivacyView < 0)
  3022. $iOwnerId = abs($iObjectPrivacyView);
  3023. //--- Process Link ---//
  3024. $aLinkIds = $oForm->getCleanValue($CNF['FIELD_LINK']);
  3025. $bLinkIds = !empty($aLinkIds) && is_array($aLinkIds);
  3026. //--- Process Photos ---//
  3027. $aPhotoIds = $oForm->getCleanValue($CNF['FIELD_PHOTO']);
  3028. $bPhotoIds = !empty($aPhotoIds) && is_array($aPhotoIds);
  3029. //--- Process Videos ---//
  3030. $aVideoIds = $oForm->getCleanValue($CNF['FIELD_VIDEO']);
  3031. $bVideoIds = !empty($aVideoIds) && is_array($aVideoIds);
  3032. //--- Process Files ---//
  3033. $aFileIds = $oForm->getCleanValue($CNF['FIELD_FILE']);
  3034. $bFileIds = !empty($aFileIds) && is_array($aFileIds);
  3035. if(!$bText && !$bLinkIds && !$bPhotoIds && !$bVideoIds && !$bFileIds) {
  3036. $oForm->aInputs['text']['error'] = _t('_bx_timeline_txt_err_empty_post');
  3037. $oForm->setValid(false);
  3038. return $this->_prepareResponse([
  3039. 'form' => $oForm->getCode($bDynamicMode),
  3040. 'form_id' => $oForm->id
  3041. ], $bAjaxMode);
  3042. }
  3043. $sTitle = $bText ? $this->_oConfig->getTitle($sText) : $this->_oConfig->getTitleDefault($bLinkIds, $bPhotoIds, $bVideoIds, $bFileIds);
  3044. $sDescription = _t('_bx_timeline_txt_user_added_sample', '{profile_name}', _t('_bx_timeline_txt_sample_with_article'));
  3045. /**
  3046. * Unset 'text' input because its data was already processed
  3047. * and will be saved via additional values which were passed
  3048. * to BxDolForm::insert method.
  3049. */
  3050. unset($oForm->aInputs['text']);
  3051. $iId = $oForm->insert([
  3052. 'owner_id' => $iOwnerId,
  3053. 'object_id' => $iUserId,
  3054. 'object_owner_id' => $iUserId,
  3055. 'object_privacy_view' => $iObjectPrivacyView,
  3056. 'content' => serialize($aContent),
  3057. 'title' => $sTitle,
  3058. 'description' => $sDescription,
  3059. 'status_admin' => $this->getStatusAdmin()
  3060. ]);
  3061. if(!empty($iId)) {
  3062. $this->isAllowedPost(true);
  3063. $aContent = array_merge($aContent, [
  3064. 'timeline_group' => [
  3065. 'by' => $this->getName() . '_' . $iUserId . '_' . $iId,
  3066. 'field' => 'owner_id'
  3067. ]
  3068. ]);
  3069. $this->_oDb->updateEvent(['content' => serialize($aContent)], ['id' => $iId]);
  3070. //--- Process Meta ---//
  3071. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  3072. if($bText)
  3073. $oMetatags->metaAdd($iId, $sText);
  3074. $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
  3075. //--- Process Link ---//
  3076. if($bLinkIds)
  3077. foreach($aLinkIds as $iLinkId)
  3078. $this->_oDb->saveLink($iId, $iLinkId);
  3079. //--- Process Media ---//
  3080. $this->_saveMedia($CNF['FIELD_PHOTO'], $iId, $aPhotoIds, $iUserId, true);
  3081. $this->_saveMedia($CNF['FIELD_VIDEO'], $iId, $aVideoIds, $iUserId, true);
  3082. $this->_saveMedia($CNF['FIELD_FILE'], $iId, $aFileIds, $iUserId, true);
  3083. $this->onPost($iId);
  3084. return $this->_prepareResponse(['id' => $iId], $bAjaxMode, [
  3085. 'redirect' => $this->_oConfig->getItemViewUrl(['id' => $iId])
  3086. ]);
  3087. }
  3088. return $this->_prepareResponse(['message' => _t('_bx_timeline_txt_err_cannot_perform_action')], $bAjaxMode);
  3089. }
  3090. $mixedResult = $this->_prepareResponse([
  3091. 'form' => $oForm->getCode($bDynamicMode),
  3092. 'form_id' => $oForm->id
  3093. ], $bAjaxMode && $oForm->isSubmitted());
  3094. if(is_array($mixedResult))
  3095. $mixedResult['form_object'] = $oForm;
  3096. return $mixedResult;
  3097. }
  3098. public function getFormEdit($iId, $aParams = [], $aBrowseParams = [])
  3099. {
  3100. $CNF = &$this->_oConfig->CNF;
  3101. $sJsObjectView = $this->_oConfig->getJsObjectView($aBrowseParams);
  3102. $iUserId = $this->getUserId();
  3103. $aEvent = $this->_oDb->getEvents(['browse' => 'id', 'value' => $iId]);
  3104. if(empty($aEvent) || !is_array($aEvent))
  3105. return [];
  3106. if(($mixedCheck = $this->isAllowedEdit($aEvent)) !== true)
  3107. return ['message' => $mixedCheck !== false ? $mixedCheck : _t('_sys_txt_access_denied')];
  3108. $aContent = unserialize($aEvent['content']);
  3109. if(is_array($aContent) && !empty($aContent['text']))
  3110. $aEvent['text'] = $aContent['text'];
  3111. if(empty($aParams['form_object']))
  3112. $aParams['form_object'] = 'form_post';
  3113. if(empty($aParams['form_display']))
  3114. $aParams['form_display'] = 'form_display_post_edit';
  3115. $oForm = $this->getFormPostObject($aParams);
  3116. $oForm->setId($this->_oConfig->getHtmlIds('view', 'edit_form') . $iId);
  3117. $aFormInitCheckerParams = [];
  3118. $bValues = !empty($aParams['values']) && is_array($aParams['values']);
  3119. if($bValues) {
  3120. $this->_prepareFormForAutoSubmit($oForm, $aParams['values']);
  3121. $aFormInitCheckerParams = [[], array_merge($aEvent, $aParams['values'])];
  3122. unset($aParams['values']);
  3123. }
  3124. else {
  3125. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'edit/' . $iId ;
  3126. if(!empty($aBrowseParams) && is_array($aBrowseParams))
  3127. $oForm->aFormAttrs['action'] = $this->_oConfig->addBrowseParams($oForm->aFormAttrs['action'], $aBrowseParams);
  3128. foreach($oForm->aInputs[$CNF['FIELD_CONTROLS']] as $mixedIndex => $aInput) {
  3129. if(!is_numeric($mixedIndex))
  3130. continue;
  3131. $oForm->aInputs[$CNF['FIELD_CONTROLS']][$mixedIndex]['attrs'] = bx_replace_markers($aInput['attrs'], [
  3132. 'js_object_view' => $sJsObjectView,
  3133. 'content_id' => $iId
  3134. ]);
  3135. }
  3136. $aFormInitCheckerParams = [$aEvent];
  3137. }
  3138. call_user_func_array([$oForm, 'initChecker'], $aFormInitCheckerParams);
  3139. $bAjaxMode = $oForm->isAjaxMode();
  3140. $bDynamicMode = $bAjaxMode || bx_is_dynamic_request();
  3141. $sCodeAdd = '';
  3142. if($bDynamicMode) {
  3143. $sCodeAdd .= $this->_oTemplate->getAddedJs('post', $bDynamicMode);
  3144. $sCodeAdd .= $this->_oTemplate->getJsCode('post', [], true, $bDynamicMode);
  3145. }
  3146. if($oForm->isSubmittedAndValid()) {
  3147. $aContent = [];
  3148. //--- Process Text ---//
  3149. $sText = $oForm->getCleanValue('text');
  3150. $sText = $this->_prepareTextForSave($sText);
  3151. $bText = !empty($sText);
  3152. unset($oForm->aInputs['text']);
  3153. if($bText)
  3154. $aContent['text'] = $sText;
  3155. $aValsToAdd = [
  3156. 'content' => serialize($aContent),
  3157. 'status_admin' => $this->getStatusAdmin()
  3158. ];
  3159. //--- Process Privacy ---//
  3160. if(isset($oForm->aInputs[$CNF['FIELD_OBJECT_PRIVACY_VIEW']])) {
  3161. $iObjectPrivacyView = (int)$oForm->getCleanValue('object_privacy_view');
  3162. $iObjectPrivacyViewDefault = $this->_oConfig->getPrivacyViewDefault('object');
  3163. if(empty($iObjectPrivacyView))
  3164. $aValsToAdd = array_merge($aValsToAdd, [
  3165. 'object_privacy_view' => $iObjectPrivacyViewDefault
  3166. ]);
  3167. else if($iObjectPrivacyView < 0)
  3168. $aValsToAdd = array_merge($aValsToAdd, [
  3169. 'owner_id' => abs($iObjectPrivacyView)
  3170. ]);
  3171. }
  3172. //--- Process Link ---//
  3173. $aLinkIds = $oForm->getCleanValue($CNF['FIELD_LINK']);
  3174. $bLinkIds = !empty($aLinkIds) && is_array($aLinkIds);
  3175. //--- Process Media ---//
  3176. $aPhotoIds = $oForm->getCleanValue($CNF['FIELD_PHOTO']);
  3177. $bPhotoIds = !empty($aPhotoIds) && is_array($aPhotoIds);
  3178. $aVideoIds = $oForm->getCleanValue($CNF['FIELD_VIDEO']);
  3179. $bVideoIds = !empty($aVideoIds) && is_array($aVideoIds);
  3180. if($bVideoIds)
  3181. $aValsToAdd[$CNF['FIELD_STATUS']] = 'awaiting';
  3182. $aFileIds = $oForm->getCleanValue($CNF['FIELD_FILE']);
  3183. $bFileIds = !empty($aFileIds) && is_array($aFileIds);
  3184. if(!$bText && !$bLinkIds && !$bPhotoIds && !$bVideoIds && !$bFileIds) {
  3185. $oForm->aInputs['text']['error'] = _t('_bx_timeline_txt_err_empty_post');
  3186. $oForm->setValid(false);
  3187. return $this->_prepareResponse([
  3188. 'form' => $sCodeAdd . $oForm->getCode($bDynamicMode),
  3189. 'form_id' => $oForm->id
  3190. ], $bAjaxMode);
  3191. }
  3192. if($oForm->update($iId, $aValsToAdd) === false)
  3193. return ['message' => _t('_bx_timeline_txt_err_cannot_perform_action')];
  3194. $this->isAllowedEdit($aEvent, true);
  3195. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  3196. if($bText)
  3197. $oMetatags->metaAdd($iId, $sText);
  3198. $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
  3199. //--- Process Link ---//
  3200. if($bLinkIds)
  3201. foreach($aLinkIds as $iLinkId)
  3202. $this->_oDb->saveLink($iId, $iLinkId);
  3203. //--- Process Media ---//
  3204. $this->_saveMedia($CNF['FIELD_PHOTO'], $iId, $aPhotoIds, $iUserId);
  3205. $this->_saveMedia($CNF['FIELD_VIDEO'], $iId, $aVideoIds, $iUserId);
  3206. $this->_saveMedia($CNF['FIELD_FILE'], $iId, $aFileIds, $iUserId);
  3207. $this->getCacheItemObject()->removeAllByPrefix($this->_oConfig->getPrefix('cache_item') . $iId);
  3208. return [
  3209. 'id' => $iId
  3210. ];
  3211. }
  3212. return [
  3213. 'id' => $iId,
  3214. 'form' => $sCodeAdd . $oForm->getCode($bDynamicMode),
  3215. 'form_id' => $oForm->id,
  3216. 'eval' => $sJsObjectView . '.onEditPost(oData)'
  3217. ];
  3218. }
  3219. public function getFormPostObject($aParams)
  3220. {
  3221. $sFormObject = !empty($aParams['form_object']) ? $aParams['form_object'] : 'form_post';
  3222. $sFormDisplay = !empty($aParams['form_display']) ? $aParams['form_display'] : 'form_display_post_add';
  3223. $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject($sFormObject), $this->_oConfig->getObject($sFormDisplay), $this->_oTemplate);
  3224. $oForm->aFormAttrs = bx_replace_markers($oForm->aFormAttrs, [
  3225. 'js_object_post' => $this->_oConfig->getJsObject('post')
  3226. ]);
  3227. /**
  3228. * Note. 'ajax_mode' parameter isn't checked because
  3229. * timeline post form works as Ajax form by default.
  3230. */
  3231. $sParamsKey = 'visibility_autoselect';
  3232. if(isset($aParams[$sParamsKey]) && (bool)$aParams[$sParamsKey] === true)
  3233. $oForm->setVisibilityAutoselect((bool)$aParams[$sParamsKey]);
  3234. $oForm->init();
  3235. return $oForm;
  3236. }
  3237. public function getCmtsObject($sSystem, $iId)
  3238. {
  3239. if(empty($sSystem) || (int)$iId == 0)
  3240. return false;
  3241. $oCmts = BxDolCmts::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  3242. if(!$oCmts || !$oCmts->isEnabled())
  3243. return false;
  3244. return $oCmts;
  3245. }
  3246. public function getViewObject($sSystem, $iId)
  3247. {
  3248. if(empty($sSystem) || (int)$iId == 0)
  3249. return false;
  3250. $oView = BxDolView::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  3251. if(!$oView || !$oView->isEnabled())
  3252. return false;
  3253. return $oView;
  3254. }
  3255. public function getVoteObject($sSystem, $iId)
  3256. {
  3257. if(empty($sSystem) || (int)$iId == 0)
  3258. return false;
  3259. $oVote = BxDolVote::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  3260. if(!$oVote || !$oVote->isEnabled())
  3261. return false;
  3262. return $oVote;
  3263. }
  3264. public function getReactionObject($sSystem, $iId)
  3265. {
  3266. if(empty($sSystem) || (int)$iId == 0)
  3267. return false;
  3268. $oReaction = BxDolVote::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  3269. if(!$oReaction || !$oReaction->isEnabled())
  3270. return false;
  3271. return $oReaction;
  3272. }
  3273. public function getScoreObject($sSystem, $iId)
  3274. {
  3275. if(empty($sSystem) || (int)$iId == 0)
  3276. return false;
  3277. $oScore = BxDolScore::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  3278. if(!$oScore || !$oScore->isEnabled())
  3279. return false;
  3280. return $oScore;
  3281. }
  3282. public function getReportObject($sSystem, $iId)
  3283. {
  3284. if(empty($sSystem) || (int)$iId == 0)
  3285. return false;
  3286. $oReport = BxDolReport::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  3287. if(!$oReport || !$oReport->isEnabled())
  3288. return false;
  3289. return $oReport;
  3290. }
  3291. public function getAttachmentsMenuObject()
  3292. {
  3293. return BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_post_attachments'), $this->_oTemplate);
  3294. }
  3295. public function getManageMenuObject()
  3296. {
  3297. return BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_manage'), $this->_oTemplate);
  3298. }
  3299. public function getCacheItemObject()
  3300. {
  3301. $oCacheEngine = bx_instance('BxDolCache' . $this->_oConfig->getCacheItemEngine());
  3302. if(!$oCacheEngine->isAvailable())
  3303. $oCacheEngine = bx_instance('BxDolCacheFile');
  3304. return $oCacheEngine;
  3305. }
  3306. public function getConnectionMuteObject()
  3307. {
  3308. return BxDolConnection::getObjectInstance($this->_oConfig->getObject('connection_mute'));
  3309. }
  3310. //--- Check permissions methods ---//
  3311. public function serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
  3312. {
  3313. if(!$iProfileId)
  3314. $iProfileId = $this->_iProfileId;
  3315. $CNF = &$this->_oConfig->CNF;
  3316. // moderator and owner always have access
  3317. $iOwnerId = (int)$aDataEntry['owner_id'];
  3318. if(!empty($iProfileId) && (abs($iOwnerId) == (int)$iProfileId || $this->isModerator()))
  3319. return CHECK_ACTION_RESULT_ALLOWED;
  3320. // check ACL
  3321. if($iOwnerId != 0 && ($oOwner = BxDolProfile::getInstanceMagic($iOwnerId)) !== false && !($oOwner instanceof BxDolProfileUndefined)) {
  3322. $mixedCheckResult = bx_srv($oOwner->getModule(), 'check_allowed_with_content_for_profile', ['view', $oOwner->getContentId(), $iProfileId]);
  3323. if($mixedCheckResult !== CHECK_ACTION_RESULT_ALLOWED)
  3324. return $mixedCheckResult;
  3325. }
  3326. // check privacy
  3327. if(!empty($CNF['OBJECT_PRIVACY_VIEW'])) {
  3328. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  3329. if($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']], $iProfileId))
  3330. return _t('_sys_access_denied_to_private_content');
  3331. }
  3332. // check alert to allow custom checks
  3333. $mixedResult = null;
  3334. bx_alert('system', 'check_allowed_view', 0, 0, array('module' => $this->getName(), 'content_info' => $aDataEntry, 'profile_id' => $iProfileId, 'override_result' => &$mixedResult));
  3335. if($mixedResult !== null)
  3336. return $mixedResult;
  3337. return CHECK_ACTION_RESULT_ALLOWED;
  3338. }
  3339. public function isModerator()
  3340. {
  3341. return $this->isModeratorForProfile((int)$this->getUserId());
  3342. }
  3343. public function isModeratorForProfile($iUserId)
  3344. {
  3345. if($this->checkAllowedEditAnyEntryForProfile(false, $iUserId) === CHECK_ACTION_RESULT_ALLOWED)
  3346. return true;
  3347. if($this->checkAllowedDeleteAnyEntryForProfile(false, $iUserId) === CHECK_ACTION_RESULT_ALLOWED)
  3348. return true;
  3349. return false;
  3350. }
  3351. public function isAllowedPost($bPerform = false)
  3352. {
  3353. if(isAdmin())
  3354. return true;
  3355. $iUserId = $this->getUserId();
  3356. $aCheckResult = checkActionModule($iUserId, 'post', $this->getName(), $bPerform);
  3357. if($aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  3358. return $aCheckResult[CHECK_ACTION_MESSAGE];
  3359. if(!empty($this->_iOwnerId) && ($oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId)) !== false) {
  3360. if($oProfileOwner->checkAllowedPostInProfile($this->_iOwnerId, $this->getName()) !== CHECK_ACTION_RESULT_ALLOWED)
  3361. return _t('_sys_txt_access_denied');
  3362. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_post', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  3363. }
  3364. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  3365. }
  3366. public function isAllowedView($aEvent, $bPerform = false)
  3367. {
  3368. $CNF = $this->_oConfig->CNF;
  3369. if((int)$aEvent[$CNF['FIELD_OWNER_ID']] == 0)
  3370. return true;
  3371. $oProfileOwner = BxDolProfile::getInstance($aEvent[$CNF['FIELD_OWNER_ID']]);
  3372. if($oProfileOwner && $oProfileOwner->checkAllowedProfileView() !== CHECK_ACTION_RESULT_ALLOWED)
  3373. return false;
  3374. $oPrivacy = BxDolPrivacy::getObjectInstance($this->_oConfig->getObject('privacy_view'));
  3375. if(!$oPrivacy)
  3376. return true;
  3377. $oPrivacy->setTableFieldAuthor($this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? 'owner_id' : 'object_id');
  3378. return $oPrivacy->check($aEvent[$CNF['FIELD_ID']]);
  3379. }
  3380. public function isAllowedEdit($aEvent, $bPerform = false)
  3381. {
  3382. if(!isLogged())
  3383. return false;
  3384. //--- System posts and Reposts cannot be edited at all.
  3385. if(!$this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) || $aEvent['type'] == $this->_oConfig->getPrefix('common_post') . 'repost')
  3386. return false;
  3387. if(isAdmin())
  3388. return true;
  3389. $iUserId = (int)$this->getUserId();
  3390. $iOwnerId = (int)$aEvent['owner_id'];
  3391. $iObjectId = abs((int)$aEvent['object_id']);
  3392. if($iObjectId == $iUserId && $this->_oConfig->isAllowEdit())
  3393. return true;
  3394. $aCheckResult = checkActionModule($iUserId, 'edit', $this->getName(), $bPerform);
  3395. if(!empty($iOwnerId) && ($oProfileOwner = BxDolProfile::getInstance($iOwnerId)) !== false) {
  3396. if(BxDolService::call($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'edit_any')) === CHECK_ACTION_RESULT_ALLOWED)
  3397. return true;
  3398. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_edit', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  3399. }
  3400. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  3401. }
  3402. public function isAllowedDelete($aEvent, $bPerform = false)
  3403. {
  3404. if(!isLogged())
  3405. return false;
  3406. if(isAdmin())
  3407. return true;
  3408. $iUserId = (int)$this->getUserId();
  3409. $iOwnerId = (int)$aEvent['owner_id'];
  3410. $iObjectId = abs((int)$aEvent['object_id']);
  3411. if((($iOwnerId == $iUserId && $this->_oConfig->isAllowDelete()) || ($this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) && $iObjectId == $iUserId)))
  3412. return true;
  3413. $aCheckResult = checkActionModule($iUserId, 'delete', $this->getName(), $bPerform);
  3414. if(!empty($iOwnerId) && ($oProfileOwner = BxDolProfile::getInstance($iOwnerId)) !== false) {
  3415. if(BxDolService::call($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'delete_any')) === CHECK_ACTION_RESULT_ALLOWED)
  3416. return true;
  3417. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_delete', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  3418. }
  3419. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  3420. }
  3421. public function isAllowedComment($aEvent, $bPerform = false)
  3422. {
  3423. $mixedComments = $this->getCommentsData($aEvent['comments']);
  3424. if($mixedComments === false)
  3425. return false;
  3426. list($sSystem, $iObjectId, $iCount) = $mixedComments;
  3427. $oCmts = $this->getCmtsObject($sSystem, $iObjectId);
  3428. if($oCmts->isViewAllowed() !== CHECK_ACTION_RESULT_ALLOWED || ($iCount == 0 && !$oCmts->isPostAllowed()))
  3429. return false;
  3430. $oCmts->addCssJs();
  3431. return true;
  3432. }
  3433. public function isAllowedViewCounter($aEvent, $bPerform = false)
  3434. {
  3435. $mixedViews = $this->getViewsData($aEvent['views']);
  3436. if($mixedViews === false)
  3437. return false;
  3438. list($sSystem, $iObjectId) = $mixedViews;
  3439. $oView = $this->getViewObject($sSystem, $iObjectId);
  3440. if(!$oView->isAllowedViewView($bPerform))
  3441. return false;
  3442. $bResult = true;
  3443. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  3444. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view_counter', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  3445. return $bResult;
  3446. }
  3447. public function isAllowedVote($aEvent, $bPerform = false)
  3448. {
  3449. $mixedVotes = $this->getVotesData($aEvent['votes']);
  3450. if($mixedVotes === false)
  3451. return false;
  3452. list($sSystem, $iObjectId) = $mixedVotes;
  3453. $oVote = $this->getVoteObject($sSystem, $iObjectId);
  3454. if(!$oVote->isAllowedVote($bPerform))
  3455. return false;
  3456. $bResult = true;
  3457. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  3458. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  3459. return $bResult;
  3460. }
  3461. public function isAllowedVoteView($aEvent, $bPerform = false)
  3462. {
  3463. $mixedVotes = $this->getVotesData($aEvent['votes']);
  3464. if($mixedVotes === false)
  3465. return false;
  3466. list($sSystem, $iObjectId) = $mixedVotes;
  3467. $oVote = $this->getVoteObject($sSystem, $iObjectId);
  3468. if(!$oVote->isAllowedVoteView($bPerform))
  3469. return false;
  3470. $bResult = true;
  3471. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  3472. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote_view', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  3473. return $bResult;
  3474. }
  3475. public function isAllowedReaction($aEvent, $bPerform = false)
  3476. {
  3477. $mixedReactions = $this->getReactionsData($aEvent['reactions']);
  3478. if($mixedReactions === false)
  3479. return false;
  3480. list($sSystem, $iObjectId) = $mixedReactions;
  3481. $oReaction = $this->getReactionObject($sSystem, $iObjectId);
  3482. if(!$oReaction->isAllowedVote($bPerform))
  3483. return false;
  3484. $bResult = true;
  3485. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  3486. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_reaction', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  3487. return $bResult;
  3488. }
  3489. public function isAllowedReactionView($aEvent, $bPerform = false)
  3490. {
  3491. $mixedReactions = $this->getReactionsData($aEvent['reactions']);
  3492. if($mixedReactions === false)
  3493. return false;
  3494. list($sSystem, $iObjectId) = $mixedReactions;
  3495. $oReaction = $this->getReactionObject($sSystem, $iObjectId);
  3496. if(!$oReaction->isAllowedVoteView($bPerform))
  3497. return false;
  3498. $bResult = true;
  3499. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  3500. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_reaction_view', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  3501. return $bResult;
  3502. }
  3503. public function isAllowedScore($aEvent, $bPerform = false)
  3504. {
  3505. $mixedScores = $this->getScoresData($aEvent['scores']);
  3506. if($mixedScores === false)
  3507. return false;
  3508. list($sSystem, $iObjectId) = $mixedScores;
  3509. $oScore = $this->getScoreObject($sSystem, $iObjectId);
  3510. if(!$oScore->isAllowedVote($bPerform))
  3511. return false;
  3512. $bResult = true;
  3513. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  3514. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_score', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  3515. return $bResult;
  3516. }
  3517. public function isAllowedReport($aEvent, $bPerform = false)
  3518. {
  3519. $mixedReports = $this->getReportsData($aEvent['reports']);
  3520. if($mixedReports === false)
  3521. return false;
  3522. list($sSystem, $iObjectId) = $mixedReports;
  3523. $oReport = $this->getReportObject($sSystem, $iObjectId);
  3524. if(!$oReport->isAllowedReport($bPerform))
  3525. return false;
  3526. $bResult = true;
  3527. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  3528. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_report', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
  3529. return $bResult;
  3530. }
  3531. public function isAllowedRepost($aEvent, $bPerform = false)
  3532. {
  3533. $mixedResult = $this->_isAllowedRepost($aEvent, $bPerform);
  3534. bx_alert($this->getName(), 'is_allowed_repost', 0, 0, [
  3535. 'content_info' => $aEvent,
  3536. 'override_result' => &$mixedResult
  3537. ]);
  3538. return $mixedResult;
  3539. }
  3540. public function isAllowedSend($aEvent, $bPerform = false)
  3541. {
  3542. if(!$this->_oDb->isEnabledByName('bx_convos'))
  3543. return false;
  3544. if(isAdmin())
  3545. return true;
  3546. $iUserId = (int)$this->getUserId();
  3547. if($iUserId == 0)
  3548. return false;
  3549. $aCheckResult = checkActionModule($iUserId, 'send', $this->getName(), $bPerform);
  3550. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  3551. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_send', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  3552. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  3553. }
  3554. public function isAllowedMute($aEvent, $bPerform = false)
  3555. {
  3556. $CNF = &$this->_oConfig->CNF;
  3557. if(!empty($aEvent[$CNF['FIELD_OWNER_ID']]) && $aEvent[$CNF['FIELD_OWNER_ID']] != $this->_iProfileId)
  3558. return false;
  3559. $iAuthor = (int)$aEvent[$CNF['FIELD_OWNER_ID']];
  3560. if(!$this->_oConfig->isSystem($aEvent['type'], $aEvent['action']))
  3561. $iAuthor = (int)$aEvent[$CNF['FIELD_OBJECT_ID']];
  3562. if($this->_iProfileId == $iAuthor || $this->getConnectionMuteObject()->isConnected($this->_iProfileId, $iAuthor))
  3563. return false;
  3564. return $this->_isAllowedMute($bPerform);
  3565. }
  3566. public function isAllowedUnmute($iAuthor, $bPerform = false)
  3567. {
  3568. if(!$this->getConnectionMuteObject()->isConnected($this->_iProfileId, $iAuthor))
  3569. return false;
  3570. return $this->_isAllowedMute($bPerform);
  3571. }
  3572. /**
  3573. * Pin - "Pin here" - pin the post on Profile Timeline for profile owner.
  3574. * Can be done by profile owner for himself or by admin for profile owner to see.
  3575. * @param type $aEvent
  3576. * @param type $bPerform
  3577. * @return boolean
  3578. */
  3579. public function isAllowedPin($aEvent, $bPerform = false)
  3580. {
  3581. if((int)$aEvent['pinned'] != 0)
  3582. return false;
  3583. return $this->_isAllowedPin($aEvent, $bPerform);
  3584. }
  3585. public function isAllowedUnpin($aEvent, $bPerform = false)
  3586. {
  3587. if((int)$aEvent['pinned'] == 0)
  3588. return false;
  3589. return $this->_isAllowedPin($aEvent, $bPerform);
  3590. }
  3591. /**
  3592. * Stick - "Pin for All" - pin the post on Public Timeline for everybody to see.
  3593. * Is available for Administrators/Moderators only.
  3594. * @param type $aEvent
  3595. * @param type $bPerform
  3596. * @return boolean
  3597. */
  3598. public function isAllowedStick($aEvent, $bPerform = false)
  3599. {
  3600. if((int)$aEvent['sticked'] != 0)
  3601. return false;
  3602. return $this->_isAllowedStick($aEvent, $bPerform);
  3603. }
  3604. public function isAllowedUnstick($aEvent, $bPerform = false)
  3605. {
  3606. if((int)$aEvent['sticked'] == 0)
  3607. return false;
  3608. return $this->_isAllowedStick($aEvent, $bPerform);
  3609. }
  3610. public function isAllowedPromote($aEvent, $bPerform = false)
  3611. {
  3612. if((int)$aEvent['promoted'] != 0)
  3613. return false;
  3614. return $this->_isAllowedPromote($aEvent, $bPerform);
  3615. }
  3616. public function isAllowedUnpromote($aEvent, $bPerform = false)
  3617. {
  3618. if((int)$aEvent['promoted'] == 0)
  3619. return false;
  3620. return $this->_isAllowedPromote($aEvent, $bPerform);
  3621. }
  3622. public function isAllowedNotes($aEvent, $bPerform = false)
  3623. {
  3624. return $this->isModerator();
  3625. }
  3626. public function isAllowedMore($aEvent, $bPerform = false)
  3627. {
  3628. $oMoreMenu = $this->getManageMenuObject();
  3629. if(!$oMoreMenu)
  3630. return false;
  3631. $oMoreMenu->setEvent($aEvent);
  3632. return $oMoreMenu->isVisible();
  3633. }
  3634. public function checkAllowedView ($aContentInfo, $isPerformAction = false)
  3635. {
  3636. if(!$this->isAllowedView($aContentInfo, $isPerformAction))
  3637. return _t('_sys_txt_access_denied');
  3638. return CHECK_ACTION_RESULT_ALLOWED;
  3639. }
  3640. public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false)
  3641. {
  3642. if(($mixedResult = $this->isAllowedDelete($aDataEntry, $isPerformAction)) !== true)
  3643. return is_string($mixedResult) ? $mixedResult : _t('_sys_txt_access_denied');
  3644. return CHECK_ACTION_RESULT_ALLOWED;
  3645. }
  3646. /**
  3647. * Checks if it's allowed to view a comment by checking the availability to view the content which was commented.
  3648. * Note. Don't check the related comments object for view action accessibility because this method is called from there.
  3649. */
  3650. public function checkAllowedCommentsView ($aContentInfo, $isPerformAction = false)
  3651. {
  3652. $CNF = $this->_oConfig->CNF;
  3653. $iOwner = (int)$aContentInfo[$CNF['FIELD_OWNER_ID']];
  3654. if($iOwner == 0) //--- in case of Public Timeline.
  3655. return CHECK_ACTION_RESULT_ALLOWED;
  3656. $oOwner = BxDolProfile::getInstance($iOwner);
  3657. if(!$oOwner) //--- in case of non-existed Timeline owner.
  3658. return _t('_sys_txt_access_denied');
  3659. $mixedResult = $oOwner->checkAllowedProfileView();
  3660. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
  3661. return $mixedResult;
  3662. return $this->checkAllowedView($aContentInfo, $isPerformAction);
  3663. }
  3664. /**
  3665. * Checks if it's allowed to post a comment by checking the availability to post anything in the context.
  3666. * Note. Don't check the related comments object for post action accessibility because this method is called from there.
  3667. */
  3668. public function checkAllowedCommentsPost ($aContentInfo, $isPerformAction = false)
  3669. {
  3670. $CNF = $this->_oConfig->CNF;
  3671. $iOwner = (int)$aContentInfo[$CNF['FIELD_OWNER_ID']];
  3672. if($iOwner == 0) //--- in case of Public Timeline.
  3673. return CHECK_ACTION_RESULT_ALLOWED;
  3674. $oOwner = BxDolProfile::getInstance($iOwner);
  3675. if(!$oOwner) //--- in case of non-existed Timeline owner.
  3676. return _t('_sys_txt_access_denied');
  3677. /*
  3678. * Disabled in accordance with #4238 ticket.
  3679. *
  3680. if(($mixedResult = $oOwner->checkAllowedPostInProfile()) !== CHECK_ACTION_RESULT_ALLOWED)
  3681. return $mixedResult;
  3682. */
  3683. return CHECK_ACTION_RESULT_ALLOWED;
  3684. }
  3685. public function checkAllowedEditAnyEntryForProfile ($isPerformAction = false, $iProfileId = false)
  3686. {
  3687. if(!$iProfileId)
  3688. $iProfileId = $this->_iProfileId;
  3689. $aCheck = checkActionModule($iProfileId, 'edit', $this->getName(), $isPerformAction);
  3690. if($aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  3691. return CHECK_ACTION_RESULT_ALLOWED;
  3692. return _t('_sys_txt_access_denied');
  3693. }
  3694. public function checkAllowedDeleteAnyEntryForProfile ($isPerformAction = false, $iProfileId = false)
  3695. {
  3696. if(!$iProfileId)
  3697. $iProfileId = $this->_iProfileId;
  3698. $aCheck = checkActionModule($iProfileId, 'delete', $this->getName(), $isPerformAction);
  3699. if($aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  3700. return CHECK_ACTION_RESULT_ALLOWED;
  3701. return _t('_sys_txt_access_denied');
  3702. }
  3703. public function onPost($iContentId)
  3704. {
  3705. $CNF = &$this->_oConfig->CNF;
  3706. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  3707. if($this->_oConfig->isSystem($aEvent['type'], $aEvent['action'])) {
  3708. //--- Request event's data from content module and update it in the Timeline DB.
  3709. $this->_oTemplate->getDataCached($aEvent);
  3710. $sPostType = 'system';
  3711. $iSenderId = $iObjectAuthorId = (int)$aEvent['owner_id'];
  3712. }
  3713. else {
  3714. $sPostType = 'common';
  3715. $iSenderId = $iObjectAuthorId = (int)$aEvent['object_id'];
  3716. }
  3717. //--- Event -> Post/Defer for Alerts Engine ---//
  3718. $sAction = ($aEvent[$CNF['FIELD_STATUS']] == BX_TIMELINE_STATUS_AWAITING ? 'defer' : 'post') . '_' . $sPostType;
  3719. bx_alert($this->_oConfig->getObject('alert'), $sAction, $iContentId, $iSenderId, array(
  3720. 'source' => $this->_oConfig->getName() . '_' . $iContentId,
  3721. 'owner_id' => $aEvent['owner_id'],
  3722. 'object_author_id' => $iObjectAuthorId,
  3723. 'privacy_view' => $aEvent['object_privacy_view'],
  3724. ));
  3725. //--- Event -> Post for Alerts Engine ---//
  3726. }
  3727. public function onPublished($iContentId)
  3728. {
  3729. //--- Clear Item cache
  3730. $this->getCacheItemObject()->removeAllByPrefix($this->_oConfig->getPrefix('cache_item') . $iContentId);
  3731. $this->onPost($iContentId);
  3732. }
  3733. public function onFailed($iContentId)
  3734. {
  3735. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  3736. //--- Clear Item cache
  3737. $this->getCacheItemObject()->removeAllByPrefix($this->_oConfig->getPrefix('cache_item') . $iContentId);
  3738. if($this->_oConfig->isSystem($aEvent['type'], $aEvent['action'])) {
  3739. //--- Request event's data from content module and update it in the Timeline DB.
  3740. $this->_oTemplate->getDataCached($aEvent);
  3741. $sPostType = 'system';
  3742. $iSenderId = $iObjectAuthorId = (int)$aEvent['owner_id'];
  3743. }
  3744. else {
  3745. $sPostType = 'common';
  3746. $iSenderId = $iObjectAuthorId = (int)$aEvent['object_id'];
  3747. }
  3748. //--- Event -> Fail for Alerts Engine ---//
  3749. bx_alert($this->_oConfig->getObject('alert'), 'fail_' . $sPostType, $iContentId, $iSenderId, array(
  3750. 'owner_id' => $aEvent['owner_id'],
  3751. 'object_author_id' => $iObjectAuthorId,
  3752. 'privacy_view' => $aEvent['object_privacy_view'],
  3753. ));
  3754. //--- Event -> Post for Alerts Engine ---//
  3755. }
  3756. public function onRepost($iContentId, $aReposted = array())
  3757. {
  3758. $CNF = &$this->_oConfig->CNF;
  3759. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  3760. if(empty($aReposted)) {
  3761. $aContent = unserialize($aEvent['content']);
  3762. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  3763. if(empty($aReposted) || !is_array($aReposted))
  3764. return;
  3765. }
  3766. $iUserId = (int)$aEvent[$CNF['FIELD_OBJECT_OWNER_ID']];
  3767. $this->_oDb->insertRepostTrack($aEvent['id'], $iUserId, $this->getUserIp(), $aReposted['id']);
  3768. $this->_oDb->updateRepostCounter($aReposted['id'], $aReposted['reposts']);
  3769. //--- Timeline -> Update for Alerts Engine ---//
  3770. bx_alert($this->_oConfig->getObject('alert'), 'repost', $aReposted['id'], $iUserId, array(
  3771. 'privacy_view' => $aEvent['object_privacy_view'],
  3772. 'object_author_id' => $aReposted['owner_id'],
  3773. 'repost_id' => $iContentId,
  3774. ));
  3775. //--- Timeline -> Update for Alerts Engine ---//
  3776. }
  3777. public function onHide($aEvent)
  3778. {
  3779. $CNF = &$this->_oConfig->CNF;
  3780. $iUserId = $this->getUserId();
  3781. $sCommonPostPrefix = $this->_oConfig->getPrefix('common_post');
  3782. //--- Update parent event when repost event was deactivated.
  3783. $bRepost = $aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_REPOST;
  3784. if($bRepost) {
  3785. $this->_oDb->updateRepostTrack(['active' => 0], ['event_id' => $aEvent[$CNF['FIELD_ID']]]);
  3786. $aContent = unserialize($aEvent['content']);
  3787. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  3788. if(!empty($aReposted) && is_array($aReposted))
  3789. $this->_oDb->updateRepostCounter($aReposted[$CNF['FIELD_ID']], $aReposted['reposts'], -1);
  3790. }
  3791. //--- Find and hide repost events when parent event was deactivated.
  3792. $aRepostEvents = $this->_oDb->getEvents(['browse' => 'reposted_by_track', 'value' => $aEvent[$CNF['FIELD_ID']]]);
  3793. foreach($aRepostEvents as $aRepostEvent) {
  3794. if((int)$this->_oDb->updateEvent(['active' => 0], ['id' => (int)$aRepostEvent[$CNF['FIELD_ID']]]) == 0)
  3795. continue;
  3796. $this->_oDb->updateRepostTrack(['active' => 0], ['event_id' => $aRepostEvent[$CNF['FIELD_ID']]]);
  3797. bx_alert($this->_oConfig->getObject('alert'), 'hide_repost', $aEvent[$CNF['FIELD_ID']], $iUserId, array(
  3798. 'repost_id' => $aRepostEvent[$CNF['FIELD_ID']],
  3799. ));
  3800. }
  3801. //--- Delete associated meta for Common events.
  3802. if($this->_oConfig->isCommon($aEvent['type'], $aEvent['action'])) {
  3803. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  3804. $oMetatags->onDeleteContent($aEvent[$CNF['FIELD_ID']]);
  3805. }
  3806. //--- Delete item cache.
  3807. $sCacheItemKey = $this->_oConfig->getCacheItemKey($aEvent[$CNF['FIELD_ID']]);
  3808. $this->getCacheItemObject()->delData($sCacheItemKey);
  3809. //--- Event -> Hide for Alerts Engine ---//
  3810. if($bRepost)
  3811. bx_alert($this->_oConfig->getObject('alert'), 'hide_repost', $aReposted[$CNF['FIELD_ID']], $iUserId, array(
  3812. 'repost_id' => $aEvent[$CNF['FIELD_ID']],
  3813. ));
  3814. else
  3815. bx_alert($this->_oConfig->getObject('alert'), 'hide', $aEvent[$CNF['FIELD_ID']], $iUserId);
  3816. //--- Event -> Hide for Alerts Engine ---//
  3817. }
  3818. public function onUnhide($aEvent)
  3819. {
  3820. $CNF = &$this->_oConfig->CNF;
  3821. $iUserId = $this->getUserId();
  3822. $sCommonPostPrefix = $this->_oConfig->getPrefix('common_post');
  3823. //--- Update parent event when repost event was activated back.
  3824. $bRepost = $aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_REPOST;
  3825. if($bRepost) {
  3826. $this->_oDb->updateRepostTrack(['active' => 1], ['event_id' => $aEvent[$CNF['FIELD_ID']]]);
  3827. $aContent = unserialize($aEvent['content']);
  3828. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  3829. if(!empty($aReposted) && is_array($aReposted))
  3830. $this->_oDb->updateRepostCounter($aReposted[$CNF['FIELD_ID']], $aReposted['reposts'], 1);
  3831. }
  3832. //--- Find and hide repost events when parent event was activated back.
  3833. $aRepostEvents = $this->_oDb->getEvents(['browse' => 'reposted_by_track', 'value' => $aEvent[$CNF['FIELD_ID']]]);
  3834. foreach($aRepostEvents as $aRepostEvent) {
  3835. if((int)$this->_oDb->updateEvent(['active' => 1], ['id' => (int)$aRepostEvent[$CNF['FIELD_ID']]]) == 0)
  3836. continue;
  3837. $this->_oDb->updateRepostTrack(['active' => 1], ['event_id' => $aRepostEvent[$CNF['FIELD_ID']]]);
  3838. bx_alert($this->_oConfig->getObject('alert'), 'unhide_repost', $aEvent[$CNF['FIELD_ID']], $iUserId, array(
  3839. 'repost_id' => $aRepostEvent[$CNF['FIELD_ID']],
  3840. ));
  3841. }
  3842. //--- Process meta for Common events.
  3843. if($this->_oConfig->isCommon($aEvent['type'], $aEvent['action'])) {
  3844. $aContent = unserialize($aEvent['content']);
  3845. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  3846. if(!empty($aContent['text']))
  3847. $oMetatags->metaAdd($aEvent[$CNF['FIELD_ID']], $aContent['text']);
  3848. $oMetatags->locationsAddFromForm($aEvent[$CNF['FIELD_ID']], $CNF['FIELD_LOCATION_PREFIX']);
  3849. }
  3850. //--- Event -> Unhide for Alerts Engine ---//
  3851. if($bRepost)
  3852. bx_alert($this->_oConfig->getObject('alert'), 'unhide_repost', $aReposted[$CNF['FIELD_ID']], $iUserId, array(
  3853. 'repost_id' => $aEvent[$CNF['FIELD_ID']],
  3854. ));
  3855. else
  3856. bx_alert($this->_oConfig->getObject('alert'), 'unhide', $aEvent[$CNF['FIELD_ID']], $iUserId);
  3857. //--- Event -> Unhide for Alerts Engine ---//
  3858. }
  3859. public function onDelete($aEvent)
  3860. {
  3861. $CNF = &$this->_oConfig->CNF;
  3862. $iUserId = $this->getUserId();
  3863. $sCommonPostPrefix = $this->_oConfig->getPrefix('common_post');
  3864. $sCommonPostComment = $this->_oConfig->getObject('comment');
  3865. //--- Delete comments for Common posts.
  3866. if($this->_oConfig->isCommon($aEvent['type'], $aEvent['action'])) {
  3867. $oComments = $this->getCmtsObject($sCommonPostComment, $aEvent[$CNF['FIELD_ID']]);
  3868. if($oComments !== false)
  3869. $oComments->onObjectDelete($aEvent[$CNF['FIELD_ID']]);
  3870. }
  3871. //--- Delete attached photos, videos and links when common event was deleted.
  3872. if($aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_POST) {
  3873. $this->_deleteMedia($CNF['FIELD_PHOTO'], $aEvent[$CNF['FIELD_ID']]);
  3874. $this->_deleteMedia($CNF['FIELD_VIDEO'], $aEvent[$CNF['FIELD_ID']]);
  3875. $this->_deleteMedia($CNF['FIELD_FILE'], $aEvent[$CNF['FIELD_ID']]);
  3876. $this->_deleteLinks($aEvent[$CNF['FIELD_ID']]);
  3877. }
  3878. //--- Update parent event when repost event was deleted.
  3879. $bRepost = $aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_REPOST;
  3880. if($bRepost) {
  3881. $this->_oDb->deleteRepostTrack($aEvent[$CNF['FIELD_ID']]);
  3882. $aContent = unserialize($aEvent['content']);
  3883. $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
  3884. if(!empty($aReposted) && is_array($aReposted))
  3885. $this->_oDb->updateRepostCounter($aReposted[$CNF['FIELD_ID']], $aReposted['reposts'], -1);
  3886. }
  3887. //--- Find and delete repost events when parent event was deleted.
  3888. $aRepostEvents = $this->_oDb->getEvents(array('browse' => 'reposted_by_track', 'value' => $aEvent[$CNF['FIELD_ID']]));
  3889. foreach($aRepostEvents as $aRepostEvent) {
  3890. if((int)$this->_oDb->deleteEvent(array('id' => (int)$aRepostEvent[$CNF['FIELD_ID']])) == 0)
  3891. continue;
  3892. $this->_oDb->deleteRepostTrack($aRepostEvent[$CNF['FIELD_ID']]);
  3893. $oComments = $this->getCmtsObject($sCommonPostComment, $aRepostEvent[$CNF['FIELD_ID']]);
  3894. if($oComments !== false)
  3895. $oComments->onObjectDelete($aRepostEvent[$CNF['FIELD_ID']]);
  3896. bx_alert($this->_oConfig->getObject('alert'), 'delete_repost', $aEvent[$CNF['FIELD_ID']], $iUserId, array(
  3897. 'repost_id' => $aRepostEvent[$CNF['FIELD_ID']],
  3898. ));
  3899. }
  3900. //--- Delete associated meta for Common events.
  3901. if($this->_oConfig->isCommon($aEvent['type'], $aEvent['action'])) {
  3902. $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
  3903. $oMetatags->onDeleteContent($aEvent[$CNF['FIELD_ID']]);
  3904. }
  3905. //--- Delete item cache.
  3906. $sCacheItemKey = $this->_oConfig->getCacheItemKey($aEvent[$CNF['FIELD_ID']]);
  3907. $this->getCacheItemObject()->delData($sCacheItemKey);
  3908. //--- Event -> Delete for Alerts Engine ---//
  3909. if($bRepost)
  3910. bx_alert($this->_oConfig->getObject('alert'), 'delete_repost', $aReposted[$CNF['FIELD_ID']], $iUserId, array(
  3911. 'repost_id' => $aEvent[$CNF['FIELD_ID']],
  3912. ));
  3913. else
  3914. bx_alert($this->_oConfig->getObject('alert'), 'delete', $aEvent[$CNF['FIELD_ID']], $iUserId);
  3915. //--- Event -> Delete for Alerts Engine ---//
  3916. }
  3917. public function getParams($sView = '', $sType = '', $iOwnerId = 0, $iStart = 0, $iPerPage = 0, $sFilter = BX_TIMELINE_FILTER_ALL, $aModules = array(), $iTimeline = 0)
  3918. {
  3919. return $this->_prepareParams(array(
  3920. 'view' => $sView,
  3921. 'type' => $sType,
  3922. 'owner_id' => $iOwnerId,
  3923. 'start' => $iStart,
  3924. 'per_page' => $iPerPage,
  3925. 'timeline' => $iTimeline,
  3926. 'filter' => $sFilter,
  3927. 'modules' => $aModules
  3928. ));
  3929. }
  3930. public function getParamsExt($aParams = array())
  3931. {
  3932. return $this->_prepareParams($aParams);
  3933. }
  3934. public function getViewsData(&$aViews)
  3935. {
  3936. if(empty($aViews) || !is_array($aViews))
  3937. return false;
  3938. $sSystem = isset($aViews['system']) ? $aViews['system'] : '';
  3939. $iObjectId = isset($aViews['object_id']) ? (int)$aViews['object_id'] : 0;
  3940. $iCount = isset($aViews['count']) ? (int)$aViews['count'] : 0;
  3941. if($sSystem == '' || $iObjectId == 0)
  3942. return false;
  3943. return array($sSystem, $iObjectId, $iCount);
  3944. }
  3945. public function getVotesData(&$aVotes)
  3946. {
  3947. if(empty($aVotes) || !is_array($aVotes))
  3948. return false;
  3949. $sSystem = isset($aVotes['system']) ? $aVotes['system'] : '';
  3950. $iObjectId = isset($aVotes['object_id']) ? (int)$aVotes['object_id'] : 0;
  3951. $iCount = isset($aVotes['count']) ? (int)$aVotes['count'] : 0;
  3952. if($sSystem == '' || $iObjectId == 0)
  3953. return false;
  3954. return array($sSystem, $iObjectId, $iCount);
  3955. }
  3956. public function getReactionsData(&$aReactions)
  3957. {
  3958. if(empty($aReactions) || !is_array($aReactions))
  3959. return false;
  3960. $sSystem = isset($aReactions['system']) ? $aReactions['system'] : '';
  3961. $iObjectId = isset($aReactions['object_id']) ? (int)$aReactions['object_id'] : 0;
  3962. $iCount = isset($aReactions['count']) ? (int)$aReactions['count'] : 0;
  3963. if($sSystem == '' || $iObjectId == 0)
  3964. return false;
  3965. return array($sSystem, $iObjectId, $iCount);
  3966. }
  3967. public function getScoresData(&$aScores)
  3968. {
  3969. if(empty($aScores) || !is_array($aScores))
  3970. return false;
  3971. $sSystem = isset($aScores['system']) ? $aScores['system'] : '';
  3972. $iObjectId = isset($aScores['object_id']) ? (int)$aScores['object_id'] : 0;
  3973. $iScore = isset($aScores['score']) ? (int)$aScores['score'] : 0;
  3974. if($sSystem == '' || $iObjectId == 0)
  3975. return false;
  3976. return array($sSystem, $iObjectId, $iScore);
  3977. }
  3978. public function getReportsData(&$aReports)
  3979. {
  3980. if(empty($aReports) || !is_array($aReports))
  3981. return false;
  3982. $sSystem = isset($aReports['system']) ? $aReports['system'] : '';
  3983. $iObjectId = isset($aReports['object_id']) ? (int)$aReports['object_id'] : 0;
  3984. $iCount = isset($aReports['count']) ? (int)$aReports['count'] : 0;
  3985. if($sSystem == '' || $iObjectId == 0)
  3986. return false;
  3987. return array($sSystem, $iObjectId, $iCount);
  3988. }
  3989. public function getCommentsData(&$aComments)
  3990. {
  3991. if(empty($aComments) || !is_array($aComments))
  3992. return false;
  3993. $sSystem = isset($aComments['system']) ? $aComments['system'] : '';
  3994. $iObjectId = isset($aComments['object_id']) ? (int)$aComments['object_id'] : 0;
  3995. $iCount = isset($aComments['count']) ? (int)$aComments['count'] : 0;
  3996. if($sSystem == '' || $iObjectId == 0)
  3997. return false;
  3998. return [$sSystem, $iObjectId, $iCount];
  3999. }
  4000. public function getEventLinks($iEventId)
  4001. {
  4002. $aLinks = $this->_oDb->getLinks($iEventId);
  4003. if(empty($aLinks) || !is_array($aLinks))
  4004. return array();
  4005. $oTranscoder = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_photos_preview'));
  4006. $aResult = array();
  4007. foreach($aLinks as $aLink)
  4008. $aResult[] = array(
  4009. 'url' => $aLink['url'],
  4010. 'title' => $aLink['title'],
  4011. 'text' => $aLink['text'],
  4012. 'thumbnail' => (int)$aLink['media_id'] != 0 ? $oTranscoder->getFileUrl($aLink['media_id']) : ''
  4013. );
  4014. return $aResult;
  4015. }
  4016. public function getEventImages($iEventId)
  4017. {
  4018. $CNF = &$this->_oConfig->CNF;
  4019. $aPhotos = $this->_oDb->getMedia($CNF['FIELD_PHOTO'], $iEventId);
  4020. if(empty($aPhotos) || !is_array($aPhotos))
  4021. return [];
  4022. $oTranscoderSm = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_photos_view'));
  4023. $oTranscoderMd = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_photos_medium'));
  4024. $oTranscoderLg = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_photos_big'));
  4025. $aResult = [];
  4026. foreach($aPhotos as $iPhotoId) {
  4027. $sPhotoSrcMd = $oTranscoderMd->getFileUrl($iPhotoId);
  4028. if(empty($sPhotoSrcMd))
  4029. continue;
  4030. $sPhotoSrcSm = $oTranscoderSm->getFileUrl($iPhotoId);
  4031. if(empty($sPhotoSrcSm))
  4032. $sPhotoSrcSm = $sPhotoSrcMd;
  4033. $sPhotoSrcLg = $oTranscoderLg->getFileUrl($iPhotoId);
  4034. if(empty($sPhotoSrcLg))
  4035. $sPhotoSrcLg = $sPhotoSrcMd;
  4036. $aResult[] = [
  4037. 'id' => $iPhotoId,
  4038. 'src' => $sPhotoSrcMd,
  4039. 'src_small' => $sPhotoSrcSm,
  4040. 'src_medium' => $sPhotoSrcMd,
  4041. 'src_orig' => $sPhotoSrcLg,
  4042. ];
  4043. }
  4044. return $aResult;
  4045. }
  4046. public function getEventVideos($iEventId)
  4047. {
  4048. $CNF = &$this->_oConfig->CNF;
  4049. $aMediaIds = $this->_oDb->getMedia($CNF['FIELD_VIDEO'], $iEventId);
  4050. if(empty($aMediaIds) || !is_array($aMediaIds))
  4051. return array();
  4052. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_videos'));
  4053. $oTranscoderPoster = BxDolTranscoderVideo::getObjectInstance($this->_oConfig->getObject('transcoder_videos_poster'));
  4054. $oTranscoderMp4 = BxDolTranscoderVideo::getObjectInstance($this->_oConfig->getObject('transcoder_videos_mp4'));
  4055. $oTranscoderMp4Hd = BxDolTranscoderVideo::getObjectInstance($this->_oConfig->getObject('transcoder_videos_mp4_hd'));
  4056. $oTranscoderPhoto = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_videos_photo_view'));
  4057. $oTranscoderPhotoBig = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_videos_photo_big'));
  4058. $aResult = array();
  4059. foreach($aMediaIds as $iMediaId) {
  4060. $aMediaFile = $oStorage->getFile($iMediaId);
  4061. $bVideoFile = strncmp('video/', $aMediaFile['mime_type'], 6) === 0 && $oTranscoderPoster->isMimeTypeSupported($aMediaFile['mime_type']);
  4062. if($bVideoFile) {
  4063. $sVideoUrlHd = '';
  4064. if (!empty($aMediaFile['dimensions']) && $oTranscoderMp4Hd->isProcessHD($aMediaFile['dimensions']))
  4065. $sVideoUrlHd = $oTranscoderMp4Hd->getFileUrl($iMediaId);
  4066. $aResult[$iMediaId] = array(
  4067. 'id' => $iMediaId,
  4068. 'src_poster' => $oTranscoderPoster->getFileUrl($iMediaId),
  4069. 'src_mp4' => $oTranscoderMp4->getFileUrl($iMediaId),
  4070. 'src_mp4_hd' => $sVideoUrlHd,
  4071. );
  4072. }
  4073. $bImageFile = strncmp('image/', $aMediaFile['mime_type'], 6) === 0 && $oTranscoderPhoto->isMimeTypeSupported($aMediaFile['mime_type']);
  4074. if($bImageFile) {
  4075. $sPhotoSrc = $oTranscoderPhoto->getFileUrl($iMediaId);
  4076. $sPhotoSrcBig = $oTranscoderPhotoBig->getFileUrl($iMediaId);
  4077. if(empty($sPhotoSrcBig) && !empty($sPhotoSrc))
  4078. $sPhotoSrcBig = $sPhotoSrc;
  4079. $aResult[$iMediaId] = array(
  4080. 'id' => $iMediaId,
  4081. 'src' => $sPhotoSrc,
  4082. 'src_orig' => $sPhotoSrcBig,
  4083. );
  4084. }
  4085. }
  4086. return $aResult;
  4087. }
  4088. public function getEventFiles($iEventId)
  4089. {
  4090. $CNF = &$this->_oConfig->CNF;
  4091. $aFiles = $this->_oDb->getMedia($CNF['FIELD_FILE'], $iEventId);
  4092. if(empty($aFiles) || !is_array($aFiles))
  4093. return [];
  4094. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_files'));
  4095. $aResult = [];
  4096. foreach($aFiles as $iFileId) {
  4097. $sFileUrl = $oStorage->getFileUrlById($iFileId);
  4098. $aFileFile = $oStorage->getFile($iFileId);
  4099. $aResult[$iFileId] = [
  4100. 'id' => $iFileId,
  4101. 'src' => $this->_oTemplate->getIconUrl($oStorage->getIconNameByFileName($aFileFile['file_name'])),
  4102. 'src_medium' => '',
  4103. 'src_orig' => '',
  4104. 'url' => $sFileUrl,
  4105. 'title' => $aFileFile['file_name']
  4106. ];
  4107. }
  4108. return $aResult;
  4109. }
  4110. /**
  4111. * Protected Methods
  4112. */
  4113. protected function _serviceGetBlockView($iProfileId = 0, $aBrowseParams = array())
  4114. {
  4115. if(empty($iProfileId) && bx_get('profile_id') !== false)
  4116. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  4117. if(empty($iProfileId) && isLogged())
  4118. $iProfileId = bx_get_logged_profile_id();
  4119. $aBrowseParams['owner_id'] = $iProfileId;
  4120. $aBlock = $this->_getBlockView($aBrowseParams);
  4121. if(!empty($aBlock))
  4122. return $aBlock;
  4123. return array('content' => MsgBox(_t('_bx_timeline_txt_msg_no_results')));
  4124. }
  4125. protected function _serviceGetBlockViewProfile($sProfileModule = 'bx_persons', $iProfileContentId = 0, $aBrowseParams = array())
  4126. {
  4127. if(empty($sProfileModule))
  4128. return array();
  4129. if(empty($iProfileContentId) && bx_get('id') !== false)
  4130. $iProfileContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  4131. $oProfile = BxDolProfile::getInstanceByContentAndType($iProfileContentId, $sProfileModule);
  4132. if(empty($oProfile))
  4133. return array();
  4134. $aBrowseParams['owner_id'] = $oProfile->id();
  4135. return $this->_getBlockView($aBrowseParams);
  4136. }
  4137. protected function _serviceGetBlockViews($aBrowseParams = array())
  4138. {
  4139. $aParams = $this->_prepareParams($aBrowseParams);
  4140. if(($sType = $this->_oConfig->getUserChoice('type')) !== false)
  4141. $aParams['type'] = $sType;
  4142. $this->_iOwnerId = $aParams['owner_id'];
  4143. return $this->_oTemplate->getViewsBlock($aParams);
  4144. }
  4145. protected function _serviceGetBlockViewHome($aBrowseParams = array())
  4146. {
  4147. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . $aBrowseParams['type'] . '/';
  4148. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view_home'), $sRssUrl);
  4149. return $this->_serviceGetBlockViewByType($aBrowseParams);
  4150. }
  4151. protected function _serviceGetBlockViewHot($aBrowseParams = array())
  4152. {
  4153. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . $aBrowseParams['type'] . '/';
  4154. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view_hot'), $sRssUrl);
  4155. return $this->_serviceGetBlockViewByType($aBrowseParams);
  4156. }
  4157. protected function _serviceGetBlockViewByType($aBrowseParams = array())
  4158. {
  4159. $aParams = $this->_prepareParams($aBrowseParams);
  4160. $this->_iOwnerId = $aParams['owner_id'];
  4161. return bx_is_api() ? [['id' => 1, 'type' => 'browse', 'data' => [
  4162. 'unit' => 'feed',
  4163. 'params' => $aParams,
  4164. 'data' => $this->_oTemplate->getViewBlock($aParams)]],
  4165. ] : ['content' => $this->_oTemplate->getViewBlock($aParams)];
  4166. }
  4167. protected function _getBlockPost($iProfileId, $aParams = array())
  4168. {
  4169. $this->_iOwnerId = $iProfileId;
  4170. if($this->isAllowedPost() !== true)
  4171. return array();
  4172. return array(
  4173. 'content' => $this->_oTemplate->getPostBlock($this->_iOwnerId, $aParams)
  4174. );
  4175. }
  4176. protected function _getBlockView($aBrowseParams = array())
  4177. {
  4178. if(empty($aBrowseParams['owner_id']))
  4179. return array();
  4180. $aParams = $this->_prepareParams($aBrowseParams);
  4181. if(empty($aParams['per_page']))
  4182. $aParams['per_page'] = $this->_oConfig->getPerPage('profile');
  4183. $this->_iOwnerId = $aParams['owner_id'];
  4184. $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
  4185. if(!$oProfileOwner)
  4186. return array();
  4187. $mixedResult = $oProfileOwner->checkAllowedProfileView();
  4188. if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED) {
  4189. $this->_oTemplate->displayAccessDenied($mixedResult);
  4190. exit;
  4191. }
  4192. $sUserName = $this->getObjectUser($aParams['owner_id'])->getDisplayName();
  4193. $sView = $aParams['view'];
  4194. $sRssUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . BX_BASE_MOD_NTFS_TYPE_OWNER . '/' . $this->_iOwnerId . '/';
  4195. $sJsObject = $this->_oConfig->getJsObjectView($aParams);
  4196. $aMenu = array(
  4197. 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),
  4198. 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)),
  4199. 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')),
  4200. array('id' => $sView . '-get-rss', 'name' => $sView . '-get-rss', 'class' => '', 'link' => $sRssUrl, 'onclick' => '', 'target' => '_blank', 'title' => _t('_bx_timeline_menu_item_get_rss')),
  4201. );
  4202. $sContent = '';
  4203. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view', $this->_iOwnerId, $this->getUserId(), array('override_content' => &$sContent, 'params' => &$aParams, 'menu' => &$aMenu));
  4204. $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> $sView . '-view-all', 'menu_items' => $aMenu));
  4205. $oMenu->setSelected('', $sView . '-view-all');
  4206. if (!$sContent)
  4207. $sContent = $this->_oTemplate->getViewBlock($aParams);
  4208. BxDolTemplate::getInstance()->addPageRssLink(_t('_bx_timeline_page_title_view'), $sRssUrl);
  4209. return array('content' => $sContent, 'menu' => $oMenu);
  4210. }
  4211. protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
  4212. {
  4213. $CNF = &$this->_oConfig->CNF;
  4214. $iId = (int)$aContentInfo[$CNF['FIELD_ID']];
  4215. $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iId));
  4216. $sText = '';
  4217. if(isset($aContentInfo['content'])){
  4218. $aTmp = unserialize($aContentInfo['content']);
  4219. if(isset($aTmp['text']))
  4220. $sText = $aTmp['text'];
  4221. }
  4222. if(empty($sText) && !empty($aContentInfo[$CNF['FIELD_TITLE']]))
  4223. $sText = $aContentInfo[$CNF['FIELD_TITLE']];
  4224. if(!empty($CNF['OBJECT_METATAGS']) && !empty($sText)) {
  4225. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  4226. $sText = $oMetatags->metaParse($iId, $sText);
  4227. }
  4228. return array(
  4229. 'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
  4230. 'sample_wo_article' => $CNF['T']['txt_sample_single'],
  4231. 'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
  4232. 'url' => $sUrl,
  4233. 'title' => '',
  4234. 'text' => $sText,
  4235. 'links' => $this->getEventLinks($iId),
  4236. 'images' => array(),
  4237. 'images_attach' => $this->getEventImages($iId),
  4238. 'videos' => array(),
  4239. 'videos_attach' => $this->getEventVideos($iId),
  4240. 'files' => array(),
  4241. 'files_attach' => $this->getEventFiles($iId)
  4242. );
  4243. }
  4244. protected function _isAllowedRepost($aEvent, $bPerform = false)
  4245. {
  4246. $iUserId = (int)$this->getUserId();
  4247. if($iUserId == 0)
  4248. return false;
  4249. $iPrivacy = (int)$aEvent['object_privacy_view'];
  4250. if($iPrivacy >= 0 && !in_array($iPrivacy, [BX_DOL_PG_ALL, BX_DOL_PG_MEMBERS]))
  4251. return false;
  4252. if(isAdmin())
  4253. return true;
  4254. $aCheckResult = checkActionModule($iUserId, 'repost', $this->getName(), $bPerform);
  4255. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  4256. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_repost', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  4257. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  4258. }
  4259. protected function _isAllowedMute($bPerform = false)
  4260. {
  4261. if($this->_iProfileId == 0)
  4262. return false;
  4263. if(isAdmin())
  4264. return true;
  4265. $aCheckResult = checkActionModule($this->_iProfileId, 'mute', $this->getName(), $bPerform);
  4266. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  4267. }
  4268. protected function _isAllowedPin($aEvent, $bPerform = false)
  4269. {
  4270. $iUserId = (int)$this->getUserId();
  4271. if($iUserId == 0)
  4272. return false;
  4273. if(isAdmin() || (int)$aEvent['owner_id'] == $iUserId || ((int)$aEvent['owner_id'] == 0 && $this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) && (int)$aEvent['object_id'] == $iUserId))
  4274. return true;
  4275. $aCheckResult = checkActionModule($iUserId, 'pin', $this->getName(), $bPerform);
  4276. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false) {
  4277. if (BxDolService::call($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'pin')) === CHECK_ACTION_RESULT_ALLOWED) {
  4278. return true;
  4279. }
  4280. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_pin', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  4281. }
  4282. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  4283. }
  4284. protected function _isAllowedStick($aEvent, $bPerform = false)
  4285. {
  4286. $iUserId = (int)$this->getUserId();
  4287. if($iUserId == 0)
  4288. return false;
  4289. if(isAdmin())
  4290. return true;
  4291. $aCheckResult = checkActionModule($iUserId, 'stick', $this->getName(), $bPerform);
  4292. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  4293. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_stick', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  4294. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  4295. }
  4296. protected function _isAllowedPromote($aEvent, $bPerform = false)
  4297. {
  4298. if(isAdmin())
  4299. return true;
  4300. $iUserId = (int)$this->getUserId();
  4301. if($iUserId == 0)
  4302. return false;
  4303. $aCheckResult = checkActionModule($iUserId, 'promote', $this->getName(), $bPerform);
  4304. if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
  4305. bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_promote', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
  4306. return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
  4307. }
  4308. protected function _addLink(&$oForm)
  4309. {
  4310. $iUserId = $this->getUserId();
  4311. $iEventId = (int)$oForm->getCleanValue('event_id');
  4312. $sLink = rtrim($oForm->getCleanValue('url'), '/');
  4313. $sHost = parse_url($sLink, PHP_URL_HOST);
  4314. if ($sHost && is_private_ip(gethostbyname($sHost)))
  4315. return array('message' => _t('_sys_txt_error_occured'));
  4316. $aMatches = array();
  4317. preg_match($this->_oConfig->getPregPattern('url'), $sLink, $aMatches);
  4318. $sLink = (empty($aMatches[2]) ? 'http://' : '') . $aMatches[0];
  4319. $aSiteInfo = bx_get_site_info($sLink, array(
  4320. 'thumbnailUrl' => array('tag' => 'link', 'content_attr' => 'href'),
  4321. 'OGImage' => array('name_attr' => 'property', 'name' => 'og:image'),
  4322. ));
  4323. $sTitle = !empty($aSiteInfo['title']) ? $aSiteInfo['title'] : _t('_Empty');
  4324. $sDescription = !empty($aSiteInfo['description']) ? $aSiteInfo['description'] : _t('_Empty');
  4325. $sMediaUrl = '';
  4326. if(!empty($aSiteInfo['thumbnailUrl']))
  4327. $sMediaUrl = $aSiteInfo['thumbnailUrl'];
  4328. else if(!empty($aSiteInfo['OGImage']))
  4329. $sMediaUrl = $aSiteInfo['OGImage'];
  4330. $iMediaId = 0;
  4331. $oStorage = null;
  4332. if(!empty($sMediaUrl)) {
  4333. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'));
  4334. $iMediaId = $oStorage->storeFileFromUrl($sMediaUrl, true, $iUserId);
  4335. }
  4336. $iId = (int)$oForm->insert(array('profile_id' => $iUserId, 'media_id' => $iMediaId, 'url' => $sLink, 'title' => $sTitle, 'text' => $sDescription, 'added' => time()));
  4337. if(!empty($iId)) {
  4338. if(!empty($oStorage) && !empty($iMediaId))
  4339. $oStorage->afterUploadCleanup($iMediaId, $iUserId);
  4340. return array(
  4341. 'id' => $iId,
  4342. 'event_id' => $iEventId,
  4343. 'url' => $sLink,
  4344. 'item' => $this->_oTemplate->getAttachLinkItem($iUserId, $iId)
  4345. );
  4346. }
  4347. return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
  4348. }
  4349. protected function _deleteLinks($iId)
  4350. {
  4351. $aLinks = $this->_oDb->getLinks($iId);
  4352. if(empty($aLinks) || !is_array($aLinks))
  4353. return;
  4354. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'));
  4355. foreach($aLinks as $aLink)
  4356. if(!empty($aLink['media_id']))
  4357. $oStorage->deleteFile($aLink['media_id']);
  4358. $this->_oDb->deleteLinks($iId);
  4359. }
  4360. protected function _saveMedia($sType, $iContentId, $aItemIds, $iProfileId = 0, $isAssociateWithContent = false)
  4361. {
  4362. if(empty($iContentId))
  4363. return;
  4364. if(!$isAssociateWithContent)
  4365. $this->_oDb->deleteMedia($sType, $iContentId);
  4366. if(empty($aItemIds) || !is_array($aItemIds))
  4367. return;
  4368. if(empty($iProfileId))
  4369. $iProfileId = $this->_iProfileId;
  4370. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
  4371. $aGhostFiles = $oStorage->getGhosts ($iProfileId, !$isAssociateWithContent ? $iContentId : 0, true, $this->_isModerator());
  4372. if(empty($aGhostFiles) || !is_array($aGhostFiles))
  4373. return;
  4374. foreach($aGhostFiles as $aFile) {
  4375. if(is_array($aItemIds) && !in_array($aFile['id'], $aItemIds))
  4376. continue;
  4377. $iFileId = (int)$aFile['id'];
  4378. if($aFile['private'])
  4379. $oStorage->setFilePrivate($iFileId, 1);
  4380. $oStorage->updateGhostsContentId($iFileId, $iProfileId, $iContentId, $this->_isModerator());
  4381. $this->_oDb->saveMedia($sType, $iContentId, $iFileId);
  4382. }
  4383. }
  4384. protected function _deleteMedia($sType, $iContentId)
  4385. {
  4386. $aItems = $this->_oDb->getMedia($sType, $iContentId);
  4387. if(empty($aItems) || !is_array($aItems))
  4388. return;
  4389. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_' . strtolower($sType) . 's'));
  4390. foreach($aItems as $iItemId)
  4391. $oStorage->deleteFile($iItemId);
  4392. $this->_oDb->deleteMedia($sType, $iContentId);
  4393. }
  4394. protected function _prepareParams($aParams)
  4395. {
  4396. if(empty($aParams['name']))
  4397. $aParams['name'] = '';
  4398. if(empty($aParams['view']))
  4399. $aParams['view'] = BX_TIMELINE_VIEW_DEFAULT;
  4400. if(empty($aParams['type']))
  4401. $aParams['type'] = BX_TIMELINE_TYPE_DEFAULT;
  4402. if(empty($aParams['owner_id']))
  4403. $aParams['owner_id'] = $this->getUserId();
  4404. if(!isset($aParams['start']) || (int)$aParams['start'] < 0)
  4405. $aParams['start'] = 0;
  4406. if(!isset($aParams['per_page']) || (int)$aParams['per_page'] <= 0)
  4407. $aParams['per_page'] = isset($aParams['per_page_default']) && (int)$aParams['per_page_default'] > 0 ? $aParams['per_page_default'] : $this->_oConfig->getPerPage();
  4408. if(empty($aParams['timeline']) || (int)$aParams['timeline'] < 0)
  4409. $aParams['timeline'] = 0;
  4410. if(empty($aParams['filter']))
  4411. $aParams['filter'] = BX_TIMELINE_FILTER_ALL;
  4412. if(empty($aParams['modules']) || !is_array($aParams['modules']))
  4413. $aParams['modules'] = array();
  4414. if(empty($aParams['context']))
  4415. $aParams['context'] = 0;
  4416. if(empty($aParams['blink']) || !is_array($aParams['blink']))
  4417. $aParams['blink'] = array();
  4418. $iViewerId = $this->getUserId();
  4419. if(empty($aParams['viewer_id']) || (int)$aParams['viewer_id'] != $iViewerId)
  4420. $aParams['viewer_id'] = $iViewerId;
  4421. $aParams = array_merge($aParams, array(
  4422. 'browse' => 'list',
  4423. 'status' => BX_TIMELINE_STATUS_ACTIVE,
  4424. 'moderator' => $this->isModeratorForProfile($aParams['viewer_id']),
  4425. 'dynamic_mode' => false,
  4426. ));
  4427. return $aParams;
  4428. }
  4429. protected function _prepareParamsGet($mParams = false)
  4430. {
  4431. $aKeys = ['name', 'view', 'type', 'owner_id', 'start', 'per_page', 'timeline', 'filter', 'modules', 'context', 'blink', 'viewer_id'];
  4432. $aParams = [];
  4433. if(!empty($mParams) && is_array($mParams))
  4434. foreach($aKeys as $sKey)
  4435. $aParams[$sKey] = isset($mParams[$sKey]) ? $mParams[$sKey] : false;
  4436. else
  4437. foreach($aKeys as $sKey)
  4438. $aParams[$sKey] = bx_get($sKey);
  4439. $aParams['name'] = $this->_oConfig->processParam($aParams['name']);
  4440. $aParams['view'] = $this->_oConfig->processParamWithDefault($aParams['view'], BX_TIMELINE_VIEW_DEFAULT);
  4441. $aParams['type'] = $this->_oConfig->processParamWithDefault($aParams['type'], BX_TIMELINE_TYPE_DEFAULT);
  4442. $aParams['owner_id'] = $aParams['owner_id'] !== false ? bx_process_input($aParams['owner_id'], BX_DATA_INT) : $this->getUserId();
  4443. $aParams['start'] = $aParams['start'] !== false ? bx_process_input($aParams['start'], BX_DATA_INT) : 0;
  4444. $aParams['per_page'] = $aParams['per_page'] !== false ? bx_process_input($aParams['per_page'], BX_DATA_INT) : $this->_oConfig->getPerPage();
  4445. $aParams['timeline'] = $aParams['timeline'] !== false ? bx_process_input($aParams['timeline']) : '';
  4446. $aParams['filter'] = $aParams['filter'] !== false ? bx_process_input($aParams['filter'], BX_DATA_TEXT) : BX_TIMELINE_FILTER_ALL;
  4447. $aParams['modules'] = $aParams['modules'] !== false ? bx_process_input($aParams['modules'], BX_DATA_TEXT) : [];
  4448. $aParams['context'] = $aParams['context'] !== false ? bx_process_input($aParams['context'], BX_DATA_INT) : 0;
  4449. if($aParams['blink'] !== false)
  4450. $aParams['blink'] = bx_process_input(is_string($aParams['blink']) ? explode(',', $aParams['blink']) : $aParams['blink'], BX_DATA_TEXT);
  4451. else
  4452. $aParams['blink'] = [];
  4453. $iViewerId = $this->getUserId();
  4454. if($aParams['viewer_id'] !== false)
  4455. $aParams['viewer_id'] = bx_process_input($aParams['viewer_id'], BX_DATA_INT);
  4456. if(!$aParams['viewer_id'] || $aParams['viewer_id'] != $iViewerId)
  4457. $aParams['viewer_id'] = $iViewerId;
  4458. $aParams = array_merge($aParams, [
  4459. 'browse' => 'list',
  4460. 'status' => BX_TIMELINE_STATUS_ACTIVE,
  4461. 'moderator' => $this->isModeratorForProfile($aParams['viewer_id']),
  4462. 'dynamic_mode' => true,
  4463. ]);
  4464. return $aParams;
  4465. }
  4466. protected function _prepareTextForSave($s)
  4467. {
  4468. return bx_process_input($s, BX_DATA_HTML);
  4469. }
  4470. protected function _prepareFormForAutoSubmit(&$oForm, &$aValues)
  4471. {
  4472. $oForm->aFormAttrs['method'] = BX_DOL_FORM_METHOD_SPECIFIC;
  4473. $oForm->aParams['csrf']['disable'] = true;
  4474. if(!empty($oForm->aParams['db']['submit_name'])) {
  4475. $sSubmitName = $sSubmitValue = false;
  4476. if(is_array($oForm->aParams['db']['submit_name'])) {
  4477. foreach ($oForm->aParams['db']['submit_name'] as $sName) {
  4478. if(isset($oForm->aInputs[$sName])) {
  4479. $sSubmitName = $sName;
  4480. $sSubmitValue = $oForm->aInputs[$sName]['value'];
  4481. break;
  4482. }
  4483. else if(isset($oForm->aInputs['controls']))
  4484. foreach($oForm->aInputs['controls'] as $mixedKey => $mixedInput)
  4485. if(is_numeric($mixedKey) && isset($mixedInput['name']) && $mixedInput['name'] == $sName) {
  4486. $sSubmitName = $sName;
  4487. $sSubmitValue = $mixedInput['value'];
  4488. break 2;
  4489. }
  4490. }
  4491. }
  4492. else {
  4493. $sName = $oForm->aParams['db']['submit_name'];
  4494. if(isset($oForm->aInputs[$sName])) {
  4495. $sSubmitName = $sName;
  4496. $sSubmitValue = $oForm->aInputs[$sName]['value'];
  4497. }
  4498. else if(isset($oForm->aInputs['controls']))
  4499. foreach($oForm->aInputs['controls'] as $mixedKey => $mixedInput)
  4500. if(is_numeric($mixedKey) && isset($mixedInput['name']) && $mixedInput['name'] == $sName) {
  4501. $sSubmitName = $sName;
  4502. $sSubmitValue = $mixedInput['value'];
  4503. break;
  4504. }
  4505. }
  4506. if($sSubmitName && $sSubmitValue)
  4507. $aValues[$sSubmitName] = $sSubmitValue;
  4508. }
  4509. }
  4510. protected function _getFieldValue($sField, $iContentId)
  4511. {
  4512. $CNF = &$this->_oConfig->CNF;
  4513. if(empty($CNF[$sField]))
  4514. return false;
  4515. $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iContentId));
  4516. if(empty($aEvent) || empty($aEvent[$CNF[$sField]]))
  4517. return false;
  4518. return $aEvent[$CNF[$sField]];
  4519. }
  4520. /**
  4521. * Returns records for React Jot using OAuth2
  4522. * @param int $iProfileId
  4523. * @param string $sPage
  4524. * @param string $sTab
  4525. * @param int $iStart
  4526. * @param int $iPerPage
  4527. * @return array
  4528. */
  4529. public function serviceGetUserPosts($iProfileId = 0, $sPage = 'home', $sTab = 'hot', $iStart = 0, $iPerPage = 0)
  4530. {
  4531. $iProfileId = (int)$iProfileId ? (int)$iProfileId : bx_get_logged_profile_id();
  4532. if(empty($iProfileId))
  4533. return array(
  4534. 'code' => 1,
  4535. 'result' => array(),
  4536. 'message' => _t('_bx_timeline_txt_msg_no_profile_id'),
  4537. 'page' => $sPage,
  4538. 'tab' => $sTab
  4539. );
  4540. $sType = BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS;
  4541. $sView = BX_TIMELINE_VIEW_DEFAULT;
  4542. $sFilter = BX_TIMELINE_FILTER_ALL;
  4543. $aModules = array();
  4544. switch($sPage){
  4545. case 'profile':
  4546. $sType = BX_BASE_MOD_NTFS_TYPE_OWNER;
  4547. $sFilter = BX_TIMELINE_FILTER_OWNER;
  4548. break;
  4549. default:
  4550. if ($this -> _oDb -> isModuleByName($sPage))
  4551. $aModules = array($sPage);
  4552. }
  4553. switch($sTab)
  4554. {
  4555. case 'latest':
  4556. $sType = BX_BASE_MOD_NTFS_TYPE_PUBLIC;
  4557. break;
  4558. case 'popular':
  4559. $sType = BX_TIMELINE_TYPE_HOT;
  4560. break;
  4561. case 'feed':
  4562. $sType = BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS;
  4563. break;
  4564. default:
  4565. if ($this -> _oDb -> isModuleByName($sTab))
  4566. $aModules = array($sTab);
  4567. }
  4568. $aParams = $this->getParams($sView, $sType, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules);
  4569. $aEvents = $this->_oDb->getEvents($aParams);
  4570. $iCount = $this->_oDb->getEvents(array_merge($aParams, array('count' => true)));
  4571. if(empty($aEvents) || !is_array($aEvents))
  4572. return array(
  4573. 'code' => 0,
  4574. 'result' => array(),
  4575. 'message' => _t('_bx_timeline_txt_msg_no_results'),
  4576. 'page' => $sPage,
  4577. 'tab' => $sTab
  4578. );
  4579. $aBrowseParams = array();
  4580. $aItems = array();
  4581. foreach($aEvents as $aEvent) {
  4582. $aResult = $this->_oTemplate->getData($aEvent, $aBrowseParams);
  4583. if($aResult === false)
  4584. continue;
  4585. $oOwnerProfile = BxDolProfile::getInstance($aResult['owner_id']);
  4586. $aFiles = array();
  4587. $aContent = &$aResult['content'];
  4588. if (!empty($aContent['image']))
  4589. $aFiles['images'] = array_values($aContent['images']);
  4590. if (!empty($aContent['images_attach']))
  4591. $aFiles['images'] = array_values($aContent['images_attach']);
  4592. if (!empty($aContent['videos']))
  4593. $aFiles['videos'] = array_values($aContent['videos']);
  4594. else
  4595. if (!empty($aContent['videos_attach']))
  4596. $aFiles['videos'] = array_values($aContent['videos_attach']);
  4597. if (!empty($aContent['files']))
  4598. $aFiles['files'] = array_values($aContent['files']);
  4599. else
  4600. if (!empty($aContent['files_attach']))
  4601. $aFiles['files'] = array_values($aContent['files_attach']);
  4602. $aItems[$aEvent['id']] = array_merge(array(
  4603. 'owner' => array(
  4604. 'icon' => $oOwnerProfile -> getThumb(),
  4605. 'name' => $oOwnerProfile -> getDisplayName(),
  4606. 'url' => $oOwnerProfile -> getUrl()
  4607. ),
  4608. 'sample' => !empty($aResult['sample']) ? _t($aResult['sample']) : _t('_bx_timeline_txt_sample'),
  4609. 'sample_action' => !empty($aResult['sample_action']) ? _t($aResult['sample_action']) : _t('_bx_timeline_txt_added_sample'),
  4610. 'url' => isset($aResult['url']) ? $aResult['url'] : '',
  4611. 'raw' => isset($aContent['raw']) ? strip_tags($aContent['raw']) : '',
  4612. 'text' => isset($aContent['text']) ? strip_tags($aContent['text']) : '',
  4613. 'views' => isset($aResult['views']['count']) ? (int)$aResult['views']['count'] : 0,
  4614. 'votes' => isset($aResult['votes']['count']) ? (int)$aResult['votes']['count'] : 0,
  4615. 'reactions' => isset($aResult['reactions']['count']) ? (int)$aResult['reactions']['count'] : 0,
  4616. 'scores' => isset($aResult['scores']['count']) ? (int)$aResult['scores']['count'] : 0,
  4617. 'reports' => isset($aResult['reports']['count']) ? (int)$aResult['reports']['count'] : 0,
  4618. 'comments' => isset($aResult['comments']['count']) ? (int)$aResult['comments']['count'] : 0,
  4619. 'date' => isset($aResult['date']) ? $aResult['date'] : $aEvent['date'],
  4620. 'type' => stripos($aEvent['type'], 'timeline') !== false ? 'bx_timeline' : $aEvent['type'],
  4621. 'event_type' => $aEvent['type'],
  4622. 'id' => $aEvent['id'],
  4623. 'content' => $aResult['content'],
  4624. 'title' => isset($aResult['title']) ? _t($aResult['title']) : '',
  4625. 'description' => isset($aResult['description']) ? $aResult['description'] : ''
  4626. ), $aFiles);
  4627. }
  4628. return array(
  4629. 'result' => $aItems,
  4630. 'code' => 0,
  4631. 'message' => '',
  4632. 'page' => $sPage,
  4633. 'tab' => $sTab,
  4634. 'total' => $iCount,
  4635. 'start' => (int)$iStart
  4636. );
  4637. }
  4638. }
  4639. /** @} */