From acf5457f6aee54719b31236de32042ba4d85bb81 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 19 Mar 2005 20:57:08 +0000 Subject: [PATCH] more bug fixes --- docs/changelog/6.x.x.txt | 8 +++ docs/upgrades/upgrade_6.5.2-6.5.3.pl | 16 ++++++ docs/upgrades/upgrade_6.5.2-6.5.3.sql | 2 + etc/WebGUI.conf.original | 2 - lib/WebGUI.pm | 3 +- lib/WebGUI/Asset/File.pm | 15 ++++- lib/WebGUI/Asset/File/Image.pm | 10 +++- lib/WebGUI/Asset/Snippet.pm | 25 ++++++--- lib/WebGUI/Asset/Wobject/Collaboration.pm | 24 ++++---- lib/WebGUI/Asset/Wobject/DataForm.pm | 67 ++++++++++++++++------- lib/WebGUI/Asset/Wobject/IndexedSearch.pm | 14 ++--- lib/WebGUI/i18n/English/Snippet.pm | 12 +++- 12 files changed, 142 insertions(+), 56 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 22b1941f9..4b8152c2c 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -34,6 +34,14 @@ - fix [ 1166071 ] Create New User allows blank username [mwilson] - fix [ 1166133 ] DataForm www_edit and www_editField's "proceed" [mwilson] - fix [ 1164211 ] DataForm export tab deliniated always contains.. [mwilson] + - fix [ 1165616 ] calling a non-existent func= on a good url crashes Apache + - fix [ 1154384 ] 6.2.11 Admins with default UI level + - fix [ 1151879 ] Search button changes to "Please wait" + - fix [ 1165645 ] Search not working + - fix [ 1157233 ] search crashes + - fix [ 1146359 ] certain templates still hardcoded + - fix [ 1056470 ] Improper macro hangs calendar + - fix [ 1120959 ] 5.5.x forms - export tab delimited 6.5.2 diff --git a/docs/upgrades/upgrade_6.5.2-6.5.3.pl b/docs/upgrades/upgrade_6.5.2-6.5.3.pl index 7c5a30d60..9f34f68ae 100644 --- a/docs/upgrades/upgrade_6.5.2-6.5.3.pl +++ b/docs/upgrades/upgrade_6.5.2-6.5.3.pl @@ -66,6 +66,8 @@ WebGUI::SQL->write("update asset set groupIdView='4' where className='WebGUI::As WebGUI::SQL->write("update wobject set styleTemplateId='PBtmpl0000000000000060' where assetId='$templateFolder'"); +#-------------------------------------------- +print "\tSetting up a new failsafe style\n" unless ($quiet); my $newFailSafe = ' @@ -132,6 +134,20 @@ my $newFailSafe = ' WebGUI::SQL->write("update template set template=".quote($newFailSafe)." where assetId='PBtmpl0000000000000060'"); +#-------------------------------------------- +print "\tMaking templates editable for files and images.\n" unless ($quiet); +my $sth = WebGUI::SQL->read("select assetId,className from asset where className like 'WebGUI::Asset::File%'"); +while (my ($id, $class) = $sth->array) { + my $template; + if ($class =~ /Image/) { + $template = 'PBtmpl0000000000000088'; + } else { + $template = 'PBtmpl0000000000000024'; + } + WebGUI::SQL->write("update FileAsset set templateId=".quote($template)." where assetId=".quote($id)); +} +$sth->finish; + WebGUI::Session::close(); diff --git a/docs/upgrades/upgrade_6.5.2-6.5.3.sql b/docs/upgrades/upgrade_6.5.2-6.5.3.sql index 14bdceaa2..f5cf37d42 100644 --- a/docs/upgrades/upgrade_6.5.2-6.5.3.sql +++ b/docs/upgrades/upgrade_6.5.2-6.5.3.sql @@ -28,4 +28,6 @@ update template set template='\"> \r\n Hash_userId, \ GroupDelete => GroupDelete, \ GroupText => GroupText, \ H => H_homeLink, \ - I => I_imageWithTags, \ International => International, \ JavaScript => JavaScript, \ L => L_loginBox, \ @@ -94,7 +93,6 @@ macros=# => Hash_userId, \ a => a_account, \ c => c_companyName, \ e => e_companyEmail, \ - i => i_imageNoTags, \ r => r_printable, \ u => u_companyUrl diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index a668e6892..1741b75dc 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -97,7 +97,8 @@ sub page { $method = "www_".$method; $output = eval{$asset->$method()}; if ($@) { - WebGUI::ErrorHandler::fatalError("Couldn't call method ".$method." on asset for ".$session{env}{PATH_INFO}." Root cause: ".$@); + WebGUI::ErrorHandler::warn("Couldn't call method ".$method." on asset for ".$session{env}{PATH_INFO}." Root cause: ".$@); + $output = $asset->www_view; } else { if ($output eq "" && $method ne "view") { $output = $asset->www_view; diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index bf0783216..cbf15a1a2 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -77,6 +77,10 @@ sub definition { noFormPost=>1, fieldType=>'hidden', defaultValue=>undef + }, + templateId=>{ + fieldType=>'template', + defaultValue=>'PBtmpl0000000000000024' } } }); @@ -242,7 +246,7 @@ sub view { $var{controls} = $self->getToolbar; $var{fileUrl} = $self->getFileUrl; $var{fileIcon} = $self->getFileIconUrl; - return $self->processTemplate(\%var,"PBtmpl0000000000000024"); + return $self->processTemplate(\%var,$self->getValue("templateId")); } @@ -250,7 +254,12 @@ sub view { sub www_edit { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; - return $self->getAdminConsole->render($self->getEditForm->print,"Edit File"); + my $tabform = $self->getEditForm; + $tabform->getTab("display")->template( + -value=>$self->getValue("templateId"), + -namespace=>"FileAsset" + ); + return $self->getAdminConsole->render($tabform->print,"Edit File"); } @@ -258,7 +267,7 @@ sub www_view { my $self = shift; return WebGUI::Privilege::noAccess() unless $self->canView; if ($session{var}{adminOn}) { - return $self->www_edit; + return $self->getContainer->www_view; } WebGUI::HTTP::setRedirect($self->getFileUrl); return ""; diff --git a/lib/WebGUI/Asset/File/Image.pm b/lib/WebGUI/Asset/File/Image.pm index 2d8ec1253..858c15b80 100644 --- a/lib/WebGUI/Asset/File/Image.pm +++ b/lib/WebGUI/Asset/File/Image.pm @@ -215,7 +215,7 @@ sub view { $var{fileUrl} = $self->getFileUrl; $var{fileIcon} = $self->getFileIconUrl; $var{thumbnail} = $self->getThumbnailUrl; - return $self->processTemplate(\%var,"PBtmpl0000000000000088"); + return $self->processTemplate(\%var,$self->get("templateId")); } @@ -225,7 +225,13 @@ sub www_edit { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; $self->getAdminConsole->addSubmenuItem($self->getUrl('func=resize'),WebGUI::International::get("resize image","Image")) if ($self->get("filename")); - return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("edit image","Image")); + my $tabform = $self->getEditForm; + $tabform->getTab("display")->template( + -value=>$self->get("templateId"), + -namespace=>"ImageAsset", + -defaultValue=>"PBtmpl0000000000000088" + ); + return $self->getAdminConsole->render($tabform->print,WebGUI::International::get("edit image","Image")); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Snippet.pm b/lib/WebGUI/Asset/Snippet.pm index 665dbffe9..c95c741d1 100644 --- a/lib/WebGUI/Asset/Snippet.pm +++ b/lib/WebGUI/Asset/Snippet.pm @@ -63,10 +63,14 @@ sub definition { tableName=>'snippet', className=>'WebGUI::Asset::Snippet', properties=>{ - snippet=>{ - fieldType=>'codearea', - defaultValue=>undef - } + snippet=>{ + fieldType=>'codearea', + defaultValue=>undef + }, + processAsTemplate=>{ + fieldType=>'yesNo', + defaultValue=>0 + } } }); return $class->SUPER::definition($definition); @@ -88,9 +92,13 @@ sub getEditForm { $tabform->getTab("properties")->codearea( -name=>"snippet", -label=>WebGUI::International::get('snippet', 'Snippet'), - -label=>"Snippet", -value=>$self->getValue("snippet") ); + $tabform->getTab("properties")->yesNo( + -name=>"processAsTemplate", + -label=>WebGUI::International::get('process as template', 'Snippet'), + -value=>$self->getValue("processAsTemplate") + ); return $tabform; } @@ -147,9 +155,10 @@ sub getName { #------------------------------------------------------------------- sub view { my $self = shift; + my $calledAsWebMethod = shift; my $output = WebGUI::Macro::process($self->get("snippet")); -# if it's a javascript file this would break it -# $output = '

