BxBaseModGeneralModule.php 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup BaseGeneral Base classes for modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolAcl');
  12. /**
  13. * Base module class.
  14. */
  15. class BxBaseModGeneralModule extends BxDolModule
  16. {
  17. protected $_iProfileId;
  18. protected $_aSearchableNamesExcept;
  19. protected $_aFormParams;
  20. function __construct(&$aModule)
  21. {
  22. parent::__construct($aModule);
  23. $this->_iProfileId = bx_get_logged_profile_id();
  24. $this->_aSearchableNamesExcept = array(
  25. 'allow_view_to'
  26. );
  27. $this->_aFormParams = array(
  28. 'display' => false,
  29. 'dynamic_mode' => false,
  30. 'ajax_mode' => false,
  31. 'absolute_action_url' => false,
  32. 'visibility_autoselect' => false,
  33. 'context_id' => 0,
  34. 'custom' => array()
  35. );
  36. }
  37. // ====== ACTIONS METHODS
  38. public function actionRss ()
  39. {
  40. $aArgs = func_get_args();
  41. $this->_rss($aArgs);
  42. }
  43. public function actionGetCreatePostForm()
  44. {
  45. $sName = $this->_oConfig->getName();
  46. $aParams = bx_process_input(array_intersect_key($_GET, $this->_aFormParams));
  47. $aParams = array_merge($this->_aFormParams, $aParams);
  48. $aParams['context_id'] = (bool)$aParams['context_id'] ? (int)$aParams['context_id'] : false;
  49. $mixedResponse = $this->serviceGetCreatePostForm($aParams);
  50. if(empty($mixedResponse))
  51. return echoJson(array());
  52. else if(is_array($mixedResponse)) {
  53. $mixedResponse['module'] = $sName;
  54. return echoJson($mixedResponse);
  55. }
  56. return echoJson(array(
  57. 'module' => $sName,
  58. 'content' => $mixedResponse
  59. ));
  60. }
  61. public function actionGetNotes()
  62. {
  63. $CNF = &$this->_oConfig->CNF;
  64. if(empty($CNF['OBJECT_NOTES']))
  65. return echoJson(array());
  66. $iContentId = (int)bx_get('content_id');
  67. $oCmtsNotes = BxDolCmts::getObjectInstance($CNF['OBJECT_NOTES'], $iContentId, true, $this->_oTemplate);
  68. $aCmtsNotes = $oCmtsNotes->getCommentsBlock(array(), array('in_designbox' => false));
  69. if(empty($aCmtsNotes) || !is_array($aCmtsNotes))
  70. return echoJson(array());
  71. $sPopupId = $this->getName() . '_notes_' . $iContentId;
  72. $sPopupTitle = !empty($CNF['T']['txt_cmts_notes_popup_view_title']) ? $CNF['T']['txt_cmts_notes_popup_view_title'] : '_cmt_nts_popup_view_title';
  73. echoJson(array('popup' => BxTemplFunctions::getInstance()->popupBox($sPopupId, _t($sPopupTitle), $aCmtsNotes['content'])));
  74. }
  75. public function actionNested()
  76. {
  77. $sAction = bx_get('a');
  78. $sMethodName = 'subaction' . ucfirst($sAction);
  79. if (!method_exists($this, $sMethodName)) {
  80. return;
  81. }
  82. $this->$sMethodName();
  83. }
  84. public function subactionDelete()
  85. {
  86. header('Content-type: text/html; charset=utf-8');
  87. $iNestedId = (int)bx_get('id');
  88. $sNestedForm = bx_get('s');
  89. $oForm = BxDolForm::getObjectInstance($sNestedForm, $sNestedForm);
  90. if (!$oForm){
  91. echo _t('_sys_request_page_not_found_cpt');
  92. return;
  93. }
  94. $aNested = $this->_oDb->getNestedBy(array('type' => 'id', 'id' => $iNestedId, 'key_name' => $oForm->aParams['db']['key']), $oForm->aParams['db']['table']);
  95. if (empty($aNested)){
  96. echo _t('_sys_request_page_not_found_cpt');
  97. return;
  98. }
  99. $aContentInfo = $this->_oDb->getContentInfoById ($aNested['content_id']);
  100. if (!$aContentInfo){
  101. echo _t('_sys_request_page_not_found_cpt');
  102. return;
  103. }
  104. elseif (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedEdit ($aContentInfo))) {
  105. echo $sMsg;
  106. }
  107. elseif (!$this->_oDb->deleteNestedById($iNestedId, $oForm->aParams['db']['key'], $oForm->aParams['db']['table'])) {
  108. echo _t('_sys_txt_error_occured');
  109. }
  110. else {
  111. echo 'ok';
  112. }
  113. }
  114. // ====== SERVICE METHODS
  115. public function serviceIsBadgesAvaliable()
  116. {
  117. $oBadges = BxDolBadges::getInstance();
  118. $aBadges = $oBadges->getData(array('type' => 'by_module&object', 'object_id' => 0, 'module' => $this->_oConfig->getName()));
  119. return count($aBadges) > 0 ? true : false;
  120. }
  121. public function serviceGetSafeServices()
  122. {
  123. return array(
  124. // other
  125. 'ModuleIcon' => '',
  126. 'GetLink' => '',
  127. // browse
  128. 'GetSearchResultUnit' => '',
  129. 'Browse' => '',
  130. 'BrowseFeatured' => '',
  131. 'BrowseFavorite' => '',
  132. // forms
  133. 'GetCreatePostForm' => '',
  134. 'EntityEdit' => '',
  135. 'EntityDelete' => '',
  136. // page blocks
  137. 'EntityTextBlock' => '',
  138. 'EntityInfo' => '',
  139. 'EntityInfoFull' => '',
  140. 'EntityInfoExtended' => '',
  141. 'EntityLocation' => '',
  142. 'EntityComments' => '',
  143. 'EntityAttachments' => '',
  144. // menu
  145. 'EntityAllActions' => '',
  146. 'EntityActions' => '',
  147. 'EntitySocialSharing' => '',
  148. 'MyEntriesActions' => '',
  149. );
  150. }
  151. /**
  152. * @page service Service Calls
  153. * @section bx_base_general Base General
  154. * @subsection bx_base_general-other Other
  155. * @subsubsection bx_base_general-module_icon module_icon
  156. *
  157. * @code bx_srv('bx_posts', 'module_icon', [...]); @endcode
  158. *
  159. * Get module icon as CSS class name with FontAwesome icon name class and color class
  160. *
  161. * @see BxBaseModGeneralModule::serviceModuleIcon
  162. */
  163. /**
  164. * @ref bx_base_general-module_icon "module_icon"
  165. */
  166. public function serviceModuleIcon ()
  167. {
  168. return isset($this->_oConfig->CNF['ICON']) ? $this->_oConfig->CNF['ICON'] : '';
  169. }
  170. public function serviceGetAuthor ($iContentId)
  171. {
  172. $mixedResult = $this->_getFieldValue('FIELD_AUTHOR', $iContentId);
  173. return $mixedResult !== false ? (int)$mixedResult : 0;
  174. }
  175. public function serviceGetPrivacyView ($iContentId)
  176. {
  177. return $this->_getFieldValue('FIELD_ALLOW_VIEW_TO', $iContentId);
  178. }
  179. public function serviceGetDateAdded ($iContentId)
  180. {
  181. $mixedResult = $this->_getFieldValue('FIELD_ADDED', $iContentId);
  182. return $mixedResult !== false ? (int)$mixedResult : 0;
  183. }
  184. public function serviceGetDateChanged ($iContentId)
  185. {
  186. $mixedResult = $this->_getFieldValue('FIELD_CHANGED', $iContentId);
  187. return $mixedResult !== false ? (int)$mixedResult : 0;
  188. }
  189. /**
  190. * @page service Service Calls
  191. * @section bx_base_general Base General
  192. * @subsection bx_base_general-other Other
  193. * @subsubsection bx_base_general-get_link get_link
  194. *
  195. * @code bx_srv('bx_posts', 'get_link', [...]); @endcode
  196. *
  197. * Get URL for the specified content.
  198. * @param $iContentId content id
  199. *
  200. * @see BxBaseModGeneralModule::serviceGetLink
  201. */
  202. /**
  203. * @ref bx_base_general-get_link "get_link"
  204. */
  205. public function serviceGetLink ($iContentId)
  206. {
  207. $CNF = &$this->_oConfig->CNF;
  208. if(empty($CNF['URI_VIEW_ENTRY']))
  209. return '';
  210. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  211. if(empty($aContentInfo))
  212. return '';
  213. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  214. }
  215. public function serviceGetTitle ($iContentId)
  216. {
  217. $mixedResult = $this->_getFieldValue('FIELD_TITLE', $iContentId);
  218. return $mixedResult !== false ? $mixedResult : '';
  219. }
  220. public function serviceGetText ($iContentId)
  221. {
  222. $mixedResult = $this->_getFieldValue('FIELD_TEXT', $iContentId);
  223. if (false === $mixedResult)
  224. return '';
  225. $CNF = &$this->_oConfig->CNF;
  226. if (!empty($CNF['OBJECT_METATAGS']) && is_string($mixedResult)) {
  227. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  228. $mixedResult = $oMetatags->metaParse($iContentId, $mixedResult);
  229. }
  230. return $mixedResult;
  231. }
  232. public function serviceGetInfo ($iContentId, $bSearchableFieldsOnly = true)
  233. {
  234. $CNF = &$this->_oConfig->CNF;
  235. $aContentInfo = $this->_getFields($iContentId);
  236. if(empty($aContentInfo))
  237. return array();
  238. if(!$bSearchableFieldsOnly)
  239. return $aContentInfo;
  240. if(empty($CNF['PARAM_SEARCHABLE_FIELDS']))
  241. return array();
  242. $aFields = explode(',', getParam($CNF['PARAM_SEARCHABLE_FIELDS']));
  243. if(empty($aFields))
  244. return array();
  245. $aResult = array();
  246. foreach($aFields as $sField)
  247. if(isset($aContentInfo[$sField]))
  248. $aResult[$sField] = $aContentInfo[$sField];
  249. return $aResult;
  250. }
  251. /**
  252. * @page service Service Calls
  253. * @section bx_base_general Base General
  254. * @subsection bx_base_general-browsing Browsing
  255. * @subsubsection bx_base_general-get_search_result_unit get_search_result_unit
  256. *
  257. * @code bx_srv('bx_posts', 'get_search_result_unit', [3,"unit_gallery.html"]); @endcode
  258. *
  259. * Get browsing unit for the specified content
  260. * @param $iContentId content id
  261. * @param $sUnitTemplate unit template, such as: unit_full.html, unit_gallery.html, unit_live_search.html
  262. *
  263. * @see BxBaseModGeneralModule::serviceGetSearchResultUnit
  264. */
  265. /**
  266. * @ref bx_base_general-get_search_result_unit "get_search_result_unit"
  267. */
  268. public function serviceGetSearchResultUnit ($iContentId, $sUnitTemplate = '')
  269. {
  270. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  271. if(empty($aContentInfo))
  272. return '';
  273. if(empty($sUnitTemplate))
  274. $sUnitTemplate = 'unit.html';
  275. return $this->_oTemplate->unit($aContentInfo, true, $sUnitTemplate);
  276. }
  277. public function serviceGetAll ($aParams = array())
  278. {
  279. if(empty($aParams) || !is_array($aParams))
  280. $aParams = array('type' => 'all');
  281. return $this->_oDb->getEntriesBy($aParams);
  282. }
  283. public function serviceGetAllByAuthor ($iProfileId)
  284. {
  285. return $this->_oDb->getEntriesByAuthor((int)$iProfileId);
  286. }
  287. public function serviceGetSearchableFieldsExtended($aInputsAdd = array())
  288. {
  289. $CNF = &$this->_oConfig->CNF;
  290. if(empty($CNF['OBJECT_FORM_ENTRY']))
  291. return array();
  292. $aResult = array();
  293. if(!empty($CNF['FIELD_AUTHOR']) && !in_array($CNF['FIELD_AUTHOR'], $this->_aSearchableNamesExcept))
  294. $aResult[$CNF['FIELD_AUTHOR']] = array(
  295. 'type' => 'text_auto',
  296. 'caption' => $CNF['T']['form_field_author'],
  297. 'info' => '',
  298. 'value' => '',
  299. 'values' => '',
  300. 'pass' => ''
  301. );
  302. $aInputs = array();
  303. if(!empty($CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'])) {
  304. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate);
  305. $aInputs = array_merge($aInputs, $oForm->aInputs);
  306. }
  307. if(!empty($CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'])) {
  308. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'], $this->_oTemplate);
  309. $aInputs = array_merge($aInputs, $oForm->aInputs);
  310. }
  311. if(!empty($aInputsAdd) && is_array($aInputsAdd))
  312. $aInputs = array_merge($aInputs, $aInputsAdd);
  313. foreach($aInputs as $aInput){
  314. if(in_array($aInput['type'], BxDolSearchExtended::$SEARCHABLE_TYPES) && !in_array($aInput['name'], $this->_aSearchableNamesExcept)) {
  315. $aField = array(
  316. 'type' => $aInput['type'],
  317. 'caption_system' => $aInput['caption_system_src'],
  318. 'caption' => $aInput['caption_src'],
  319. 'info' => $aInput['info_src'],
  320. 'value' => !empty($aInput['value']) ? $aInput['value'] : '',
  321. 'values' => !empty($aInput['values_src']) ? $aInput['values_src'] : '',
  322. 'pass' => !empty($aInput['db']['pass']) ? $aInput['db']['pass'] : '',
  323. );
  324. if(isset($aInput['search_type']))
  325. $aField['search_type'] = $aInput['search_type'];
  326. if(isset($aInput['search_operator']))
  327. $aField['search_operator'] = $aInput['search_operator'];
  328. $aResult[$aInput['name']] = $aField;
  329. }
  330. }
  331. return $aResult;
  332. }
  333. public function serviceGetSearchResultExtended($aParams, $iStart = 0, $iPerPage = 0, $bFilterMode = false)
  334. {
  335. if((empty($aParams) || !is_array($aParams)) && !$bFilterMode)
  336. return array();
  337. return $this->_oDb->getEntriesBy(array('type' => 'search_ids', 'search_params' => $aParams, 'start' => $iStart, 'per_page' => $iPerPage));
  338. }
  339. public function serviceGetSearchableFields ($aInputsAdd = array())
  340. {
  341. $CNF = $this->_oConfig->CNF;
  342. if(!isset($CNF['PARAM_SEARCHABLE_FIELDS']) || !isset($CNF['OBJECT_FORM_ENTRY']) || !isset($CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']))
  343. return array();
  344. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate);
  345. if(!$oForm)
  346. return array();
  347. $aInputs = $oForm->aInputs;
  348. if(!empty($aInputsAdd) && is_array($aInputsAdd))
  349. $aInputs = array_merge($aInputs, $aInputsAdd);
  350. $aTextTypes = array('text', 'textarea');
  351. $aTextFields = array();
  352. foreach($aInputs as $r)
  353. if(in_array($r['type'], $aTextTypes))
  354. $aTextFields[$r['name']] = $r['caption'];
  355. return $aTextFields;
  356. }
  357. public function serviceManageTools($sType = 'common')
  358. {
  359. $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->getGridObject($sType));
  360. if(!$oGrid)
  361. return '';
  362. $CNF = &$this->_oConfig->CNF;
  363. $sMenu = '';
  364. if(BxDolAcl::getInstance()->isMemberLevelInSet(192)) {
  365. $oPermalink = BxDolPermalinks::getInstance();
  366. $aMenuItems = array();
  367. if(!empty($CNF['OBJECT_GRID_COMMON']) && !empty($CNF['T']['menu_item_manage_my']))
  368. $aMenuItems[] = array('id' => 'manage-common', 'name' => 'manage-common', 'class' => '', 'link' => $oPermalink->permalink($CNF['URL_MANAGE_COMMON']), 'target' => '_self', 'title' => _t($CNF['T']['menu_item_manage_my']), 'active' => 1);
  369. if(!empty($CNF['OBJECT_GRID_ADMINISTRATION']) && !empty($CNF['T']['menu_item_manage_all']))
  370. $aMenuItems[] = array('id' => 'manage-administration', 'name' => 'manage-administration', 'class' => '', 'link' => $oPermalink->permalink($CNF['URL_MANAGE_ADMINISTRATION']), 'target' => '_self', 'title' => _t($CNF['T']['menu_item_manage_all']), 'active' => 1);
  371. if(count($aMenuItems) > 1) {
  372. $oMenu = new BxTemplMenu(array(
  373. 'template' => 'menu_vertical.html',
  374. 'menu_items' => $aMenuItems
  375. ), $this->_oTemplate);
  376. $oMenu->setSelected($this->_aModule['name'], 'manage-' . $sType);
  377. $sMenu = $oMenu->getCode();
  378. }
  379. }
  380. if(!empty($CNF['OBJECT_MENU_SUBMENU']) && isset($CNF['URI_MANAGE_COMMON'])) {
  381. BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SUBMENU'])->setSelected($this->_aModule['name'], $CNF['URI_MANAGE_COMMON']);
  382. }
  383. $this->_oTemplate->addCss(array('manage_tools.css'));
  384. $this->_oTemplate->addJs(array('manage_tools.js'));
  385. $this->_oTemplate->addJsTranslation(array('_sys_grid_search'));
  386. return array(
  387. 'content' => $this->_oTemplate->getJsCode('manage_tools', array('sObjNameGrid' => $this->_oConfig->getGridObject($sType))) . $oGrid->getCode(),
  388. 'menu' => $sMenu
  389. );
  390. }
  391. public function serviceGetMenuAddonManageTools()
  392. {
  393. return 0;
  394. }
  395. public function serviceGetMenuAddonManageToolsProfileStats()
  396. {
  397. return 0;
  398. }
  399. /**
  400. * @page service Service Calls
  401. * @section bx_base_general Base General
  402. * @subsection bx_base_general-browsing Browsing
  403. * @subsubsection bx_base_general-browse browse
  404. *
  405. * @code bx_srv('bx_posts', 'browse', [...]); @endcode
  406. * @code {{~bx_posts:browse[{"mode":"author", "params":{"author":"10"}}]~}} @endcode
  407. *
  408. * Universal browse method.
  409. * @param $aParams custom browse params, possible params are the following:
  410. * - mode - browse mode, such as 'recent', 'featured', etc
  411. * - params - custom params to browse method, for example 'unit_view' can be passed here
  412. * - design_box - design box style, @see BxBaseFunctions::DesignBoxContent
  413. * - empty_message - display or not "empty" message when there is no content
  414. * - ajax_paginate - use AJAX paginate or not
  415. *
  416. * @see BxBaseModGeneralModule::serviceBrowse
  417. */
  418. /**
  419. * @ref bx_base_general-browse "browse"
  420. */
  421. public function serviceBrowse ($aParams = array())
  422. {
  423. unset($aParams['params']['condition']);
  424. return $this->serviceBrowseWithCondition ($aParams);
  425. }
  426. public function serviceBrowseWithCondition ($aParams = array())
  427. {
  428. $aDefaults = array (
  429. 'mode' => 'recent',
  430. 'params' => false,
  431. 'design_box' => BX_DB_PADDING_DEF,
  432. 'empty_message' => false,
  433. 'ajax_paginate' => true,
  434. 'class_search_result' => 'SearchResult'
  435. );
  436. $aParams = array_merge($aDefaults, $aParams);
  437. return $this->_serviceBrowse ($aParams['mode'], $aParams['params'], $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate'], $aParams['class_search_result']);
  438. }
  439. /**
  440. * @page service Service Calls
  441. * @section bx_base_general Base General
  442. * @subsection bx_base_general-browsing Browsing
  443. * @subsubsection bx_base_general-browse_featured browse_featured
  444. *
  445. * @code bx_srv('bx_posts', 'browse_featured', [...]); @endcode
  446. *
  447. * Display featured entries
  448. * @param $sUnitView browsing unity view,
  449. * such as: full, extended, gallery, showcase
  450. * @param $bEmptyMessage display or not "empty" message when there is no content
  451. * @param $bAjaxPaginate use AJAX paginate or not
  452. *
  453. * @see BxBaseModGeneralModule::serviceBrowseFeatured
  454. */
  455. /**
  456. * @ref bx_base_general-browse_featured "browse_featured"
  457. */
  458. public function serviceBrowseFeatured ($sUnitView = false, $bEmptyMessage = false, $bAjaxPaginate = true)
  459. {
  460. return $this->_serviceBrowse ('featured', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  461. }
  462. /**
  463. * @page service Service Calls
  464. * @section bx_base_general Base General
  465. * @subsection bx_base_general-browsing Browsing
  466. * @subsubsection bx_base_general-browse_favorite browse_favorite
  467. *
  468. * @code bx_srv('bx_posts', 'browse_favorite', [...]); @endcode
  469. *
  470. * Display entries which were added to favorite list by some member
  471. * @param $iProfileId profile ID
  472. * @param $aParams additional browse params, see BxBaseModGeneralModule::serviceBrowse
  473. *
  474. * @see BxBaseModGeneralModule::serviceBrowseFavorite BxBaseModGeneralModule::serviceBrowse
  475. */
  476. /**
  477. * @ref bx_base_general-browse_favorite "browse_favorite"
  478. */
  479. public function serviceBrowseFavorite ($iProfileId = 0, $aParams = array())
  480. {
  481. $oProfile = null;
  482. if((int)$iProfileId)
  483. $oProfile = BxDolProfile::getInstance($iProfileId);
  484. if(!$oProfile && bx_get('profile_id') !== false)
  485. $oProfile = BxDolProfile:: getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT));
  486. if(!$oProfile)
  487. $oProfile = BxDolProfile::getInstance();
  488. if(!$oProfile)
  489. return '';
  490. $bEmptyMessage = false;
  491. if(isset($aParams['empty_message'])) {
  492. $bEmptyMessage = (bool)$aParams['empty_message'];
  493. unset($aParams['empty_message']);
  494. }
  495. if(bx_get('list_id') !== false && !isset($aParams['list_id']))
  496. $aParams['list_id'] = (int) bx_get('list_id');
  497. return $this->_serviceBrowse ('favorite', array_merge(array('user' => $oProfile->id()), $aParams), BX_DB_PADDING_DEF, $bEmptyMessage);
  498. }
  499. /**
  500. * @page service Service Calls
  501. * @section bx_base_general Base General
  502. * @subsection bx_base_general-browsing Browsing
  503. * @subsubsection bx_base_general-browse_favorite_lists browse_favorite_lists
  504. *
  505. * @code bx_srv('bx_posts', 'browse_favorite_lists', [...]); @endcode
  506. *
  507. * Display entries which were added to favorite lists grouped by lists by some member
  508. * @param $iProfileId profile ID
  509. * @param $aParams additional browse params, see BxBaseModGeneralModule::serviceBrowse
  510. *
  511. * @see BxBaseModGeneralModule::serviceBrowseFavoriteLists BxBaseModGeneralModule::serviceBrowse
  512. */
  513. /**
  514. * @ref bx_base_general-browse_favorite_lists "browse_favorite_lists"
  515. */
  516. public function serviceBrowseFavoriteLists ($iProfileId = 0, $aParams = array())
  517. {
  518. $CNF = &$this->_oConfig->CNF;
  519. $oProfile = null;
  520. if((int)$iProfileId)
  521. $oProfile = BxDolProfile::getInstance($iProfileId);
  522. if(!$oProfile && bx_get('profile_id') !== false)
  523. $oProfile = BxDolProfile:: getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT));
  524. if(!$oProfile)
  525. $oProfile = BxDolProfile::getInstance();
  526. if(!$oProfile)
  527. return '';
  528. $iStart = (bx_get('list_start') !== false ? (int)bx_get('list_start') : 0);
  529. $iPerPage = (int)getParam($CNF['PARAM_PER_PAGE_FOR_FAVORITES_LISTS']);
  530. return $this->_oTemplate->getFavoriteList($oProfile, $iStart, $iPerPage, $aParams);
  531. }
  532. /**
  533. * @page service Service Calls
  534. * @section bx_base_general Base General
  535. * @subsection bx_base_general-browsing Browsing
  536. * @subsubsection bx_base_general-browse_favorite_list_actions browse_favorite_list_actions
  537. *
  538. * @code bx_srv('bx_posts', 'browse_favorite_list_actions', [...]); @endcode
  539. *
  540. * Display menu actions for favorite lists
  541. *
  542. * @see BxBaseModGeneralModule::serviceFavoritesListActions
  543. */
  544. /**
  545. * @ref bx_base_general-browse_favorite_list_actions "browse_favorite_list_actions"
  546. */
  547. public function serviceFavoritesListActions(){
  548. $iListId = null;
  549. if(bx_get('list_id') === false)
  550. return false;
  551. $iListId = (int) bx_get('list_id');
  552. $oProfile = null;
  553. if(bx_get('profile_id') !== false)
  554. $oProfile = BxDolProfile:: getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT));
  555. if(!$oProfile)
  556. return false;
  557. $CNF = &$this->_oConfig->CNF;
  558. $oFavorite = BxDolFavorite::getObjectInstance($CNF['OBJECT_FAVORITES'], 0, true);
  559. $aList = $oFavorite->getQueryObject()->getList(array('type' => 'id', 'list_id' => $iListId));
  560. $sRv = '';
  561. if (!empty($aList) && $oFavorite->isAllowedEditList($aList['author_id'])){
  562. $aMarkers = array(
  563. 'js_object' => $oFavorite->getJsObjectName(),
  564. 'list_id' => $iListId,
  565. );
  566. $oMenu = BxDolMenu::getObjectInstance('sys_favorite_list');
  567. $oMenu->addMarkers($aMarkers);
  568. $sMenu = $oMenu->getCode();
  569. $sRv .= $sMenu . $oFavorite->getJsScript();
  570. }
  571. $aMarkers = array(
  572. 'id' => $iListId,
  573. 'module' => $this->_aModule['name'],
  574. 'url' => $this->_getFavoriteListUrl($iListId, $oProfile->id()),
  575. 'title' => $iListId > 0 ? $aList['title'] : _t('_sys_txt_default_favorite_list')
  576. );
  577. $oMenu = BxDolMenu::getObjectInstance('sys_social_sharing');
  578. $oMenu->addMarkers($aMarkers);
  579. $sRv .= $sMenu = $oMenu->getCode();
  580. return $sRv;
  581. }
  582. /**
  583. * @page service Service Calls
  584. * @section bx_base_general Base General
  585. * @subsection bx_base_general-menu Menu
  586. * @subsubsection bx_base_general-favorites_list_info favorites_list_info
  587. *
  588. * @code bx_srv('bx_posts', 'favorites_list_info', [...]); @endcode
  589. *
  590. * Favorites list info
  591. * @param $aParams array with additional custom params
  592. * which may overwrite some default values
  593. *
  594. * @see BxBaseModGeneralModule::serviceFavoritesListInfo
  595. */
  596. /**
  597. * @ref bx_base_general-favorites_list_info "favorites_list_info"
  598. */
  599. public function serviceFavoritesListInfo($aParams = array()){
  600. $CNF = &$this->_oConfig->CNF;
  601. $iListId = null;
  602. if(bx_get('list_id') === false)
  603. return false;
  604. $iListId = (int) bx_get('list_id');
  605. $oProfile = null;
  606. if(bx_get('profile_id') !== false)
  607. $oProfile = BxDolProfile:: getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT));
  608. if(!$oProfile)
  609. return false;
  610. $oFavorite = BxDolFavorite::getObjectInstance($CNF['OBJECT_FAVORITES'], 0, true);
  611. $aList = $oFavorite->getQueryObject()->getList(array('type' => 'info', 'list_id' => $iListId, 'author_id' => $oProfile->id()));
  612. if (empty($aList))
  613. return false;
  614. return $this->_oTemplate->getFavoritesListInfo($aList, $oProfile);
  615. }
  616. /**
  617. * Display entries posted into particular context
  618. * @return HTML string
  619. */
  620. public function serviceBrowseContext ($iProfileId = 0, $aParams = array())
  621. {
  622. return $this->_serviceBrowseWithParam ('context', 'profile_id', $iProfileId, $aParams);
  623. }
  624. public function _serviceBrowseWithParam ($sParamName, $sParamGet, $sParamVal, $aParams = array())
  625. {
  626. if(!$sParamVal)
  627. $sParamVal = bx_process_input(bx_get($sParamGet), BX_DATA_INT);
  628. if(!$sParamVal)
  629. return '';
  630. $bEmptyMessage = true;
  631. if(isset($aParams['empty_message'])) {
  632. $bEmptyMessage = (bool)$aParams['empty_message'];
  633. unset($aParams['empty_message']);
  634. }
  635. $bAjaxPaginate = true;
  636. if(isset($aParams['ajax_paginate'])) {
  637. $bAjaxPaginate = (bool)$aParams['ajax_paginate'];
  638. unset($aParams['ajax_paginate']);
  639. }
  640. return $this->_serviceBrowse ($sParamName, array_merge(array($sParamName => $sParamVal), $aParams), BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  641. }
  642. public function serviceFormsHelper ()
  643. {
  644. bx_import('FormsEntryHelper', $this->_aModule);
  645. $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
  646. return new $sClass($this);
  647. }
  648. /**
  649. * Add entry using provided fields' values.
  650. * @return array with result: 'code' is 0 on success or non-zero on error, 'message' is error message in case of error, 'content' is content info array in case of success
  651. */
  652. public function serviceEntityAdd ($iProfile, $aValues, $sDisplay = false)
  653. {
  654. bx_import('FormsEntryHelper', $this->_aModule);
  655. $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
  656. $oFormsHelper = new $sClass($this);
  657. return $oFormsHelper->addData($iProfile, $aValues, $sDisplay);
  658. }
  659. /**
  660. * Perform redirect after content creation
  661. * @return nothing, rediret header is sent
  662. */
  663. public function serviceRedirectAfterAdd($aContentInfo)
  664. {
  665. bx_import('FormsEntryHelper', $this->_aModule);
  666. $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
  667. $oFormsHelper = new $sClass($this);
  668. $oFormsHelper->redirectAfterAdd($aContentInfo);
  669. }
  670. /**
  671. * Get form object for add, edit, view or delete the content
  672. * @param $sType 'add', 'edit', 'view' or 'delete'
  673. * @param $aParams optional array with parameters(display name, etc)
  674. * @return form object or false on error
  675. */
  676. public function serviceGetObjectForm ($sType, $aParams = array())
  677. {
  678. if(!in_array($sType, array('add', 'edit', 'view', 'delete')))
  679. return false;
  680. $mixedContextId = isset($aParams['context_id']) ? $aParams['context_id'] : false;
  681. $bContext = $mixedContextId !== false;
  682. if($bContext && ($oContextProfile = BxDolProfile::getInstance(abs($mixedContextId))) !== false)
  683. if($oContextProfile->checkAllowedPostInProfile() !== CHECK_ACTION_RESULT_ALLOWED)
  684. return false;
  685. $CNF = &$this->_oConfig->CNF;
  686. bx_import('FormsEntryHelper', $this->_aModule);
  687. $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
  688. $oFormsHelper = new $sClass($this);
  689. $sParamsKey = 'ajax_mode';
  690. if(isset($aParams[$sParamsKey]) && (bool)$aParams[$sParamsKey] === true)
  691. $oFormsHelper->setAjaxMode((bool)$aParams[$sParamsKey]);
  692. $sParamsKey = 'absolute_action_url';
  693. if(isset($aParams[$sParamsKey]) && (bool)$aParams[$sParamsKey] === true)
  694. $oFormsHelper->setAbsoluteActionUrl((bool)$aParams[$sParamsKey]);
  695. $sDisplay = !empty($aParams['display']) ? $aParams['display'] : false;
  696. $sFunc = 'getObjectForm' . ucfirst($sType);
  697. $oForm = $oFormsHelper->$sFunc($sDisplay);
  698. $sKey = 'FIELD_ALLOW_VIEW_TO';
  699. if(!empty($CNF[$sKey]) && !empty($oForm->aInputs[$CNF[$sKey]]) && (!$bContext || $mixedContextId < 0)) {
  700. $bContextOwner = $bContext && abs($mixedContextId) == (int)bx_get_logged_profile_id();
  701. if(!$bContext || $bContextOwner) {
  702. $iGc = 0;
  703. $iKeyGh = false;
  704. foreach($oForm->aInputs[$CNF[$sKey]]['values'] as $iKey => $aValue) {
  705. if(isset($aValue['type']) && in_array($aValue['type'], array('group_header', 'group_end'))) {
  706. if($iKeyGh !== false && $iGc == 0) {
  707. unset($oForm->aInputs[$CNF[$sKey]]['values'][$iKeyGh]);
  708. $iKeyGh = false;
  709. if($aValue['type'] == 'group_end')
  710. unset($oForm->aInputs[$CNF[$sKey]]['values'][$iKey]);
  711. }
  712. if($aValue['type'] == 'group_header') {
  713. $iGc = 0;
  714. $iKeyGh = $iKey;
  715. }
  716. continue;
  717. }
  718. //--- Show 'Public' privacy group only in Public post form.
  719. if(!$bContext && $aValue['key'] == BX_DOL_PG_ALL) {
  720. $iGc += 1;
  721. continue;
  722. }
  723. //--- Show a default privacy groups in Profile (for Owner) post form.
  724. if($bContextOwner && (int)$aValue['key'] >= 0) {
  725. $iGc += 1;
  726. continue;
  727. }
  728. unset($oForm->aInputs[$CNF[$sKey]]['values'][$iKey]);
  729. }
  730. }
  731. else {
  732. $oForm->aInputs[$CNF[$sKey]]['value'] = $mixedContextId;
  733. $oForm->aInputs[$CNF[$sKey]]['type'] = 'hidden';
  734. }
  735. }
  736. bx_alert('system', 'get_object_form', 0, 0, array(
  737. 'module' => $this->_oConfig->getName(),
  738. 'type' => $sType,
  739. 'params' => $aParams,
  740. 'form' => &$oForm
  741. ));
  742. return $oForm;
  743. }
  744. /**
  745. * Create entry form
  746. * @return HTML string
  747. */
  748. public function serviceEntityCreate ($sParams = false)
  749. {
  750. $bParamsArray = is_array($sParams);
  751. $sDisplay = is_string($sParams) ? $sParams : false;
  752. if($bParamsArray && !empty($sParams['display']))
  753. $sDisplay = $sParams['display'];
  754. bx_import('FormsEntryHelper', $this->_aModule);
  755. $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
  756. $oFormsHelper = new $sClass($this);
  757. if($bParamsArray && isset($sParams['dynamic_mode']))
  758. $oFormsHelper->setDynamicMode($sParams['dynamic_mode']);
  759. $mixedResult = $oFormsHelper->addDataForm($sDisplay);
  760. if(isset($mixedResult['_dt']) && $mixedResult['_dt'] == 'json') {
  761. echoJson($mixedResult);
  762. exit;
  763. }
  764. return $mixedResult;
  765. }
  766. /**
  767. * @page service Service Calls
  768. * @section bx_base_general Base General
  769. * @subsection bx_base_general-forms Forms
  770. * @subsubsection bx_base_general-get_create_post_form get_create_post_form
  771. *
  772. * @code bx_srv('bx_posts', 'get_create_post_form'); @endcode
  773. *
  774. * Get content creation form
  775. * @param $aParams additional parameters array:
  776. * context_id, ajax_mode, absolute_action_url, displays
  777. *
  778. * @see BxBaseModGeneralModule::serviceGetCreatePostForm
  779. */
  780. /**
  781. * @ref bx_base_general-get_create_post_form "get_create_post_form"
  782. */
  783. public function serviceGetCreatePostForm($aParams = array())
  784. {
  785. $aParams = array_merge($this->_aFormParams, $aParams);
  786. $oForm = $this->serviceGetObjectForm('add', $aParams);
  787. if(!$oForm)
  788. return '';
  789. return $this->serviceEntityCreate($aParams);
  790. }
  791. /**
  792. * @page service Service Calls
  793. * @section bx_base_general Base General
  794. * @subsection bx_base_general-forms Forms
  795. * @subsubsection bx_base_general-entity_edit entity_edit
  796. *
  797. * @code bx_srv('bx_posts', 'entity_edit', [...]); @endcode
  798. *
  799. * Get content edit form
  800. * @param $iContentId content ID
  801. * @param $sDisplay optional form display name
  802. *
  803. * @see BxBaseModGeneralModule::serviceEntityEdit
  804. */
  805. /**
  806. * @ref bx_base_general-entity_edit "entity_edit"
  807. */
  808. public function serviceEntityEdit ($iContentId = 0, $sDisplay = false)
  809. {
  810. return $this->_serviceEntityForm ('editDataForm', $iContentId, $sDisplay);
  811. }
  812. /**
  813. * @page service Service Calls
  814. * @section bx_base_general Base General
  815. * @subsection bx_base_general-forms Forms
  816. * @subsubsection bx_base_general-entity_delete entity_delete
  817. *
  818. * @code bx_srv('bx_posts', 'entity_delete', [...]); @endcode
  819. *
  820. * Get content delete form
  821. * @param $iContentId content ID
  822. *
  823. * @see BxBaseModGeneralModule::serviceEntityDelete
  824. */
  825. /**
  826. * @ref bx_base_general-entity_delete "entity_delete"
  827. */
  828. public function serviceEntityDelete ($iContentId = 0)
  829. {
  830. return $this->_serviceEntityForm ('deleteDataForm', $iContentId);
  831. }
  832. /**
  833. * @page service Service Calls
  834. * @section bx_base_general Base General
  835. * @subsection bx_base_general-page_blocks Page Blocks
  836. * @subsubsection bx_base_general-entity_text_block entity_text_block
  837. *
  838. * @code bx_srv('bx_posts', 'entity_text_block', [...]); @endcode
  839. *
  840. * Get content text/description
  841. * @param $iContentId content ID
  842. *
  843. * @see BxBaseModGeneralModule::serviceEntityTextBlock
  844. */
  845. /**
  846. * @ref bx_base_general-entity_text_block "entity_text_block"
  847. */
  848. public function serviceEntityTextBlock ($iContentId = 0)
  849. {
  850. return $this->_serviceEntityForm ('viewDataEntry', $iContentId);
  851. }
  852. /**
  853. * @page service Service Calls
  854. * @section bx_base_general Base General
  855. * @subsection bx_base_general-page_blocks Page Blocks
  856. * @subsubsection bx_base_general-entity_info entity_info
  857. *
  858. * @code bx_srv('bx_posts', 'entity_info', [...]); @endcode
  859. *
  860. * Get content info
  861. * @param $iContentId content ID
  862. *
  863. * @see BxBaseModGeneralModule::serviceEntityInfo
  864. */
  865. /**
  866. * @ref bx_base_general-entity_info "entity_info"
  867. */
  868. public function serviceEntityInfo ($iContentId = 0, $sDisplay = false)
  869. {
  870. return $this->_serviceEntityForm ('viewDataForm', $iContentId, $sDisplay);
  871. }
  872. /**
  873. * @page service Service Calls
  874. * @section bx_base_general Base General
  875. * @subsection bx_base_general-page_blocks Page Blocks
  876. * @subsubsection bx_base_general-entity_info_full entity_info_full
  877. *
  878. * @code bx_srv('bx_posts', 'entity_info_full', [...]); @endcode
  879. *
  880. * Get full content info
  881. * @param $iContentId content ID
  882. *
  883. * @see BxBaseModGeneralModule::serviceEntityInfoFull
  884. */
  885. /**
  886. * @ref bx_base_general-entity_info_full "entity_info_full"
  887. */
  888. public function serviceEntityInfoFull ($iContentId = 0)
  889. {
  890. $CNF = &$this->_oConfig->CNF;
  891. $sDisplayName = 'OBJECT_FORM_ENTRY_DISPLAY_VIEW_FULL';
  892. return $this->_serviceEntityForm ('viewDataForm', $iContentId, !empty($CNF[$sDisplayName]) ? $CNF[$sDisplayName] : false);
  893. }
  894. /**
  895. * @page service Service Calls
  896. * @section bx_base_general Base General
  897. * @subsection bx_base_general-page_blocks Page Blocks
  898. * @subsubsection bx_base_general-entity_info_extended entity_info_extended
  899. *
  900. * @code bx_srv('bx_posts', 'entity_info_extended', [...]); @endcode
  901. *
  902. * Get extended content info
  903. * @param $iContentId content ID
  904. *
  905. * @see BxBaseModGeneralModule::serviceEntityInfoExtended
  906. */
  907. /**
  908. * @ref bx_base_general-entity_info_extended "entity_info_extended"
  909. */
  910. public function serviceEntityInfoExtended ($iContentId = 0)
  911. {
  912. return $this->_serviceTemplateFunc ('entryInfo', $iContentId);
  913. }
  914. /**
  915. * @page service Service Calls
  916. * @section bx_base_general Base General
  917. * @subsection bx_base_general-page_blocks Page Blocks
  918. * @subsubsection bx_base_general-entity_location entity_location
  919. *
  920. * @code bx_srv('bx_posts', 'entity_location', [...]); @endcode
  921. *
  922. * Get content location
  923. * @param $iContentId content ID
  924. *
  925. * @see BxBaseModGeneralModule::serviceEntityLocation
  926. */
  927. /**
  928. * @ref bx_base_general-entity_location "entity_location"
  929. */
  930. public function serviceEntityLocation ($iContentId = 0)
  931. {
  932. $iContentId = $this->_getContent($iContentId, false);
  933. if($iContentId === false)
  934. return false;
  935. return $this->_oTemplate->entryLocation ($iContentId);
  936. }
  937. /**
  938. * @page service Service Calls
  939. * @section bx_base_general Base General
  940. * @subsection bx_base_general-page_blocks Page Blocks
  941. * @subsubsection bx_base_general-entity_comments entity_comments
  942. *
  943. * @code bx_srv('bx_posts', 'entity_comments', [...]); @endcode
  944. *
  945. * Get content comments
  946. * @param $iContentId content ID
  947. *
  948. * @see BxBaseModGeneralModule::serviceEntityComments
  949. */
  950. /**
  951. * @ref bx_base_general-entity_comments "entity_comments"
  952. */
  953. public function serviceEntityComments ($iContentId = 0)
  954. {
  955. $CNF = &$this->_oConfig->CNF;
  956. if(empty($CNF['OBJECT_COMMENTS']))
  957. return '';
  958. return $this->_entityComments($CNF['OBJECT_COMMENTS'], $iContentId);
  959. }
  960. /**
  961. * @page service Service Calls
  962. * @section bx_base_general Base General
  963. * @subsection bx_base_general-page_blocks Page Blocks
  964. * @subsubsection bx_base_general-entity_attachments entity_attachments
  965. *
  966. * @code bx_srv('bx_posts', 'entity_attachments', [...]); @endcode
  967. *
  968. * Get content attachments
  969. * @param $iContentId content ID
  970. *
  971. * @see BxBaseModGeneralModule::serviceEntityAttachments
  972. */
  973. /**
  974. * @ref bx_base_general-entity_attachments "entity_attachments"
  975. */
  976. public function serviceEntityAttachments ($iContentId = 0)
  977. {
  978. return $this->_serviceTemplateFunc ('entryAttachments', $iContentId);
  979. }
  980. /**
  981. * Delete content entry
  982. * @param $iContentId content id
  983. * @return error message or empty string on success
  984. */
  985. public function serviceDeleteEntity ($iContentId, $sFuncDelete = 'deleteData')
  986. {
  987. bx_import('FormsEntryHelper', $this->_aModule);
  988. $sClass = $this->_oConfig->getClassPrefix() . 'FormsEntryHelper';
  989. $oFormsHelper = new $sClass($this);
  990. return $oFormsHelper->$sFuncDelete($iContentId);
  991. }
  992. /**
  993. * @page service Service Calls
  994. * @section bx_base_general Base General
  995. * @subsection bx_base_general-menu Menu
  996. * @subsubsection bx_base_general-my_entries_actions my_entries_actions
  997. *
  998. * @code bx_srv('bx_posts', 'my_entries_actions', [...]); @endcode
  999. *
  1000. * My entries actions menu
  1001. * @param $iProfileId profiles ID,
  1002. * if omitted it try to get it from 'profile_id' GET param
  1003. *
  1004. * @see BxBaseModGeneralModule::serviceMyEntriesActions
  1005. */
  1006. /**
  1007. * @ref bx_base_general-my_entries_actions "my_entries_actions"
  1008. */
  1009. public function serviceMyEntriesActions ($iProfileId = 0)
  1010. {
  1011. $CNF = &$this->_oConfig->CNF;
  1012. if(empty($CNF['OBJECT_MENU_ACTIONS_MY_ENTRIES']))
  1013. return false;
  1014. if (!$iProfileId)
  1015. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  1016. if (!$iProfileId || !($oProfile = BxDolProfile::getInstance($iProfileId)))
  1017. return false;
  1018. if ($iProfileId != $this->_iProfileId)
  1019. return false;
  1020. $oMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_MY_ENTRIES']);
  1021. return $oMenu ? $oMenu->getCode() : false;
  1022. }
  1023. /**
  1024. * @page service Service Calls
  1025. * @section bx_base_general Base General
  1026. * @subsection bx_base_general-menu Menu
  1027. * @subsubsection bx_base_general-entity_all_actions entity_all_actions
  1028. *
  1029. * @code bx_srv('bx_posts', 'entity_all_actions', [...]); @endcode
  1030. *
  1031. * Entry actions and social sharing actions
  1032. * @param $mixedContent content ID
  1033. * @param $aParams additional params
  1034. *
  1035. * @see BxBaseModGeneralModule::serviceEntityAllActions
  1036. */
  1037. /**
  1038. * @ref bx_base_general-entity_all_actions "entity_all_actions"
  1039. */
  1040. public function serviceEntityAllActions ($mixedContent = false, $aParams = array())
  1041. {
  1042. $CNF = &$this->_oConfig->CNF;
  1043. if(!empty($mixedContent)) {
  1044. if(!is_array($mixedContent))
  1045. $mixedContent = array((int)$mixedContent, (method_exists($this->_oDb, 'getContentInfoById')) ? $this->_oDb->getContentInfoById((int)$mixedContent) : array());
  1046. }
  1047. else {
  1048. $mixedContent = $this->_getContent();
  1049. if($mixedContent === false)
  1050. return false;
  1051. }
  1052. list($iContentId, $aContentInfo) = $mixedContent;
  1053. $sObjectMenu = !empty($aParams['object_menu']) ? $aParams['object_menu'] : '';
  1054. if(empty($sObjectMenu) && !empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL']))
  1055. $sObjectMenu = $CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL'];
  1056. if(empty($sObjectMenu))
  1057. return false;
  1058. $sEntryTitle = !empty($aParams['entry_title']) ? $aParams['entry_title'] : '';
  1059. if(empty($sEntryTitle) && !empty($CNF['FIELD_TITLE']) && !empty($aContentInfo[$CNF['FIELD_TITLE']]))
  1060. $sEntryTitle = $aContentInfo[$CNF['FIELD_TITLE']];
  1061. $sEntryUrl = !empty($aParams['entry_url']) ? $aParams['entry_url'] : '';
  1062. if(empty($sEntryUrl) && !empty($CNF['URI_VIEW_ENTRY']))
  1063. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId);
  1064. $iEntryThumb = !empty($aParams['entry_thumb']) ? (int)$aParams['entry_thumb'] : 0;
  1065. if(empty($iEntryThumb) && !empty($CNF['FIELD_THUMB']) && !empty($aContentInfo[$CNF['FIELD_THUMB']]))
  1066. $iEntryThumb = (int)$aContentInfo[$CNF['FIELD_THUMB']];
  1067. $sObjectStorage = !empty($aParams['object_storage']) ? $aParams['object_storage'] : false;
  1068. if(empty($sObjectStorage) && !empty($CNF['OBJECT_STORAGE']))
  1069. $sObjectStorage = $CNF['OBJECT_STORAGE'];
  1070. $sObjectTranscoder = !empty($aParams['object_transcoder']) ? $aParams['object_transcoder'] : false;
  1071. $aMarkers = array(
  1072. 'id' => $iContentId,
  1073. 'module' => $this->_oConfig->getName(),
  1074. 'title' => !empty($sEntryTitle) ? $sEntryTitle : '',
  1075. 'url' => !empty($sEntryUrl) ? $sEntryUrl : '',
  1076. 'img_url' => ''
  1077. );
  1078. if(!empty($iEntryThumb)) {
  1079. if(!empty($sObjectTranscoder))
  1080. $o = BxDolTranscoder::getObjectInstance($sObjectTranscoder);
  1081. else if(!empty($sObjectStorage))
  1082. $o = BxDolStorage::getObjectInstance($sObjectStorage);
  1083. $sImageUrl = $o ? $o->getFileUrlById($iEntryThumb) : '';
  1084. if(!empty($sImageUrl))
  1085. $aMarkers['img_url'] = $sImageUrl;
  1086. }
  1087. $oActions = BxDolMenu::getObjectInstance($sObjectMenu);
  1088. if(!$oActions)
  1089. return false;
  1090. $oActions->setContentId($iContentId);
  1091. $oActions->addMarkers($aMarkers);
  1092. return $this->_oTemplate->entryAllActions($oActions->getCode());
  1093. }
  1094. /**
  1095. * @page service Service Calls
  1096. * @section bx_base_general Base General
  1097. * @subsection bx_base_general-menu Menu
  1098. * @subsubsection bx_base_general-entity_actions entity_actions
  1099. *
  1100. * @code bx_srv('bx_posts', 'entity_actions', [...]); @endcode
  1101. *
  1102. * Entry actions, without social sharing actions
  1103. * @param $iContentId content ID
  1104. *
  1105. * @see BxBaseModGeneralModule::serviceEntityActions
  1106. */
  1107. /**
  1108. * @ref bx_base_general-entity_actions "entity_actions"
  1109. */
  1110. public function serviceEntityActions ($iContentId = 0)
  1111. {
  1112. $iContentId = $this->_getContent($iContentId, false);
  1113. if($iContentId === false)
  1114. return false;
  1115. $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']);
  1116. return $oMenu ? $oMenu->getCode() : false;
  1117. }
  1118. /**
  1119. * @page service Service Calls
  1120. * @section bx_base_general Base General
  1121. * @subsection bx_base_general-page_blocks Page Blocks
  1122. * @subsubsection bx_base_general-entity_reports entity_reports
  1123. *
  1124. * @code bx_srv('bx_posts', 'entity_reports', [...]); @endcode
  1125. *
  1126. * Get content reports
  1127. * @param $iContentId content ID
  1128. *
  1129. * @see BxBaseModGeneralModule::serviceEntityReports
  1130. */
  1131. /**
  1132. * @ref bx_base_general-entity_reports "entity_reports"
  1133. */
  1134. public function serviceEntityReports ($iContentId = 0)
  1135. {
  1136. $mixedContent = $this->_getContent($iContentId);
  1137. list($iContentId, $aContentInfo) = $mixedContent;
  1138. if($iContentId === false)
  1139. return false;
  1140. $CNF = &$this->_oConfig->CNF;
  1141. if (!isset($CNF['OBJECT_REPORTS']) || !isset($CNF['OBJECT_NOTES']))
  1142. return false;
  1143. if(!(BxDolAcl::getInstance()->isMemberLevelInSet(192) || bx_get_logged_profile_id() == $aContentInfo[$CNF['FIELD_AUTHOR']]))
  1144. return false;
  1145. $oReport = BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], $iContentId, true);
  1146. return $oReport->getReportedByWithComments($CNF['OBJECT_NOTES']);
  1147. }
  1148. /**
  1149. * @page service Service Calls
  1150. * @section bx_base_general Base General
  1151. * @subsection bx_base_general-menu Menu
  1152. * @subsubsection bx_base_general-entity_social_sharing entity_social_sharing
  1153. *
  1154. * @code bx_srv('bx_posts', 'entity_social_sharing', [...]); @endcode
  1155. *
  1156. * Entry social sharing actions
  1157. * @param $mixedContent content ID or array with integer content ID and
  1158. * array with content info, or false
  1159. * @param $aParams array with additional custom params
  1160. * which may overwrite some default values
  1161. *
  1162. * @see BxBaseModGeneralModule::serviceEntitySocialSharing
  1163. */
  1164. /**
  1165. * @ref bx_base_general-entity_social_sharing "entity_social_sharing"
  1166. */
  1167. public function serviceEntitySocialSharing($mixedContent = false, $aParams = array())
  1168. {
  1169. if(!empty($mixedContent)) {
  1170. if(!is_array($mixedContent))
  1171. $mixedContent = array((int)$mixedContent, array());
  1172. }
  1173. else {
  1174. $mixedContent = $this->_getContent();
  1175. if($mixedContent === false)
  1176. return false;
  1177. }
  1178. list($iContentId, $aContentInfo) = $mixedContent;
  1179. $CNF = &$this->_oConfig->CNF;
  1180. $sUri = !empty($aParams['uri']) ? $aParams['uri'] : '';
  1181. if(empty($sUri) && !empty($CNF['URI_VIEW_ENTRY']))
  1182. $sUri = $CNF['URI_VIEW_ENTRY'];
  1183. $sUrl = !empty($sUri) ? BxDolPermalinks::getInstance()->permalink('page.php?i=' . $sUri . '&id=' . $iContentId) : '';
  1184. $sTitle = !empty($aParams['title']) ? $aParams['title'] : '';
  1185. if(empty($sTitle) && !empty($aContentInfo[$CNF['FIELD_TITLE']]))
  1186. $sTitle = $aContentInfo[$CNF['FIELD_TITLE']];
  1187. $aMarkers = array(
  1188. 'id' => $iContentId,
  1189. 'module' => $this->_aModule['name'],
  1190. 'url' => BX_DOL_URL_ROOT . $sUrl,
  1191. 'title' => $sTitle,
  1192. );
  1193. $iIdThumb = !empty($aParams['id_thumb']) ? (int)$aParams['id_thumb'] : 0;
  1194. if(empty($iIdThumb) && !empty($CNF['FIELD_THUMB']) && !empty($aContentInfo[$CNF['FIELD_THUMB']]))
  1195. $iIdThumb = (int)$aContentInfo[$CNF['FIELD_THUMB']];
  1196. if ($iIdThumb) {
  1197. $sTranscoder = !empty($aParams['object_transcoder']) ? $aParams['object_transcoder'] : '';
  1198. $sStorage = !empty($aParams['object_storage']) ? $aParams['object_storage'] : '';
  1199. if(empty($sStorage) && !empty($CNF['OBJECT_STORAGE']))
  1200. $sStorage = $CNF['OBJECT_STORAGE'];
  1201. if(!empty($sTranscoder))
  1202. $o = BxDolTranscoder::getObjectInstance($sTranscoder);
  1203. else if(!empty($sStorage))
  1204. $o = BxDolStorage::getObjectInstance($sStorage);
  1205. $sImgUrl = $o ? $o->getFileUrlById($iIdThumb) : '';
  1206. if($sImgUrl)
  1207. $aMarkers['img_url'] = $sImgUrl;
  1208. }
  1209. $oMenu = BxDolMenu::getObjectInstance('sys_social_sharing');
  1210. $oMenu->addMarkers($aMarkers);
  1211. $sMenu = $oMenu->getCode();
  1212. if(empty($sMenu))
  1213. return '';
  1214. return $this->_oTemplate->parseHtmlByName('entry-share.html', array(
  1215. 'menu' => $sMenu
  1216. ));
  1217. }
  1218. /**
  1219. * Entry context block
  1220. */
  1221. public function serviceEntityContext ($iContentId = 0)
  1222. {
  1223. return $this->_serviceTemplateFunc ('entryContext', $iContentId);
  1224. }
  1225. /**
  1226. * Blocks for lables tree browsing
  1227. */
  1228. public function serviceGetLablesTree()
  1229. {
  1230. $aBreadcrumbs = array();
  1231. $this->_getLablesBreadcrumbsArray(bx_get('label'), $aBreadcrumbs);
  1232. return $this->_getLablesTreeLevel($aBreadcrumbs);
  1233. }
  1234. public function serviceGetLablesBreadcrumbs()
  1235. {
  1236. if (bx_get('label')){
  1237. $aBreadcrumbs = array();
  1238. $this->_getLablesBreadcrumbsArray(bx_process_input(bx_get('label'), BX_DATA_INT), $aBreadcrumbs);
  1239. $aLabels = array();
  1240. foreach (array_reverse($aBreadcrumbs) as $aLabel){
  1241. $aLabels[] = array(
  1242. 'value' => $aLabel['value'],
  1243. 'url' => $this->_getLablesBrowseUrl($aLabel['id'])
  1244. );
  1245. }
  1246. return $this->_oTemplate->parseHtmlByName('labels_breadcrumbs.html', array('bx_repeat:items' => $aLabels));
  1247. }
  1248. return '';
  1249. }
  1250. public function serviceBrowseByLabel()
  1251. {
  1252. $CNF = &$this->_oConfig->CNF;
  1253. if (empty($CNF['OBJECT_METATAGS']))
  1254. return '';
  1255. $sMode = 'recent';
  1256. $sClassSearchResult ='SearchResult';
  1257. bx_import($sClassSearchResult, $this->_aModule['name']);
  1258. $sClass = $this->_aModule['class_prefix'] . $sClassSearchResult;
  1259. $o = new $sClass($sMode, false);
  1260. $o->setDesignBoxTemplateId(BX_DB_PADDING_DEF);
  1261. $o->setDisplayEmptyMsg(true);
  1262. $o->setAjaxPaginate(false);
  1263. $o->setUnitParams(array('context' => $sMode));
  1264. if (bx_get('label')){
  1265. $iLabelId = (int)bx_get('label');
  1266. $oLabel = BxDolLabel::getInstance();
  1267. $aLabel = $oLabel->getLabels(array('type' => 'id', 'id' => $iLabelId));
  1268. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  1269. $sTmp =$oMetatags->keywordsSetSearchCondition($o, $aLabel['value']);
  1270. }
  1271. if ($o->isError)
  1272. return '';
  1273. if ($s = $o->processing())
  1274. return $s;
  1275. else
  1276. return '';
  1277. }
  1278. public function serviceBrowseByCategories($sUnitView, $bEmptyMessage, $bAjaxPaginate, $sMode, $iPerPage)
  1279. {
  1280. $CNF = &$this->_oConfig->CNF;
  1281. $sClassSearchResult ='SearchResult';
  1282. bx_import($sClassSearchResult, $this->_aModule['name']);
  1283. $sClass = $this->_aModule['class_prefix'] . $sClassSearchResult;
  1284. $o = new $sClass($sMode, array('unit_view' => $sUnitView, 'paginate' => array('perPage' => 10, 'start' => 0, 'num' => 11)));
  1285. $o->setDesignBoxTemplateId(BX_DB_PADDING_DEF);
  1286. $o->setAjaxPaginate($bAjaxPaginate);
  1287. $o->setCategoryObject('multi');
  1288. $aCategoriesOutput = array();
  1289. $aCategories = BxDolCategories::getInstance()->getData(array('type' => 'by_module_with_num', 'module' => $this->_aModule['name']));
  1290. foreach($aCategories as $aCategory){
  1291. if ($aCategory['num'] > 0){
  1292. $o->setCustomSearchCondition(array('keyword' => $aCategory['value']));
  1293. $o->setPaginatePerPage(2);
  1294. if (!$o->isError){
  1295. $aResult = $o->processing();
  1296. if ($aResult && $aResult['content'] != '')
  1297. $aCategoriesOutput[] = array('name' => _t($aCategory['value']), 'url' => '', 'content' => $aResult['content']);
  1298. }
  1299. }
  1300. }
  1301. return $this->_oTemplate->parseHtmlByName('browse_by_categories.html', array(
  1302. 'bx_repeat:categories' => $aCategoriesOutput,
  1303. ));
  1304. }
  1305. /**
  1306. * Data for Notifications module
  1307. */
  1308. public function serviceGetNotificationsData()
  1309. {
  1310. $sModule = $this->_aModule['name'];
  1311. $sEventPrivacy = $sModule . '_allow_view_event_to';
  1312. if(BxDolPrivacy::getObjectInstance($sEventPrivacy) === false)
  1313. $sEventPrivacy = '';
  1314. $aResult = array(
  1315. 'handlers' => array(
  1316. array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added', 'module_name' => $sModule, 'module_method' => 'get_notifications_post', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  1317. array('group' => $sModule . '_object', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'edited'),
  1318. array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'deleted'),
  1319. array('group' => $sModule . '_comment', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'commentPost', 'module_name' => $sModule, 'module_method' => 'get_notifications_comment', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  1320. array('group' => $sModule . '_comment', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'commentRemoved'),
  1321. array('group' => $sModule . '_reply', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'replyPost', 'module_name' => $sModule, 'module_method' => 'get_notifications_reply', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  1322. array('group' => $sModule . '_reply', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'replyRemoved'),
  1323. array('group' => $sModule . '_vote', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_vote', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  1324. array('group' => $sModule . '_vote', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'undoVote'),
  1325. array('group' => $sModule . '_reaction', 'type' => 'insert', 'alert_unit' => $sModule . '_reactions', 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_reaction', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  1326. array('group' => $sModule . '_reaction', 'type' => 'delete', 'alert_unit' => $sModule . '_reactions', 'alert_action' => 'undoVote'),
  1327. array('group' => $sModule . '_score_up', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVoteUp', 'module_name' => $sModule, 'module_method' => 'get_notifications_score_up', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  1328. array('group' => $sModule . '_score_down', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVoteDown', 'module_name' => $sModule, 'module_method' => 'get_notifications_score_down', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  1329. ),
  1330. 'settings' => array(
  1331. array('group' => 'content', 'unit' => $sModule, 'action' => 'added', 'types' => array('follow_member', 'follow_context')),
  1332. array('group' => 'comment', 'unit' => $sModule, 'action' => 'commentPost', 'types' => array('personal', 'follow_member', 'follow_context')),
  1333. array('group' => 'reply', 'unit' => $sModule, 'action' => 'replyPost', 'types' => array('personal')),
  1334. array('group' => 'vote', 'unit' => $sModule, 'action' => 'doVote', 'types' => array('personal', 'follow_member', 'follow_context')),
  1335. array('group' => 'vote', 'unit' => $sModule . '_reactions', 'action' => 'doVote', 'types' => array('personal', 'follow_member', 'follow_context')),
  1336. array('group' => 'score_up', 'unit' => $sModule, 'action' => 'doVoteUp', 'types' => array('personal', 'follow_member', 'follow_context')),
  1337. array('group' => 'score_down', 'unit' => $sModule, 'action' => 'doVoteDown', 'types' => array('personal', 'follow_member', 'follow_context'))
  1338. ),
  1339. 'alerts' => array(
  1340. array('unit' => $sModule, 'action' => 'added'),
  1341. array('unit' => $sModule, 'action' => 'edited'),
  1342. array('unit' => $sModule, 'action' => 'deleted'),
  1343. array('unit' => $sModule, 'action' => 'commentPost'),
  1344. array('unit' => $sModule, 'action' => 'commentRemoved'),
  1345. array('unit' => $sModule, 'action' => 'replyPost'),
  1346. array('unit' => $sModule, 'action' => 'replyRemoved'),
  1347. array('unit' => $sModule, 'action' => 'doVote'),
  1348. array('unit' => $sModule, 'action' => 'undoVote'),
  1349. array('unit' => $sModule . '_reactions', 'action' => 'doVote'),
  1350. array('unit' => $sModule . '_reactions', 'action' => 'undoVote'),
  1351. array('unit' => $sModule, 'action' => 'doVoteUp'),
  1352. array('unit' => $sModule, 'action' => 'doVoteDown'),
  1353. )
  1354. );
  1355. if(!empty($this->_oConfig->CNF['FIELDS_DELAYED_PROCESSING'])) {
  1356. $aResult['handlers'] = array_merge($aResult['handlers'], array(
  1357. array('group' => $sModule . '_object_publish_failed', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'publish_failed', 'module_name' => $sModule, 'module_method' => 'get_notifications_post_publish_failed', 'module_class' => 'Module', 'module_event_privacy' => ''),
  1358. array('group' => $sModule . '_object_publish_succeeded', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'publish_succeeded', 'module_name' => $sModule, 'module_method' => 'get_notifications_post_publish_succeeded', 'module_class' => 'Module', 'module_event_privacy' => ''),
  1359. ));
  1360. $aResult['settings'] = array_merge($aResult['settings'], array(
  1361. array('group' => 'content_publish_failed', 'unit' => $sModule, 'action' => 'publish_failed', 'types' => array('personal')),
  1362. array('group' => 'content_publish_succeeded', 'unit' => $sModule, 'action' => 'publish_succeeded', 'types' => array('personal')),
  1363. ));
  1364. $aResult['alerts'] = array_merge($aResult['alerts'], array(
  1365. array('unit' => $sModule, 'action' => 'publish_failed'),
  1366. array('unit' => $sModule, 'action' => 'publish_succeeded'),
  1367. ));
  1368. }
  1369. return $aResult;
  1370. }
  1371. /**
  1372. * Entry post for Notifications module
  1373. */
  1374. public function serviceGetNotificationsPost($aEvent)
  1375. {
  1376. $CNF = &$this->_oConfig->CNF;
  1377. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  1378. if(empty($aContentInfo) || !is_array($aContentInfo))
  1379. return array();
  1380. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  1381. $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
  1382. return array(
  1383. 'entry_sample' => $CNF['T']['txt_sample_single'],
  1384. 'entry_url' => $sEntryUrl,
  1385. 'entry_caption' => $sEntryCaption,
  1386. 'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
  1387. 'entry_privacy' => '', //may be empty or not specified. In this case Public privacy will be used.
  1388. 'lang_key' => '', //may be empty or not specified, or a string, or an array('site' => '...', 'email' => '...', 'push' => '...'). In this case of empty/not specified the default one from Notification module will be used.
  1389. /*
  1390. * Custom settings for email and/or push notifications can be provided here.
  1391. * Only necessary parts of 'settings' array can be used.
  1392. *
  1393. 'settings' => array(
  1394. 'email' => array(
  1395. 'template' => '', //--- custom email template
  1396. 'markers' => '', //--- markers to parse email parts (subject, body) with
  1397. 'subject' => '' //--- custom email subject
  1398. ),
  1399. 'push' => array(
  1400. 'subject' => '' //--- custom push notification subject
  1401. )
  1402. )
  1403. */
  1404. );
  1405. }
  1406. public function serviceGetNotificationsPostPublishFailed($aEvent)
  1407. {
  1408. return $this->serviceGetNotificationsPost($aEvent);
  1409. }
  1410. public function serviceGetNotificationsPostPublishSucceeded($aEvent)
  1411. {
  1412. return $this->serviceGetNotificationsPost($aEvent);
  1413. }
  1414. /**
  1415. * Entry post comment for Notifications module
  1416. */
  1417. public function serviceGetNotificationsComment($aEvent)
  1418. {
  1419. $CNF = &$this->_oConfig->CNF;
  1420. $iContentId = (int)$aEvent['object_id'];
  1421. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  1422. if(empty($aContentInfo) || !is_array($aContentInfo))
  1423. return array();
  1424. $oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContentId);
  1425. if(!$oComment || !$oComment->isEnabled())
  1426. return array();
  1427. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  1428. $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
  1429. return array(
  1430. 'entry_sample' => $CNF['T']['txt_sample_single'],
  1431. 'entry_url' => $sEntryUrl,
  1432. 'entry_caption' => $sEntryCaption,
  1433. 'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
  1434. 'subentry_sample' => $CNF['T']['txt_sample_comment_single'],
  1435. 'subentry_url' => $oComment->getViewUrl((int)$aEvent['subobject_id']),
  1436. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  1437. );
  1438. }
  1439. /**
  1440. * Entry post reply for Notifications module
  1441. */
  1442. public function serviceGetNotificationsReply($aEvent)
  1443. {
  1444. $CNF = &$this->_oConfig->CNF;
  1445. $oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], 0, false);
  1446. if(!$oComment || !$oComment->isEnabled())
  1447. return array();
  1448. $iParentId = (int)$aEvent['object_id'];
  1449. $aParentInfo = $oComment->getQueryObject()->getCommentsBy(array('type' => 'id', 'id' => $iParentId));
  1450. if(empty($aParentInfo) || !is_array($aParentInfo))
  1451. return array();
  1452. $iObjectId = (int)$aParentInfo['cmt_object_id'];
  1453. $oComment->init($iObjectId);
  1454. return array(
  1455. 'object_id' => $iObjectId,
  1456. 'entry_sample' => '_cmt_txt_sample_comment_single',
  1457. 'entry_url' => $oComment->getViewUrl($iParentId),
  1458. 'entry_caption' => strmaxtextlen($aParentInfo['cmt_text'], 20, '...'),
  1459. 'entry_author' => (int)$aParentInfo['cmt_author_id'],
  1460. 'subentry_sample' => '_cmt_txt_sample_reply_to',
  1461. 'subentry_url' => $oComment->getViewUrl((int)$aEvent['subobject_id']),
  1462. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  1463. );
  1464. }
  1465. /**
  1466. * Entry post vote for Notifications module
  1467. */
  1468. public function serviceGetNotificationsVote($aEvent)
  1469. {
  1470. $CNF = &$this->_oConfig->CNF;
  1471. $iContentId = (int)$aEvent['object_id'];
  1472. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  1473. if(empty($aContentInfo) || !is_array($aContentInfo))
  1474. return array();
  1475. $oVote = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContentId);
  1476. if(!$oVote || !$oVote->isEnabled())
  1477. return array();
  1478. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  1479. $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
  1480. return array(
  1481. 'entry_sample' => $CNF['T']['txt_sample_single'],
  1482. 'entry_url' => $sEntryUrl,
  1483. 'entry_caption' => $sEntryCaption,
  1484. 'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
  1485. 'subentry_sample' => $CNF['T']['txt_sample_vote_single'],
  1486. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  1487. );
  1488. }
  1489. /**
  1490. * Entry post vote for Notifications module
  1491. */
  1492. public function serviceGetNotificationsReaction($aEvent)
  1493. {
  1494. $CNF = &$this->_oConfig->CNF;
  1495. $iContentId = (int)$aEvent['object_id'];
  1496. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  1497. if(empty($aContentInfo) || !is_array($aContentInfo))
  1498. return array();
  1499. $oReaction = BxDolVote::getObjectInstance($CNF['OBJECT_REACTIONS'], $iContentId);
  1500. if(!$oReaction || !$oReaction->isEnabled())
  1501. return array();
  1502. $aSubentry = $oReaction->getTrackBy(array('type' => 'id', 'id' => (int)$aEvent['subobject_id']));
  1503. if(empty($aSubentry) || !is_array($aSubentry))
  1504. return array();
  1505. $aSubentrySampleParams = array();
  1506. $aReaction = $oReaction->getReaction($aSubentry['reaction']);
  1507. if(!empty($aReaction['title']))
  1508. $aSubentrySampleParams[] = $aReaction['title'];
  1509. else
  1510. $aSubentrySampleParams[] = '_undefined';
  1511. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  1512. $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
  1513. return array(
  1514. 'entry_sample' => $CNF['T']['txt_sample_single'],
  1515. 'entry_url' => $sEntryUrl,
  1516. 'entry_caption' => $sEntryCaption,
  1517. 'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
  1518. 'subentry_sample' => $CNF['T']['txt_sample_reaction_single'],
  1519. 'subentry_sample_params' => $aSubentrySampleParams,
  1520. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  1521. );
  1522. }
  1523. /**
  1524. * Entry post score -> vote up for Notifications module
  1525. */
  1526. public function serviceGetNotificationsScoreUp($aEvent)
  1527. {
  1528. return $this->_serviceGetNotificationsScore('up', $aEvent);
  1529. }
  1530. /**
  1531. * Entry post score -> vote up for Notifications module
  1532. */
  1533. public function serviceGetNotificationsScoreDown($aEvent)
  1534. {
  1535. return $this->_serviceGetNotificationsScore('down', $aEvent);
  1536. }
  1537. protected function _serviceGetNotificationsScore($sType, $aEvent)
  1538. {
  1539. $CNF = &$this->_oConfig->CNF;
  1540. $iContentId = (int)$aEvent['object_id'];
  1541. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  1542. if(empty($aContentInfo) || !is_array($aContentInfo))
  1543. return array();
  1544. $oScore = BxDolScore::getObjectInstance($CNF['OBJECT_SCORES'], $iContentId);
  1545. if(!$oScore || !$oScore->isEnabled())
  1546. return array();
  1547. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  1548. $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
  1549. return array(
  1550. 'entry_sample' => $CNF['T']['txt_sample_single'],
  1551. 'entry_url' => $sEntryUrl,
  1552. 'entry_caption' => $sEntryCaption,
  1553. 'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
  1554. 'subentry_sample' => $CNF['T']['txt_sample_score_' . $sType . '_single'],
  1555. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  1556. );
  1557. }
  1558. /**
  1559. * Data for Timeline module
  1560. */
  1561. public function serviceGetTimelineData()
  1562. {
  1563. $sModule = $this->_aModule['name'];
  1564. return array(
  1565. 'handlers' => array(
  1566. array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added', 'module_name' => $sModule, 'module_method' => 'get_timeline_post', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
  1567. array('group' => $sModule . '_object', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'edited'),
  1568. array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'deleted')
  1569. ),
  1570. 'alerts' => array(
  1571. array('unit' => $sModule, 'action' => 'added'),
  1572. array('unit' => $sModule, 'action' => 'edited'),
  1573. array('unit' => $sModule, 'action' => 'deleted'),
  1574. )
  1575. );
  1576. }
  1577. /**
  1578. * Entry post for Timeline module
  1579. */
  1580. public function serviceGetTimelinePost($aEvent, $aBrowseParams = array())
  1581. {
  1582. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  1583. if(empty($aContentInfo) || !is_array($aContentInfo))
  1584. return false;
  1585. $CNF = &$this->_oConfig->CNF;
  1586. if((!empty($CNF['FIELD_STATUS']) && $aContentInfo[$CNF['FIELD_STATUS']] != 'active') || (!empty($CNF['FIELD_STATUS_ADMIN']) && $aContentInfo[$CNF['FIELD_STATUS_ADMIN']] != 'active'))
  1587. return false;
  1588. $iUserId = $this->getUserId();
  1589. $iAuthorId = (int)$aContentInfo[$CNF['FIELD_AUTHOR']];
  1590. $iAuthorIdAbs = abs($iAuthorId);
  1591. if($iAuthorId < 0 && ((is_numeric($aEvent['owner_id']) && $iAuthorIdAbs == (int)$aEvent['owner_id']) || (is_array($aEvent['owner_id']) && in_array($iAuthorIdAbs, $aEvent['owner_id']))) && $iAuthorIdAbs != $iUserId)
  1592. return false;
  1593. //--- Views
  1594. $oViews = isset($CNF['OBJECT_VIEWS']) ? BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $aContentInfo[$CNF['FIELD_ID']]) : null;
  1595. $aViews = array();
  1596. if ($oViews && $oViews->isEnabled())
  1597. $aViews = array(
  1598. 'system' => $CNF['OBJECT_VIEWS'],
  1599. 'object_id' => $aContentInfo[$CNF['FIELD_ID']],
  1600. 'count' => $aContentInfo['views']
  1601. );
  1602. //--- Votes
  1603. $oVotes = isset($CNF['OBJECT_VOTES']) ? BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aContentInfo[$CNF['FIELD_ID']]) : null;
  1604. $aVotes = array();
  1605. if ($oVotes && $oVotes->isEnabled())
  1606. $aVotes = array(
  1607. 'system' => $CNF['OBJECT_VOTES'],
  1608. 'object_id' => $aContentInfo[$CNF['FIELD_ID']],
  1609. 'count' => $aContentInfo['votes']
  1610. );
  1611. //--- Reactions
  1612. $oReactions = isset($CNF['OBJECT_REACTIONS']) ? BxDolVote::getObjectInstance($CNF['OBJECT_REACTIONS'], $aContentInfo[$CNF['FIELD_ID']]) : null;
  1613. $aReactions = array();
  1614. if ($oReactions && $oReactions->isEnabled())
  1615. $aReactions = array(
  1616. 'system' => $CNF['OBJECT_REACTIONS'],
  1617. 'object_id' => $aContentInfo[$CNF['FIELD_ID']],
  1618. 'count' => $aContentInfo['rvotes']
  1619. );
  1620. //--- Scores
  1621. $oScores = isset($CNF['OBJECT_SCORES']) ? BxDolScore::getObjectInstance($CNF['OBJECT_SCORES'], $aContentInfo[$CNF['FIELD_ID']]) : null;
  1622. $aScores = array();
  1623. if ($oScores && $oScores->isEnabled())
  1624. $aScores = array(
  1625. 'system' => $CNF['OBJECT_SCORES'],
  1626. 'object_id' => $aContentInfo[$CNF['FIELD_ID']],
  1627. 'score' => $aContentInfo['score']
  1628. );
  1629. //--- Reports
  1630. $oReports = isset($CNF['OBJECT_REPORTS']) ? BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], $aContentInfo[$CNF['FIELD_ID']]) : null;
  1631. $aReports = array();
  1632. if ($oReports && $oReports->isEnabled())
  1633. $aReports = array(
  1634. 'system' => $CNF['OBJECT_REPORTS'],
  1635. 'object_id' => $aContentInfo[$CNF['FIELD_ID']],
  1636. 'count' => $aContentInfo['reports']
  1637. );
  1638. //--- Comments
  1639. $oCmts = isset($CNF['OBJECT_COMMENTS']) ? BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $aContentInfo[$CNF['FIELD_ID']]) : null;
  1640. $aComments = array();
  1641. if($oCmts && $oCmts->isEnabled())
  1642. $aComments = array(
  1643. 'system' => $CNF['OBJECT_COMMENTS'],
  1644. 'object_id' => $aContentInfo[$CNF['FIELD_ID']],
  1645. 'count' => $aContentInfo['comments']
  1646. );
  1647. //--- Title & Description
  1648. $sTitle = !empty($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : '';
  1649. if(empty($sTitle) && !empty($aContentInfo[$CNF['FIELD_TEXT']]))
  1650. $sTitle = $aContentInfo[$CNF['FIELD_TEXT']];
  1651. $iOwnerId = $iAuthorIdAbs;
  1652. if(isset($aEvent['object_privacy_view']) && (int)$aEvent['object_privacy_view'] < 0)
  1653. $iOwnerId = abs($aEvent['object_privacy_view']);
  1654. $bCache = true;
  1655. $aContent = $this->_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams);
  1656. if(isset($aContent['_cache'])) {
  1657. $bCache = (bool)$aContent['_cache'];
  1658. unset($aContent['_cache']);
  1659. }
  1660. return array(
  1661. '_cache' => $bCache,
  1662. 'owner_id' => $iOwnerId,
  1663. 'object_owner_id' => $iAuthorId,
  1664. 'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
  1665. 'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
  1666. 'sample_wo_article' => $CNF['T']['txt_sample_single'],
  1667. 'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
  1668. 'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]),
  1669. 'content' => $aContent, //a string to display or array to parse default template before displaying.
  1670. 'date' => $aContentInfo[$CNF['FIELD_ADDED']],
  1671. 'views' => $aViews,
  1672. 'votes' => $aVotes,
  1673. 'reactions' => $aReactions,
  1674. 'scores' => $aScores,
  1675. 'reports' => $aReports,
  1676. 'comments' => $aComments,
  1677. 'title' => $sTitle, //may be empty.
  1678. 'description' => '' //may be empty.
  1679. );
  1680. }
  1681. public function serviceGetTimelinePostAllowedView($aEvent)
  1682. {
  1683. $iContentId = (int)$aEvent['object_id'];
  1684. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  1685. if(empty($aContentInfo) || !is_array($aContentInfo))
  1686. return _t('_sys_txt_access_denied');
  1687. return $this->serviceCheckAllowedViewForProfile($aContentInfo);
  1688. }
  1689. /**
  1690. * Check particular action permission without content
  1691. * @param $sAction action to check, for example: Browse, Add
  1692. * @param $iContentId content ID
  1693. * @return message on error, or CHECK_ACTION_RESULT_ALLOWED when allowed
  1694. */
  1695. public function serviceCheckAllowed($sAction, $isPerformAction = false)
  1696. {
  1697. $sMethod = 'checkAllowed' . bx_gen_method_name($sAction);
  1698. if (!method_exists($this, $sMethod))
  1699. return _t('_sys_request_method_not_found_cpt');
  1700. return $this->$sMethod($isPerformAction);
  1701. }
  1702. /**
  1703. * Check particular action permission with content
  1704. * @param $sAction action to check, for example: View, Edit
  1705. * @param $iContentId content ID
  1706. * @return message on error, or CHECK_ACTION_RESULT_ALLOWED when allowed
  1707. */
  1708. public function serviceCheckAllowedWithContent($sAction, $iContentId, $isPerformAction = false)
  1709. {
  1710. if (!$iContentId || !($aContentInfo = $this->_oDb->getContentInfoById($iContentId)))
  1711. return _t('_sys_request_page_not_found_cpt');
  1712. $sMethod = 'checkAllowed' . bx_gen_method_name($sAction);
  1713. if (!method_exists($this, $sMethod))
  1714. return _t('_sys_request_method_not_found_cpt');
  1715. return $this->$sMethod($aContentInfo, $isPerformAction);
  1716. }
  1717. /**
  1718. * Check particular action permission with content for specified profile
  1719. * @param $sAction action to check, for example: View, Edit
  1720. * @param $iContentId content ID
  1721. * @param $iProfileId profile ID which the permissions to be cheked for
  1722. * @return message on error, or CHECK_ACTION_RESULT_ALLOWED when allowed
  1723. */
  1724. public function serviceCheckAllowedWithContentForProfile($sAction, $iContentId, $iProfileId, $isPerformAction = false)
  1725. {
  1726. if (!$iContentId || !($aContentInfo = $this->_oDb->getContentInfoById($iContentId)))
  1727. return _t('_sys_request_page_not_found_cpt');
  1728. $sMethod = 'checkAllowed' . bx_gen_method_name($sAction) . 'ForProfile';
  1729. if (!method_exists($this, $sMethod))
  1730. return _t('_sys_request_method_not_found_cpt');
  1731. return $this->$sMethod($aContentInfo, $iProfileId, $isPerformAction);
  1732. }
  1733. public function serviceCheckAllowedCommentsView($iContentId, $sObjectComments)
  1734. {
  1735. //negative id used in comments for reports
  1736. if ($iContentId < 0)
  1737. return CHECK_ACTION_RESULT_ALLOWED;
  1738. return $this->serviceCheckAllowedWithContent('comments_view', $iContentId);
  1739. }
  1740. public function serviceCheckAllowedCommentsPost($iContentId, $sObjectComments)
  1741. {
  1742. //negative id used in comments for reports
  1743. if ($iContentId < 0)
  1744. return CHECK_ACTION_RESULT_ALLOWED;
  1745. return $this->serviceCheckAllowedWithContent('comments_post', $iContentId);
  1746. }
  1747. public function serviceGetContentOwnerProfileId ($iContentId)
  1748. {
  1749. $CNF = &$this->_oConfig->CNF;
  1750. // file owner must be author of the content or profile itself in case of profile based module
  1751. if ($iContentId) {
  1752. $sModule = $this->getName();
  1753. if ($this instanceof iBxDolProfileService && BxDolService::call($sModule, 'act_as_profile')) {
  1754. $oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $sModule);
  1755. }
  1756. else {
  1757. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  1758. $oProfile = $aContentInfo ? BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_AUTHOR']]) : null;
  1759. }
  1760. $iProfileId = $oProfile ? $oProfile->id() : bx_get_logged_profile_id();
  1761. }
  1762. else {
  1763. $iProfileId = bx_get_logged_profile_id();
  1764. }
  1765. return $iProfileId;
  1766. }
  1767. public function serviceGetBadges($iContentId, $bIsSingle = false, $bIsCompact = false)
  1768. {
  1769. $sModule = $this->getName();
  1770. $oBadges = BxDolBadges::getInstance();
  1771. $aBadges = $oBadges->getData(array(
  1772. 'type' => ($bIsSingle ? 'by_module&object2_single' : 'by_module&object2'),
  1773. 'module' => $sModule,
  1774. 'object_id' => $iContentId
  1775. ));
  1776. $sResult = false;
  1777. bx_alert('system', 'get_badges', 0, 0, array(
  1778. 'module' => $sModule,
  1779. 'content_id' => $iContentId,
  1780. 'is_single' => $bIsSingle,
  1781. 'is_compact' => $bIsCompact,
  1782. 'badges' => $aBadges,
  1783. 'override_result' => &$sResult
  1784. ));
  1785. if($sResult !== false)
  1786. return $sResult;
  1787. if($bIsSingle && count($aBadges) > 0)
  1788. return BxDolService::call('system', 'get_badge', array($aBadges[0], $bIsCompact), 'TemplServices');
  1789. $aBadgesOutput = array();
  1790. foreach($aBadges as $aBadge)
  1791. $aBadgesOutput[] = array('badge' => BxDolService::call('system', 'get_badge', array($aBadge, $bIsCompact), 'TemplServices'));
  1792. return $this->_oTemplate->parseHtmlByName('badges.html', array(
  1793. 'bx_repeat:items' => $aBadgesOutput,
  1794. ));
  1795. }
  1796. /**
  1797. * @page service Service Calls
  1798. * @section bx_base_general Base Text
  1799. * @subsection bx_base_general-page_blocks Page Blocks
  1800. * @subsubsection bx_base_general-categories_multi_list categories_multi_list
  1801. *
  1802. * @code bx_srv('bx_posts', 'categories_multi_list', [...]); @endcode
  1803. *
  1804. * Display multi-categorories block with number of posts in each category
  1805. * @param $bDisplayEmptyCats display empty categories
  1806. *
  1807. * @see BxBaseModGeneralModule::serviceCategoriesMultiList
  1808. */
  1809. /**
  1810. * @ref bx_base_general-categories_multi_list "categories_multi_list"
  1811. */
  1812. public function serviceCategoriesMultiList($bDisplayEmptyCats = true)
  1813. {
  1814. $oCategories = BxDolCategories::getInstance();
  1815. $aCats = $oCategories->getData(array('type' => 'by_module_with_num', 'module' => $this->getName()));
  1816. $aVars = array('bx_repeat:cats' => array());
  1817. foreach ($aCats as $oCat) {
  1818. $sValue = $oCat['value'];
  1819. $iNum = $oCat['num'];
  1820. $aVars['bx_repeat:cats'][] = array(
  1821. 'url' => $oCategories->getUrl($this->getName(), $sValue),
  1822. 'name' => _t($sValue),
  1823. 'value' => $sValue,
  1824. 'num' => $iNum,
  1825. );
  1826. }
  1827. if (!$aVars['bx_repeat:cats'])
  1828. return '';
  1829. return $this->_oTemplate->parseHtmlByName('category_list.html', $aVars);
  1830. }
  1831. /**
  1832. * ======
  1833. * PERMISSION METHODS
  1834. * ======
  1835. */
  1836. public function serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
  1837. {
  1838. $mixedResult = $this->_serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction, $iProfileId);
  1839. // check alert to allow custom checks
  1840. bx_alert('system', 'check_allowed_view', 0, 0, array('module' => $this->getName(), 'content_info' => $aDataEntry, 'profile_id' => $iProfileId, 'override_result' => &$mixedResult));
  1841. return $mixedResult;
  1842. }
  1843. public function checkAllowedSetThumb ($iContentId = 0)
  1844. {
  1845. return CHECK_ACTION_RESULT_ALLOWED;
  1846. }
  1847. /**
  1848. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make "true === " checking.
  1849. */
  1850. public function checkAllowedBrowse ()
  1851. {
  1852. // check alert to allow custom checks
  1853. $mixedResult = null;
  1854. bx_alert('system', 'check_allowed_browse', 0, 0, array('module' => $this->getName(), 'profile_id' => $this->_iProfileId, 'override_result' => &$mixedResult));
  1855. if($mixedResult !== null)
  1856. return $mixedResult;
  1857. return CHECK_ACTION_RESULT_ALLOWED;
  1858. }
  1859. /**
  1860. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1861. */
  1862. public function checkAllowedView ($aDataEntry, $isPerformAction = false)
  1863. {
  1864. return $this->serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction);
  1865. }
  1866. /**
  1867. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1868. */
  1869. public function checkAllowedViewForProfile ($aDataEntry, $iProfileId, $isPerformAction = false)
  1870. {
  1871. return $this->serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction, $iProfileId);
  1872. }
  1873. /**
  1874. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1875. */
  1876. public function checkAllowedAdd ($isPerformAction = false)
  1877. {
  1878. // check ACL
  1879. $aCheck = checkActionModule($this->_iProfileId, 'create entry', $this->getName(), $isPerformAction);
  1880. if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  1881. return $aCheck[CHECK_ACTION_MESSAGE];
  1882. return CHECK_ACTION_RESULT_ALLOWED;
  1883. }
  1884. /**
  1885. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1886. */
  1887. public function checkAllowedEdit ($aDataEntry, $isPerformAction = false)
  1888. {
  1889. // moderator and owner always have access
  1890. if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || -$aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction))
  1891. return CHECK_ACTION_RESULT_ALLOWED;
  1892. // check for context's admins
  1893. if (!empty($this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']) && (int)$aDataEntry[$this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']] < 0) {
  1894. $oProfile = BxDolProfile::getInstance(-(int)$aDataEntry[$this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']]);
  1895. if ($oProfile){
  1896. $sModule = $oProfile->getModule();
  1897. $aEntity = BxDolRequest::serviceExists($sModule, 'get_all') ? BxDolService::call($sModule, 'get_all', array(array('type' => 'id', 'id' => $oProfile->getContentId()))) : array();
  1898. $oModule = BxDolModule::getInstance($sModule);
  1899. if(isset($aEntity) && $oModule->checkAllowedEdit($aEntity) === CHECK_ACTION_RESULT_ALLOWED){
  1900. return CHECK_ACTION_RESULT_ALLOWED;
  1901. }
  1902. }
  1903. }
  1904. return _t('_sys_txt_access_denied');
  1905. }
  1906. /**
  1907. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1908. */
  1909. public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false)
  1910. {
  1911. // moderator always has access
  1912. if ($this->_isAdministrator($isPerformAction))
  1913. return CHECK_ACTION_RESULT_ALLOWED;
  1914. // check ACL
  1915. $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
  1916. if (($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || -$aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId) && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  1917. return CHECK_ACTION_RESULT_ALLOWED;
  1918. // check for context's admins
  1919. if (isset($this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']) && (int)$aDataEntry[$this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']] < 0){
  1920. $oProfile = BxDolProfile::getInstance(-(int)$aDataEntry[$this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']]);
  1921. if ($oProfile){
  1922. $sModule = $oProfile->getModule();
  1923. $aEntity = BxDolRequest::serviceExists($sModule, 'get_all') ? BxDolService::call($sModule, 'get_all', array(array('type' => 'id', 'id' => $oProfile->getContentId()))) : array();
  1924. $oModule = BxDolModule::getInstance($sModule);
  1925. if(isset($aEntity) && $oModule->checkAllowedDelete($aEntity) === CHECK_ACTION_RESULT_ALLOWED){
  1926. return CHECK_ACTION_RESULT_ALLOWED;
  1927. }
  1928. }
  1929. }
  1930. return _t('_sys_txt_access_denied');
  1931. }
  1932. /**
  1933. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1934. */
  1935. public function checkAllowedSetMembership (&$aDataEntry, $isPerformAction = false)
  1936. {
  1937. // admin always has access
  1938. if (isAdmin())
  1939. return CHECK_ACTION_RESULT_ALLOWED;
  1940. // check ACL
  1941. $aCheck = checkActionModule($this->_iProfileId, 'set acl level', 'system', $isPerformAction);
  1942. if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  1943. return $aCheck[CHECK_ACTION_MESSAGE];
  1944. return CHECK_ACTION_RESULT_ALLOWED;
  1945. }
  1946. /**
  1947. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1948. */
  1949. public function checkAllowedEditAnyEntry ($isPerformAction = false)
  1950. {
  1951. return $this->checkAllowedEditAnyEntryForProfile($isPerformAction, $this->_iProfileId);
  1952. }
  1953. /**
  1954. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1955. */
  1956. public function checkAllowedDeleteAnyEntry ($isPerformAction = false)
  1957. {
  1958. return $this->checkAllowedDeleteAnyEntryForProfile($isPerformAction, $this->_iProfileId);
  1959. }
  1960. /**
  1961. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1962. */
  1963. public function checkAllowedEditAnyEntryForProfile ($isPerformAction = false, $iProfileId = false)
  1964. {
  1965. if(!$iProfileId)
  1966. $iProfileId = $this->_iProfileId;
  1967. $aCheck = checkActionModule($iProfileId, 'edit any entry', $this->getName(), $isPerformAction);
  1968. if($aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  1969. return CHECK_ACTION_RESULT_ALLOWED;
  1970. return _t('_sys_txt_access_denied');
  1971. }
  1972. /**
  1973. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1974. */
  1975. public function checkAllowedDeleteAnyEntryForProfile ($isPerformAction = false, $iProfileId = false)
  1976. {
  1977. if(!$iProfileId)
  1978. $iProfileId = $this->_iProfileId;
  1979. $aCheck = checkActionModule($iProfileId, 'delete any entry', $this->getName(), $isPerformAction);
  1980. if($aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  1981. return CHECK_ACTION_RESULT_ALLOWED;
  1982. return _t('_sys_txt_access_denied');
  1983. }
  1984. /**
  1985. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make "true === " checking.
  1986. */
  1987. public function checkAllowedCommentsView ($aContentInfo, $isPerformAction = false)
  1988. {
  1989. return $this->checkAllowedView ($aContentInfo, $isPerformAction);
  1990. }
  1991. /**
  1992. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make "true === " checking.
  1993. */
  1994. public function checkAllowedCommentsPost ($aContentInfo, $isPerformAction = false)
  1995. {
  1996. return $this->checkAllowedView ($aContentInfo, $isPerformAction);
  1997. }
  1998. protected function _serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction, $iProfileId)
  1999. {
  2000. $CNF = &$this->_oConfig->CNF;
  2001. if(!$iProfileId)
  2002. $iProfileId = $this->_iProfileId;
  2003. if(empty($aDataEntry) || !is_array($aDataEntry))
  2004. return _t('_sys_txt_not_found');
  2005. // moderator and owner always have access
  2006. if(!empty($iProfileId) && (abs($aDataEntry[$CNF['FIELD_AUTHOR']]) == (int)$iProfileId || $this->_isModeratorForProfile($isPerformAction, $iProfileId)))
  2007. return CHECK_ACTION_RESULT_ALLOWED;
  2008. // check ACL
  2009. $aCheck = checkActionModule($iProfileId, 'view entry', $this->getName(), $isPerformAction);
  2010. if($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  2011. return $aCheck[CHECK_ACTION_MESSAGE];
  2012. // check privacy
  2013. if(!empty($CNF['OBJECT_PRIVACY_VIEW'])) {
  2014. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  2015. if ($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']], $iProfileId))
  2016. return _t('_sys_access_denied_to_private_content');
  2017. }
  2018. return CHECK_ACTION_RESULT_ALLOWED;
  2019. }
  2020. public function _serviceBrowse ($sMode, $aParams = false, $iDesignBox = BX_DB_PADDING_DEF, $bDisplayEmptyMsg = false, $bAjaxPaginate = true, $sClassSearchResult = 'SearchResult')
  2021. {
  2022. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse()))
  2023. return MsgBox($sMsg);
  2024. bx_import($sClassSearchResult, $this->_aModule);
  2025. $sClass = $this->_aModule['class_prefix'] . $sClassSearchResult;
  2026. $o = new $sClass($sMode, $aParams);
  2027. $o->setDesignBoxTemplateId($iDesignBox);
  2028. $o->setDisplayEmptyMsg($bDisplayEmptyMsg);
  2029. $o->setAjaxPaginate($bAjaxPaginate);
  2030. $o->setUnitParams(array('context' => $sMode));
  2031. if (isset($aParams['condition']) && is_array($aParams['condition']))
  2032. $o->setCustomCurrentCondition($aParams['condition']);
  2033. if ($o->isError)
  2034. return '';
  2035. if ($s = $o->processing())
  2036. return $s;
  2037. else
  2038. return '';
  2039. }
  2040. protected function _serviceBrowseQuick($aProfiles, $iStart = 0, $iLimit = 4, $aAdditionalParams = array())
  2041. {
  2042. // get paginate object
  2043. $oPaginate = new BxTemplPaginate(array(
  2044. 'on_change_page' => "return !loadDynamicBlockAutoPaginate(this, '{start}', '{per_page}', " . bx_js_string(json_encode($aAdditionalParams)) . ");",
  2045. 'num' => count($aProfiles),
  2046. 'per_page' => $iLimit,
  2047. 'start' => $iStart,
  2048. ));
  2049. // remove last item from connection array, because we've got one more item for pagination calculations only
  2050. if (count($aProfiles) > $iLimit)
  2051. array_pop($aProfiles);
  2052. // get profiles HTML
  2053. $s = '';
  2054. foreach ($aProfiles as $mixedProfile) {
  2055. $bProfile = is_array($mixedProfile);
  2056. $oProfile = BxDolProfile::getInstance($bProfile ? (int)$mixedProfile['id'] : (int)$mixedProfile);
  2057. if(!$oProfile)
  2058. continue;
  2059. $aUnitParams = array('template' => array('name' => 'unit', 'size' => 'thumb'));
  2060. if(BxDolModule::getInstance($oProfile->getModule()) instanceof BxBaseModGroupsModule)
  2061. $aUnitParams['template']['name'] = 'unit_wo_cover';
  2062. if($bProfile && is_array($mixedProfile['info']))
  2063. $aUnitParams['template']['vars'] = $mixedProfile['info'];
  2064. $s .= $oProfile->getUnit(0, $aUnitParams);
  2065. }
  2066. // return profiles + paginate
  2067. return $s . (!$iStart && $oPaginate->getNum() <= $iLimit ? '' : $oPaginate->getSimplePaginate());
  2068. }
  2069. // ====== COMMON METHODS
  2070. public function alertAfterAdd($aContentInfo) {}
  2071. public function alertAfterEdit($aContentInfo) {}
  2072. public function onPublished($iContentId) {}
  2073. public function onFailed($iContentId) {}
  2074. public function processMetasAdd($iContentId)
  2075. {
  2076. $CNF = &$this->_oConfig->CNF;
  2077. if(empty($CNF['OBJECT_METATAGS']))
  2078. return false;
  2079. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  2080. $bFldStatus = isset($CNF['FIELD_STATUS']);
  2081. $bFldStatusAdmin = isset($CNF['FIELD_STATUS_ADMIN']);
  2082. $bContentInfo = $aContentInfo && (!$bFldStatus || ($bFldStatus && $aContentInfo[$CNF['FIELD_STATUS']] == 'active')) && (!$bFldStatusAdmin || ($bFldStatusAdmin && $aContentInfo[$CNF['FIELD_STATUS_ADMIN']] == 'active'));
  2083. if(!$bContentInfo)
  2084. return false;
  2085. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  2086. $oMetatags->metaAddAuto($iContentId, $aContentInfo, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']);
  2087. $sKey = 'FIELD_LOCATION';
  2088. if($oMetatags->locationsIsEnabled() && !empty($CNF[$sKey]) && !empty($aContentInfo[$CNF[$sKey]])) {
  2089. $aLocation = unserialize($aContentInfo[$CNF[$sKey]]);
  2090. if(!empty($aLocation) && is_array($aLocation))
  2091. call_user_func_array(array($oMetatags, 'locationsAdd'), array_merge(array($iContentId), array_values($aLocation)));
  2092. }
  2093. $sKey = 'FIELD_LABELS';
  2094. if($oMetatags->keywordsIsEnabled() && !empty($CNF[$sKey]) && !empty($aContentInfo[$CNF[$sKey]])) {
  2095. $aLabels = unserialize($aContentInfo[$CNF[$sKey]]);
  2096. if(!empty($aLabels) && is_array($aLabels))
  2097. foreach ($aLabels as $sLabel)
  2098. $oMetatags->keywordsAddOne($iContentId, $sLabel, false);
  2099. }
  2100. return true;
  2101. }
  2102. public function processMetasEdit($iContentId, $oForm)
  2103. {
  2104. $CNF = &$this->_oConfig->CNF;
  2105. if(empty($CNF['OBJECT_METATAGS']))
  2106. return false;
  2107. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  2108. $bFldStatus = isset($CNF['FIELD_STATUS']);
  2109. $bFldStatusAdmin = isset($CNF['FIELD_STATUS_ADMIN']);
  2110. $bContentInfo = $aContentInfo && (!$bFldStatus || ($bFldStatus && $aContentInfo[$CNF['FIELD_STATUS']] == 'active')) && (!$bFldStatusAdmin || ($bFldStatusAdmin && $aContentInfo[$CNF['FIELD_STATUS_ADMIN']] == 'active'));
  2111. if(!$bContentInfo)
  2112. return false;
  2113. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  2114. $oMetatags->metaAddAuto($iContentId, $aContentInfo, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT']);
  2115. $sKey = 'FIELD_LOCATION';
  2116. if($oMetatags->locationsIsEnabled() && !empty($CNF[$sKey]) && !empty($aContentInfo[$CNF[$sKey]])) {
  2117. $aLocation = unserialize($aContentInfo[$CNF[$sKey]]);
  2118. if(!empty($aLocation) && is_array($aLocation))
  2119. call_user_func_array(array($oMetatags, 'locationsAdd'), array_merge(array($iContentId), array_values($aLocation)));
  2120. }
  2121. $sKey = 'FIELD_LABELS';
  2122. if($oMetatags->keywordsIsEnabled() && !empty($CNF[$sKey]) && !empty($aContentInfo[$CNF[$sKey]])) {
  2123. $aLabels = unserialize($aContentInfo[$CNF[$sKey]]);
  2124. if(!empty($aLabels) && is_array($aLabels))
  2125. foreach ($aLabels as $sLabel)
  2126. $oMetatags->keywordsAddOne($iContentId, $sLabel, false);
  2127. }
  2128. return true;
  2129. }
  2130. public function getEntryImageData($aContentInfo, $sField = 'FIELD_THUMB', $aTranscoders = array())
  2131. {
  2132. if(empty($aTranscoders))
  2133. $aTranscoders = array('OBJECT_TRANSCODER_COVER', 'OBJECT_IMAGES_TRANSCODER_COVER', 'OBJECT_IMAGES_TRANSCODER_GALLERY');
  2134. $CNF = &$this->_oConfig->CNF;
  2135. if(empty($CNF[$sField]) || empty($aContentInfo[$CNF[$sField]]) || empty($CNF['OBJECT_STORAGE']))
  2136. return false;
  2137. $iId = (int)$aContentInfo[$CNF[$sField]];
  2138. foreach($aTranscoders as $sTranscoder)
  2139. if(!empty($CNF[$sTranscoder]))
  2140. return array('id' => $iId, 'transcoder' => $CNF[$sTranscoder]);
  2141. return array('id' => $iId, 'object' => $CNF['OBJECT_STORAGE']);
  2142. }
  2143. public function getProfileId()
  2144. {
  2145. return bx_get_logged_profile_id();
  2146. }
  2147. public function getProfileInfo($iUserId = false)
  2148. {
  2149. $oProfile = $this->getObjectUser($iUserId);
  2150. $oAccount = null;
  2151. if($oProfile && !($oProfile instanceof BxDolProfileUndefined) && !($oProfile instanceof BxDolProfileAnonymous))
  2152. $oAccount = $oProfile->getAccountObject();
  2153. $bAccount = !empty($oAccount);
  2154. if(!$bAccount)
  2155. $oProfile = BxDolProfileUndefined::getInstance();
  2156. return array(
  2157. 'id' => $oProfile->id(),
  2158. 'name' => $oProfile->getDisplayName(),
  2159. 'email' => $bAccount ? $oAccount->getEmail() : '',
  2160. 'link' => $oProfile->getUrl(),
  2161. 'icon' => $oProfile->getIcon(),
  2162. 'thumb' => $oProfile->getThumb(),
  2163. 'avatar' => $oProfile->getAvatar(),
  2164. 'unit' => $oProfile->getUnit(),
  2165. 'active' => $oProfile->isActive(),
  2166. );
  2167. }
  2168. public function getObjectUser($iUserId = false)
  2169. {
  2170. bx_import('BxDolProfile');
  2171. return BxDolProfile::getInstanceMagic($iUserId);
  2172. }
  2173. public function getObjectFavorite($sSystem = '', $iId = 0)
  2174. {
  2175. $CNF = &$this->_oConfig->CNF;
  2176. if(empty($sSystem) && !empty($CNF['OBJECT_FAVORITES']))
  2177. $sSystem = $CNF['OBJECT_FAVORITES'];
  2178. if(empty($sSystem))
  2179. return false;
  2180. $oFavorite = BxDolFavorite::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  2181. if(!$oFavorite || !$oFavorite->isEnabled())
  2182. return false;
  2183. return $oFavorite;
  2184. }
  2185. public function getUserId()
  2186. {
  2187. return isLogged() ? bx_get_logged_profile_id() : 0;
  2188. }
  2189. public function getUserIp()
  2190. {
  2191. return getVisitorIP();
  2192. }
  2193. public function getUserInfo($iUserId = 0)
  2194. {
  2195. $oProfile = BxDolProfile::getInstanceMagic($iUserId);
  2196. return array(
  2197. $oProfile->getDisplayName(),
  2198. $oProfile->getUrl(),
  2199. $oProfile->getThumb(),
  2200. $oProfile->getUnit(),
  2201. $oProfile->getUnit(0, array('template' => 'unit_wo_info'))
  2202. );
  2203. }
  2204. public function getUserInfoWithBadges($iUserId = 0)
  2205. {
  2206. $oProfile = BxDolProfile::getInstanceMagic($iUserId);
  2207. return array(
  2208. $oProfile->getDisplayName(),
  2209. $oProfile->getUrl(),
  2210. $oProfile->getThumb(),
  2211. $oProfile->getUnit(),
  2212. $oProfile->getUnit(0, array('template' => 'unit_wo_info')),
  2213. $oProfile->getBadges()
  2214. );
  2215. }
  2216. public function isMenuItemVisible($sObject, &$aItem, &$aContentInfo)
  2217. {
  2218. $CNF = &$this->_oConfig->CNF;
  2219. // default visible settings
  2220. if(!BxDolAcl::getInstance()->isMemberLevelInSet($aItem['visible_for_levels']))
  2221. return false;
  2222. if (!empty($aItem['visibility_custom'])) {
  2223. $oMenu = BxDolMenu::getObjectInstance($sObject);
  2224. if ($oMenu && !BxDolService::callSerialized($aItem['visibility_custom'], $oMenu->getMarkers()))
  2225. return false;
  2226. }
  2227. // get custom function name to check menu item visibility
  2228. $sFuncCheckAccess = false;
  2229. if(isset($CNF['MENU_ITEM_TO_METHOD'][$sObject][$aItem['name']]))
  2230. $sFuncCheckAccess = $CNF['MENU_ITEM_TO_METHOD'][$sObject][$aItem['name']];
  2231. // check custom visibility settings defined in module config class
  2232. if(!isset($aContentInfo))
  2233. $aContentInfo = array();
  2234. if($sFuncCheckAccess && CHECK_ACTION_RESULT_ALLOWED !== call_user_func_array(array($this, $sFuncCheckAccess), array(&$aContentInfo)))
  2235. return false;
  2236. return true;
  2237. }
  2238. public function _isModerator ($isPerformAction = false)
  2239. {
  2240. return $this->_isModeratorForProfile($isPerformAction, $this->_iProfileId);
  2241. }
  2242. public function _isModeratorForProfile($isPerformAction = false, $iProfileId = false)
  2243. {
  2244. return CHECK_ACTION_RESULT_ALLOWED === $this->checkAllowedEditAnyEntryForProfile ($isPerformAction, $iProfileId);
  2245. }
  2246. public function _isAdministrator ($isPerformAction = false)
  2247. {
  2248. return $this->_isAdministratorForProfile($isPerformAction, $this->_iProfileId);
  2249. }
  2250. public function _isAdministratorForProfile($isPerformAction = false, $iProfileId = false)
  2251. {
  2252. return CHECK_ACTION_RESULT_ALLOWED === $this->checkAllowedDeleteAnyEntryForProfile ($isPerformAction, $iProfileId);
  2253. }
  2254. public function _prepareAuditParams($aContentInfo, $bIsSaveData = true, $aOverrideAuditParams = array())
  2255. {
  2256. $CNF = &$this->_oConfig->CNF;
  2257. $iContextId = isset($CNF['FIELD_ALLOW_VIEW_TO']) && (!empty($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) && (int)$aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0) ? - $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] : 0;
  2258. $AuditParams = array(
  2259. 'content_title' => (isset($CNF['FIELD_TITLE']) && isset($aContentInfo[$CNF['FIELD_TITLE']])) ? $aContentInfo[$CNF['FIELD_TITLE']] : '',
  2260. 'context_profile_id' => $iContextId,
  2261. 'content_info_object' => isset($CNF['OBJECT_CONTENT_INFO']) ? $CNF['OBJECT_CONTENT_INFO'] : '',
  2262. 'data' => ($bIsSaveData ? $aContentInfo : array())
  2263. );
  2264. if ($iContextId > 0)
  2265. $AuditParams['context_profile_title'] = BxDolProfile::getInstance($iContextId)->getDisplayName();
  2266. $AuditParams = array_merge($AuditParams, $aOverrideAuditParams);
  2267. return $AuditParams;
  2268. }
  2269. public function _getFavoriteListUrl ($iListId, $iProfileId)
  2270. {
  2271. $CNF = &$this->_oConfig->CNF;
  2272. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_FAVORITES_LIST'] . '&profile_id=' . $iProfileId . '&list_id=' . $iListId);
  2273. }
  2274. // ====== PROTECTED METHODS
  2275. protected function _serviceEntityForm ($sFormMethod, $iContentId = 0, $sDisplay = false, $sCheckFunction = false, $bErrorMsg = true)
  2276. {
  2277. $iContentId = $this->_getContent($iContentId, false);
  2278. if($iContentId === false)
  2279. return false;
  2280. bx_import('FormsEntryHelper', $this->_aModule);
  2281. $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
  2282. $oFormsHelper = new $sClass($this);
  2283. return $oFormsHelper->$sFormMethod((int)$iContentId, $sDisplay, $sCheckFunction, $bErrorMsg);
  2284. }
  2285. protected function _serviceTemplateFunc ($sFunc, $iContentId, $sFuncGetContent = 'getContentInfoById')
  2286. {
  2287. $mixedContent = $this->_getContent($iContentId, $sFuncGetContent);
  2288. if($mixedContent === false)
  2289. return false;
  2290. list($iContentId, $aContentInfo) = $mixedContent;
  2291. return $this->_oTemplate->$sFunc($aContentInfo);
  2292. }
  2293. protected function _rss ($aArgs, $sClass = 'SearchResult')
  2294. {
  2295. $sMode = array_shift($aArgs);
  2296. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse())) {
  2297. $this->_oTemplate->displayAccessDenied ($sMsg);
  2298. exit;
  2299. }
  2300. $aParams = $this->_buildRssParams($sMode, $aArgs);
  2301. bx_import ($sClass, $this->_aModule);
  2302. $sClass = $this->_aModule['class_prefix'] . $sClass;
  2303. $o = new $sClass($sMode, $aParams);
  2304. if ($o->isError)
  2305. $this->_oTemplate->displayPageNotFound ();
  2306. else
  2307. $o->outputRSS();
  2308. exit;
  2309. }
  2310. protected function _getContent($iContentId = 0, $sFuncGetContent = true)
  2311. {
  2312. if(!$iContentId)
  2313. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  2314. if(!$iContentId)
  2315. return false;
  2316. if($sFuncGetContent === true)
  2317. $sFuncGetContent = 'getContentInfoById';
  2318. if(empty($sFuncGetContent) || !method_exists($this->_oDb, $sFuncGetContent))
  2319. return $iContentId;
  2320. $aContentInfo = $this->_oDb->$sFuncGetContent($iContentId);
  2321. if(!$aContentInfo)
  2322. return false;
  2323. return array($iContentId, $aContentInfo);
  2324. }
  2325. protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
  2326. {
  2327. $CNF = &$this->_oConfig->CNF;
  2328. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  2329. //--- Image(s)
  2330. $aImages = $this->_getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  2331. $aImagesAttach = $this->_getImagesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  2332. //--- Video(s)
  2333. $aVideos = $this->_getVideosForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  2334. $aVideosAttach = $this->_getVideosForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  2335. //--- Files(s)
  2336. $aFiles = $this->_getFilesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  2337. $aFilesAttach = $this->_getFilesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  2338. //--- Title
  2339. $sTitle = '';
  2340. if(isset($CNF['FIELD_TITLE']) && isset($aContentInfo[$CNF['FIELD_TITLE']]))
  2341. $sTitle = $aContentInfo[$CNF['FIELD_TITLE']];
  2342. else if(isset($CNF['FIELD_TEXT']) && isset($aContentInfo[$CNF['FIELD_TEXT']]))
  2343. $sTitle = strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
  2344. //--- Text
  2345. $sText = isset($CNF['FIELD_TEXT']) && isset($aContentInfo[$CNF['FIELD_TEXT']]) ? $aContentInfo[$CNF['FIELD_TEXT']] : '';
  2346. if(!empty($CNF['OBJECT_METATAGS']) && is_string($sText)) {
  2347. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  2348. $sText = $oMetatags->metaParse($aContentInfo[$CNF['FIELD_ID']], $sText);
  2349. }
  2350. return array(
  2351. 'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
  2352. 'sample_wo_article' => $CNF['T']['txt_sample_single'],
  2353. 'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
  2354. 'url' => $sUrl,
  2355. 'title' => $sTitle,
  2356. 'text' => $sText,
  2357. 'images' => $aImages,
  2358. 'images_attach' => $aImagesAttach,
  2359. 'videos' => $aVideos,
  2360. 'videos_attach' => $aVideosAttach,
  2361. 'files' => $aFiles,
  2362. 'files_attach' => $aFilesAttach
  2363. );
  2364. }
  2365. protected function _getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  2366. {
  2367. $CNF = &$this->_oConfig->CNF;
  2368. $sImage = $sImageOrig = '';
  2369. if(isset($CNF['FIELD_COVER']) && isset($aContentInfo[$CNF['FIELD_COVER']]) && $aContentInfo[$CNF['FIELD_COVER']]) {
  2370. $sImage = $this->_oConfig->getImageUrl($aContentInfo[$CNF['FIELD_COVER']], array('OBJECT_IMAGES_TRANSCODER_GALLERY', 'OBJECT_IMAGES_TRANSCODER_THUMB'));
  2371. $sImageOrig = $this->_oConfig->getImageUrl($aContentInfo[$CNF['FIELD_COVER']], array('OBJECT_IMAGES_TRANSCODER_COVER'));
  2372. }
  2373. $bImageThumb = isset($CNF['FIELD_THUMB']) && isset($aContentInfo[$CNF['FIELD_THUMB']]) && $aContentInfo[$CNF['FIELD_THUMB']];
  2374. if($sImage == '' && $bImageThumb)
  2375. $sImage = $this->_oConfig->getImageUrl($aContentInfo[$CNF['FIELD_THUMB']], array('OBJECT_IMAGES_TRANSCODER_GALLERY', 'OBJECT_IMAGES_TRANSCODER_THUMB'));
  2376. if($sImageOrig == '' && $bImageThumb)
  2377. $sImageOrig = $this->_oConfig->getImageUrl($aContentInfo[$CNF['FIELD_THUMB']], array('OBJECT_IMAGES_TRANSCODER_COVER'));
  2378. if(empty($sImage))
  2379. return array();
  2380. if($sImageOrig == '')
  2381. $sImageOrig = $sImage;
  2382. return array(
  2383. array('id' => $aContentInfo[$CNF['FIELD_THUMB']], 'url' => $sUrl, 'src' => $sImage, 'src_orig' => $sImageOrig),
  2384. );
  2385. }
  2386. protected function _getImagesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  2387. {
  2388. return array();
  2389. }
  2390. protected function _getVideosForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  2391. {
  2392. return array();
  2393. }
  2394. protected function _getVideosForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  2395. {
  2396. return array();
  2397. }
  2398. protected function _getFilesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  2399. {
  2400. return array();
  2401. }
  2402. protected function _getFilesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  2403. {
  2404. return array();
  2405. }
  2406. protected function _entityComments ($sObject, $iId = 0)
  2407. {
  2408. if (!$iId)
  2409. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  2410. if (!$iId)
  2411. return false;
  2412. $oCmts = BxDolCmts::getObjectInstance($sObject, $iId);
  2413. if (!$oCmts || !$oCmts->isEnabled())
  2414. return false;
  2415. return $oCmts->getCommentsBlock(array(), array('in_designbox' => false, 'show_empty' => true));
  2416. }
  2417. protected function _getFields($iContentId)
  2418. {
  2419. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  2420. if(empty($aContentInfo))
  2421. return array();
  2422. return BxDolContentInfo::formatFields($aContentInfo);
  2423. }
  2424. protected function _getFieldValue($sField, $iContentId)
  2425. {
  2426. $CNF = &$this->_oConfig->CNF;
  2427. if(empty($CNF[$sField]))
  2428. return false;
  2429. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  2430. if(empty($aContentInfo) || empty($aContentInfo[$CNF[$sField]]))
  2431. return false;
  2432. return $aContentInfo[$CNF[$sField]];
  2433. }
  2434. protected function _getFieldValueThumb($sField, $iContentId, $sTranscoder = '')
  2435. {
  2436. $CNF = &$this->_oConfig->CNF;
  2437. if(empty($sTranscoder) || empty($CNF[$sField]))
  2438. return false;
  2439. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  2440. if(empty($aContentInfo) || empty($aContentInfo[$CNF[$sField]]))
  2441. return false;
  2442. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($sTranscoder);
  2443. if(!$oImagesTranscoder)
  2444. return false;
  2445. return $oImagesTranscoder->getFileUrl($aContentInfo[$CNF[$sField]]);
  2446. }
  2447. protected function _prepareResponse($aResponse, $bAsJson = false, $aAdditional = array())
  2448. {
  2449. if(!$bAsJson)
  2450. return $aResponse;
  2451. if(!empty($aAdditional) && is_array($aAdditional))
  2452. $aResponse = array_merge($aResponse, $aAdditional);
  2453. echoJson($aResponse);
  2454. exit;
  2455. }
  2456. /**
  2457. * Blocks for lables tree browsing private functions
  2458. */
  2459. private function _getLablesBreadcrumbsArray($iLabelId, &$aBreadcrumbs)
  2460. {
  2461. $oLabel = BxDolLabel::getInstance();
  2462. $aLabel = $oLabel->getLabels(array('type' => 'id', 'id' => $iLabelId));
  2463. if ($aLabel){
  2464. $aBreadcrumbs[$aLabel['id']] = array('id' => $aLabel['id'], 'value' => $aLabel['value']);
  2465. $this->_getLablesBreadcrumbsArray($aLabel['parent'], $aBreadcrumbs);
  2466. }
  2467. }
  2468. private function _getLablesBrowseUrl($iLabelId)
  2469. {
  2470. list($sPageLink, $aPageParams) = bx_get_base_url_inline();
  2471. return BxDolPermalinks::getInstance()->permalink(bx_append_url_params($sPageLink, array_merge($aPageParams, array('label' => $iLabelId))));
  2472. }
  2473. private function _getLablesTreeLevel($aBreadcrumbs, $iParent = 0)
  2474. {
  2475. $oLabel = BxDolLabel::getInstance();
  2476. $aLabelsOutput = array();
  2477. $aLabels = $oLabel->getLabels(array('type' => 'parent', 'parent' => $iParent));
  2478. if (count($aLabels) > 0){
  2479. foreach($aLabels as $aLabel) {
  2480. $sChild = $this->_getLablesTreeLevel($aBreadcrumbs, $aLabel['id']);
  2481. $bChildPresent = $sChild != '' ? true : false;
  2482. $bIsOpen = array_key_exists($aLabel['id'], $aBreadcrumbs) ? true : false;
  2483. if (!$bIsOpen){
  2484. $sChild = '';
  2485. }
  2486. $aLabelsOutput[] = array(
  2487. 'value' => $aLabel['value'],
  2488. 'url' => $this->_getLablesBrowseUrl($aLabel['id']),
  2489. 'child' => $sChild,
  2490. 'selected' => bx_process_input(bx_get('label'), BX_DATA_INT) == $aLabel['id'] ? 'selected' : ''.$aLabel['id'],
  2491. 'bx_if:open' => array(
  2492. 'condition' => $bChildPresent && $bIsOpen,
  2493. 'content' => array()
  2494. ),
  2495. 'bx_if:can_open' => array(
  2496. 'condition' => $bChildPresent && !$bIsOpen,
  2497. 'content' => array()
  2498. )
  2499. );
  2500. }
  2501. return $this->_oTemplate->parseHtmlByName('labels_tree.html',
  2502. array(
  2503. 'bx_repeat:items' => $aLabelsOutput,
  2504. 'parent' => $iParent,
  2505. )
  2506. );
  2507. }
  2508. return '';
  2509. }
  2510. }
  2511. /** @} */