Merge branch 'master' of git@github.com:plainblack/webgui

Conflicts:

	lib/WebGUI/i18n/English/Asset_EMSSubmission.pm
This commit is contained in:
daviddelikat 2009-12-01 18:50:27 -06:00
commit 60b04ff928
71 changed files with 686 additions and 176 deletions

View file

@ -336,7 +336,7 @@ sub getInboxNotificationTemplateId {
#-------------------------------------------------------------------
=head2 getInboxSMSNotificationTemplateId ( )
=head2 getInboxSmsNotificationTemplateId ( )
This method returns the template ID for inbox SMS notifications.

View file

@ -1402,6 +1402,21 @@ sub getRoot {
}
#-------------------------------------------------------------------
=head2 getSearchUrl ( )
Returns the URL for the search screen of the asset manager.
=cut
sub getSearchUrl {
my $self = shift;
return $self->getUrl( 'op=assetManager;method=search' );
}
#-------------------------------------------------------------------
=head2 getSeparator
@ -2285,16 +2300,18 @@ sub processTemplate {
my $var = shift;
my $templateId = shift;
my $template = shift;
my $session = $self->session;
# Sanity checks
if (ref $var ne "HASH") {
$self->session->errorHandler->error("First argument to processTemplate() should be a hash reference.");
$session->errorHandler->error("First argument to processTemplate() should be a hash reference.");
return "Error: Can't process template for asset ".$self->getId." of type ".$self->get("className");
}
$template = WebGUI::Asset->new($self->session, $templateId,"WebGUI::Asset::Template") unless (defined $template);
$template = WebGUI::Asset->new($session, $templateId,"WebGUI::Asset::Template") unless (defined $template);
if (defined $template) {
$var = { %{ $var }, %{ $self->getMetaDataAsTemplateVariables } };
$var->{'controls'} = $self->getToolbar if $self->session->var->isAdminOn;
$var->{'controls'} = $self->getToolbar if $session->var->isAdminOn;
$var->{'assetIdHex'} = $session->id->toHex($self->getId);
my %vars = (
%{$self->{_properties}},
'title' => $self->getTitle,
@ -2304,7 +2321,7 @@ sub processTemplate {
return $template->process(\%vars);
}
else {
$self->session->errorHandler->error("Can't instantiate template $templateId for asset ".$self->getId);
$session->errorHandler->error("Can't instantiate template $templateId for asset ".$self->getId);
my $i18n = WebGUI::International->new($self->session, 'Asset');
return $i18n->get('Error: Cannot instantiate template').' '.$templateId;
}
@ -2889,8 +2906,7 @@ sub www_editSave {
=head2 www_manageAssets ( )
Redirect to the asset manager content handler (for backwards
compatibility)
Redirect to the asset manager content handler (for backwards compatibility)
=cut
@ -2902,6 +2918,21 @@ sub www_manageAssets {
#-------------------------------------------------------------------
=head2 www_searchAssets ( )
Redirect to the asset manager content handler (for backwards
compatibility)
=cut
sub www_searchAssets {
my $self = shift;
$self->session->http->setRedirect( $self->getSearchUrl );
return "redirect";
}
#-------------------------------------------------------------------
=head2 www_view ( )
Returns the view() method of the asset object if the requestor canView.

View file

@ -176,6 +176,30 @@ sub exportGetUrlAsPath {
#-------------------------------------------------------------------
=head2 getCache ( $calledAsWebMethod )
Overrides the base method to handle Snippet specific caching.
=head3 $calledAsWebMethod
If this is true, then change the cache key.
=cut
sub getCache {
my $self = shift;
my $calledAsWebMethod = shift;
my $session = $self->session;
my $cacheKey = "view_".$calledAsWebMethod.'_'.$self->getId;
if ($session->env->sslRequest) {
$cacheKey .= '_ssl';
}
my $cache = WebGUI::Cache->new($session, $cacheKey);
return $cache;
}
#-------------------------------------------------------------------
=head2 getToolbar ( )
Returns a toolbar with a set of icons that hyperlink to functions that delete, edit, promote, demote, cut, and copy.
@ -253,6 +277,8 @@ sub purgeCache {
WebGUI::Cache->new($self->session,"view__".$self->getId)->delete;
WebGUI::Cache->new($self->session,"view_1_".$self->getId)->delete;
WebGUI::Cache->new($self->session,"view__".$self->getId."_ssl")->delete;
WebGUI::Cache->new($self->session,"view_1_".$self->getId."_ssl")->delete;
$self->SUPER::purgeCache();
}
@ -270,16 +296,16 @@ toolbar if in adminMode.
=cut
sub view {
my $self = shift;
my $self = shift;
my $calledAsWebMethod = shift;
my $session = $self->session;
my $session = $self->session;
my $versionTag = WebGUI::VersionTag->getWorking($session, 1);
my $noCache =
$session->var->isAdminOn
|| $self->get("cacheTimeout") <= 10
|| ($versionTag && $versionTag->getId eq $self->get("tagId"));
unless ($noCache) {
my $cache = $self->getCache;
my $cache = $self->getCache($calledAsWebMethod);
my $out = $cache->get if defined $cache;
return $out if $out;
}
@ -293,7 +319,8 @@ sub view {
}
WebGUI::Macro::process($session,\$output);
unless ($noCache) {
WebGUI::Cache->new($session,"view_".$calledAsWebMethod."_".$self->getId)->set($output,$self->get("cacheTimeout"));
my $cache = $self->getCache($calledAsWebMethod);
$cache->set($output,$self->get("cacheTimeout"));
}
return $output;
}

View file

@ -946,6 +946,16 @@ sub duplicate {
my $self = shift;
my $newAsset = $self->next::method(@_);
$newAsset->createSubscriptionGroup;
my $i18n = WebGUI::International->new($self->session, "Asset_Collaboration");
my $newCron = WebGUI::Workflow::Cron->create($self->session, {
title=>$self->getTitle." ".$i18n->get("mail"),
minuteOfHour=>"*/".($self->get("getMailInterval")/60),
className=>(ref $self),
methodName=>"new",
parameters=>$self->getId,
workflowId=>"csworkflow000000000001"
});
$self->update({getMailCronId=>$newCron->getId});
return $newAsset;
}

View file

@ -112,7 +112,9 @@ sub handler {
my $asset = getAsset($session, getRequestedAssetUrl($session));
# display from cache if page hasn't been modified.
if ($var->get("userId") eq "1" && defined $asset && !$http->ifModifiedSince($asset->getContentLastModified)) {
if ($var->get("userId") eq "1"
&& defined $asset
&& !$http->ifModifiedSince($asset->getContentLastModified, $session->setting->get('maxCacheTimeout'))) {
$http->setStatus("304","Content Not Modified");
$http->sendHeader;
$session->close;

View file

@ -19,17 +19,20 @@ Gets a select box to choose a class name.
sub getClassSelectBox {
my $session = shift;
my $i18n = WebGUI::International->new($session, 'Asset');
tie my %classes, "Tie::IxHash", (
"" => "Any Class",
"" => $i18n->get("Any Class"),
$session->db->buildHash("select distinct(className) from asset"),
);
delete $classes{"WebGUI::Asset"}; # don't want to search for the root asset
my $className = $session->scratch->get('assetManagerSearchClassName') || $session->form->process("class","className");
$session->scratch->set('assetManagerSearchClassName', $className);
return WebGUI::Form::selectBox( $session, {
name => "class",
value => $session->form->process("class","className"),
defaultValue => "",
name => "class",
value => $className,
defaultValue => "",
options => \%classes,
});
}
@ -142,8 +145,10 @@ sub getSearchPaginator {
$queryString .= ';class=' . $class;
}
my $p = $s->getPaginatorResultSet( $session->url->page( $queryString ) );
my $pageNumber = $session->scratch->get('assetManagerSearchPageNumber') || $session->form->get('pn');
my $p = $s->getPaginatorResultSet( $session->url->page( $queryString ), undef, $pageNumber );
$session->scratch->set('assetManagerSearchPageNumber', $pageNumber);
return $p;
}
@ -533,64 +538,36 @@ sub www_search {
$session->style->setScript( $session->url->extras( 'yui/build/yahoo-dom-event/yahoo-dom-event.js' ) );
$session->style->setScript( $session->url->extras( 'yui-webgui/build/assetManager/assetManager.js' ) );
$session->style->setScript( $session->url->extras( 'yui-webgui/build/form/form.js' ) );
my $keywords = $session->scratch->get('assetManagerSearchKeywords') || $session->form->get('keywords');
### Show the form
$output .= q{<form method="post" enctype="multipart/form-data" action="} . $currentAsset->getUrl . q{"><p>}
. q{<input type="hidden" name="op" value="assetManager" />}
. q{<input type="hidden" name="method" value="search" />}
. q{<input type="text" size="45" name="keywords" value="} . $session->form->get('keywords') . q{" />}
. q{<input type="text" size="45" name="keywords" value="} . $keywords . q{" />}
. getClassSelectBox( $session )
. q{<input type="submit" name="action" value="}.$i18n->get( "search" ).q{" />}
. q{</p></form>}
;
### Actions
if ( my $action = lc $session->form->get( 'action' ) ) {
my @assetIds = $session->form->get( 'assetId' );
if ( $action eq "delete" ) { ##aka trash
for my $assetId ( @assetIds ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
next unless $asset;
$asset->trash;
}
}
elsif ( $action eq "cut" ) {
for my $assetId ( @assetIds ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
next unless $asset;
$asset->cut;
}
}
elsif ( $action eq "copy" ) {
for my $assetId ( @assetIds ) {
# Copy == Duplicate + Cut
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId);
my $newAsset = $asset->duplicate( { skipAutoCommitWorkflows => 1 } );
$newAsset->update( { title => $newAsset->getTitle . ' (copy)' } );
$newAsset->cut;
}
}
}
### Run the search
if ( $session->form->get( 'keywords' ) || $session->form->get( 'class' ) ) {
my $keywords = $session->form->get( 'keywords' );
my @classes = $session->form->get( 'class' );
if ( $keywords || $session->form->get( 'class' ) ) {
my @classes = $session->form->get( 'class' );
my $keywordsScrubbed = $keywords;
# Detect a helper word key
my @assetIds = ($keywords =~ /assetid:\s*([^\s]+)/gi);
# purge helper word keys
if (@assetIds) {
$keywords =~ s/\bassetid:\s*[^\s]+//gi;
$keywordsScrubbed =~ s/\bassetid:\s*[^\s]+//gi;
}
$keywords =~ s/^\s+//g;
$keywords =~ s/\s+$//g;
$keywordsScrubbed =~ s/^\s+//g;
$keywordsScrubbed =~ s/\s+$//g;
my $p = getSearchPaginator( $session, {
assetIds => \@assetIds,
keywords => $keywords,
keywords => $keywordsScrubbed,
classes => \@classes,
orderByColumn => $session->form->get( 'orderByColumn' ),
orderByDirection => $session->form->get( 'orderByDirection' ),
@ -601,9 +578,10 @@ sub www_search {
}
else {
### Display the search results
$output .= q{<form method="post" enctype="multipart/form-data">}
. q{<input type="hidden" name="op" value="assetManager" />}
. q{<input type="hidden" name="method" value="search" />}
$output .= q{<form method="post" enctype="multipart/form-data" action="}.$currentAsset->getUrl.q{">}
. q{<input type="hidden" name="func" value="searchAssets" />}
. q{<input type="hidden" name="proceed" value="searchAssets" />}
. WebGUI::Form::CsrfToken->new($session)->toHtml
. q{<input type="hidden" name="pn" value="} . $session->form->get('pn') . q{" />}
. q{<input type="hidden" name="keywords" value="} . $keywords . q{" />}
;
@ -707,9 +685,9 @@ sub www_search {
$output .= q{</tbody>}
. q{</table>}
. q{<p class="actions">} . $i18n->get( 'with selected' )
. q{<input type="submit" name="action" value="}.$i18n->get( 'delete' ) . q{" />}
. q{<input type="submit" name="action" value="}.$i18n->get( "cut" ) . q{" />}
. q{<input type="submit" name="action" value="}.$i18n->get( "Copy" ) .q{" />}
. q{<input type="submit" name="action" value="}.$i18n->get( 'delete' ) . q[" onclick="if(confirm('].$i18n->get('43').q[')){this.form.func.value='deleteList'; this.form.submit();}{ return false; }" />]
. q{<input type="submit" name="action" value="}.$i18n->get( "cut" ) . q{" onclick="this.form.func.value='cutList'; this.form.submit();" />}
. q{<input type="submit" name="action" value="}.$i18n->get( "Copy" ) .q{" onclick="this.form.func.value='copyList'; this.form.submit();" />}
. q{</p>}
. q{</form>}
;
@ -730,6 +708,7 @@ sub www_search {
$output .= '</div>';
$session->scratch->set('assetManagerSearchKeywords', $keywords);
return $ac->render( $output );
}

View file

@ -60,6 +60,15 @@ use Exception::Class (
},
);
sub WebGUI::Error::full_message {
my $self = shift;
my $message = $self->message ? $self->message : $self->description;
my @fields = map { defined $self->$_ ? ($_ . ': ' . $self->$_) : () } $self->Fields;
if (@fields) {
$message .= ' (' . join( q{, }, @fields ) . ')';
}
return $message;
}
=head1 NAME

View file

@ -60,16 +60,9 @@ time - time component formatted as HH:MM:SS
sub process {
my ( $session, $toTZ, $format, $date, $time ) = @_;
my $uTZ = 'UTC';
my $uFormat = '%F %T';
my $uTZ = $session->user->profileField("timeZone");
my $uFormat = $session->user->profileField("dateFormat");
# Change defaults only if we have a user defined and they have these set.
eval { $session->user };
unless ($@) {
$uTZ = $session->user->profileField("timeZone");
$uFormat = $session->user->profileField("dateFormat");
}
$toTZ ||= $uTZ;
$format ||= $uFormat;

View file

@ -35,8 +35,8 @@ sub process {
my $i18n = WebGUI::International->new($session, "Macro_SpectreCheck");
if (defined $status) {
return $i18n->get('success') if($status eq 'success');
return $i18n->get('subnet') if($status eq 'subnet');
return $i18n->get('spectre') if($status eq 'spectre');
return $i18n->get('subnet') if($status eq 'subnet');
return $i18n->get('spectre');
}
else {
return $i18n->get('spectre');

View file

@ -204,6 +204,14 @@ sub definition {
hoverHelp=>$i18n->get("Enable Metadata description"),
defaultValue=>$setting->get("metaDataEnabled")
});
push(@fields, {
tab=>"content",
fieldType=>"interval",
name=>"maxCacheTimeout",
label=>$i18n->get("Maximum cache timeout"),
hoverHelp=>$i18n->get("Maximum cache timeout description"),
defaultValue=>$setting->get("maxCacheTimeout")
});
# user interface settings
push(@fields, {
tab=>"ui",

View file

@ -205,19 +205,36 @@ sub getStreamedFile {
#-------------------------------------------------------------------
=head2 ifModifiedSince ( epoch )
=head2 ifModifiedSince ( epoch [, maxCacheTimeout] )
Returns 1 if the epoch is greater than the modified date check.
=head3 epoch
The date that the requested content was last modified in epoch format.
=head3 maxCacheTimeout
A modifier to the epoch, that allows us to set a maximum timeout where content will appear to
have changed and a new page request will be allowed to be processed.
=cut
sub ifModifiedSince {
my $self = shift;
my $epoch = shift;
my $self = shift;
my $epoch = shift;
my $maxCacheTimeout = shift;
require APR::Date;
my $modified = $self->session->request->headers_in->{'If-Modified-Since'};
return 1 if ($modified eq "");
$modified = APR::Date::parse_http($modified);
##Implement a step function that increments the epoch time in integer multiples of
##the maximum cache time. Used to handle the case where layouts containing macros
##(like assetproxied Navigations) can be periodically updated.
if ($maxCacheTimeout) {
my $delta = time() - $epoch;
$epoch += $delta - ($delta % $maxCacheTimeout);
}
return ($epoch > $modified);
}

View file

@ -54,9 +54,12 @@ sub buildXML {
$xmlTop->{Package} = [];
##Do a request for each package.
my $packageIndex;
my $shipType = $self->get('shipType');
my $service = $shipType eq 'PRIORITY VARIABLE' ? 'PRIORITY'
: $shipType;
my $shipType = $self->get('shipType');
my $service = $shipType eq 'PRIORITY VARIABLE'
? 'PRIORITY'
: $shipType;
my $sourceZip = $self->get('sourceZip');
$sourceZip =~ s/^(\d{5}).*$/$1/;
PACKAGE: for(my $packageIndex = 0; $packageIndex < scalar @packages; $packageIndex++) {
my $package = $packages[$packageIndex];
next PACKAGE unless scalar @{ $package };
@ -79,6 +82,7 @@ sub buildXML {
}
my $destination = $package->[0]->getShippingAddress;
my $destZipCode = $destination->get('code');
$destZipCode =~ s/^(\d{5}).*$/$1/;
$packageData{ID} = $packageIndex;
$packageData{Service} = [ $service ];
$packageData{ZipOrigination} = [ $self->get('sourceZip') ];

View file

@ -197,7 +197,6 @@ sub new {
my $session = shift;
my $startingTabs = shift;
my $css = shift || $session->url->extras('tabs/tabs.css');
my $cancelUrl = shift || $session->url->page();
my %tabs;
tie %tabs, 'Tie::IxHash';
foreach my $key (keys %{$startingTabs}) {
@ -206,9 +205,13 @@ sub new {
$tabs{$key}{uiLevel} = $startingTabs->{$key}->{uiLevel};
}
my $i18n = WebGUI::International->new($session);
my $cancelJS = 'history.go(-1);';
if (my $cancelURL = $session->env->get('HTTP_REFERER')) {
$cancelJS = sprintf q{window.location.href='%s';}, $cancelURL;
}
my $cancel = WebGUI::Form::button($session,{
value=>$i18n->get('cancel'),
extras=>q|onclick="history.go(-1);" class="backwardButton"|
extras=>sprintf(q|onclick="%s" class="backwardButton"|, $cancelJS),
});
bless { _session=>$session, _cancel=>$cancel, _submit=>WebGUI::Form::submit($session),
_form=>WebGUI::Form::formHeader($session), _hidden=>"", _tab=>\%tabs, _css=>$css }, $class;

View file

@ -115,7 +115,7 @@ sub execute {
# Stop if there are no records preceding ageToDelete
next USERLOOP unless @deleteTimes;
my $inTimes = WebGUI::SQL::quoteAndJoin( \@deleteTimes );
my $inTimes = $db->quoteAndJoin( \@deleteTimes );
$db->write( "DELETE FROM userLoginLog WHERE userId = ? AND timeStamp IN ($inTimes)", [$userId] );
} ## end while ( my (@userIdData) ...
} ## end else [ if ( not $self->get("retainLastAlways"...

View file

@ -1392,6 +1392,12 @@ Couldn't open %-s because %-s <br />
context => q{},
},
'Any Class' => {
message => q{Any Class},
lastUpdated => 0,
context => q{Class, as in name of class, or type of asset},
},
};
1;

View file

@ -4660,6 +4660,16 @@ Users may override this setting in their profile.
lastUpdated => 0,
},
'Maximum cache timeout' => {
message => 'Maximum cache timeout',
lastUpdated => 0,
},
'Maximum cache timeout description' => {
message => 'This timeout will override the content check that is done before generating a page. It can help with caching problems for macros and Navigations. Setting it to 0 will disable the timeout. A setting of several hours is recommended.',
lastUpdated => 0,
},
};
1;