X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fhtml%2FAdmin%2FElements%2FEditScrip;h=edf949ba3523c235b5e0410dce2314750cb64a8f;hp=907ae9a9219942f0f2c79648edf4325a7dba1760;hb=ef20b2b6b1feb47ad02b5ff7525f1a0fd11d0fa4;hpb=a513c0bef534d05f03c1242831b6f3be19b97dae diff --git a/rt/html/Admin/Elements/EditScrip b/rt/html/Admin/Elements/EditScrip index 907ae9a92..edf949ba3 100644 --- a/rt/html/Admin/Elements/EditScrip +++ b/rt/html/Admin/Elements/EditScrip @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +%# 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. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -44,150 +46,95 @@ %# %# END BPS TAGGED BLOCK }}} <& /Elements/ListActions, actions => \@actions &> - -
- - -<& /Elements/TitleBoxStart, title => loc('Scrip Fields') &> - - - - - - - - - - - - - - - - - - - - + + + + +<&| /Widgets/TitleBox, title => loc('Scrip Fields') &> +
-<&|/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 &> -
+ + + + + + + + + + +
<&|/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, +&>
-<& /Elements/TitleBoxEnd &> -<& /Elements/Submit, Caption => loc("Be sure to save your changes"), Reset => 1 &> + + +<& /Elements/Submit, + Label => $SubmitLabel, + Caption => loc("Be sure to save your changes"), + Reset => 1, +&>
-
-<& /Elements/TitleBoxStart, title => loc('User Defined conditions and actions') &> +<&| /Widgets/TitleBox, 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 => loc('Create'), Reset => 1 &> +<& /Elements/Submit, Label => $SubmitLabel, Reset => 1 &> -
+ <%init> -my (@actions); +my (@actions, $SubmitLabel); -my $scrip = new RT::Scrip($session{'CurrentUser'}); - -if ( $id eq 'new' ) { +my $scrip = RT::Scrip->new( $session{'CurrentUser'} ); - 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); +if ( $id ) { + $scrip->Load( $id ); + unless ( $id = $scrip->id ) { + push @actions, loc("Couldn't load scrip #[_1]", $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 ); - push (@actions, @results); + $SubmitLabel = loc('Update'); } -elsif ($ARGS{'create'}) { +unless ( $id ) { $id = 'new'; + $SubmitLabel = loc('Create'); } -# }}} <%ARGS> @@ -195,3 +142,42 @@ $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); +} + +