Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 7b6e8bd

Browse files
committed
ENH: refs #460 #487 #485. Upgrade script for new license table
1 parent 19c5f47 commit 7b6e8bd

File tree

3 files changed

+160
-4
lines changed

3 files changed

+160
-4
lines changed

core/constant/license.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
define("LICENSE_ODC_BY", 1); // Attribution for data/databases http://www.opendatacommons.org/licenses/by/summary/
2323
define("LICENSE_ODBL", 2); // Attribution Share-Alike for data/databases http://www.opendatacommons.org/licenses/odbl/summary/
2424
define("LICENSE_RESERVED", 3); //This work is copyrighted by is owner and cannot be shared, distributed or modified without prior consent of the author.
25-
define("LICENSE_CC_ATRRIBUTION", 4); // Attribution 3.0 Unported (CC BY 3.0) http://creativecommons.org/licenses/by/3.0/
26-
define("LICENSE_CC_ATRRIBUTION_SHAREALIKE", 5); // Attribution-ShareAlike 3.0 Unported http://creativecommons.org/licenses/by-sa/3.0/
25+
define("LICENSE_CC_ATTRIBUTION", 4); // Attribution 3.0 Unported (CC BY 3.0) http://creativecommons.org/licenses/by/3.0/
26+
define("LICENSE_CC_ATTRIBUTION_SHAREALIKE", 5); // Attribution-ShareAlike 3.0 Unported http://creativecommons.org/licenses/by-sa/3.0/
2727
define("LICENSE_CC_NODERIVS", 6); // Attribution-NoDerivs 3.0 Unported (CC BY-ND 3.0) http://creativecommons.org/licenses/by-nd/3.0/
2828
define("LICENSE_CC_NONCOMMERCIAL", 7); // Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0) http://creativecommons.org/licenses/by-nc/3.0/
2929
define("LICENSE_CC_NONCOMMERCIAL_SHARELIKE", 8); // Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) http://creativecommons.org/licenses/by-nc-sa/3.0/

