deprecated-1.8.php 145 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743
  1. <?php
  2. /**
  3. * Lists entities from an access collection
  4. *
  5. * @deprecated 1.8 Use elgg_list_entities_from_access_id()
  6. *
  7. * @return str
  8. */
  9. function list_entities_from_access_id($access_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
  10. elgg_deprecated_notice("All list_entities* functions were deprecated in 1.8. Use elgg_list_entities* instead.", 1.8);
  11. echo elgg_list_entities_from_access_id(array('access_id' => $access_id,
  12. 'type' => $entity_type, 'subtype' => $entity_subtype, 'owner_guids' => $owner_guid,
  13. 'limit' => $limit, 'full_view' => $fullview, 'list_type_toggle' => $listtypetoggle,
  14. 'pagination' => $pagination,));
  15. }
  16. /**
  17. * Registers a particular action in memory
  18. *
  19. * @deprecated 1.8 Use {@link elgg_register_action()} instead
  20. *
  21. * @param string $action The name of the action (eg "register", "account/settings/save")
  22. * @param boolean $public Can this action be accessed by people not logged into the system?
  23. * @param string $filename Optionally, the filename where this action is located
  24. * @param boolean $admin_only Whether this action is only available to admin users.
  25. */
  26. function register_action($action, $public = false, $filename = "", $admin_only = false) {
  27. elgg_deprecated_notice("register_action() was deprecated by elgg_register_action()", 1.8);
  28. if ($admin_only) {
  29. $access = 'admin';
  30. } elseif ($public) {
  31. $access = 'public';
  32. } else {
  33. $access = 'logged_in';
  34. }
  35. return elgg_register_action($action, $filename, $access);
  36. }
  37. /**
  38. * Register an admin page with the admin panel.
  39. * This function extends the view "admin/main" with the provided view.
  40. * This view should provide a description and either a control or a link to.
  41. *
  42. * @deprecated 1.8 Extend admin views manually
  43. *
  44. * Usage:
  45. * - To add a control to the main admin panel then extend admin/main
  46. * - To add a control to a new page create a page which renders a view admin/subpage
  47. * (where subpage is your new page -
  48. * nb. some pages already exist that you can extend), extend the main view to point to it,
  49. * and add controls to your new view.
  50. *
  51. * At the moment this is essentially a wrapper around elgg_extend_view().
  52. *
  53. * @param string $new_admin_view The view associated with the control you're adding
  54. * @param string $view The view to extend, by default this is 'admin/main'.
  55. * @param int $priority Optional priority to govern the appearance in the list.
  56. *
  57. * @return void
  58. */
  59. function extend_elgg_admin_page($new_admin_view, $view = 'admin/main', $priority = 500) {
  60. elgg_deprecated_notice('extend_elgg_admin_page() does nothing. Extend admin views manually.', 1.8);
  61. }
  62. /**
  63. * Get entities ordered by a mathematical calculation
  64. *
  65. * @deprecated 1.8 Use elgg_get_entities_from_annotation_calculation()
  66. *
  67. * @param string $sum What sort of calculation to perform
  68. * @param string $entity_type Type of Entity
  69. * @param string $entity_subtype Subtype of Entity
  70. * @param string $name Name of annotation
  71. * @param string $mdname Metadata name
  72. * @param string $mdvalue Metadata value
  73. * @param int $owner_guid GUID of owner of annotation
  74. * @param int $limit Limit of results
  75. * @param int $offset Offset of results
  76. * @param string $orderdir Order of results
  77. * @param bool $count Return count or entities
  78. *
  79. * @return mixed
  80. */
  81. function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
  82. $msg = 'get_entities_from_annotations_calculate_x() is deprecated by elgg_get_entities_from_annotation_calculation().';
  83. elgg_deprecated_notice($msg, 1.8);
  84. $options = array();
  85. $options['calculation'] = $sum;
  86. if ($entity_type) {
  87. $options['types'] = $entity_type;
  88. }
  89. if ($entity_subtype) {
  90. $options['subtypes'] = $entity_subtype;
  91. }
  92. $options['annotation_names'] = $name;
  93. if ($mdname) {
  94. $options['metadata_names'] = $mdname;
  95. }
  96. if ($mdvalue) {
  97. $options['metadata_values'] = $mdvalue;
  98. }
  99. // original function rewrote this to container guid.
  100. if ($owner_guid) {
  101. if (is_array($owner_guid)) {
  102. $options['container_guids'] = $owner_guid;
  103. } else {
  104. $options['container_guid'] = $owner_guid;
  105. }
  106. }
  107. $options['limit'] = $limit;
  108. $options['offset'] = $offset;
  109. $options['order_by'] = "annotation_calculation $orderdir";
  110. $options['count'] = $count;
  111. return elgg_get_entities_from_annotation_calculation($options);
  112. }
  113. /**
  114. * Returns entities ordered by the sum of an annotation
  115. *
  116. * @warning This is function uses sum instead of count. THIS IS SLOW. See #3366.
  117. * This should be used when you have annotations with different values and you
  118. * want a list of entities ordered by the sum of all of those values.
  119. * If you want a list of entities ordered by the number of annotations on each entity,
  120. * use __get_entities_from_annotations_calculate_x() and pass 'count' as the first param.
  121. *
  122. * @deprecated 1.8 Use elgg_get_entities_from_annotation_calculation()
  123. *
  124. * @param string $entity_type Type of Entity
  125. * @param string $entity_subtype Subtype of Entity
  126. * @param string $name Name of annotation
  127. * @param string $mdname Metadata name
  128. * @param string $mdvalue Metadata value
  129. * @param int $owner_guid GUID of owner of annotation
  130. * @param int $limit Limit of results
  131. * @param int $offset Offset of results
  132. * @param string $orderdir Order of results
  133. * @param bool $count Return count or entities
  134. *
  135. * @return ElggEntity[]|int
  136. */
  137. function get_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
  138. $msg = 'get_entities_from_annotation_count() is deprecated by elgg_get_entities_from_annotation_calculation().';
  139. elgg_deprecated_notice($msg, 1.8);
  140. $options = array();
  141. $options['calculation'] = 'sum';
  142. if ($entity_type) {
  143. $options['types'] = $entity_type;
  144. }
  145. if ($entity_subtype) {
  146. $options['subtypes'] = $entity_subtype;
  147. }
  148. $options['annotation_names'] = $name;
  149. if ($mdname) {
  150. $options['metadata_names'] = $mdname;
  151. }
  152. if ($mdvalue) {
  153. $options['metadata_values'] = $mdvalue;
  154. }
  155. if ($owner_guid) {
  156. if (is_array($owner_guid)) {
  157. $options['owner_guids'] = $owner_guid;
  158. } else {
  159. $options['owner_guid'] = $owner_guid;
  160. }
  161. }
  162. $options['limit'] = $limit;
  163. $options['offset'] = $offset;
  164. $options['order_by'] = "annotation_calculation $orderdir";
  165. $options['count'] = $count;
  166. return elgg_get_entities_from_annotation_calculation($options);
  167. }
  168. /**
  169. * Lists entities by the totals of a particular kind of annotation
  170. *
  171. * @deprecated 1.8 Use elgg_list_entities_from_annotation_calculation()
  172. *
  173. * @param string $entity_type Type of entity.
  174. * @param string $entity_subtype Subtype of entity.
  175. * @param string $name Name of annotation.
  176. * @param int $limit Maximum number of results to return.
  177. * @param int $owner_guid Owner.
  178. * @param int $group_guid Group container. Currently only supported if entity_type is object
  179. * @param boolean $asc Whether to list in ascending or descending order (default: desc)
  180. * @param boolean $fullview Whether to display the entities in full
  181. * @param boolean $listtypetoggle Can the 'gallery' view can be displayed (default: no)
  182. * @param boolean $pagination Add pagination
  183. * @param string $orderdir Order desc or asc
  184. *
  185. * @return string Formatted entity list
  186. */
  187. function list_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "", $limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $orderdir = 'desc') {
  188. $msg = 'list_entities_from_annotation_count() is deprecated by elgg_list_entities_from_annotation_calculation().';
  189. elgg_deprecated_notice($msg, 1.8);
  190. $options = array();
  191. $options['calculation'] = 'sum';
  192. if ($entity_type) {
  193. $options['types'] = $entity_type;
  194. }
  195. if ($entity_subtype) {
  196. $options['subtypes'] = $entity_subtype;
  197. }
  198. $options['annotation_names'] = $name;
  199. if ($owner_guid) {
  200. if (is_array($owner_guid)) {
  201. $options['owner_guids'] = $owner_guid;
  202. } else {
  203. $options['owner_guid'] = $owner_guid;
  204. }
  205. }
  206. $options['full_view'] = $fullview;
  207. $options['list_type_toggle'] = $listtypetoggle;
  208. $options['pagination'] = $pagination;
  209. $options['limit'] = $limit;
  210. $options['order_by'] = "annotation_calculation $orderdir";
  211. return elgg_get_entities_from_annotation_calculation($options);
  212. }
  213. /**
  214. * Adds an entry in $CONFIG[$register_name][$subregister_name].
  215. *
  216. * @deprecated 1.8 Use the new menu system.
  217. *
  218. * This is only used for the site-wide menu. See {@link add_menu()}.
  219. *
  220. * @param string $register_name The name of the top-level register
  221. * @param string $subregister_name The name of the subregister
  222. * @param mixed $subregister_value The value of the subregister
  223. * @param array $children_array Optionally, an array of children
  224. *
  225. * @return true|false Depending on success
  226. */
  227. function add_to_register($register_name, $subregister_name, $subregister_value, $children_array = array()) {
  228. elgg_deprecated_notice("add_to_register() has been deprecated", 1.8);
  229. global $CONFIG;
  230. if (empty($register_name) || empty($subregister_name)) {
  231. return false;
  232. }
  233. if (!isset($CONFIG->registers)) {
  234. $CONFIG->registers = array();
  235. }
  236. if (!isset($CONFIG->registers[$register_name])) {
  237. $CONFIG->registers[$register_name] = array();
  238. }
  239. $subregister = new \stdClass;
  240. $subregister->name = $subregister_name;
  241. $subregister->value = $subregister_value;
  242. if (is_array($children_array)) {
  243. $subregister->children = $children_array;
  244. }
  245. $CONFIG->registers[$register_name][$subregister_name] = $subregister;
  246. return true;
  247. }
  248. /**
  249. * Removes a register entry from $CONFIG[register_name][subregister_name]
  250. *
  251. * @deprecated 1.8 Use the new menu system.
  252. *
  253. * This is used to by {@link remove_menu()} to remove site-wide menu items.
  254. *
  255. * @param string $register_name The name of the top-level register
  256. * @param string $subregister_name The name of the subregister
  257. *
  258. * @return true|false Depending on success
  259. * @since 1.7.0
  260. */
  261. function remove_from_register($register_name, $subregister_name) {
  262. elgg_deprecated_notice("remove_from_register() has been deprecated", 1.8);
  263. global $CONFIG;
  264. if (empty($register_name) || empty($subregister_name)) {
  265. return false;
  266. }
  267. if (!isset($CONFIG->registers)) {
  268. return false;
  269. }
  270. if (!isset($CONFIG->registers[$register_name])) {
  271. return false;
  272. }
  273. if (isset($CONFIG->registers[$register_name][$subregister_name])) {
  274. unset($CONFIG->registers[$register_name][$subregister_name]);
  275. return true;
  276. }
  277. return false;
  278. }
  279. /**
  280. * If it exists, returns a particular register as an array
  281. *
  282. * @deprecated 1.8 Use the new menu system
  283. *
  284. * @param string $register_name The name of the register
  285. *
  286. * @return array|false Depending on success
  287. */
  288. function get_register($register_name) {
  289. elgg_deprecated_notice("get_register() has been deprecated", 1.8);
  290. global $CONFIG;
  291. if ($register_name == 'menu') {
  292. // backward compatible code for site menu
  293. $menu = $CONFIG->menus['site'];
  294. $builder = new \ElggMenuBuilder($menu);
  295. $menu_items = $builder->getMenu('text');
  296. $menu_items = $menu_items['default'];
  297. $menu = array();
  298. foreach ($menu_items as $item) {
  299. $subregister = new \stdClass;
  300. $subregister->name = $item->getText();
  301. $subregister->value = $item->getHref();
  302. $menu[$subregister->name] = $subregister;
  303. }
  304. return $menu;
  305. }
  306. if (isset($CONFIG->registers[$register_name])) {
  307. return $CONFIG->registers[$register_name];
  308. }
  309. return false;
  310. }
  311. /**
  312. * Deprecated events core function. Code divided between elgg_register_event_handler()
  313. * and trigger_elgg_event().
  314. *
  315. * @deprecated 1.8 Use explicit register/trigger event functions
  316. *
  317. * @param string $event The type of event (eg 'init', 'update', 'delete')
  318. * @param string $object_type The type of object (eg 'system', 'blog', 'user')
  319. * @param string $function The name of the function that will handle the event
  320. * @param int $priority Priority to call handler. Lower numbers called first (default 500)
  321. * @param boolean $call Set to true to call the event rather than add to it (default false)
  322. * @param mixed $object Optionally, the object the event is being performed on (eg a user)
  323. *
  324. * @return true|false Depending on success
  325. */
  326. function events($event = "", $object_type = "", $function = "", $priority = 500, $call = false, $object = null) {
  327. elgg_deprecated_notice('events() has been deprecated.', 1.8);
  328. // leaving this here just in case someone was directly calling this internal function
  329. if (!$call) {
  330. return elgg_register_event_handler($event, $object_type, $function, $priority);
  331. } else {
  332. return trigger_elgg_event($event, $object_type, $object);
  333. }
  334. }
  335. /**
  336. * Alias function for events, that registers a function to a particular kind of event
  337. *
  338. * @deprecated 1.8 Use elgg_register_event_handler() instead
  339. *
  340. * @param string $event The event type
  341. * @param string $object_type The object type
  342. * @param string $function The function name
  343. * @return true|false Depending on success
  344. */
  345. function register_elgg_event_handler($event, $object_type, $callback, $priority = 500) {
  346. elgg_deprecated_notice("register_elgg_event_handler() was deprecated by elgg_register_event_handler()", 1.8);
  347. return elgg_register_event_handler($event, $object_type, $callback, $priority);
  348. }
  349. /**
  350. * Unregisters a function to a particular kind of event
  351. *
  352. * @deprecated 1.8 Use elgg_unregister_event_handler instead
  353. *
  354. * @param string $event The event type
  355. * @param string $object_type The object type
  356. * @param string $function The function name
  357. * @since 1.7.0
  358. */
  359. function unregister_elgg_event_handler($event, $object_type, $callback) {
  360. elgg_deprecated_notice('unregister_elgg_event_handler => elgg_unregister_event_handler', 1.8);
  361. elgg_unregister_event_handler($event, $object_type, $callback);
  362. }
  363. /**
  364. * Alias function for events, that triggers a particular kind of event
  365. *
  366. * @deprecated 1.8 Use elgg_trigger_event() instead
  367. *
  368. * @param string $event The event type
  369. * @param string $object_type The object type
  370. * @param string $function The function name
  371. * @return true|false Depending on success
  372. */
  373. function trigger_elgg_event($event, $object_type, $object = null) {
  374. elgg_deprecated_notice('trigger_elgg_event() was deprecated by elgg_trigger_event()', 1.8);
  375. return elgg_trigger_event($event, $object_type, $object);
  376. }
  377. /**
  378. * Register a function to a plugin hook for a particular entity type, with a given priority.
  379. *
  380. * @deprecated 1.8 Use elgg_register_plugin_hook_handler() instead
  381. *
  382. * eg if you want the function "export_user" to be called when the hook "export" for "user" entities
  383. * is run, use:
  384. *
  385. * register_plugin_hook("export", "user", "export_user");
  386. *
  387. * "all" is a valid value for both $hook and $entity_type. "none" is a valid value for $entity_type.
  388. *
  389. * The export_user function would then be defined as:
  390. *
  391. * function export_user($hook, $entity_type, $returnvalue, $params);
  392. *
  393. * Where $returnvalue is the return value returned by the last function returned by the hook, and
  394. * $params is an array containing a set of parameters (or nothing).
  395. *
  396. * @param string $hook The name of the hook
  397. * @param string $entity_type The name of the type of entity (eg "user", "object" etc)
  398. * @param string $function The name of a valid function to be run
  399. * @param string $priority The priority - 0 is first, 1000 last, default is 500
  400. * @return true|false Depending on success
  401. */
  402. function register_plugin_hook($hook, $type, $callback, $priority = 500) {
  403. elgg_deprecated_notice("register_plugin_hook() was deprecated by elgg_register_plugin_hook_handler()", 1.8);
  404. return elgg_register_plugin_hook_handler($hook, $type, $callback, $priority);
  405. }
  406. /**
  407. * Unregister a function to a plugin hook for a particular entity type
  408. *
  409. * @deprecated 1.8 Use elgg_unregister_plugin_hook_handler() instead
  410. *
  411. * @param string $hook The name of the hook
  412. * @param string $entity_type The name of the type of entity (eg "user", "object" etc)
  413. * @param string $function The name of a valid function to be run
  414. * @since 1.7.0
  415. */
  416. function unregister_plugin_hook($hook, $entity_type, $callback) {
  417. elgg_deprecated_notice("unregister_plugin_hook() was deprecated by elgg_unregister_plugin_hook_handler()", 1.8);
  418. elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback);
  419. }
  420. /**
  421. * Triggers a plugin hook, with various parameters as an array. For example, to provide
  422. * a 'foo' hook that concerns an entity of type 'bar', with a parameter called 'param1'
  423. * with value 'value1', that by default returns true, you'd call:
  424. *
  425. * @deprecated 1.8 Use elgg_trigger_plugin_hook() instead
  426. *
  427. * trigger_plugin_hook('foo', 'bar', array('param1' => 'value1'), true);
  428. *
  429. * @see register_plugin_hook
  430. * @param string $hook The name of the hook to trigger
  431. * @param string $entity_type The name of the entity type to trigger it for (or "all", or "none")
  432. * @param array $params Any parameters. It's good practice to name the keys, i.e. by using array('name' => 'value', 'name2' => 'value2')
  433. * @param mixed $returnvalue An initial return value
  434. * @return mixed|null The cumulative return value for the plugin hook functions
  435. */
  436. function trigger_plugin_hook($hook, $type, $params = null, $returnvalue = null) {
  437. elgg_deprecated_notice("trigger_plugin_hook() was deprecated by elgg_trigger_plugin_hook()", 1.8);
  438. return elgg_trigger_plugin_hook($hook, $type, $params, $returnvalue);
  439. }
  440. /**
  441. * Checks if code is being called from a certain function.
  442. *
  443. * To use, call this function with the function name (and optional
  444. * file location) that it has to be called from, it will either
  445. * return true or false.
  446. *
  447. * e.g.
  448. *
  449. * function my_secure_function()
  450. * {
  451. * if (!call_gatekeeper("my_call_function"))
  452. * return false;
  453. *
  454. * ... do secure stuff ...
  455. * }
  456. *
  457. * function my_call_function()
  458. * {
  459. * // will work
  460. * my_secure_function();
  461. * }
  462. *
  463. * function bad_function()
  464. * {
  465. * // Will not work
  466. * my_secure_function();
  467. * }
  468. *
  469. * @param mixed $function The function that this function must have in its call stack,
  470. * to test against a method pass an array containing a class and
  471. * method name.
  472. * @param string $file Optional file that the function must reside in.
  473. *
  474. * @return bool
  475. *
  476. * @deprecated 1.8 A neat but pointless function
  477. */
  478. function call_gatekeeper($function, $file = "") {
  479. elgg_deprecated_notice("call_gatekeeper() is neat but pointless", 1.8);
  480. // Sanity check
  481. if (!$function) {
  482. return false;
  483. }
  484. // Check against call stack to see if this is being called from the correct location
  485. $callstack = debug_backtrace();
  486. $stack_element = false;
  487. foreach ($callstack as $call) {
  488. if (is_array($function)) {
  489. if ((strcmp($call['class'], $function[0]) == 0) && (strcmp($call['function'], $function[1]) == 0)) {
  490. $stack_element = $call;
  491. }
  492. } else {
  493. if (strcmp($call['function'], $function) == 0) {
  494. $stack_element = $call;
  495. }
  496. }
  497. }
  498. if (!$stack_element) {
  499. return false;
  500. }
  501. // If file then check that this it is being called from this function
  502. if ($file) {
  503. $mirror = null;
  504. if (is_array($function)) {
  505. $mirror = new ReflectionMethod($function[0], $function[1]);
  506. } else {
  507. $mirror = new ReflectionFunction($function);
  508. }
  509. if ((!$mirror) || (strcmp($file, $mirror->getFileName()) != 0)) {
  510. return false;
  511. }
  512. }
  513. return true;
  514. }
  515. /**
  516. * This function checks to see if it is being called at somepoint by a function defined somewhere
  517. * on a given path (optionally including subdirectories).
  518. *
  519. * This function is similar to call_gatekeeper() but returns true if it is being called
  520. * by a method or function which has been defined on a given path or by a specified file.
  521. *
  522. * @param string $path The full path and filename that this function must have
  523. * in its call stack If a partial path is given and
  524. * $include_subdirs is true, then the function will return
  525. * true if called by any function in or below the specified path.
  526. * @param bool $include_subdirs Are subdirectories of the path ok, or must you specify an
  527. * absolute path and filename.
  528. * @param bool $strict_mode If true then the calling method or function must be directly
  529. * called by something on $path, if false the whole call stack is
  530. * searched.
  531. *
  532. * @return void
  533. *
  534. * @deprecated 1.8 A neat but pointless function
  535. */
  536. function callpath_gatekeeper($path, $include_subdirs = true, $strict_mode = false) {
  537. elgg_deprecated_notice("callpath_gatekeeper() is neat but pointless", 1.8);
  538. global $CONFIG;
  539. $path = sanitise_string($path);
  540. if ($path) {
  541. $callstack = debug_backtrace();
  542. foreach ($callstack as $call) {
  543. $call['file'] = str_replace("\\", "/", $call['file']);
  544. if ($include_subdirs) {
  545. if (strpos($call['file'], $path) === 0) {
  546. if ($strict_mode) {
  547. $callstack[1]['file'] = str_replace("\\", "/", $callstack[1]['file']);
  548. if ($callstack[1] === $call) {
  549. return true;
  550. }
  551. } else {
  552. return true;
  553. }
  554. }
  555. } else {
  556. if (strcmp($path, $call['file']) == 0) {
  557. if ($strict_mode) {
  558. if ($callstack[1] === $call) {
  559. return true;
  560. }
  561. } else {
  562. return true;
  563. }
  564. }
  565. }
  566. }
  567. return false;
  568. }
  569. if (isset($CONFIG->debug)) {
  570. system_message("Gatekeeper'd function called from {$callstack[1]['file']}:" . "{$callstack[1]['line']}\n\nStack trace:\n\n" . print_r($callstack, true));
  571. }
  572. return false;
  573. }
  574. /**
  575. * Returns SQL where clause for owner and containers.
  576. *
  577. * @deprecated 1.8 Use elgg_get_guid_based_where_sql();
  578. *
  579. * @param string $table Entity table prefix as defined in SELECT...FROM entities $table
  580. * @param NULL|array $owner_guids Owner GUIDs
  581. *
  582. * @return string|false
  583. * @since 1.7.0
  584. * @access private
  585. */
  586. function elgg_get_entity_owner_where_sql($table, $owner_guids) {
  587. elgg_deprecated_notice('elgg_get_entity_owner_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
  588. return _elgg_get_guid_based_where_sql("{$table}.owner_guid", $owner_guids);
  589. }
  590. /**
  591. * Returns SQL where clause for containers.
  592. *
  593. * @deprecated 1.8 Use elgg_get_guid_based_where_sql();
  594. *
  595. * @param string $table Entity table prefix as defined in
  596. * SELECT...FROM entities $table
  597. * @param NULL|array $container_guids Array of container guids
  598. *
  599. * @return FALSE|string
  600. * @since 1.7.0
  601. * @access private
  602. */
  603. function elgg_get_entity_container_where_sql($table, $container_guids) {
  604. elgg_deprecated_notice('elgg_get_entity_container_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
  605. return _elgg_get_guid_based_where_sql("{$table}.container_guid", $container_guids);
  606. }
  607. /**
  608. * Returns SQL where clause for site entities
  609. *
  610. * @deprecated 1.8 Use elgg_get_guid_based_where_sql()
  611. *
  612. * @param string $table Entity table prefix as defined in SELECT...FROM entities $table
  613. * @param NULL|array $site_guids Array of site guids
  614. *
  615. * @return FALSE|string
  616. * @since 1.7.0
  617. * @access private
  618. */
  619. function elgg_get_entity_site_where_sql($table, $site_guids) {
  620. elgg_deprecated_notice('elgg_get_entity_site_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
  621. return _elgg_get_guid_based_where_sql("{$table}.site_guid", $site_guids);
  622. }
  623. /**
  624. * Return an array of objects in a given container.
  625. *
  626. * @see get_entities()
  627. *
  628. * @param int $group_guid The container (defaults to current page owner)
  629. * @param string $subtype The subtype
  630. * @param int $owner_guid Owner
  631. * @param int $site_guid The site
  632. * @param string $order_by Order
  633. * @param int $limit Limit on number of elements to return, by default 10.
  634. * @param int $offset Where to start, by default 0.
  635. * @param bool $count Whether to return the entities or a count of them.
  636. *
  637. * @return array|false
  638. * @deprecated 1.8 Use elgg_get_entities() instead
  639. */
  640. function get_objects_in_group($group_guid, $subtype = "", $owner_guid = 0, $site_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = FALSE) {
  641. elgg_deprecated_notice("get_objects_in_group was deprected in 1.8. Use elgg_get_entities() instead", 1.8);
  642. global $CONFIG;
  643. if ($subtype === FALSE || $subtype === null || $subtype === 0) {
  644. return FALSE;
  645. }
  646. if ($order_by == "") {
  647. $order_by = "e.time_created desc";
  648. }
  649. $order_by = sanitise_string($order_by);
  650. $limit = (int)$limit;
  651. $offset = (int)$offset;
  652. $site_guid = (int)$site_guid;
  653. if ($site_guid == 0) {
  654. $site_guid = $CONFIG->site_guid;
  655. }
  656. $container_guid = (int)$group_guid;
  657. if ($container_guid == 0) {
  658. $container_guid = elgg_get_page_owner_guid();
  659. }
  660. $where = array();
  661. $where[] = "e.type='object'";
  662. if (!empty($subtype)) {
  663. if (!$subtype = get_subtype_id('object', $subtype)) {
  664. return FALSE;
  665. }
  666. $where[] = "e.subtype=$subtype";
  667. }
  668. if ($owner_guid != "") {
  669. if (!is_array($owner_guid)) {
  670. $owner_guid = (int)$owner_guid;
  671. $where[] = "e.container_guid = '$owner_guid'";
  672. } else if (sizeof($owner_guid) > 0) {
  673. // Cast every element to the owner_guid array to int
  674. $owner_guid = array_map("sanitise_int", $owner_guid);
  675. $owner_guid = implode(",", $owner_guid);
  676. $where[] = "e.container_guid in ({$owner_guid})";
  677. }
  678. }
  679. if ($site_guid > 0) {
  680. $where[] = "e.site_guid = {$site_guid}";
  681. }
  682. if ($container_guid > 0) {
  683. $where[] = "e.container_guid = {$container_guid}";
  684. }
  685. if (!$count) {
  686. $query = "SELECT * from {$CONFIG->dbprefix}entities e" . " join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where ";
  687. } else {
  688. $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e" . " join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where ";
  689. }
  690. foreach ($where as $w) {
  691. $query .= " $w and ";
  692. }
  693. // Add access controls
  694. $query .= _elgg_get_access_where_sql();
  695. if (!$count) {
  696. $query .= " order by $order_by";
  697. // Add order and limit
  698. if ($limit) {
  699. $query .= " limit $offset, $limit";
  700. }
  701. $dt = get_data($query, "entity_row_to_elggstar");
  702. return $dt;
  703. } else {
  704. $total = get_data_row($query);
  705. return $total->total;
  706. }
  707. }
  708. /**
  709. * Lists entities that belong to a group.
  710. *
  711. * @param string $subtype The arbitrary subtype of the entity
  712. * @param int $owner_guid The GUID of the owning user
  713. * @param int $container_guid The GUID of the containing group
  714. * @param int $limit The number of entities to display per page (default: 10)
  715. * @param bool $fullview Whether or not to display the full view (default: true)
  716. * @param bool $listtypetoggle Whether or not to allow gallery view (default: true)
  717. * @param bool $pagination Whether to display pagination (default: true)
  718. *
  719. * @return string List of parsed entities
  720. *
  721. * @see elgg_list_entities()
  722. * @deprecated 1.8 Use elgg_list_entities() instead
  723. */
  724. function list_entities_groups($subtype = "", $owner_guid = 0, $container_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
  725. elgg_deprecated_notice("list_entities_groups was deprecated in 1.8. Use elgg_list_entities() instead.", 1.8);
  726. $offset = (int)get_input('offset');
  727. $count = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset, true);
  728. $entities = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset);
  729. return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
  730. }
  731. /**
  732. * Get all the entities from metadata from a group.
  733. *
  734. * @param int $group_guid The ID of the group.
  735. * @param mixed $meta_name Metadata name
  736. * @param mixed $meta_value Metadata value
  737. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  738. * @param string $entity_subtype The subtype of the entity.
  739. * @param int $owner_guid Owner guid
  740. * @param int $limit Limit
  741. * @param int $offset Offset
  742. * @param string $order_by Optional ordering.
  743. * @param int $site_guid Site GUID. 0 for current, -1 for any
  744. * @param bool $count Return count instead of entities
  745. *
  746. * @return array|false
  747. * @deprecated 1.8 Use elgg_get_entities_from_metadata()
  748. */
  749. function get_entities_from_metadata_groups($group_guid, $meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
  750. elgg_deprecated_notice("get_entities_from_metadata_groups was deprecated in 1.8.", 1.8);
  751. global $CONFIG;
  752. $meta_n = get_metastring_id($meta_name);
  753. $meta_v = get_metastring_id($meta_value);
  754. $entity_type = sanitise_string($entity_type);
  755. $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
  756. $limit = (int)$limit;
  757. $offset = (int)$offset;
  758. if ($order_by == "") {
  759. $order_by = "e.time_created desc";
  760. }
  761. $order_by = sanitise_string($order_by);
  762. $site_guid = (int)$site_guid;
  763. if (is_array($owner_guid)) {
  764. foreach ($owner_guid as $key => $guid) {
  765. $owner_guid[$key] = (int)$guid;
  766. }
  767. } else {
  768. $owner_guid = (int)$owner_guid;
  769. }
  770. if ($site_guid == 0) {
  771. $site_guid = $CONFIG->site_guid;
  772. }
  773. $container_guid = (int)$group_guid;
  774. if ($container_guid == 0) {
  775. $container_guid = elgg_get_page_owner_guid();
  776. }
  777. $where = array();
  778. if ($entity_type != "") {
  779. $where[] = "e.type='$entity_type'";
  780. }
  781. if ($entity_subtype) {
  782. $where[] = "e.subtype=$entity_subtype";
  783. }
  784. if ($meta_name != "") {
  785. $where[] = "m.name_id='$meta_n'";
  786. }
  787. if ($meta_value != "") {
  788. $where[] = "m.value_id='$meta_v'";
  789. }
  790. if ($site_guid > 0) {
  791. $where[] = "e.site_guid = {$site_guid}";
  792. }
  793. if ($container_guid > 0) {
  794. $where[] = "e.container_guid = {$container_guid}";
  795. }
  796. if (is_array($owner_guid)) {
  797. $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")";
  798. } else if ($owner_guid > 0) {
  799. $where[] = "e.container_guid = {$owner_guid}";
  800. }
  801. if (!$count) {
  802. $query = "SELECT distinct e.* ";
  803. } else {
  804. $query = "SELECT count(e.guid) as total ";
  805. }
  806. $query .= "from {$CONFIG->dbprefix}entities e" . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid " . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid where";
  807. foreach ($where as $w) {
  808. $query .= " $w and ";
  809. }
  810. // Add access controls
  811. $query .= _elgg_get_access_where_sql();
  812. if (!$count) {
  813. $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
  814. return get_data($query, "entity_row_to_elggstar");
  815. } else {
  816. if ($row = get_data_row($query)) {
  817. return $row->total;
  818. }
  819. }
  820. return false;
  821. }
  822. /**
  823. * As get_entities_from_metadata_groups() but with multiple entities.
  824. *
  825. * @param int $group_guid The ID of the group.
  826. * @param array $meta_array Array of 'name' => 'value' pairs
  827. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  828. * @param string $entity_subtype The subtype of the entity.
  829. * @param int $owner_guid Owner GUID
  830. * @param int $limit Limit
  831. * @param int $offset Offset
  832. * @param string $order_by Optional ordering.
  833. * @param int $site_guid Site GUID. 0 for current, -1 for any
  834. * @param bool $count Return count of entities instead of entities
  835. *
  836. * @return int|array List of \ElggEntities, or the total number if count is set to false
  837. * @deprecated 1.8 Use elgg_get_entities_from_metadata()
  838. */
  839. function get_entities_from_metadata_groups_multi($group_guid, $meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
  840. elgg_deprecated_notice("get_entities_from_metadata_groups_multi was deprecated in 1.8.", 1.8);
  841. global $CONFIG;
  842. if (!is_array($meta_array) || sizeof($meta_array) == 0) {
  843. return false;
  844. }
  845. $where = array();
  846. $mindex = 1;
  847. $join = "";
  848. foreach ($meta_array as $meta_name => $meta_value) {
  849. $meta_n = get_metastring_id($meta_name);
  850. $meta_v = get_metastring_id($meta_value);
  851. $join .= " JOIN {$CONFIG->dbprefix}metadata m{$mindex} on e.guid = m{$mindex}.entity_guid" . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid ";
  852. if ($meta_name != "") {
  853. $where[] = "m{$mindex}.name_id='$meta_n'";
  854. }
  855. if ($meta_value != "") {
  856. $where[] = "m{$mindex}.value_id='$meta_v'";
  857. }
  858. $mindex++;
  859. }
  860. $entity_type = sanitise_string($entity_type);
  861. $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
  862. $limit = (int)$limit;
  863. $offset = (int)$offset;
  864. if ($order_by == "") {
  865. $order_by = "e.time_created desc";
  866. }
  867. $order_by = sanitise_string($order_by);
  868. $owner_guid = (int)$owner_guid;
  869. $site_guid = (int)$site_guid;
  870. if ($site_guid == 0) {
  871. $site_guid = $CONFIG->site_guid;
  872. }
  873. //$access = get_access_list();
  874. if ($entity_type != "") {
  875. $where[] = "e.type = '{$entity_type}'";
  876. }
  877. if ($entity_subtype) {
  878. $where[] = "e.subtype = {$entity_subtype}";
  879. }
  880. if ($site_guid > 0) {
  881. $where[] = "e.site_guid = {$site_guid}";
  882. }
  883. if ($owner_guid > 0) {
  884. $where[] = "e.owner_guid = {$owner_guid}";
  885. }
  886. if ($group_guid > 0) {
  887. $where[] = "e.container_guid = {$group_guid}";
  888. }
  889. if ($count) {
  890. $query = "SELECT count(e.guid) as total ";
  891. } else {
  892. $query = "SELECT distinct e.* ";
  893. }
  894. $query .= " from {$CONFIG->dbprefix}entities e {$join} where";
  895. foreach ($where as $w) {
  896. $query .= " $w and ";
  897. }
  898. $query .= _elgg_get_access_where_sql();
  899. if (!$count) {
  900. $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
  901. return get_data($query, "entity_row_to_elggstar");
  902. } else {
  903. if ($count = get_data_row($query)) {
  904. return $count->total;
  905. }
  906. }
  907. return false;
  908. }
  909. /**
  910. * List items within a given geographic area.
  911. *
  912. * @param float $lat Latitude
  913. * @param float $long Longitude
  914. * @param float $radius The radius
  915. * @param string $type The type of entity (eg "user", "object" etc)
  916. * @param string $subtype The arbitrary subtype of the entity
  917. * @param int $owner_guid The GUID of the owning user
  918. * @param int $limit The number of entities to display per page (default: 10)
  919. * @param bool $fullview Whether or not to display the full view (default: true)
  920. * @param bool $listtypetoggle Whether or not to allow gallery view
  921. * @param bool $navigation Display pagination? Default: true
  922. *
  923. * @return string A viewable list of entities
  924. * @deprecated 1.8 Use elgg_get_entities_from_location()
  925. */
  926. function list_entities_in_area($lat, $long, $radius, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
  927. elgg_deprecated_notice('list_entities_in_area() was deprecated. Use elgg_list_entities_from_location()', 1.8);
  928. $options = array();
  929. $options['latitude'] = $lat;
  930. $options['longitude'] = $long;
  931. $options['distance'] = $radius;
  932. if ($type) {
  933. $options['types'] = $type;
  934. }
  935. if ($subtype) {
  936. $options['subtypes'] = $subtype;
  937. }
  938. if ($owner_guid) {
  939. if (is_array($owner_guid)) {
  940. $options['owner_guids'] = $owner_guid;
  941. } else {
  942. $options['owner_guid'] = $owner_guid;
  943. }
  944. }
  945. $options['limit'] = $limit;
  946. $options['full_view'] = $fullview;
  947. $options['list_type_toggle'] = $listtypetoggle;
  948. $options['pagination'] = true;
  949. return elgg_list_entities_from_location($options);
  950. }
  951. /**
  952. * List entities in a given location
  953. *
  954. * @param string $location Location
  955. * @param string $type The type of entity (eg "user", "object" etc)
  956. * @param string $subtype The arbitrary subtype of the entity
  957. * @param int $owner_guid The GUID of the owning user
  958. * @param int $limit The number of entities to display per page (default: 10)
  959. * @param bool $fullview Whether or not to display the full view (default: true)
  960. * @param bool $listtypetoggle Whether or not to allow gallery view
  961. * @param bool $navigation Display pagination? Default: true
  962. *
  963. * @return string A viewable list of entities
  964. * @deprecated 1.8 Use elgg_list_entities_from_location()
  965. */
  966. function list_entities_location($location, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
  967. elgg_deprecated_notice('list_entities_location() was deprecated. Use elgg_list_entities_from_metadata()', 1.8);
  968. return list_entities_from_metadata('location', $location, $type, $subtype, $owner_guid, $limit, $fullview, $listtypetoggle, $navigation);
  969. }
  970. /**
  971. * Return entities within a given geographic area.
  972. *
  973. * @param float $lat Latitude
  974. * @param float $long Longitude
  975. * @param float $radius The radius
  976. * @param string $type The type of entity (eg "user", "object" etc)
  977. * @param string $subtype The arbitrary subtype of the entity
  978. * @param int $owner_guid The GUID of the owning user
  979. * @param string $order_by The field to order by; by default, time_created desc
  980. * @param int $limit The number of entities to return; 10 by default
  981. * @param int $offset The indexing offset, 0 by default
  982. * @param boolean $count Count entities
  983. * @param int $site_guid Site GUID. 0 for current, -1 for any
  984. * @param int|array $container_guid Container GUID
  985. *
  986. * @return array A list of entities.
  987. * @deprecated 1.8 Use elgg_get_entities_from_location()
  988. */
  989. function get_entities_in_area($lat, $long, $radius, $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = NULL) {
  990. elgg_deprecated_notice('get_entities_in_area() was deprecated by elgg_get_entities_from_location()!', 1.8);
  991. $options = array();
  992. $options['latitude'] = $lat;
  993. $options['longitude'] = $long;
  994. $options['distance'] = $radius;
  995. // set container_guid to owner_guid to emulate old functionality
  996. if ($owner_guid != "") {
  997. if (is_null($container_guid)) {
  998. $container_guid = $owner_guid;
  999. }
  1000. }
  1001. if ($type) {
  1002. $options['types'] = $type;
  1003. }
  1004. if ($subtype) {
  1005. $options['subtypes'] = $subtype;
  1006. }
  1007. if ($owner_guid) {
  1008. if (is_array($owner_guid)) {
  1009. $options['owner_guids'] = $owner_guid;
  1010. } else {
  1011. $options['owner_guid'] = $owner_guid;
  1012. }
  1013. }
  1014. if ($container_guid) {
  1015. if (is_array($container_guid)) {
  1016. $options['container_guids'] = $container_guid;
  1017. } else {
  1018. $options['container_guid'] = $container_guid;
  1019. }
  1020. }
  1021. $options['limit'] = $limit;
  1022. if ($offset) {
  1023. $options['offset'] = $offset;
  1024. }
  1025. if ($order_by) {
  1026. $options['order_by'];
  1027. }
  1028. if ($site_guid) {
  1029. $options['site_guid'];
  1030. }
  1031. if ($count) {
  1032. $options['count'] = $count;
  1033. }
  1034. return elgg_get_entities_from_location($options);
  1035. }
  1036. /**
  1037. * Return a list of entities suitable for display based on the given search criteria.
  1038. *
  1039. * @see elgg_view_entity_list
  1040. *
  1041. * @deprecated 1.8 Use elgg_list_entities_from_metadata
  1042. *
  1043. * @param mixed $meta_name Metadata name to search on
  1044. * @param mixed $meta_value The value to match, optionally
  1045. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  1046. * @param string $entity_subtype The subtype of the entity
  1047. * @param int $owner_guid Owner GUID
  1048. * @param int $limit Number of entities to display per page
  1049. * @param bool $fullview WDisplay the full view (default: true)
  1050. * @param bool $listtypetoggle Allow users to toggle to the gallery view. Default: true
  1051. * @param bool $pagination Display pagination? Default: true
  1052. * @param bool $case_sensitive Case sensitive metadata names?
  1053. *
  1054. * @return string
  1055. *
  1056. * @return string A list of entities suitable for display
  1057. */
  1058. function list_entities_from_metadata($meta_name, $meta_value = "", $entity_type = ELGG_ENTITIES_ANY_VALUE, $entity_subtype = ELGG_ENTITIES_ANY_VALUE, $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true, $case_sensitive = true) {
  1059. elgg_deprecated_notice('list_entities_from_metadata() was deprecated by elgg_list_entities_from_metadata()!', 1.8);
  1060. $offset = (int)get_input('offset');
  1061. $limit = (int)$limit;
  1062. $options = array(
  1063. 'metadata_name' => $meta_name,
  1064. 'metadata_value' => $meta_value,
  1065. 'type' => $entity_type,
  1066. 'subtype' => $entity_subtype,
  1067. 'limit' => $limit,
  1068. 'offset' => $offset,
  1069. 'count' => TRUE,
  1070. 'metadata_case_sensitive' => $case_sensitive
  1071. );
  1072. // previous function allowed falsy $owner_guid for anything
  1073. if ($owner_guid) {
  1074. $options['owner_guid'] = $owner_guid;
  1075. }
  1076. $count = elgg_get_entities_from_metadata($options);
  1077. $options['count'] = FALSE;
  1078. $entities = elgg_get_entities_from_metadata($options);
  1079. return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
  1080. }
  1081. /**
  1082. * Returns a viewable list of entities based on the given search criteria.
  1083. *
  1084. * @see elgg_view_entity_list
  1085. *
  1086. * @param array $meta_array Array of 'name' => 'value' pairs
  1087. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  1088. * @param string $entity_subtype The subtype of the entity.
  1089. * @param int $owner_guid Owner GUID
  1090. * @param int $limit Limit
  1091. * @param bool $fullview WDisplay the full view (default: true)
  1092. * @param bool $listtypetoggle Allow users to toggle to the gallery view. Default: true
  1093. * @param bool $pagination Display pagination? Default: true
  1094. *
  1095. * @return string List of \ElggEntities suitable for display
  1096. *
  1097. * @deprecated 1.8 Use elgg_list_entities_from_metadata() instead
  1098. */
  1099. function list_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
  1100. elgg_deprecated_notice(elgg_echo('deprecated:function', array(
  1101. 'list_entities_from_metadata_multi', 'elgg_get_entities_from_metadata')), 1.8);
  1102. $offset = (int)get_input('offset');
  1103. $limit = (int)$limit;
  1104. $count = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, true);
  1105. $entities = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, false);
  1106. return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
  1107. }
  1108. /**
  1109. * Deprecated by elgg_register_menu_item(). Set $menu_name to 'page'.
  1110. *
  1111. * @see elgg_register_menu_item()
  1112. * @deprecated 1.8 Use the new menu system
  1113. *
  1114. * @param string $label The label
  1115. * @param string $link The link
  1116. * @param string $group The group to store item in
  1117. * @param boolean $onclick Add a confirmation when clicked?
  1118. * @param boolean $selected Is menu item selected
  1119. *
  1120. * @return bool
  1121. */
  1122. function add_submenu_item($label, $link, $group = 'default', $onclick = false, $selected = NULL) {
  1123. elgg_deprecated_notice('add_submenu_item was deprecated by elgg_register_menu_item', 1.8);
  1124. // submenu items were added in the page setup hook usually by checking
  1125. // the context. We'll pass in the current context here, which will
  1126. // emulate that effect.
  1127. // if context == 'main' (default) it probably means they always wanted
  1128. // the menu item to show up everywhere.
  1129. $context = elgg_get_context();
  1130. if ($context == 'main') {
  1131. $context = 'all';
  1132. }
  1133. $item = array('name' => $label, 'text' => $label, 'href' => $link, 'context' => $context,
  1134. 'section' => $group,);
  1135. if ($selected) {
  1136. $item['selected'] = true;
  1137. }
  1138. if ($onclick) {
  1139. $js = "onclick=\"javascript:return confirm('" . elgg_echo('deleteconfirm') . "')\"";
  1140. $item['vars'] = array('js' => $js);
  1141. }
  1142. return elgg_register_menu_item('page', $item);
  1143. }
  1144. /**
  1145. * Remove an item from submenu by label
  1146. *
  1147. * @deprecated 1.8 Use the new menu system
  1148. * @see elgg_unregister_menu_item()
  1149. *
  1150. * @param string $label The item label
  1151. * @param string $group The submenu group (default "a")
  1152. * @return bool whether the item was removed or not
  1153. * @since 1.7.8
  1154. */
  1155. function remove_submenu_item($label, $group = 'a') {
  1156. elgg_deprecated_notice('remove_submenu_item was deprecated by elgg_unregister_menu_item', 1.8);
  1157. return elgg_unregister_menu_item('page', $label);
  1158. }
  1159. /**
  1160. * Use elgg_view_menu(). Set $menu_name to 'owner_block'.
  1161. *
  1162. * @see elgg_view_menu()
  1163. * @deprecated 1.8 Use the new menu system. elgg_view_menu()
  1164. *
  1165. * @return string
  1166. */
  1167. function get_submenu() {
  1168. elgg_deprecated_notice("get_submenu() has been deprecated by elgg_view_menu()", 1.8);
  1169. $owner = elgg_get_page_owner_entity();
  1170. return elgg_view_menu('owner_block', array('entity' => $owner,
  1171. 'class' => 'elgg-menu-owner-block',));
  1172. }
  1173. /**
  1174. * Adds an item to the site-wide menu.
  1175. *
  1176. * You can obtain the menu array by calling {@link get_register('menu')}
  1177. *
  1178. * @param string $menu_name The name of the menu item
  1179. * @param string $menu_url The URL of the page
  1180. * @param array $menu_children Optionally, an array of submenu items (not used)
  1181. * @param string $context (not used)
  1182. *
  1183. * @return true|false Depending on success
  1184. * @deprecated 1.8 use elgg_register_menu_item() for the menu 'site'
  1185. */
  1186. function add_menu($menu_name, $menu_url, $menu_children = array(), $context = "") {
  1187. elgg_deprecated_notice('add_menu() deprecated by elgg_register_menu_item()', 1.8);
  1188. return elgg_register_menu_item('site', array('name' => $menu_name, 'text' => $menu_name,
  1189. 'href' => $menu_url,));
  1190. }
  1191. /**
  1192. * Removes an item from the menu register
  1193. *
  1194. * @param string $menu_name The name of the menu item
  1195. *
  1196. * @return true|false Depending on success
  1197. * @deprecated 1.8 Use the new menu system
  1198. */
  1199. function remove_menu($menu_name) {
  1200. elgg_deprecated_notice("remove_menu() deprecated by elgg_unregister_menu_item()", 1.8);
  1201. return elgg_unregister_menu_item('site', $menu_name);
  1202. }
  1203. /**
  1204. * When given a title, returns a version suitable for inclusion in a URL
  1205. *
  1206. * @param string $title The title
  1207. *
  1208. * @return string The optimised title
  1209. * @deprecated 1.8 Use elgg_get_friendly_title()
  1210. */
  1211. function friendly_title($title) {
  1212. elgg_deprecated_notice('friendly_title was deprecated by elgg_get_friendly_title', 1.8);
  1213. return elgg_get_friendly_title($title);
  1214. }
  1215. /**
  1216. * Displays a UNIX timestamp in a friendly way (eg "less than a minute ago")
  1217. *
  1218. * @param int $time A UNIX epoch timestamp
  1219. *
  1220. * @return string The friendly time
  1221. * @deprecated 1.8 Use elgg_view_friendly_time()
  1222. */
  1223. function friendly_time($time) {
  1224. elgg_deprecated_notice('friendly_time was deprecated by elgg_view_friendly_time', 1.8);
  1225. return elgg_view_friendly_time($time);
  1226. }
  1227. /**
  1228. * Filters a string into an array of significant words
  1229. *
  1230. * @deprecated 1.8 Don't use this.
  1231. *
  1232. * @param string $string A string
  1233. *
  1234. * @return array
  1235. */
  1236. function filter_string($string) {
  1237. elgg_deprecated_notice('filter_string() was deprecated!', 1.8);
  1238. // Convert it to lower and trim
  1239. $string = strtolower($string);
  1240. $string = trim($string);
  1241. // Remove links and email addresses
  1242. // match protocol://address/path/file.extension?some=variable&another=asf%
  1243. $string = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}" . "[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu", " ", $string);
  1244. // match www.something.domain/path/file.extension?some=variable&another=asf%
  1245. $string = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}" . "[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu", " ", $string);
  1246. // match name@address
  1247. $string = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]" . "*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/iu", " ", $string);
  1248. // Sanitise the string; remove unwanted characters
  1249. $string = preg_replace('/\W/ui', ' ', $string);
  1250. // Explode it into an array
  1251. $terms = explode(' ', $string);
  1252. // Remove any blacklist terms
  1253. //$terms = array_filter($terms, 'remove_blacklist');
  1254. return $terms;
  1255. }
  1256. /**
  1257. * Returns true if the word in $input is considered significant
  1258. *
  1259. * @deprecated 1.8 Don't use this.
  1260. *
  1261. * @param string $input A word
  1262. *
  1263. * @return true|false
  1264. */
  1265. function remove_blacklist($input) {
  1266. elgg_deprecated_notice('remove_blacklist() was deprecated!', 1.8);
  1267. global $CONFIG;
  1268. if (!is_array($CONFIG->wordblacklist)) {
  1269. return $input;
  1270. }
  1271. if (strlen($input) < 3 || in_array($input, $CONFIG->wordblacklist)) {
  1272. return false;
  1273. }
  1274. return true;
  1275. }
  1276. /**
  1277. * Gets the guid of the entity that owns the current page.
  1278. *
  1279. * @deprecated 1.8 Use elgg_get_page_owner_guid()
  1280. *
  1281. * @return int The current page owner guid (0 if none).
  1282. */
  1283. function page_owner() {
  1284. elgg_deprecated_notice('page_owner() was deprecated by elgg_get_page_owner_guid().', 1.8);
  1285. return elgg_get_page_owner_guid();
  1286. }
  1287. /**
  1288. * Gets the owner entity for the current page.
  1289. *
  1290. * @deprecated 1.8 Use elgg_get_page_owner_entity()
  1291. * @return \ElggEntity|false The current page owner or false if none.
  1292. */
  1293. function page_owner_entity() {
  1294. elgg_deprecated_notice('page_owner_entity() was deprecated by elgg_get_page_owner_entity().', 1.8);
  1295. return elgg_get_page_owner_entity();
  1296. }
  1297. /**
  1298. * Registers a page owner handler function
  1299. *
  1300. * @param string $functionname The callback function
  1301. *
  1302. * @deprecated 1.8 Use the 'page_owner', 'system' plugin hook
  1303. * @return void
  1304. */
  1305. function add_page_owner_handler($functionname) {
  1306. elgg_deprecated_notice("add_page_owner_handler() was deprecated by the plugin hook 'page_owner', 'system'.", 1.8);
  1307. }
  1308. /**
  1309. * Set a page owner entity
  1310. *
  1311. * @param int $entitytoset The GUID of the entity
  1312. *
  1313. * @deprecated 1.8 Use elgg_set_page_owner_guid()
  1314. * @return void
  1315. */
  1316. function set_page_owner($entitytoset = -1) {
  1317. elgg_deprecated_notice('set_page_owner() was deprecated by elgg_set_page_owner_guid().', 1.8);
  1318. elgg_set_page_owner_guid($entitytoset);
  1319. }
  1320. /**
  1321. * Sets the functional context of a page
  1322. *
  1323. * @deprecated 1.8 Use elgg_set_context()
  1324. *
  1325. * @param string $context The context of the page
  1326. *
  1327. * @return mixed Either the context string, or false on failure
  1328. */
  1329. function set_context($context) {
  1330. elgg_deprecated_notice('set_context() was deprecated by elgg_set_context().', 1.8);
  1331. elgg_set_context($context);
  1332. if (empty($context)) {
  1333. return false;
  1334. }
  1335. return $context;
  1336. }
  1337. /**
  1338. * Returns the functional context of a page
  1339. *
  1340. * @deprecated 1.8 Use elgg_get_context()
  1341. *
  1342. * @return string The context, or 'main' if no context has been provided
  1343. */
  1344. function get_context() {
  1345. elgg_deprecated_notice('get_context() was deprecated by elgg_get_context().', 1.8);
  1346. return elgg_get_context();
  1347. // @todo - used to set context based on calling script
  1348. // $context = get_plugin_name(true)
  1349. }
  1350. /**
  1351. * Returns a list of plugins to load, in the order that they should be loaded.
  1352. *
  1353. * @deprecated 1.8 Use elgg_get_plugin_ids_in_dir() or elgg_get_plugins()
  1354. *
  1355. * @return array List of plugins
  1356. */
  1357. function get_plugin_list() {
  1358. elgg_deprecated_notice('get_plugin_list() is deprecated by elgg_get_plugin_ids_in_dir() or elgg_get_plugins()', 1.8);
  1359. $plugins = elgg_get_plugins('any');
  1360. $list = array();
  1361. if ($plugins) {
  1362. foreach ($plugins as $i => $plugin) {
  1363. // in <=1.7 this returned indexed by multiples of 10.
  1364. // uh...sure...why not.
  1365. $index = ($i + 1) * 10;
  1366. $list[$index] = $plugin->getID();
  1367. }
  1368. }
  1369. return $list;
  1370. }
  1371. /**
  1372. * Regenerates the list of known plugins and saves it to the current site
  1373. *
  1374. * Important: You should regenerate simplecache and the viewpath cache after executing this function
  1375. * otherwise you may experience view display artifacts. Do this with the following code:
  1376. *
  1377. * elgg_regenerate_simplecache();
  1378. * elgg_reset_system_cache();
  1379. *
  1380. * @deprecated 1.8 Use elgg_generate_plugin_entities() and elgg_set_plugin_priorities()
  1381. *
  1382. * @param array $pluginorder Optionally, a list of existing plugins and their orders
  1383. *
  1384. * @return array The new list of plugins and their orders
  1385. */
  1386. function regenerate_plugin_list($pluginorder = FALSE) {
  1387. $msg = 'regenerate_plugin_list() is (sorta) deprecated by elgg_generate_plugin_entities() and'
  1388. . ' elgg_set_plugin_priorities().';
  1389. elgg_deprecated_notice($msg, 1.8);
  1390. // they're probably trying to set it?
  1391. if ($pluginorder) {
  1392. if (_elgg_generate_plugin_entities()) {
  1393. // sort the plugins by the index numerically since we used
  1394. // weird indexes in the old system.
  1395. ksort($pluginorder, SORT_NUMERIC);
  1396. return _elgg_set_plugin_priorities($pluginorder);
  1397. }
  1398. return false;
  1399. } else {
  1400. // they're probably trying to regenerate from disk?
  1401. return _elgg_generate_plugin_entities();
  1402. }
  1403. }
  1404. /**
  1405. * Get the name of the most recent plugin to be called in the
  1406. * call stack (or the plugin that owns the current page, if any).
  1407. *
  1408. * i.e., if the last plugin was in /mod/foobar/, get_plugin_name would return foo_bar.
  1409. *
  1410. * @deprecated 1.8 Use elgg_get_calling_plugin_id()
  1411. *
  1412. * @param boolean $mainfilename If set to true, this will instead determine the
  1413. * context from the main script filename called by
  1414. * the browser. Default = false.
  1415. *
  1416. * @return string|false Plugin name, or false if no plugin name was called
  1417. */
  1418. function get_plugin_name($mainfilename = false) {
  1419. elgg_deprecated_notice('get_plugin_name() is deprecated by elgg_get_calling_plugin_id()', 1.8);
  1420. return elgg_get_calling_plugin_id($mainfilename);
  1421. }
  1422. /**
  1423. * Load and parse a plugin manifest from a plugin XML file.
  1424. *
  1425. * @deprecated 1.8 Use \ElggPlugin->getManifest()
  1426. *
  1427. * @param string $plugin Plugin name.
  1428. * @return array of values
  1429. */
  1430. function load_plugin_manifest($plugin) {
  1431. elgg_deprecated_notice('load_plugin_manifest() is deprecated by \ElggPlugin->getManifest()', 1.8);
  1432. $xml_file = elgg_get_plugins_path() . "$plugin/manifest.xml";
  1433. try {
  1434. $manifest = new \ElggPluginManifest($xml_file, $plugin);
  1435. } catch(Exception $e) {
  1436. return false;
  1437. }
  1438. return $manifest->getManifest();
  1439. }
  1440. /**
  1441. * This function checks a plugin manifest 'elgg_version' value against the current install
  1442. * returning TRUE if the elgg_version is >= the current install's version.
  1443. *
  1444. * @deprecated 1.8 Use \ElggPlugin->canActivate()
  1445. *
  1446. * @param string $manifest_elgg_version_string The build version (eg 2009010201).
  1447. * @return bool
  1448. */
  1449. function check_plugin_compatibility($manifest_elgg_version_string) {
  1450. elgg_deprecated_notice('check_plugin_compatibility() is deprecated by \ElggPlugin->canActivate()', 1.8);
  1451. $version = elgg_get_version();
  1452. if (strpos($manifest_elgg_version_string, '.') === false) {
  1453. // Using version
  1454. $req_version = (int)$manifest_elgg_version_string;
  1455. return ($version >= $req_version);
  1456. }
  1457. return false;
  1458. }
  1459. /**
  1460. * Shorthand function for finding the plugin settings.
  1461. *
  1462. * @deprecated 1.8 Use elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()
  1463. *
  1464. * @param string $plugin_id Optional plugin id, if not specified
  1465. * then it is detected from where you are calling.
  1466. *
  1467. * @return mixed
  1468. */
  1469. function find_plugin_settings($plugin_id = null) {
  1470. elgg_deprecated_notice('find_plugin_setting() is deprecated by elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()', 1.8);
  1471. if ($plugin_id) {
  1472. return elgg_get_plugin_from_id($plugin_id);
  1473. } else {
  1474. return elgg_get_calling_plugin_entity();
  1475. }
  1476. }
  1477. /**
  1478. * Return an array of installed plugins.
  1479. *
  1480. * @deprecated 1.8 use elgg_get_plugins()
  1481. *
  1482. * @param string $status any|enabled|disabled
  1483. * @return array
  1484. */
  1485. function get_installed_plugins($status = 'all') {
  1486. global $CONFIG;
  1487. elgg_deprecated_notice('get_installed_plugins() was deprecated by elgg_get_plugins()', 1.8);
  1488. $plugins = elgg_get_plugins($status);
  1489. if (!$plugins) {
  1490. return array();
  1491. }
  1492. $installed_plugins = array();
  1493. foreach ($plugins as $plugin) {
  1494. if (!$plugin->isValid()) {
  1495. continue;
  1496. }
  1497. $include = true;
  1498. if ($status == 'enabled' && !$plugin->isActive()) {
  1499. $include = false;
  1500. } elseif ($status == 'disabled' && $plugin->isActive()) {
  1501. $include = true;
  1502. }
  1503. if ($include) {
  1504. $installed_plugins[$plugin->getID()] = array(
  1505. 'active' => $plugin->isActive(),
  1506. 'manifest' => $plugin->getManifest()->getManifest()
  1507. );
  1508. }
  1509. }
  1510. return $installed_plugins;
  1511. }
  1512. /**
  1513. * Enable a plugin for a site (default current site)
  1514. *
  1515. * Important: You should regenerate simplecache and the viewpath cache after executing this function
  1516. * otherwise you may experience view display artifacts. Do this with the following code:
  1517. *
  1518. * elgg_regenerate_simplecache();
  1519. * elgg_reset_system_cache();
  1520. *
  1521. * @deprecated 1.8 Use \ElggPlugin->activate()
  1522. *
  1523. * @param string $plugin The plugin name.
  1524. * @param int $site_guid The site id, if not specified then this is detected.
  1525. *
  1526. * @return array
  1527. * @throws InvalidClassException
  1528. */
  1529. function enable_plugin($plugin, $site_guid = null) {
  1530. elgg_deprecated_notice('enable_plugin() was deprecated by \ElggPlugin->activate()', 1.8);
  1531. $plugin = sanitise_string($plugin);
  1532. $site_guid = (int) $site_guid;
  1533. if (!$site_guid) {
  1534. $site = get_config('site');
  1535. $site_guid = $site->guid;
  1536. }
  1537. try {
  1538. $plugin = new \ElggPlugin($plugin);
  1539. } catch(Exception $e) {
  1540. return false;
  1541. }
  1542. if (!$plugin->canActivate($site_guid)) {
  1543. return false;
  1544. }
  1545. return $plugin->activate($site_guid);
  1546. }
  1547. /**
  1548. * Disable a plugin for a site (default current site)
  1549. *
  1550. * Important: You should regenerate simplecache and the viewpath cache after executing this function
  1551. * otherwise you may experience view display artifacts. Do this with the following code:
  1552. *
  1553. * elgg_regenerate_simplecache();
  1554. * elgg_reset_system_cache();
  1555. *
  1556. * @deprecated 1.8 Use \ElggPlugin->deactivate()
  1557. *
  1558. * @param string $plugin The plugin name.
  1559. * @param int $site_guid The site id, if not specified then this is detected.
  1560. *
  1561. * @return bool
  1562. * @throws InvalidClassException
  1563. */
  1564. function disable_plugin($plugin, $site_guid = 0) {
  1565. elgg_deprecated_notice('disable_plugin() was deprecated by \ElggPlugin->deactivate()', 1.8);
  1566. $plugin = sanitise_string($plugin);
  1567. $site_guid = (int) $site_guid;
  1568. if (!$site_guid) {
  1569. $site = get_config('site');
  1570. $site_guid = $site->guid;
  1571. }
  1572. try {
  1573. $plugin = new \ElggPlugin($plugin);
  1574. } catch(Exception $e) {
  1575. return false;
  1576. }
  1577. return $plugin->deactivate($site_guid);
  1578. }
  1579. /**
  1580. * Return whether a plugin is enabled or not.
  1581. *
  1582. * @deprecated 1.8 Use elgg_is_active_plugin()
  1583. *
  1584. * @param string $plugin The plugin name.
  1585. * @param int $site_guid The site id, if not specified then this is detected.
  1586. *
  1587. * @return bool
  1588. */
  1589. function is_plugin_enabled($plugin, $site_guid = 0) {
  1590. elgg_deprecated_notice('is_plugin_enabled() was deprecated by elgg_is_active_plugin()', 1.8);
  1591. return elgg_is_active_plugin($plugin, $site_guid);
  1592. }
  1593. /**
  1594. * Get entities based on their private data.
  1595. *
  1596. * @param string $name The name of the setting
  1597. * @param string $value The value of the setting
  1598. * @param string $type The type of entity (eg "user", "object" etc)
  1599. * @param string $subtype The arbitrary subtype of the entity
  1600. * @param int $owner_guid The GUID of the owning user
  1601. * @param string $order_by The field to order by; by default, time_created desc
  1602. * @param int $limit The number of entities to return; 10 by default
  1603. * @param int $offset The indexing offset, 0 by default
  1604. * @param boolean $count Return a count of entities
  1605. * @param int $site_guid The site to get entities for. 0 for current, -1 for any
  1606. * @param mixed $container_guid The container(s) GUIDs
  1607. *
  1608. * @return array A list of entities.
  1609. * @deprecated 1.8 Use elgg_get_entities_from_private_settings()
  1610. */
  1611. function get_entities_from_private_setting($name = "", $value = "", $type = "", $subtype = "",
  1612. $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0,
  1613. $container_guid = null) {
  1614. elgg_deprecated_notice('get_entities_from_private_setting() was deprecated by elgg_get_entities_from_private_setting()!', 1.8);
  1615. $options = array();
  1616. $options['private_setting_name'] = $name;
  1617. $options['private_setting_value'] = $value;
  1618. // set container_guid to owner_guid to emulate old functionality
  1619. if ($owner_guid != "") {
  1620. if (is_null($container_guid)) {
  1621. $container_guid = $owner_guid;
  1622. }
  1623. }
  1624. if ($type) {
  1625. $options['types'] = $type;
  1626. }
  1627. if ($subtype) {
  1628. $options['subtypes'] = $subtype;
  1629. }
  1630. if ($owner_guid) {
  1631. if (is_array($owner_guid)) {
  1632. $options['owner_guids'] = $owner_guid;
  1633. } else {
  1634. $options['owner_guid'] = $owner_guid;
  1635. }
  1636. }
  1637. if ($container_guid) {
  1638. if (is_array($container_guid)) {
  1639. $options['container_guids'] = $container_guid;
  1640. } else {
  1641. $options['container_guid'] = $container_guid;
  1642. }
  1643. }
  1644. $options['limit'] = $limit;
  1645. if ($offset) {
  1646. $options['offset'] = $offset;
  1647. }
  1648. if ($order_by) {
  1649. $options['order_by'];
  1650. }
  1651. if ($site_guid) {
  1652. $options['site_guid'];
  1653. }
  1654. if ($count) {
  1655. $options['count'] = $count;
  1656. }
  1657. return elgg_get_entities_from_private_settings($options);
  1658. }
  1659. /**
  1660. * Get entities based on their private data by multiple keys.
  1661. *
  1662. * @param string $name The name of the setting
  1663. * @param mixed $type Entity type
  1664. * @param string $subtype Entity subtype
  1665. * @param int $owner_guid The GUID of the owning user
  1666. * @param string $order_by The field to order by; by default, time_created desc
  1667. * @param int $limit The number of entities to return; 10 by default
  1668. * @param int $offset The indexing offset, 0 by default
  1669. * @param bool $count Count entities
  1670. * @param int $site_guid Site GUID. 0 for current, -1 for any.
  1671. * @param mixed $container_guid Container GUID
  1672. *
  1673. * @return array A list of entities.
  1674. * @deprecated 1.8 Use elgg_get_entities_from_private_settings()
  1675. */
  1676. function get_entities_from_private_setting_multi(array $name, $type = "", $subtype = "",
  1677. $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false,
  1678. $site_guid = 0, $container_guid = null) {
  1679. elgg_deprecated_notice('get_entities_from_private_setting_multi() was deprecated by elgg_get_entities_from_private_settings()!', 1.8);
  1680. $options = array();
  1681. $pairs = array();
  1682. foreach ($name as $setting_name => $setting_value) {
  1683. $pairs[] = array('name' => $setting_name, 'value' => $setting_value);
  1684. }
  1685. $options['private_setting_name_value_pairs'] = $pairs;
  1686. // set container_guid to owner_guid to emulate old functionality
  1687. if ($owner_guid != "") {
  1688. if (is_null($container_guid)) {
  1689. $container_guid = $owner_guid;
  1690. }
  1691. }
  1692. if ($type) {
  1693. $options['types'] = $type;
  1694. }
  1695. if ($subtype) {
  1696. $options['subtypes'] = $subtype;
  1697. }
  1698. if ($owner_guid) {
  1699. if (is_array($owner_guid)) {
  1700. $options['owner_guids'] = $owner_guid;
  1701. } else {
  1702. $options['owner_guid'] = $owner_guid;
  1703. }
  1704. }
  1705. if ($container_guid) {
  1706. if (is_array($container_guid)) {
  1707. $options['container_guids'] = $container_guid;
  1708. } else {
  1709. $options['container_guid'] = $container_guid;
  1710. }
  1711. }
  1712. $options['limit'] = $limit;
  1713. if ($offset) {
  1714. $options['offset'] = $offset;
  1715. }
  1716. if ($order_by) {
  1717. $options['order_by'];
  1718. }
  1719. if ($site_guid) {
  1720. $options['site_guid'];
  1721. }
  1722. if ($count) {
  1723. $options['count'] = $count;
  1724. }
  1725. return elgg_get_entities_from_private_settings($options);
  1726. }
  1727. /**
  1728. * Returns a viewable list of entities by relationship
  1729. *
  1730. * @see elgg_view_entity_list
  1731. *
  1732. * @deprecated 1.8 Use elgg_list_entities_from_relationship()
  1733. *
  1734. * @param string $relationship The relationship eg "friends_of"
  1735. * @param int $relationship_guid The guid of the entity to use query
  1736. * @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of"
  1737. * @param string $type The type of entity (eg 'object')
  1738. * @param string $subtype The entity subtype
  1739. * @param int $owner_guid The owner (default: all)
  1740. * @param int $limit The number of entities to display on a page
  1741. * @param true|false $fullview Whether or not to display the full view (default: true)
  1742. * @param true|false $viewtypetoggle Whether or not to allow gallery view
  1743. * @param true|false $pagination Whether to display pagination (default: true)
  1744. * @param bool $order_by SQL order by clause
  1745. * @return string The viewable list of entities
  1746. */
  1747. function list_entities_from_relationship($relationship, $relationship_guid,
  1748. $inverse_relationship = false, $type = ELGG_ENTITIES_ANY_VALUE,
  1749. $subtype = ELGG_ENTITIES_ANY_VALUE, $owner_guid = 0, $limit = 10,
  1750. $fullview = true, $listtypetoggle = false, $pagination = true, $order_by = '') {
  1751. elgg_deprecated_notice("list_entities_from_relationship was deprecated by elgg_list_entities_from_relationship()!", 1.8);
  1752. return elgg_list_entities_from_relationship(array(
  1753. 'relationship' => $relationship,
  1754. 'relationship_guid' => $relationship_guid,
  1755. 'inverse_relationship' => $inverse_relationship,
  1756. 'type' => $type,
  1757. 'subtype' => $subtype,
  1758. 'owner_guid' => $owner_guid,
  1759. 'order_by' => $order_by,
  1760. 'limit' => $limit,
  1761. 'full_view' => $fullview,
  1762. 'list_type_toggle' => $listtypetoggle,
  1763. 'pagination' => $pagination,
  1764. ));
  1765. }
  1766. /**
  1767. * Gets the number of entities by a the number of entities related to them in a particular way.
  1768. * This is a good way to get out the users with the most friends, or the groups with the
  1769. * most members.
  1770. *
  1771. * @deprecated 1.8 Use elgg_get_entities_from_relationship_count()
  1772. *
  1773. * @param string $relationship The relationship eg "friends_of"
  1774. * @param bool $inverse_relationship Inverse relationship owners
  1775. * @param string $type The type of entity (default: all)
  1776. * @param string $subtype The entity subtype (default: all)
  1777. * @param int $owner_guid The owner of the entities (default: none)
  1778. * @param int $limit Limit
  1779. * @param int $offset Offset
  1780. * @param bool $count Return a count instead of entities
  1781. * @param int $site_guid Site GUID
  1782. *
  1783. * @return array|int|false An array of entities, or the number of entities, or false on failure
  1784. */
  1785. function get_entities_by_relationship_count($relationship, $inverse_relationship = true, $type = "",
  1786. $subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
  1787. elgg_deprecated_notice('get_entities_by_relationship_count() is deprecated by elgg_get_entities_from_relationship_count()', 1.8);
  1788. $options = array();
  1789. $options['relationship'] = $relationship;
  1790. // this used to default to true, which is wrong.
  1791. // flip it for the new function
  1792. $options['inverse_relationship'] = !$inverse_relationship;
  1793. if ($type) {
  1794. $options['types'] = $type;
  1795. }
  1796. if ($subtype) {
  1797. $options['subtypes'] = $subtype;
  1798. }
  1799. if ($owner_guid) {
  1800. $options['owner_guid'] = $owner_guid;
  1801. }
  1802. $options['limit'] = $limit;
  1803. if ($offset) {
  1804. $options['offset'] = $offset;
  1805. }
  1806. if ($site_guid) {
  1807. $options['site_guid'];
  1808. }
  1809. if ($count) {
  1810. $options['count'] = $count;
  1811. }
  1812. return elgg_get_entities_from_relationship_count($options);
  1813. }
  1814. /**
  1815. * Displays a human-readable list of entities
  1816. *
  1817. * @deprecated 1.8 Use elgg_list_entities_from_relationship_count()
  1818. *
  1819. * @param string $relationship The relationship eg "friends_of"
  1820. * @param bool $inverse_relationship Inverse relationship owners
  1821. * @param string $type The type of entity (eg 'object')
  1822. * @param string $subtype The entity subtype
  1823. * @param int $owner_guid The owner (default: all)
  1824. * @param int $limit The number of entities to display on a page
  1825. * @param bool $fullview Whether or not to display the full view (default: true)
  1826. * @param bool $listtypetoggle Whether or not to allow gallery view
  1827. * @param bool $pagination Whether to display pagination (default: true)
  1828. *
  1829. * @return string The viewable list of entities
  1830. */
  1831. function list_entities_by_relationship_count($relationship, $inverse_relationship = true,
  1832. $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true,
  1833. $listtypetoggle = false, $pagination = true) {
  1834. elgg_deprecated_notice('list_entities_by_relationship_count() was deprecated by elgg_list_entities_from_relationship_count()', 1.8);
  1835. $options = array();
  1836. $options['relationship'] = $relationship;
  1837. // this used to default to true, which is wrong.
  1838. // flip it for the new function
  1839. $options['inverse_relationship'] = !$inverse_relationship;
  1840. if ($type) {
  1841. $options['types'] = $type;
  1842. }
  1843. if ($subtype) {
  1844. $options['subtypes'] = $subtype;
  1845. }
  1846. if ($owner_guid) {
  1847. $options['owner_guid'] = $owner_guid;
  1848. }
  1849. $options['limit'] = $limit;
  1850. $options['full_view'] = $fullview;
  1851. return elgg_list_entities_from_relationship_count($options);
  1852. }
  1853. /**
  1854. * Gets the number of entities by a the number of entities related to
  1855. * them in a particular way also constrained by metadata.
  1856. *
  1857. * @deprecated 1.8 Use elgg_get_entities_from_relationship()
  1858. *
  1859. * @param string $relationship The relationship eg "friends_of"
  1860. * @param int $relationship_guid The guid of the entity to use query
  1861. * @param bool $inverse_relationship Inverse relationship owner
  1862. * @param String $meta_name The metadata name
  1863. * @param String $meta_value The metadata value
  1864. * @param string $type The type of entity (default: all)
  1865. * @param string $subtype The entity subtype (default: all)
  1866. * @param int $owner_guid The owner of the entities (default: none)
  1867. * @param int $limit Limit
  1868. * @param int $offset Offset
  1869. * @param bool $count Return a count instead of entities
  1870. * @param int $site_guid Site GUID
  1871. *
  1872. * @return array|int|false An array of entities, or the number of entities, or false on failure
  1873. */
  1874. function get_entities_from_relationships_and_meta($relationship, $relationship_guid,
  1875. $inverse_relationship = false, $meta_name = "", $meta_value = "", $type = "",
  1876. $subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
  1877. elgg_deprecated_notice('get_entities_from_relationship_and_meta() was deprecated by elgg_get_entities_from_relationship()!', 1.7);
  1878. $options = array();
  1879. $options['relationship'] = $relationship;
  1880. $options['relationship_guid'] = $relationship_guid;
  1881. $options['inverse_relationship'] = $inverse_relationship;
  1882. if ($meta_value) {
  1883. $options['values'] = $meta_value;
  1884. }
  1885. if ($type) {
  1886. $options['types'] = $type;
  1887. }
  1888. if ($subtype) {
  1889. $options['subtypes'] = $subtype;
  1890. }
  1891. if ($owner_guid) {
  1892. $options['owner_guid'] = $owner_guid;
  1893. }
  1894. if ($limit) {
  1895. $options['limit'] = $limit;
  1896. }
  1897. if ($offset) {
  1898. $options['offset'] = $offset;
  1899. }
  1900. if ($site_guid) {
  1901. $options['site_guid'] = $site_guid;
  1902. }
  1903. if ($count) {
  1904. $options['count'] = $count;
  1905. }
  1906. return elgg_get_entities_from_relationship($options);
  1907. }
  1908. /**
  1909. * Retrieves items from the river. All parameters are optional.
  1910. *
  1911. * @param int|array $subject_guid Acting entity to restrict to. Default: all
  1912. * @param int|array $object_guid Entity being acted on to restrict to. Default: all
  1913. * @param string $subject_relationship If set to a relationship type, this will use
  1914. * $subject_guid as the starting point and set the
  1915. * subjects to be all users this
  1916. * entity has this relationship with (eg 'friend').
  1917. * Default: blank
  1918. * @param string $type The type of entity to restrict to. Default: all
  1919. * @param string $subtype The subtype of entity to restrict to. Default: all
  1920. * @param string $action_type The type of river action to restrict to. Default: all
  1921. * @param int $limit The number of items to retrieve. Default: 20
  1922. * @param int $offset The page offset. Default: 0
  1923. * @param int $posted_min The minimum time period to look at. Default: none
  1924. * @param int $posted_max The maximum time period to look at. Default: none
  1925. *
  1926. * @return array|false Depending on success
  1927. * @deprecated 1.8 Use elgg_get_river()
  1928. */
  1929. function get_river_items($subject_guid = 0, $object_guid = 0, $subject_relationship = '',
  1930. $type = '', $subtype = '', $action_type = '', $limit = 20, $offset = 0, $posted_min = 0,
  1931. $posted_max = 0) {
  1932. elgg_deprecated_notice("get_river_items deprecated by elgg_get_river", 1.8);
  1933. $options = array();
  1934. if ($subject_guid) {
  1935. $options['subject_guid'] = $subject_guid;
  1936. }
  1937. if ($object_guid) {
  1938. $options['object_guid'] = $object_guid;
  1939. }
  1940. if ($subject_relationship) {
  1941. $options['relationship'] = $subject_relationship;
  1942. unset($options['subject_guid']);
  1943. $options['relationship_guid'] = $subject_guid;
  1944. }
  1945. if ($type) {
  1946. $options['type'] = $type;
  1947. }
  1948. if ($subtype) {
  1949. $options['subtype'] = $subtype;
  1950. }
  1951. if ($action_type) {
  1952. $options['action_type'] = $action_type;
  1953. }
  1954. $options['limit'] = $limit;
  1955. $options['offset'] = $offset;
  1956. if ($posted_min) {
  1957. $options['posted_time_lower'] = $posted_min;
  1958. }
  1959. if ($posted_max) {
  1960. $options['posted_time_upper'] = $posted_max;
  1961. }
  1962. return elgg_get_river($options);
  1963. }
  1964. /**
  1965. * Returns a human-readable version of the river.
  1966. *
  1967. * @param int|array $subject_guid Acting entity to restrict to. Default: all
  1968. * @param int|array $object_guid Entity being acted on to restrict to. Default: all
  1969. * @param string $subject_relationship If set to a relationship type, this will use
  1970. * $subject_guid as the starting point and set
  1971. * the subjects to be all users this entity has this
  1972. * relationship with (eg 'friend'). Default: blank
  1973. * @param string $type The type of entity to restrict to. Default: all
  1974. * @param string $subtype The subtype of entity to restrict to. Default: all
  1975. * @param string $action_type The type of river action to restrict to. Default: all
  1976. * @param int $limit The number of items to retrieve. Default: 20
  1977. * @param int $posted_min The minimum time period to look at. Default: none
  1978. * @param int $posted_max The maximum time period to look at. Default: none
  1979. * @param bool $pagination Show pagination?
  1980. *
  1981. * @return string Human-readable river.
  1982. * @deprecated 1.8 Use elgg_list_river()
  1983. */
  1984. function elgg_view_river_items($subject_guid = 0, $object_guid = 0, $subject_relationship = '',
  1985. $type = '', $subtype = '', $action_type = '', $limit = 20, $posted_min = 0,
  1986. $posted_max = 0, $pagination = true) {
  1987. elgg_deprecated_notice("elgg_view_river_items deprecated for elgg_list_river", 1.8);
  1988. $river_items = get_river_items($subject_guid, $object_guid, $subject_relationship,
  1989. $type, $subtype, $action_type, $limit + 1, $posted_min, $posted_max);
  1990. // Get input from outside world and sanitise it
  1991. $offset = (int) get_input('offset', 0);
  1992. // view them
  1993. $params = array(
  1994. 'items' => $river_items,
  1995. 'count' => count($river_items),
  1996. 'offset' => $offset,
  1997. 'limit' => $limit,
  1998. 'pagination' => $pagination,
  1999. 'list-class' => 'elgg-list-river',
  2000. );
  2001. return elgg_view('page/components/list', $params);
  2002. }
  2003. /**
  2004. * Construct and execute the query required for the activity stream.
  2005. *
  2006. * @deprecated 1.8 This is outdated and uses the systemlog table instead of the river table.
  2007. * Don't use it.
  2008. */
  2009. function get_activity_stream_data($limit = 10, $offset = 0, $type = "", $subtype = "",
  2010. $owner_guid = "", $owner_relationship = "") {
  2011. elgg_deprecated_notice("get_activity_stream_data was deprecated", 1.8);
  2012. global $CONFIG;
  2013. $limit = (int)$limit;
  2014. $offset = (int)$offset;
  2015. if ($type) {
  2016. if (!is_array($type)) {
  2017. $type = array(sanitise_string($type));
  2018. } else {
  2019. foreach ($type as $k => $v) {
  2020. $type[$k] = sanitise_string($v);
  2021. }
  2022. }
  2023. }
  2024. if ($subtype) {
  2025. if (!is_array($subtype)) {
  2026. $subtype = array(sanitise_string($subtype));
  2027. } else {
  2028. foreach ($subtype as $k => $v) {
  2029. $subtype[$k] = sanitise_string($v);
  2030. }
  2031. }
  2032. }
  2033. if ($owner_guid) {
  2034. if (is_array($owner_guid)) {
  2035. foreach ($owner_guid as $k => $v) {
  2036. $owner_guid[$k] = (int)$v;
  2037. }
  2038. } else {
  2039. $owner_guid = array((int)$owner_guid);
  2040. }
  2041. }
  2042. $owner_relationship = sanitise_string($owner_relationship);
  2043. // Get a list of possible views
  2044. $activity_events = array();
  2045. $activity_views = array_merge(elgg_view_tree('activity', 'default'),
  2046. elgg_view_tree('river', 'default'));
  2047. $done = array();
  2048. foreach ($activity_views as $view) {
  2049. $fragments = explode('/', $view);
  2050. $tmp = explode('/', $view, 2);
  2051. $tmp = $tmp[1];
  2052. if ((isset($fragments[0])) && (($fragments[0] == 'river') || ($fragments[0] == 'activity'))
  2053. && (!in_array($tmp, $done))) {
  2054. if (isset($fragments[1])) {
  2055. $f = array();
  2056. for ($n = 1; $n < count($fragments); $n++) {
  2057. $val = sanitise_string($fragments[$n]);
  2058. switch($n) {
  2059. case 1: $key = 'type'; break;
  2060. case 2: $key = 'subtype'; break;
  2061. case 3: $key = 'event'; break;
  2062. }
  2063. $f[$key] = $val;
  2064. }
  2065. // Filter result based on parameters
  2066. $add = true;
  2067. if ($type) {
  2068. if (!in_array($f['type'], $type)) {
  2069. $add = false;
  2070. }
  2071. }
  2072. if (($add) && ($subtype)) {
  2073. if (!in_array($f['subtype'], $subtype)) {
  2074. $add = false;
  2075. }
  2076. }
  2077. if ($add) {
  2078. $activity_events[] = $f;
  2079. }
  2080. }
  2081. $done[] = $tmp;
  2082. }
  2083. }
  2084. $n = 0;
  2085. foreach ($activity_events as $details) {
  2086. // Get what we're talking about
  2087. if ($details['subtype'] == 'default') {
  2088. $details['subtype'] = '';
  2089. }
  2090. if (($details['type']) && ($details['event'])) {
  2091. if ($n > 0) {
  2092. $obj_query .= " or ";
  2093. }
  2094. $access = "";
  2095. if ($details['type'] != 'relationship') {
  2096. $access = " and " . _elgg_get_access_where_sql(array('table_alias' => 'sl'));
  2097. }
  2098. $obj_query .= "( sl.object_type='{$details['type']}'
  2099. AND sl.object_subtype='{$details['subtype']}'
  2100. AND sl.event='{$details['event']}' $access )";
  2101. $n++;
  2102. }
  2103. }
  2104. // User
  2105. if ((count($owner_guid)) && ($owner_guid[0] != 0)) {
  2106. $user = " and sl.performed_by_guid in (" . implode(',', $owner_guid) . ")";
  2107. if ($owner_relationship) {
  2108. $friendsarray = "";
  2109. if ($friends = elgg_get_entities_from_relationship(array(
  2110. 'relationship' => $owner_relationship,
  2111. 'relationship_guid' => $owner_guid[0],
  2112. 'inverse_relationship' => FALSE,
  2113. 'type' => 'user',
  2114. 'subtype' => $subtype,
  2115. 'limit' => false))
  2116. ) {
  2117. $friendsarray = array();
  2118. foreach ($friends as $friend) {
  2119. $friendsarray[] = $friend->getGUID();
  2120. }
  2121. $user = " and sl.performed_by_guid in (" . implode(',', $friendsarray) . ")";
  2122. }
  2123. }
  2124. }
  2125. $query = "SELECT sl.* FROM {$CONFIG->dbprefix}system_log sl
  2126. WHERE 1 $user AND ($obj_query)
  2127. ORDER BY sl.time_created desc limit $offset, $limit";
  2128. return get_data($query);
  2129. }
  2130. /**
  2131. * Perform standard authentication with a given username and password.
  2132. * Returns an \ElggUser object for use with login.
  2133. *
  2134. * @see login
  2135. *
  2136. * @param string $username The username, optionally (for standard logins)
  2137. * @param string $password The password, optionally (for standard logins)
  2138. *
  2139. * @return \ElggUser|false The authenticated user object, or false on failure.
  2140. *
  2141. * @deprecated 1.8 Use elgg_authenticate
  2142. */
  2143. function authenticate($username, $password) {
  2144. elgg_deprecated_notice('authenticate() has been deprecated for elgg_authenticate()', 1.8);
  2145. $pam = new \ElggPAM('user');
  2146. $credentials = array('username' => $username, 'password' => $password);
  2147. $result = $pam->authenticate($credentials);
  2148. if ($result) {
  2149. return get_user_by_username($username);
  2150. }
  2151. return false;
  2152. }
  2153. /**
  2154. * Get the members of a site.
  2155. *
  2156. * @param int $site_guid Site GUID
  2157. * @param int $limit User GUID
  2158. * @param int $offset Offset
  2159. *
  2160. * @return mixed
  2161. * @deprecated 1.8 Use \ElggSite::getMembers()
  2162. */
  2163. function get_site_members($site_guid, $limit = 10, $offset = 0) {
  2164. elgg_deprecated_notice("get_site_members() deprecated.
  2165. Use \ElggSite::getMembers()", 1.8);
  2166. $site = get_entity($site_guid);
  2167. if ($site) {
  2168. return $site->getMembers($limit, $offset);
  2169. }
  2170. return false;
  2171. }
  2172. /**
  2173. * Display a list of site members
  2174. *
  2175. * @param int $site_guid The GUID of the site
  2176. * @param int $limit The number of members to display on a page
  2177. * @param bool $fullview Whether or not to display the full view (default: true)
  2178. *
  2179. * @return string A displayable list of members
  2180. * @deprecated 1.8 Use \ElggSite::listMembers()
  2181. */
  2182. function list_site_members($site_guid, $limit = 10, $fullview = true) {
  2183. elgg_deprecated_notice("list_site_members() deprecated.
  2184. Use \ElggSite::listMembers()", 1.8);
  2185. $options = array(
  2186. 'limit' => $limit,
  2187. 'full_view' => $fullview,
  2188. );
  2189. $site = get_entity($site_guid);
  2190. if ($site) {
  2191. return $site->listMembers($options);
  2192. }
  2193. return '';
  2194. }
  2195. /**
  2196. * Add a collection to a site.
  2197. *
  2198. * @param int $site_guid Site GUID
  2199. * @param int $collection_guid Collection GUID
  2200. *
  2201. * @return mixed
  2202. * @deprecated 1.8 Don't use this.
  2203. */
  2204. function add_site_collection($site_guid, $collection_guid) {
  2205. elgg_deprecated_notice("add_site_collection has been deprecated", 1.8);
  2206. global $CONFIG;
  2207. $site_guid = (int)$site_guid;
  2208. $collection_guid = (int)$collection_guid;
  2209. return add_entity_relationship($collection_guid, "member_of_site", $site_guid);
  2210. }
  2211. /**
  2212. * Remove a collection from a site.
  2213. *
  2214. * @param int $site_guid Site GUID
  2215. * @param int $collection_guid Collection GUID
  2216. *
  2217. * @return mixed
  2218. * @deprecated 1.8 Don't use this.
  2219. */
  2220. function remove_site_collection($site_guid, $collection_guid) {
  2221. elgg_deprecated_notice("remove_site_collection has been deprecated", 1.8);
  2222. $site_guid = (int)$site_guid;
  2223. $collection_guid = (int)$collection_guid;
  2224. return remove_entity_relationship($collection_guid, "member_of_site", $site_guid);
  2225. }
  2226. /**
  2227. * Get the collections belonging to a site.
  2228. *
  2229. * @param int $site_guid Site GUID
  2230. * @param string $subtype Subtype
  2231. * @param int $limit Limit
  2232. * @param int $offset Offset
  2233. *
  2234. * @return mixed
  2235. * @deprecated 1.8 Don't use this.
  2236. */
  2237. function get_site_collections($site_guid, $subtype = "", $limit = 10, $offset = 0) {
  2238. elgg_deprecated_notice("get_site_collections has been deprecated", 1.8);
  2239. $site_guid = (int)$site_guid;
  2240. $subtype = sanitise_string($subtype);
  2241. $limit = (int)$limit;
  2242. $offset = (int)$offset;
  2243. // collection isn't a valid type. This won't work.
  2244. return elgg_get_entities_from_relationship(array(
  2245. 'relationship' => 'member_of_site',
  2246. 'relationship_guid' => $site_guid,
  2247. 'inverse_relationship' => TRUE,
  2248. 'type' => 'collection',
  2249. 'subtype' => $subtype,
  2250. 'limit' => $limit,
  2251. 'offset' => $offset
  2252. ));
  2253. }
  2254. /**
  2255. * Get an array of tags with weights for use with the output/tagcloud view.
  2256. *
  2257. * @deprecated 1.8 Use elgg_get_tags().
  2258. *
  2259. * @param int $threshold Get the threshold of minimum number of each tags to
  2260. * bother with (ie only show tags where there are more
  2261. * than $threshold occurances)
  2262. * @param int $limit Number of tags to return
  2263. * @param string $metadata_name Optionally, the name of the field you want to grab for
  2264. * @param string $entity_type Optionally, the entity type ('object' etc)
  2265. * @param string $entity_subtype The entity subtype, optionally
  2266. * @param int $owner_guid The GUID of the tags owner, optionally
  2267. * @param int $site_guid Optionally, the site to restrict to (default is the current site)
  2268. * @param int $start_ts Optionally specify a start timestamp for tags used to
  2269. * generate cloud.
  2270. * @param int $end_ts Optionally specify an end timestamp for tags used to generate cloud
  2271. *
  2272. * @return array|false Array of objects with ->tag and ->total values, or false on failure
  2273. */
  2274. function get_tags($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object",
  2275. $entity_subtype = "", $owner_guid = "", $site_guid = -1, $start_ts = "", $end_ts = "") {
  2276. elgg_deprecated_notice('get_tags() has been replaced by elgg_get_tags()', 1.8);
  2277. if (is_array($metadata_name)) {
  2278. return false;
  2279. }
  2280. $options = array();
  2281. if ($metadata_name === '') {
  2282. $options['tag_names'] = array();
  2283. } else {
  2284. $options['tag_names'] = array($metadata_name);
  2285. }
  2286. $options['threshold'] = $threshold;
  2287. $options['limit'] = $limit;
  2288. // rewrite owner_guid to container_guid to emulate old functionality
  2289. $container_guid = $owner_guid;
  2290. if ($container_guid) {
  2291. $options['container_guids'] = $container_guid;
  2292. }
  2293. if ($entity_type) {
  2294. $options['type'] = $entity_type;
  2295. }
  2296. if ($entity_subtype) {
  2297. $options['subtype'] = $entity_subtype;
  2298. }
  2299. if ($site_guid != -1) {
  2300. $options['site_guids'] = $site_guid;
  2301. }
  2302. if ($end_ts) {
  2303. $options['created_time_upper'] = $end_ts;
  2304. }
  2305. if ($start_ts) {
  2306. $options['created_time_lower'] = $start_ts;
  2307. }
  2308. $r = elgg_get_tags($options);
  2309. return $r;
  2310. }
  2311. /**
  2312. * Loads and displays a tagcloud given particular criteria.
  2313. *
  2314. * @deprecated 1.8 use elgg_view_tagcloud()
  2315. *
  2316. * @param int $threshold Get the threshold of minimum number of each tags
  2317. * to bother with (ie only show tags where there are
  2318. * more than $threshold occurances)
  2319. * @param int $limit Number of tags to return
  2320. * @param string $metadata_name Optionally, the name of the field you want to grab for
  2321. * @param string $entity_type Optionally, the entity type ('object' etc)
  2322. * @param string $entity_subtype The entity subtype, optionally
  2323. * @param int $owner_guid The GUID of the tags owner, optionally
  2324. * @param int $site_guid Optionally, the site to restrict to (default is the current site)
  2325. * @param int $start_ts Optionally specify a start timestamp for tags used to
  2326. * generate cloud.
  2327. * @param int $end_ts Optionally specify an end timestamp for tags used to generate
  2328. * cloud.
  2329. *
  2330. * @return string The HTML (or other, depending on view type) of the tagcloud.
  2331. */
  2332. function display_tagcloud($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object",
  2333. $entity_subtype = "", $owner_guid = "", $site_guid = -1, $start_ts = "", $end_ts = "") {
  2334. elgg_deprecated_notice('display_tagcloud() was deprecated by elgg_view_tagcloud()!', 1.8);
  2335. $tags = get_tags($threshold, $limit, $metadata_name, $entity_type,
  2336. $entity_subtype, $owner_guid, $site_guid, $start_ts, $end_ts);
  2337. return elgg_view('output/tagcloud', array(
  2338. 'value' => $tags,
  2339. 'type' => $entity_type,
  2340. 'subtype' => $entity_subtype,
  2341. ));
  2342. }
  2343. /**
  2344. * Obtains a list of objects owned by a user
  2345. *
  2346. * @param int $user_guid The GUID of the owning user
  2347. * @param string $subtype Optionally, the subtype of objects
  2348. * @param int $limit The number of results to return (default 10)
  2349. * @param int $offset Indexing offset, if any
  2350. * @param int $timelower The earliest time the entity can have been created. Default: all
  2351. * @param int $timeupper The latest time the entity can have been created. Default: all
  2352. *
  2353. * @return false|array An array of \ElggObjects or false, depending on success
  2354. * @deprecated 1.8 Use elgg_get_entities() instead
  2355. */
  2356. function get_user_objects($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $limit = 10,
  2357. $offset = 0, $timelower = 0, $timeupper = 0) {
  2358. elgg_deprecated_notice("get_user_objects() was deprecated in favor of elgg_get_entities()", 1.8);
  2359. $ntt = elgg_get_entities(array(
  2360. 'type' => 'object',
  2361. 'subtype' => $subtype,
  2362. 'owner_guid' => $user_guid,
  2363. 'limit' => $limit,
  2364. 'offset' => $offset,
  2365. 'container_guid' => $user_guid,
  2366. 'created_time_lower' => $timelower,
  2367. 'created_time_upper' => $timeupper
  2368. ));
  2369. return $ntt;
  2370. }
  2371. /**
  2372. * Counts the objects (optionally of a particular subtype) owned by a user
  2373. *
  2374. * @param int $user_guid The GUID of the owning user
  2375. * @param string $subtype Optionally, the subtype of objects
  2376. * @param int $timelower The earliest time the entity can have been created. Default: all
  2377. * @param int $timeupper The latest time the entity can have been created. Default: all
  2378. *
  2379. * @return int The number of objects the user owns (of this subtype)
  2380. * @deprecated 1.8 Use elgg_get_entities() instead
  2381. */
  2382. function count_user_objects($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $timelower = 0,
  2383. $timeupper = 0) {
  2384. elgg_deprecated_notice("count_user_objects() was deprecated in favor of elgg_get_entities()", 1.8);
  2385. $total = elgg_get_entities(array(
  2386. 'type' => 'object',
  2387. 'subtype' => $subtype,
  2388. 'owner_guid' => $user_guid,
  2389. 'count' => TRUE,
  2390. 'container_guid' => $user_guid,
  2391. 'created_time_lower' => $timelower,
  2392. 'created_time_upper' => $timeupper
  2393. ));
  2394. return $total;
  2395. }
  2396. /**
  2397. * Displays a list of user objects of a particular subtype, with navigation.
  2398. *
  2399. * @see elgg_view_entity_list
  2400. *
  2401. * @param int $user_guid The GUID of the user
  2402. * @param string $subtype The object subtype
  2403. * @param int $limit The number of entities to display on a page
  2404. * @param bool $fullview Whether or not to display the full view (default: true)
  2405. * @param bool $listtypetoggle Whether or not to allow gallery view (default: true)
  2406. * @param bool $pagination Whether to display pagination (default: true)
  2407. * @param int $timelower The earliest time the entity can have been created. Default: all
  2408. * @param int $timeupper The latest time the entity can have been created. Default: all
  2409. *
  2410. * @return string The list in a form suitable to display
  2411. * @deprecated 1.8 Use elgg_list_entities() instead
  2412. */
  2413. function list_user_objects($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $limit = 10,
  2414. $fullview = true, $listtypetoggle = true, $pagination = true, $timelower = 0, $timeupper = 0) {
  2415. elgg_deprecated_notice("list_user_objects() was deprecated in favor of elgg_list_entities()", 1.8);
  2416. $offset = (int) get_input('offset');
  2417. $limit = (int) $limit;
  2418. $count = (int) count_user_objects($user_guid, $subtype, $timelower, $timeupper);
  2419. $entities = get_user_objects($user_guid, $subtype, $limit, $offset, $timelower, $timeupper);
  2420. return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle,
  2421. $pagination);
  2422. }
  2423. /**
  2424. * Get user objects by an array of metadata
  2425. *
  2426. * @param int $user_guid The GUID of the owning user
  2427. * @param string $subtype Optionally, the subtype of objects
  2428. * @param array $metadata An array of metadata
  2429. * @param int $limit The number of results to return (default 10)
  2430. * @param int $offset Indexing offset, if any
  2431. *
  2432. * @return false|array An array of \ElggObjects or false, depending on success
  2433. * @deprecated 1.8 Use elgg_get_entities_from_metadata() instead
  2434. */
  2435. function get_user_objects_by_metadata($user_guid, $subtype = "", $metadata = array(),
  2436. $limit = 0, $offset = 0) {
  2437. elgg_deprecated_notice("get_user_objects_by_metadata() was deprecated in favor of elgg_get_entities_from_metadata()", 1.8);
  2438. return get_entities_from_metadata_multi($metadata, "object", $subtype, $user_guid,
  2439. $limit, $offset);
  2440. }
  2441. /**
  2442. * Set the validation status for a user.
  2443. *
  2444. * @param bool $status Validated (true) or false
  2445. * @param string $method Optional method to say how a user was validated
  2446. * @return bool
  2447. * @deprecated 1.8 Use elgg_set_user_validation_status()
  2448. */
  2449. function set_user_validation_status($user_guid, $status, $method = '') {
  2450. elgg_deprecated_notice("set_user_validation_status() is deprecated", 1.8);
  2451. return elgg_set_user_validation_status($user_guid, $status, $method);
  2452. }
  2453. /**
  2454. * Trigger an event requesting that a user guid be validated somehow - either by email address or some other way.
  2455. *
  2456. * This function invalidates any existing validation value.
  2457. *
  2458. * @param int $user_guid User's GUID
  2459. * @deprecated 1.8 Hook into the register, user plugin hook and request validation.
  2460. */
  2461. function request_user_validation($user_guid) {
  2462. elgg_deprecated_notice("request_user_validation() is deprecated.
  2463. Plugins should register for the 'register, user' plugin hook", 1.8);
  2464. $user = get_entity($user_guid);
  2465. if (($user) && ($user instanceof \ElggUser)) {
  2466. // invalidate any existing validations
  2467. set_user_validation_status($user_guid, false);
  2468. // request validation
  2469. trigger_elgg_event('validate', 'user', $user);
  2470. }
  2471. }
  2472. /**
  2473. * Register a user settings page with the admin panel.
  2474. * This function extends the view "usersettings/main" with the provided view.
  2475. * This view should provide a description and either a control or a link to.
  2476. *
  2477. * Usage:
  2478. * - To add a control to the main admin panel then extend usersettings/main
  2479. * - To add a control to a new page create a page which renders a view
  2480. * usersettings/subpage (where subpage is your new page -
  2481. * nb. some pages already exist that you can extend), extend the main view
  2482. * to point to it, and add controls to your new view.
  2483. *
  2484. * At the moment this is essentially a wrapper around elgg_extend_view().
  2485. *
  2486. * @param string $new_settings_view The view associated with the control you're adding
  2487. * @param string $view The view to extend, by default this is 'usersettings/main'.
  2488. * @param int $priority Optional priority to govern the appearance in the list.
  2489. *
  2490. * @return bool
  2491. * @deprecated 1.8 Extend one of the views in core/settings
  2492. */
  2493. function extend_elgg_settings_page($new_settings_view, $view = 'usersettings/main',
  2494. $priority = 500) {
  2495. // see views: /core/settings
  2496. elgg_deprecated_notice("extend_elgg_settings_page has been deprecated. Extend one of the settings views instead", 1.8);
  2497. return elgg_extend_view($view, $new_settings_view, $priority);
  2498. }
  2499. /**
  2500. * Returns a representation of a full 'page' (which might be an HTML page,
  2501. * RSS file, etc, depending on the current viewtype)
  2502. *
  2503. * @param string $title
  2504. * @param string $body
  2505. * @return string
  2506. *
  2507. * @deprecated 1.8 Use elgg_view_page()
  2508. */
  2509. function page_draw($title, $body, $sidebar = "") {
  2510. elgg_deprecated_notice("page_draw() was deprecated in favor of elgg_view_page() in 1.8.", 1.8);
  2511. $vars = array(
  2512. 'sidebar' => $sidebar
  2513. );
  2514. echo elgg_view_page($title, $body, 'default', $vars);
  2515. }
  2516. /**
  2517. * Wrapper function to display search listings.
  2518. *
  2519. * @param string $icon The icon for the listing
  2520. * @param string $info Any information that needs to be displayed.
  2521. *
  2522. * @return string The HTML (etc) representing the listing
  2523. * @deprecated 1.8 use elgg_view_image_block()
  2524. */
  2525. function elgg_view_listing($icon, $info) {
  2526. elgg_deprecated_notice('elgg_view_listing deprecated by elgg_view_image_block', 1.8);
  2527. return elgg_view('page/components/image_block', array('image' => $icon, 'body' => $info));
  2528. }
  2529. /**
  2530. * Return the icon URL for an entity.
  2531. *
  2532. * @tip Can be overridden by registering a plugin hook for entity:icon:url, $entity_type.
  2533. *
  2534. * @internal This is passed an entity rather than a guid to handle non-created entities.
  2535. *
  2536. * @param \ElggEntity $entity The entity
  2537. * @param string $size Icon size
  2538. *
  2539. * @return string URL to the entity icon.
  2540. * @deprecated 1.8 Use $entity->getIconURL()
  2541. */
  2542. function get_entity_icon_url(\ElggEntity $entity, $size = 'medium') {
  2543. elgg_deprecated_notice("get_entity_icon_url() deprecated for getIconURL()", 1.8);
  2544. global $CONFIG;
  2545. $size = sanitise_string($size);
  2546. switch (strtolower($size)) {
  2547. case 'master':
  2548. $size = 'master';
  2549. break;
  2550. case 'large' :
  2551. $size = 'large';
  2552. break;
  2553. case 'topbar' :
  2554. $size = 'topbar';
  2555. break;
  2556. case 'tiny' :
  2557. $size = 'tiny';
  2558. break;
  2559. case 'small' :
  2560. $size = 'small';
  2561. break;
  2562. case 'medium' :
  2563. default:
  2564. $size = 'medium';
  2565. }
  2566. $url = false;
  2567. $viewtype = elgg_get_viewtype();
  2568. // Step one, see if anyone knows how to render this in the current view
  2569. $params = array('entity' => $entity, 'viewtype' => $viewtype, 'size' => $size);
  2570. $url = elgg_trigger_plugin_hook('entity:icon:url', $entity->getType(), $params, $url);
  2571. // Fail, so use default
  2572. if (!$url) {
  2573. $type = $entity->getType();
  2574. $subtype = $entity->getSubtype();
  2575. if (!empty($subtype)) {
  2576. $overrideurl = elgg_view("icon/{$type}/{$subtype}/{$size}", array('entity' => $entity));
  2577. if (!empty($overrideurl)) {
  2578. return $overrideurl;
  2579. }
  2580. }
  2581. $overrideurl = elgg_view("icon/{$type}/default/{$size}", array('entity' => $entity));
  2582. if (!empty($overrideurl)) {
  2583. return $overrideurl;
  2584. }
  2585. $url = "_graphics/icons/default/$size.png";
  2586. }
  2587. return elgg_normalize_url($url);
  2588. }
  2589. /**
  2590. * Return the current logged in user, or NULL if no user is logged in.
  2591. *
  2592. * If no user can be found in the current session, a plugin
  2593. * hook - 'session:get' 'user' to give plugin authors another
  2594. * way to provide user details to the ACL system without touching the session.
  2595. *
  2596. * @deprecated 1.8 Use elgg_get_logged_in_user_entity()
  2597. * @return \ElggUser|NULL
  2598. */
  2599. function get_loggedin_user() {
  2600. elgg_deprecated_notice('get_loggedin_user() is deprecated by elgg_get_logged_in_user_entity()', 1.8);
  2601. return elgg_get_logged_in_user_entity();
  2602. }
  2603. /**
  2604. * Return the current logged in user by id.
  2605. *
  2606. * @deprecated 1.8 Use elgg_get_logged_in_user_guid()
  2607. * @see elgg_get_logged_in_user_entity()
  2608. * @return int
  2609. */
  2610. function get_loggedin_userid() {
  2611. elgg_deprecated_notice('get_loggedin_userid() is deprecated by elgg_get_logged_in_user_guid()', 1.8);
  2612. return elgg_get_logged_in_user_guid();
  2613. }
  2614. /**
  2615. * Returns whether or not the user is currently logged in
  2616. *
  2617. * @deprecated 1.8 Use elgg_is_logged_in();
  2618. * @return bool
  2619. */
  2620. function isloggedin() {
  2621. elgg_deprecated_notice('isloggedin() is deprecated by elgg_is_logged_in()', 1.8);
  2622. return elgg_is_logged_in();
  2623. }
  2624. /**
  2625. * Returns whether or not the user is currently logged in and that they are an admin user.
  2626. *
  2627. * @deprecated 1.8 Use elgg_is_admin_logged_in()
  2628. * @return bool
  2629. */
  2630. function isadminloggedin() {
  2631. elgg_deprecated_notice('isadminloggedin() is deprecated by elgg_is_admin_logged_in()', 1.8);
  2632. return elgg_is_admin_logged_in();
  2633. }
  2634. /**
  2635. * Loads plugins
  2636. *
  2637. * @deprecated 1.8 Use elgg_load_plugins()
  2638. *
  2639. * @return bool
  2640. */
  2641. function load_plugins() {
  2642. elgg_deprecated_notice('load_plugins() is deprecated by elgg_load_plugins()', 1.8);
  2643. return _elgg_load_plugins();
  2644. }
  2645. /**
  2646. * Find the plugin settings for a user.
  2647. *
  2648. * @param string $plugin_id Plugin name.
  2649. * @param int $user_guid The guid who's settings to retrieve.
  2650. *
  2651. * @deprecated 1.8 Use elgg_get_all_plugin_user_settings() or \ElggPlugin->getAllUserSettings()
  2652. * @return StdClass Object with all user settings.
  2653. */
  2654. function find_plugin_usersettings($plugin_id = null, $user_guid = 0) {
  2655. elgg_deprecated_notice('find_plugin_usersettings() is deprecated by elgg_get_all_plugin_user_settings()', 1.8);
  2656. return elgg_get_all_plugin_user_settings($user_guid, $plugin_id, true);
  2657. }
  2658. /**
  2659. * Set a user specific setting for a plugin.
  2660. *
  2661. * @param string $name The name - note, can't be "title".
  2662. * @param mixed $value The value.
  2663. * @param int $user_guid Optional user.
  2664. * @param string $plugin_id Optional plugin name, if not specified then it
  2665. * is detected from where you are calling from.
  2666. *
  2667. * @return bool
  2668. * @deprecated 1.8 Use elgg_set_plugin_user_setting() or \ElggPlugin->setUserSetting()
  2669. */
  2670. function set_plugin_usersetting($name, $value, $user_guid = 0, $plugin_id = "") {
  2671. elgg_deprecated_notice('find_plugin_usersettings() is deprecated by elgg_get_all_plugin_user_settings()', 1.8);
  2672. return elgg_set_plugin_user_setting($name, $value, $user_guid, $plugin_id);
  2673. }
  2674. /**
  2675. * Clears a user-specific plugin setting
  2676. *
  2677. * @param string $name Name of the plugin setting
  2678. * @param int $user_guid Defaults to logged in user
  2679. * @param string $plugin_id Defaults to contextual plugin name
  2680. *
  2681. * @deprecated 1.8 Use elgg_unset_plugin_user_setting or \ElggPlugin->unsetUserSetting().
  2682. * @return bool Success
  2683. */
  2684. function clear_plugin_usersetting($name, $user_guid = 0, $plugin_id = '') {
  2685. elgg_deprecated_notice('clear_plugin_usersetting() is deprecated by elgg_unset_plugin_usersetting()', 1.8);
  2686. return elgg_unset_plugin_user_setting($name, $user_guid, $plugin_id);
  2687. }
  2688. /**
  2689. * Get a user specific setting for a plugin.
  2690. *
  2691. * @param string $name The name.
  2692. * @param int $user_guid Guid of owning user
  2693. * @param string $plugin_id Optional plugin name, if not specified
  2694. * it is detected from where you are calling.
  2695. *
  2696. * @deprecated 1.8 Use elgg_get_plugin_user_setting() or \ElggPlugin->getUserSetting()
  2697. * @return mixed
  2698. */
  2699. function get_plugin_usersetting($name, $user_guid = 0, $plugin_id = "") {
  2700. elgg_deprecated_notice('get_plugin_usersetting() is deprecated by elgg_get_plugin_user_setting()', 1.8);
  2701. return elgg_get_plugin_user_setting($name, $user_guid, $plugin_id);
  2702. }
  2703. /**
  2704. * Set a setting for a plugin.
  2705. *
  2706. * @param string $name The name - note, can't be "title".
  2707. * @param mixed $value The value.
  2708. * @param string $plugin_id Optional plugin name, if not specified
  2709. * then it is detected from where you are calling from.
  2710. *
  2711. * @deprecated 1.8 Use elgg_set_plugin_setting() or \ElggPlugin->setSetting()
  2712. * @return int|false
  2713. */
  2714. function set_plugin_setting($name, $value, $plugin_id = null) {
  2715. elgg_deprecated_notice('set_plugin_setting() is deprecated by elgg_set_plugin_setting()', 1.8);
  2716. return elgg_set_plugin_setting($name, $value, $plugin_id);
  2717. }
  2718. /**
  2719. * Get setting for a plugin.
  2720. *
  2721. * @param string $name The name.
  2722. * @param string $plugin_id Optional plugin name, if not specified
  2723. * then it is detected from where you are calling from.
  2724. *
  2725. * @deprecated 1.8 Use elgg_get_plugin_setting() or \ElggPlugin->getSetting()
  2726. * @return mixed
  2727. */
  2728. function get_plugin_setting($name, $plugin_id = "") {
  2729. elgg_deprecated_notice('get_plugin_setting() is deprecated by elgg_get_plugin_setting()', 1.8);
  2730. return elgg_get_plugin_setting($name, $plugin_id);
  2731. }
  2732. /**
  2733. * Clear a plugin setting.
  2734. *
  2735. * @param string $name The name.
  2736. * @param string $plugin_id Optional plugin name, if not specified
  2737. * then it is detected from where you are calling from.
  2738. *
  2739. * @deprecated 1.8 Use elgg_unset_plugin_setting() or \ElggPlugin->unsetSetting()
  2740. * @return bool
  2741. */
  2742. function clear_plugin_setting($name, $plugin_id = "") {
  2743. elgg_deprecated_notice('clear_plugin_setting() is deprecated by elgg_unset_plugin_setting()', 1.8);
  2744. return elgg_unset_plugin_setting($name, $plugin_id);
  2745. }
  2746. /**
  2747. * Unsets all plugin settings for a plugin.
  2748. *
  2749. * @param string $plugin_id Optional plugin name, if not specified
  2750. * then it is detected from where you are calling from.
  2751. *
  2752. * @return bool
  2753. * @deprecated 1.8 Use elgg_unset_all_plugin_settings() or \ElggPlugin->unsetAllSettings()
  2754. * @since 1.7.0
  2755. */
  2756. function clear_all_plugin_settings($plugin_id = "") {
  2757. elgg_deprecated_notice('clear_all_plugin_settings() is deprecated by elgg_unset_all_plugin_setting()', 1.8);
  2758. return elgg_unset_all_plugin_settings($plugin_id);
  2759. }
  2760. /**
  2761. * Get a list of annotations for a given object/user/annotation type.
  2762. *
  2763. * @param int|array $entity_guid GUID to return annotations of (falsey for any)
  2764. * @param string $entity_type Type of entity
  2765. * @param string $entity_subtype Subtype of entity
  2766. * @param string $name Name of annotation
  2767. * @param mixed $value Value of annotation
  2768. * @param int|array $owner_guid Owner(s) of annotation
  2769. * @param int $limit Limit
  2770. * @param int $offset Offset
  2771. * @param string $order_by Order annotations by SQL
  2772. * @param int $timelower Lower time limit
  2773. * @param int $timeupper Upper time limit
  2774. * @param int $entity_owner_guid Owner guid for the entity
  2775. *
  2776. * @return array
  2777. * @deprecated 1.8 Use elgg_get_annotations()
  2778. */
  2779. function get_annotations($entity_guid = 0, $entity_type = "", $entity_subtype = "", $name = "",
  2780. $value = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "asc", $timelower = 0,
  2781. $timeupper = 0, $entity_owner_guid = 0) {
  2782. elgg_deprecated_notice('get_annotations() is deprecated by elgg_get_annotations()', 1.8);
  2783. $options = array();
  2784. if ($entity_guid) {
  2785. $options['guid'] = $entity_guid;
  2786. }
  2787. if ($entity_type) {
  2788. $options['type'] = $entity_type;
  2789. }
  2790. if ($entity_subtype) {
  2791. $options['subtype'] = $entity_subtype;
  2792. }
  2793. if ($name) {
  2794. $options['annotation_name'] = $name;
  2795. }
  2796. if ($value) {
  2797. $options['annotation_value'] = $value;
  2798. }
  2799. if ($owner_guid) {
  2800. $options['annotation_owner_guid'] = $owner_guid;
  2801. }
  2802. $options['limit'] = $limit;
  2803. $options['offset'] = $offset;
  2804. if ($order_by == 'desc') {
  2805. $options['order_by'] = 'n_table.time_created desc';
  2806. }
  2807. if ($timelower) {
  2808. $options['annotation_time_lower'] = $timelower;
  2809. }
  2810. if ($timeupper) {
  2811. $options['annotation_time_upper'] = $timeupper;
  2812. }
  2813. if ($entity_owner_guid) {
  2814. $options['owner_guid'] = $entity_owner_guid;
  2815. }
  2816. return elgg_get_annotations($options);
  2817. }
  2818. /**
  2819. * Returns a human-readable list of annotations on a particular entity.
  2820. *
  2821. * @param int $entity_guid The entity GUID
  2822. * @param string $name The name of the kind of annotation
  2823. * @param int $limit The number of annotations to display at once
  2824. * @param true|false $asc Display annotations in ascending order. (Default: true)
  2825. *
  2826. * @return string HTML (etc) version of the annotation list
  2827. * @deprecated 1.8 Use elgg_list_annotations()
  2828. */
  2829. function list_annotations($entity_guid, $name = "", $limit = 25, $asc = true) {
  2830. elgg_deprecated_notice('list_annotations() is deprecated by elgg_list_annotations()', 1.8);
  2831. if ($asc) {
  2832. $asc = "asc";
  2833. } else {
  2834. $asc = "desc";
  2835. }
  2836. $options = array(
  2837. 'guid' => $entity_guid,
  2838. 'limit' => $limit,
  2839. 'order_by' => "n_table.time_created $asc"
  2840. );
  2841. return elgg_list_annotations($options);
  2842. }
  2843. /**
  2844. * Helper function to deprecate annotation calculation functions. Don't use.
  2845. *
  2846. * @param unknown_type $entity_guid
  2847. * @param unknown_type $entity_type
  2848. * @param unknown_type $entity_subtype
  2849. * @param unknown_type $name
  2850. * @param unknown_type $value
  2851. * @param unknown_type $value_type
  2852. * @param unknown_type $owner_guid
  2853. * @param unknown_type $timelower
  2854. * @param unknown_type $timeupper
  2855. * @param unknown_type $calculation
  2856. * @internal Don't use this at all.
  2857. * @deprecated 1.8 Use elgg_get_annotations()
  2858. */
  2859. function elgg_deprecated_annotation_calculation($entity_guid = 0, $entity_type = "", $entity_subtype = "",
  2860. $name = "", $value = "", $value_type = "", $owner_guid = 0, $timelower = 0,
  2861. $timeupper = 0, $calculation = '') {
  2862. $options = array('annotation_calculation' => $calculation);
  2863. if ($entity_guid) {
  2864. $options['guid'] = $entity_guid;
  2865. }
  2866. if ($entity_type) {
  2867. $options['type'] = $entity_type;
  2868. }
  2869. if ($entity_subtype) {
  2870. $options['subtype'] = $entity_subtype;
  2871. }
  2872. if ($name) {
  2873. $options['annotation_name'] = $name;
  2874. }
  2875. if ($value) {
  2876. $options['annotation_value'] = $value;
  2877. }
  2878. if ($owner_guid) {
  2879. $options['annotation_owner_guid'] = $owner_guid;
  2880. }
  2881. if ($timelower) {
  2882. $options['annotation_time_lower'] = $timelower;
  2883. }
  2884. if ($timeupper) {
  2885. $options['annotation_time_upper'] = $timeupper;
  2886. }
  2887. return elgg_get_annotations($options);
  2888. }
  2889. /**
  2890. * Count the number of annotations based on search parameters
  2891. *
  2892. * @param int $entity_guid Guid of Entity
  2893. * @param string $entity_type Type of Entity
  2894. * @param string $entity_subtype Subtype of Entity
  2895. * @param string $name Name of annotation
  2896. * @param string $value Value of annotation
  2897. * @param string $value_type Type of value
  2898. * @param int $owner_guid GUID of owner of annotation
  2899. * @param int $timelower Lower time limit
  2900. * @param int $timeupper Upper time limit
  2901. *
  2902. * @deprecated 1.8 Use elgg_get_annotations() and pass 'count' => true
  2903. * @return int
  2904. */
  2905. function count_annotations($entity_guid = 0, $entity_type = "", $entity_subtype = "",
  2906. $name = "", $value = "", $value_type = "", $owner_guid = 0, $timelower = 0,
  2907. $timeupper = 0) {
  2908. elgg_deprecated_notice('count_annotations() is deprecated by elgg_get_annotations() and passing "count" => true', 1.8);
  2909. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  2910. $name, $value, $value_type, $owner_guid, $timelower, $timeupper, 'count');
  2911. }
  2912. /**
  2913. * Return the sum of a given integer annotation.
  2914. *
  2915. * @param int $entity_guid Guid of Entity
  2916. * @param string $entity_type Type of Entity
  2917. * @param string $entity_subtype Subtype of Entity
  2918. * @param string $name Name of annotation
  2919. * @param string $value Value of annotation
  2920. * @param string $value_type Type of value
  2921. * @param int $owner_guid GUID of owner of annotation
  2922. *
  2923. * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'sum'
  2924. * @return int
  2925. */
  2926. function get_annotations_sum($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
  2927. $value = "", $value_type = "", $owner_guid = 0) {
  2928. elgg_deprecated_notice('get_annotations_sum() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "sum"', 1.8);
  2929. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  2930. $name, $value, $value_type, $owner_guid, 0, 0, 'sum');
  2931. }
  2932. /**
  2933. * Return the max of a given integer annotation.
  2934. *
  2935. * @param int $entity_guid Guid of Entity
  2936. * @param string $entity_type Type of Entity
  2937. * @param string $entity_subtype Subtype of Entity
  2938. * @param string $name Name of annotation
  2939. * @param string $value Value of annotation
  2940. * @param string $value_type Type of value
  2941. * @param int $owner_guid GUID of owner of annotation
  2942. *
  2943. * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'max'
  2944. * @return int
  2945. */
  2946. function get_annotations_max($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
  2947. $value = "", $value_type = "", $owner_guid = 0) {
  2948. elgg_deprecated_notice('get_annotations_max() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "max"', 1.8);
  2949. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  2950. $name, $value, $value_type, $owner_guid, 0, 0, 'max');
  2951. }
  2952. /**
  2953. * Return the minumum of a given integer annotation.
  2954. *
  2955. * @param int $entity_guid Guid of Entity
  2956. * @param string $entity_type Type of Entity
  2957. * @param string $entity_subtype Subtype of Entity
  2958. * @param string $name Name of annotation
  2959. * @param string $value Value of annotation
  2960. * @param string $value_type Type of value
  2961. * @param int $owner_guid GUID of owner of annotation
  2962. *
  2963. * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'min'
  2964. * @return int
  2965. */
  2966. function get_annotations_min($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
  2967. $value = "", $value_type = "", $owner_guid = 0) {
  2968. elgg_deprecated_notice('get_annotations_min() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "min"', 1.8);
  2969. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  2970. $name, $value, $value_type, $owner_guid, 0, 0, 'min');
  2971. }
  2972. /**
  2973. * Return the average of a given integer annotation.
  2974. *
  2975. * @param int $entity_guid Guid of Entity
  2976. * @param string $entity_type Type of Entity
  2977. * @param string $entity_subtype Subtype of Entity
  2978. * @param string $name Name of annotation
  2979. * @param string $value Value of annotation
  2980. * @param string $value_type Type of value
  2981. * @param int $owner_guid GUID of owner of annotation
  2982. *
  2983. * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'min'
  2984. *
  2985. * @return int
  2986. */
  2987. function get_annotations_avg($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
  2988. $value = "", $value_type = "", $owner_guid = 0) {
  2989. elgg_deprecated_notice('get_annotations_avg() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "avg"', 1.8);
  2990. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  2991. $name, $value, $value_type, $owner_guid, 0, 0, 'avg');
  2992. }
  2993. /**
  2994. * Perform a mathmatical calculation on integer annotations.
  2995. *
  2996. * @param string $sum What sort of calculation to perform
  2997. * @param int $entity_guid Guid of Entity
  2998. * @param string $entity_type Type of Entity
  2999. * @param string $entity_subtype Subtype of Entity
  3000. * @param string $name Name of annotation
  3001. * @param string $value Value of annotation
  3002. * @param string $value_type Type of value
  3003. * @param int $owner_guid GUID of owner of annotation
  3004. * @param int $timelower Lower time limit
  3005. * @param int $timeupper Upper time limit
  3006. *
  3007. * @return int
  3008. * @deprecated 1.8 Use elgg_get_annotations() and pass anntoation_calculation => <calculation>
  3009. */
  3010. function get_annotations_calculate_x($sum = "avg", $entity_guid, $entity_type = "",
  3011. $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0,
  3012. $timelower = 0, $timeupper = 0) {
  3013. elgg_deprecated_notice('get_annotations_calculate_x() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "calculation"', 1.8);
  3014. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  3015. $name, $value, $value_type, $owner_guid, $timelower, $timeupper, $sum);
  3016. }
  3017. /**
  3018. * Lists entities by the totals of a particular kind of annotation AND
  3019. * the value of a piece of metadata
  3020. *
  3021. * @param string $entity_type Type of entity.
  3022. * @param string $entity_subtype Subtype of entity.
  3023. * @param string $name Name of annotation.
  3024. * @param string $mdname Metadata name
  3025. * @param string $mdvalue Metadata value
  3026. * @param int $limit Maximum number of results to return.
  3027. * @param int $owner_guid Owner.
  3028. * @param int $group_guid Group container. Currently only supported if entity_type is object
  3029. * @param boolean $asc Whether to list in ascending or descending order (default: desc)
  3030. * @param boolean $fullview Whether to display the entities in full
  3031. * @param boolean $listtypetoggle Can the 'gallery' view can be displayed (default: no)
  3032. * @param boolean $pagination Display pagination
  3033. * @param string $orderdir 'desc' or 'asc'
  3034. *
  3035. * @deprecated 1.8 Use elgg_list_entities_from_annotation_calculation().
  3036. *
  3037. * @return string Formatted entity list
  3038. */
  3039. function list_entities_from_annotation_count_by_metadata($entity_type = "", $entity_subtype = "",
  3040. $name = "", $mdname = '', $mdvalue = '', $limit = 10, $owner_guid = 0, $group_guid = 0,
  3041. $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $orderdir = 'desc') {
  3042. $msg = 'list_entities_from_annotation_count_by_metadata() is deprecated by elgg_list_entities_from_annotation_calculation().';
  3043. elgg_deprecated_notice($msg, 1.8);
  3044. $options = array();
  3045. $options['calculation'] = 'sum';
  3046. if ($entity_type) {
  3047. $options['types'] = $entity_type;
  3048. }
  3049. if ($entity_subtype) {
  3050. $options['subtypes'] = $entity_subtype;
  3051. }
  3052. $options['annotation_names'] = $name;
  3053. if ($mdname) {
  3054. $options['metadata_name'] = $mdname;
  3055. }
  3056. if ($mdvalue) {
  3057. $options['metadata_value'] = $mdvalue;
  3058. }
  3059. if ($owner_guid) {
  3060. if (is_array($owner_guid)) {
  3061. $options['owner_guids'] = $owner_guid;
  3062. } else {
  3063. $options['owner_guid'] = $owner_guid;
  3064. }
  3065. }
  3066. $options['full_view'] = $fullview;
  3067. $options['list_type_toggle'] = $listtypetoggle;
  3068. $options['pagination'] = $pagination;
  3069. $options['limit'] = $limit;
  3070. $options['order_by'] = "annotation_calculation $orderdir";
  3071. return elgg_get_entities_from_annotation_calculation($options);
  3072. }
  3073. /**
  3074. * Set an alternative base location for a view (as opposed to the default of $CONFIG->viewpath)
  3075. *
  3076. * @param string $view The name of the view
  3077. * @param string $location The base location path
  3078. *
  3079. * @deprecated 1.8 Use elgg_set_view_location()
  3080. */
  3081. function set_view_location($view, $location, $viewtype = '') {
  3082. elgg_deprecated_notice("set_view_location() was deprecated by elgg_set_view_location()", 1.8);
  3083. return elgg_set_view_location($view, $location, $viewtype);
  3084. }
  3085. /**
  3086. * Sets the URL handler for a particular entity type and subtype
  3087. *
  3088. * @param string $function_name The function to register
  3089. * @param string $entity_type The entity type
  3090. * @param string $entity_subtype The entity subtype
  3091. * @return true|false Depending on success
  3092. *
  3093. * @deprecated 1.8 Use elgg_register_entity_url_handler()
  3094. */
  3095. function register_entity_url_handler($function_name, $entity_type = "all", $entity_subtype = "all") {
  3096. elgg_deprecated_notice("register_entity_url_handler() was deprecated by elgg_register_entity_url_handler()", 1.8);
  3097. return elgg_register_entity_url_handler($entity_type, $entity_subtype, $function_name);
  3098. }
  3099. /**
  3100. * Get the metadata where the entities they are referring to match a given criteria.
  3101. *
  3102. * @param mixed $meta_name Metadata name
  3103. * @param mixed $meta_value Metadata value
  3104. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  3105. * @param string $entity_subtype The subtype of the entity.
  3106. * @param int $limit Limit
  3107. * @param int $offset Offset
  3108. * @param string $order_by Optional ordering.
  3109. * @param int $site_guid Site GUID. 0 for current, -1 for any
  3110. *
  3111. * @return mixed
  3112. * @deprecated 1.8 Use elgg_get_metadata()
  3113. */
  3114. function find_metadata($meta_name = "", $meta_value = "", $entity_type = "", $entity_subtype = "",
  3115. $limit = 10, $offset = 0, $order_by = "", $site_guid = 0) {
  3116. elgg_deprecated_notice('get_metadata() is deprecated by elgg_get_metadata()', 1.8);
  3117. $options = array();
  3118. if ($meta_name) {
  3119. $options['annotation_name'] = $meta_name;
  3120. }
  3121. if ($meta_value) {
  3122. $options['annotation_value'] = $meta_value;
  3123. }
  3124. if ($entity_type) {
  3125. $options['type'] = $entity_type;
  3126. }
  3127. if ($entity_subtype) {
  3128. $options['subtype'] = $entity_subtype;
  3129. }
  3130. $options['limit'] = $limit;
  3131. $options['offset'] = $offset;
  3132. if ($order_by == 'desc') {
  3133. $options['order_by'] = 'n_table.time_created desc';
  3134. }
  3135. if ($site_guid) {
  3136. $options['site_guid'] = $site_guid;
  3137. }
  3138. return elgg_get_metadata($options);
  3139. }
  3140. /**
  3141. * Get metadata objects by name.
  3142. *
  3143. * @param int $entity_guid Entity GUID
  3144. * @param string $meta_name Metadata name
  3145. *
  3146. * @return ElggMetadata|ElggMetadata[]|false object, an array of \ElggMetadata or false.
  3147. * @deprecated 1.8 Use elgg_get_metadata()
  3148. */
  3149. function get_metadata_byname($entity_guid, $meta_name) {
  3150. elgg_deprecated_notice('get_metadata_byname() is deprecated by elgg_get_metadata()', 1.8);
  3151. if (!$entity_guid || !$meta_name) {
  3152. return false;
  3153. }
  3154. $options = array(
  3155. 'guid' => $entity_guid,
  3156. 'metadata_name' => $meta_name,
  3157. 'limit' => 0
  3158. );
  3159. $md = elgg_get_metadata($options);
  3160. if ($md && count($md) == 1) {
  3161. return $md[0];
  3162. }
  3163. return $md;
  3164. }
  3165. /**
  3166. * Return all the metadata for a given GUID.
  3167. *
  3168. * @param int $entity_guid Entity GUID
  3169. *
  3170. * @return mixed
  3171. * @deprecated 1.8 Use elgg_get_metadata()
  3172. */
  3173. function get_metadata_for_entity($entity_guid) {
  3174. elgg_deprecated_notice('get_metadata_for_entity() is deprecated by elgg_get_metadata()', 1.8);
  3175. if (!$entity_guid) {
  3176. return false;
  3177. }
  3178. $options = array(
  3179. 'guid' => $entity_guid,
  3180. 'limit' => 0
  3181. );
  3182. return elgg_get_metadata($options);
  3183. }
  3184. /**
  3185. * Get a specific metadata object.
  3186. *
  3187. * @param int $id The id of the metadata being retrieved.
  3188. *
  3189. * @return mixed False on failure or \ElggMetadata
  3190. * @deprecated 1.8 Use elgg_get_metadata_from_id()
  3191. */
  3192. function get_metadata($id) {
  3193. elgg_deprecated_notice('get_metadata() is deprecated by elgg_get_metadata_from_id()', 1.8);
  3194. return elgg_get_metadata_from_id($id);
  3195. }
  3196. /**
  3197. * Clear all the metadata for a given entity, assuming you have access to that entity.
  3198. *
  3199. * @param int $guid Entity GUID
  3200. *
  3201. * @return bool
  3202. * @deprecated 1.8 Use elgg_delete_metadata()
  3203. */
  3204. function clear_metadata($guid) {
  3205. elgg_deprecated_notice('clear_metadata() is deprecated by elgg_delete_metadata()', 1.8);
  3206. if (!$guid) {
  3207. return false;
  3208. }
  3209. return elgg_delete_metadata(array('guid' => $guid, 'limit' => 0));
  3210. }
  3211. /**
  3212. * Clear all metadata belonging to a given owner_guid
  3213. *
  3214. * @param int $owner_guid The owner
  3215. *
  3216. * @return bool
  3217. * @deprecated 1.8 Use elgg_delete_metadata()
  3218. */
  3219. function clear_metadata_by_owner($owner_guid) {
  3220. elgg_deprecated_notice('clear_metadata() is deprecated by elgg_delete_metadata()', 1.8);
  3221. if (!$owner_guid) {
  3222. return false;
  3223. }
  3224. return elgg_delete_metadata(array('metadata_owner_guid' => $owner_guid, 'limit' => 0));
  3225. }
  3226. /**
  3227. * Delete a piece of metadata, where the current user has access.
  3228. *
  3229. * @param int $id The id of metadata to delete.
  3230. *
  3231. * @return bool
  3232. * @deprecated 1.8 Use elgg_delete_metadata()
  3233. */
  3234. function delete_metadata($id) {
  3235. elgg_deprecated_notice('delete_metadata() is deprecated by elgg_delete_metadata()', 1.8);
  3236. if (!$id) {
  3237. return false;
  3238. }
  3239. return elgg_delete_metadata(array('metadata_id' => $id));
  3240. }
  3241. /**
  3242. * Removes metadata on an entity with a particular name, optionally with a given value.
  3243. *
  3244. * @param int $guid The entity GUID
  3245. * @param string $name The name of the metadata
  3246. * @param string $value The value of the metadata (useful to remove a single item of a set)
  3247. *
  3248. * @return bool Depending on success
  3249. * @deprecated 1.8 Use elgg_delete_metadata()
  3250. */
  3251. function remove_metadata($guid, $name, $value = "") {
  3252. elgg_deprecated_notice('delete_metadata() is deprecated by elgg_delete_metadata()', 1.8);
  3253. // prevent them from deleting everything
  3254. if (!$guid) {
  3255. return false;
  3256. }
  3257. $options = array(
  3258. 'guid' => $guid,
  3259. 'metadata_name' => $name,
  3260. 'limit' => 0
  3261. );
  3262. if ($value) {
  3263. $options['metadata_value'] = $value;
  3264. }
  3265. return elgg_delete_metadata($options);
  3266. }
  3267. /**
  3268. * Get a specific annotation.
  3269. *
  3270. * @param int $annotation_id Annotation ID
  3271. *
  3272. * @return \ElggAnnotation
  3273. * @deprecated 1.8 Use elgg_get_annotation_from_id()
  3274. */
  3275. function get_annotation($annotation_id) {
  3276. elgg_deprecated_notice('get_annotation() is deprecated by elgg_get_annotation_from_id()', 1.8);
  3277. return elgg_get_annotation_from_id($annotation_id);
  3278. }
  3279. /**
  3280. * Delete a given annotation.
  3281. *
  3282. * @param int $id The annotation id
  3283. *
  3284. * @return bool
  3285. * @deprecated 1.8 Use elgg_delete_annotations()
  3286. */
  3287. function delete_annotation($id) {
  3288. elgg_deprecated_notice('delete_annotation() is deprecated by elgg_delete_annotations()', 1.8);
  3289. if (!$id) {
  3290. return false;
  3291. }
  3292. return elgg_delete_annotations(array('annotation_id' => $id));
  3293. }
  3294. /**
  3295. * Clear all the annotations for a given entity, assuming you have access to that metadata.
  3296. *
  3297. * @param int $guid The entity guid
  3298. * @param string $name The name of the annotation to delete.
  3299. *
  3300. * @return int Number of annotations deleted or false if an error
  3301. * @deprecated 1.8 Use elgg_delete_annotations()
  3302. */
  3303. function clear_annotations($guid, $name = "") {
  3304. elgg_deprecated_notice('clear_annotations() is deprecated by elgg_delete_annotations()', 1.8);
  3305. if (!$guid) {
  3306. return false;
  3307. }
  3308. $options = array(
  3309. 'guid' => $guid,
  3310. 'limit' => 0
  3311. );
  3312. if ($name) {
  3313. $options['annotation_name'] = $name;
  3314. }
  3315. return elgg_delete_annotations($options);
  3316. }
  3317. /**
  3318. * Clear all annotations belonging to a given owner_guid
  3319. *
  3320. * @param int $owner_guid The owner
  3321. *
  3322. * @return int Number of annotations deleted
  3323. * @deprecated 1.8 Use elgg_delete_annotations()
  3324. */
  3325. function clear_annotations_by_owner($owner_guid) {
  3326. elgg_deprecated_notice('clear_annotations_by_owner() is deprecated by elgg_delete_annotations()', 1.8);
  3327. if (!$owner_guid) {
  3328. return false;
  3329. }
  3330. $options = array(
  3331. 'annotation_owner_guid' => $owner_guid,
  3332. 'limit' => 0
  3333. );
  3334. return elgg_delete_annotations($options);
  3335. }
  3336. /**
  3337. * Registers a page handler for a particular identifier
  3338. *
  3339. * For example, you can register a function called 'blog_page_handler' for handler type 'blog'
  3340. * Now for all URLs of type http://yoururl/pg/blog/*, the blog_page_handler() function will be called.
  3341. * The part of the URL marked with * above will be exploded on '/' characters and passed as an
  3342. * array to that function.
  3343. * For example, the URL http://yoururl/blog/username/friends/ would result in the call:
  3344. * blog_page_handler(array('username','friends'), blog);
  3345. *
  3346. * Page handler functions should return true or the default page handler will be called.
  3347. *
  3348. * A request to register a page handler with the same identifier as previously registered
  3349. * handler will replace the previous one.
  3350. *
  3351. * The context is set to the page handler identifier before the registered
  3352. * page handler function is called. For the above example, the context is set to 'blog'.
  3353. *
  3354. * @param string $handler The page type to handle
  3355. * @param string $function Your function name
  3356. * @return true|false Depending on success
  3357. *
  3358. * @deprecated 1.8 Use {@link elgg_register_page_handler()}
  3359. */
  3360. function register_page_handler($handler, $function){
  3361. elgg_deprecated_notice("register_page_handler() was deprecated by elgg_register_page_handler()", 1.8);
  3362. return elgg_register_page_handler($handler, $function);
  3363. }
  3364. /**
  3365. * Unregister a page handler for an identifier
  3366. *
  3367. * Note: to replace a page handler, call register_page_handler()
  3368. *
  3369. * @param string $handler The page type identifier
  3370. * @since 1.7.2
  3371. *
  3372. * @deprecated 1.8 Use {@link elgg_unregister_page_handler()}
  3373. */
  3374. function unregister_page_handler($handler) {
  3375. elgg_deprecated_notice("unregister_page_handler() was deprecated by elgg_unregister_page_handler()", 1.8);
  3376. return elgg_unregister_page_handler($handler);
  3377. }
  3378. /**
  3379. * Register an annotation url handler.
  3380. *
  3381. * @param string $function_name The function.
  3382. * @param string $extender_name The name, default 'all'.
  3383. *
  3384. * @deprecated 1.8 Use {@link elgg_register_annotation_url_handler()}
  3385. */
  3386. function register_annotation_url_handler($function, $extender_name) {
  3387. elgg_deprecated_notice("register_annotation_url_handler() was deprecated by elgg_register_annotation_url_handler()", 1.8);
  3388. return elgg_register_annotation_url_handler($extender_name, $function);
  3389. }
  3390. /**
  3391. * Sets the URL handler for a particular extender type and name.
  3392. * It is recommended that you do not call this directly, instead use one of the wrapper functions in the
  3393. * subtype files.
  3394. *
  3395. * @param string $function_name The function to register
  3396. * @param string $extender_type Extender type
  3397. * @param string $extender_name The name of the extender
  3398. * @return true|false Depending on success
  3399. *
  3400. * @deprecated 1.8 Use {@link elgg_register_extender_url_handler()}
  3401. */
  3402. function register_extender_url_handler($function, $type = "all", $name = "all") {
  3403. elgg_deprecated_notice("register_extender_url_handler() was deprecated by elgg_register_extender_url_handler()", 1.8);
  3404. return elgg_register_extender_url_handler($type, $name, $function);
  3405. }
  3406. /**
  3407. * Registers and entity type and subtype to return in search and other places.
  3408. * A description in the elgg_echo languages file of the form item:type:subtype
  3409. * is also expected.
  3410. *
  3411. * @param string $type The type of entity (object, site, user, group)
  3412. * @param string $subtype The subtype to register (may be blank)
  3413. * @return true|false Depending on success
  3414. *
  3415. * @deprecated 1.8 Use {@link elgg_register_entity_type()}
  3416. */
  3417. function register_entity_type($type, $subtype = null) {
  3418. elgg_deprecated_notice("register_entity_type() was deprecated by elgg_register_entity_type()", 1.8);
  3419. return elgg_register_entity_type($type, $subtype);
  3420. }
  3421. /**
  3422. * Register a metadata url handler.
  3423. *
  3424. * @param string $function_name The function.
  3425. * @param string $extender_name The name, default 'all'.
  3426. *
  3427. * @deprecated 1.8 Use {@link elgg_register_metadata_url_handler()}
  3428. */
  3429. function register_metadata_url_handler($function, $extender_name = "all") {
  3430. return elgg_register_metadata_url_handler($extender_name, $function);
  3431. }
  3432. /**
  3433. * Sets the URL handler for a particular relationship type
  3434. *
  3435. * @param string $function_name The function to register
  3436. * @param string $relationship_type The relationship type.
  3437. * @return true|false Depending on success
  3438. *
  3439. * @deprecated 1.8 Use {@link elgg_register_relationship_url_handler()}
  3440. */
  3441. function register_relationship_url_handler($function_name, $relationship_type = "all") {
  3442. elgg_deprecated_notice("register_relationship_url_handler() was deprecated by elgg_register_relationship_url_handler()", 1.8);
  3443. return elgg_register_relationship_url_handler($relationship_type, $function_name);
  3444. }
  3445. /**
  3446. * Registers a view to be simply cached
  3447. *
  3448. * Views cached in this manner must take no parameters and be login agnostic -
  3449. * that is to say, they look the same no matter who is logged in (or logged out).
  3450. *
  3451. * CSS and the basic jS views are automatically cached like this.
  3452. *
  3453. * @param string $viewname View name
  3454. *
  3455. * @deprecated 1.8 Use {@link elgg_register_simplecache_view()}
  3456. */
  3457. function elgg_view_register_simplecache($viewname) {
  3458. elgg_deprecated_notice("elgg_view_register_simplecache() was deprecated by elgg_register_simplecache_view()", 1.8);
  3459. return elgg_register_simplecache_view($viewname);
  3460. }
  3461. /**
  3462. * Regenerates the simple cache.
  3463. *
  3464. * @param string $viewtype Optional viewtype to regenerate
  3465. * @see elgg_view_register_simplecache()
  3466. *
  3467. * @deprecated 1.8 Use {@link elgg_regenerate_simplecache()}
  3468. */
  3469. function elgg_view_regenerate_simplecache($viewtype = NULL) {
  3470. elgg_deprecated_notice("elgg_view_regenerate_simplecache() was deprecated by elgg_regenerate_simplecache()", 1.8);
  3471. return elgg_regenerate_simplecache($viewtype);
  3472. }
  3473. /**
  3474. * Enables the simple cache.
  3475. *
  3476. * @see elgg_view_register_simplecache()
  3477. *
  3478. * @deprecated 1.8 Use {@link elgg_enable_simplecache()}
  3479. */
  3480. function elgg_view_enable_simplecache() {
  3481. elgg_deprecated_notice("elgg_view_enable_simplecache() was deprecated by elgg_enable_simplecache()", 1.8);
  3482. return elgg_enable_simplecache();
  3483. }
  3484. /**
  3485. * Disables the simple cache.
  3486. *
  3487. * @see elgg_view_register_simplecache()
  3488. *
  3489. * @deprecated 1.8 Use {@link elgg_disable_simplecache()}
  3490. */
  3491. function elgg_view_disable_simplecache() {
  3492. elgg_deprecated_notice("elgg_view_disable_simplecache() was deprecated by elgg_disable_simplecache()", 1.8);
  3493. return elgg_disable_simplecache();
  3494. }
  3495. // these were internal functions that perhaps can be removed rather than deprecated
  3496. /**
  3497. * @deprecated 1.8
  3498. */
  3499. function is_db_installed() {
  3500. elgg_deprecated_notice('is_db_installed() has been deprecated', 1.8);
  3501. return true;
  3502. }
  3503. /**
  3504. * @deprecated 1.8
  3505. */
  3506. function is_installed() {
  3507. elgg_deprecated_notice('is_installed() has been deprecated', 1.8);
  3508. return true;
  3509. }
  3510. /**
  3511. * Attempt to authenticate.
  3512. * This function will process all registered PAM handlers or stop when the first
  3513. * handler fails. A handler fails by either returning false or throwing an
  3514. * exception. The advantage of throwing an exception is that it returns a message
  3515. * through the global $_PAM_HANDLERS_MSG which can be used in communication with
  3516. * a user. The order that handlers are processed is determined by the order that
  3517. * they were registered.
  3518. *
  3519. * If $credentials are provided the PAM handler should authenticate using the
  3520. * provided credentials, if not then credentials should be prompted for or
  3521. * otherwise retrieved (eg from the HTTP header or $_SESSION).
  3522. *
  3523. * @param mixed $credentials Mixed PAM handler specific credentials (e.g. username, password)
  3524. * @param string $policy - the policy type, default is "user"
  3525. * @return bool true if authenticated, false if not.
  3526. *
  3527. * @deprecated 1.8 See {@link \ElggPAM}
  3528. */
  3529. function pam_authenticate($credentials = NULL, $policy = "user") {
  3530. elgg_deprecated_notice('pam_authenticate has been deprecated for \ElggPAM', 1.8);
  3531. global $_PAM_HANDLERS, $_PAM_HANDLERS_MSG;
  3532. $_PAM_HANDLERS_MSG = array();
  3533. $authenticated = false;
  3534. foreach ($_PAM_HANDLERS[$policy] as $k => $v) {
  3535. $handler = $v->handler;
  3536. $importance = $v->importance;
  3537. try {
  3538. // Execute the handler
  3539. if ($handler($credentials)) {
  3540. // Explicitly returned true
  3541. $_PAM_HANDLERS_MSG[$k] = "Authenticated!";
  3542. $authenticated = true;
  3543. } else {
  3544. $_PAM_HANDLERS_MSG[$k] = "Not Authenticated.";
  3545. // If this is required then abort.
  3546. if ($importance == 'required') {
  3547. return false;
  3548. }
  3549. }
  3550. } catch (Exception $e) {
  3551. $_PAM_HANDLERS_MSG[$k] = "$e";
  3552. // If this is required then abort.
  3553. if ($importance == 'required') {
  3554. return false;
  3555. }
  3556. }
  3557. }
  3558. return $authenticated;
  3559. }
  3560. /**
  3561. * When given a widget entity and a new requested location, saves the new location
  3562. * and also provides a sensible ordering for all widgets in that column
  3563. *
  3564. * @param \ElggObject $widget The widget entity
  3565. * @param int $order The order within the column
  3566. * @param int $column The column (1, 2 or 3)
  3567. *
  3568. * @return bool Depending on success
  3569. * @deprecated 1.8 use \ElggWidget::move()
  3570. */
  3571. function save_widget_location(\ElggObject $widget, $order, $column) {
  3572. elgg_deprecated_notice('save_widget_location() is deprecated', 1.8);
  3573. if ($widget instanceof \ElggObject) {
  3574. if ($widget->getSubtype() == "widget") {
  3575. // If you can't move the widget, don't save a new location
  3576. if (!$widget->draggable) {
  3577. return false;
  3578. }
  3579. // Sanitise the column value
  3580. if ($column != 1 || $column != 2 || $column != 3) {
  3581. $column = 1;
  3582. }
  3583. $widget->column = (int) $column;
  3584. $ordertmp = array();
  3585. $params = array(
  3586. 'context' => $widget->context,
  3587. 'column' => $column,
  3588. );
  3589. if ($entities = get_entities_from_metadata_multi($params, 'object', 'widget')) {
  3590. foreach ($entities as $entity) {
  3591. $entityorder = $entity->order;
  3592. if ($entityorder < $order) {
  3593. $ordertmp[$entityorder] = $entity;
  3594. }
  3595. if ($entityorder >= $order) {
  3596. $ordertmp[$entityorder + 10000] = $entity;
  3597. }
  3598. }
  3599. }
  3600. $ordertmp[$order] = $widget;
  3601. ksort($ordertmp);
  3602. $orderticker = 10;
  3603. foreach ($ordertmp as $orderval => $entity) {
  3604. $entity->order = $orderticker;
  3605. $orderticker += 10;
  3606. }
  3607. return true;
  3608. } else {
  3609. register_error($widget->getSubtype());
  3610. }
  3611. }
  3612. return false;
  3613. }
  3614. /**
  3615. * Get widgets for a particular context and column, in order of display
  3616. *
  3617. * @param int $user_guid The owner user GUID
  3618. * @param string $context The context (profile, dashboard etc)
  3619. * @param int $column The column (1 or 2)
  3620. *
  3621. * @return array|false An array of widget \ElggObjects, or false
  3622. * @deprecated 1.8 Use elgg_get_widgets()
  3623. */
  3624. function get_widgets($user_guid, $context, $column) {
  3625. elgg_deprecated_notice('get_widgets is depecated for elgg_get_widgets', 1.8);
  3626. $params = array(
  3627. 'column' => $column,
  3628. 'context' => $context
  3629. );
  3630. $widgets = get_entities_from_private_setting_multi($params, "object",
  3631. "widget", $user_guid, "", 10000);
  3632. if ($widgets) {
  3633. $widgetorder = array();
  3634. foreach ($widgets as $widget) {
  3635. $order = $widget->order;
  3636. while (isset($widgetorder[$order])) {
  3637. $order++;
  3638. }
  3639. $widgetorder[$order] = $widget;
  3640. }
  3641. ksort($widgetorder);
  3642. return $widgetorder;
  3643. }
  3644. return false;
  3645. }
  3646. /**
  3647. * Add a new widget instance
  3648. *
  3649. * @param int $entity_guid GUID of entity that owns this widget
  3650. * @param string $handler The handler for this widget
  3651. * @param string $context The page context for this widget
  3652. * @param int $order The order to display this widget in
  3653. * @param int $column The column to display this widget in (1, 2 or 3)
  3654. * @param int $access_id If not specified, it is set to the default access level
  3655. *
  3656. * @return int|false Widget GUID or false on failure
  3657. * @deprecated 1.8 use elgg_create_widget()
  3658. */
  3659. function add_widget($entity_guid, $handler, $context, $order = 0, $column = 1, $access_id = null) {
  3660. elgg_deprecated_notice('add_widget has been deprecated for elgg_create_widget', 1.8);
  3661. if (empty($entity_guid) || empty($context) || empty($handler) || !widget_type_exists($handler)) {
  3662. return false;
  3663. }
  3664. if ($entity = get_entity($entity_guid)) {
  3665. $widget = new \ElggWidget;
  3666. $widget->owner_guid = $entity_guid;
  3667. $widget->container_guid = $entity_guid;
  3668. if (isset($access_id)) {
  3669. $widget->access_id = $access_id;
  3670. } else {
  3671. $widget->access_id = get_default_access();
  3672. }
  3673. $guid = $widget->save();
  3674. // private settings cannot be set until \ElggWidget saved
  3675. $widget->handler = $handler;
  3676. $widget->context = $context;
  3677. $widget->column = $column;
  3678. $widget->order = $order;
  3679. return $guid;
  3680. }
  3681. return false;
  3682. }
  3683. /**
  3684. * Define a new widget type
  3685. *
  3686. * @param string $handler The identifier for the widget handler
  3687. * @param string $name The name of the widget type
  3688. * @param string $description A description for the widget type
  3689. * @param string $context A comma-separated list of contexts where this
  3690. * widget is allowed (default: 'all')
  3691. * @param bool $multiple Whether or not multiple instances of this widget
  3692. * are allowed on a single dashboard (default: false)
  3693. * @param string $positions A comma-separated list of positions on the page
  3694. * (side or main) where this widget is allowed (default: "side,main")
  3695. *
  3696. * @return bool Depending on success
  3697. * @deprecated 1.8 Use elgg_register_widget_type
  3698. */
  3699. function add_widget_type($handler, $name, $description, $context = "all",
  3700. $multiple = false, $positions = "side,main") {
  3701. elgg_deprecated_notice("add_widget_type deprecated for elgg_register_widget_type", 1.8);
  3702. return elgg_register_widget_type($handler, $name, $description, $context, $multiple);
  3703. }
  3704. /**
  3705. * Remove a widget type
  3706. *
  3707. * @param string $handler The identifier for the widget handler
  3708. *
  3709. * @return void
  3710. * @since 1.7.1
  3711. * @deprecated 1.8 Use elgg_unregister_widget_type
  3712. */
  3713. function remove_widget_type($handler) {
  3714. elgg_deprecated_notice("remove_widget_type deprecated for elgg_unregister_widget_type", 1.8);
  3715. return elgg_unregister_widget_type($handler);
  3716. }
  3717. /**
  3718. * Determines whether or not widgets with the specified handler have been defined
  3719. *
  3720. * @param string $handler The widget handler identifying string
  3721. *
  3722. * @return bool Whether or not those widgets exist
  3723. * @deprecated 1.8 Use elgg_is_widget_type
  3724. */
  3725. function widget_type_exists($handler) {
  3726. elgg_deprecated_notice("widget_type_exists deprecated for elgg_is_widget_type", 1.8);
  3727. return elgg_is_widget_type($handler);
  3728. }
  3729. /**
  3730. * Returns an array of \stdClass objects representing the defined widget types
  3731. *
  3732. * @return array A list of types defined (if any)
  3733. * @deprecated 1.8 Use elgg_get_widget_types
  3734. */
  3735. function get_widget_types() {
  3736. elgg_deprecated_notice("get_widget_types deprecrated for elgg_get_widget_types", 1.8);
  3737. return elgg_get_widget_types();
  3738. }
  3739. /**
  3740. * Saves a widget's settings (by passing an array of
  3741. * (name => value) pairs to save_{$handler}_widget)
  3742. *
  3743. * @param int $widget_guid The GUID of the widget we're saving to
  3744. * @param array $params An array of name => value parameters
  3745. *
  3746. * @return bool
  3747. * @deprecated 1.8 Use elgg_save_widget_settings
  3748. */
  3749. function save_widget_info($widget_guid, $params) {
  3750. elgg_deprecated_notice("save_widget_info() is deprecated for elgg_save_widget_settings", 1.8);
  3751. if ($widget = get_entity($widget_guid)) {
  3752. $subtype = $widget->getSubtype();
  3753. if ($subtype != "widget") {
  3754. return false;
  3755. }
  3756. $handler = $widget->handler;
  3757. if (empty($handler) || !widget_type_exists($handler)) {
  3758. return false;
  3759. }
  3760. if (!$widget->canEdit()) {
  3761. return false;
  3762. }
  3763. // Save the params to the widget
  3764. if (is_array($params) && sizeof($params) > 0) {
  3765. foreach ($params as $name => $value) {
  3766. if (!empty($name) && !in_array($name, array(
  3767. 'guid', 'owner_guid', 'site_guid'
  3768. ))) {
  3769. if (is_array($value)) {
  3770. // @todo Handle arrays securely
  3771. $widget->setMetadata($name, $value, "", true);
  3772. } else {
  3773. $widget->$name = $value;
  3774. }
  3775. }
  3776. }
  3777. $widget->save();
  3778. }
  3779. $function = "save_{$handler}_widget";
  3780. if (is_callable($function)) {
  3781. return $function($params);
  3782. }
  3783. return true;
  3784. }
  3785. return false;
  3786. }
  3787. /**
  3788. * Reorders the widgets from a widget panel
  3789. *
  3790. * @param string $panelstring1 String of guids of \ElggWidget objects separated by ::
  3791. * @param string $panelstring2 String of guids of \ElggWidget objects separated by ::
  3792. * @param string $panelstring3 String of guids of \ElggWidget objects separated by ::
  3793. * @param string $context Profile or dashboard
  3794. * @param int $owner Owner guid
  3795. *
  3796. * @return void
  3797. * @deprecated 1.8 Don't use.
  3798. */
  3799. function reorder_widgets_from_panel($panelstring1, $panelstring2, $panelstring3, $context, $owner) {
  3800. elgg_deprecated_notice("reorder_widgets_from_panel() is deprecated", 1.8);
  3801. $return = true;
  3802. $mainwidgets = explode('::', $panelstring1);
  3803. $sidewidgets = explode('::', $panelstring2);
  3804. $rightwidgets = explode('::', $panelstring3);
  3805. $handlers = array();
  3806. $guids = array();
  3807. if (is_array($mainwidgets) && sizeof($mainwidgets) > 0) {
  3808. foreach ($mainwidgets as $widget) {
  3809. $guid = (int) $widget;
  3810. if ("{$guid}" == "{$widget}") {
  3811. $guids[1][] = $widget;
  3812. } else {
  3813. $handlers[1][] = $widget;
  3814. }
  3815. }
  3816. }
  3817. if (is_array($sidewidgets) && sizeof($sidewidgets) > 0) {
  3818. foreach ($sidewidgets as $widget) {
  3819. $guid = (int) $widget;
  3820. if ("{$guid}" == "{$widget}") {
  3821. $guids[2][] = $widget;
  3822. } else {
  3823. $handlers[2][] = $widget;
  3824. }
  3825. }
  3826. }
  3827. if (is_array($rightwidgets) && sizeof($rightwidgets) > 0) {
  3828. foreach ($rightwidgets as $widget) {
  3829. $guid = (int) $widget;
  3830. if ("{$guid}" == "{$widget}") {
  3831. $guids[3][] = $widget;
  3832. } else {
  3833. $handlers[3][] = $widget;
  3834. }
  3835. }
  3836. }
  3837. // Reorder existing widgets or delete ones that have vanished
  3838. foreach (array(1, 2, 3) as $column) {
  3839. if ($dbwidgets = get_widgets($owner, $context, $column)) {
  3840. foreach ($dbwidgets as $dbwidget) {
  3841. if (in_array($dbwidget->getGUID(), $guids[1])
  3842. || in_array($dbwidget->getGUID(), $guids[2]) || in_array($dbwidget->getGUID(), $guids[3])) {
  3843. if (in_array($dbwidget->getGUID(), $guids[1])) {
  3844. $pos = array_search($dbwidget->getGUID(), $guids[1]);
  3845. $col = 1;
  3846. } else if (in_array($dbwidget->getGUID(), $guids[2])) {
  3847. $pos = array_search($dbwidget->getGUID(), $guids[2]);
  3848. $col = 2;
  3849. } else {
  3850. $pos = array_search($dbwidget->getGUID(), $guids[3]);
  3851. $col = 3;
  3852. }
  3853. $pos = ($pos + 1) * 10;
  3854. $dbwidget->column = $col;
  3855. $dbwidget->order = $pos;
  3856. } else {
  3857. $dbguid = $dbwidget->getGUID();
  3858. if (!$dbwidget->delete()) {
  3859. $return = false;
  3860. } else {
  3861. // Remove state cookie
  3862. $cookie = new \ElggCookie("widget$dbguid");
  3863. $cookie->value = NULL;
  3864. elgg_set_cookie($cookie);
  3865. }
  3866. }
  3867. }
  3868. }
  3869. // Add new ones
  3870. if (sizeof($guids[$column]) > 0) {
  3871. foreach ($guids[$column] as $key => $guid) {
  3872. if ($guid == 0) {
  3873. $pos = ($key + 1) * 10;
  3874. $handler = $handlers[$column][$key];
  3875. if (!add_widget($owner, $handler, $context, $pos, $column)) {
  3876. $return = false;
  3877. }
  3878. }
  3879. }
  3880. }
  3881. }
  3882. return $return;
  3883. }
  3884. /**
  3885. * Register a particular context for use with widgets.
  3886. *
  3887. * @param string $context The context we wish to enable context for
  3888. *
  3889. * @return void
  3890. * @deprecated 1.8 Don't use.
  3891. */
  3892. function use_widgets($context) {
  3893. elgg_deprecated_notice("use_widgets is deprecated", 1.8);
  3894. global $CONFIG;
  3895. if (!isset($CONFIG->widgets)) {
  3896. $CONFIG->widgets = new \stdClass;
  3897. }
  3898. if (!isset($CONFIG->widgets->contexts)) {
  3899. $CONFIG->widgets->contexts = array();
  3900. }
  3901. if (!empty($context)) {
  3902. $CONFIG->widgets->contexts[] = $context;
  3903. }
  3904. }
  3905. /**
  3906. * Determines whether or not the current context is using widgets
  3907. *
  3908. * @return bool Depending on widget status
  3909. * @deprecated 1.8 Don't use.
  3910. */
  3911. function using_widgets() {
  3912. elgg_deprecated_notice("using_widgets is deprecated", 1.8);
  3913. global $CONFIG;
  3914. $context = elgg_get_context();
  3915. if (isset($CONFIG->widgets->contexts) && is_array($CONFIG->widgets->contexts)) {
  3916. if (in_array($context, $CONFIG->widgets->contexts)) {
  3917. return true;
  3918. }
  3919. }
  3920. return false;
  3921. }
  3922. /**
  3923. * Displays a particular widget
  3924. *
  3925. * @param \ElggObject $widget The widget to display
  3926. * @return string The HTML for the widget, including JavaScript wrapper
  3927. *
  3928. * @deprecated 1.8 Use elgg_view_entity()
  3929. */
  3930. function display_widget(\ElggObject $widget) {
  3931. elgg_deprecated_notice("display_widget() was been deprecated. Use elgg_view_entity().", 1.8);
  3932. return elgg_view_entity($widget);
  3933. }
  3934. /**
  3935. * Count the number of comments attached to an entity
  3936. *
  3937. * @param \ElggEntity $entity
  3938. * @return int Number of comments
  3939. * @deprecated 1.8 Use \ElggEntity->countComments()
  3940. */
  3941. function elgg_count_comments($entity) {
  3942. elgg_deprecated_notice('elgg_count_comments() is deprecated by \ElggEntity->countComments()', 1.8);
  3943. if ($entity instanceof \ElggEntity) {
  3944. return $entity->countComments();
  3945. }
  3946. return 0;
  3947. }
  3948. /**
  3949. * Removes all items relating to a particular acting entity from the river
  3950. *
  3951. * @param int $subject_guid The GUID of the entity
  3952. *
  3953. * @return bool Depending on success
  3954. * @deprecated 1.8 Use elgg_delete_river()
  3955. */
  3956. function remove_from_river_by_subject($subject_guid) {
  3957. elgg_deprecated_notice("remove_from_river_by_subject() deprecated by elgg_delete_river()", 1.8);
  3958. return elgg_delete_river(array('subject_guid' => $subject_guid));
  3959. }
  3960. /**
  3961. * Removes all items relating to a particular entity being acted upon from the river
  3962. *
  3963. * @param int $object_guid The GUID of the entity
  3964. *
  3965. * @return bool Depending on success
  3966. * @deprecated 1.8 Use elgg_delete_river()
  3967. */
  3968. function remove_from_river_by_object($object_guid) {
  3969. elgg_deprecated_notice("remove_from_river_by_object() deprecated by elgg_delete_river()", 1.8);
  3970. return elgg_delete_river(array('object_guid' => $object_guid));
  3971. }
  3972. /**
  3973. * Removes all items relating to a particular annotation being acted upon from the river
  3974. *
  3975. * @param int $annotation_id The ID of the annotation
  3976. *
  3977. * @return bool Depending on success
  3978. * @since 1.7.0
  3979. * @deprecated 1.8 Use elgg_delete_river()
  3980. */
  3981. function remove_from_river_by_annotation($annotation_id) {
  3982. elgg_deprecated_notice("remove_from_river_by_annotation() deprecated by elgg_delete_river()", 1.8);
  3983. return elgg_delete_river(array('annotation_id' => $annotation_id));
  3984. }
  3985. /**
  3986. * Removes a single river entry
  3987. *
  3988. * @param int $id The ID of the river entry
  3989. *
  3990. * @return bool Depending on success
  3991. * @since 1.7.2
  3992. * @deprecated 1.8 Use elgg_delete_river()
  3993. */
  3994. function remove_from_river_by_id($id) {
  3995. elgg_deprecated_notice("remove_from_river_by_id() deprecated by elgg_delete_river()", 1.8);
  3996. return elgg_delete_river(array('id' => $id));
  3997. }
  3998. /**
  3999. * A default page handler
  4000. * Tries to locate a suitable file to include. Only works for core pages, not plugins.
  4001. *
  4002. * @param array $page The page URL elements
  4003. * @param string $handler The base handler
  4004. *
  4005. * @return true|false Depending on success
  4006. * @deprecated 1.8
  4007. */
  4008. function default_page_handler($page, $handler) {
  4009. global $CONFIG;
  4010. elgg_deprecated_notice("default_page_handler is deprecated", "1.8");
  4011. $page = implode('/', $page);
  4012. // protect against including arbitary files
  4013. $page = str_replace("..", "", $page);
  4014. $callpath = $CONFIG->path . $handler . "/" . $page;
  4015. if (is_dir($callpath)) {
  4016. $callpath = sanitise_filepath($callpath);
  4017. $callpath .= "index.php";
  4018. if (file_exists($callpath)) {
  4019. if (include($callpath)) {
  4020. return TRUE;
  4021. }
  4022. }
  4023. } else if (file_exists($callpath)) {
  4024. include($callpath);
  4025. return TRUE;
  4026. }
  4027. return FALSE;
  4028. }
  4029. /**
  4030. * Invalidate this class's entry in the cache.
  4031. *
  4032. * @param int $guid The entity guid
  4033. *
  4034. * @return void
  4035. * @access private
  4036. * @deprecated 1.8
  4037. */
  4038. function invalidate_cache_for_entity($guid) {
  4039. elgg_deprecated_notice('invalidate_cache_for_entity() is a private function and should not be used.', 1.8);
  4040. _elgg_invalidate_cache_for_entity($guid);
  4041. }
  4042. /**
  4043. * Cache an entity.
  4044. *
  4045. * Stores an entity in $ENTITY_CACHE;
  4046. *
  4047. * @param \ElggEntity $entity Entity to cache
  4048. *
  4049. * @return void
  4050. * @access private
  4051. * @deprecated 1.8
  4052. */
  4053. function cache_entity(\ElggEntity $entity) {
  4054. elgg_deprecated_notice('cache_entity() is a private function and should not be used.', 1.8);
  4055. _elgg_cache_entity($entity);
  4056. }
  4057. /**
  4058. * Retrieve a entity from the cache.
  4059. *
  4060. * @param int $guid The guid
  4061. *
  4062. * @return \ElggEntity|bool false if entity not cached, or not fully loaded
  4063. * @access private
  4064. * @deprecated 1.8
  4065. */
  4066. function retrieve_cached_entity($guid) {
  4067. elgg_deprecated_notice('retrieve_cached_entity() is a private function and should not be used.', 1.8);
  4068. return _elgg_retrieve_cached_entity($guid);
  4069. }
  4070. /**
  4071. * Returns the category of a file from its MIME type
  4072. *
  4073. * @param string $mime_type The MIME type
  4074. *
  4075. * @return string 'document', 'audio', 'video', or 'general' if the MIME type was unrecognized
  4076. * @deprecated 1.8 Use elgg_get_file_simple_type()
  4077. */
  4078. function get_general_file_type($mime_type) {
  4079. elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_file_simple_type()', 1.8);
  4080. return elgg_get_file_simple_type($mime_type);
  4081. }