BxDolBadges.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 UnaCore UNA Core
  7. * @{
  8. */
  9. class BxDolBadges extends BxDolFactory implements iBxDolSingleton
  10. {
  11. protected $_oDb;
  12. protected function __construct()
  13. {
  14. parent::__construct();
  15. $this->_oDb = new BxDolBadgesQuery();
  16. }
  17. public function __clone()
  18. {
  19. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  20. trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
  21. }
  22. public static function getInstance()
  23. {
  24. if(!isset($GLOBALS['bxDolClasses'][__CLASS__]))
  25. $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolBadges();
  26. return $GLOBALS['bxDolClasses'][__CLASS__];
  27. }
  28. public function getData($aParams = array(), &$aItems = false)
  29. {
  30. return $this->_oDb->getData($aParams, $aItems);
  31. }
  32. public function add($iBadgeId, $iObjectId, $sModule)
  33. {
  34. return $this->_oDb->add($iBadgeId, $iObjectId, $sModule);
  35. }
  36. public function delete($aParams)
  37. {
  38. return $this->_oDb->delete($aParams);
  39. }
  40. public static function onModuleUninstall ($sModuleName, &$iFiles = null)
  41. {
  42. $oBadges = BxDolBadges::getInstance();
  43. $oBadges->_oDb->delete(['type' => 'by_module', 'module' => $sModuleName]);
  44. return true;
  45. }
  46. }
  47. /** @} */