ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMDCopyrightUpdateSteps Class Reference
+ Inheritance diagram for ilMDCopyrightUpdateSteps:
+ Collaboration diagram for ilMDCopyrightUpdateSteps:

Public Member Functions

 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 
 step_1 ()
 Add a column to il_md_cpr_selections for the full name of the licence. More...
 
 step_2 ()
 Add a column to il_md_cpr_selections for the link to the licence. More...
 
 step_3 ()
 Add a column to il_md_cpr_selections for the link to the licence's image. More...
 
 step_4 ()
 Add a column to il_md_cpr_selections for the alt text of the licence's image. More...
 
 step_5 ()
 Add a column to il_md_cpr_selections to track which licences have been migrated. More...
 
 step_6 ()
 Add a column to il_md_cpr_selections for the string identifier for the licence's image, if it is saved as a file. More...
 
 step_7 ()
 Add CC0 to the available copyrights. More...
 
 step_8 ()
 Replace CC0 image link by svg. More...
 
 step_9 ()
 Change title, description and full name of 'All rights reserved', see https://mantis.ilias.de/view.php?id=41301. More...
 
 step_10 ()
 Change title, description and full name of 'Public Domain', see https://mantis.ilias.de/view.php?id=41301. More...
 
 step_11 ()
 Change title of CC licences, see https://mantis.ilias.de/view.php?id=41898. More...
 
 step_12 ()
 Also change description of unmigrated 'All rights reserved', see https://mantis.ilias.de/view.php?id=41301. More...
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

Definition at line 21 of file class.ilMDCopyrightUpdateSteps.php.

Member Function Documentation

◆ prepare()

ilMDCopyrightUpdateSteps::prepare ( \ilDBInterface  $db)

Prepare the execution of the steps.

Do not use anything from the globals or the DIC inside your steps, only use the instance of the database provided here.

Implements ilDatabaseUpdateSteps.

Definition at line 25 of file class.ilMDCopyrightUpdateSteps.php.

References $db.

25  : void
26  {
27  $this->db = $db;
28  }

◆ step_1()

ilMDCopyrightUpdateSteps::step_1 ( )

Add a column to il_md_cpr_selections for the full name of the licence.

Definition at line 33 of file class.ilMDCopyrightUpdateSteps.php.

References ilDBConstants\T_CLOB.

33  : void
34  {
35  if (!$this->db->tableColumnExists('il_md_cpr_selections', 'full_name')) {
36  $this->db->addTableColumn(
37  'il_md_cpr_selections',
38  'full_name',
39  ['type' => ilDBConstants::T_CLOB]
40  );
41  }
42  }

◆ step_10()

ilMDCopyrightUpdateSteps::step_10 ( )

Change title, description and full name of 'Public Domain', see https://mantis.ilias.de/view.php?id=41301.

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

References $res, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

215  : void
216  {
217  $title = "Public Domain";
218  $link = "http://creativecommons.org/publicdomain/zero/1.0/";
219  $old_full_name = "This work is free of known copyright restrictions.";
220  $new_full_name = "Public Domain";
221  $new_description = "Creative work to which no exclusive intellectual property rights apply.";
222 
223  $res = $this->db->query(
224  'SELECT entry_id FROM il_md_cpr_selections WHERE title = ' .
225  $this->db->quote($title, ilDBConstants::T_TEXT) . ' AND full_name = ' .
226  $this->db->quote($old_full_name, ilDBConstants::T_TEXT) . ' AND link = ' .
227  $this->db->quote($link, ilDBConstants::T_TEXT) .
228  " AND COALESCE(description, '') = ''"
229  );
230  if (($row = $this->db->fetchAssoc($res)) && isset($row['entry_id'])) {
231  $this->db->update(
232  'il_md_cpr_selections',
233  [
234  'full_name' => [\ilDBConstants::T_TEXT, $new_full_name],
235  'description' => [\ilDBConstants::T_TEXT, $new_description]
236  ],
237  ['entry_id' => [\ilDBConstants::T_INTEGER, $row['entry_id']]]
238  );
239  }
240  }
$res
Definition: ltiservices.php:66

