bunch of bug fixes

This commit is contained in:
JT Smith 2005-03-23 19:15:23 +00:00
parent c7b19a74bb
commit 01c0802c22
11 changed files with 40 additions and 25 deletions

View file

@ -194,14 +194,13 @@ sub getStorageLocation {
sub processPropertiesFromFormPost {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost;
my $storage = $self->getStorageLocation->create;
# might have to create a new storage location for versioning
my $storage = ($self->get("storageId") eq "") ? $self->getStorageLocation : $self->getStorageLocation->create;
my $filename = $storage->addFileFromFormPost("file");
if (defined $filename) {
my $oldVersions;
my $oldVersions = $self->get("olderVersions");
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);
$oldVersions .= "\n".$self->get("storageId")."|".$self->get("filename");
}
my %data;
$data{filename} = $filename;

View file

@ -418,6 +418,7 @@ sub getTemplateVars {
$var{"attachment.url"} = $storage->getUrl($filename);
$var{"attachment.icon"} = $storage->getFileIconUrl($filename);
$var{"attachment.name"} = $filename;
$gotAttachment = 1;
}
push(@{$var{"attachment_loop"}}, {
url=>$storage->getUrl($filename),
@ -691,11 +692,11 @@ An integer between 1 and 5 (5 being best) to rate this post with.
sub rate {
my $self = shift;
my $rating = shift;
my $rating = shift || 3;
unless ($self->hasRated) {
WebGUI::SQL->write("insert into Post_rating (assetId,userId,ipAddress,dateOfRating,rating) values ("
.quote($self->getId).", ".quote($session{user}{userId}).", ".quote($session{env}{REMOTE_ADDR}).",
".WebGUI::DateTime::time().", $rating)");
".WebGUI::DateTime::time().", ".quote($rating).")");
my ($count) = WebGUI::SQL->quickArray("select count(*) from Post_rating where assetId=".quote($self->getId));
$count = $count || 1;
my ($sum) = WebGUI::SQL->quickArray("select sum(rating) from Post_rating where assetId=".quote($self->getId));

View file

@ -854,7 +854,7 @@ sub view {
left join asset on Thread.assetId=asset.assetId
left join Post on Post.assetId=asset.assetId
where asset.parentId=".quote($self->getId)." and asset.state='published' and asset.className='WebGUI::Asset::Post::Thread' and $constraints
order by ".$sortBy." ".$sortOrder;
order by Thread.isLocked desc, ".$sortBy." ".$sortOrder;
my $p = WebGUI::Paginator->new($self->getUrl,$self->get("threadsPerPage"));
$self->appendPostListTemplateVars(\%var, $sql, $p);
$self->appendTemplateLabels(\%var);