X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fhtml%2FAdmin%2FElements%2FEditScrip;h=907ae9a9219942f0f2c79648edf4325a7dba1760;hp=edf949ba3523c235b5e0410dce2314750cb64a8f;hb=9c68254528b6f2c7d8c1921b452fa56064783782;hpb=ef20b2b6b1feb47ad02b5ff7525f1a0fd11d0fa4 diff --git a/rt/html/Admin/Elements/EditScrip b/rt/html/Admin/Elements/EditScrip index edf949ba3..907ae9a92 100644 --- a/rt/html/Admin/Elements/EditScrip +++ b/rt/html/Admin/Elements/EditScrip @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -22,9 +22,7 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -%# 02110-1301 or visit their web page on the internet at -%# http://www.gnu.org/copyleft/gpl.html. +%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -46,95 +44,150 @@ %# %# END BPS TAGGED BLOCK }}} <& /Elements/ListActions, actions => \@actions &> - -
- - - -<&| /Widgets/TitleBox, title => loc('Scrip Fields') &> - - - - - - - - - - - + + + + +<& /Elements/TitleBoxStart, title => loc('Scrip Fields') &> +
<&|/l&>Description: -Description %>" /> -
<&|/l&>Condition: -<& /Admin/Elements/SelectScripCondition, - Name => "Scrip-$id-ScripCondition", - Default => $ARGS{"Scrip-$id-ScripCondition"} || $scrip->ConditionObj->Id, -&>
<&|/l&>Action: -<& /Admin/Elements/SelectScripAction, - Name => "Scrip-$id-ScripAction", - Default => $ARGS{"Scrip-$id-ScripAction"} || $scrip->ActionObj->Id, -&>
<&|/l&>Template: -<& /Admin/Elements/SelectTemplate, - Name => "Scrip-$id-Template", - Default => $ARGS{"Scrip-$id-Template"} || $scrip->TemplateObj->Id, - Queue => $Queue, -&>
<&|/l&>Stage: -<& /Admin/Elements/SelectStage, - Name => "Scrip-$id-Stage", - Default => $ARGS{"Scrip-$id-Stage"} || $scrip->Stage, -&>
+ + + + + + + + + + + + + + + + + + +
+<&|/l&>Description: + + +
+<&|/l&>Condition: + +<& /Admin/Elements/SelectScripCondition, Name => "Scrip-$id-ScripCondition", Default => $scrip->ConditionObj->Id &>
+
+<&|/l&>Action: + +<& /Admin/Elements/SelectScripAction, Name => "Scrip-$id-ScripAction", Default => $scrip->ActionObj->Id &> +
+<&|/l&>Template: + +<& /Admin/Elements/SelectTemplate, Name => "Scrip-$id-Template", Default => $scrip->TemplateObj->Id, Queue => $Queue &> +
+<&|/l&>Stage: + +<& /Admin/Elements/SelectStage, Name => "Scrip-$id-Stage", Default => $scrip->Stage &> +
- - -<& /Elements/Submit, - Label => $SubmitLabel, - Caption => loc("Be sure to save your changes"), - Reset => 1, -&>
+<& /Elements/TitleBoxEnd &> +<& /Elements/Submit, Caption => loc("Be sure to save your changes"), Reset => 1 &> -<&| /Widgets/TitleBox, title => loc('User Defined conditions and actions') &> +
+<& /Elements/TitleBoxStart, title => loc('User Defined conditions and actions') &> - + - - - - - - - + + + + + + + + + + + + + +
+
<&|/l&>(Use these fields when you choose 'User Defined' for a condition or action) -
<&|/l&>Custom condition: - -
<&|/l&>Custom action preparation code: - -
<&|/l&>Custom action cleanup code: - -
+<&|/l&>Custom condition: + + +
+<&|/l&>Custom action preparation code: + + +
+<&|/l&>Custom action cleanup code: + + +
- +<& /Elements/TitleBoxEnd &> -<& /Elements/Submit, Label => $SubmitLabel, Reset => 1 &> +<& /Elements/Submit, Label => loc('Create'), Reset => 1 &> -
+ <%init> +my (@actions); -my (@actions, $SubmitLabel); -my $scrip = RT::Scrip->new( $session{'CurrentUser'} ); +my $scrip = new RT::Scrip($session{'CurrentUser'}); + +if ( $id eq 'new' ) { -if ( $id ) { - $scrip->Load( $id ); - unless ( $id = $scrip->id ) { - push @actions, loc("Couldn't load scrip #[_1]", $id); + my ( $retval, $msg ) = $scrip->Create( + Queue => $Queue, + ScripAction => $ARGS{"Scrip-new-ScripAction"}, + ScripCondition => $ARGS{"Scrip-new-ScripCondition"}, + Template => $ARGS{"Scrip-new-Template"}, + Description => $ARGS{"Scrip-new-Description"}, + CustomPrepareCode => $ARGS{"Scrip-new-CustomPrepareCode"}, + CustomCommitCode => $ARGS{"Scrip-new-CustomCommitCode"}, + CustomIsApplicableCode => $ARGS{"Scrip-new-CustomIsApplicableCode"}, + ); + if ( defined $retval ) { + push @actions, $msg; + $id = $scrip->id; + } + else { + Abort( $msg); + } +} +elsif ($id) { + my ($val,$msg) =$scrip->Load($id); + if ($val) { + $id = $scrip->id; + } else { + Abort ($msg); } - $SubmitLabel = loc('Update'); + my @attribs = qw ( + Queue + ScripAction + ScripCondition + Template + Stage + Description + CustomPrepareCode + CustomCommitCode + CustomIsApplicableCode + ); + my @results = UpdateRecordObject( AttributesRef => \@attribs, + AttributePrefix => 'Scrip-'.$scrip->Id, + Object => $scrip, + ARGSRef => \%ARGS ); + push (@actions, @results); } -unless ( $id ) { +elsif ($ARGS{'create'}) { $id = 'new'; - $SubmitLabel = loc('Create'); } +# }}} <%ARGS> @@ -142,42 +195,3 @@ $id => undef $title => undef $Queue => 0 - -<%METHOD Process> -<%ARGS> -$id => undef -$Queue => undef - -<%INIT> -return ($id) unless $id; - -my $scrip = RT::Scrip->new( $session{'CurrentUser'} ); -if ( $id eq 'new' ) { - return $scrip->Create( - Queue => $Queue, - ScripAction => $ARGS{"Scrip-new-ScripAction"}, - ScripCondition => $ARGS{"Scrip-new-ScripCondition"}, - Template => $ARGS{"Scrip-new-Template"}, - Description => $ARGS{"Scrip-new-Description"}, - CustomPrepareCode => $ARGS{"Scrip-new-CustomPrepareCode"}, - CustomCommitCode => $ARGS{"Scrip-new-CustomCommitCode"}, - CustomIsApplicableCode => $ARGS{"Scrip-new-CustomIsApplicableCode"}, - ); -} -else { - $scrip->Load( $id ); - return (undef, loc("Couldn't load scrip #[_1]", $id)) - unless $scrip->id; - - my @attribs = qw(Queue ScripAction ScripCondition Template Stage - Description CustomPrepareCode CustomCommitCode CustomIsApplicableCode); - my @results = UpdateRecordObject( - AttributesRef => \@attribs, - AttributePrefix => 'Scrip-'.$scrip->Id, - Object => $scrip, - ARGSRef => \%ARGS - ); - return ($scrip->id, @results); -} - -