◆ step_11()

ilMDCopyrightUpdateSteps::step_11 ( )

Change title of CC licences, see https://mantis.ilias.de/view.php?id=41898.

Definition at line 245 of file class.ilMDCopyrightUpdateSteps.php.

References $res, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

245  : void
246  {
247  $old_titles_by_link = [
248  'http://creativecommons.org/licenses/by-nc-nd/4.0/' => 'Attribution Non-commercial No Derivatives (by-nc-nd)',
249  'http://creativecommons.org/licenses/by-nc-sa/4.0/' => 'Attribution Non-commercial Share Alike (by-nc-sa)',
250  'http://creativecommons.org/licenses/by-nc/4.0/' => 'Attribution Non-commercial (by-nc)',
251  'http://creativecommons.org/licenses/by-nd/4.0/' => 'Attribution No Derivatives (by-nd)',
252  'http://creativecommons.org/licenses/by-sa/4.0/' => 'Attribution Share Alike (by-sa)',
253  'http://creativecommons.org/licenses/by/4.0/' => 'Attribution (by)'
254  ];
255  $new_titles_by_link = [
256  'http://creativecommons.org/licenses/by-nc-nd/4.0/' => 'Attribution Non-commercial No Derivatives (BY-NC-ND) 4.0',
257  'http://creativecommons.org/licenses/by-nc-sa/4.0/' => 'Attribution Non-commercial Share Alike (BY-NC-SA) 4.0',
258  'http://creativecommons.org/licenses/by-nc/4.0/' => 'Attribution Non-commercial (BY-NC) 4.0',
259  'http://creativecommons.org/licenses/by-nd/4.0/' => 'Attribution No Derivatives (BY-ND) 4.0',
260  'http://creativecommons.org/licenses/by-sa/4.0/' => 'Attribution Share Alike (BY-SA) 4.0',
261  'http://creativecommons.org/licenses/by/4.0/' => 'Attribution (BY) 4.0'
262  ];
263 
264  foreach ($old_titles_by_link as $link => $old_title) {
265  $res = $this->db->query(
266  'SELECT entry_id FROM il_md_cpr_selections WHERE title = ' .
267  $this->db->quote($old_title, ilDBConstants::T_TEXT) . ' AND link = ' .
268  $this->db->quote($link, ilDBConstants::T_TEXT)
269  );
270  if (
271  ($row = $this->db->fetchAssoc($res)) &&
272  isset($row['entry_id']) &&
273  isset($new_titles_by_link[$link])
274  ) {
275  $this->db->update(
276  'il_md_cpr_selections',
277  ['title' => [\ilDBConstants::T_TEXT, $new_titles_by_link[$link]]],
278  ['entry_id' => [\ilDBConstants::T_INTEGER, $row['entry_id']]]
279  );
280  }
281  }
282  }
$res
Definition: ltiservices.php:66

◆ step_12()

ilMDCopyrightUpdateSteps::step_12 ( )

Also change description of unmigrated 'All rights reserved', see https://mantis.ilias.de/view.php?id=41301.

Definition at line 288 of file class.ilMDCopyrightUpdateSteps.php.

References $res, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

288  : void
289  {
290  $title = "All rights reserved";
291  $old_copyright = "This work has all rights reserved by the owner.";
292  $new_description = "The copyright holder reserves, or holds for their own use, all the rights provided by copyright law.";
293 
294  $res = $this->db->query(
295  'SELECT entry_id FROM il_md_cpr_selections WHERE title = ' .
296  $this->db->quote($title, ilDBConstants::T_TEXT) . ' AND copyright = ' .
297  $this->db->quote($old_copyright, ilDBConstants::T_TEXT) .
298  " AND COALESCE(description, '') = ''"
299  );
300  if (($row = $this->db->fetchAssoc($res)) && isset($row['entry_id'])) {
301  $this->db->update(
302  'il_md_cpr_selections',
303  ['description' => [\ilDBConstants::T_TEXT, $new_description]],
304  ['entry_id' => [\ilDBConstants::T_INTEGER, $row['entry_id']]]
305  );
306  }
307  }
$res
Definition: ltiservices.php:66

