BxBaseModGeneralMenuViewActions.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. if(($mixedResult = $this->_rewriteMenuItem($aItem)) !== false)
  113. return $mixedResult;
  114. if($this->_bIsApi)
  115. return $aItem;
  116. $aItem['class_wrp'] = 'bx-base-general-entity-action' . (!empty($aItem['class_wrp']) ? ' ' . $aItem['class_wrp'] : '');
  117. if($this->_bShowAsButton)
  118. $aItem['class_link'] = 'bx-btn' . (isset($aItem['primary']) && (int)$aItem['primary'] == 1 ? ' bx-btn-primary' : '') . (!empty($aItem['class_link']) ? ' ' . $aItem['class_link'] : '');
  119. if(!$this->_bShowTitle)
  120. $aItem['bx_if:title']['condition'] = false;
  121. return parent::_getMenuItemDefault ($aItem);
  122. }
  123. protected function _getMenuItemDefaultApi($aItem)
  124. {
  125. if(($mixedResult = $this->_rewriteMenuItem($aItem)) !== false)
  126. return $mixedResult;
  127. return parent::_getMenuItemDefaultApi($aItem);
  128. }
  129. protected function _getMenuItemView($aItem, $aParams = array())
  130. {
  131. $CNF = &$this->_oModule->_oConfig->CNF;
  132. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  133. if(empty($sObject) && !empty($CNF['OBJECT_VIEWS']))
  134. $sObject = $CNF['OBJECT_VIEWS'];
  135. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  136. if(empty($iId))
  137. $iId = $this->_iContentId;
  138. $oObject = !empty($sObject) ? BxDolView::getObjectInstance($sObject, $iId) : false;
  139. if(!$oObject || !$oObject->isEnabled())
  140. return '';
  141. $aObjectOptions = array(
  142. 'dynamic_mode' => $this->_bDynamicMode,
  143. 'show_do_view_as_button' => $this->_bShowAsButton,
  144. 'show_do_view_label' => $this->_bShowTitle
  145. );
  146. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  147. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  148. if($this->_bIsApi)
  149. return $oObject->getElementApi($aObjectOptions);
  150. $sResult = $oObject->getElementBlock($aObjectOptions);
  151. if(empty($sResult))
  152. return '';
  153. return array($sResult, $this->_sClassMiSa);
  154. }
  155. protected function _getMenuItemComment($aItem, $aParams = array())
  156. {
  157. $CNF = &$this->_oModule->_oConfig->CNF;
  158. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  159. if(empty($sObject) && !empty($CNF['OBJECT_COMMENTS']))
  160. $sObject = $CNF['OBJECT_COMMENTS'];
  161. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  162. if(empty($iId))
  163. $iId = $this->_iContentId;
  164. $oObject = !empty($sObject) ? BxTemplCmts::getObjectInstance($sObject, $iId) : false;
  165. if(!$oObject || !$oObject->isEnabled())
  166. return '';
  167. $aObjectOptions = array(
  168. 'dynamic_mode' => $this->_bDynamicMode,
  169. 'show_do_comment_as_button' => $this->_bShowAsButton,
  170. 'show_do_comment_label' => $this->_bShowTitle,
  171. 'show_counter' => false
  172. );
  173. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  174. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  175. if($this->_bIsApi)
  176. return $oObject->getElementApi($aObjectOptions);
  177. $sResult = $oObject->getElementBlock($aObjectOptions);
  178. if(empty($sResult))
  179. return '';
  180. return array($sResult, $this->_sClassMiSa);
  181. }
  182. protected function _getMenuItemVote($aItem, $aParams = [])
  183. {
  184. $CNF = &$this->_oModule->_oConfig->CNF;
  185. if(empty($aParams['object']) && !empty($CNF['OBJECT_VOTES']))
  186. $aParams['object'] = $CNF['OBJECT_VOTES'];
  187. return $this->__getMenuItemVote($aItem, $aParams);
  188. }
  189. protected function _getMenuItemReaction($aItem, $aParams = [])
  190. {
  191. $CNF = &$this->_oModule->_oConfig->CNF;
  192. if(empty($aParams['object']) && !empty($CNF['OBJECT_REACTIONS']))
  193. $aParams['object'] = $CNF['OBJECT_REACTIONS'];
  194. return $this->__getMenuItemVote($aItem, $aParams);
  195. }
  196. protected function _getMenuItemScore($aItem, $aParams = [])
  197. {
  198. $CNF = &$this->_oModule->_oConfig->CNF;
  199. $aParams['class'] = 'BxDolScore';
  200. if(empty($aParams['object']) && !empty($CNF['OBJECT_SCORES']))
  201. $aParams['object'] = $CNF['OBJECT_SCORES'];
  202. return $this->__getMenuItemVote($aItem, $aParams);
  203. }
  204. protected function __getMenuItemVote($aItem, $aParams = [])
  205. {
  206. $CNF = &$this->_oModule->_oConfig->CNF;
  207. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  208. if(empty($iId))
  209. $iId = $this->_iContentId;
  210. $sClass = $aParams['class'] ?? 'BxDolVote';
  211. $oObject = ($sObject = $aParams['object'] ?? '') ? $sClass::getObjectInstance($sObject, $iId) : false;
  212. if(!$oObject || !$oObject->isEnabled())
  213. return '';
  214. $aObjectOptions = array(
  215. 'dynamic_mode' => $this->_bDynamicMode,
  216. 'show_do_vote_as_button' => $this->_bShowAsButton,
  217. 'show_do_vote_label' => $this->_bShowTitle
  218. );
  219. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  220. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  221. if($this->_bIsApi)
  222. return [
  223. 'id' => $aItem['id'],
  224. 'name' => $aItem['name'],
  225. 'display_type' => 'element',
  226. 'data' => $oObject->getElementApi($aObjectOptions)
  227. ];
  228. $sResult = $oObject->getElementBlock($aObjectOptions);
  229. if(empty($sResult))
  230. return '';
  231. return array($sResult, $this->_sClassMiSa);
  232. }
  233. protected function _getMenuItemFavorite($aItem, $aParams = array())
  234. {
  235. $CNF = &$this->_oModule->_oConfig->CNF;
  236. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  237. if(empty($sObject) && !empty($CNF['OBJECT_FAVORITES']))
  238. $sObject = $CNF['OBJECT_FAVORITES'];
  239. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  240. if(empty($iId))
  241. $iId = $this->_iContentId;
  242. $oObject = !empty($sObject) ? BxDolFavorite::getObjectInstance($sObject, $iId) : false;
  243. if(!$oObject || !$oObject->isEnabled())
  244. return '';
  245. $aObjectOptions = array(
  246. 'dynamic_mode' => $this->_bDynamicMode,
  247. 'show_do_favorite_as_button' => $this->_bShowAsButton,
  248. 'show_do_favorite_label' => $this->_bShowTitle
  249. );
  250. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  251. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  252. if($this->_bIsApi)
  253. return [
  254. 'id' => $aItem['id'],
  255. 'name' => $aItem['name'],
  256. 'display_type' => 'element',
  257. 'data' => $oObject->getElementApi($aObjectOptions)
  258. ];
  259. $sResult = $oObject->getElementBlock($aObjectOptions);
  260. if(empty($sResult))
  261. return '';
  262. return array($sResult, $this->_sClassMiSa);
  263. }
  264. protected function _getMenuItemFeature($aItem, $aParams = array())
  265. {
  266. $CNF = &$this->_oModule->_oConfig->CNF;
  267. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  268. if(empty($sObject) && !empty($CNF['OBJECT_FEATURED']))
  269. $sObject = $CNF['OBJECT_FEATURED'];
  270. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  271. if(empty($iId))
  272. $iId = $this->_iContentId;
  273. if(!$this->_isContentPublic($iId))
  274. return '';
  275. $oObject = !empty($sObject) ? BxDolFeature::getObjectInstance($sObject, $iId) : false;
  276. if(!$oObject || !$oObject->isEnabled())
  277. return '';
  278. $aObjectOptions = array(
  279. 'dynamic_mode' => $this->_bDynamicMode,
  280. 'show_do_feature_as_button' => $this->_bShowAsButton,
  281. 'show_do_feature_label' => $this->_bShowTitle
  282. );
  283. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  284. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  285. if($this->_bIsApi)
  286. return [
  287. 'id' => $aItem['id'],
  288. 'name' => $aItem['name'],
  289. 'display_type' => 'element',
  290. 'data' => $oObject->getElementApi($aObjectOptions)
  291. ];
  292. $sResult = $oObject->getElementBlock($aObjectOptions);
  293. if(empty($sResult))
  294. return '';
  295. return array($sResult, $this->_sClassMiSa);
  296. }
  297. protected function _getMenuItemRepost($aItem, $aParams = array())
  298. {
  299. $CNF = &$this->_oModule->_oConfig->CNF;
  300. $sAction = !empty($aParams['action']) ? $aParams['action'] : '';
  301. if(empty($sAction))
  302. $sAction = 'added';
  303. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  304. if(empty($iId))
  305. $iId = $this->_iContentId;
  306. $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iId);
  307. if(!empty($CNF['FIELD_PUBLISHED']) && isset($aContentInfo[$CNF['FIELD_PUBLISHED']]) && (int)$aContentInfo[$CNF['FIELD_PUBLISHED']] > time())
  308. return '';
  309. 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)))
  310. return '';
  311. $sStatus = 'active';
  312. if(!empty($CNF['FIELD_STATUS']) && isset($aContentInfo[$CNF['FIELD_STATUS']]) && $aContentInfo[$CNF['FIELD_STATUS']] != $sStatus)
  313. return '';
  314. if(!empty($CNF['FIELD_STATUS_ADMIN']) && isset($aContentInfo[$CNF['FIELD_STATUS_ADMIN']]) && $aContentInfo[$CNF['FIELD_STATUS_ADMIN']] != $sStatus)
  315. return '';
  316. $sRepostDo = !empty($aParams['do']) ? $aParams['do'] : 'repost';
  317. $aRepostParams = [
  318. 'do' => $sRepostDo,
  319. 'show_do_repost_as_button' => $this->_bShowAsButton,
  320. 'show_do_repost_text' => $this->_bShowTitle
  321. ];
  322. if(!empty($aItem['title']))
  323. $aRepostParams['text_do_' . $sRepostDo] = $aItem['title'];
  324. if(!empty($aItem['icon']))
  325. $aRepostParams['icon_do_' . $sRepostDo] = $aItem['icon'];
  326. $aSrvParams = [bx_get_logged_profile_id(), $this->_oModule->_oConfig->getName(), $sAction, $iId, $aRepostParams];
  327. if($this->_bIsApi && bx_is_srv('bx_timeline', 'get_repost_element_block_api'))
  328. return [
  329. 'id' => $aItem['id'],
  330. 'name' => $aItem['name'],
  331. 'display_type' => 'element',
  332. 'data' => bx_srv('bx_timeline', 'get_repost_element_block_api', $aSrvParams)
  333. ];
  334. if(!bx_is_srv('bx_timeline', 'get_repost_element_block'))
  335. return '';
  336. $sResult = bx_srv('bx_timeline', 'get_repost_element_block', $aSrvParams);
  337. if(empty($sResult))
  338. return '';
  339. return array($sResult, $this->_sClassMiSa);
  340. }
  341. protected function _getMenuItemRepostWithText($aItem, $aParams = [])
  342. {
  343. return $this->_getMenuItemRepost($aItem, array_merge($aParams, [
  344. 'do' => 'repost_with'
  345. ]));
  346. }
  347. protected function _getMenuItemRepostToContext($aItem, $aParams = [])
  348. {
  349. return $this->_getMenuItemRepost($aItem, array_merge($aParams, [
  350. 'do' => 'repost_to'
  351. ]));
  352. }
  353. protected function _getMenuItemReport($aItem, $aParams = array())
  354. {
  355. $CNF = &$this->_oModule->_oConfig->CNF;
  356. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  357. if(empty($sObject) && !empty($CNF['OBJECT_REPORTS']))
  358. $sObject = $CNF['OBJECT_REPORTS'];
  359. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  360. if(empty($iId))
  361. $iId = $this->_iContentId;
  362. $oObject = !empty($sObject) ? BxDolReport::getObjectInstance($sObject, $iId) : false;
  363. if(!$oObject || !$oObject->isEnabled())
  364. return '';
  365. $aObjectOptions = array(
  366. 'dynamic_mode' => $this->_bDynamicMode,
  367. 'show_do_report_as_button' => $this->_bShowAsButton,
  368. 'show_do_report_label' => $this->_bShowTitle
  369. );
  370. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  371. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  372. if($this->_bIsApi)
  373. return [
  374. 'id' => $aItem['id'],
  375. 'name' => $aItem['name'],
  376. 'display_type' => 'element',
  377. 'data' => $oObject->getElementApi($aObjectOptions)
  378. ];
  379. $sResult = $oObject->getElementBlock($aObjectOptions);
  380. if(empty($sResult))
  381. return '';
  382. return array($sResult, $this->_sClassMiSa);
  383. }
  384. protected function _getMenuItemSocialSharing($aItem, $aParams = array())
  385. {
  386. if(!$this->_bIsApi)
  387. return true;
  388. if(empty($this->_oMenuSocialSharing) && !$this->_initMenuSocialSharing())
  389. return [];
  390. return [
  391. 'id' => $aItem['id'],
  392. 'name' => $aItem['name'],
  393. 'display_type' => 'element',
  394. 'data' => [
  395. 'type' => 'shares',
  396. 'system' => $this->_sModule,
  397. 'object_id' => $this->_iContentId,
  398. 'params' => [],
  399. 'action' => [
  400. 'url' => bx_api_get_relative_url(bx_replace_markers('{url}', $this->_aMarkers))
  401. ]
  402. ]
  403. ];
  404. }
  405. protected function _getMenuItemNotes($aItem, $aParams = array())
  406. {
  407. $CNF = &$this->_oModule->_oConfig->CNF;
  408. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  409. if(empty($sObject) && !empty($CNF['OBJECT_NOTES']))
  410. $sObject = $CNF['OBJECT_NOTES'];
  411. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  412. if(empty($iId))
  413. $iId = $this->_iContentId;
  414. if(!$this->_oModule->_isModerator())
  415. return false;
  416. $this->addMarkers(array(
  417. 'content_id' => $iId
  418. ));
  419. return true;
  420. }
  421. protected function _getMenuItemByNameActions($aItem, $aParams = array())
  422. {
  423. $CNF = &$this->_oModule->_oConfig->CNF;
  424. if(empty($this->_oMenuActions)) {
  425. $sObjectMenu = !empty($aParams['object_menu']) ? $aParams['object_menu'] : '';
  426. if(empty($sObjectMenu) && !empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']))
  427. $sObjectMenu = $CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'];
  428. if(empty($sObjectMenu))
  429. return '';
  430. $this->_oMenuActions = BxDolMenu::getObjectInstance($sObjectMenu);
  431. if(!$this->_oMenuActions)
  432. return '';
  433. $this->_oMenuActions->setContentId($this->_iContentId);
  434. $this->_oMenuActions->addMarkers($this->getMarkers());
  435. $this->addMarkers($this->_oMenuActions->getMarkers());
  436. }
  437. $aItem = $this->_oMenuActions->getMenuItem($aItem['name']);
  438. if(empty($aItem) || !is_array($aItem))
  439. return false;
  440. if($this->_bIsApi)
  441. return $aItem;
  442. else
  443. return $this->_getMenuItemDefault($aItem);
  444. }
  445. protected function _getMenuItemByNameSocialSharing($aItem, $aParams = array())
  446. {
  447. if(empty($this->_oMenuSocialSharing) && !$this->_initMenuSocialSharing())
  448. return false;
  449. $aItem = $this->_oMenuSocialSharing->getMenuItem($aItem['name']);
  450. if(empty($aItem) || !is_array($aItem))
  451. return false;
  452. if($this->_bIsApi)
  453. return $aItem;
  454. else
  455. return $this->_getMenuItemDefault($aItem);
  456. }
  457. protected function _getMenuItemByNameActionDelete($aItem)
  458. {
  459. $oProfile = $this->_oModule->getProfileObject(($this->_iContentId));
  460. if (!$this->_oModule->isAllowDeleteOrDisable(bx_get_logged_profile_id(), $oProfile->id()))
  461. return false;
  462. return $this->_getMenuItemByNameActionsMore($aItem);
  463. }
  464. protected function _getMenuItemByNameActionsMore($aItem)
  465. {
  466. $CNF = &$this->_oModule->_oConfig->CNF;
  467. if(empty($this->_oMenuActionsMore)) {
  468. if(empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']))
  469. return '';
  470. $this->_oMenuActionsMore = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']);
  471. if(!$this->_oMenuActionsMore)
  472. return '';
  473. $this->_oMenuActionsMore->setContentId($this->_iContentId);
  474. $this->addMarkers($this->_oMenuActionsMore->getMarkers());
  475. }
  476. $aItem = $this->_oMenuActionsMore->getMenuItem($aItem['name']);
  477. if(empty($aItem) || !is_array($aItem))
  478. return false;
  479. if($this->_bIsApi)
  480. return $aItem;
  481. else
  482. return $this->_getMenuItemDefault($aItem);
  483. }
  484. protected function _rewriteMenuItem($aItem, $aExtrasAddon = [])
  485. {
  486. return parent::_rewriteMenuItem($aItem, [
  487. 'module' => $this->_sModule,
  488. 'content_id' => $this->_iContentId,
  489. 'content_data' => $this->_aContentInfo,
  490. ]);
  491. }
  492. }
  493. /** @} */