BxDolStudioInstallerQuery.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 DolphinStudio Dolphin Studio
  7. * @{
  8. */
  9. bx_import('BxDolModuleQuery');
  10. class BxDolStudioInstallerQuery extends BxDolModuleQuery {
  11. function __construct() {
  12. parent::__construct();
  13. }
  14. function insertModule(&$aConfig) {
  15. $sProductUrl = isset($aConfig['product_url']) ? $aConfig['product_url'] : '';
  16. $sUpdateUrl = isset($aConfig['update_url']) ? $aConfig['update_url'] : '';
  17. $sDependencies = '';
  18. if(isset($aConfig['dependencies']) && is_array($aConfig['dependencies']))
  19. $sDependencies = implode(',', $aConfig['dependencies']);
  20. $sQuery = $this->prepare("INSERT IGNORE INTO `sys_modules`(`type`, `name`, `title`, `vendor`, `version`, `product_url`, `update_url`, `path`, `uri`, `class_prefix`, `db_prefix`, `lang_category`, `dependencies`, `date`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, UNIX_TIMESTAMP())", $aConfig['type'], $aConfig['name'], $aConfig['title'], $aConfig['vendor'], $aConfig['version'], $sProductUrl, $sUpdateUrl, $aConfig['home_dir'], $aConfig['home_uri'], $aConfig['class_prefix'], $aConfig['db_prefix'], $aConfig['language_category'], $sDependencies);
  21. $iResult = (int)$this->query($sQuery);
  22. return $iResult > 0 ? (int)$this->lastId() : 0;
  23. }
  24. function insertModuleTrack($iModuleId, &$aFile) {
  25. $sQuery = $this->prepare("INSERT IGNORE INTO `sys_modules_file_tracks`(`module_id`, `file`, `hash`) VALUES(?, ?, ?)", $iModuleId, $aFile['file'], $aFile['hash']);
  26. $this->query($sQuery);
  27. }
  28. function deleteModule($aConfig) {
  29. $sQuery = $this->prepare("SELECT `id` FROM `sys_modules` WHERE `vendor`=? AND `path`=? LIMIT 1", $aConfig['vendor'], $aConfig['home_dir']);
  30. $iId = (int)$this->getOne($sQuery);
  31. $sQuery = $this->prepare("DELETE FROM `sys_modules` WHERE `vendor`=? AND `path`=? LIMIT 1", $aConfig['vendor'], $aConfig['home_dir']);
  32. $this->query($sQuery);
  33. $sQuery = $this->prepare("DELETE FROM `sys_modules_file_tracks` WHERE `module_id`=?", $iId);
  34. $this->query($sQuery);
  35. return $iId;
  36. }
  37. }
  38. /** @} */