BxBaseModGeneralMenuViewActions.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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 $oObject->getElementApi($aObjectOptions);
  289. $sResult = $oObject->getElementBlock($aObjectOptions);
  290. if(empty($sResult))
  291. return '';
  292. return array($sResult, $this->_sClassMiSa);
  293. }
  294. protected function _getMenuItemFeature($aItem, $aParams = array())
  295. {
  296. $CNF = &$this->_oModule->_oConfig->CNF;
  297. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  298. if(empty($sObject) && !empty($CNF['OBJECT_FEATURED']))
  299. $sObject = $CNF['OBJECT_FEATURED'];
  300. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  301. if(empty($iId))
  302. $iId = $this->_iContentId;
  303. if(!$this->_isContentPublic($iId))
  304. return '';
  305. $oObject = !empty($sObject) ? BxDolFeature::getObjectInstance($sObject, $iId) : false;
  306. if(!$oObject || !$oObject->isEnabled())
  307. return '';
  308. $aObjectOptions = array(
  309. 'dynamic_mode' => $this->_bDynamicMode,
  310. 'show_do_feature_as_button' => $this->_bShowAsButton,
  311. 'show_do_feature_label' => $this->_bShowTitle
  312. );
  313. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  314. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  315. if($this->_bIsApi)
  316. return $oObject->getElementApi($aObjectOptions);
  317. $sResult = $oObject->getElementBlock($aObjectOptions);
  318. if(empty($sResult))
  319. return '';
  320. return array($sResult, $this->_sClassMiSa);
  321. }
  322. protected function _getMenuItemRepost($aItem, $aParams = array())
  323. {
  324. $CNF = &$this->_oModule->_oConfig->CNF;
  325. $sAction = !empty($aParams['action']) ? $aParams['action'] : '';
  326. if(empty($sAction))
  327. $sAction = 'added';
  328. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  329. if(empty($iId))
  330. $iId = $this->_iContentId;
  331. $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iId);
  332. if(!empty($CNF['FIELD_PUBLISHED']) && isset($aContentInfo[$CNF['FIELD_PUBLISHED']]) && (int)$aContentInfo[$CNF['FIELD_PUBLISHED']] > time())
  333. return '';
  334. 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)))
  335. return '';
  336. $sStatus = 'active';
  337. if(!empty($CNF['FIELD_STATUS']) && isset($aContentInfo[$CNF['FIELD_STATUS']]) && $aContentInfo[$CNF['FIELD_STATUS']] != $sStatus)
  338. return '';
  339. if(!empty($CNF['FIELD_STATUS_ADMIN']) && isset($aContentInfo[$CNF['FIELD_STATUS_ADMIN']]) && $aContentInfo[$CNF['FIELD_STATUS_ADMIN']] != $sStatus)
  340. return '';
  341. $sRepostDo = !empty($aParams['do']) ? $aParams['do'] : 'repost';
  342. $aRepostParams = [
  343. 'do' => $sRepostDo,
  344. 'show_do_repost_as_button' => $this->_bShowAsButton,
  345. 'show_do_repost_text' => $this->_bShowTitle
  346. ];
  347. if(!empty($aItem['title']))
  348. $aRepostParams['text_do_' . $sRepostDo] = $aItem['title'];
  349. if(!empty($aItem['icon']))
  350. $aRepostParams['icon_do_' . $sRepostDo] = $aItem['icon'];
  351. $aSrvParams = [bx_get_logged_profile_id(), $this->_oModule->_oConfig->getName(), $sAction, $iId, $aRepostParams];
  352. if($this->_bIsApi && bx_is_srv('bx_timeline', 'get_repost_element_block_api'))
  353. return bx_srv('bx_timeline', 'get_repost_element_block_api', $aSrvParams);
  354. if(!bx_is_srv('bx_timeline', 'get_repost_element_block'))
  355. return '';
  356. $sResult = bx_srv('bx_timeline', 'get_repost_element_block', $aSrvParams);
  357. if(empty($sResult))
  358. return '';
  359. return array($sResult, $this->_sClassMiSa);
  360. }
  361. protected function _getMenuItemRepostWithText($aItem, $aParams = [])
  362. {
  363. return $this->_getMenuItemRepost($aItem, array_merge($aParams, [
  364. 'do' => 'repost_with'
  365. ]));
  366. }
  367. protected function _getMenuItemRepostToContext($aItem, $aParams = [])
  368. {
  369. return $this->_getMenuItemRepost($aItem, array_merge($aParams, [
  370. 'do' => 'repost_to'
  371. ]));
  372. }
  373. protected function _getMenuItemReport($aItem, $aParams = array())
  374. {
  375. $CNF = &$this->_oModule->_oConfig->CNF;
  376. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  377. if(empty($sObject) && !empty($CNF['OBJECT_REPORTS']))
  378. $sObject = $CNF['OBJECT_REPORTS'];
  379. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  380. if(empty($iId))
  381. $iId = $this->_iContentId;
  382. $oObject = !empty($sObject) ? BxDolReport::getObjectInstance($sObject, $iId) : false;
  383. if(!$oObject || !$oObject->isEnabled())
  384. return '';
  385. $aObjectOptions = array(
  386. 'dynamic_mode' => $this->_bDynamicMode,
  387. 'show_do_report_as_button' => $this->_bShowAsButton,
  388. 'show_do_report_label' => $this->_bShowTitle
  389. );
  390. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  391. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  392. if($this->_bIsApi)
  393. return [
  394. 'id' => $aItem['id'],
  395. 'name' => $aItem['name'],
  396. 'display_type' => 'element',
  397. 'data' => $oObject->getElementApi($aObjectOptions)
  398. ];
  399. $sResult = $oObject->getElementBlock($aObjectOptions);
  400. if(empty($sResult))
  401. return '';
  402. return array($sResult, $this->_sClassMiSa);
  403. }
  404. protected function _getMenuItemNotes($aItem, $aParams = array())
  405. {
  406. $CNF = &$this->_oModule->_oConfig->CNF;
  407. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  408. if(empty($sObject) && !empty($CNF['OBJECT_NOTES']))
  409. $sObject = $CNF['OBJECT_NOTES'];
  410. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  411. if(empty($iId))
  412. $iId = $this->_iContentId;
  413. if(!$this->_oModule->_isModerator())
  414. return false;
  415. $this->addMarkers(array(
  416. 'content_id' => $iId
  417. ));
  418. return true;
  419. }
  420. protected function _getMenuItemByNameActions($aItem, $aParams = array())
  421. {
  422. $CNF = &$this->_oModule->_oConfig->CNF;
  423. if(empty($this->_oMenuActions)) {
  424. $sObjectMenu = !empty($aParams['object_menu']) ? $aParams['object_menu'] : '';
  425. if(empty($sObjectMenu) && !empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']))
  426. $sObjectMenu = $CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'];
  427. if(empty($sObjectMenu))
  428. return '';
  429. $this->_oMenuActions = BxDolMenu::getObjectInstance($sObjectMenu);
  430. if(!$this->_oMenuActions)
  431. return '';
  432. $this->_oMenuActions->setContentId($this->_iContentId);
  433. $this->addMarkers($this->_oMenuActions->getMarkers());
  434. }
  435. $aItem = $this->_oMenuActions->getMenuItem($aItem['name']);
  436. if(empty($aItem) || !is_array($aItem))
  437. return false;
  438. if($this->_bIsApi)
  439. return $aItem;
  440. else
  441. return $this->_getMenuItemDefault($aItem);
  442. }
  443. protected function _getMenuItemByNameSocialSharing($aItem, $aParams = array())
  444. {
  445. if(empty($this->_oMenuSocialSharing) && !$this->_initMenuSocialSharing())
  446. return false;
  447. $aItem = $this->_oMenuSocialSharing->getMenuItem($aItem['name']);
  448. if(empty($aItem) || !is_array($aItem))
  449. return false;
  450. if($this->_bIsApi)
  451. return $aItem;
  452. else
  453. return $this->_getMenuItemDefault($aItem);
  454. }
  455. protected function _getMenuItemByNameActionDelete($aItem)
  456. {
  457. $oProfile = $this->_oModule->getProfileObject(($this->_iContentId));
  458. if (!$this->_oModule->isAllowDeleteOrDisable(bx_get_logged_profile_id(), $oProfile->id()))
  459. return false;
  460. return $this->_getMenuItemByNameActionsMore($aItem);
  461. }
  462. protected function _getMenuItemByNameActionsMore($aItem)
  463. {
  464. $CNF = &$this->_oModule->_oConfig->CNF;
  465. if(empty($this->_oMenuActionsMore)) {
  466. if(empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']))
  467. return '';
  468. $this->_oMenuActionsMore = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']);
  469. if(!$this->_oMenuActionsMore)
  470. return '';
  471. $this->_oMenuActionsMore->setContentId($this->_iContentId);
  472. $this->addMarkers($this->_oMenuActionsMore->getMarkers());
  473. }
  474. $aItem = $this->_oMenuActionsMore->getMenuItem($aItem['name']);
  475. if(empty($aItem) || !is_array($aItem))
  476. return false;
  477. if($this->_bIsApi)
  478. return $aItem;
  479. else
  480. return $this->_getMenuItemDefault($aItem);
  481. }
  482. }
  483. /** @} */