ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilFileObjectDatabaseObjective Class Reference
+ Inheritance diagram for ilFileObjectDatabaseObjective:
+ Collaboration diagram for ilFileObjectDatabaseObjective:

Public Member Functions

 prepare (ilDBInterface $db)
 
 step_1 ()
 adds a new table column called 'direct_download' that is used to determine if the on-click action in the ilObjFileListGUI should More...
 
 step_2 ()
 adds a new table column called 'downloads' which is used to keep More...
 
 step_3 ()
 sets the default visibility of the amount of downloads to visible ('1' or true). More...
 
 step_4 ()
 adds two new tables to store data concerning suffix-specific icons for files More...
 
 step_5 ()
 
 step_6 ()
 Adds a new table column called 'important_info' to store important information regarding a file such as work instructions. More...
 
 step_7 ()
 This step sets all files which were created before the "centralizing online/offline status" feature to online. More...
 
- Public Member Functions inherited from ilDatabaseUpdateSteps
 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 

Private Member Functions

 abortIfNotPrepared ()
 Halts the execution of these update steps if no database was provided. More...
 

Private Attributes

ilDBInterface $database = null
 

Detailed Description

Author
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns @noinspection AutoloadingIssuesInspection

Definition at line 28 of file class.ilFileObjectDatabaseObjective.php.

Member Function Documentation

◆ abortIfNotPrepared()

ilFileObjectDatabaseObjective::abortIfNotPrepared ( )
private

Halts the execution of these update steps if no database was provided.

Exceptions
LogicExceptionif the database update steps were not yet prepared.

Definition at line 227 of file class.ilFileObjectDatabaseObjective.php.

227 : void
228 {
229 if (null === $this->database) {
230 throw new LogicException(self::class . "::prepare() must be called before db-update-steps execution.");
231 }
232 }

References ILIAS\Repository\database().

Referenced by step_1(), step_2(), step_3(), step_4(), and step_6().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepare()

ilFileObjectDatabaseObjective::prepare ( ilDBInterface  $db)

Definition at line 32 of file class.ilFileObjectDatabaseObjective.php.

32 : void
33 {
34 $this->database = $db;
35 }

References ILIAS\Repository\database().

+ Here is the call graph for this function:

◆ step_1()

ilFileObjectDatabaseObjective::step_1 ( )

adds a new table column called 'direct_download' that is used to determine if the on-click action in the ilObjFileListGUI should

download the file directly or redirect to the objects info-page.

NOTE: this won't affect the default-behaviour which currently downloads the file directly, since '1' or true is added as the default value to the new column.

Definition at line 46 of file class.ilFileObjectDatabaseObjective.php.

46 : void
47 {
48 $this->abortIfNotPrepared();
49 if ($this->database->tableExists('file_data')) {
50 $this->database->addTableColumn(
51 'file_data',
52 'on_click_mode',
53 [
54 'type' => 'integer',
55 'length' => '1',
56 'notnull' => '1',
58 ]
59 );
60 }
61 }
abortIfNotPrepared()
Halts the execution of these update steps if no database was provided.
const CLICK_MODE_DOWNLOAD

References abortIfNotPrepared(), ilObjFile\CLICK_MODE_DOWNLOAD, and ILIAS\Repository\database().

+ Here is the call graph for this function:

◆ step_2()

ilFileObjectDatabaseObjective::step_2 ( )

adds a new table column called 'downloads' which is used to keep

track of the actual amount of downloads of a file object.

NOTE: the initial value will be the collective sum of read_count from the database table read_event of the tracking service. This will not be an accurate representation of the download count, but provides at least some insight.

Definition at line 72 of file class.ilFileObjectDatabaseObjective.php.

72 : void
73 {
74 $this->abortIfNotPrepared();
75 if (!$this->database->tableExists('file_data')) {
76 return;
77 }
78 if ($this->database->tableColumnExists('file_data', 'downloads')) {
79 return;
80 }
81
82 $this->database->addTableColumn(
83 'file_data',
84 'downloads',
85 [
86 'type' => 'integer',
87 'length' => 8,
88 'notnull' => false,
89 'default' => 0 // will be adjusted in an update query.
90 ]
91 );
92
93 $this->database->manipulate(
94 "
95 UPDATE file_data SET downloads = (
96 SELECT COALESCE(SUM(read_event.read_count), 0) FROM read_event
97 WHERE read_event.obj_id = file_data.file_id
98 );
99 "
100 );
101 }

References abortIfNotPrepared(), and ILIAS\Repository\database().

+ Here is the call graph for this function:

◆ step_3()

ilFileObjectDatabaseObjective::step_3 ( )

sets the default visibility of the amount of downloads to visible ('1' or true).

copied from

