ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMediaObjectsDBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
20
25{
26 protected \ilDBInterface $db;
27
28 public function prepare(\ilDBInterface $db): void
29 {
30 $this->db = $db;
31 }
32
33 public function step_1(): void
34 {
35 $db = $this->db;
36 if (!$db->tableColumnExists('media_item', 'duration')) {
37 $db->addTableColumn('media_item', 'duration', array(
38 "type" => "integer",
39 "notnull" => true,
40 "length" => 4,
41 "default" => 0
42 ));
43 }
44 }
45
46 public function step_2(): void
47 {
48 // skipped, since added to ILIAS 8 later
49 }
50
51 public function step_3(): void
52 {
53 $db = $this->db;
54 $set = $db->queryF(
55 "SELECT * FROM settings " .
56 " WHERE module = %s AND keyword = %s ",
57 ["text", "text"],
58 ["mobs", "black_list_file_types"]
59 );
60 $black_list_str = "";
61 while ($rec = $db->fetchAssoc($set)) {
62 $black_list_str = $rec["value"] ?? "";
63 }
64 $black_list = explode(",", $black_list_str);
65 $new_black_list = [];
66 foreach ($black_list as $type) {
67 $type = strtolower(trim($type));
68 switch ($type) {
69 case "html": $type = "text/html";
70 break;
71 case "mp4": $type = "video/mp4";
72 break;
73 case "webm": $type = "video/webm";
74 break;
75 case "mp3": $type = "audio/mpeg";
76 break;
77 case "png": $type = "image/png";
78 break;
79 case "jpeg":
80 case "jpg": $type = "image/jpeg";
81 break;
82 case "gif": $type = "image/gif";
83 break;
84 case "webp": $type = "image/webp";
85 break;
86 case "svg": $type = "image/svg+xml";
87 break;
88 case "pdf": $type = "application/pdf";
89 break;
90 }
91 if (in_array($type, ["video/vimeo", "video/youtube", "video/mp4", "video/webm", "audio/mpeg",
92 "image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml",
93 "text/html", "application/pdf"])) {
94 if (!in_array($type, $new_black_list)) {
95 $new_black_list[] = $type;
96 }
97 }
98 }
99 $db->update(
100 "settings",
101 [
102 "value" => ["text", implode(",", $new_black_list)]
103 ],
104 [ // where
105 "module" => ["text", "mobs"],
106 "keyword" => ["text", "black_list_file_types"]
107 ]
108 );
109 }
110
111 public function step_4(): void
112 {
113 $db = $this->db;
114 $db->modifyTableColumn('map_area', 'coords', ['length' => 4000]);
115 }
116
117 public function step_5(): void
118 {
119 $db = $this->db;
120 $db->createTable('mob_data', [
121 "id" => [
122 "type" => "integer",
123 "notnull" => true,
124 "length" => 4,
125 "default" => 0
126 ],
127 "rid" => [
128 'type' => 'text',
129 'notnull' => true,
130 'length' => 64,
131 'default' => ""
132 ]
133 ]);
134 }
135
136 public function step_6(): void
137 {
138 $db = $this->db;
139 $db->addPrimaryKey("mob_data", ["id"]);
140 }
141
142 public function step_7(): void
143 {
144 if (!$this->db->indexExistsByFields('media_item', ['mob_id'])) {
145 $this->db->addIndex('media_item', ['mob_id'], 'i1');
146 }
147 }
148
149}
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
Interface ilDBInterface.
addTableColumn(string $table_name, string $column_name, array $attributes)
update(string $table_name, array $values, array $where)
@description $where MUST contain existing columns only.
tableColumnExists(string $table_name, string $column_name)
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
createTable(string $table_name, array $fields, bool $drop_table=false, bool $ignore_erros=false)
modifyTableColumn(string $table, string $column, array $attributes)
addPrimaryKey(string $table_name, array $primary_keys)
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...