X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FArticles%2FArticle%2FEdit.html;h=a6e5e12fec880a11a6ba950b0dde48d6e1d57081;hp=d14c33076093a511648b4158daab5ef955ec6f97;hb=9aee669886202be7035e6c6049fc71bc99dd3013;hpb=f3c4966ed1f6ec3db7accd6dcdd3a5a3821d72a7 diff --git a/rt/share/html/Articles/Article/Edit.html b/rt/share/html/Articles/Article/Edit.html index d14c33076..a6e5e12fe 100644 --- a/rt/share/html/Articles/Article/Edit.html +++ b/rt/share/html/Articles/Article/Edit.html @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -115,6 +115,12 @@ my $title; my $Entries = {}; my $ArticleObj = RT::Article->new( $session{'CurrentUser'} ); my $ClassObj = RT::Class->new( $session{'CurrentUser'} ); + +if ($Class) { + $ClassObj->Load($Class); + Abort(loc("'[_1]' isn't a valid class", $Class)) unless $ClassObj->Id; +} + my %create_args; my %CFContent; my $EditClass = 1; @@ -129,11 +135,6 @@ if ( !$id ) { } } - $ClassObj->Load($Class); - unless ( $ClassObj->Id ) { - $m->comp( "/Elements/Error", - Why => loc( "'[_1]' isn't a valid class identifier", $Class ) ); - } $EditClass = 0; $id = 'new'; } @@ -149,48 +150,10 @@ elsif ( $id eq 'new' ) { split( /\s+/, $ARGS{'new-RefersTo'} ); } - - foreach my $arg (keys %ARGS) { - next if $arg =~ /-(?:Magic|Category)$/; - # Object-RT::Article--CustomField-3-Values - if ( $arg =~ /^Object-RT::Article--CustomField-(\d+)(.*?)$/ ) { - my $cfid = $1; - - my $cf = RT::CustomField->new( $session{'CurrentUser'} ); - $cf->SetContextObject( $ArticleObj ); - $cf->Load( $cfid ); - unless ( $cf->id ) { - $RT::Logger->error( "Couldn't load custom field #". $cfid ); - next; - } - - if ( $arg =~ /-Upload$/ ) { - $create_args{"CustomField-$cfid"} = _UploadedFile( $arg ); - next; - } - - my $type = $cf->Type; - - my @values = (); - if ( ref $ARGS{ $arg } eq 'ARRAY' ) { - @values = @{ $ARGS{ $arg } }; - } elsif ( $type =~ /text/i ) { - @values = ($ARGS{ $arg }); - } else { - @values = split /\r*\n/, $ARGS{ $arg } || ''; - } - @values = grep $_ ne '', - map { - s/\r+\n/\n/g; - s/^\s+//; - s/\s+$//; - $_; - } - grep defined, @values; - - $create_args{"CustomField-$cfid"} = \@values; - } - } + my %cfs = ProcessObjectCustomFieldUpdatesForCreate( + ARGSRef => \%ARGS, + ContextObject => $ClassObj, + ); my $msg; ( $id, $msg ) = $ArticleObj->Create( @@ -198,7 +161,8 @@ elsif ( $id eq 'new' ) { Name => $ARGS{'Name'}, Class => $ARGS{'Class'}, Topics => $ARGS{'Topics'}, - %create_args + %create_args, + %cfs ); push( @results, $msg ); if ($id) { @@ -219,12 +183,7 @@ elsif ( $id eq 'new' ) { ); } } - if (!$id) { - $ClassObj->Load($Class); - unless ( $ClassObj->Id ) { - $m->comp( "/Elements/Error", - Why => loc( "'[_1]' isn't a valid class identifier", $Class ) ); - } + else { $ArticleObj = RT::Article->new( $session{'CurrentUser'} ); $id = 'new'; $EditClass = 0;