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

@ -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