Lines 4960-4965
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
Link Here
|
4960 |
SetVersion($DBversion); |
4960 |
SetVersion($DBversion); |
4961 |
} |
4961 |
} |
4962 |
|
4962 |
|
|
|
4963 |
$DBversion = "3.07.99.XXX"; #FIXME |
4964 |
if ( C4::Context->preference("Version") lt TransformToNum($DBversion) ) { |
4965 |
$dbh->do("ALTER TABLE virtualshelves MODIFY COLUMN owner int"); #should have been int already (fk to borrowers) |
4966 |
$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 |
4967 |
$dbh->do("DELETE FROM virtualshelves WHERE owner IS NULL and category=1"); #delete private lists without owner (cascades to shelfcontents) |
4968 |
$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"); |
4969 |
$dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=1"); |
4970 |
$dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=2"); |
4971 |
$dbh->do("UPDATE virtualshelves SET allow_add=1, allow_delete_own=1, allow_delete_other=1 WHERE category=3"); |
4972 |
$dbh->do("UPDATE virtualshelves SET category=2 WHERE category=3"); |
4973 |
|
4974 |
$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"); |
4975 |
$dbh->do("UPDATE virtualshelfcontents co LEFT JOIN virtualshelves sh USING (shelfnumber) SET co.borrowernumber=sh.owner"); |
4976 |
|
4977 |
$dbh->do("CREATE TABLE virtualshelfshares |
4978 |
(id int AUTO_INCREMENT PRIMARY KEY, shelfnumber int NOT NULL, |
4979 |
borrowernumber int, invitekey varchar(10), sharedate datetime, |
4980 |
CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE, |
4981 |
CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8"); |
4982 |
|
4983 |
$dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAllowPublicListCreation',1,'If set, allows opac users to create public lists',NULL,'YesNo');"); |
4984 |
$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');"); |
4985 |
|
4986 |
print "Upgrade to $DBversion done (BZ7310: Improving list permissions)\n"; |
4987 |
SetVersion($DBversion); |
4988 |
} |
4989 |
|
4963 |
=head1 FUNCTIONS |
4990 |
=head1 FUNCTIONS |
4964 |
|
4991 |
|
4965 |
=head2 DropAllForeignKeys($table) |
4992 |
=head2 DropAllForeignKeys($table) |
4966 |
- |
|
|