◆ step_2()

ilMDCopyrightUpdateSteps::step_2 ( )

Add a column to il_md_cpr_selections for the link to the licence.

Definition at line 47 of file class.ilMDCopyrightUpdateSteps.php.

References ilDBConstants\T_CLOB.

47  : void
48  {
49  if (!$this->db->tableColumnExists('il_md_cpr_selections', 'link')) {
50  $this->db->addTableColumn(
51  'il_md_cpr_selections',
52  'link',
53  ['type' => ilDBConstants::T_CLOB]
54  );
55  }
56  }

◆ step_3()

ilMDCopyrightUpdateSteps::step_3 ( )

Add a column to il_md_cpr_selections for the link to the licence's image.

Definition at line 61 of file class.ilMDCopyrightUpdateSteps.php.

References ilDBConstants\T_CLOB.

61  : void
62  {
63  if (!$this->db->tableColumnExists('il_md_cpr_selections', 'image_link')) {
64  $this->db->addTableColumn(
65  'il_md_cpr_selections',
66  'image_link',
67  ['type' => ilDBConstants::T_CLOB]
68  );
69  }
70  }

◆ step_4()

ilMDCopyrightUpdateSteps::step_4 ( )

Add a column to il_md_cpr_selections for the alt text of the licence's image.

Definition at line 75 of file class.ilMDCopyrightUpdateSteps.php.

References ilDBConstants\T_CLOB.

75  : void
76  {
77  if (!$this->db->tableColumnExists('il_md_cpr_selections', 'alt_text')) {
78  $this->db->addTableColumn(
79  'il_md_cpr_selections',
80  'alt_text',
81  ['type' => ilDBConstants::T_CLOB]
82  );
83  }
84  }

◆ step_5()

ilMDCopyrightUpdateSteps::step_5 ( )

Add a column to il_md_cpr_selections to track which licences have been migrated.

Definition at line 89 of file class.ilMDCopyrightUpdateSteps.php.

References ilDBConstants\T_INTEGER.

89  : void
90  {
91  if (!$this->db->tableColumnExists('il_md_cpr_selections', 'migrated')) {
92  $this->db->addTableColumn(
93  'il_md_cpr_selections',
94  'migrated',
95  [
96  'type' => ilDBConstants::T_INTEGER,
97  'length' => 4,
98  'default' => 0
99  ]
100  );
101  }
102  }

◆ step_6()

ilMDCopyrightUpdateSteps::step_6 ( )

Add a column to il_md_cpr_selections for the string identifier for the licence's image, if it is saved as a file.

Definition at line 108 of file class.ilMDCopyrightUpdateSteps.php.

References ilDBConstants\T_CLOB.

108  : void
109  {
110  if (!$this->db->tableColumnExists('il_md_cpr_selections', 'image_file')) {
111  $this->db->addTableColumn(
112  'il_md_cpr_selections',
113  'image_file',
114  ['type' => ilDBConstants::T_CLOB]
115  );
116  }
117  }

◆ step_7()

ilMDCopyrightUpdateSteps::step_7 ( )

Add CC0 to the available copyrights.

Definition at line 122 of file class.ilMDCopyrightUpdateSteps.php.

References $res, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

