[Rt-commit] rt branch, 4.2/add-action-condition-config-ui, created. rt-4.1.6-287-g3ebac26
Jim Brandt
jbrandt at bestpractical.com
Tue Jul 2 13:45:15 EDT 2013
The branch, 4.2/add-action-condition-config-ui has been created
at 3ebac268b31d4201776f805681192a685643ec6b (commit)
- Log -----------------------------------------------------------------
commit 297c25ee8350faf465881267237a44ea66c7e7b9
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Mon Mar 4 08:55:33 2013 -0500
First cut at conditions ui
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 42a812d..52f88e8 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2632,6 +2632,10 @@ Set(%AdminSearchResultFormat,
q{'<a href="__WebPath__/__WebRequestPathDir__/Template.html?Queue=__QueueId__&Template=__id__">__id__</a>/TITLE:#'}
.q{,'<a href="__WebPath__/__WebRequestPathDir__/Template.html?Queue=__QueueId__&Template=__id__">__Name__</a>/TITLE:Name'}
.q{,'__Description__','__UsedBy__','__IsEmpty__'},
+ Conditions =>
+ q{'<a href="__WebPath__/Admin/Conditions/Modify.html?&id=__id__">__id__</a>/TITLE:#'}
+ .q{,'<a href="__WebPath__/Admin/Conditions/Modify.html?id=__id__">__Name__</a>/TITLE:Name'}
+ .q{,'__Description__'},
Classes =>
q{ '<a href="__WebPath__/Admin/Articles/Classes/Modify.html?id=__id__">__id__</a>/TITLE:#'}
.q{,'<a href="__WebPath__/Admin/Articles/Classes/Modify.html?id=__id__">__Name__</a>/TITLE:Name'}
diff --git a/share/html/Admin/Conditions/Modify.html b/share/html/Admin/Conditions/Modify.html
new file mode 100644
index 0000000..b1d1e98
--- /dev/null
+++ b/share/html/Admin/Conditions/Modify.html
@@ -0,0 +1,110 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# 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/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<& /Admin/Elements/Header, Title => loc("Modify scrip #[_1]", $id) &>
+<& /Elements/Tabs &>
+<& /Elements/ListActions, actions => \@results &>
+
+<form method="post" action="Modify.html" id="ModifyCondition" name="ModifyCondition">
+<input type="hidden" class="hidden" name="id" value="<% $id %>" />
+
+<&| /Widgets/TitleBox, title => loc('Basics') &>
+<table>
+<tr><td class="label"><&|/l&>Name</&>:</td>
+<td class="value"><input name="Name" value="<%$condition->Name||''%>" size="20" /></td>
+</tr>
+<tr>
+<td class="label"><&|/l&>Description</&>:</td>
+<td class="value"><input name="Description" value="<%$condition->Description||''%>" size="80" /></td>
+</tr>
+<tr>
+<td class="label"><&|/l&>Condition Module</&>:</td>
+<td class="value"><input name="ExecModule" value="<%$condition->ExecModule||''%>" size="60" /></td>
+</tr>
+<tr>
+<td class="label"><&|/l&>Parameters to Pass</&>:</td>
+<td class="value"><input name="Argument" value="<%$condition->Argument||''%>" size="60" /></td>
+</tr>
+<tr>
+<td class="label"><&|/l&>Applicable Transaction Types</&>:</td>
+<td class="value"><input name="ApplicableTransTypes" value="<%$condition->ApplicableTransTypes||''%>" size="60" /></td>
+</tr>
+</table>
+</&>
+<& /Elements/Submit, Label => loc('Save Changes'), Name => 'Update', Reset => 1 &>
+
+</form>
+<%ARGS>
+$id => undef
+$Update => undef
+</%ARGS>
+<%INIT>
+my $condition = RT::ScripCondition->new( $session{'CurrentUser'} );
+$condition->Load( $id );
+$m->abort(loc("Couldn't load condition #[_1]", $id))
+ unless $condition->id;
+
+$m->abort unless ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ExecuteCode'));
+
+my @results;
+if ( $Update ) {
+ my @attribs = qw(
+ Name Description
+ ExecModule Argument ApplicableTransTypes
+ );
+ @results = UpdateRecordObject(
+ AttributesRef => \@attribs,
+ Object => $condition,
+ ARGSRef => \%ARGS
+ );
+ MaybeRedirectForResults(
+ Actions => \@results,
+ Arguments => { id => $condition->id },
+ );
+}
+
+</%INIT>
diff --git a/share/html/Admin/Elements/EditConditions b/share/html/Admin/Elements/EditConditions
new file mode 100644
index 0000000..3181b39
--- /dev/null
+++ b/share/html/Admin/Elements/EditConditions
@@ -0,0 +1,156 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# 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/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<& /Elements/ListActions, actions => \@actions &>
+
+<form action="Conditions.html" method="post">
+
+<h2><&|/l&>Conditions</&></h2>
+<div class="admin-hint"></div>
+% my $conditions = $find_conditions->();
+<& /Elements/CollectionList, %common_applied_args, Collection => $conditions &>
+% unless ( $conditions->Count ) {
+<p><i><&|/l&>(No conditions)</&></i></p>
+% }
+
+<& /Elements/Submit,
+ Name => 'RemoveConditions',
+ Caption => loc("Delete selected conditions"),
+ Label => loc("Update"),
+&>
+
+</form>
+
+<%init>
+my (@actions);
+
+$id ||= 0;
+
+my $find_conditions = sub {
+ my %args = (Added => 1, @_);
+ my $conditions = RT::ScripConditions->new($session{'CurrentUser'});
+ $conditions->OrderBy( FIELD => 'Name' );
+ $conditions->UnLimit;
+ $conditions->FindAllRows;
+ return $conditions;
+};
+
+$Format ||= RT->Config->Get('AdminSearchResultFormat')->{'Conditions'};
+my $DisplayFormat = $Format;
+if ( $id ) {
+ $DisplayFormat = "__RemoveCheckBox__, $DisplayFormat";
+} else {
+ $DisplayFormat = "__CheckBox.{RemoveScrip}__, $DisplayFormat";
+}
+
+my %common_applied_args = (
+ %ARGS,
+ Format => $Format,
+ DisplayFormat => $DisplayFormat,
+ Rows => 0,
+ Page => 1,
+ AllowSorting => 1,
+ PassArguments => [ qw(Format id) ],
+);
+
+# if ( $RemoveScrips ) {
+# foreach my $sid ( @RemoveScrip ) {
+# my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
+# $scrip->Load( $sid );
+# next unless $scrip->id;
+
+# my ($status, $msg) = $scrip->RemoveFromObject( $id );
+# push @actions, $msg;
+# }
+# }
+
+# if ( $AddScrips ) {
+# foreach my $sid ( @AddScrip ) {
+# my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
+# $scrip->Load( $sid );
+# next unless $scrip->id;
+
+# my ($status, $msg) = $scrip->AddToObject( $id, Stage => $Stage );
+# push @actions, $msg;
+# }
+# }
+
+# if ( $MoveScripUp ) {
+# my $scrip = RT::ObjectScrip->new( $session{'CurrentUser'} );
+# $scrip->LoadByCols( Scrip => $MoveScripUp, ObjectId => $id );
+# if ( $scrip->id ) {
+# my ($status, $msg) = $scrip->MoveUp;
+# push @actions, $msg;
+# }
+# }
+
+# if ( $MoveScripDown ) {
+# my $scrip = RT::ObjectScrip->new( $session{'CurrentUser'} );
+# $scrip->LoadByCols( Scrip => $MoveScripDown, ObjectId => $id );
+# if ( $scrip->id ) {
+# my ($status, $msg) = $scrip->MoveDown;
+# push @actions, $msg;
+# }
+# }
+
+</%init>
+
+<%ARGS>
+$id => undef
+$title => undef
+$Format => undef
+
+ at RemoveCondition => ()
+$RemoveConditions => undef
+
+ at AddCondition => ()
+$AddConditions => undef
+
+$MoveConditionUp => undef
+$MoveConditionDown => undef
+
+</%ARGS>
diff --git a/share/html/Admin/Global/Conditions.html b/share/html/Admin/Global/Conditions.html
new file mode 100644
index 0000000..dfad175
--- /dev/null
+++ b/share/html/Admin/Global/Conditions.html
@@ -0,0 +1,58 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# 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/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<& /Admin/Elements/Header, Title => $title &>
+<& /Elements/Tabs &>
+<& /Admin/Elements/EditConditions, title => $title, id => $id, %ARGS &>
+</form>
+<%init>
+my $title = loc("Modify conditions which apply to all queues");
+my (@actions);
+</%init>
+<%ARGS>
+$id => 0
+</%ARGS>
diff --git a/share/html/Elements/RT__ScripCondition/ColumnMap b/share/html/Elements/RT__ScripCondition/ColumnMap
new file mode 100644
index 0000000..cfa2ab8
--- /dev/null
+++ b/share/html/Elements/RT__ScripCondition/ColumnMap
@@ -0,0 +1,77 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# 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/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%ARGS>
+$Name
+$Attr => undef
+$GenericMap => {}
+</%ARGS>
+<%ONCE>
+my $COLUMN_MAP = {
+ id => {
+ title => '#', # loc
+ attribute => 'id',
+ align => 'right',
+ value => sub { return $_[0]->id },
+ },
+ Name => {
+ title => 'Name', # loc
+ attribute => 'Name',
+ value => sub { return $_[0]->Name() },
+ },
+ Description => {
+ title => 'Description', # loc
+ attribute => 'Description',
+ value => sub { return $_[0]->Description() },
+ },
+};
+
+</%ONCE>
+<%INIT>
+$m->callback( GenericMap => $GenericMap, COLUMN_MAP => $COLUMN_MAP, CallbackName => 'ColumnMap', CallbackOnce => 1 );
+return GetColumnMapEntry( Map => $COLUMN_MAP, Name => $Name, Attribute => $Attr );
+</%INIT>
commit 3ebac268b31d4201776f805681192a685643ec6b
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Fri Mar 22 15:50:32 2013 -0400
Initial attempts
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 52f88e8..5638673 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2635,7 +2635,7 @@ Set(%AdminSearchResultFormat,
Conditions =>
q{'<a href="__WebPath__/Admin/Conditions/Modify.html?&id=__id__">__id__</a>/TITLE:#'}
.q{,'<a href="__WebPath__/Admin/Conditions/Modify.html?id=__id__">__Name__</a>/TITLE:Name'}
- .q{,'__Description__'},
+ .q{,'__Description__','__UsedBy__},
Classes =>
q{ '<a href="__WebPath__/Admin/Articles/Classes/Modify.html?id=__id__">__id__</a>/TITLE:#'}
.q{,'<a href="__WebPath__/Admin/Articles/Classes/Modify.html?id=__id__">__Name__</a>/TITLE:Name'}
diff --git a/lib/RT/ScripCondition.pm b/lib/RT/ScripCondition.pm
index e9f5daa..c7eb3cd 100644
--- a/lib/RT/ScripCondition.pm
+++ b/lib/RT/ScripCondition.pm
@@ -115,7 +115,30 @@ No API available for deleting things just yet.
sub Delete {
my $self = shift;
- return(0, $self->loc('Unimplemented'));
+
+ unless ( $self->CurrentUser->HasRight(Object => $RT::System, Right => 'ModifyScrips') ) {
+ return ( 0, $self->loc('Permission Denied') );
+ }
+
+ if ( $self->UsedBy->Count ) {
+ return ( 0, $self->loc('Condition is in use') );
+ }
+
+ return ( $self->SUPER::Delete(@_) );
+}
+
+=head2 UsedBy
+
+Returns L<RT::Scrips> limited to scrips that use this condition.
+
+=cut
+
+sub UsedBy {
+ my $self = shift;
+
+ my $scrips = RT::Scrips->new( $self->CurrentUser );
+ $scrips->LimitByCondition( $self );
+ return $scrips;
}
diff --git a/lib/RT/Scrips.pm b/lib/RT/Scrips.pm
index 007d7fe..77c7777 100644
--- a/lib/RT/Scrips.pm
+++ b/lib/RT/Scrips.pm
@@ -226,6 +226,20 @@ sub LimitByTemplate {
}
}
+=head2 LimitByCondition
+
+Takes a L<RT::ScripCondition> object and limits scrips to those that
+use the condition.
+
+=cut
+
+sub LimitByCondition {
+ my $self = shift;
+ my $condition = shift;
+
+ $self->Limit( FIELD => 'ScripCondition', VALUE => $condition->Id );
+}
+
sub ApplySortOrder {
my $self = shift;
my $order = shift || 'ASC';
diff --git a/share/html/Elements/RT__ScripCondition/ColumnMap b/share/html/Admin/Conditions/Create.html
similarity index 61%
copy from share/html/Elements/RT__ScripCondition/ColumnMap
copy to share/html/Admin/Conditions/Create.html
index cfa2ab8..190695b 100644
--- a/share/html/Elements/RT__ScripCondition/ColumnMap
+++ b/share/html/Admin/Conditions/Create.html
@@ -45,33 +45,52 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
+<& /Admin/Elements/Header, Title => "Create a global condition" &>
+<& /Elements/Tabs &>
+<& /Elements/ListActions, actions => \@results &>
+
+<form method="post" action="Create.html" id="CreateCondition" name="CreateCondition">
+
+<&| /Widgets/TitleBox, title => loc('Basics') &>
+<table>
+<& Elements/EditBasics, %ARGS, Condition => $condition, &>
+</table>
+</&>
+
+<& /Elements/Submit,
+ Label => loc('Create'),
+ Name => 'Create',
+&>
+
+</form>
<%ARGS>
-$Name
-$Attr => undef
-$GenericMap => {}
+$Create => undef
</%ARGS>
-<%ONCE>
-my $COLUMN_MAP = {
- id => {
- title => '#', # loc
- attribute => 'id',
- align => 'right',
- value => sub { return $_[0]->id },
- },
- Name => {
- title => 'Name', # loc
- attribute => 'Name',
- value => sub { return $_[0]->Name() },
- },
- Description => {
- title => 'Description', # loc
- attribute => 'Description',
- value => sub { return $_[0]->Description() },
- },
-};
-
-</%ONCE>
<%INIT>
-$m->callback( GenericMap => $GenericMap, COLUMN_MAP => $COLUMN_MAP, CallbackName => 'ColumnMap', CallbackOnce => 1 );
-return GetColumnMapEntry( Map => $COLUMN_MAP, Name => $Name, Attribute => $Attr );
+my @results;
+
+unless ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ModifyScrips')) {
+ $m->abort(loc('You must have the ModifyScrips right to work with conditions.'));
+}
+
+my $condition = RT::ScripCondition->new( $session{'CurrentUser'} );
+if ( $Create ) {
+ my ($status, $msg) = $condition->Create(
+ Name => $ARGS{"Name"},
+ Description => $ARGS{"Description"},
+ ExecModule => $ARGS{"ExecModule"},
+ Argument => $ARGS{"Argument"},
+ ApplicableTransTypes => $ARGS{"ApplicableTransTypes"},
+ );
+
+ MaybeRedirectForResults(
+ Force => 1,
+ Actions => [ $msg ],
+ Path => 'Admin/Conditions/Modify.html',
+ Arguments => { id => $condition->id },
+ ) if $status;
+
+ push @results, $msg;
+}
+
</%INIT>
diff --git a/share/html/Elements/RT__ScripCondition/ColumnMap b/share/html/Admin/Conditions/Elements/EditBasics
similarity index 67%
copy from share/html/Elements/RT__ScripCondition/ColumnMap
copy to share/html/Admin/Conditions/Elements/EditBasics
index cfa2ab8..79b9326 100644
--- a/share/html/Elements/RT__ScripCondition/ColumnMap
+++ b/share/html/Admin/Conditions/Elements/EditBasics
@@ -45,33 +45,38 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
+<tr><td class="label"><&|/l&>Name</&>:</td><td class="value">
+<input name="Name"
+ size="60"
+ value="<% $ARGS{"Name"} || $Condition->Name || '' %>" />
+</td></tr>
+
+<tr><td class="label"><&|/l&>Description</&>:</td><td class="value">
+<input name="Description"
+ size="60"
+ value="<% $ARGS{"Description"} || $Condition->Description || '' %>" />
+</td></tr>
+
+<tr><td class="label"><&|/l&>Condition Module</&>:</td><td class="value">
+<input name="ExecModule"
+ size="60"
+ value="<% $ARGS{"ExecModule"} || $Condition->ExecModule || ''%>" />
+</td></tr>
+<tr>
+<td class="label"><&|/l&>Parameters to Pass</&>:</td><td class="value">
+<input name="Argument"
+ size="60"
+ value="<% $ARGS{"Argument"} || $Condition->Argument || '' %>"/>
+</td></tr>
+<tr>
+<td class="label"><&|/l&>Applicable Transaction Types</&>:</td><td class="value">
+<input name="ApplicableTransTypes"
+ size="60"
+ value="<% $ARGS{"ApplicableTransTypes"} || $Condition->ApplicableTransTypes || '' %>" />
+</td></tr>
+
<%ARGS>
-$Name
-$Attr => undef
-$GenericMap => {}
+$Condition
</%ARGS>
-<%ONCE>
-my $COLUMN_MAP = {
- id => {
- title => '#', # loc
- attribute => 'id',
- align => 'right',
- value => sub { return $_[0]->id },
- },
- Name => {
- title => 'Name', # loc
- attribute => 'Name',
- value => sub { return $_[0]->Name() },
- },
- Description => {
- title => 'Description', # loc
- attribute => 'Description',
- value => sub { return $_[0]->Description() },
- },
-};
-
-</%ONCE>
<%INIT>
-$m->callback( GenericMap => $GenericMap, COLUMN_MAP => $COLUMN_MAP, CallbackName => 'ColumnMap', CallbackOnce => 1 );
-return GetColumnMapEntry( Map => $COLUMN_MAP, Name => $Name, Attribute => $Attr );
</%INIT>
diff --git a/share/html/Admin/Conditions/Modify.html b/share/html/Admin/Conditions/Modify.html
index b1d1e98..d16ce14 100644
--- a/share/html/Admin/Conditions/Modify.html
+++ b/share/html/Admin/Conditions/Modify.html
@@ -54,25 +54,7 @@
<&| /Widgets/TitleBox, title => loc('Basics') &>
<table>
-<tr><td class="label"><&|/l&>Name</&>:</td>
-<td class="value"><input name="Name" value="<%$condition->Name||''%>" size="20" /></td>
-</tr>
-<tr>
-<td class="label"><&|/l&>Description</&>:</td>
-<td class="value"><input name="Description" value="<%$condition->Description||''%>" size="80" /></td>
-</tr>
-<tr>
-<td class="label"><&|/l&>Condition Module</&>:</td>
-<td class="value"><input name="ExecModule" value="<%$condition->ExecModule||''%>" size="60" /></td>
-</tr>
-<tr>
-<td class="label"><&|/l&>Parameters to Pass</&>:</td>
-<td class="value"><input name="Argument" value="<%$condition->Argument||''%>" size="60" /></td>
-</tr>
-<tr>
-<td class="label"><&|/l&>Applicable Transaction Types</&>:</td>
-<td class="value"><input name="ApplicableTransTypes" value="<%$condition->ApplicableTransTypes||''%>" size="60" /></td>
-</tr>
+<& Elements/EditBasics, %ARGS, Condition => $condition, &>
</table>
</&>
<& /Elements/Submit, Label => loc('Save Changes'), Name => 'Update', Reset => 1 &>
@@ -83,13 +65,15 @@ $id => undef
$Update => undef
</%ARGS>
<%INIT>
+unless ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ModifyScrips')) {
+ $m->abort(loc('You must have the ModifyScrips right to work with conditions.'));
+}
+
my $condition = RT::ScripCondition->new( $session{'CurrentUser'} );
$condition->Load( $id );
$m->abort(loc("Couldn't load condition #[_1]", $id))
unless $condition->id;
-$m->abort unless ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ExecuteCode'));
-
my @results;
if ( $Update ) {
my @attribs = qw(
diff --git a/share/html/Admin/Elements/EditConditions b/share/html/Admin/Elements/EditConditions
index 3181b39..fce7cfa 100644
--- a/share/html/Admin/Elements/EditConditions
+++ b/share/html/Admin/Elements/EditConditions
@@ -51,10 +51,10 @@
<h2><&|/l&>Conditions</&></h2>
<div class="admin-hint"></div>
-% my $conditions = $find_conditions->();
+% if ( $conditions->Count ){
<& /Elements/CollectionList, %common_applied_args, Collection => $conditions &>
-% unless ( $conditions->Count ) {
-<p><i><&|/l&>(No conditions)</&></i></p>
+% } else {
+<p><i><&|/l&>Click Create to add a new custom condition.</&></i></p>
% }
<& /Elements/Submit,
@@ -66,25 +66,23 @@
</form>
<%init>
-my (@actions);
+unless ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ModifyScrips')) {
+ $m->abort(loc('You must have the ModifyScrips right to work with conditions.'));
+}
+my (@actions);
$id ||= 0;
-my $find_conditions = sub {
- my %args = (Added => 1, @_);
- my $conditions = RT::ScripConditions->new($session{'CurrentUser'});
- $conditions->OrderBy( FIELD => 'Name' );
- $conditions->UnLimit;
- $conditions->FindAllRows;
- return $conditions;
-};
+my $conditions = RT::ScripConditions->new($session{'CurrentUser'});
+$conditions->OrderBy( FIELD => 'Name' );
+$conditions->Limit( FIELD => 'Creator', OPERATOR => '!=', VALUE => RT->SystemUser->Id,);
$Format ||= RT->Config->Get('AdminSearchResultFormat')->{'Conditions'};
my $DisplayFormat = $Format;
if ( $id ) {
$DisplayFormat = "__RemoveCheckBox__, $DisplayFormat";
} else {
- $DisplayFormat = "__CheckBox.{RemoveScrip}__, $DisplayFormat";
+ $DisplayFormat = "__CheckBox.{RemoveCondition}__, $DisplayFormat";
}
my %common_applied_args = (
@@ -97,45 +95,16 @@ my %common_applied_args = (
PassArguments => [ qw(Format id) ],
);
-# if ( $RemoveScrips ) {
-# foreach my $sid ( @RemoveScrip ) {
-# my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
-# $scrip->Load( $sid );
-# next unless $scrip->id;
-
-# my ($status, $msg) = $scrip->RemoveFromObject( $id );
-# push @actions, $msg;
-# }
-# }
-
-# if ( $AddScrips ) {
-# foreach my $sid ( @AddScrip ) {
-# my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
-# $scrip->Load( $sid );
-# next unless $scrip->id;
-
-# my ($status, $msg) = $scrip->AddToObject( $id, Stage => $Stage );
-# push @actions, $msg;
-# }
-# }
+if ( $RemoveConditions ) {
+ foreach my $cid ( @RemoveCondition ) {
+ my $condition = RT::ScripCondition->new( $session{'CurrentUser'} );
+ $condition->Load( $cid );
+ next unless $condition->Id;
-# if ( $MoveScripUp ) {
-# my $scrip = RT::ObjectScrip->new( $session{'CurrentUser'} );
-# $scrip->LoadByCols( Scrip => $MoveScripUp, ObjectId => $id );
-# if ( $scrip->id ) {
-# my ($status, $msg) = $scrip->MoveUp;
-# push @actions, $msg;
-# }
-# }
-
-# if ( $MoveScripDown ) {
-# my $scrip = RT::ObjectScrip->new( $session{'CurrentUser'} );
-# $scrip->LoadByCols( Scrip => $MoveScripDown, ObjectId => $id );
-# if ( $scrip->id ) {
-# my ($status, $msg) = $scrip->MoveDown;
-# push @actions, $msg;
-# }
-# }
+ my ($status, $msg) = $condition->Delete( $id );
+ push @actions, $msg;
+ }
+}
</%init>
@@ -143,14 +112,6 @@ my %common_applied_args = (
$id => undef
$title => undef
$Format => undef
-
@RemoveCondition => ()
$RemoveConditions => undef
-
- at AddCondition => ()
-$AddConditions => undef
-
-$MoveConditionUp => undef
-$MoveConditionDown => undef
-
</%ARGS>
diff --git a/share/html/Elements/RT__ScripCondition/ColumnMap b/share/html/Elements/RT__ScripCondition/ColumnMap
index cfa2ab8..17188b5 100644
--- a/share/html/Elements/RT__ScripCondition/ColumnMap
+++ b/share/html/Elements/RT__ScripCondition/ColumnMap
@@ -68,6 +68,20 @@ my $COLUMN_MAP = {
attribute => 'Description',
value => sub { return $_[0]->Description() },
},
+ UsedBy => {
+ title => 'Used by scrips', # loc
+ value => sub {
+ my @res;
+ my $scrips = $_[0]->UsedBy;
+ while ( my $scrip = $scrips->Next ) {
+ push @res, ', ' if @res;
+ push @res, \'<a href="', RT->Config->Get('WebPath'), '/Admin/Scrips/Modify.html';
+ push @res, '?id='. $scrip->id;
+ push @res, \'" title="', $scrip->Description, \'">', $scrip->id, \'</a>';
+ }
+ return @res;
+ },
+ },
};
</%ONCE>
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 14536ae..1a08246 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -129,6 +129,16 @@ my $build_admin_menu = sub {
$templates->child( select => title => loc('Select'), path => "/Admin/Global/Templates.html" );
$templates->child( create => title => loc('Create'), path => "/Admin/Global/Template.html?Create=1" );
+ if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'ModifyScrips' ) ) {
+ my $conditions = $admin_global->child( conditions =>
+ title => loc('Conditions'),
+ description => loc('Edit system conditions'),
+ path => '/Admin/Global/Conditions.html',
+ );
+ $conditions->child( select => title => loc('Select'), path => "/Admin/Global/Conditions.html" );
+ $conditions->child( create => title => loc('Create'), path => "/Admin/Conditions/Create.html" );
+ }
+
my $cfadmin = $admin_global->child( 'custom-fields' =>
title => loc('Custom Fields'),
description => loc('Modify global custom fields'),
@@ -409,6 +419,14 @@ my $build_admin_menu = sub {
$tabs->child( create => title => loc('Create'), path => "/Admin/Global/Template.html?Create=1" );
}
+ if ( $request_path =~ m{^/Admin/Global/Conditions\.html}
+ or $request_path =~ m{^/Admin/Conditions/Modify\.html}
+ or $request_path =~ m{^/Admin/Conditions/Create\.html} ) {
+ my $tabs = PageMenu();
+ $tabs->child( select => title => loc('Select'), path => "/Admin/Global/Conditions.html" );
+ $tabs->child( create => title => loc('Create'), path => "/Admin/Conditions/Create.html" );
+ }
+
if ( $request_path =~ m{^/Admin/Articles/Classes/} ) {
my $tabs = PageMenu();
if ( my $id = $DECODED_ARGS->{'id'} ) {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list