core/database/upgrade/3.2.2.php

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
3+
class Upgrade_3_2_2 extends MIDASUpgrade
4+
{
5+
var $existingLicenses;
6+
7+
public function preUpgrade()
8+
{
9+
$this->existingLicenses = array(
10+
array('constant' => LICENSE_PDDL,
11+
'name' => 'Public (PDDL)',
12+
'fulltext' => '<b>You are free:</b><ul>'.
13+
'<li>To Share: To copy, distribute and use the database.</li>'.
14+
'<li>To Create: To produce works from the database.</li>'.
15+
'<li>To Adapt: To modify, transform, and build upon the database.</li></ul>'.
16+
'<a href="opendatacommons.org/licenses/pddl/summary">Full License Information</a>'),
17+
array('constant' => LICENSE_ODC_BY,
18+
'name' => 'Public: Attribution (ODC-BY)',
19+
'fulltext' => '<b>You are free:</b><ul>'.
20+
'<li>To Share: To copy, distribute and use the database.</li>'.
21+
'<li>To Create: To produce works from the database.</li>'.
22+
'<li>To Adapt: To modify, transform, and build upon the database.</li></ul>'.
23+
'<b>As long as you:</b><ul>'.
24+
'<li>Attribute: You must attribute any public use of the database, or works produced from the database, '.
25+
'in the manner specified in the license. For any use or redistribution of the database, or works produced '.
26+
'from it, you must make clear to others the license of the database and keep intact any notices on the '.
27+
'original database.</li></ul>'.
28+
'<a href="opendatacommons.org/licenses/by/summary">Full License Information</a>'),
29+
array('constant' => LICENSE_ODBL,
30+
'name' => 'Public: Attribution, Share-Alike (ODBL)',
31+
'fulltext' => '<b>You are free:</b><ul>'.
32+
'<li>To Share: To copy, distribute and use the database.</li>'.
33+
'<li>To Create: To produce works from the database.</li>'.
34+
'<li>To Adapt: To modify, transform, and build upon the database.</li></ul>'.
35+
'<b>As long as you:</b><ul>'.
36+
'<li>Attribute: You must attribute any public use of the database, or works produced from the database, '.
37+
'in the manner specified in the license. For any use or redistribution of the database, or works produced '.
38+
'from it, you must make clear to others the license of the database and keep intact any notices on the '.
39+
'original database.</li>'.
40+
'<li>Share-Alike: If you publicly use any adapted version of this database, or works produced from an adapted '.
41+
'database, you must also offer that adapted database under the ODbL.</li>'.
42+
'<li>Keep open: If you redistribute the database, or an adapted version of it, then you may use technological '.
43+
'measures that restrict the work (such as DRM) as long as you also redistribute a version without such measures.</li></ul>'.
44+
'<a href="opendatacommons.org/licenses/odbl/summary">Full License Information</a>'),
45+
array('constant' => LICENSE_RESERVED,
46+
'name' => 'Private: All right reserved',
47+
'fulltext' => 'This work is copyrighted by its owner and cannot be shared, distributed or modified without prior consent of the author.'),
48+
array('constant' => LICENSE_CC_ATTRIBUTION,
49+
'name' => 'Public: Attribution (CC BY 3.0)',
50+
'fulltext' => '<b>You are free:</b><ul>'.
51+
'<li>To Share: To copy, distribute and transmit the work.</li>'.
52+
'<li>To Remix: To adapt the work.</li>'.
53+
'<li>To make commercial use of the work.</li></ul>'.
54+
'<b>Under the following conditions:</b><ul>'.
55+
'<li>Attribution: You must attribute the work in the manner specified by the author or licensor '.
56+
'(but not in any way that suggests that they endorse you or your use of the work)</li></ul>'.
57+
'<a href="http://creativecommons.org/licenses/by/3.0/">Full License Information</a>'),
58+
array('constant' => LICENSE_CC_ATTRIBUTION_SHAREALIKE,
59+
'name' => 'Public: Attribution, Share-Alike (CC BY-SA 3.0)',
60+
'fulltext' => '<b>You are free:</b><ul>'.
61+
'<li>To Share: To copy, distribute and transmit the work.</li>'.
62+
'<li>To Remix: To adapt the work.</li>'.
63+
'<li>To make commercial use of the work.</li></ul>'.
64+
'<b>Under the following conditions:</b><ul>'.
65+
'<li>Attribution: You must attribute the work in the manner specified by the author or licensor '.
66+
'(but not in any way that suggests that they endorse you or your use of the work)</li>'.
67+
'<li>Share Alike: If you alter, transform, or build upon this work, you may distribute the resulting '.
68+
'work only under the same or similar license to this one.</li></ul>'.
69+
'<a href="http://creativecommons.org/licenses/by-sa/3.0/">Full License Information</a>'),
70+
array('constant' => LICENSE_CC_NODERIVS,
71+
'name' => 'Public: Attribution, No Derivative Works (CC BY-ND 3.0)',
72+
'fulltext' => '<b>You are free:</b><ul>'.
73+
'<li>To Share: To copy, distribute and transmit the work.</li>'.
74+
'<li>To make commercial use of the work.</li></ul>'.
75+
'<b>Under the following conditions:</b><ul>'.
76+
'<li>Attribution: You must attribute the work in the manner specified by the author or licensor '.
77+
'(but not in any way that suggests that they endorse you or your use of the work)</li>'.
78+
'<li>No Derivative Works: You may not alter, transform, or build upon this work.</li></ul>'.
79+
'<a href="http://creativecommons.org/licenses/by-nd/3.0/">Full License Information</a>'),
80+
array('constant' => LICENSE_CC_NONCOMMERCIAL,
81+
'name' => 'Public: Attribution, Non Commercial (CC BY-NC 3.0)',
82+
'fulltext' => '<b>You are free:</b><ul>'.
83+
'<li>To Share: To copy, distribute and transmit the work.</li>'.
84+
'<li>To Remix: To adapt the work.</li></ul>'.
85+
'<b>Under the following conditions:</b><ul>'.
86+
'<li>Attribution: You must attribute the work in the manner specified by the author or licensor '.
87+
'(but not in any way that suggests that they endorse you or your use of the work)</li>'.
88+
'<li>Noncommercial: You may not use this work for commercial purposes.</li></ul>'.
89+
'<a href="http://creativecommons.org/licenses/by-nc/3.0/">Full License Information</a>'),
90+
array('constant' => LICENSE_CC_NONCOMMERCIAL_SHARELIKE,
91+
'name' => 'Public: Attribution, Non Commercial, Share-Alike (CC BY-NC-SA 3.0)',
92+
'fulltext' => '<b>You are free:</b><ul>'.
93+
'<li>To Share: To copy, distribute and transmit the work.</li>'.
94+
'<li>To Remix: To adapt the work.</li></ul>'.
95+
'<b>Under the following conditions:</b><ul>'.
96+
'<li>Attribution: You must attribute the work in the manner specified by the author or licensor '.
97+
'(but not in any way that suggests that they endorse you or your use of the work)</li>'.
98+
'<li>Noncommercial: You may not use this work for commercial purposes.</li>'.
99+
'<li>Share Alike: If you alter, transform, or build upon this work, you may distribute the resulting '.
100+
'work only under the same or similar license to this one.</li></ul>'.
101+
'<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Full License Information</a>'),
102+
array('constant' => LICENSE_CC_NONCOMMERCIAL_NODERIVS,
103+
'name' => 'Public: Attribution, Non Commercial, No Derivative Works (CC BY-NC-ND 3.0)',
104+
'fulltext' => '<b>You are free:</b><ul>'.
105+
'<li>To Share: To copy, distribute and transmit the work.</li></ul>'.
106+
'<b>Under the following conditions:</b><ul>'.
107+
'<li>Attribution: You must attribute the work in the manner specified by the author or licensor '.
108+
'(but not in any way that suggests that they endorse you or your use of the work)</li>'.
109+
'<li>Noncommercial: You may not use this work for commercial purposes.</li>'.
110+
'<li>No Derivative Works: You may not alter, transform, or build upon this work.</li></ul>'.
111+
'<a href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Full License Information</a>')
112+
);
113+
}
114+
115+
/**
116+
* Create the license table. Add our default license set to it.
117+
* Replace old reference column with a new one pointing at the license table entries.
118+
*/
119+
public function mysql()
120+
{
121+
// Create the license table
122+
$this->db->query("CREATE TABLE `license` (
123+
`license_id` bigint(20) NOT NULL AUTO_INCREMENT,
124+
`name` TEXT NOT NULL DEFAULT '',
125+
`fulltext` TEXT NOT NULL DEFAULT '',
126+
PRIMARY KEY (`license_id`)
127+
)");
128+
129+
// Add a logical foreign key for license into the itemrevision table
130+
$this->db->query("ALTER TABLE `itemrevision` ADD COLUMN `license_id` bigint(20) NOT NULL");
131+
132+
// Add existing licenses to the database
133+
foreach($this->existingLicenses as $value)
134+
{
135+
$this->db->insert('license', array('name' => $value['name'], 'fulltext' => $value['fulltext']));
136+
$id = $this->db->lastInsertId('license', 'license_id');
137+
138+
// Update existing license references to point to our new table
139+
$this->db->update('itemrevision',
140+
array('license_id' => $id),
141+
array('license = ?' => $value['constant']));
142+
}
143+
144+
// Remove the obsolete column from the item revision table
145+
$this->db->query("ALTER TABLE `itemrevision` DROP `license`");
146+
}
147+
148+
public function pgsql()
149+
{
150+
}
151+
152+
public function postUpgrade()
153+
{
154+
}
155+
}
156+
?>