122  : void
123  {
124  $title = "Public Domain";
125  $full_name = "This work is free of known copyright restrictions.";
126  $link = "http://creativecommons.org/publicdomain/zero/1.0/";
127  $image_link = "https://licensebuttons.net/p/zero/1.0/88x31.png";
128  $alt_text = "CC0";
129 
130  $next_id = $this->db->nextId('il_md_cpr_selections');
131 
132  $res = $this->db->query(
133  'SELECT MAX(position) AS max FROM il_md_cpr_selections WHERE is_default = 0'
134  );
135  $row = $this->db->fetchAssoc($res);
136  $position = isset($row['max']) ? $row['max'] + 1 : 0;
137 
138  $this->db->insert(
139  'il_md_cpr_selections',
140  [
141  'entry_id' => [\ilDBConstants::T_INTEGER, $next_id],
142  'title' => [\ilDBConstants::T_TEXT, $title],
143  'description' => [\ilDBConstants::T_TEXT, ''],
144  'is_default' => [\ilDBConstants::T_INTEGER, 0],
145  'outdated' => [\ilDBConstants::T_INTEGER, 0],
146  'position' => [\ilDBConstants::T_INTEGER, $position],
147  'full_name' => [\ilDBConstants::T_TEXT, $full_name],
148  'link' => [\ilDBConstants::T_TEXT, $link],
149  'image_link' => [\ilDBConstants::T_TEXT, $image_link],
150  'image_file' => [\ilDBConstants::T_TEXT, ''],
151  'alt_text' => [\ilDBConstants::T_TEXT, $alt_text],
152  'migrated' => [\ilDBConstants::T_INTEGER, 1]
153  ]
154  );
155  }
$res
Definition: ltiservices.php:66

◆ step_8()

ilMDCopyrightUpdateSteps::step_8 ( )

Replace CC0 image link by svg.

Definition at line 160 of file class.ilMDCopyrightUpdateSteps.php.

References $res, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

160  : void
161  {
162  $title = "Public Domain";
163  $full_name = "This work is free of known copyright restrictions.";
164  $old_image_link = "https://licensebuttons.net/p/zero/1.0/88x31.png";
165  $new_image_link = "https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/cc-zero.svg";
166 
167  $res = $this->db->query(
168  'SELECT entry_id FROM il_md_cpr_selections WHERE title = ' .
169  $this->db->quote($title, ilDBConstants::T_TEXT) . ' AND full_name = ' .
170  $this->db->quote($full_name, ilDBConstants::T_TEXT) . ' AND image_link = ' .
171  $this->db->quote($old_image_link, ilDBConstants::T_TEXT)
172  );
173  if (($row = $this->db->fetchAssoc($res)) && isset($row['entry_id'])) {
174  $this->db->update(
175  'il_md_cpr_selections',
176  ['image_link' => [\ilDBConstants::T_TEXT, $new_image_link]],
177  ['entry_id' => [\ilDBConstants::T_INTEGER, $row['entry_id']]]
178  );
179  }
180  }
$res
Definition: ltiservices.php:66

◆ step_9()

ilMDCopyrightUpdateSteps::step_9 ( )

Change title, description and full name of 'All rights reserved', see https://mantis.ilias.de/view.php?id=41301.

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

References $res, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

186  : void
187  {
188  $title = "All rights reserved";
189  $old_full_name = "This work has all rights reserved by the owner.";
190  $new_full_name = "All rights reserved";
191  $new_description = "The copyright holder reserves, or holds for their own use, all the rights provided by copyright law.";
192 
193  $res = $this->db->query(
194  'SELECT entry_id FROM il_md_cpr_selections WHERE title = ' .
195  $this->db->quote($title, ilDBConstants::T_TEXT) . ' AND full_name = ' .
196  $this->db->quote($old_full_name, ilDBConstants::T_TEXT) .
197  " AND COALESCE(link, '') = '' AND COALESCE(description, '') = ''"
198  );
199  if (($row = $this->db->fetchAssoc($res)) && isset($row['entry_id'])) {
200  $this->db->update(
201  'il_md_cpr_selections',
202  [
203  'full_name' => [\ilDBConstants::T_TEXT, $new_full_name],
204  'description' => [\ilDBConstants::T_TEXT, $new_description]
205  ],
206  ['entry_id' => [\ilDBConstants::T_INTEGER, $row['entry_id']]]
207  );
208  }
209  }
$res
Definition: ltiservices.php:66

Field Documentation

◆ $db

ilDBInterface ilMDCopyrightUpdateSteps::$db
protected

Definition at line 23 of file class.ilMDCopyrightUpdateSteps.php.

Referenced by prepare().


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