ILIAS  release_8 Revision v8.24
class.ilPluginDBUpdate.php
Go to the documentation of this file.
1<?php
20
29{
30 protected const PLUGIN_UPDATE_FILE = "/sql/dbupdate.php";
31
32 protected \ilDBInterface $db;
33 protected \ilPluginInfo $plugin;
34
39 public function __construct(
42 ) {
43 $this->client_ini = null;
44 $this->db = $db;
45 $this->plugin = $plugin;
46
47 $this->currentVersion = $plugin->getCurrentDBVersion() ?? 0;
48
49 $this->current_file = $this->getFileForStep(0 /* doesn't matter */);
50 $this->DB_UPDATE_FILE = $this->PATH . $this->getDBUpdateScriptName();
51 $this->LAST_UPDATE_FILE = $this->DB_UPDATE_FILE;
52
53 $this->readDBUpdateFile();
54 $this->readLastUpdateFile();
55 $this->readFileVersion();
56
57 $class_map = require ILIAS_ABSOLUTE_PATH . '/libs/composer/vendor/composer/autoload_classmap.php';
58 $this->ctrl_structure_iterator = new ilCtrlArrayIterator($class_map);
59 }
60
64 public function getFileForStep(int $a_version /* doesn't matter */): string
65 {
66 return "dbupdate.php";
67 }
68
72 public function getCurrentVersion(): int
73 {
75 }
76
80 public function setCurrentVersion(int $a_version): void
81 {
82 $this->currentVersion = $a_version;
83 }
84
85 public function loadXMLInfo(): bool
86 {
87 return true;
88 }
89
93 public function checkQuery(string $q): bool
94 {
95 if ((is_int(stripos($q, "create table")) || is_int(stripos($q, "alter table")) ||
96 is_int(stripos($q, "drop table")))
97 && !is_int(stripos($q, $this->getTablePrefix()))) {
98 return false;
99 }
100
101 return true;
102 }
103
104 public function getDBUpdateScriptName(): string
105 {
106 return $this->plugin->getPath() . self::PLUGIN_UPDATE_FILE;
107 }
108
109 protected function getTablePrefix(): string
110 {
111 $component = $this->plugin->getComponent();
112 $slot = $this->plugin->getPluginSlot();
113 return $component->getId() . "_" . $slot->getId() . "_" . $this->plugin->getId();
114 }
115}
A version number that consists of three numbers (major, minor, patch).
Definition: Version.php:27
Class ilCtrlArrayIterator.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $DB_UPDATE_FILE
Database Update class.
getFileForStep(int $a_version)
FROM ilDBUpdate.
__construct(\ilDBInterface $db, \ilPluginInfo $plugin)
constructor @noinspection MagicMethodsValidityInspection
getCurrentVersion()
Get current DB version.
setCurrentVersion(int $a_version)
Set current DB version.
checkQuery(string $q)
This is a very simple check.
Simple value class for information about a plugin.
Interface ilDBInterface.
const PATH
Definition: proxy_ylocal.php:8