[bugzilla-gnome-org-customizations/production] add parameters
- From: Olav Vitters <ovitters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-customizations/production] add parameters
- Date: Thu, 5 Jan 2017 19:36:38 +0000 (UTC)
commit a8cc701aa328972ce55b2439f6f6f4fc1201bf90
Author: Olav Vitters <olav vitters nl>
Date: Thu Jan 5 20:36:08 2017 +0100
add parameters
extensions/AntiSpam/Config.pm | 33 ++++++++
extensions/AntiSpam/Extension.pm | 79 ++++++++++++++++++++
extensions/AntiSpam/README | 6 ++
extensions/AntiSpam/lib/Params.pm | 58 ++++++++++++++
extensions/AntiSpam/lib/Util.pm | 34 +++++++++
.../en/default/admin/params/antispam.html.tmpl | 34 +++++++++
6 files changed, 244 insertions(+), 0 deletions(-)
---
diff --git a/extensions/AntiSpam/Config.pm b/extensions/AntiSpam/Config.pm
new file mode 100644
index 0000000..0b9652a
--- /dev/null
+++ b/extensions/AntiSpam/Config.pm
@@ -0,0 +1,33 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is the GNOME Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is Olav Vitters
+# Portions created by the Initial Developer are Copyright (C) 2011 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Olav Vitters <olav vitters nl>
+
+package Bugzilla::Extension::AntiSpam;
+use strict;
+
+use constant NAME => 'GNOME';
+
+use constant REQUIRED_MODULES => [
+];
+
+use constant OPTIONAL_MODULES => [
+];
+
+__PACKAGE__->NAME;
diff --git a/extensions/AntiSpam/Extension.pm b/extensions/AntiSpam/Extension.pm
new file mode 100644
index 0000000..2485acc
--- /dev/null
+++ b/extensions/AntiSpam/Extension.pm
@@ -0,0 +1,79 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is the GNOME Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is Olav Vitters
+# Portions created by the Initial Developer are Copyright (C) 2011 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Olav Vitters <olav vitters nl>
+
+package Bugzilla::Extension::GNOME;
+use strict;
+use base qw(Bugzilla::Extension);
+
+# This code for this is in ./extensions/GNOME/lib/Util.pm
+use Bugzilla::Extension::GNOME::Util;
+use Bugzilla::Constants;
+use Bugzilla::Field;
+use Bugzilla::Object;
+use Bugzilla::Util;
+
+our $VERSION = '0.01';
+
+sub config_add_panels {
+ my ($self, $args) = @_;
+ my $modules = $args->{'panel_modules'};
+ $modules->{'AntiSpam'} = 'Bugzilla::Extension::AntiSpam::Params';
+}
+
+sub bug_end_of_create_validators {
+ my ($self, $args) = @_;
+ my $params = $args->{params};
+ my $user = Bugzilla->user;
+
+ # Users with editbugs are excempt from AntiSpam protection
+ return if $user->in_group('editbugs');
+
+ my $short_desc = $params->{short_desc};
+
+ my @spam_strings = grep($_ !~ /^\s*$/, split(/\n+/, Bugzilla->params->{"spam-strings"}));
+ my @spam_regexps = grep($_ !~ /$\s*$/, split(/\n/, Bugzilla->params->{"spam-strings"}));
+
+ my $ispam = 0;
+
+ foreach my $spamword (@spam_strings) {
+ if (index($short_desc, $spamword) != -1) {
+ $isspam = 1;
+
+ # break out of loop
+ last;
+ }
+ }
+
+ foreach my $spamregexp (@spam_regexps) {
+ if ($short_desc =~ $spamregexp) {
+ $isspam = 1;
+ last;
+ }
+ }
+
+ return if !$isspam;
+
+ # Spam
+ $params->{alias} = "spam";
+
+};
+
+__PACKAGE__->NAME;
diff --git a/extensions/AntiSpam/README b/extensions/AntiSpam/README
new file mode 100644
index 0000000..cddc3eb
--- /dev/null
+++ b/extensions/AntiSpam/README
@@ -0,0 +1,6 @@
+
+This extensions implements everything related to GNOME Bugzilla.
+
+Recommend not to use this extension anywhere else. The functionality is really
+specific.
+
diff --git a/extensions/AntiSpam/lib/Params.pm b/extensions/AntiSpam/lib/Params.pm
new file mode 100644
index 0000000..cdde964
--- /dev/null
+++ b/extensions/AntiSpam/lib/Params.pm
@@ -0,0 +1,58 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is the Bugzilla Bug Tracking System.
+#
+# The Initial Developer of the Original Code is Netscape Communications
+# Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s): Terry Weissman <terry mozilla org>
+# Dawn Endico <endico mozilla org>
+# Dan Mosedale <dmose mozilla org>
+# Joe Robins <jmrobins tgix com>
+# Jacob Steenhagen <jake bugzilla org>
+# J. Paul Reed <preed sigkill com>
+# Bradley Baetz <bbaetz student usyd edu au>
+# Joseph Heenan <joseph heenan me uk>
+# Erik Stambaugh <erik dasbistro com>
+# Frédéric Buclin <LpSolit gmail com>
+#
+
+package Bugzilla::Extension::Antispam::Params;
+
+use strict;
+
+use Bugzilla::Config::Common;
+
+our $sortkey = 1000;
+
+sub get_param_list {
+ my ($class) = @_;
+
+ my @param_list = (
+ {
+ name => 'antispam-strings',
+ type => 'l',
+ default => ''
+ },
+ {
+ name => 'antispam-regexps',
+ type => 'l',
+ default => ''
+ },
+ );
+ return @param_list;
+};
+
+1;
diff --git a/extensions/AntiSpam/lib/Util.pm b/extensions/AntiSpam/lib/Util.pm
new file mode 100644
index 0000000..d83114c
--- /dev/null
+++ b/extensions/AntiSpam/lib/Util.pm
@@ -0,0 +1,34 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is the GNOME Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is YOUR NAME
+# Portions created by the Initial Developer are Copyright (C) 2011 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# YOUR NAME <YOUR EMAIL ADDRESS>
+
+package Bugzilla::Extension::GNOME::Util;
+use strict;
+use base qw(Exporter);
+our @EXPORT = qw(
+
+);
+
+# This file can be loaded by your extension via
+# "use Bugzilla::Extension::GNOME::Util". You can put functions
+# used by your extension in here. (Make sure you also list them in
+# @EXPORT.)
+
+1;
\ No newline at end of file
diff --git a/extensions/AntiSpam/template/en/default/admin/params/antispam.html.tmpl
b/extensions/AntiSpam/template/en/default/admin/params/antispam.html.tmpl
new file mode 100644
index 0000000..3c6eb8f
--- /dev/null
+++ b/extensions/AntiSpam/template/en/default/admin/params/antispam.html.tmpl
@@ -0,0 +1,34 @@
+[%# The contents of this file are subject to the Mozilla Public
+ # License Version 1.1 (the "License"); you may not use this file
+ # except in compliance with the License. You may obtain a copy of
+ # the License at http://www.mozilla.org/MPL/
+ #
+ # Software distributed under the License is distributed on an "AS
+ # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ # implied. See the License for the specific language governing
+ # rights and limitations under the License.
+ #
+ # The Original Code is the Bugzilla Bug Tracking System.
+ #
+ # The Initial Developer of the Original Code is Netscape Communications
+ # Corporation. Portions created by Netscape are
+ # Copyright (C) 1998 Netscape Communications Corporation. All
+ # Rights Reserved.
+ #
+ # Contributor(s): Dave Miller <justdave bugzilla org>
+ # Frédéric Buclin <LpSolit gmail com>
+ #%]
+[%
+ title = "AntiSpam"
+ desc = "Set up parameters specific to AntiSpam protection"
+%]
+
+[% param_descs = {
+
+ "antispam-strings" =>
+ "Strings (one per line) which indicate Spam. Spaces are allowed!",
+
+ "antispam-regexps" =>
+ "Regular expressions (one per line) which indicate Spam. Spaces are allowed!",
+
+} %]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]