BxDolLabel.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 BxDolLabel extends BxDolFactory implements iBxDolSingleton
  10. {
  11. protected $_oDb;
  12. protected function __construct()
  13. {
  14. parent::__construct();
  15. $this->_oDb = new BxDolLabelQuery();
  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 BxDolLabel();
  26. return $GLOBALS['bxDolClasses'][__CLASS__];
  27. }
  28. public function getLabels($aParams = array())
  29. {
  30. return $this->_oDb->getLabels($aParams);
  31. }
  32. public function onAdd($iId)
  33. {
  34. $aLabel = $this->_oDb->getLabels(array('type' => 'id', 'id' => $iId));
  35. if(empty($aLabel) || !is_array($aLabel))
  36. return;
  37. bx_alert('label', 'added', $iId, false, array('label' => $aLabel));
  38. }
  39. public function onEdit($iId)
  40. {
  41. $aLabel = $this->_oDb->getLabels(array('type' => 'id', 'id' => $iId));
  42. if(empty($aLabel) || !is_array($aLabel))
  43. return;
  44. bx_alert('label', 'edited', $iId, false, array('label' => $aLabel));
  45. }
  46. public function onDelete($iId)
  47. {
  48. $aLabel = $this->_oDb->getLabels(array('type' => 'id', 'id' => $iId));
  49. if(empty($aLabel) || !is_array($aLabel))
  50. return;
  51. bx_alert('label', 'deleted', $iId, false, array('label' => $aLabel));
  52. }
  53. }
  54. /** @} */