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

@ -83,6 +83,7 @@ property mailAccount => (
tab => 'mail',
label => [ "mail account", 'Asset_Collaboration' ],
hoverHelp => [ "mail account help", 'Asset_Collaboration' ],
extras => 'autocomplete="off"',
);
property mailPassword => (
fieldType => "password",

View file

@ -107,6 +107,24 @@ sub _fetchDepartments {
}
#-------------------------------------------------------------------
=head2 getStatusList
Returns the statusList property as an array
=cut
sub getStatusList {
my $self = shift;
my $text = $self->get('statusList');
return
grep { $_ } # no empty lines
map { s/^\s+//; s/\s+$//; $_ } # trim
split(/\r\n|\r|\n/, $text); # seperated by any kind of newline
}
#-------------------------------------------------------------------
=head2 prepareView ( )
@ -174,16 +192,9 @@ sub view {
}
my $statusUserId = $self->session->scratch->get("userId") || $self->session->user->userId;
my $statusListString = $self->statusList;
my @statusListArray = split("\n",$statusListString);
my $statusListHashRef;
tie %$statusListHashRef, 'Tie::IxHash';
foreach my $status (@statusListArray) {
chomp($status);
next if $status eq "";
$statusListHashRef->{$status} = $status;
}
tie my %statusOptions, 'Tie::IxHash', (
map { $_ => $_ } $self->getStatusList
);
#$self->session->log->warn("VIEW: userId: ".$statusUserId."\n" );
my ($status) = $session->db->quickArray(
@ -222,7 +233,7 @@ sub view {
$f->radioList(
-name=>"status",
-value=>$status,
-options=>$statusListHashRef,
-options=>\%statusOptions,
-label=>$i18n->get(5),
-hoverHelp=>$i18n->get('5 description'),
);

View file

@ -298,9 +298,10 @@ sub getFolder {
my ($self, $date) = @_;
my $session = $self->session;
my $folderName = $session->datetime->epochToHuman($date, DATE_FORMAT);
my $folderUrl = join '/', $self->getUrl, $folderName;
my $folderUrl = $self->getFolderUrl($folderName);
my $folder = eval { WebGUI::Asset->newByUrl($session, $folderUrl); };
return $folder if !Exception::Class->caught();
##The requested folder doesn't exist. Make it and autocommit it.
##For a fully automatic commit, save the current tag, create a new one
@ -335,6 +336,26 @@ sub getFolder {
#-------------------------------------------------------------------
=head2 getFolderUrl ( name )
Constructs a url for a subfolder with the given name.
=cut
sub getFolderUrl {
my ($self, $name) = @_;
my $session = $self->session;
my $base = $self->getUrl;
$base =~ s/(.*)\..*/$1/;
my $url = "$base/$name";
if (my $ext = $session->setting->get('urlExtension')) {
$url .= ".$ext";
}
return $session->url->urlize($url);
}
#-------------------------------------------------------------------
=head2 getKeywordFilename ( $keyword )
Returns the name for the file containing stories that match this keyword. Used

View file

@ -45,6 +45,8 @@ sub _defaultThingId_options {
return $things;
}
use WebGUI::ProgressBar;
#-------------------------------------------------------------------
@ -2628,6 +2630,11 @@ sub www_export {
my $thingProperties = $self->getThing($thingId);
return $session->privilege->insufficient() unless $self->hasPrivileges($thingProperties->{groupIdExport});
my $i18n = WebGUI::International->new($session, 'Asset_Thingy');
my $pb = WebGUI::ProgressBar->new($session);
$pb->start($i18n->get('export label').' '.$thingProperties->{label}, $session->url->extras('assets/thingy.gif'));
$pb->update($i18n->get('Creating column headers'));
my $tempStorage = WebGUI::Storage->createTemp($session);
$fields = $session->db->read('select * from Thingy_fields where assetId =? and thingId = ? order by sequenceNumber',
[$self->getId,$thingId]);
while (my $field = $fields->hashRef) {
@ -2649,9 +2656,13 @@ sub www_export {
### Loop through the returned structure and put it through Text::CSV
# Column heads
$out = WebGUI::Text::joinCSV(@fieldLabels);
my $csv_filename = 'export_'.$thingProperties->{label}.'.csv';
$tempStorage->addFileFromScalar($csv_filename, WebGUI::Text::joinCSV(@fieldLabels));
open my $CSV, '>', $tempStorage->getPath($csv_filename);
# Data lines
$pb->update($i18n->get('Writing data'));
my $rowCounter = 0;
while (my $data = $sth->hashRef) {
my @fieldValues;
foreach my $field (@fields){
@ -2660,19 +2671,20 @@ sub www_export {
my $value = $self->getFieldValue($data->{"field_".$fieldId},$field->{properties},"%y-%m-%d","%y-%m-%d %j:%n:%s");
push(@fieldValues, $value);
}
foreach my $metaDataField (@metaDataFields){
push(@fieldValues,$data->{$metaDataField});
if ($thingProperties->{exportMetaData}) {
foreach my $metaDataField (@metaDataFields){
push(@fieldValues,$data->{$metaDataField});
}
}
$out .= "\n".WebGUI::Text::joinCSV(
@fieldValues
);
print $CSV "\n".WebGUI::Text::joinCSV( @fieldValues );
#if (! ++$rowCounter % 25) {
$pb->update($i18n->get('Writing data'));
#}
}
$fileName = "export_".$thingProperties->{label}.".csv";
$self->session->http->setFilename($fileName,"application/octet-stream");
$self->session->http->sendHeader;
return $out;
close $CSV;
$pb->update(sprintf q|<a href="%s">%s</a>|, $self->getUrl, sprintf($i18n->get('Return to %s'), $thingProperties->{label}));
return $pb->finish($tempStorage->getUrl($csv_filename));
}
#-------------------------------------------------------------------