BxBaseModTextModule.php 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  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 BaseText Base classes for text modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. define('BX_BASE_MOD_TEXT_STATUS_ACTIVE', 'active');
  12. define('BX_BASE_MOD_TEXT_STATUS_HIDDEN', 'hidden');
  13. define('BX_BASE_MOD_TEXT_STATUS_AWAITING', 'awaiting');
  14. /**
  15. * Saved for backward compatibility.
  16. * Can be removed in future releases of UNA 13.
  17. */
  18. define('BX_BASE_MOD_TEXT_STATUS_PENDING', 'pending');
  19. /**
  20. * Base module class for text based modules
  21. */
  22. class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolContentInfoService
  23. {
  24. function __construct(&$aModule)
  25. {
  26. parent::__construct($aModule);
  27. }
  28. // ====== ACTIONS METHODS
  29. public function actionEmbedPoll($iPollId = 0)
  30. {
  31. if(empty($iPollId) && bx_get('poll_id') !== false)
  32. $iPollId = (int)bx_get('poll_id');
  33. $aParams = bx_get_with_prefix('param');
  34. array_walk($aParams, function(&$sValue) {
  35. $sValue = bx_process_input($sValue);
  36. });
  37. $this->_oTemplate->embedPollItem($iPollId, $aParams);
  38. }
  39. public function actionEmbedPolls($iId = 0)
  40. {
  41. list($iContentId, $aContentInfo) = $this->_getContent($iId);
  42. if($iContentId === false)
  43. return;
  44. $aParams = bx_get_with_prefix('param');
  45. array_walk($aParams, function(&$sValue) {
  46. $sValue = bx_process_input($sValue);
  47. });
  48. $this->_oTemplate->embedPollItems($aContentInfo, $aParams);
  49. }
  50. public function actionGetPoll()
  51. {
  52. $iPollId = (int)bx_get('poll_id');
  53. $sView = bx_process_input(bx_get('view'));
  54. $sMethod = 'serviceGetBlockPoll' . bx_gen_method_name($sView);
  55. if(!method_exists($this, $sMethod))
  56. return echoJson(array());
  57. $aBlock = $this->$sMethod($iPollId, true);
  58. if(empty($aBlock) || !is_array($aBlock))
  59. return echoJson(array());
  60. return echoJson(array(
  61. 'content' => $aBlock['content']
  62. ));
  63. }
  64. public function actionDeletePoll()
  65. {
  66. $CNF = &$this->_oConfig->CNF;
  67. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  68. if(empty($iId))
  69. return echoJson(array());
  70. $aResult = array();
  71. if($this->_oDb->deletePolls(array($CNF['FIELD_POLL_ID'] => $iId)))
  72. $aResult = array('code' => 0);
  73. else
  74. $aResult = array('code' => 1, 'message' => _t($CNF['txt_err_cannot_perform_action']));
  75. echoJson($aResult);
  76. }
  77. public function actionGetPollForm()
  78. {
  79. echo $this->_oTemplate->getPollForm();
  80. }
  81. public function actionSubmitPollForm()
  82. {
  83. echoJson($this->getPollForm());
  84. }
  85. public function actionGetAttachLinkForm()
  86. {
  87. $iContentId = 0;
  88. if(bx_get('content_id') !== false)
  89. $iContentId = (int)bx_get('content_id');
  90. echo $this->_oTemplate->getAttachLinkForm($iContentId);
  91. }
  92. public function actionSubmitAttachLinkForm()
  93. {
  94. echoJson($this->getFormAttachLink());
  95. }
  96. public function actionAddAttachLink()
  97. {
  98. $sUrl = bx_process_input(bx_get('url'));
  99. if(empty($sUrl))
  100. return echoJson(array());
  101. $sUrl = htmlspecialchars_decode($sUrl);
  102. $sHeader = 'Content-Type';
  103. $aHeaders = @get_headers($sUrl, 1);
  104. if(!empty($aHeaders) && is_array($aHeaders) && !empty($aHeaders[$sHeader])) {
  105. $mixedContentType = $aHeaders[$sHeader];
  106. if(!is_array($mixedContentType))
  107. $mixedContentType = array($mixedContentType);
  108. foreach($mixedContentType as $sContentType)
  109. if(strpos($sContentType, 'image') !== false)
  110. return echoJson(array());
  111. }
  112. $iContentId = 0;
  113. if(bx_get('content_id') !== false)
  114. $iContentId = (int)bx_get('content_id');
  115. echoJson($this->addAttachLink(array(
  116. 'content_id' => $iContentId,
  117. 'url' => $sUrl
  118. )));
  119. }
  120. public function actionDeleteAttachLink()
  121. {
  122. $CNF = &$this->_oConfig->CNF;
  123. $iUserId = $this->getUserId();
  124. $iLinkId = bx_process_input(bx_get('id'), BX_DATA_INT);
  125. if(empty($iLinkId))
  126. return echoJson(array());
  127. $aLink = $this->_oDb->getLinksBy(array('type' => 'id', 'id' => $iLinkId, 'profile_id' => $iUserId));
  128. if(empty($aLink) || !is_array($aLink))
  129. return echoJson(array());
  130. if(!empty($aLink['media_id']))
  131. BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_PHOTOS'])->deleteFile($aLink['media_id']);
  132. $aResult = array();
  133. if($this->_oDb->deleteLink($iLinkId))
  134. $aResult = array('code' => 0);
  135. else
  136. $aResult = array('code' => 1, 'message' => _t('_bx_posts_form_post_input_link_err_delete'));
  137. echoJson($aResult);
  138. }
  139. public function actionFileEmbedVideo($iFileId)
  140. {
  141. $this->_oTemplate->embedVideo($iFileId);
  142. }
  143. public function actionFileEmbedSound($iFileId)
  144. {
  145. $this->_oTemplate->embedSound($iFileId);
  146. }
  147. // ====== SERVICE METHODS
  148. public function serviceGetSafeServices()
  149. {
  150. $a = parent::serviceGetSafeServices();
  151. return array_merge($a, array (
  152. 'GetBlockPollAnswers' => '',
  153. 'GetBlockPollResults' => '',
  154. 'GetMenuAddonManageToolsProfileStats' => '',
  155. 'BrowsePublic' => '',
  156. 'BrowsePopular' => '',
  157. 'BrowseTop' => '',
  158. 'BrowseUpdated' => '',
  159. 'BrowseAuthor' => '',
  160. 'CategoriesMultiListContext' => ''
  161. ));
  162. }
  163. public function serviceManageTools($sType = 'common')
  164. {
  165. $sResult = parent::serviceManageTools($sType);
  166. if(!empty($sResult))
  167. $this->_oTemplate->addJsSystem(['modules/base/text/js/|manage_tools.js']);
  168. return $sResult;
  169. }
  170. /**
  171. * @page service Service Calls
  172. * @section bx_base_text Base Text
  173. * @subsection bx_base_general-page_blocks Page Blocks
  174. * @subsubsection bx_base_general-categories_multi_list_context categories_multi_list_context
  175. *
  176. * @code bx_srv('bx_posts', 'categories_multi_list_context', [...]); @endcode
  177. *
  178. * Display multi-categorories block with number of posts in each category for current context
  179. * @param $bDisplayEmptyCats display empty categories
  180. *
  181. * @see BxBaseModGeneralModule::serviceCategoriesMultiListContext
  182. */
  183. /**
  184. * @ref bx_base_general-categories_multi_list_context "categories_multi_list_context"
  185. */
  186. public function serviceCategoriesMultiListContext($iProfileId = 0, $bDisplayEmptyCats = true)
  187. {
  188. if ($iProfileId == 0)
  189. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  190. $oCategories = BxDolCategories::getInstance();
  191. $aCats = $oCategories->getData([
  192. 'type' => 'by_module&context_with_num',
  193. 'module' => $this->getName(),
  194. 'context_id' => $iProfileId
  195. ]
  196. );
  197. $aVars = array('bx_repeat:cats' => array());
  198. foreach ($aCats as $oCat) {
  199. $sValue = $oCat['value'];
  200. $iNum = $oCat['num'];
  201. $aVars['bx_repeat:cats'][] = array(
  202. 'url' => $oCategories->getUrl($this->getName(), $sValue, '&context_id=' . $iProfileId),
  203. 'name' => _t($sValue),
  204. 'value' => $sValue,
  205. 'num' => $iNum,
  206. );
  207. }
  208. if (!$aVars['bx_repeat:cats'])
  209. return '';
  210. return $this->_oTemplate->parseHtmlByName('category_list_multi.html', $aVars);
  211. }
  212. /**
  213. * @page service Service Calls
  214. * @section bx_base_text Base Text
  215. * @subsection bx_base_text-polls Polls Blocks
  216. * @subsubsection bx_base_text-get_block_poll_answers get_block_poll_answers
  217. *
  218. * @code bx_srv('bx_posts', 'get_block_poll_answers', [...]); @endcode
  219. *
  220. * Get block with poll answers
  221. * @param $iPollId poll ID
  222. *
  223. * @see BxBaseModTextModule::serviceGetBlockPollAnswers
  224. */
  225. /**
  226. * @ref bx_base_text-get_block_poll_answers "get_block_poll_answers"
  227. */
  228. public function serviceGetBlockPollAnswers($iPollId, $bForceDisplay = false)
  229. {
  230. if(!$iPollId)
  231. return false;
  232. if(!$bForceDisplay && $this->isPollPerformed($iPollId))
  233. return $this->serviceGetBlockPollResults($iPollId);
  234. return $this->_serviceTemplateFunc('entryPollAnswers', $iPollId, 'getPollInfoById');
  235. }
  236. /**
  237. * @page service Service Calls
  238. * @section bx_base_text Base Text
  239. * @subsection bx_base_text-polls Polls Blocks
  240. * @subsubsection bx_base_text-get_block_poll_results get_block_poll_results
  241. *
  242. * @code bx_srv('bx_posts', 'get_block_poll_results', [...]); @endcode
  243. *
  244. * Get block with poll results
  245. * @param $iPollId poll ID
  246. *
  247. * @see BxBaseModTextModule::serviceGetBlockPollResults
  248. */
  249. /**
  250. * @ref bx_base_text-get_block_poll_results "get_block_poll_results"
  251. */
  252. public function serviceGetBlockPollResults($iPollId)
  253. {
  254. return $this->_serviceTemplateFunc('entryPollResults', $iPollId, 'getPollInfoById');
  255. }
  256. /**
  257. * Display media EXIF information.
  258. * @param $iMediaId media ID, if it's omitted then it's taken from 'id' GET variable.
  259. * @return HTML string with EXIF info. On error empty string is returned.
  260. */
  261. public function serviceMediaExif ($iMediaId = 0)
  262. {
  263. $CNF = &$this->_oConfig->CNF;
  264. return $this->_serviceTemplateFunc ('mediaExif', $iMediaId, $CNF['FUNCTION_FOR_GET_ITEM_INFO']);
  265. }
  266. public function serviceGetThumb ($iContentId, $sTranscoder = '')
  267. {
  268. $CNF = &$this->_oConfig->CNF;
  269. if(bx_is_api()){
  270. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  271. return bx_api_get_image($CNF['OBJECT_STORAGE'], $aContentInfo[$CNF['FIELD_THUMB']]);
  272. }
  273. if(empty($sTranscoder) && !empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']))
  274. $sTranscoder = $CNF['OBJECT_IMAGES_TRANSCODER_GALLERY'];
  275. $mixedResult = $this->_getFieldValueThumb('FIELD_THUMB', $iContentId, $sTranscoder);
  276. return $mixedResult !== false ? $mixedResult : '';
  277. }
  278. public function serviceGetMenuAddonManageTools()
  279. {
  280. $CNF = &$this->_oConfig->CNF;
  281. $iNumTotal = $this->_oDb->getEntriesNumByParams();
  282. $iNum1 = $this->_oDb->getEntriesNumByParams([
  283. [
  284. 'key' => $CNF['FIELD_STATUS'],
  285. 'value' => 'hidden',
  286. 'operator' => '='
  287. ]
  288. ]);
  289. $iNum2 = 0;
  290. if (isset($CNF['OBJECT_REPORTS'])){
  291. $iNum2 = $this->_oDb->getEntriesNumByParams([
  292. [
  293. 'key' => 'reports',
  294. 'value' => '0',
  295. 'operator' => '>'
  296. ]
  297. ]);
  298. }
  299. return array('counter1_value' => $iNum1, 'counter2_value' => $iNum2, 'counter3_value' => $iNumTotal );
  300. }
  301. /**
  302. * @page service Service Calls
  303. * @section bx_base_text Base Text
  304. * @subsection bx_base_text-other Other
  305. * @subsubsection bx_base_text-get_menu_addon_manage_tools_profile_stats get_menu_addon_manage_tools_profile_stats
  306. *
  307. * @code bx_srv('bx_posts', 'get_menu_addon_manage_tools_profile_stats', []); @endcode
  308. *
  309. * Get number of posts for currently logged in user
  310. *
  311. * @see BxBaseModTextModule::serviceGetMenuAddonManageToolsProfileStats
  312. */
  313. /**
  314. * @ref bx_base_text-get_menu_addon_manage_tools_profile_stats "get_menu_addon_manage_tools_profile_stats"
  315. */
  316. public function serviceGetMenuAddonManageToolsProfileStats()
  317. {
  318. bx_import('SearchResult', $this->_aModule);
  319. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  320. $o = new $sClass();
  321. $o->fillFilters(array(
  322. 'author' => bx_get_logged_profile_id()
  323. ));
  324. $o->unsetPaginate();
  325. return $o->getNum();
  326. }
  327. /**
  328. * @page service Service Calls
  329. * @section bx_base_text Base Text
  330. * @subsection bx_base_text-browse Browse
  331. * @subsubsection bx_base_text-browse_public browse_public
  332. *
  333. * @code bx_srv('bx_posts', 'browse_public', [...]); @endcode
  334. *
  335. * Display public posts
  336. * @param $sUnitView unit view, such as: full, extended, gallery, showcase
  337. * @param $bEmptyMessage display or not "empty" message when there is no content
  338. * @param $bAjaxPaginate use AJAX paginate or not
  339. *
  340. * @see BxBaseModTextModule::serviceBrowsePublic
  341. */
  342. /**
  343. * @ref bx_base_text-browse_public "browse_public"
  344. */
  345. public function serviceBrowsePublic ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  346. {
  347. return $this->_serviceBrowse ('public', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  348. }
  349. /**
  350. * @page service Service Calls
  351. * @section bx_base_text Base Text
  352. * @subsection bx_base_text-browse Browse
  353. * @subsubsection bx_base_text-browse_popular browse_popular
  354. *
  355. * @code bx_srv('bx_posts', 'browse_popular', [...]); @endcode
  356. *
  357. * Display popular posts
  358. * @param $sUnitView unit view, such as: full, extended, gallery, showcase
  359. * @param $bEmptyMessage display or not "empty" message when there is no content
  360. * @param $bAjaxPaginate use AJAX paginate or not
  361. *
  362. * @see BxBaseModTextModule::serviceBrowsePopular
  363. */
  364. /**
  365. * @ref bx_base_text-browse_popular "browse_popular"
  366. */
  367. public function serviceBrowsePopular ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  368. {
  369. return $this->_serviceBrowse ('popular', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  370. }
  371. /**
  372. * @page service Service Calls
  373. * @section bx_base_text Base Text
  374. * @subsection bx_base_text-browse Browse
  375. * @subsubsection bx_base_text-browse_top browse_top
  376. *
  377. * @code bx_srv('bx_posts', 'browse_top', [...]); @endcode
  378. *
  379. * Display top posts
  380. * @param $sUnitView unit view, such as: full, extended, gallery, showcase
  381. * @param $bEmptyMessage display or not "empty" message when there is no content
  382. * @param $bAjaxPaginate use AJAX paginate or not
  383. *
  384. * @see BxBaseModTextModule::serviceBrowseTop
  385. */
  386. /**
  387. * @ref bx_base_text-browse_top "browse_top"
  388. */
  389. public function serviceBrowseTop ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  390. {
  391. return $this->_serviceBrowse ('top', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  392. }
  393. /**
  394. * @page service Service Calls
  395. * @section bx_base_text Base Text
  396. * @subsection bx_base_text-browse Browse
  397. * @subsubsection bx_base_text-browse_updated browse_updated
  398. *
  399. * @code bx_srv('bx_posts', 'browse_updated', [...]); @endcode
  400. *
  401. * Display recently updated posts
  402. * @param $sUnitView unit view, such as: full, extended, gallery, showcase
  403. * @param $bEmptyMessage display or not "empty" message when there is no content
  404. * @param $bAjaxPaginate use AJAX paginate or not
  405. *
  406. * @see BxBaseModTextModule::serviceBrowseUpdated
  407. */
  408. /**
  409. * @ref bx_base_text-browse_updated "browse_updated"
  410. */
  411. public function serviceBrowseUpdated ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  412. {
  413. return $this->_serviceBrowse ('updated', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  414. }
  415. /**
  416. * @page service Service Calls
  417. * @section bx_base_text Base Text
  418. * @subsection bx_base_text-browse Browse
  419. * @subsubsection bx_base_text-browse_author browse_author
  420. *
  421. * @code bx_srv('bx_posts', 'browse_author', [...]); @endcode
  422. *
  423. * Display posts of specified author
  424. * @param $iProfileId profile ID
  425. * @param $aParams additional params, see BxBaseModGeneralModule::serviceBrowse
  426. *
  427. * @see BxBaseModTextModule::serviceBrowseAuthor
  428. */
  429. /**
  430. * @ref bx_base_text-browse_author "browse_author"
  431. */
  432. public function serviceBrowseAuthor ($iProfileId = 0, $aParams = array())
  433. {
  434. return $this->_serviceBrowseWithParam ('author', 'profile_id', $iProfileId, $aParams);
  435. }
  436. /**
  437. * @page service Service Calls
  438. * @section bx_base_text Base Text
  439. * @subsection bx_base_text-page_blocks Page Blocks
  440. * @subsubsection bx_base_text-entity_author entity_author
  441. *
  442. * @code bx_srv('bx_posts', 'entity_author', [...]); @endcode
  443. *
  444. * Display author block for the specified post
  445. * @param $iContentId content ID
  446. *
  447. * @see BxBaseModTextModule::serviceEntityAuthor
  448. */
  449. /**
  450. * @ref bx_base_text-entity_author "entity_author"
  451. */
  452. public function serviceEntityAuthor ($iContentId = 0)
  453. {
  454. return $this->_serviceTemplateFunc ('entryAuthor', $iContentId);
  455. }
  456. /**
  457. * @page service Service Calls
  458. * @section bx_base_text Base Text
  459. * @subsection bx_base_text-page_blocks Page Blocks
  460. * @subsubsection bx_base_text-entity_polls entity_polls
  461. *
  462. * @code bx_srv('bx_posts', 'entity_polls', [...]); @endcode
  463. *
  464. * Display polls for the specified post
  465. * @param $iContentId content ID
  466. *
  467. * @see BxBaseModTextModule::serviceEntityPolls
  468. */
  469. /**
  470. * @ref bx_base_text-entity_polls "entity_polls"
  471. */
  472. public function serviceEntityPolls ($iContentId = 0)
  473. {
  474. return $this->_serviceTemplateFunc ('entryPolls', $iContentId);
  475. }
  476. /**
  477. * @page service Service Calls
  478. * @section bx_base_text Base Text
  479. * @subsection bx_base_text-page_blocks Page Blocks
  480. * @subsubsection bx_base_text-entity_breadcrumb entity_breadcrumb
  481. *
  482. * @code bx_srv('bx_forum', 'entity_breadcrumb', [...]); @endcode
  483. *
  484. * Display breadcrumb for the specified post
  485. * @param $iContentId content ID
  486. *
  487. * @see BxBaseModTextModule::serviceEntityBreadcrumb
  488. */
  489. /**
  490. * @ref bx_base_text-entity_breadcrumb "entity_breadcrumb"
  491. */
  492. public function serviceEntityBreadcrumb ($iContentId = 0)
  493. {
  494. return $this->_serviceTemplateFunc ('entryBreadcrumb', $iContentId);
  495. }
  496. /**
  497. * Delete all content by profile
  498. * @param $iProfileId profile id
  499. * @return number of deleted items
  500. */
  501. public function serviceDeleteEntitiesByAuthor ($iProfileId)
  502. {
  503. $a = $this->_oDb->getEntriesByAuthor((int)$iProfileId);
  504. if (!$a)
  505. return 0;
  506. $iCount = 0;
  507. foreach ($a as $aContentInfo)
  508. $iCount += ('' == $this->serviceDeleteEntity($aContentInfo[$this->_oConfig->CNF['FIELD_ID']]) ? 1 : 0);
  509. return $iCount;
  510. }
  511. // ====== PERMISSION METHODS
  512. /**
  513. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  514. */
  515. public function checkAllowedSetThumb ($iContentId = 0)
  516. {
  517. // check ACL
  518. $aCheck = checkActionModule($this->_iProfileId, 'set thumb', $this->getName(), false);
  519. if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  520. return $aCheck[CHECK_ACTION_MESSAGE];
  521. return CHECK_ACTION_RESULT_ALLOWED;
  522. }
  523. public function isAllowedApprove($mixedContent, $isPerformAction = false)
  524. {
  525. return $this->checkAllowedApprove($mixedContent, $isPerformAction) === CHECK_ACTION_RESULT_ALLOWED;
  526. }
  527. public function checkAllowedApprove($mixedContent, $isPerformAction = false)
  528. {
  529. $CNF = &$this->_oConfig->CNF;
  530. $sTxtError = '_sys_txt_access_denied';
  531. $iProfileId = bx_get_logged_profile_id();
  532. if(!is_array($mixedContent))
  533. $mixedContent = $this->_oDb->getContentInfoById((int)$mixedContent);
  534. if(empty($mixedContent) || !is_array($mixedContent))
  535. return _t($sTxtError);
  536. if(!isset($CNF['FIELD_STATUS_ADMIN']) || $mixedContent[$CNF['FIELD_STATUS_ADMIN']] != BX_BASE_MOD_GENERAL_STATUS_PENDING)
  537. return _t($sTxtError);
  538. if($this->_isModerator())
  539. return CHECK_ACTION_RESULT_ALLOWED;
  540. if(!empty($CNF['FIELD_ALLOW_VIEW_TO']) && (int)$mixedContent[$CNF['FIELD_ALLOW_VIEW_TO']] < 0) {
  541. $iContextProfileId = abs((int)$mixedContent[$CNF['FIELD_ALLOW_VIEW_TO']]);
  542. $oContextProfile = BxDolProfile::getInstance($iContextProfileId);
  543. $aAdmins = bx_srv($oContextProfile->getModule(), 'get_admins_to_manage_content', [$iContextProfileId]);
  544. if(in_array($iProfileId, $aAdmins))
  545. return CHECK_ACTION_RESULT_ALLOWED;
  546. }
  547. return _t($sTxtError);
  548. }
  549. public function isPollPerformed($iObjectId, $iAuthorId = 0, $iAuthorIp = 0)
  550. {
  551. if(empty($iAuthorId)) {
  552. $iAuthorId = bx_get_logged_profile_id();
  553. $iAuthorIp = bx_get_ip_hash(getVisitorIP());
  554. }
  555. return $this->_oDb->isPollPerformed($iObjectId, $iAuthorId, $iAuthorIp);
  556. }
  557. // ====== COMMON METHODS
  558. public function addAttachLink($aValues, $sDisplay = false)
  559. {
  560. $CNF = &$this->_oConfig->CNF;
  561. if(!$sDisplay)
  562. $sDisplay = $CNF['OBJECT_FORM_DISPLAY_ATTACH_LINK_ADD'];
  563. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ATTACH_LINK'], $sDisplay, $this->_oTemplate);
  564. if(!$oForm)
  565. return array('message' => '_sys_txt_error_occured');
  566. $oForm->aFormAttrs['method'] = BX_DOL_FORM_METHOD_SPECIFIC;
  567. $oForm->aParams['csrf']['disable'] = true;
  568. if(!empty($oForm->aParams['db']['submit_name'])) {
  569. $sSubmitName = $oForm->aParams['db']['submit_name'];
  570. if(!isset($oForm->aInputs[$sSubmitName])) {
  571. if(isset($oForm->aInputs[$CNF['FIELD_ATTACH_LINK_CONTROLS']]))
  572. foreach($oForm->aInputs[$CNF['FIELD_ATTACH_LINK_CONTROLS']] as $mixedIndex => $aInput) {
  573. if(!is_numeric($mixedIndex) || empty($aInput['name']) || $aInput['name'] != $sSubmitName)
  574. continue;
  575. $aValues[$sSubmitName] = $aInput['value'];
  576. }
  577. }
  578. else
  579. $aValues[$sSubmitName] = $oForm->aInputs[$sSubmitName]['value'];
  580. }
  581. $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url');
  582. $oForm->initChecker(array(), $aValues);
  583. if(!$oForm->isSubmittedAndValid())
  584. return array('message' => '_sys_txt_error_occured');
  585. return $this->_addLink($oForm);
  586. }
  587. public function getFormAttachLink($iContentId = 0)
  588. {
  589. $CNF = &$this->_oConfig->CNF;
  590. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ATTACH_LINK'], $CNF['OBJECT_FORM_DISPLAY_ATTACH_LINK_ADD'], $this->_oTemplate);
  591. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'submit_attach_link_form/';
  592. $oForm->aInputs['content_id']['value'] = $iContentId;
  593. $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url');
  594. $oForm->initChecker();
  595. if($oForm->isSubmittedAndValid())
  596. return $this->_addLink($oForm);
  597. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  598. }
  599. protected function _addLink(&$oForm)
  600. {
  601. $CNF = &$this->_oConfig->CNF;
  602. $iUserId = $this->getUserId();
  603. $iContentId = (int)$oForm->getCleanValue('content_id');
  604. $sLink = rtrim($oForm->getCleanValue('url'), '/');
  605. $sHost = parse_url($sLink, PHP_URL_HOST);
  606. if (is_private_ip(gethostbyname($sHost)))
  607. return array('message' => _t('_sys_txt_error_occured'));
  608. $aMatches = array();
  609. preg_match($this->_oConfig->getPregPattern('url'), $sLink, $aMatches);
  610. $sLink = (empty($aMatches[2]) ? 'http://' : '') . $aMatches[0];
  611. $aSiteInfo = bx_get_site_info($sLink, array(
  612. 'thumbnailUrl' => array('tag' => 'link', 'content_attr' => 'href'),
  613. 'OGImage' => array('name_attr' => 'property', 'name' => 'og:image'),
  614. ));
  615. $sTitle = !empty($aSiteInfo['title']) ? $aSiteInfo['title'] : _t('_Empty');
  616. $sDescription = !empty($aSiteInfo['description']) ? $aSiteInfo['description'] : _t('_Empty');
  617. $sMediaUrl = '';
  618. if(!empty($aSiteInfo['thumbnailUrl']))
  619. $sMediaUrl = $aSiteInfo['thumbnailUrl'];
  620. else if(!empty($aSiteInfo['OGImage']))
  621. $sMediaUrl = $aSiteInfo['OGImage'];
  622. $iMediaId = 0;
  623. $oStorage = null;
  624. if(!empty($sMediaUrl)) {
  625. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_PHOTOS']);
  626. $iMediaId = $oStorage->storeFileFromUrl($sMediaUrl, true, $iUserId);
  627. }
  628. $iId = (int)$oForm->insert(array('profile_id' => $iUserId, 'media_id' => $iMediaId, 'url' => $sLink, 'title' => $sTitle, 'text' => $sDescription, 'added' => time()));
  629. if(!empty($iId)) {
  630. if(!empty($oStorage) && !empty($iMediaId))
  631. $oStorage->afterUploadCleanup($iMediaId, $iUserId);
  632. return array(
  633. 'id' => $iId,
  634. 'content_id' => $iContentId,
  635. 'url' => $sLink,
  636. 'item' => $this->_oTemplate->getAttachLinkItem($iUserId, $iId)
  637. );
  638. }
  639. return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
  640. }
  641. public function onApprove($mixedContent)
  642. {
  643. $CNF = &$this->_oConfig->CNF;
  644. if(!is_array($mixedContent))
  645. $mixedContent = $this->_oDb->getContentInfoById((int)$mixedContent);
  646. $this->alertAfterApprove($mixedContent);
  647. $this->onPublished($mixedContent[$CNF['FIELD_ID']]);
  648. }
  649. public function alertAfterAdd($aContentInfo)
  650. {
  651. $CNF = &$this->_oConfig->CNF;
  652. $iId = (int)$aContentInfo[$CNF['FIELD_ID']];
  653. $iAuthorId = (int)$aContentInfo[$CNF['FIELD_AUTHOR']];
  654. $sAction = 'added';
  655. if(isset($CNF['FIELD_STATUS']) && isset($aContentInfo[$CNF['FIELD_STATUS']]) && $aContentInfo[$CNF['FIELD_STATUS']] == BX_BASE_MOD_TEXT_STATUS_AWAITING)
  656. $sAction = 'deferred';
  657. else if(isset($CNF['FIELD_STATUS_ADMIN']) && isset($aContentInfo[$CNF['FIELD_STATUS_ADMIN']]) && $aContentInfo[$CNF['FIELD_STATUS_ADMIN']] == BX_BASE_MOD_GENERAL_STATUS_PENDING)
  658. $sAction = 'deferred';
  659. $aParams = $this->_alertParamsAdd($aContentInfo);
  660. bx_alert('system', 'prepare_alert_params', 0, 0, array('unit'=> $this->getName(), 'action' => &$sAction, 'object_id' => &$iId, 'sender_id' => &$iAuthorId, 'extras' => &$aParams));
  661. bx_alert($this->getName(), $sAction, $iId, $iAuthorId, $aParams);
  662. $this->_processModerationNotifications($aContentInfo);
  663. }
  664. public function alertAfterEdit($aContentInfo)
  665. {
  666. $CNF = &$this->_oConfig->CNF;
  667. $iId = (int)$aContentInfo[$CNF['FIELD_ID']];
  668. $aParams = $this->_alertParams($aContentInfo);
  669. bx_alert($this->getName(), 'edited', $iId, false, $aParams);
  670. }
  671. /**
  672. * Get array of params to be passed in Add/Edit Alert.
  673. */
  674. protected function _alertParams($aContentInfo)
  675. {
  676. $aParams = parent::_alertParams($aContentInfo);
  677. $CNF = &$this->_oConfig->CNF;
  678. if(!empty($CNF['FIELD_ALLOW_VIEW_TO']) && isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
  679. $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
  680. if(!empty($CNF['FIELD_CF']) && isset($aContentInfo[$CNF['FIELD_CF']]))
  681. $aParams['cf'] = $aContentInfo[$CNF['FIELD_CF']];
  682. return $aParams;
  683. }
  684. protected function _alertParamsAdd($aContentInfo)
  685. {
  686. $aParams = $this->_alertParams($aContentInfo);
  687. $CNF = &$this->_oConfig->CNF;
  688. if(!empty($CNF['OBJECT_METATAGS']))
  689. $aParams['timeline_group'] = array(
  690. 'by' => $this->getName() . '_' . (int)$aContentInfo[$CNF['FIELD_AUTHOR']] . '_' . (int)$aContentInfo[$CNF['FIELD_ID']],
  691. 'field' => 'owner_id'
  692. );
  693. return $aParams;
  694. }
  695. public function getPollForm()
  696. {
  697. $CNF = &$this->_oConfig->CNF;
  698. if(empty($CNF['OBJECT_FORM_POLL']))
  699. return array('code' => 1, 'message' => '_sys_txt_error_occured');
  700. $iProfileId = bx_get_logged_profile_id();
  701. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_POLL'], $CNF['OBJECT_FORM_POLL_DISPLAY_ADD'], $this->_oTemplate);
  702. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'submit_poll_form/';
  703. $oForm->initChecker();
  704. if($oForm->isSubmittedAndValid()) {
  705. $iId = $oForm->insert();
  706. if($iId)
  707. return array('code' => 0, 'id' => $iId, 'item' => $this->_oTemplate->getPollItem($iId, $iProfileId, array(
  708. 'manage' => true
  709. )));
  710. else
  711. return array('code' => 2, 'message' => '_sys_txt_error_entry_creation');
  712. }
  713. return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
  714. }
  715. public function getEntryImageData($aContentInfo, $sField = 'FIELD_THUMB', $aTranscoders = array())
  716. {
  717. $CNF = &$this->_oConfig->CNF;
  718. $mResult = parent::getEntryImageData($aContentInfo, $sField, $aTranscoders);
  719. if ($mResult === false && isset($CNF['PARAM_USE_GALERY_AS_COVER']) && getParam($CNF['PARAM_USE_GALERY_AS_COVER']) == 'on'){
  720. if(!empty($CNF['OBJECT_STORAGE_PHOTOS']) && !empty($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS'])){
  721. $sStorage = $CNF['OBJECT_STORAGE_PHOTOS'];
  722. $oStorage = BxDolStorage::getObjectInstance($sStorage);
  723. $aGhostFiles = $oStorage->getGhosts ($this->serviceGetContentOwnerProfileId($aContentInfo[$CNF['FIELD_ID']]), $aContentInfo[$CNF['FIELD_ID']]);
  724. if ($aGhostFiles){
  725. foreach ($aGhostFiles as $k => $a) {
  726. return array('id' => $a['id'], 'transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS']);
  727. }
  728. }
  729. }
  730. }
  731. return $mResult;
  732. }
  733. // ====== PROTECTED METHODS
  734. protected function _getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  735. {
  736. $CNF = &$this->_oConfig->CNF;
  737. $aResults = parent::_getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  738. if (count($aResults) == 0 && isset($CNF['PARAM_USE_GALERY_AS_COVER']) && getParam($CNF['PARAM_USE_GALERY_AS_COVER']) == 'on'){
  739. $aResults = $this->_getImagesForTimelinePostAttachInner($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  740. if (count($aResults) > 1){
  741. $aResults = array_slice($aResults, 0, 1);
  742. }
  743. }
  744. return $aResults;
  745. }
  746. protected function _getImagesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  747. {
  748. $CNF = &$this->_oConfig->CNF;
  749. $aTmp = parent::_getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  750. $aResults = $this->_getImagesForTimelinePostAttachInner($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  751. if (count($aTmp) == 0 && count($aResults) > 0 && isset($CNF['PARAM_USE_GALERY_AS_COVER']) && getParam($CNF['PARAM_USE_GALERY_AS_COVER']) == 'on'){
  752. $aResults = array_slice($aResults, 1);
  753. }
  754. return $aResults;
  755. }
  756. protected function _getImagesForTimelinePostAttachInner($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  757. {
  758. $CNF = &$this->_oConfig->CNF;
  759. $aResults = parent::_getImagesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  760. if(!$this->_oConfig->isAttachmentsInTimeline() || empty($CNF['OBJECT_STORAGE_PHOTOS']) || empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']))
  761. return $aResults;
  762. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  763. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_PHOTOS']);
  764. $aGhostFiles = $oStorage->getGhosts($this->serviceGetContentOwnerProfileId($iContentId), $iContentId);
  765. if(!$aGhostFiles)
  766. return [];
  767. $oTranscoderSm = false;
  768. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_MINIATURE_PHOTOS']))
  769. $oTranscoderSm = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_MINIATURE_PHOTOS']);
  770. $oTranscoderMd = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS']);
  771. $oTranscoderXl = false;
  772. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_VIEW_PHOTOS']))
  773. $oTranscoderXl = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_VIEW_PHOTOS']);
  774. foreach($aGhostFiles as $k => $a) {
  775. $sPhotoSrcMd = $oTranscoderMd->getFileUrl($a['id']);
  776. if(empty($sPhotoSrcMd))
  777. continue;
  778. $sPhotoSrcSm = $oTranscoderSm !== false ? $oTranscoderSm->getFileUrl($a['id']) : '';
  779. if(!$sPhotoSrcSm)
  780. $sPhotoSrcSm = $sPhotoSrcMd;
  781. $sPhotoSrcXl = $oTranscoderXl !== false ? $oTranscoderXl->getFileUrl($a['id']) : $oStorage->getFileUrlById($a['id']);
  782. if(!$sPhotoSrcXl)
  783. $sPhotoSrcXl = $sPhotoSrcMd;
  784. $aResults[] = [
  785. 'id' => $a['id'],
  786. 'src' => $sPhotoSrcMd,
  787. 'src_small' => $sPhotoSrcSm,
  788. 'src_medium' => $sPhotoSrcMd,
  789. 'src_orig' => $sPhotoSrcXl,
  790. ];
  791. }
  792. return $aResults;
  793. }
  794. protected function _getVideosForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  795. {
  796. $CNF = &$this->_oConfig->CNF;
  797. $aResults = parent::_getVideosForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  798. if(!$this->_oConfig->isAttachmentsInTimeline() || empty($CNF['OBJECT_STORAGE_VIDEOS']) || empty($CNF['OBJECT_VIDEOS_TRANSCODERS']))
  799. return $aResults;
  800. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  801. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_VIDEOS']);
  802. $aGhostFiles = $oStorage->getGhosts($this->serviceGetContentOwnerProfileId($iContentId), $iContentId);
  803. if(!$aGhostFiles)
  804. return array();
  805. $oTcPoster = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['poster']);
  806. $oTcMp4 = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4']);
  807. $oTcMp4Hd = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4_hd']);
  808. if(!$oTcPoster || !$oTcMp4 || !$oTcMp4Hd)
  809. return array();
  810. $aResults = array();
  811. foreach ($aGhostFiles as $k => $a) {
  812. $sVideoUrl = $oStorage->getFileUrlById($a['id']);
  813. $aVideoFile = $oStorage->getFile($a['id']);
  814. $sVideoUrlHd = '';
  815. if (!empty($aVideoFile['dimensions']) && $oTcMp4Hd->isProcessHD($aVideoFile['dimensions']))
  816. $sVideoUrlHd = $oTcMp4Hd->getFileUrl($a['id']);
  817. $aResults[$a['id']] = array(
  818. 'id' => $a['id'],
  819. 'src_poster' => $oTcPoster->getFileUrl($a['id']),
  820. 'src_mp4' => $oTcMp4->getFileUrl($a['id']),
  821. 'src_mp4_hd' => $sVideoUrlHd,
  822. );
  823. }
  824. return $aResults;
  825. }
  826. protected function _getFilesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  827. {
  828. $CNF = &$this->_oConfig->CNF;
  829. $aResults = parent::_getFilesForTimelinePostAttach($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  830. if(!$this->_oConfig->isAttachmentsInTimeline() || empty($CNF['OBJECT_STORAGE_FILES']))
  831. return $aResults;
  832. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  833. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_FILES']);
  834. $aGhostFiles = $oStorage->getGhosts($this->serviceGetContentOwnerProfileId($iContentId), $iContentId);
  835. if(!$aGhostFiles)
  836. return array();
  837. $oTranscoder = null;
  838. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']))
  839. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY_FILES']);
  840. foreach ($aGhostFiles as $k => $a) {
  841. $bImage = in_array($a['ext'], array('jpg', 'jpeg', 'png', 'gif'));
  842. $sPhotoSrc = '';
  843. if($bImage && $oTranscoder)
  844. $sPhotoSrc = $oTranscoder->getFileUrl($a['id']);
  845. if(empty($sPhotoSrc) && $oStorage)
  846. $sPhotoSrc = $this->_oTemplate->getIconUrl($oStorage->getIconNameByFileName($a['file_name']));
  847. $sUrl = $oStorage->getFileUrlById($a['id']);
  848. $aResults[] = array(
  849. 'id' => $a['id'],
  850. 'src' => $sPhotoSrc,
  851. 'src_medium' => $sPhotoSrc,
  852. 'src_orig' => $bImage ? $sUrl : '',
  853. 'url' => !$bImage ? $sUrl : ''
  854. );
  855. }
  856. return $aResults;
  857. }
  858. protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
  859. {
  860. $aResult = parent::_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams);
  861. if(!$this->_oConfig->isAttachmentsInTimeline())
  862. return $aResult;
  863. $CNF = &$this->_oConfig->CNF;
  864. $bDynamic = isset($aBrowseParams['dynamic_mode']) && (bool)$aBrowseParams['dynamic_mode'] === true;
  865. if(!empty($CNF['PARAM_POLL_ENABLED']) && $CNF['PARAM_POLL_ENABLED'] == true)
  866. $aPolls = $this->_oDb->getPolls(array('type' => 'content_id', 'content_id' => (int)$aContentInfo[$CNF['FIELD_ID']]));
  867. if(!empty($aPolls) && is_array($aPolls)) {
  868. $sInclude = $this->_oTemplate->addCss(array('polls.css'), $bDynamic);
  869. $aResult['raw'] = ($bDynamic ? $sInclude : '') . $this->_oTemplate->parseHtmlByName('poll_items_embed.html', array(
  870. 'embed_url' => BX_DOL_URL_ROOT . bx_append_url_params($this->_oConfig->getBaseUri() . 'embed_polls/', array(
  871. 'id' => (int)$aContentInfo[$CNF['FIELD_ID']],
  872. 'param_switch_menu' => 0,
  873. 'param_showcase' => 1
  874. ))
  875. ));
  876. /*
  877. if((!empty($aResult['videos']) && is_array($aResult['videos'])) || (!empty($aResult['videos_attach']) && is_array($aResult['videos_attach'])))
  878. $aResult['_cache'] = false;
  879. */
  880. }
  881. return $aResult;
  882. }
  883. protected function _buildRssParams($sMode, $aArgs)
  884. {
  885. $aParams = array ();
  886. $sMode = bx_process_input($sMode);
  887. switch ($sMode) {
  888. case 'author':
  889. $aParams = array('author' => isset($aArgs[0]) ? (int)$aArgs[0] : '');
  890. break;
  891. }
  892. return $aParams;
  893. }
  894. public function serviceIsAllowedPostInContext()
  895. {
  896. return true;
  897. }
  898. }
  899. /** @} */