Merge branch 'master' into WebGUI8. Merged up to 7.10.4

This commit is contained in:
Colin Kuskie 2010-11-03 09:47:36 -07:00
commit 5f3014aaee
66 changed files with 3078 additions and 997 deletions

View file

@ -391,6 +391,9 @@ use WebGUI::HTML;
use WebGUI::HTMLForm;
use WebGUI::Keyword;
require WebGUI::ProgressBar;
use WebGUI::ProgressTree;
use Monkey::Patch;
use WebGUI::Fork;
use WebGUI::Search::Index;
use WebGUI::TabForm;
use WebGUI::PassiveAnalytics::Logging;
@ -836,6 +839,59 @@ sub fixUrl {
#-------------------------------------------------------------------
=head2 forkWithStatusPage ($args)
Kicks off a WebGUI::Fork running $method with $args (from the args hashref)
and redirects to a ProgressTree status page to show the progress. The
following arguments are required in $args:
=head3 method
The name of the WebGUI::Asset method to call
=head3 args
The arguments to pass that method (see WebGUI::Fork)
=head3 plugin
The WebGUI::Operation::Fork plugin to render (e.g. ProgressTree)
=head3 title
An key in Asset's i18n hash for the title of the rendered console page
=head3 redirect
The full url to redirect to after the fork has finished.
=cut
sub forkWithStatusPage {
my ( $self, $args ) = @_;
my $session = $self->session;
my $process = WebGUI::Fork->start( $session, 'WebGUI::Asset', $args->{method}, $args->{args} );
if ( my $groupId = $args->{groupId} ) {
$process->setGroup($groupId);
}
my $method = $session->form->get('proceed') || 'manageTrash';
my $i18n = WebGUI::International->new( $session, 'Asset' );
my $pairs = $process->contentPairs(
$args->{plugin}, {
title => $i18n->get( $args->{title} ),
icon => 'assets',
proceed => $args->{redirect} || '',
}
);
$session->http->setRedirect( $self->getUrl($pairs) );
return 'redirect';
} ## end sub forkWithStatusPage
#-------------------------------------------------------------------
=head2 getClassById ( $session, $assetId )
Class method that looks up a className for an object in the database, using it's assetId.
@ -2412,6 +2468,35 @@ sub setSize {
$self->assetSize($size);
}
#-------------------------------------------------------------------
=head2 setState ( $state )
Updates the asset table with the new state of the asset.
=cut
sub setState {
my ($self, $state) = @_;
my $sql = q{
UPDATE asset
SET state = ?,
stateChangedBy = ?,
stateChanged = ?
WHERE assetId = ?
};
my @props = ($state, $self->session->user->userId, time);
$self->session->db->write(
$sql, [
@props,
$self->getId,
]
);
$self->state($state);
$self->stateChangedBy($props[1]);
$self->stateChanged($props[2]);
$self->purgeCache;
}
#-------------------------------------------------------------------
@ -2477,23 +2562,7 @@ sub write {
Returns the asset's url without any site specific prefixes. If you want a browser friendly url see the getUrl() method.
# set the property
if ($propertyDefinition->{serialize}) {
# Only serialize references
if ( ref $value ) {
$setPairs{$property} = JSON->new->canonical->encode($value);
}
# Passing already serialized JSON string
elsif ( $value ) {
$setPairs{$property} = $value;
$value = JSON->new->decode( $value ); # for setting in _properties, below
}
}
else {
$setPairs{$property} = $value;
}
$self->{_properties}{$property} = $value;
}
=head3 value
The new value to set the URL to.