From 03b4b0ed3328f727f3ba4d4a2c1cf2b97e7dd549 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 25 Jul 2006 17:15:57 +0000 Subject: [PATCH] - fix: Head Block in styles - fix: select assetVersionTag - fix: Infinite recursion - fix: assetUiLevel override broken - fix: Indexing files failes (derck) - fix: Unable to approve New listings on Matrix --- docs/changelog/7.x.x.txt | 6 +++++ lib/WebGUI/AdminConsole.pm | 10 ++++----- lib/WebGUI/Asset.pm | 36 +++++++++++++----------------- lib/WebGUI/Asset/Wobject/Matrix.pm | 2 +- lib/WebGUI/Macro/AdminBar.pm | 9 ++++---- lib/WebGUI/Operation/VersionTag.pm | 22 +++++++++--------- lib/WebGUI/Search/Index.pm | 2 +- lib/WebGUI/Session/Style.pm | 1 + lib/WebGUI/VersionTag.pm | 19 ++++++++++++++++ 9 files changed, 63 insertions(+), 44 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index fdd6846c0..b83c71eb4 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -43,6 +43,12 @@ - fix: Splat_random Macro not so random (Wouter van Oijen / ProcoliX) (Thanks to Colin Kuskie for pointing this out and writing some tests) - rfe: phone validation javascript + - fix: Head Block in styles + - fix: select assetVersionTag + - fix: Infinite recursion + - fix: assetUiLevel override broken + - fix: Indexing files failes (derck) + - fix: Unable to approve New listings on Matrix 7.0.2 diff --git a/lib/WebGUI/AdminConsole.pm b/lib/WebGUI/AdminConsole.pm index e120c5f85..519940360 100644 --- a/lib/WebGUI/AdminConsole.pm +++ b/lib/WebGUI/AdminConsole.pm @@ -17,6 +17,7 @@ package WebGUI::AdminConsole; use strict; use WebGUI::International; use WebGUI::Asset::Template; +use WebGUI::VersionTag; =head1 NAME @@ -461,12 +462,11 @@ sub render { icon=>$self->session->url->extras('adminConsole/small/versionTags.gif') }); } - my $rs = $self->session->db->read("select tagId, name, groupToUse from assetVersionTag where isCommitted=0 and isLocked=0 order by name"); - while (my ($id, $name, $group) = $rs->array) { - next unless $self->session->user->isInGroup($group); + foreach my $tag (@{WebGUI::VersionTag->getOpenTags($self->session)}) { + next unless $self->session->user->isInGroup($tag->get("groupToUse")); push(@tags, { - url=>$self->session->url->page("op=setWorkingVersionTag;tagId=".$id), - title=>($id eq $workingId) ? '* '.$name : $name, + url=>$self->session->url->page("op=setWorkingVersionTag;tagId=".$tag->getId), + title=>($tag->getId eq $workingId) ? '* '.$tag->get("name") : $tag->get("name"), }); } if (scalar(@tags)) { diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 7f862b728..d73b464ed 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -490,32 +490,28 @@ sub getAssetAdderLinks { ); my $newAsset = WebGUI::Asset->newByPropertyHashRef($self->session,\%properties); next unless $newAsset; - #use Data::Dumper; print Dumper($newAsset); my $uiLevel = eval{$newAsset->getUiLevel()}; if ($@) { $self->session->errorHandler->error("Couldn't get UI level of ".$class.". Root cause: ".$@); next; - } else { - next if ($uiLevel > $self->session->user->profileField("uiLevel") && !$self->session->user->isInGroup(3)); } + next if ($uiLevel > $self->session->user->profileField("uiLevel"));# && !$self->session->user->isInGroup(3)); my $canAdd = eval{$class->canAdd($self->session)}; if ($@) { $self->session->errorHandler->error("Couldn't determine if user can add ".$class." because ".$@); next; - } else { - next unless ($canAdd); - } + } + next unless ($canAdd); my $label = eval{$newAsset->getName()}; if ($@) { $self->session->errorHandler->error("Couldn't get the name of ".$class."because ".$@); next; - } else { - my $url = $self->getUrl("func=add;class=".$class); - $url = $self->session->url->append($url,$addToUrl) if ($addToUrl); - $links{$label}{url} = $url; - $links{$label}{icon} = $newAsset->getIcon; - $links{$label}{'icon.small'} = $newAsset->getIcon(1); } + my $url = $self->getUrl("func=add;class=".$class); + $url = $self->session->url->append($url,$addToUrl) if ($addToUrl); + $links{$label}{url} = $url; + $links{$label}{icon} = $newAsset->getIcon; + $links{$label}{'icon.small'} = $newAsset->getIcon(1); } my $constraint; if ($type eq "assetContainers") { @@ -984,14 +980,12 @@ Returns the UI Level specified in the asset definition or from the config file i sub getUiLevel { my $self = shift; my $definition = $self->get("className")->definition($self->session); - my $uilevel = $self->session->config->get("assetUiLevel"); - my $ret; - if ($uilevel && ref $uilevel eq 'HASHREF') { - $ret = $self->session->config->get("assetUiLevel")->{$definition->[0]{className}} || $definition->[0]{uiLevel} || 1 ; + my $uiLevel = $self->session->config->get("assetUiLevel"); + if ($uiLevel && ref $uiLevel eq 'HASH') { + return $uiLevel->{$definition->[0]{className}} || $definition->[0]{uiLevel} || 1 ; } else { - $ret = $definition->[0]{uiLevel} || 1 ; + return $definition->[0]{uiLevel} || 1 ; } - return $ret; } @@ -1803,9 +1797,7 @@ Returns "". sub view { my $self = shift; - $self->session->http->setRedirect($self->getDefault($self->session)->getUrl) if ($self->getId eq "PBasset000000000000001"); return $self->getToolbar if ($self->session->var->get("adminOn")); - return undef; } #------------------------------------------------------------------- @@ -2035,6 +2027,10 @@ Returns the view() method of the asset object if the requestor canView. sub www_view { my $self = shift; + if ($self->getId eq "PBasset000000000000001") { + $self->session->http->setRedirect($self->getDefault($self->session)->getUrl); + return "1"; + } my $check = $self->checkView; return $check if (defined $check); $self->prepareView; diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index eb288f996..a9cc85d61 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -721,6 +721,7 @@ sub www_editListingSave { moderateGroupId => '4', postGroupId => '7' }); + WebGUI::VersionTag->getWorking($self->session)->commit; $data{forumId} = $forum->getId; $data{status} = "pending"; $isNew = 1; @@ -1105,7 +1106,6 @@ sub www_viewDetail { $var{screenshot} = $storage->getUrl($listing->{filename}); $var{thumbnail} = $storage->getThumbnailUrl($listing->{filename}); } - $forum->prepareView; $var{"discussion"} = $forum->view; $var{'isLoggedIn'} = ($self->session->user->userId ne "1"); if ($self->session->form->process("do") eq "sendEmail" && $self->session->form->process("verify","captcha")) { diff --git a/lib/WebGUI/Macro/AdminBar.pm b/lib/WebGUI/Macro/AdminBar.pm index b992126ff..8179c10f9 100644 --- a/lib/WebGUI/Macro/AdminBar.pm +++ b/lib/WebGUI/Macro/AdminBar.pm @@ -105,12 +105,11 @@ sub process { icon=>$session->url->extras('adminConsole/small/versionTags.gif') }); } - my $rs = $session->db->read("select tagId, name, groupToUse from assetVersionTag where isCommitted=0 and isLocked=0 order by name"); - while (my ($id, $name, $group) = $rs->array) { - next unless $session->user->isInGroup($group); + foreach my $tag (@{WebGUI::VersionTag->getOpenTags($session)}) { + next unless $session->user->isInGroup($tag->get("groupToUse")); push(@tags, { - url=>$session->url->page("op=setWorkingVersionTag;backToSite=1;tagId=".$id), - title=>($id eq $workingId) ? '* '.$name.'' : $name, + url=>$session->url->page("op=setWorkingVersionTag;backToSite=1;tagId=".$tag->getId), + title=>($tag->getId eq $workingId) ? '* '.$tag->get("name").'' : $tag->get("name"), icon=>$session->url->extras('spacer.gif') }); } diff --git a/lib/WebGUI/Operation/VersionTag.pm b/lib/WebGUI/Operation/VersionTag.pm index f5314383b..1b68cba30 100644 --- a/lib/WebGUI/Operation/VersionTag.pm +++ b/lib/WebGUI/Operation/VersionTag.pm @@ -360,26 +360,24 @@ sub www_manageVersions { my $commitPrompt = $i18n->get("commit version tag confirm"); my $output = '

'.$i18n->get("current tag is called").': '.$tag.'.

'; - my $sth = $session->db->read("select tagId,name,creationDate,createdBy,groupToUse from assetVersionTag where isCommitted=0 and isLocked=0"); - while (my ($id,$name,$date,$by,$group) = $sth->array) { - next unless ($session->user->isInGroup($group)); - my $u = WebGUI::User->new($session,$by); + foreach my $tag (@{WebGUI::VersionTag->getOpenTags($session)}) { + next unless ($session->user->isInGroup($tag->get("groupToUse"))); + my $u = WebGUI::User->new($session,$tag->get("createdBy")); $output .= ' - - + + '; + getId).'" onclick="return confirm(\''.$commitPrompt.'\');">'.$commit.''; } - $sth->finish; $output .= '
'.$i18n->get("version tag name").''.$i18n->get("created on").''.$i18n->get("created by").'
' - .$session->icon->delete("op=rollbackVersionTag;tagId=".$id,undef,$rollbackPrompt) - .$session->icon->edit("op=editVersionTag;tagId=".$id) + .$session->icon->delete("op=rollbackVersionTag;tagId=".$tag->getId,undef,$rollbackPrompt) + .$session->icon->edit("op=editVersionTag;tagId=".$tag->getId) .''.$name.''.$session->datetime->epochToHuman($date).'getId).'">'.$tag->get("name").''.$session->datetime->epochToHuman($tag->get("creationDate")).' '.$u->username.' '; - unless ($workingTagId eq $id) { - $output .= ''.$setTag.' | '; + unless ($workingTagId eq $tag->getId) { + $output .= 'getId).'">'.$setTag.' | '; } $output .=' - '.$commit.'
'; return $ac->render($output); } diff --git a/lib/WebGUI/Search/Index.pm b/lib/WebGUI/Search/Index.pm index 580826735..3433ab654 100644 --- a/lib/WebGUI/Search/Index.pm +++ b/lib/WebGUI/Search/Index.pm @@ -50,7 +50,7 @@ The path to the filename to index, including the filename. sub addFile { my $self = shift; my $path = shift; - $path =~ m/\.(\w)$/; + $path =~ m/\.(\w+)$/; my $type = lc($1); my $filters = $self->session->config->get("searchIndexerPlugins"); my $filter = $filters->{$type}; diff --git a/lib/WebGUI/Session/Style.pm b/lib/WebGUI/Session/Style.pm index 35f9fda03..4351c0a78 100644 --- a/lib/WebGUI/Session/Style.pm +++ b/lib/WebGUI/Session/Style.pm @@ -192,6 +192,7 @@ if ($self->session->user->isInGroup(2)) { my $style = WebGUI::Asset::Template->new($self->session,$templateId); my $output; if (defined $style) { + $var{'head.tags'} .= $style->get("headBlock"); $output = $style->process(\%var); } else { $output = "WebGUI was unable to instantiate your style template.".$var{'body.content'}; diff --git a/lib/WebGUI/VersionTag.pm b/lib/WebGUI/VersionTag.pm index 709138c28..60a54bd7b 100644 --- a/lib/WebGUI/VersionTag.pm +++ b/lib/WebGUI/VersionTag.pm @@ -164,6 +164,25 @@ sub getId { #------------------------------------------------------------------- +=head2 getOpenTags ( session ) + +Returns an array reference containing all the open version tag objects. This is a class method. + +=cut + +sub getOpenTags { + my $class = shift; + my $session = shift; + my @tags = (); + my $sth = $session->db->read("select * from assetVersionTag where isCommitted=0 and isLocked=0 order by name"); + while (my $data = $sth->hashRef) { + push(@tags, bless {_session=>$session, _id=>$data->{tagId}, _data=>$data}, $class); + } + return \@tags; +} + +#------------------------------------------------------------------- + =head2 getRevisionCount ( ) Returns the number of revisions that are under this tag.