ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilHelpDBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\Help\Setup;
20
22{
23 protected \ilDBInterface $db;
24
25 public function prepare(\ilDBInterface $db): void
26 {
27 $this->db = $db;
28 }
29
30 public function step_1(): void
31 {
32 if (!$this->db->tableColumnExists('help_module', 'order_nr')) {
33 $this->db->addTableColumn('help_module', 'order_nr', array(
34 'type' => 'integer',
35 'notnull' => true,
36 'length' => 4,
37 'default' => 0
38 ));
39 }
40 }
41
42 public function step_2(): void
43 {
44 if (!$this->db->tableColumnExists('help_module', 'active')) {
45 $this->db->addTableColumn('help_module', 'active', array(
46 'type' => 'integer',
47 'notnull' => true,
48 'length' => 1,
49 'default' => 0
50 ));
51 }
52 }
53
54 public function step_3(): void
55 {
56 $set = $this->db->queryF(
57 "SELECT value FROM settings " .
58 " WHERE module = %s AND keyword = %s",
59 ["text", "text"],
60 ["common", "help_module"]
61 );
62 if ($rec = $this->db->fetchAssoc($set)) {
63 $id = (int) $rec["value"];
64 if ($id > 0) {
65 $this->db->update(
66 "help_module",
67 [
68 "active" => ["integer", 1]
69 ],
70 [ // where
71 "id" => ["integer", $id]
72 ]
73 );
74 }
75 }
76 }
77
78 public function step_4(): void
79 {
80 if (!$this->db->tableColumnExists('help_map', 'full_id')) {
81 $this->db->addTableColumn('help_map', 'full_id', array(
82 'type' => 'text',
83 'length' => 1000,
84 'default' => ""
85 ));
86 }
87 }
88
89 public function step_5(): void
90 {
91 if (!$this->db->tableExists('help_gt_settings')) {
92 $this->db->createTable(
93 'help_gt_settings',
94 [
95 'obj_id' => [
96 'type' => 'integer',
97 'length' => 4,
98 'notnull' => true
99 ],
100 'active' => [
101 'type' => 'integer',
102 'length' => 1,
103 'notnull' => true,
104 'default' => 0
105 ],
106 'screen_ids' => [
107 'type' => 'text',
108 'length' => 1000,
109 'notnull' => true,
110 'default' => ''
111 ],
112 'permission' => [
113 'type' => 'integer',
114 'length' => 1,
115 'notnull' => true,
116 'default' => 0
117 ],
118 ]
119 );
120 $this->db->addPrimaryKey('help_gt_settings', ['obj_id']);
121 }
122 }
123
124 public function step_6(): void
125 {
126 if (!$this->db->tableExists('help_gt_step')) {
127 $this->db->createTable(
128 'help_gt_step',
129 [
130 'id' => [
131 'type' => 'integer',
132 'length' => 4,
133 'notnull' => true
134 ],
135 'tour_id' => [
136 'type' => 'integer',
137 'length' => 4,
138 'notnull' => true
139 ],
140 'order_nr' => [
141 'type' => 'integer',
142 'length' => 4,
143 'notnull' => true
144 ],
145 'type' => [
146 'type' => 'integer',
147 'length' => 1,
148 'notnull' => true
149 ],
150 'element_id' => [
151 'type' => 'text',
152 'length' => 1000,
153 'notnull' => true,
154 'default' => ''
155 ]
156 ]
157 );
158 $this->db->addPrimaryKey('help_gt_step', ['id']);
159 }
160 }
161
162 public function step_7(): void
163 {
164 $this->db->createSequence('help_gt_step');
165 }
166
167 public function step_8(): void
168 {
169 if (!$this->db->tableExists('help_gt_user_finished')) {
170 $this->db->createTable(
171 'help_gt_user_finished',
172 [
173 'tour_id' => [
174 'type' => 'integer',
175 'length' => 4,
176 'notnull' => true
177 ],
178 'user_id' => [
179 'type' => 'integer',
180 'length' => 4,
181 'notnull' => true
182 ]
183 ]
184 );
185 $this->db->addPrimaryKey('help_gt_user_finished', ['tour_id', 'user_id']);
186 }
187 }
188
189 public function step_9(): void
190 {
191 // step 5 might not be run on ilias 10 systems (see 10 branch)
192 if (!$this->db->tableExists('help_gt_settings')) {
193 $this->db->createTable(
194 'help_gt_settings',
195 [
196 'obj_id' => [
197 'type' => 'integer',
198 'length' => 4,
199 'notnull' => true
200 ],
201 'active' => [
202 'type' => 'integer',
203 'length' => 1,
204 'notnull' => true,
205 'default' => 0
206 ],
207 'screen_ids' => [
208 'type' => 'text',
209 'length' => 1000,
210 'notnull' => true,
211 'default' => ''
212 ],
213 'permission' => [
214 'type' => 'integer',
215 'length' => 1,
216 'notnull' => true,
217 'default' => 0
218 ],
219 ]
220 );
221 $this->db->addPrimaryKey('help_gt_settings', ['obj_id']);
222 }
223 if (!$this->db->tableColumnExists('help_gt_settings', 'lang')) {
224 $this->db->addTableColumn('help_gt_settings', 'lang', array(
225 'type' => 'text',
226 'notnull' => true,
227 'length' => 10,
228 'default' => ''
229 ));
230 }
231 }
232
233 public function step_10(): void
234 {
235 if ($this->db->primaryExistsByFields('help_map', array(
236 'chap', 'component', 'screen_id', 'screen_sub_id', 'perm', 'module_id'))) {
237 $this->db->dropPrimaryKey('help_map');
238 }
239 }
240
241}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.Agent.php:21