From 23bdc52690a43f7c32dcf7c0d0969758083b5d75 Mon Sep 17 00:00:00 2001 From: Tim Schmitz Date: Mon, 12 Aug 2024 15:52:46 +0200 Subject: [PATCH] MetaData: small changes to pre-installed copyright licences (41301, 41898) --- .../Setup/class.ilMDCopyrightMigration.php | 12 ++ .../Setup/class.ilMDCopyrightUpdateSteps.php | 104 +++++++++++++++++- components/ILIAS/MetaData/docs/copyrights.md | 20 ++-- 3 files changed, 124 insertions(+), 12 deletions(-) diff --git a/components/ILIAS/MetaData/classes/Setup/class.ilMDCopyrightMigration.php b/components/ILIAS/MetaData/classes/Setup/class.ilMDCopyrightMigration.php index 57e150e93796..ad6f59894124 100755 --- a/components/ILIAS/MetaData/classes/Setup/class.ilMDCopyrightMigration.php +++ b/components/ILIAS/MetaData/classes/Setup/class.ilMDCopyrightMigration.php @@ -110,6 +110,7 @@ protected function extractFields(string $copyright): array } $image_link = $this->translatePreInstalledLinksToSVG($image_link); + $full_name = $this->cleanupPreInstalledPublicDomainFullName($full_name); return [ 'full_name' => [\ilDBConstants::T_TEXT, $full_name], @@ -143,4 +144,15 @@ protected function translatePreInstalledLinksToSVG(string $image_link): string } return $image_link; } + + /** + * see https://mantis.ilias.de/view.php?id=41301 + */ + protected function cleanupPreInstalledPublicDomainFullName(string $full_name): string + { + if ($full_name === 'This work has all rights reserved by the owner.') { + return 'All rights reserved'; + } + return $full_name; + } } diff --git a/components/ILIAS/MetaData/classes/Setup/class.ilMDCopyrightUpdateSteps.php b/components/ILIAS/MetaData/classes/Setup/class.ilMDCopyrightUpdateSteps.php index 732b771855f2..5cadc8b15e45 100755 --- a/components/ILIAS/MetaData/classes/Setup/class.ilMDCopyrightUpdateSteps.php +++ b/components/ILIAS/MetaData/classes/Setup/class.ilMDCopyrightUpdateSteps.php @@ -164,8 +164,6 @@ public function step_8(): void $old_image_link = "https://licensebuttons.net/p/zero/1.0/88x31.png"; $new_image_link = "https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/cc-zero.svg"; - $next_id = $this->db->nextId('il_md_cpr_selections'); - $res = $this->db->query( 'SELECT entry_id FROM il_md_cpr_selections WHERE title = ' . $this->db->quote($title, ilDBConstants::T_TEXT) . ' AND full_name = ' . @@ -180,4 +178,106 @@ public function step_8(): void ); } } + + /** + * Change title, description and full name of 'All rights reserved', + * see https://mantis.ilias.de/view.php?id=41301 + */ + public function step_9(): void + { + $title = "All rights reserved"; + $old_full_name = "This work has all rights reserved by the owner."; + $new_full_name = "All rights reserved"; + $new_description = "The copyright holder reserves, or holds for their own use, all the rights provided by copyright law."; + + $res = $this->db->query( + 'SELECT entry_id FROM il_md_cpr_selections WHERE title = ' . + $this->db->quote($title, ilDBConstants::T_TEXT) . ' AND full_name = ' . + $this->db->quote($old_full_name, ilDBConstants::T_TEXT) . + " AND COALESCE(link, '') = '' AND COALESCE(description, '') = ''" + ); + if (($row = $this->db->fetchAssoc($res)) && isset($row['entry_id'])) { + $this->db->update( + 'il_md_cpr_selections', + [ + 'full_name' => [\ilDBConstants::T_TEXT, $new_full_name], + 'description' => [\ilDBConstants::T_TEXT, $new_description] + ], + ['entry_id' => [\ilDBConstants::T_INTEGER, $row['entry_id']]] + ); + } + } + + /** + * Change title, description and full name of 'Public Domain', + * see https://mantis.ilias.de/view.php?id=41301 + */ + public function step_10(): void + { + $title = "Public Domain"; + $link = "http://creativecommons.org/publicdomain/zero/1.0/"; + $old_full_name = "This work is free of known copyright restrictions."; + $new_full_name = "Public Domain"; + $new_description = "Creative work to which no exclusive intellectual property rights apply."; + + $res = $this->db->query( + 'SELECT entry_id FROM il_md_cpr_selections WHERE title = ' . + $this->db->quote($title, ilDBConstants::T_TEXT) . ' AND full_name = ' . + $this->db->quote($old_full_name, ilDBConstants::T_TEXT) . ' AND link = ' . + $this->db->quote($link, ilDBConstants::T_TEXT) . + " AND COALESCE(description, '') = ''" + ); + if (($row = $this->db->fetchAssoc($res)) && isset($row['entry_id'])) { + $this->db->update( + 'il_md_cpr_selections', + [ + 'full_name' => [\ilDBConstants::T_TEXT, $new_full_name], + 'description' => [\ilDBConstants::T_TEXT, $new_description] + ], + ['entry_id' => [\ilDBConstants::T_INTEGER, $row['entry_id']]] + ); + } + } + + /** + * Change title of CC licences, see https://mantis.ilias.de/view.php?id=41898 + */ + public function step_11(): void + { + $old_titles_by_link = [ + 'http://creativecommons.org/licenses/by-nc-nd/4.0/' => 'Attribution Non-commercial No Derivatives (by-nc-nd)', + 'http://creativecommons.org/licenses/by-nc-sa/4.0/' => 'Attribution Non-commercial Share Alike (by-nc-sa)', + 'http://creativecommons.org/licenses/by-nc/4.0/' => 'Attribution Non-commercial (by-nc)', + 'http://creativecommons.org/licenses/by-nd/4.0/' => 'Attribution No Derivatives (by-nd)', + 'http://creativecommons.org/licenses/by-sa/4.0/' => 'Attribution Share Alike (by-sa)', + 'http://creativecommons.org/licenses/by/4.0/' => 'Attribution (by)' + ]; + $new_titles_by_link = [ + 'http://creativecommons.org/licenses/by-nc-nd/4.0/' => 'Attribution Non-commercial No Derivatives (BY-NC-ND) 4.0', + 'http://creativecommons.org/licenses/by-nc-sa/4.0/' => 'Attribution Non-commercial Share Alike (BY-NC-SA) 4.0', + 'http://creativecommons.org/licenses/by-nc/4.0/' => 'Attribution Non-commercial (BY-NC) 4.0', + 'http://creativecommons.org/licenses/by-nd/4.0/' => 'Attribution No Derivatives (BY-ND) 4.0', + 'http://creativecommons.org/licenses/by-sa/4.0/' => 'Attribution Share Alike (BY-SA) 4.0', + 'http://creativecommons.org/licenses/by/4.0/' => 'Attribution (BY) 4.0' + ]; + + foreach ($old_titles_by_link as $link => $old_title) { + $res = $this->db->query( + 'SELECT entry_id FROM il_md_cpr_selections WHERE title = ' . + $this->db->quote($old_title, ilDBConstants::T_TEXT) . ' AND link = ' . + $this->db->quote($link, ilDBConstants::T_TEXT) + ); + if ( + ($row = $this->db->fetchAssoc($res)) && + isset($row['entry_id']) && + isset($new_titles_by_link[$link]) + ) { + $this->db->update( + 'il_md_cpr_selections', + ['title' => [\ilDBConstants::T_TEXT, $new_titles_by_link[$link]]], + ['entry_id' => [\ilDBConstants::T_INTEGER, $row['entry_id']]] + ); + } + } + } } diff --git a/components/ILIAS/MetaData/docs/copyrights.md b/components/ILIAS/MetaData/docs/copyrights.md index 166c0f492848..da91985212b0 100644 --- a/components/ILIAS/MetaData/docs/copyrights.md +++ b/components/ILIAS/MetaData/docs/copyrights.md @@ -13,16 +13,16 @@ version of the CC licenses. These can however be added manually. ## Pre-Installed Licenses -| Title | Full Name | URL | Image URL | -|------------------------------------------------------|------------------------------------------------------------------------------------|---------------------------------------------------|-----------------------------------------------------------------------------| -| All rights reserved | This work has all rights reserved by the owner. | - | - | -| Attribution Non-commercial No Derivatives (by-nc-nd) | Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License | http://creativecommons.org/licenses/by-nc-nd/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg | -| Attribution Non-commercial Share Alike (by-nc-sa) | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License | http://creativecommons.org/licenses/by-nc-sa/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg | -| Attribution Non-commercial (by-nc) | Creative Commons Attribution-NonCommercial 4.0 International License | http://creativecommons.org/licenses/by-nc/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc.svg | -| Attribution No Derivatives (by-nd) | Creative Commons Attribution-NoDerivatives 4.0 International License | http://creativecommons.org/licenses/by-nd/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nd.svg | -| Attribution Share Alike (by-sa) | Creative Commons Attribution-ShareAlike 4.0 International License | http://creativecommons.org/licenses/by-sa/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg | -| Attribution (by) | Creative Commons Attribution 4.0 International License | http://creativecommons.org/licenses/by/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg | -| Public Domain | This work is free of known copyright restrictions. | http://creativecommons.org/publicdomain/zero/1.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/cc-zero.svg | +| Title | Description | Full Name | URL | Image URL | +|----------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|---------------------------------------------------|-----------------------------------------------------------------------------| +| All rights reserved | The copyright holder reserves, or holds for their own use, all the rights provided by copyright law. | All rights reserved | - | - | +| Attribution Non-commercial No Derivatives (BY-NC-ND) 4.0 | Creative Commons License | Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License | http://creativecommons.org/licenses/by-nc-nd/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg | +| Attribution Non-commercial Share Alike (BY-NC-SA) 4.0 | Creative Commons License | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License | http://creativecommons.org/licenses/by-nc-sa/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg | +| Attribution Non-commercial (BY-NC) 4.0 | Creative Commons License | Creative Commons Attribution-NonCommercial 4.0 International License | http://creativecommons.org/licenses/by-nc/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc.svg | +| Attribution No Derivatives (BY-ND) 4.0 | Creative Commons License | Creative Commons Attribution-NoDerivatives 4.0 International License | http://creativecommons.org/licenses/by-nd/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nd.svg | +| Attribution Share Alike (BY-SA) 4.0 | Creative Commons License | Creative Commons Attribution-ShareAlike 4.0 International License | http://creativecommons.org/licenses/by-sa/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg | +| Attribution (BY) 4.0 | Creative Commons License | Creative Commons Attribution 4.0 International License | http://creativecommons.org/licenses/by/4.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg | +| Public Domain | Creative work to which no exclusive intellectual property rights apply. | Public Domain | http://creativecommons.org/publicdomain/zero/1.0/ | https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/cc-zero.svg | ## Default License