1# This Source Code Form is subject to the terms of the Mozilla Public
2# License, v. 2.0. If a copy of the MPL was not distributed with this
3# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4#
5# This Source Code Form is "Incompatible With Secondary Licenses", as
6# defined by the Mozilla Public License, v. 2.0.
7
8package Bugzilla::Whine;
9
10use 5.10.1;
11use strict;
12use warnings;
13
14use parent qw(Bugzilla::Object);
15
16use Bugzilla::Constants;
17use Bugzilla::Error;
18use Bugzilla::User;
19use Bugzilla::Util;
20use Bugzilla::Whine::Schedule;
21use Bugzilla::Whine::Query;
22
23#############
24# Constants #
25#############
26
27use constant DB_TABLE => 'whine_events';
28
29use constant DB_COLUMNS => qw(
30    id
31    owner_userid
32    subject
33    body
34    mailifnobugs
35);
36
37use constant LIST_ORDER => 'id';
38
39####################
40# Simple Accessors #
41####################
42sub subject         { return $_[0]->{'subject'};      }
43sub body            { return $_[0]->{'body'};         }
44sub mail_if_no_bugs { return $_[0]->{'mailifnobugs'}; }
45
46sub user {
47    my ($self) = @_;
48    return $self->{user} if defined $self->{user};
49    $self->{user} = new Bugzilla::User($self->{'owner_userid'});
50    return $self->{user};
51}
52
531;
54
55__END__
56
57=head1 NAME
58
59Bugzilla::Whine - A Whine event
60
61=head1 SYNOPSIS
62
63 use Bugzilla::Whine;
64
65 my $event = new Bugzilla::Whine($event_id);
66
67 my $subject      = $event->subject;
68 my $body         = $event->body;
69 my $mailifnobugs = $event->mail_if_no_bugs;
70 my $user         = $event->user;
71
72=head1 DESCRIPTION
73
74This module exists to represent a whine event that has been
75saved to the database.
76
77This is an implementation of L<Bugzilla::Object>, and so has all the
78same methods available as L<Bugzilla::Object>, in addition to what is
79documented below.
80
81=head1 METHODS
82
83=head2 Constructors
84
85=over
86
87=item C<new>
88
89Does not accept a bare C<name> argument. Instead, accepts only an id.
90
91See also: L<Bugzilla::Object/new>.
92
93=back
94
95
96=head2 Accessors
97
98These return data about the object, without modifying the object.
99
100=over
101
102=item C<subject>
103
104Returns the subject of the whine event.
105
106=item C<body>
107
108Returns the body of the whine event.
109
110=item C<mail_if_no_bugs>
111
112Returns a numeric 1(C<true>) or 0(C<false>) to represent whether this
113whine event object is supposed to be mailed even if there are no bugs
114returned by the query.
115
116=item C<user>
117
118Returns the L<Bugzilla::User> object for the owner of the L<Bugzilla::Whine>
119event.
120
121=back
122