added automatic file versioning to file assets
This commit is contained in:
parent
d81ebd361a
commit
fd76365c1b
4 changed files with 41 additions and 5 deletions
|
|
@ -93,7 +93,8 @@ create table FileAsset (
|
|||
assetId varchar(22) not null primary key,
|
||||
storageId varchar(22) not null,
|
||||
filename varchar(256) not null,
|
||||
fileSize int not null
|
||||
fileSize int not null,
|
||||
olderVersions text
|
||||
);
|
||||
|
||||
INSERT INTO settings VALUES ('commerceCheckoutCanceledTemplateId','1');
|
||||
|
|
|
|||
|
|
@ -501,6 +501,7 @@ sub purge {
|
|||
}
|
||||
WebGUI::SQL->commit;
|
||||
$self = undef;
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub setParent {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,11 @@ sub definition {
|
|||
fileSize=>{
|
||||
fieldType=>'hidden',
|
||||
defaultValue=>undef
|
||||
}
|
||||
},
|
||||
olderVersions=>{
|
||||
fieldType=>'hidden',
|
||||
defaultValue=>undef
|
||||
}
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($definition);
|
||||
|
|
@ -117,6 +121,26 @@ sub getName {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge
|
||||
|
||||
=cut
|
||||
|
||||
sub purge {
|
||||
my $self = shift;
|
||||
my @old = split("\n",$self->get("olderVersions"));
|
||||
foreach my $oldone (@old) {
|
||||
my ($storageId, $filename) = split("|",$oldone);
|
||||
my $storage = WebGUI::Storage->new($storageId);
|
||||
$storage->delete;
|
||||
}
|
||||
my $storage = WebGUI::Storage->new($self->get("storageId"));
|
||||
$storage->delete;
|
||||
return $self->SUPER::purge;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSave
|
||||
|
|
@ -131,11 +155,21 @@ sub www_editSave {
|
|||
my $storage = WebGUI::Storage->create;
|
||||
my $filename = $storage->addFileFromFormPost("file");
|
||||
if (defined $filename) {
|
||||
my $oldVersions;
|
||||
if ($self->get($filename)) { # do file versioning
|
||||
my @old = split("\n",$self->get("olderVersions"));
|
||||
push(@old,$self->get{"storageId")."|".$self->get("filename"));
|
||||
$oldVersions = join("\n",@old);
|
||||
}
|
||||
$self->update({
|
||||
filename=>$filename,
|
||||
storageId=>$storage->getId,
|
||||
fileSize=>$storage->getFileSize
|
||||
fileSize=>$storage->getFileSize,
|
||||
olderVersions=>$oldVersions
|
||||
});
|
||||
} else {
|
||||
$storage->delete;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -242,13 +242,13 @@ sub www_editUser {
|
|||
if ($u->userId eq $session{user}{userId}) {
|
||||
$tabform->getTab("account")->hidden("status",$u->status);
|
||||
} else {
|
||||
$tabform->getTab("account")->select("status",\%status,$i18n->get(816),[$u->status]);
|
||||
$tabform->getTab("account")->selectList("status",\%status,$i18n->get(816),[$u->status]);
|
||||
}
|
||||
my $options;
|
||||
foreach (@{$session{config}{authMethods}}) {
|
||||
$options->{$_} = $_;
|
||||
}
|
||||
$tabform->getTab("account")->select(
|
||||
$tabform->getTab("account")->selectList(
|
||||
-name=>"authMethod",
|
||||
-options=>$options,
|
||||
-label=>$i18n->get(164),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue