BxDolStudioInstallerQuery.php 2.3 KB

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