Merge in HEAD, up to 9866.

This commit is contained in:
Colin Kuskie 2009-03-17 23:45:21 +00:00
parent c7a66861a6
commit 2bd7a60a01
107 changed files with 6258 additions and 2436 deletions

View file

@ -58,6 +58,43 @@ sub addRevision {
return $newSelf;
}
#----------------------------------------------------------------------------
=head2 canAdd ( )
Override canAdd to ignore its permissions check. Permissions are handled
by the parent Matrix.
=cut
sub canAdd {
return 1;
}
#----------------------------------------------------------------------------
=head2 canEdit ( )
Returns true if the user can edit this asset. C<userId> is a WebGUI user ID.
Users can edit this Matrix listing if they are the owner, or if they can edit
the parent Matrix.
=cut
sub canEdit {
my $self = shift;
if ( $self->session->form->process("assetId") eq "new" ) {
return $self->getParent->canAddMatrixListing();
}
else {
return 1 if $self->session->user->userId eq $self->get("ownerUserId");
return $self->getParent->canEdit();
}
}
#-------------------------------------------------------------------
=head2 definition ( session, definition )
@ -327,7 +364,7 @@ sub getEditForm {
$form->raw(
'<tr><td COLSPAN=2>'.
WebGUI::Form::Button($session, {}).
WebGUI::Form::Submit($session, {}).
WebGUI::Form::Button($session, {
-value => $i18n->get('cancel', 'WebGUI'),
-extras => q|onclick="history.go(-1);" class="backwardButton"|
@ -580,6 +617,14 @@ sub view {
if ($emailSent){
$var->{emailSent} = 1;
}
unless($self->hasBeenCommitted){
my $workflowInstanceId = $db->quickScalar("select workflowInstanceId from assetVersionTag where tagId =?"
,[$self->get('tagId')]);
$var->{canApprove} = $self->getParent->canEdit;
$var->{approveOrDenyUrl} = $self->getUrl("op=manageRevisionsInTag;workflowInstanceId=".$workflowInstanceId
.";tagId=".$self->get('tagId'));
}
$var->{canEdit} = $self->canEdit;
$var->{editUrl} = $self->getUrl("func=edit");
$var->{controls} = $self->getToolbar;
@ -647,33 +692,10 @@ sub view {
my $storage = $file->getStorageLocation;
my @files;
@files = @{ $storage->getFiles } if (defined $storage);
$var->{screenshots} = qq|
<script type="text/javascript" src="/extras/ukplayer/swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("myFlashContent","9.0.0","/extras/ukplayer/expressInstall.swf");
</script>
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300" id="myFlashContent">
<param name="movie" value="/extras/ukplayer/slideShow.swf" />
<param name="flashvars" value="config=?func=getScreenshotsConfig" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="/extras/ukplayer/slideShow.swf" width="400"
height="300">
<param name="flashvars" value="config=?func=getScreenshotsConfig" />
<!--<![endif]-->
<a href="http:/www.adobe.com/go/getflashplayer">
<img src="http:/www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe
Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
|;
$var->{screenshotsUrl} = $self->getUrl('func=viewScreenshots');
$var->{screenshotThumbnail} = $storage->getUrl('thumb-'.$files[0]);
}
# Rating form
my %rating;
@ -835,12 +857,14 @@ Web facing method which is the default edit page
sub www_edit {
my $self = shift;
return $self->session->privilege->noAccess() unless $self->getParent->canAddMatrixListing();
my $i18n = WebGUI::International->new($self->session, "Asset_MatrixListing");
return $self->session->privilege->insufficient() unless $self->canEdit;
return $self->session->privilege->locked() unless $self->canEditIfLocked;
if($self->session->form->process('func') eq 'add'){
return $self->session->privilege->noAccess() unless $self->getParent->canAddMatrixListing();
}else{
return $self->session->privilege->insufficient() unless $self->canEdit;
return $self->session->privilege->locked() unless $self->canEditIfLocked;
}
my $var = $self->get;
my $matrix = $self->getParent;
@ -930,9 +954,7 @@ sub www_getScreenshots {
my $thumb = 'thumb-'.$file;
$xml .= "
<slide>
<width>400</width>
<height>300</height>
<title><![CDATA[<b>Slide</b> One]]></title>
<title></title>
<description><![CDATA[ Screenshots ]]></description>
<image_source>".$storage->getUrl($file)."</image_source>
<duration>5</duration>
@ -960,56 +982,14 @@ Returns the xml config file for the ukplayer that displays the screenshots.
=cut
sub www_getScreenshotsConfig {
my $self = shift;
my $self = shift;
my $var = $self->get;
return $self->session->privilege->noAccess() unless $self->canView;
$self->session->http->setMimeType('text/xml');
my $xml = qq|<?xml version="1.0" encoding="UTF-8"?>
<config>
<content_url>?func=getScreenshots</content_url>
<width>400</width><!-- this value is overwritten by the flashVars but the tag needs to be here (and it is
useful for offline testing) -->
<height>300</height><!-- this value is overwritten by the flashVars but the tag needs to be here (and it is
useful for offline testing) -->
<background_color>0xDDDDEE</background_color>
<default_duration>20</default_duration>
<default_slidewidth>100</default_slidewidth>
<default_slideheight>100</default_slideheight>
<font>Verdana</font>
<font_size>12</font_size>
<font_color>0xCCCCCC</font_color>
<text_border_color>0xCCCCCC</text_border_color>
<text_bg_color>0x000000</text_bg_color>
<text_autohide>true</text_autohide>
<controls_color>0xCCCCCC</controls_color>
<controls_border_color>0xCCCCCC</controls_border_color>
<controls_bg_color>0x000000</controls_bg_color>
<controls_autohide>false</controls_autohide>
<thumbnail_width>48</thumbnail_width>
<thumbnail_height>36</thumbnail_height>
<thumbnail_border_color>0x000000</thumbnail_border_color>
<menu_autohide>true</menu_autohide>
<menu_dead_zone_width>100</menu_dead_zone_width>
<menu_gaps>5</menu_gaps>
<mute_at_start>false</mute_at_start>
<autostart>true</autostart>
<autopause>false</autopause>
<loop>false</loop>
<error_message_content><![CDATA[XML not found: ]]></error_message_content>
<error_message_image><![CDATA[Image not found]]></error_message_image>
</config>
|;
return $xml;
return $self->processTemplate($var,$self->getParent->get("screenshotsConfigTemplateId"));
}
#-------------------------------------------------------------------
@ -1117,7 +1097,24 @@ sub www_view {
return $self->view;
}
#-------------------------------------------------------------------
=head2 www_viewScreenshots ( )
Returns this listing's screenshots in a ukplayer.
=cut
sub www_viewScreenshots {
my $self = shift;
my $var = $self->get;
$var->{configUrl} = 'config='.$self->getUrl("func=getScreenshotsConfig");
return $self->session->privilege->noAccess() unless $self->canView;
return $self->processTemplate($var,$self->getParent->get("screenshotsTemplateId"));
}
1;
#vim:ft=perl

View file

@ -292,6 +292,31 @@ sub getThumbnailUrl {
return undef;
}
#-------------------------------------------------------------------
=head2 getVendorId ( )
Returns the vendorId of the vendor for this sku. Defaults to the default
vendor with id defaultvendor000000000.
=cut
sub getVendorId {
my $self = shift;
return 'defaultvendor000000000';
}
#-------------------------------------------------------------------
=head2 getVendorPayout ( )
Returns the amount that should be payed to the vendor for this sku.
=cut
sub getVendorPayout {
return 0;
}
#-------------------------------------------------------------------
=head2 getWeight ( )

View file

@ -391,12 +391,13 @@ sub _cacheFieldConfig {
my $fieldData;
if ($jsonData && eval { $jsonData = JSON::from_json($jsonData) ; 1 }) {
# jsonData is an array in the order the fields should be
$self->{_fieldConfig} = {
map { $_->{name}, $_ } @{ $jsonData }
};
$self->{_fieldOrder} = [
map { $_->{name} } @{ $jsonData }
];
$self->{_fieldConfig} = {};
$self->{_fieldOrder} = [];
FIELD: foreach my $field (@{ $jsonData } ) {
next FIELD unless ref $field eq 'HASH';
$self->{_fieldConfig}->{$field->{name}} = $field;
push @{ $self->{_fieldOrder} }, $field->{name};
}
}
else {
$self->{_fieldConfig} = {};

View file

@ -30,10 +30,46 @@ Returns true if able to add MatrixListings.
sub canAddMatrixListing {
my $self = shift;
my $user = $self->session->user;
return 0 if $self->session->user->isVisitor;
# Users in the groupToAdd group can add listings
if ( $user->isInGroup( $self->get("groupToAdd") ) ) {
return 1;
}
# Users who can edit matrix can add listings
else {
return $self->canEdit;
}
return 1;
}
#----------------------------------------------------------------------------
=head2 canEdit ( [userId] )
Returns true if the user can edit this Matrix.
Also checks if a user is adding a Matrix Listing and allows them to if they are
part of the C<groupToAdd> group.
=cut
sub canEdit {
my $self = shift;
my $userId = shift || $self->session->user->userId;
my $form = $self->session->form;
if ( $form->get('func') eq "editSave" && $form->get('assetId') eq "new" && $form->get( 'class' )->isa(
'WebGUI::Asset::MatrixListing' ) ) {
return $self->canAddMatrixListing();
}
else {
if ($userId eq $self->get("ownerUserId")) {
return 1;
}
my $user = WebGUI::User->new($self->session, $userId);
return $user->isInGroup($self->get("groupIdEdit"));
}
}
#-------------------------------------------------------------------
@ -94,6 +130,22 @@ sub definition {
hoverHelp =>$i18n->get('edit listing template description'),
label =>$i18n->get('edit listing template label'),
},
screenshotsTemplateId=>{
defaultValue =>"matrixtmpl000000000006",
fieldType =>"template",
tab =>"display",
namespace =>"Matrix/Screenshots",
hoverHelp =>$i18n->get('screenshots template description'),
label =>$i18n->get('screenshots template label'),
},
screenshotsConfigTemplateId=>{
defaultValue =>"matrixtmpl000000000007",
fieldType =>"template",
tab =>"display",
namespace =>"Matrix/ScreenshotsConfig",
hoverHelp =>$i18n->get('screenshots config template description'),
label =>$i18n->get('screenshots config template label'),
},
defaultSort=>{
fieldType =>"selectBox",
tab =>"display",
@ -164,6 +216,13 @@ sub definition {
hoverHelp =>$i18n->get('max comparisons privileged description'),
label =>$i18n->get('max comparisons privileged label'),
},
groupToAdd=>{
fieldType =>"group",
tab =>"security",
defaultValue =>2,
hoverHelp =>$i18n->get('group to add description'),
label =>$i18n->get('group to add label'),
},
submissionApprovalWorkflowId=>{
fieldType =>"workflow",
tab =>"security",
@ -543,7 +602,8 @@ sub view {
}) };
foreach my $pendingListing (@pendingListings){
push (@{ $var->{pending_loop} }, {
url => $pendingListing->getUrl,
url => $pendingListing->getUrl
."?func=view;revision=".$pendingListing->get('revisionDate'),
name => $pendingListing->get('title'),
});
}

View file

@ -210,7 +210,11 @@ sub importProducts {
}
if ($productRow{title} ne $product->getTitle) {
$product->update({ title => $product->fixTitle($productRow{title}) });
my $newTitle = $product->fixTitle($productRow{title});
$product->update({
title => $newTitle,
menuTitle => $newTitle,
});
}
my $collaterals = $product->getAllCollateral('variantsJSON');
@ -230,10 +234,12 @@ sub importProducts {
##Insert a new product;
$session->log->warn("Making a new product: $productRow{sku}\n");
my $newProduct = $node->addChild({className => 'WebGUI::Asset::Sku::Product'});
my $newTitle = $newProduct->fixTitle($productRow{title});
$newProduct->update({
title => $newProduct->fixTitle($productRow{title}),
url => $newProduct->fixUrl($productRow{title}),
sku => $productRow{mastersku},
title => $newTitle,
menuTitle => $newTitle,
url => $newProduct->fixUrl($productRow{title}),
sku => $productRow{mastersku},
});
$newProduct->setCollateral('variantsJSON', 'variantId', 'new', \%productCollateral);
$newProduct->commit;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff