Lines 4924-4929
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
Link Here
|
4924 |
} |
4924 |
} |
4925 |
|
4925 |
|
4926 |
|
4926 |
|
|
|
4927 |
$DBversion = "3.07.00.XXX"; #FIXME |
4928 |
if ( C4::Context->preference("Version") lt TransformToNum($DBversion) ) { |
4929 |
$dbh->do("ALTER TABLE virtualshelves MODIFY COLUMN owner int"); #should have been int already (fk to borrowers) |
4930 |
$dbh->do("UPDATE virtualshelves vi LEFT JOIN borrowers bo ON bo.borrowernumber=vi.owner SET vi.owner=NULL where bo.borrowernumber IS NULL"); #before adding the constraint on borrowernumber, we need to get rid of deleted owners |
4931 |
$dbh->do("DELETE FROM virtualshelves WHERE owner IS NULL and category=1"); #delete private lists without owner (cascades to shelfcontents) |
4932 |
$dbh->do("ALTER TABLE virtualshelves ADD COLUMN allow_add tinyint(1) DEFAULT 0, ADD COLUMN allow_delete_own tinyint(1) DEFAULT 1, ADD COLUMN allow_delete_other tinyint(1) DEFAULT 0, ADD CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL"); |
4933 |
$dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=1"); |
4934 |
$dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=2"); |
4935 |
$dbh->do("UPDATE virtualshelves SET allow_add=1, allow_delete_own=1, allow_delete_other=1 WHERE category=3"); |
4936 |
$dbh->do("UPDATE virtualshelves SET category=2 WHERE category=3"); |
4937 |
|
4938 |
$dbh->do("ALTER TABLE virtualshelfcontents ADD COLUMN borrowernumber int, ADD CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL"); |
4939 |
$dbh->do("UPDATE virtualshelfcontents co LEFT JOIN virtualshelves sh USING (shelfnumber) SET co.borrowernumber=sh.owner"); |
4940 |
|
4941 |
$dbh->do("CREATE TABLE virtualshelfshares |
4942 |
(id int AUTO_INCREMENT PRIMARY KEY, shelfnumber int NOT NULL, |
4943 |
borrowernumber int, invitekey varchar(10), sharedate datetime, |
4944 |
CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE, |
4945 |
CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8"); |
4946 |
|
4947 |
$dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAllowPublicListCreation',1,'If set, allows opac users to create public lists',NULL,'YesNo');"); |
4948 |
$dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAllowSharingPrivateLists',0,'If set, allows opac users to share private lists with other patrons',NULL,'YesNo');"); |
4949 |
|
4950 |
print "Upgrade to $DBversion done (BZ7310: Improving list permissions)\n"; |
4951 |
SetVersion($DBversion); |
4952 |
} |
4953 |
|
4927 |
=head1 FUNCTIONS |
4954 |
=head1 FUNCTIONS |
4928 |
|
4955 |
|
4929 |
=head2 DropAllForeignKeys($table) |
4956 |
=head2 DropAllForeignKeys($table) |
4930 |
- |
|
|