a whole pile of bug fixes

This commit is contained in:
JT Smith 2005-03-28 00:10:47 +00:00
parent 4ddc5d66ec
commit a50fd5787a
18 changed files with 234 additions and 61 deletions

View file

@ -97,7 +97,6 @@ A lineage is a concatenated series of sequence numbers, each six digits long, th
newByLineage
newByPropertyHashRef
newByUrl
republish
paste
processPropertiesFromFormPost
promote
@ -302,14 +301,14 @@ sub checkExportPath {
=head2 cut ( )
Removes asset from lineage, places it in clipboard state. The "gap" in the lineage is changed in state to limbo.
Removes asset from lineage, places it in clipboard state. The "gap" in the lineage is changed in state to clipboard-limbo.
=cut
sub cut {
my $self = shift;
WebGUI::SQL->beginTransaction;
WebGUI::SQL->write("update asset set state='limbo', lastUpdatedBy=".quote($session{user}{userId}).", lastUpdated=".time()." where lineage like ".quote($self->get("lineage").'%'));
WebGUI::SQL->write("update asset set state='clipboard-limbo', lastUpdatedBy=".quote($session{user}{userId}).", lastUpdated=".time()." where lineage like ".quote($self->get("lineage").'%')." and state='published'");
WebGUI::SQL->write("update asset set state='clipboard', lastUpdatedBy=".quote($session{user}{userId}).", lastUpdated=".time()." where assetId=".quote($self->getId));
WebGUI::SQL->commit;
$self->updateHistory("cut");
@ -591,7 +590,9 @@ sub fixUrl {
if (length($url) > 250) {
$url = substr($url,220);
}
$url .= ".".$session{setting}{urlExtension} if ($url =~ /\./ && $session{setting}{urlExtension} ne "");
if ($session{setting}{urlExtension} ne "" && !($url =~ /\./)) {
$url .= ".".$session{setting}{urlExtension};
}
my ($test) = WebGUI::SQL->quickArray("select url from asset where assetId<>".quote($self->getId)." and url=".quote($url));
if ($test) {
my @parts = split(/\./,$url);
@ -812,6 +813,10 @@ sub getAssetManagerControl {
$output .= "var manager = new AssetManager(assets,columnHeadings,labels,crumbtrail);\n";
$output .= "manager.assetType='".$controlType."';\n" if (defined $controlType);
$output .= "manager.disableDisplay(0);\n" if (defined $removeRank);
if ($controlType eq "ManageTrash" || $controlType eq "ManageClipboard") {
# $output .= "manager.displayCrumbTrail = false;\n";
# $output .= "manager.sortEnabled = false;\n";
}
$output .= "manager.renderAssets();\n";
$output .= "</script>\n";
return $output;
@ -1177,7 +1182,7 @@ A hash reference comprising modifiers to relative listing. Rules include:
=head4 statesToInclude
An array reference containing a list of states that should be returned. Defaults to 'published'. Options include 'published', 'trash', 'cliboard', and 'limbo'.
An array reference containing a list of states that should be returned. Defaults to 'published'. Options include 'published', 'trash', 'cliboard', 'clipboard-limbo' and 'trash-limbo'.
=head4 endingLineageLength
@ -1846,20 +1851,6 @@ sub newByUrl {
#-------------------------------------------------------------------
=head2 republish ( )
Sets Asset properties state to published.
=cut
sub republish {
my $self = shift;
WebGUI::SQL->write("update asset set state='published', lastUpdatedBy=".quote($session{user}{userId}).", lastUpdated=".time()." where lineage like ".quote($self->get("lineage").'%'));
$self->{_properties}{state} = "published";
}
#-------------------------------------------------------------------
=head2 paste ( assetId )
Returns 1 if can paste an asset to a Parent. Sets the Asset to published. Otherwise returns 0.
@ -1873,9 +1864,10 @@ Alphanumeric ID tag of Asset.
sub paste {
my $self = shift;
my $assetId = shift;
my $pastedAsset = WebGUI::Asset->new($assetId);
my $pastedAsset = WebGUI::Asset->newByDynamicClass($assetId);
if ($self->getId eq $pastedAsset->get("parentId") || $pastedAsset->setParent($self)) {
$pastedAsset->republish;
WebGUI::SQL->write("update asset set state='published', lastUpdatedBy=".quote($session{user}{userId}).", lastUpdated=".time()." where lineage like ".quote($self->get("lineage").'%')." and (state='clipboard' or state='clipboard-limbo')");
$self->{_properties}{state} = "published";
$pastedAsset->updateHistory("pasted to parent ".$self->getId);
return 1;
}
@ -1905,7 +1897,11 @@ sub processPropertiesFromFormPost {
}
$data{title} = "Untitled" unless ($data{title});
$data{menuTitle} = $data{title} unless ($data{menuTitle});
$data{url} = $self->getParent->get("url").'/'.$data{menuTitle} unless ($data{url});
unless ($data{url}) {
$data{url} = $self->getParent->get("url");
$data{url} =~ s/(.*)\..*/$1/;
$data{url} .= '/'.$data{menuTitle};
}
$self->update(\%data);
foreach my $form (keys %{$session{form}}) {
if ($form =~ /^metadata_(\d+)$/) {
@ -1992,6 +1988,20 @@ sub promote {
#-------------------------------------------------------------------
=head2 publish ( )
Sets an asset and it's descendants to a state of 'published' regardless of it's current state.
=cut
sub publish {
my $self = shift;
WebGUI::SQL->write("update asset set state='published', lastUpdatedBy=".quote($session{user}{userId}).", lastUpdated=".time()." where lineage like ".quote($self->get("lineage").'%'));
$self->{_properties}{state} = "published";
}
#-------------------------------------------------------------------
=head2 purge ( )
Returns 1. Deletes an asset from tables and removes anything bound to that asset.
@ -2022,7 +2032,7 @@ Returns 1. Purges self and all descendants.
sub purgeTree {
my $self = shift;
my $descendants = $self->getLineage(["self","descendants"],{returnObjects=>1, invertTree=>1, statesToInclude=>['trash','limbo']});
my $descendants = $self->getLineage(["self","descendants"],{returnObjects=>1, invertTree=>1, statesToInclude=>['trash','trash-limbo']});
foreach my $descendant (@{$descendants}) {
$descendant->purge;
}
@ -2153,14 +2163,14 @@ sub swapRank {
=head2 trash ( )
Removes asset from lineage, places it in trash state. The "gap" in the lineage is changed in state to limbo.
Removes asset from lineage, places it in trash state. The "gap" in the lineage is changed in state to trash-limbo.
=cut
sub trash {
my $self = shift;
WebGUI::SQL->beginTransaction;
WebGUI::SQL->write("update asset set state='limbo', lastUpdatedBy=".quote($session{user}{userId}).", lastUpdated=".time()." where lineage like ".quote($self->get("lineage").'%'));
WebGUI::SQL->write("update asset set state='trash-limbo', lastUpdatedBy=".quote($session{user}{userId}).", lastUpdated=".time()." where lineage like ".quote($self->get("lineage").'%'));
WebGUI::SQL->write("update asset set state='trash', lastUpdatedBy=".quote($session{user}{userId}).", lastUpdated=".time()." where assetId=".quote($self->getId));
WebGUI::SQL->commit;
$self->{_properties}{state} = "trash";
@ -2263,7 +2273,11 @@ Returns "".
=cut
sub view {
return "";
my $self = shift;
if ($session{var}{adminOn}) {
return $self->getToolbar;
}
return undef;
}
#-------------------------------------------------------------------
@ -2329,7 +2343,7 @@ sub www_copy {
Copies to clipboard assets in a list, then returns self calling method www_manageAssets(), if canEdit. Otherwise returns AdminConsole rendered insufficient privilege.
=cut
cut
sub www_copyList {
my $self = shift;
@ -3220,6 +3234,43 @@ sub www_promote {
}
#-------------------------------------------------------------------
=head2 www_restoreList ( )
Restores a piece of content from the trash back to it's original location.
=cut
sub www_purgeList {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
foreach my $id ($session{cgi}->param("assetId")) {
my $asset = WebGUI::Asset->newByDynamicClass($id);
$asset->purge;
}
return $self->www_manageTrash();
}
#-------------------------------------------------------------------
=head2 www_restoreList ( )
Restores a piece of content from the trash back to it's original location.
=cut
sub www_restoreList {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
foreach my $id ($session{cgi}->param("assetId")) {
my $asset = WebGUI::Asset->newByDynamicClass($id);
$asset->publish;
}
return $self->www_manageTrash();
}
#-------------------------------------------------------------------
=head2 www_setParent ( )

View file

@ -95,6 +95,7 @@ sub duplicate {
my $newAsset = $self->SUPER::duplicate(shift);
my $newStorage = $self->getStorageLocation->copy;
$newAsset->update({storageId=>$newStorage->getId,olderVersions=>''});
return $newAsset;
}

View file

@ -394,7 +394,7 @@ sub getTemplateVars {
$var{"reply.url"} = $self->getReplyUrl;
$var{'reply.withquote.url'} = $self->getReplyUrl(1);
$var{'url'} = $self->getUrl.'#'.$self->getId;
$var{'url'} = WebGUI::URL::getSiteURL().$self->getUrl.'#'.$self->getId;
$var{'rating.value'} = $self->get("rating")+0;
$var{'rate.url.1'} = $self->getRateUrl(1);
@ -467,7 +467,9 @@ sub getUploadControl {
if ($self->get("storageId")) {
my $i;
foreach my $filename (@{$self->getStorageLocation->getFiles}) {
$uploadControl .= '<a href="'.$self->getStorageLocation->getUrl($filename).'">'.$filename.'</a><br />';
$uploadControl .= deleteIcon("func=deleteFile&filename=".$filename,$self->get("url"),WebGUI::International::get("delete file warning","Collaboration"))
.' <a href="'.$self->getStorageLocation->getUrl($filename).'">'.$filename.'</a>'
.'<br />';
$i++;
}
return $uploadControl unless ($i < $maxAttachments);
@ -650,7 +652,7 @@ sub processPropertiesFromFormPost {
$data{endDate} = $self->getThread->getParent->get("endDate") unless ($session{form}{endDate});
($data{synopsis}, $data{content}) = $self->getSynopsisAndContentFromFormPost;
if ($self->getThread->getParent->get("addEditStampToPosts")) {
$data{content} .= "\n\n --- (Edited on ".WebGUI::DateTime::epochToHuman()." by ".$session{user}{alias}.") --- \n";
$data{content} .= "\n\n --- (Edited on ".WebGUI::DateTime::epochToHuman(undef,"%z %Z [GMT%O]")." by ".$session{user}{alias}.") --- \n";
if ($self->getValue("contentType") eq "mixed" || $self->getValue("contentType") eq "html") {
$data{content} = '<p>'.$data{content}.'</p>';
}
@ -809,6 +811,14 @@ sub www_approve {
return $self->www_view;
}
#-------------------------------------------------------------------
sub www_deleteFile {
my $self = shift;
$self->getStorageLocation->deleteFile($session{form}{filename}) if $self->canEdit;
return $self->www_edit;
}
#-------------------------------------------------------------------
=head2 www_deny ( )
@ -883,7 +893,7 @@ sub www_edit {
value=>$session{form}{subscribe} || 1
});
}
$content .= "\n\n".$session{user}{signature} if ($session{user}{signature});
$content .= "\n\n".$session{user}{signature} if ($session{user}{signature} && !$session{form}{content});
} else { # edit
return WebGUI::Privilege::insufficient() unless ($self->canEdit);
$var{'form.header'} = WebGUI::Form::formHeader({action=>$self->getUrl})

View file

@ -127,6 +127,7 @@ sub getName {
}
#-------------------------------------------------------------------
sub www_edit {
my $self = shift;
@ -145,10 +146,10 @@ A web executable method that redirects the user to the specified page, or displa
sub www_view {
my $self = shift;
if ($session{var}{adminOn}) {
return $self->www_edit;
return $self->getContainer->www_view;
}
WebGUI::HTTP::setRedirect($self->get("redirectUrl"));
return "";
return undef;
}

View file

@ -100,6 +100,18 @@ sub definition {
}
#-------------------------------------------------------------------
=head2 deletePageCache ( )
Deletes the rendered page cache for this wobject.
=cut
sub deletePageCache {
my $self = shift;
WebGUI::Cache->new("wobject_".$self->getId."_".$session{user}{userId})->delete;
}
#-------------------------------------------------------------------
@ -395,6 +407,12 @@ sub processMacros {
}
#-------------------------------------------------------------------
sub processPropertiesFromFormPost {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost;
$self->deletePageCache;
}
#-------------------------------------------------------------------
@ -553,13 +571,14 @@ sub setCollateral {
#-------------------------------------------------------------------
=head2 www_view ( )
=head2 www_view ( [ disableCache ] )
Renders self->view based upon current style, subject to timeouts. Returns Privilege::noAccess() if canView is False.
=cut
sub www_view {
my $self = shift;
my $disableCache = shift;
return WebGUI::Privilege::noAccess() unless $self->canView;
if ($self->get("encryptPage") && $session{env}{HTTPS} ne "on") {
WebGUI::HTTP::setRedirect($self->getUrl);
@ -569,12 +588,12 @@ sub www_view {
my $cache;
my $output;
my $useCache = (
$session{form}{op} eq "" && $session{form}{pn} eq "" &&
(
( $self->get("cacheTimeout") > 10 && $session{user}{userId} ne '1') ||
( $self->get("cacheTimeoutVisitor") > 10 && $session{user}{userId} eq '1')
) &&
not $session{var}{adminOn}
$session{form}{op} eq "" && $session{form}{pn} eq ""
&& (
( $self->get("cacheTimeout") > 10 && $session{user}{userId} ne '1')
|| ( $self->get("cacheTimeoutVisitor") > 10 && $session{user}{userId} eq '1')
)
&& !( $session{var}{adminOn} || $disableCache)
);
if ($useCache) {
$cache = WebGUI::Cache->new("wobject_".$self->getId."_".$session{user}{userId});

View file

@ -1025,6 +1025,14 @@ sub _xml_encode {
return $text;
}
#-------------------------------------------------------------------
sub www_view {
my $self = shift;
my $disableCache = ($session{form}{sortBy} ne "");
return $self->SUPER::www_view($disableCache);
}
#-------------------------------------------------------------------
# print out RSS 2.0 feed describing the items visible on the first page
sub www_viewRSS {
@ -1078,6 +1086,7 @@ sub www_viewRSS {
1;

View file

@ -159,7 +159,7 @@ sub view {
title=>$child->get("title"),
synopsis=>$child->get("synopsis"),
size=>WebGUI::Utility::formatBytes($child->get("assetSize")),
"date.epoch"=>$child->get("dateStamp"),
"date.epoch"=>$child->get("lastUpdated"),
"icon.small"=>$child->getIcon(1),
"icon.big"=>$child->getIcon,
type=>$child->getName,

View file

@ -387,6 +387,13 @@ sub www_edit {
return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("26","IndexedSearch"));
}
#-------------------------------------------------------------------
sub www_view {
my $self = shift;
return $self->SUPER::www_view(1);
}
#-------------------------------------------------------------------
sub _buildPageList {
my ($self, @userSpecifiedRoots, @roots, @allowedRoots, $pageId, @pages);

View file

@ -340,8 +340,8 @@ sub view {
$pageData->{"page.isChild"} = ($asset->get("parentId") eq $current->getId);
$pageData->{"page.isParent"} = ($asset->getId eq $current->get("parentId"));
$pageData->{"page.isCurrent"} = ($asset->getId eq $current->getId);
$pageData->{"page.isDescendant"} = ( $currentLineage =~ m/^$pageLineage/ && !$pageData->{"page.isCurrent"});
$pageData->{"page.isAnscestor"} = ( $pageLineage =~ m/^$currentLineage/ && !$pageData->{"page.isCurrent"});
$pageData->{"page.isDescendant"} = ( $pageLineage =~ m/^$currentLineage/ && !$pageData->{"page.isCurrent"});
$pageData->{"page.isAncestor"} = ( $currentLineage =~ m/^$pageLineage/ && !$pageData->{"page.isCurrent"});
my $currentBranchLineage = substr($currentLineage,0,12);
$pageData->{"page.inBranchRoot"} = ($currentBranchLineage =~ m/^$pageLineage/);
$pageData->{"page.isSibling"} = (

View file

@ -368,6 +368,7 @@ sub www_vote {
$u = WebGUI::User->new($session{user}{userId});
$u->karma($self->get("karmaPerVote"),"Poll (".$self->getId.")","Voted on this poll.");
}
$self->deletePageCache;
}
return $self->getContainer->www_view;
}

View file

@ -621,7 +621,7 @@ sub url {
return $session{form}{$_[0]};
} elsif (_checkEmailAddy($session{form}{$_[0]})) {
return "mailto:".$session{form}{$_[0]};
} elsif ($session{form}{$_[0]} =~ /:\/\//) {
} elsif ($session{form}{$_[0]} =~ /^\// || $session{form}{$_[0]} =~ /:\/\// || $session{form}{$_[0]} =~ /^\^/) {
return $session{form}{$_[0]};
}
return "http://".$session{form}{$_[0]};

View file

@ -265,7 +265,11 @@ sub www_editGroup {
$f->readOnly($g->groupId,WebGUI::International::get(379));
$f->text("groupName",WebGUI::International::get(84),$g->name);
$f->textarea("description",WebGUI::International::get(85),$g->description);
$f->interval("expireOffset",WebGUI::International::get(367), WebGUI::DateTime::secondsToInterval($g->expireOffset));
$f->interval(
-name=>"expireOffset",
-label=>WebGUI::International::get(367),
-value=>$g->expireOffset
);
$f->yesNo(
-name=>"expireNotify",
-value=>$g->expireNotify,
@ -332,7 +336,11 @@ sub www_editGroup {
-value=>$g->dbQuery,
-label=>WebGUI::International::get(1005)
);
$f->interval("dbCacheTimeout",WebGUI::International::get(1004), WebGUI::DateTime::secondsToInterval($g->dbCacheTimeout));
$f->interval(
-name=>"dbCacheTimeout",
-label=>WebGUI::International::get(1004),
-value=>$g->dbCacheTimeout
);
$f->submit;
$output .= $f->print;
return _submenu($output,'87',"group add/edit");

View file

@ -1,6 +1,11 @@
package WebGUI::i18n::English::Collaboration;
our $I18N = {
'delete file warning' => {
message => q|Are you sure you wish to delete this file?|,
lastUpdated => 1109618544,
},
'display last reply' => {
message => q|Display last reply?|,
lastUpdated => 1109618544,