merged with HEAD and other interesting changes

This commit is contained in:
David Delikat 2009-03-19 04:12:03 +00:00
parent 66c6c0fae5
commit 856cc06d04
151 changed files with 7335 additions and 2602 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 )
@ -313,11 +350,27 @@ sub getEditForm {
$attribute->{label} = $attribute->{name};
$attribute->{subtext} = $attribute->{description};
$attribute->{name} = 'attribute_'.$attribute->{attributeId};
if($attribute->{fieldType} eq 'Combo'){
my %options;
tie %options, 'Tie::IxHash';
%options = $db->buildHash("select value, value from MatrixListing_attribute
where attributeId = ? and value != '' order by value",[$attribute->{attributeId}]);
$attribute->{options} = \%options;
$attribute->{extras} = "style='width:120px'";
}
$form->dynamicField(%{$attribute});
}
}
$form->submit();
$form->raw(
'<tr><td COLSPAN=2>'.
WebGUI::Form::Submit($session, {}).
WebGUI::Form::Button($session, {
-value => $i18n->get('cancel', 'WebGUI'),
-extras => q|onclick="history.go(-1);" class="backwardButton"|
}).
'</td></tr>'
);
return $form;
}
@ -564,6 +617,16 @@ 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;
$var->{comments} = $self->getFormattedComments();
$var->{productName} = $var->{title};
@ -629,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;
@ -817,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;
@ -912,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>
@ -942,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"));
}
#-------------------------------------------------------------------
@ -1099,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

