BxBaseCmtsMenuManage.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup TridentCore Trident Core
  7. * @{
  8. */
  9. bx_import('BxTemplMenu');
  10. /**
  11. * Menu representation.
  12. * @see BxDolMenu
  13. */
  14. class BxBaseCmtsMenuManage extends BxTemplMenu
  15. {
  16. protected $_oCmts;
  17. protected $_aCmt;
  18. public function __construct ($aObject, $oTemplate)
  19. {
  20. parent::__construct ($aObject, $oTemplate);
  21. }
  22. public function setCmtsData($oCmts, $iCmtId)
  23. {
  24. if(empty($oCmts) || empty($iCmtId))
  25. return;
  26. $this->_oCmts = $oCmts;
  27. $this->_aCmt = $oCmts->getCommentRow($iCmtId);
  28. $this->addMarkers(array(
  29. 'js_object' => $oCmts->getJsObjectName(),
  30. 'content_id' => $iCmtId,
  31. ));
  32. }
  33. /**
  34. * Check if menu items is visible.
  35. * @param $a menu item array
  36. * @return boolean
  37. */
  38. protected function _isVisible ($a)
  39. {
  40. if(!parent::_isVisible($a))
  41. return false;
  42. $sCheckFuncName = '';
  43. $aCheckFuncParams = array();
  44. switch ($a['name']) {
  45. case 'item-edit':
  46. $sCheckFuncName = 'isEditAllowed';
  47. if(!empty($this->_aCmt))
  48. $aCheckFuncParams = array($this->_aCmt);
  49. break;
  50. case 'item-delete':
  51. $sCheckFuncName = 'isRemoveAllowed';
  52. if(!empty($this->_aCmt))
  53. $aCheckFuncParams = array($this->_aCmt);
  54. break;
  55. }
  56. if(!$sCheckFuncName || !method_exists($this->_oCmts, $sCheckFuncName))
  57. return true;
  58. return call_user_func_array(array($this->_oCmts, $sCheckFuncName), $aCheckFuncParams);
  59. }
  60. }
  61. /** @} */