See also
ilSetting::set()

Definition at line 106 of file class.ilFileObjectDatabaseObjective.php.

106 : void
107 {
108 $this->abortIfNotPrepared();
109
111 $this->database->insert(
112 'settings',
113 [
114 'module' => ['text', General::MODULE_NAME],
115 'keyword' => ['text', General::F_SHOW_AMOUNT_OF_DOWNLOADS],
116 'value' => ['text', '1'],
117 ]
118 );
119 }

References abortIfNotPrepared(), and ILIAS\Repository\database().

+ Here is the call graph for this function:

◆ step_4()

ilFileObjectDatabaseObjective::step_4 ( )

adds two new tables to store data concerning suffix-specific icons for files

Definition at line 124 of file class.ilFileObjectDatabaseObjective.php.

124 : void
125 {
126 $this->abortIfNotPrepared();
127 if (!$this->database->tableExists(IconDatabaseRepository::ICON_TABLE_NAME)) {
128 $this->database->createTable(
129 IconDatabaseRepository::ICON_TABLE_NAME,
130 [
131 IconDatabaseRepository::ICON_RESOURCE_IDENTIFICATION => [
132 'type' => 'text',
133 'length' => 64,
134 'notnull' => true,
135 'default' => '',
136 ],
137 IconDatabaseRepository::ICON_ACTIVE => [
138 'type' => 'integer',
139 'length' => 1,
140 'notnull' => false,
141 'default' => 0,
142 ],
143 IconDatabaseRepository::IS_DEFAULT_ICON => [
144 'type' => 'integer',
145 'length' => 1,
146 'notnull' => false,
147 'default' => 0,
148 ]
149 ]
150 );
151 }
152 if (!$this->database->tableExists(IconDatabaseRepository::SUFFIX_TABLE_NAME)) {
153 $this->database->createTable(
154 IconDatabaseRepository::SUFFIX_TABLE_NAME,
155 [
156 IconDatabaseRepository::ICON_RESOURCE_IDENTIFICATION => [
157 'type' => 'text',
158 'length' => 64,
159 'notnull' => true,
160 'default' => '',
161 ],
162 IconDatabaseRepository::SUFFIX => [
163 'type' => 'text',
164 'length' => 32,
165 'notnull' => false,
166 'default' => '',
167 ]
168 ]
169 );
170 }
171 }

References abortIfNotPrepared(), and ILIAS\Repository\database().

+ Here is the call graph for this function:

◆ step_5()

ilFileObjectDatabaseObjective::step_5 ( )

Definition at line 173 of file class.ilFileObjectDatabaseObjective.php.

173 : void
174 {
175 // replace wrong suffixes. currently they are stored with e.g. icon_file_docx and should be docx.
176 // update the whole table with a replace statement.
177 $this->database->manipulate(
178 "UPDATE il_file_icon_suffixes SET suffix = REPLACE(suffix, 'icon_file_', '') WHERE suffix LIKE 'icon_file_%';"
179 );
180 }

References ILIAS\Repository\database().

+ Here is the call graph for this function:

◆ step_6()

ilFileObjectDatabaseObjective::step_6 ( )

Adds a new table column called 'important_info' to store important information regarding a file such as work instructions.

Definition at line 186 of file class.ilFileObjectDatabaseObjective.php.

186 : void
187 {
188 $this->abortIfNotPrepared();
189 if (!$this->database->tableExists('file_data')) {
190 return;
191 }
192 if ($this->database->tableColumnExists(
193 'file_data',
194 'important_info'
195 )) {
196 return;
197 }
198 $this->database->addTableColumn(
199 'file_data',
200 'important_info',
201 [
202 'type' => 'blob',
203 'notnull' => false,
204 'default' => null
205 ]
206 );
207 }

References abortIfNotPrepared(), and ILIAS\Repository\database().

+ Here is the call graph for this function:

◆ step_7()

ilFileObjectDatabaseObjective::step_7 ( )

This step sets all files which were created before the "centralizing online/offline status" feature to online.

It will update the offline value in the table object_data of each object of type file whose offline value currently is null (as this was not set for files before the feature) to 0 (online), which is the new default online status for files.

Definition at line 215 of file class.ilFileObjectDatabaseObjective.php.

215 : void
216 {
217 $query = "UPDATE `object_data` SET `offline` = 0 WHERE `type` = \"file\" AND `offline` IS NULL";
218 $this->database->manipulate($query);
219 }

References ILIAS\Repository\database().

+ Here is the call graph for this function:

Field Documentation

◆ $database

ilDBInterface ilFileObjectDatabaseObjective::$database = null
private

Definition at line 30 of file class.ilFileObjectDatabaseObjective.php.


The documentation for this class was generated from the following file: