BxBaseModGeneralMenuViewActions.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  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('BxDolPrivacy');
  12. /**
  13. * View entry social actions menu
  14. */
  15. class BxBaseModGeneralMenuViewActions extends BxTemplMenuCustom
  16. {
  17. protected $_sModule;
  18. protected $_oModule;
  19. protected $_oMenuActions;
  20. protected $_oMenuActionsMore;
  21. protected $_oMenuSocialSharing;
  22. protected $_iContentId;
  23. protected $_aContentInfo;
  24. protected $_bDynamicMode;
  25. protected $_bShowAsButton;
  26. protected $_bShowTitle;
  27. protected $_sClassMiSa; // Separate class for Social Actions (View, Vote, Comment, Report, etc) menu items.
  28. public function __construct($aObject, $oTemplate = false)
  29. {
  30. parent::__construct($aObject, $oTemplate);
  31. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  32. $this->setContentId(bx_process_input(bx_get('id'), BX_DATA_INT));
  33. $this->_oMenuActions = null;
  34. $this->_oMenuActionsMore = null;
  35. $this->_oMenuSocialSharing = null;
  36. $this->_sTmplContent = $this->_oTemplate->getHtml($this->getTemplateName('menu_custom_actions.html'));
  37. $this->_sTmplContentItem = $this->_oTemplate->getHtml($this->getTemplateNameItem('menu_custom_item_actions.html'));
  38. $this->_bShowAsButton = true;
  39. $this->_bShowTitle = true;
  40. $this->_sClassMiSa = 'bx-base-general-ea-sa';
  41. $this->addMarkers(array(
  42. 'module' => $this->_oModule->_oConfig->getName(),
  43. 'module_uri' => $this->_oModule->_oConfig->getUri(),
  44. ));
  45. }
  46. public function addMarkers($a)
  47. {
  48. $bResult = parent::addMarkers($a);
  49. if($bResult) {
  50. if(empty($this->_oMenuSocialSharing))
  51. $this->_initMenuSocialSharing();
  52. //it still may be false in case the sys_social_sharing menu is turned off
  53. if (!empty($this->_oMenuSocialSharing)) {
  54. $this->_oMenuSocialSharing->addMarkers($a);
  55. parent::addMarkers($this->_oMenuSocialSharing->getMarkers());
  56. }
  57. }
  58. return $bResult;
  59. }
  60. public function setContentId($iContentId)
  61. {
  62. $this->_iContentId = (int)$iContentId;
  63. $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iContentId);
  64. if($this->_aContentInfo)
  65. $this->addMarkers(array('content_id' => (int)$this->_iContentId));
  66. }
  67. public function setShowAsButton($bShowAsButton)
  68. {
  69. $this->_bShowAsButton = $bShowAsButton;
  70. }
  71. /**
  72. * Check if menu items is visible with extended checking linked to "allow*" method of particular module
  73. * Associated "allow*" method with particular menu item is stored in module config in MENU_ITEM_TO_METHOD array.
  74. * @param $a menu item array
  75. * @return boolean
  76. */
  77. protected function _isVisible($a)
  78. {
  79. if(!parent::_isVisible($a))
  80. return false;
  81. return $this->_oModule->isMenuItemVisible($this->_sObject, $a, $this->_aContentInfo);
  82. }
  83. protected function _isContentPublic($iContentId, $aPublicGroups = [])
  84. {
  85. $CNF = &$this->_oModule->_oConfig->CNF;
  86. if(empty($CNF['FIELD_ALLOW_VIEW_TO']))
  87. return true;
  88. $aContentInfo = $iContentId == $this->_iContentId ? $this->_aContentInfo : $this->_oModule->_oDb->getContentInfoById($iContentId);
  89. if(!isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
  90. return true;
  91. if(empty($aPublicGroups))
  92. $aPublicGroups = [BX_DOL_PG_ALL, BX_DOL_PG_MEMBERS];
  93. return in_array($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']], $aPublicGroups);
  94. }
  95. protected function _initMenuSocialSharing()
  96. {
  97. $this->_oMenuSocialSharing = BxDolMenu::getObjectInstance('sys_social_sharing');
  98. if(!$this->_oMenuSocialSharing)
  99. return false;
  100. /**
  101. * Adding current markers to social sharing menu object to force it to generate its own markers.
  102. * Getting generated social sharing markers back and adding all of them to current menu object. So, now these markers can be parsed for any menu item.
  103. */
  104. $this->_oMenuSocialSharing->addMarkers($this->_aMarkers);
  105. $this->addMarkers($this->_oMenuSocialSharing->getMarkers());
  106. return true;
  107. }
  108. protected function _getMenuItemDefault($aItem)
  109. {
  110. if(empty($this->_oMenuSocialSharing))
  111. $this->_initMenuSocialSharing();
  112. $aItem['class_wrp'] = 'bx-base-general-entity-action' . (!empty($aItem['class_wrp']) ? ' ' . $aItem['class_wrp'] : '');
  113. if($this->_bShowAsButton)
  114. $aItem['class_link'] = 'bx-btn' . (isset($aItem['primary']) && (int)$aItem['primary'] == 1 ? ' bx-btn-primary' : '') . (!empty($aItem['class_link']) ? ' ' . $aItem['class_link'] : '');
  115. if(!$this->_bShowTitle)
  116. $aItem['bx_if:title']['condition'] = false;
  117. if($this->_bIsApi)
  118. return $aItem;
  119. else
  120. return parent::_getMenuItemDefault ($aItem);
  121. }
  122. protected function _getMenuItemView($aItem, $aParams = array())
  123. {
  124. $CNF = &$this->_oModule->_oConfig->CNF;
  125. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  126. if(empty($sObject) && !empty($CNF['OBJECT_VIEWS']))
  127. $sObject = $CNF['OBJECT_VIEWS'];
  128. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  129. if(empty($iId))
  130. $iId = $this->_iContentId;
  131. $oObject = !empty($sObject) ? BxDolView::getObjectInstance($sObject, $iId) : false;
  132. if(!$oObject || !$oObject->isEnabled())
  133. return '';
  134. $aObjectOptions = array(
  135. 'dynamic_mode' => $this->_bDynamicMode,
  136. 'show_do_view_as_button' => $this->_bShowAsButton,
  137. 'show_do_view_label' => $this->_bShowTitle
  138. );
  139. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  140. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  141. if($this->_bIsApi)
  142. return $oObject->getElementApi($aObjectOptions);
  143. $sResult = $oObject->getElementBlock($aObjectOptions);
  144. if(empty($sResult))
  145. return '';
  146. return array($sResult, $this->_sClassMiSa);
  147. }
  148. protected function _getMenuItemComment($aItem, $aParams = array())
  149. {
  150. $CNF = &$this->_oModule->_oConfig->CNF;
  151. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  152. if(empty($sObject) && !empty($CNF['OBJECT_COMMENTS']))
  153. $sObject = $CNF['OBJECT_COMMENTS'];
  154. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  155. if(empty($iId))
  156. $iId = $this->_iContentId;
  157. $oObject = !empty($sObject) ? BxTemplCmts::getObjectInstance($sObject, $iId) : false;
  158. if(!$oObject || !$oObject->isEnabled())
  159. return '';
  160. $aObjectOptions = array(
  161. 'dynamic_mode' => $this->_bDynamicMode,
  162. 'show_do_comment_as_button' => $this->_bShowAsButton,
  163. 'show_do_comment_label' => $this->_bShowTitle,
  164. 'show_counter' => false
  165. );
  166. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  167. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  168. if($this->_bIsApi)
  169. return $oObject->getElementApi($aObjectOptions);
  170. $sResult = $oObject->getElementBlock($aObjectOptions);
  171. if(empty($sResult))
  172. return '';
  173. return array($sResult, $this->_sClassMiSa);
  174. }
  175. protected function _getMenuItemVote($aItem, $aParams = array())
  176. {
  177. $CNF = &$this->_oModule->_oConfig->CNF;
  178. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  179. if(empty($sObject) && !empty($CNF['OBJECT_VOTES']))
  180. $sObject = $CNF['OBJECT_VOTES'];
  181. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  182. if(empty($iId))
  183. $iId = $this->_iContentId;
  184. $oObject = !empty($sObject) ? BxDolVote::getObjectInstance($sObject, $iId) : false;
  185. if(!$oObject || !$oObject->isEnabled())
  186. return '';
  187. $aObjectOptions = array(
  188. 'dynamic_mode' => $this->_bDynamicMode,
  189. 'show_do_vote_as_button' => $this->_bShowAsButton,
  190. 'show_do_vote_label' => $this->_bShowTitle
  191. );
  192. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  193. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  194. if($this->_bIsApi)
  195. return [
  196. 'id' => $aItem['id'],
  197. 'name' => $aItem['name'],
  198. 'display_type' => 'element',
  199. 'data' => $oObject->getElementApi($aObjectOptions)
  200. ];
  201. $sResult = $oObject->getElementBlock($aObjectOptions);
  202. if(empty($sResult))
  203. return '';
  204. return array($sResult, $this->_sClassMiSa);
  205. }
  206. protected function _getMenuItemReaction($aItem, $aParams = array())
  207. {
  208. $CNF = &$this->_oModule->_oConfig->CNF;
  209. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  210. if(empty($sObject) && !empty($CNF['OBJECT_REACTIONS']))
  211. $sObject = $CNF['OBJECT_REACTIONS'];
  212. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  213. if(empty($iId))
  214. $iId = $this->_iContentId;
  215. $oObject = !empty($sObject) ? BxDolVote::getObjectInstance($sObject, $iId) : false;
  216. if(!$oObject || !$oObject->isEnabled())
  217. return '';
  218. $aObjectOptions = array(
  219. 'dynamic_mode' => $this->_bDynamicMode,
  220. 'show_do_vote_as_button' => $this->_bShowAsButton,
  221. 'show_do_vote_label' => $this->_bShowTitle
  222. );
  223. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  224. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  225. if($this->_bIsApi)
  226. return [
  227. 'id' => $aItem['id'],
  228. 'name' => $aItem['name'],
  229. 'display_type' => 'element',
  230. 'data' => $oObject->getElementApi($aObjectOptions)
  231. ];
  232. $sResult = $oObject->getElementBlock($aObjectOptions);
  233. if(empty($sResult))
  234. return '';
  235. return array($sResult, $this->_sClassMiSa);
  236. }
  237. protected function _getMenuItemScore($aItem, $aParams = array())
  238. {
  239. $CNF = &$this->_oModule->_oConfig->CNF;
  240. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  241. if(empty($sObject) && !empty($CNF['OBJECT_SCORES']))
  242. $sObject = $CNF['OBJECT_SCORES'];
  243. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  244. if(empty($iId))
  245. $iId = $this->_iContentId;
  246. $oObject = !empty($sObject) ? BxDolScore::getObjectInstance($sObject, $iId) : false;
  247. if(!$oObject || !$oObject->isEnabled())
  248. return '';
  249. $aObjectOptions = array(
  250. 'dynamic_mode' => $this->_bDynamicMode,
  251. 'show_do_vote_as_button' => $this->_bShowAsButton,
  252. 'show_do_vote_label' => $this->_bShowTitle
  253. );
  254. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  255. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  256. if($this->_bIsApi)
  257. return [
  258. 'id' => $aItem['id'],
  259. 'name' => $aItem['name'],
  260. 'display_type' => 'element',
  261. 'data' => $oObject->getElementApi($aObjectOptions)
  262. ];
  263. $sResult = $oObject->getElementBlock($aObjectOptions);
  264. if(empty($sResult))
  265. return '';
  266. return array($sResult, $this->_sClassMiSa);
  267. }
  268. protected function _getMenuItemFavorite($aItem, $aParams = array())
  269. {
  270. $CNF = &$this->_oModule->_oConfig->CNF;
  271. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  272. if(empty($sObject) && !empty($CNF['OBJECT_FAVORITES']))
  273. $sObject = $CNF['OBJECT_FAVORITES'];
  274. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  275. if(empty($iId))
  276. $iId = $this->_iContentId;
  277. $oObject = !empty($sObject) ? BxDolFavorite::getObjectInstance($sObject, $iId) : false;
  278. if(!$oObject || !$oObject->isEnabled())
  279. return '';
  280. $aObjectOptions = array(
  281. 'dynamic_mode' => $this->_bDynamicMode,
  282. 'show_do_favorite_as_button' => $this->_bShowAsButton,
  283. 'show_do_favorite_label' => $this->_bShowTitle
  284. );
  285. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  286. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  287. if($this->_bIsApi)
  288. return [
  289. 'id' => $aItem['id'],
  290. 'name' => $aItem['name'],
  291. 'display_type' => 'element',
  292. 'data' => $oObject->getElementApi($aObjectOptions)
  293. ];
  294. $sResult = $oObject->getElementBlock($aObjectOptions);
  295. if(empty($sResult))
  296. return '';
  297. return array($sResult, $this->_sClassMiSa);
  298. }
  299. protected function _getMenuItemFeature($aItem, $aParams = array())
  300. {
  301. $CNF = &$this->_oModule->_oConfig->CNF;
  302. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  303. if(empty($sObject) && !empty($CNF['OBJECT_FEATURED']))
  304. $sObject = $CNF['OBJECT_FEATURED'];
  305. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  306. if(empty($iId))
  307. $iId = $this->_iContentId;
  308. if(!$this->_isContentPublic($iId))
  309. return '';
  310. $oObject = !empty($sObject) ? BxDolFeature::getObjectInstance($sObject, $iId) : false;
  311. if(!$oObject || !$oObject->isEnabled())
  312. return '';
  313. $aObjectOptions = array(
  314. 'dynamic_mode' => $this->_bDynamicMode,
  315. 'show_do_feature_as_button' => $this->_bShowAsButton,
  316. 'show_do_feature_label' => $this->_bShowTitle
  317. );
  318. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  319. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  320. if($this->_bIsApi)
  321. return [
  322. 'id' => $aItem['id'],
  323. 'name' => $aItem['name'],
  324. 'display_type' => 'element',
  325. 'data' => $oObject->getElementApi($aObjectOptions)
  326. ];
  327. $sResult = $oObject->getElementBlock($aObjectOptions);
  328. if(empty($sResult))
  329. return '';
  330. return array($sResult, $this->_sClassMiSa);
  331. }
  332. protected function _getMenuItemRepost($aItem, $aParams = array())
  333. {
  334. $CNF = &$this->_oModule->_oConfig->CNF;
  335. $sAction = !empty($aParams['action']) ? $aParams['action'] : '';
  336. if(empty($sAction))
  337. $sAction = 'added';
  338. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  339. if(empty($iId))
  340. $iId = $this->_iContentId;
  341. $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iId);
  342. if(!empty($CNF['FIELD_PUBLISHED']) && isset($aContentInfo[$CNF['FIELD_PUBLISHED']]) && (int)$aContentInfo[$CNF['FIELD_PUBLISHED']] > time())
  343. return '';
  344. if(!empty($CNF['FIELD_ALLOW_VIEW_TO']) && isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) && (int)$aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] > 0 && !in_array((int)$aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']], array(BX_DOL_PG_ALL, BX_DOL_PG_MEMBERS)))
  345. return '';
  346. $sStatus = 'active';
  347. if(!empty($CNF['FIELD_STATUS']) && isset($aContentInfo[$CNF['FIELD_STATUS']]) && $aContentInfo[$CNF['FIELD_STATUS']] != $sStatus)
  348. return '';
  349. if(!empty($CNF['FIELD_STATUS_ADMIN']) && isset($aContentInfo[$CNF['FIELD_STATUS_ADMIN']]) && $aContentInfo[$CNF['FIELD_STATUS_ADMIN']] != $sStatus)
  350. return '';
  351. $sRepostDo = !empty($aParams['do']) ? $aParams['do'] : 'repost';
  352. $aRepostParams = [
  353. 'do' => $sRepostDo,
  354. 'show_do_repost_as_button' => $this->_bShowAsButton,
  355. 'show_do_repost_text' => $this->_bShowTitle
  356. ];
  357. if(!empty($aItem['title']))
  358. $aRepostParams['text_do_' . $sRepostDo] = $aItem['title'];
  359. if(!empty($aItem['icon']))
  360. $aRepostParams['icon_do_' . $sRepostDo] = $aItem['icon'];
  361. $aSrvParams = [bx_get_logged_profile_id(), $this->_oModule->_oConfig->getName(), $sAction, $iId, $aRepostParams];
  362. if($this->_bIsApi && bx_is_srv('bx_timeline', 'get_repost_element_block_api'))
  363. return [
  364. 'id' => $aItem['id'],
  365. 'name' => $aItem['name'],
  366. 'display_type' => 'element',
  367. 'data' => bx_srv('bx_timeline', 'get_repost_element_block_api', $aSrvParams)
  368. ];
  369. if(!bx_is_srv('bx_timeline', 'get_repost_element_block'))
  370. return '';
  371. $sResult = bx_srv('bx_timeline', 'get_repost_element_block', $aSrvParams);
  372. if(empty($sResult))
  373. return '';
  374. return array($sResult, $this->_sClassMiSa);
  375. }
  376. protected function _getMenuItemRepostWithText($aItem, $aParams = [])
  377. {
  378. return $this->_getMenuItemRepost($aItem, array_merge($aParams, [
  379. 'do' => 'repost_with'
  380. ]));
  381. }
  382. protected function _getMenuItemRepostToContext($aItem, $aParams = [])
  383. {
  384. return $this->_getMenuItemRepost($aItem, array_merge($aParams, [
  385. 'do' => 'repost_to'
  386. ]));
  387. }
  388. protected function _getMenuItemReport($aItem, $aParams = array())
  389. {
  390. $CNF = &$this->_oModule->_oConfig->CNF;
  391. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  392. if(empty($sObject) && !empty($CNF['OBJECT_REPORTS']))
  393. $sObject = $CNF['OBJECT_REPORTS'];
  394. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  395. if(empty($iId))
  396. $iId = $this->_iContentId;
  397. $oObject = !empty($sObject) ? BxDolReport::getObjectInstance($sObject, $iId) : false;
  398. if(!$oObject || !$oObject->isEnabled())
  399. return '';
  400. $aObjectOptions = array(
  401. 'dynamic_mode' => $this->_bDynamicMode,
  402. 'show_do_report_as_button' => $this->_bShowAsButton,
  403. 'show_do_report_label' => $this->_bShowTitle
  404. );
  405. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  406. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  407. if($this->_bIsApi)
  408. return [
  409. 'id' => $aItem['id'],
  410. 'name' => $aItem['name'],
  411. 'display_type' => 'element',
  412. 'data' => $oObject->getElementApi($aObjectOptions)
  413. ];
  414. $sResult = $oObject->getElementBlock($aObjectOptions);
  415. if(empty($sResult))
  416. return '';
  417. return array($sResult, $this->_sClassMiSa);
  418. }
  419. protected function _getMenuItemSocialSharing($aItem, $aParams = array())
  420. {
  421. if(!$this->_bIsApi)
  422. return true;
  423. if(empty($this->_oMenuSocialSharing) && !$this->_initMenuSocialSharing())
  424. return [];
  425. return [
  426. 'id' => $aItem['id'],
  427. 'name' => $aItem['name'],
  428. 'display_type' => 'element',
  429. 'data' => [
  430. 'type' => 'shares',
  431. 'system' => $this->_sModule,
  432. 'object_id' => $this->_iContentId,
  433. 'params' => [],
  434. 'action' => [
  435. 'url' => bx_replace_markers('{url_encoded}', $this->_aMarkers)
  436. ]
  437. ]
  438. ];
  439. }
  440. protected function _getMenuItemNotes($aItem, $aParams = array())
  441. {
  442. $CNF = &$this->_oModule->_oConfig->CNF;
  443. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  444. if(empty($sObject) && !empty($CNF['OBJECT_NOTES']))
  445. $sObject = $CNF['OBJECT_NOTES'];
  446. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  447. if(empty($iId))
  448. $iId = $this->_iContentId;
  449. if(!$this->_oModule->_isModerator())
  450. return false;
  451. $this->addMarkers(array(
  452. 'content_id' => $iId
  453. ));
  454. return true;
  455. }
  456. protected function _getMenuItemByNameActions($aItem, $aParams = array())
  457. {
  458. $CNF = &$this->_oModule->_oConfig->CNF;
  459. if(empty($this->_oMenuActions)) {
  460. $sObjectMenu = !empty($aParams['object_menu']) ? $aParams['object_menu'] : '';
  461. if(empty($sObjectMenu) && !empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']))
  462. $sObjectMenu = $CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'];
  463. if(empty($sObjectMenu))
  464. return '';
  465. $this->_oMenuActions = BxDolMenu::getObjectInstance($sObjectMenu);
  466. if(!$this->_oMenuActions)
  467. return '';
  468. $this->_oMenuActions->setContentId($this->_iContentId);
  469. $this->addMarkers($this->_oMenuActions->getMarkers());
  470. }
  471. $aItem = $this->_oMenuActions->getMenuItem($aItem['name']);
  472. if(empty($aItem) || !is_array($aItem))
  473. return false;
  474. if($this->_bIsApi)
  475. return $aItem;
  476. else
  477. return $this->_getMenuItemDefault($aItem);
  478. }
  479. protected function _getMenuItemByNameSocialSharing($aItem, $aParams = array())
  480. {
  481. if(empty($this->_oMenuSocialSharing) && !$this->_initMenuSocialSharing())
  482. return false;
  483. $aItem = $this->_oMenuSocialSharing->getMenuItem($aItem['name']);
  484. if(empty($aItem) || !is_array($aItem))
  485. return false;
  486. if($this->_bIsApi)
  487. return $aItem;
  488. else
  489. return $this->_getMenuItemDefault($aItem);
  490. }
  491. protected function _getMenuItemByNameActionDelete($aItem)
  492. {
  493. $oProfile = $this->_oModule->getProfileObject(($this->_iContentId));
  494. if (!$this->_oModule->isAllowDeleteOrDisable(bx_get_logged_profile_id(), $oProfile->id()))
  495. return false;
  496. return $this->_getMenuItemByNameActionsMore($aItem);
  497. }
  498. protected function _getMenuItemByNameActionsMore($aItem)
  499. {
  500. $CNF = &$this->_oModule->_oConfig->CNF;
  501. if(empty($this->_oMenuActionsMore)) {
  502. if(empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']))
  503. return '';
  504. $this->_oMenuActionsMore = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']);
  505. if(!$this->_oMenuActionsMore)
  506. return '';
  507. $this->_oMenuActionsMore->setContentId($this->_iContentId);
  508. $this->addMarkers($this->_oMenuActionsMore->getMarkers());
  509. }
  510. $aItem = $this->_oMenuActionsMore->getMenuItem($aItem['name']);
  511. if(empty($aItem) || !is_array($aItem))
  512. return false;
  513. if($this->_bIsApi)
  514. return $aItem;
  515. else
  516. return $this->_getMenuItemDefault($aItem);
  517. }
  518. }
  519. /** @} */