core/views/element/license.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ echo "<div class='licenseSelectContent'>
2727
</optgroup>
2828
<optgroup label='Document'>
2929
<option value='".LICENSE_RESERVED."' ".(($this->selectedLicense==LICENSE_RESERVED)?'selected':'').">Private: All right reserved</option>
30-
<option value='".LICENSE_CC_ATRRIBUTION."' ".(($this->selectedLicense==LICENSE_CC_ATRRIBUTION)?'selected':'').">Public: Attribution (CC BY 3.0)</option>
31-
<option value='".LICENSE_CC_ATRRIBUTION_SHAREALIKE."' ".(($this->selectedLicense==LICENSE_CC_ATRRIBUTION_SHAREALIKE)?'selected':'').">Public: Attribution, Share-Alike (CC BY-SA 3.0)</option>
30+
<option value='".LICENSE_CC_ATTRIBUTION."' ".(($this->selectedLicense==LICENSE_CC_ATTRIBUTION)?'selected':'').">Public: Attribution (CC BY 3.0)</option>
31+
<option value='".LICENSE_CC_ATTRIBUTION_SHAREALIKE."' ".(($this->selectedLicense==LICENSE_CC_ATTRIBUTION_SHAREALIKE)?'selected':'').">Public: Attribution, Share-Alike (CC BY-SA 3.0)</option>
3232
<option value='".LICENSE_CC_NODERIVS."' ".(($this->selectedLicense==LICENSE_CC_NODERIVS)?'selected':'').">Public: Attribution, No Derivative Works CC BY-ND 3.0)</option>
3333
<option value='".LICENSE_CC_NONCOMMERCIAL."' ".(($this->selectedLicense==LICENSE_CC_NONCOMMERCIAL)?'selected':'').">Public: Attribution, Non Commercial (CC BY-NC 3.0)</option>
3434
<option value='".LICENSE_CC_NONCOMMERCIAL_SHARELIKE."' ".(($this->selectedLicense==LICENSE_CC_NONCOMMERCIAL_SHARELIKE)?'selected':'').">Public: Attribution, Non Commercial, Share-Alike (CC BY-NC-SA 3.0)</option>

0 commit comments

Comments
 (0)