'.$self->getToolbar.'

'.$output if ($session{var}{adminOn}); + $output = '

'.$self->getToolbar.'

'.$output if ($session{var}{adminOn} && !$calledAsWebMethod); + return $output unless ($self->getValue("processAsTemplate")); return WebGUI::Asset::Template->processRaw($output); } @@ -170,7 +179,7 @@ A web accessible version of the view method. sub www_view { my $self = shift; - return $self->view; + return $self->view(1); } diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index ef04c0925..7c4220769 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -62,18 +62,20 @@ sub appendPostListTemplateVars { for (my $i=0;$i<=$post->get("rating");$i++) { push(@rating_loop,{'rating_loop.count'=>$i}); } - my $lastPost = $post->getLastPost(); my %lastReply; - if ($self->get("displayLastReply")) { - %lastReply = ( - "lastReply.url"=>$lastPost->getUrl(), - "lastReply.title"=>$lastPost->get("title"), - "lastReply.user.isVisitor"=>$lastPost->get("ownerUserId") eq "1", - "lastReply.username"=>$lastPost->get("username"), - "lastReply.userProfile.url"=>$lastPost->WebGUI::Asset::Post::getPosterProfileUrl(), - "lastReply.dateSubmitted.human"=>epochToHuman($lastPost->get("dateSubmitted"),"%z"), - "lastReply.timeSubmitted.human"=>epochToHuman($lastPost->get("dateSubmitted"),"%Z") - ); + if ($post->get("className") =~ /Thread/) { + my $lastPost = $post->getLastPost(); + if ($self->get("displayLastReply")) { + %lastReply = ( + "lastReply.url"=>$lastPost->getUrl(), + "lastReply.title"=>$lastPost->get("title"), + "lastReply.user.isVisitor"=>$lastPost->get("ownerUserId") eq "1", + "lastReply.username"=>$lastPost->get("username"), + "lastReply.userProfile.url"=>$lastPost->WebGUI::Asset::Post::getPosterProfileUrl(), + "lastReply.dateSubmitted.human"=>epochToHuman($lastPost->get("dateSubmitted"),"%z"), + "lastReply.timeSubmitted.human"=>epochToHuman($lastPost->get("dateSubmitted"),"%Z") + ); + } } push(@{$var->{post_loop}}, { %{$post->get}, diff --git a/lib/WebGUI/Asset/Wobject/DataForm.pm b/lib/WebGUI/Asset/Wobject/DataForm.pm index 556cbff27..e6817f673 100644 --- a/lib/WebGUI/Asset/Wobject/DataForm.pm +++ b/lib/WebGUI/Asset/Wobject/DataForm.pm @@ -883,27 +883,52 @@ sub www_editTabSave { #------------------------------------------------------------------- sub www_exportTab { - my $self = shift; - return WebGUI::Privilege::insufficient() unless $self->canEdit; - WebGUI::HTTP::setFilename($self->get("url").".tab","text/plain"); - my %fields = WebGUI::SQL->buildHash("select DataForm_fieldId,name from DataForm_field where assetId=".quote($self->getId)." order by sequenceNumber"); - my $select = "select a.DataForm_entryId as entryId, a.ipAddress, a.username, a.userId, a.submissionDate"; - my $from = " from DataForm_entry a"; - my $join; - my $where = " where a.assetId=".quote($self->getId); - my $orderBy = " order by a.DataForm_entryId"; - my $columnCounter = "b"; - my $mailData = ($self->get("mailData") == 0); - foreach my $fieldId (keys %fields) { - next if (isIn($fields{$fieldId}, qw(to from cc bcc subject)) && $mailData); - my $extension = ""; - $extension = "mail_" if (isIn($fields{$fieldId}, qw(to from cc bcc subject))); - $select .= ", ".$columnCounter.".value as ".$extension.$fields{$fieldId}; - $join .= " left join DataForm_entryData ".$columnCounter." on a.DataForm_entryId=".$columnCounter.".DataForm_entryId and " - .$columnCounter.".DataForm_fieldId=".quote($fieldId); - $columnCounter++; - } - return WebGUI::SQL->quickTab($select.$from.$join.$where.$orderBy); + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + WebGUI::HTTP::setFilename($self->get("url").".tab","text/plain"); + my %fields = WebGUI::SQL->buildHash("select DataForm_fieldId,name from DataForm_field where + assetId=".quote($self->getId)." order by sequenceNumber"); + my @data; + my $entries = WebGUI::SQL->read("select * from DataForm_entry where assetId=".quote($self->getId)); + my $i; + my $noMailData = ($self->get("mailData") == 0); + while (my $entryData = $entries->hashRef) { + $data[$i] = { + entryId => $entryData->{DataForm_entryId}, + ipAddress => $entryData->{ipAddress}, + username => $entryData->{username}, + userId => $entryData->{userId}, + submissionDate => WebGUI::DateTime::epochToHuman($entryData->{submissionDate}), + }; + my $values = WebGUI::SQL->read("select value,DataForm_fieldId from DataForm_entryData where + DataForm_entryId=".quote($entryData->{DataForm_entryId})); + while (my ($value, $fieldId) = $values->array) { + next if (isIn($fields{$fieldId}, qw(to from cc bcc subject)) && $noMailData); + $data[$i]{$fields{$fieldId}} = $value; + } + $values->finish; + $i++; + } + $entries->finish; + my @row; + foreach my $fieldId (keys %fields) { + next if (isIn($fields{$fieldId}, qw(to from cc bcc subject)) && $noMailData); + push(@row, $fields{$fieldId}); + } + my $tab = join("\t",@row)."\n"; + foreach my $record (@data) { + @row = (); + foreach my $fieldId (keys %fields) { + next if (isIn($fields{$fieldId}, qw(to from cc bcc subject)) && $noMailData); + my $value = $record->{$fields{$fieldId}}; + $value =~ s/\t/\\t/g; + $value =~ s/\r//g; + $value =~ s/\n/;/g; + push(@row, $value); + } + $tab .= join("\t", @row)."\n"; + } + return $tab; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Wobject/IndexedSearch.pm b/lib/WebGUI/Asset/Wobject/IndexedSearch.pm index b3da396f9..ccb2a320d 100644 --- a/lib/WebGUI/Asset/Wobject/IndexedSearch.pm +++ b/lib/WebGUI/Asset/Wobject/IndexedSearch.pm @@ -422,10 +422,10 @@ sub _buildFilter { my $self = shift; my %filter = (); - # pages - if($self->get('searchRoot') !~ /any/i) { - $filter{pageId} = $self->_buildPageList; - } +# # pages +# if($self->get('searchRoot') !~ /any/i) { +# $filter{assetId} = $self->_buildPageList; +# } # content-types if($session{form}{contentTypes} && ! isIn('any', $session{cgi}->param('contentTypes'))) { @@ -528,10 +528,10 @@ sub _getContentTypes { sub _getSearchablePages { my $searchRoot = shift; my %pages; - my $sth = WebGUI::SQL->read("select pageId from page where parentId = ".quote($searchRoot)); + my $sth = WebGUI::SQL->read("select assetId from asset where parentId = ".quote($searchRoot)); while (my %data = $sth->hash) { - $pages{$data{pageId}} = 1; - %pages = (%pages, _getSearchablePages($data{pageId}) ); + $pages{$data{assetId}} = 1; + %pages = (%pages, _getSearchablePages($data{assetId}) ); } return %pages; } diff --git a/lib/WebGUI/i18n/English/Snippet.pm b/lib/WebGUI/i18n/English/Snippet.pm index 01912cc2b..b5e1bb191 100644 --- a/lib/WebGUI/i18n/English/Snippet.pm +++ b/lib/WebGUI/i18n/English/Snippet.pm @@ -8,6 +8,11 @@ our $I18N = { context => 'Default name of all snippets' }, + 'process as template' => { + message => q|Process as template?|, + lastUpdated => 1104630516, + }, + 'snippet add/edit title' => { message => q|Snippet, Add/Edit|, lastUpdated => 1104630516, @@ -18,8 +23,13 @@ our $I18N = {

Since Snippets are Assets, so they have all the properties that Assets do.

-

Snippet
+

Snippet
This is the snippet. Either type it in or copy and paste it into the form field. +

+ +

Process as template?
+This will run the snippet through the template engine. It will enable you to use session variables in the snippet, but it is a little slower. +

|, context => 'Describing snippets and its sole field.', lastUpdated => 1106683569,