@ -140,6 +140,25 @@ sub definition {
#-------------------------------------------------------------------
=head2 getDiscountAmount -- class level function
returns the amount of discount to apply to this purchase
=cut
sub getDiscountAmount {
my($discounts,$count) = @_;
my @discounts = parseDiscountText( $discounts );
my $previousDiscount = 0;
foreach my $discountSet ( @discounts ) {
last if $count < $discountSet->[1];
$previousDiscount = $discountSet->[0];
}
return $previousDiscount;
}
#-------------------------------------------------------------------
=head2 getDiscountText -- class level function
returns a string with a coma seperated list of counts fromt he discount text
@ -181,6 +200,24 @@ sub getImpressionDiscountText {
#-------------------------------------------------------------------
=head2 getPrice
get the price for this purchase
sub getPrice {
my $self = shift;
my $options = $self->getOptions;
my $impressionCount = $options->{impressions};
my $clickCount = $options->{clicks};
my $impressionDiscount = getDiscountAmount($self->get('impressionDiscounts'),$impressionCount );
my $clickDiscount = getDiscountAmount($self->get('clickDiscounts'),$clickCount );
my $impressionPrice = $self->get('pricePerImpression') - ( $impressionDiscount / 100 );
my $clickPrice = $self->get('pricePerClick') - ( $clickDiscount / 100 );
return sprintf "%.2f", $impressionPrice * $impressionCount + $clickPrice * $clickCount;
}
#-------------------------------------------------------------------
=head2 i18n
returns an internationalization object for this class
@ -235,7 +272,7 @@ sub manage {
=head2 onCompletePurchase
Applies the first term of the subscription. This method is called when the payment is successful.
inserts the ad intothe adspace...
=cut
@ -265,7 +302,7 @@ sub parseDiscountText {
push @discounts, [ $1, $2 ];
}
}
return @discounts;
return sort { $a->[1] <=> $b->[1] } @discounts;
}
#-------------------------------------------------------------------
@ -325,40 +362,40 @@ sub view {
manageLink => $self->getUrl("func=manage"),
adSkuTitle => $self->get('title'),
adSkuDescription => $self->get('description'),
form_title => WebGUI::Form::text($session, {
-name=>"form_title",
formTitle => WebGUI::Form::text($session, {
-name=>"formTitle",
-value=>$self->{title},
-size=>40
-default=>'untitled',
}),
form_link => WebGUI::Form::Url($session, {
-name=>"form_link",
formLink => WebGUI::Form::Url($session, {
-name=>"formLink",
-value=>$self->{link},
-size=>40
-required=>1,
}),
form_image => WebGUI::Form::Image($session, {
-name=>"form_image",
formImage => WebGUI::Form::Image($session, {
-name=>"formImage",
-value=>$self->{image},
-size=>40
-required=>1,
-forceImageOnly=>1,
}),
form_clicks => WebGUI::Form::Integer($session, {
-name=>"form_clicks",
formClicks => WebGUI::Form::Integer($session, {
-name=>"formClicks",
-value=>$self->{clicks},
-size=>40
-required=>1,
}),
form_impressions => WebGUI::Form::Integer($session, {
-name=>"form_impressions",
formImpressions => WebGUI::Form::Integer($session, {
-name=>"formImpressions",
-value=>$self->{impressions},
-size=>40
-required=>1,
}),
click_price => $self->get('pricePerClick'),
impression_price => $self->get('pricePerImpression'),
click_discount => $self->getClickDiscountText,
impression_discount => $self->getImpressionDiscountText,
clickPrice => $self->get('pricePerClick'),
impressionPrice => $self->get('pricePerImpression'),
clickDiscount => $self->getClickDiscountText,
impressionDiscount => $self->getImpressionDiscountText,
);
return $self->processTemplate(\%var,undef,$self->{_viewTemplate});
}
@ -398,7 +435,14 @@ sub www_addToCart {
my $self = shift;
if ($self->canView) {
$self->{_hasAddedToCart} = 1;
$self->addToCart({price => $self->getPrice});
my $form = $self->session->form;
$self->addToCart({
title => $form->get('formTitle'),
link => $form->get('formLink','url'),
image => $form->get('formImage'),
clicks => $form->get('formClicks'),
impressions => $form->get('formImpressions'),
});
}
return $self->www_view;
}

View file

@ -169,11 +169,14 @@ Accepts the information from the donation form and adds it to the cart.
=cut
sub www_donate {
my $self = shift;
if ($self->canView) {
my $self = shift;
my $price = $self->session->form->get("price") || $self->getPrice;
if ($self->canView && $price > 0) {
$self->{_hasAddedToCart} = 1;
$self->addToCart({price => ($self->session->form->get("price") || $self->getPrice) });
$self->addToCart( { price => $price } );
}
return $self->www_view;
}

View file

@ -88,7 +88,7 @@ sub definition {
},
parser => {
noFormPost => 1,
fieldType => 'selectList',
fieldType => 'selectBox',
defaultValue => [$session->config->get("defaultTemplateParser")],
},
namespace => {
@ -144,6 +144,7 @@ sub processPropertiesFromFormPost {
my %data;
my $needsUpdate = 0;
if ($self->getValue("parser") ne $self->session->form->process("parser","className") && ($self->session->form->process("parser","className") ne "")) {
$needsUpdate = 1;
if (isIn($self->session->form->process("parser","className"),@{$self->session->config->get("templateParsers")})) {
%data = ( parser => $self->session->form->process("parser","className") );
} else {

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} = {};
@ -484,9 +485,7 @@ sub deleteAttachedFiles {
my $form = $self->_createForm($fieldConfig->{$field}, $entryData->{$field});
if ($form->can('getStorageLocation')) {
my $storage = $form->getStorageLocation;
if ($storage) {
$storage->delete;
}
$storage->delete if $storage;
}
}
}
@ -498,7 +497,7 @@ sub deleteAttachedFiles {
my $form = $self->_createForm($fieldConfig->{$field}, $entryData->{$field});
if ($form->can('getStorageLocation')) {
my $storage = $form->getStorageLocation;
$storage->delete;
$storage->delete if $storage;
}
}
}

View file

@ -1104,6 +1104,7 @@ sub www_addAlbumService {
description => $form->get('synopsis','textarea'),
synopsis => $form->get('synopsis','textarea'),
othersCanAdd => $form->get('othersCanAdd','yesNo'),
ownerUserId => $session->user->userId,
});
$album->requestAutoCommit;

View file

@ -1019,6 +1019,7 @@ sub www_addFileService {
title => $form->get('title','text'),
description => $form->get('synopsis','textarea'),
synopsis => $form->get('synopsis','textarea'),
ownerUserId => $session->user->userId,
});
my $storage = $file->getStorageLocation;

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",
@ -442,6 +501,8 @@ sub view {
# javascript and css files for compare form datatable
$self->session->style->setLink($self->session->url->extras('yui/build/datatable/assets/skins/sam/datatable.css'),
{type =>'text/css', rel=>'stylesheet'});
$self->session->style->setScript($self->session->url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'), {type =>
'text/javascript'});
$self->session->style->setScript($self->session->url->extras('yui/build/json/json-min.js'), {type =>
'text/javascript'});
$self->session->style->setScript($self->session->url->extras('yui/build/connection/connection-min.js'), {type =>
@ -541,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'),
});
}
@ -1024,6 +1086,7 @@ sub www_getCompareListData {
unless (scalar(@listingIds)) {
@listingIds = $self->session->form->checkList("listingId");
}
my @responseFields = ("attributeId", "name", "description","fieldType", "checked");
foreach my $listingId (@listingIds){
$listingId =~ s/_____/-/g;
@ -1038,11 +1101,13 @@ sub www_getCompareListData {
url =>$listing->getUrl,
lastUpdated =>$session->datetime->epochToHuman( $listing->get('revisonDate'),"%z" ),
});
push(@responseFields, $listingId_safe, $listingId_safe."_compareColor");
}
push(@results,{name=>$i18n->get('last updated label'),fieldType=>'lastUpdated'});
my $jsonOutput;
$jsonOutput->{ColumnDefs} = \@columnDefs;
$jsonOutput->{ColumnDefs} = \@columnDefs;
$jsonOutput->{ResponseFields} = \@responseFields;
foreach my $category (keys %{$self->getCategories}) {
push(@results,{name=>$category,fieldType=>'category'});
@ -1144,6 +1209,7 @@ sub www_search {
my $self = shift;
my $var = $self->get;
my $db = $self->session->db;
$var->{compareForm} = $self->getCompareForm;
$self->session->style->setScript($self->session->url->extras('yui/build/yahoo/yahoo-min.js'),
@ -1175,7 +1241,7 @@ sub www_search {
my $attributes;
my @attribute_loop;
my $categoryLoopName = $self->session->url->urlize($category)."_loop";
$attributes = $self->session->db->read("select * from Matrix_attribute where category =? and assetId = ?",
$attributes = $db->read("select * from Matrix_attribute where category =? and assetId = ?",
[$category,$self->getId]);
while (my $attribute = $attributes->hashRef) {
$attribute->{label} = $attribute->{name};
@ -1184,10 +1250,14 @@ sub www_search {
$attribute->{extras} = " class='attributeSelect'";
if($attribute->{fieldType} eq 'Combo'){
$attribute->{fieldType} = 'SelectBox';
}
if($attribute->{fieldType} eq 'SelectBox'){
$attribute->{options} = "blank\n".$attribute->{options};
my %options;
tie %options, 'Tie::IxHash';
%options = $db->buildHash('select value, value from MatrixListing_attribute
where attributeId = ? order by value',[$attribute->{attributeId}]);
$options{'blank'} = 'blank';
$attribute->{options} = \%options;
$attribute->{value} = 'blank';
$attribute->{extras} = "style='width:120px'";
}
$attribute->{form} = WebGUI::Form::DynamicField->new($self->session,%{$attribute})->toHtml;
push(@attribute_loop,$attribute);

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

View file

@ -212,6 +212,7 @@ sub purgeRevision {
}
#-------------------------------------------------------------------
=head2 view ( )
method called by the container www_view method.
@ -261,6 +262,7 @@ our @EXPORT = qw(install uninstall);
use WebGUI::Session;
#-------------------------------------------------------------------
sub install {
my $config = $ARGV[0];
my $home = $ARGV[1] || "/data/WebGUI";
@ -279,6 +281,7 @@ sub install {
}
#-------------------------------------------------------------------
sub uninstall {
my $config = $ARGV[0];
my $home = $ARGV[1] || "/data/WebGUI";