[Rt-commit] rt branch, 4.4/create-via-interface-condition, created. rt-4.4.3-61-gfac9e840c

? sunnavy sunnavy at bestpractical.com
Fri Oct 19 16:29:52 EDT 2018


The branch, 4.4/create-via-interface-condition has been created
        at  fac9e840c6cbb382ec8ceb7c28eec1f8cef505ab (commit)

- Log -----------------------------------------------------------------
commit fac9e840c6cbb382ec8ceb7c28eec1f8cef505ab
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 20 03:59:49 2018 +0800

    Adds "Create Via Email" and "Create Via Web" conditions

diff --git a/etc/initialdata b/etc/initialdata
index e65066185..454f76336 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -133,6 +133,19 @@
       ApplicableTransTypes => 'Create',
       ExecModule           => 'AnyTransaction', },
 
+    {
+        Name                 => 'On Create Via Email',
+        Description          => 'When a ticket is created via Email',
+        ApplicableTransTypes => 'Create',
+        Argument             => 'Email',
+        ExecModule           => 'ViaInterface', },
+    {
+        Name                 => 'On Create Via Web',
+        Description          => 'When a ticket is created via Web',
+        ApplicableTransTypes => 'Create',
+        Argument             => 'Web,Mobile',
+        ExecModule           => 'ViaInterface', },
+
     { Name                 => 'On Transaction',                           # loc
       Description          => 'When anything happens',                    # loc
       ApplicableTransTypes => 'Any',
diff --git a/etc/upgrade/4.4.5/content b/etc/upgrade/4.4.5/content
new file mode 100644
index 000000000..295c21b78
--- /dev/null
+++ b/etc/upgrade/4.4.5/content
@@ -0,0 +1,19 @@
+use warnings;
+use strict;
+
+our @ScripConditions = (
+    {
+        Name                 => 'On Create Via Email',
+        Description          => 'When a ticket is created via Email',
+        ApplicableTransTypes => 'Create',
+        Argument             => 'Email',
+        ExecModule           => 'ViaInterface',
+    },
+    {
+        Name                 => 'On Create Via Web',
+        Description          => 'When a ticket is created via Web',
+        ApplicableTransTypes => 'Create',
+        Argument             => 'Web,Mobile',
+        ExecModule           => 'ViaInterface',
+    },
+);
diff --git a/lib/RT/Condition/ViaInterface.pm b/lib/RT/Condition/ViaInterface.pm
new file mode 100644
index 000000000..33bf5e87c
--- /dev/null
+++ b/lib/RT/Condition/ViaInterface.pm
@@ -0,0 +1,78 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2018 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 }}}
+
+package RT::Condition::ViaInterface;
+use base 'RT::Condition';
+
+use strict;
+use warnings;
+
+
+=head2 IsApplicable
+
+If the transaction is created via a specified interface.
+
+=cut
+
+sub IsApplicable {
+    my $self = shift;
+
+    return 0 unless $self->Argument;
+    my @interfaces = split /,/, $self->Argument;
+
+    if (my $msg = $self->TransactionObj->Message->First) {
+        my $interface = $msg->GetHeader('X-RT-Interface');
+        return 0 unless $interface;
+        return 1 if grep { lc $interface eq lc $_ } @interfaces;
+    }
+    return 0;
+}
+
+RT::Base->_ImportOverlays();
+
+1;

-----------------------------------------------------------------------


More information about the rt-commit mailing list