BxBaseModProfileMenuManageTools.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 BaseProfile Base classes for profile modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Manage tools submenu
  13. */
  14. class BxBaseModProfileMenuManageTools extends BxBaseModGeneralMenuManageTools
  15. {
  16. public function __construct($aObject, $oTemplate = false)
  17. {
  18. parent::__construct($aObject, $oTemplate);
  19. }
  20. /**
  21. * Check if menu items is visible.
  22. * @param $a menu item array
  23. * @return boolean
  24. */
  25. protected function _isVisible ($a)
  26. {
  27. if(!parent::_isVisible($a))
  28. return false;
  29. if(empty($this->_aContentInfo) || !is_array($this->_aContentInfo))
  30. return false;
  31. $sCheckFuncName = '';
  32. switch ($a['name']) {
  33. case 'delete':
  34. case 'delete-with-content':
  35. if($this->_oModule->checkMyself($this->_iContentId))
  36. return false;
  37. $oProfile = $this->_oModule->getProfileObject(($this->_iContentId));
  38. if (!$this->_oModule->isAllowDeleteOrDisable(bx_get_logged_profile_id(), $oProfile->id()))
  39. return false;
  40. $sCheckFuncName = 'checkAllowedDelete';
  41. break;
  42. }
  43. if(!$sCheckFuncName || !method_exists($this->_oModule, $sCheckFuncName))
  44. return true;
  45. return $this->_oModule->{$sCheckFuncName}($this->_aContentInfo) === CHECK_ACTION_RESULT_ALLOWED;
  46. }
  47. }
  48. /** @} */