blob: 3b9ab802cbfff36bd61a64419c63826debe1dad4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
package Bugzilla::Extension::ExternalBugs::Regex;
use strict;
use warnings;
use 5.10.1;
use base qw(Bugzilla::Object);
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Util qw(diff_arrays trick_taint);
use File::Basename;
use constant DB_COLUMNS => qw(
id
name
regex
description
);
use constant DB_TABLE => 'ext_bz_regex';
use constant LIST_ORDER => 'name';
use constant ID_FIELD => 'id';
use constant REQUIRED_CREATE_FIELDS => qw(
name
regex
description
);
use constant UPDATE_COLUMNS => qw(
name
regex
description
);
use constant VALIDATORS => {
name => \&_check_name,
regex => \&_check_regex,
description => \&_check_description,
};
###############################
#### Constructors #####
###############################
sub new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $param = shift;
my $self = $class->SUPER::new($param);
return $self;
}
sub set_name { $_[0]->set('name', $_[1]); return; }
sub set_regex { $_[0]->set('regex', $_[1]); return; }
sub set_description { $_[0]->set('description', $_[1]); return; }
###############################
#### Accessors ######
###############################
sub id { return $_[0]->{'id'}; }
sub name { return $_[0]->{'name'}; }
sub regex { return $_[0]->{'regex'}; }
sub description { return $_[0]->{'description'}; }
###############################
#### Validators ####
###############################
sub _check_name {
my ($invocant, $name) = @_;
if (!defined $name || $name eq '') {
ThrowUserError("ext_bz_require_name");
}
return $name;
}
sub _check_regex {
my ($invocant, $regex) = @_;
if (!defined $regex || $regex eq 'regex') {
ThrowUserError("ext_bz_require_regex");
}
return $regex;
}
sub _check_description {
my ($invocant, $description) = @_;
if (!defined $description || $description eq '') {
ThrowUserError("ext_bz_require_description");
}
return $description;
}
1;
__END__
|