BxDolFeatureQuery.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /**
  10. * @see BxDolFeature
  11. */
  12. class BxDolFeatureQuery extends BxDolObjectQuery
  13. {
  14. protected $_sTriggerFieldFlag;
  15. public function __construct(&$oModule)
  16. {
  17. parent::__construct($oModule);
  18. $aSystem = $this->_oModule->getSystemInfo();
  19. $this->_sTriggerFieldFlag = isset($aSystem['trigger_field_flag']) ? $aSystem['trigger_field_flag'] : '';
  20. $this->_sMethodGetEntry = 'getFeature';
  21. }
  22. public function isPerformed($iObjectId, $iAuthorId)
  23. {
  24. return (int)$this->getObjectFlag($iObjectId) > 0;
  25. }
  26. public function getPerformedBy($iObjectId, $iStart = 0, $iPerPage = 0)
  27. {
  28. return array();
  29. }
  30. public function getObjectFlag($iId)
  31. {
  32. $sQuery = $this->prepare("SELECT `{$this->_sTriggerFieldFlag}` FROM `{$this->_sTriggerTable}` WHERE `{$this->_sTriggerFieldId}` = ? LIMIT 1", $iId);
  33. return (int)$this->getOne($sQuery);
  34. }
  35. public function updateTriggerTableValue($iObjectId, $iValue)
  36. {
  37. $sQuery = $this->prepare("UPDATE `{$this->_sTriggerTable}` SET `{$this->_sTriggerFieldFlag}` = ? WHERE `{$this->_sTriggerFieldId}` = ?", (int)$iValue, $iObjectId);
  38. return (int)$this->query($sQuery) > 0;
  39. }
  40. protected function _updateTriggerTable($iObjectId, $aEntry)
  41. {
  42. $sQuery = $this->prepare("UPDATE `{$this->_sTriggerTable}` SET `{$this->_sTriggerFieldFlag}` = ? WHERE `{$this->_sTriggerFieldId}` = ?", $aEntry['count'], $iObjectId);
  43. return (int)$this->query($sQuery) > 0;
  44. }
  45. public function getFeature($iObjectId)
  46. {
  47. return array('count' => $this->getObjectFlag($iObjectId));
  48. }
  49. }
  50. /** @} */