BxBaseModGeneralMenuViewActions.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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 [
  354. 'id' => $aItem['id'],
  355. 'name' => $aItem['name'],
  356. 'display_type' => 'element',
  357. 'data' => bx_srv('bx_timeline', 'get_repost_element_block_api', $aSrvParams)
  358. ];
  359. if(!bx_is_srv('bx_timeline', 'get_repost_element_block'))
  360. return '';
  361. $sResult = bx_srv('bx_timeline', 'get_repost_element_block', $aSrvParams);
  362. if(empty($sResult))
  363. return '';
  364. return array($sResult, $this->_sClassMiSa);
  365. }
  366. protected function _getMenuItemRepostWithText($aItem, $aParams = [])
  367. {
  368. return $this->_getMenuItemRepost($aItem, array_merge($aParams, [
  369. 'do' => 'repost_with'
  370. ]));
  371. }
  372. protected function _getMenuItemRepostToContext($aItem, $aParams = [])
  373. {
  374. return $this->_getMenuItemRepost($aItem, array_merge($aParams, [
  375. 'do' => 'repost_to'
  376. ]));
  377. }
  378. protected function _getMenuItemReport($aItem, $aParams = array())
  379. {
  380. $CNF = &$this->_oModule->_oConfig->CNF;
  381. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  382. if(empty($sObject) && !empty($CNF['OBJECT_REPORTS']))
  383. $sObject = $CNF['OBJECT_REPORTS'];
  384. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  385. if(empty($iId))
  386. $iId = $this->_iContentId;
  387. $oObject = !empty($sObject) ? BxDolReport::getObjectInstance($sObject, $iId) : false;
  388. if(!$oObject || !$oObject->isEnabled())
  389. return '';
  390. $aObjectOptions = array(
  391. 'dynamic_mode' => $this->_bDynamicMode,
  392. 'show_do_report_as_button' => $this->_bShowAsButton,
  393. 'show_do_report_label' => $this->_bShowTitle
  394. );
  395. if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
  396. $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
  397. if($this->_bIsApi)
  398. return [
  399. 'id' => $aItem['id'],
  400. 'name' => $aItem['name'],
  401. 'display_type' => 'element',
  402. 'data' => $oObject->getElementApi($aObjectOptions)
  403. ];
  404. $sResult = $oObject->getElementBlock($aObjectOptions);
  405. if(empty($sResult))
  406. return '';
  407. return array($sResult, $this->_sClassMiSa);
  408. }
  409. protected function _getMenuItemSocialSharing($aItem, $aParams = array())
  410. {
  411. if(!$this->_bIsApi)
  412. return true;
  413. if(empty($this->_oMenuSocialSharing) && !$this->_initMenuSocialSharing())
  414. return [];
  415. return [
  416. 'id' => $aItem['id'],
  417. 'name' => $aItem['name'],
  418. 'display_type' => 'element',
  419. 'data' => [
  420. 'type' => 'shares',
  421. 'system' => $this->_sModule,
  422. 'object_id' => $this->_iContentId,
  423. 'params' => [],
  424. 'action' => [
  425. 'url' => bx_replace_markers('{url_encoded}', $this->_aMarkers)
  426. ]
  427. ]
  428. ];
  429. }
  430. protected function _getMenuItemNotes($aItem, $aParams = array())
  431. {
  432. $CNF = &$this->_oModule->_oConfig->CNF;
  433. $sObject = !empty($aParams['object']) ? $aParams['object'] : '';
  434. if(empty($sObject) && !empty($CNF['OBJECT_NOTES']))
  435. $sObject = $CNF['OBJECT_NOTES'];
  436. $iId = !empty($aParams['id']) ? (int)$aParams['id'] : '';
  437. if(empty($iId))
  438. $iId = $this->_iContentId;
  439. if(!$this->_oModule->_isModerator())
  440. return false;
  441. $this->addMarkers(array(
  442. 'content_id' => $iId
  443. ));
  444. return true;
  445. }
  446. protected function _getMenuItemByNameActions($aItem, $aParams = array())
  447. {
  448. $CNF = &$this->_oModule->_oConfig->CNF;
  449. if(empty($this->_oMenuActions)) {
  450. $sObjectMenu = !empty($aParams['object_menu']) ? $aParams['object_menu'] : '';
  451. if(empty($sObjectMenu) && !empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']))
  452. $sObjectMenu = $CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'];
  453. if(empty($sObjectMenu))
  454. return '';
  455. $this->_oMenuActions = BxDolMenu::getObjectInstance($sObjectMenu);
  456. if(!$this->_oMenuActions)
  457. return '';
  458. $this->_oMenuActions->setContentId($this->_iContentId);
  459. $this->addMarkers($this->_oMenuActions->getMarkers());
  460. }
  461. $aItem = $this->_oMenuActions->getMenuItem($aItem['name']);
  462. if(empty($aItem) || !is_array($aItem))
  463. return false;
  464. if($this->_bIsApi)
  465. return $aItem;
  466. else
  467. return $this->_getMenuItemDefault($aItem);
  468. }
  469. protected function _getMenuItemByNameSocialSharing($aItem, $aParams = array())
  470. {
  471. if(empty($this->_oMenuSocialSharing) && !$this->_initMenuSocialSharing())
  472. return false;
  473. $aItem = $this->_oMenuSocialSharing->getMenuItem($aItem['name']);
  474. if(empty($aItem) || !is_array($aItem))
  475. return false;
  476. if($this->_bIsApi)
  477. return $aItem;
  478. else
  479. return $this->_getMenuItemDefault($aItem);
  480. }
  481. protected function _getMenuItemByNameActionDelete($aItem)
  482. {
  483. $oProfile = $this->_oModule->getProfileObject(($this->_iContentId));
  484. if (!$this->_oModule->isAllowDeleteOrDisable(bx_get_logged_profile_id(), $oProfile->id()))
  485. return false;
  486. return $this->_getMenuItemByNameActionsMore($aItem);
  487. }
  488. protected function _getMenuItemByNameActionsMore($aItem)
  489. {
  490. $CNF = &$this->_oModule->_oConfig->CNF;
  491. if(empty($this->_oMenuActionsMore)) {
  492. if(empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']))
  493. return '';
  494. $this->_oMenuActionsMore = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']);
  495. if(!$this->_oMenuActionsMore)
  496. return '';
  497. $this->_oMenuActionsMore->setContentId($this->_iContentId);
  498. $this->addMarkers($this->_oMenuActionsMore->getMarkers());
  499. }
  500. $aItem = $this->_oMenuActionsMore->getMenuItem($aItem['name']);
  501. if(empty($aItem) || !is_array($aItem))
  502. return false;
  503. if($this->_bIsApi)
  504. return $aItem;
  505. else
  506. return $this->_getMenuItemDefault($aItem);
  507. }
  508. }
  509. /** @} */