Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
4e7c28de
Commit
4e7c28de
authored
Jul 05, 2010
by
Eric Black
Committed by
Max Kanat-Alexander
Jul 05, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 530468: Create a read-only Bugzilla::Whine object for whine events and
have editwhines.cgi use it r=mkanat, a=mkanat
parent
a0a2aa90
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
143 additions
and
24 deletions
+143
-24
Whine.pm
Bugzilla/Whine.pm
+132
-0
editwhines.cgi
editwhines.cgi
+11
-24
No files found.
Bugzilla/Whine.pm
0 → 100644
View file @
4e7c28de
# -*- 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 Eric Black.
# Portions created by the Initial Developer are Copyright (C) 2010
# Eric Black. All Rights Reserved.
#
# Contributor(s): Eric Black <black.eric@gmail.com>
use
strict
;
package
Bugzilla::
Whine
;
use
base
qw(Bugzilla::Object)
;
use
Bugzilla::
Constants
;
use
Bugzilla::
Error
;
use
Bugzilla::
User
;
use
Bugzilla::
Util
;
use
Bugzilla::Whine::
Schedule
;
use
Bugzilla::Whine::
Query
;
#############
# Constants #
#############
use
constant
DB_TABLE
=>
'whine_events'
;
use
constant
DB_COLUMNS
=>
qw(
id
owner_userid
subject
body
mailifnobugs
)
;
use
constant
LIST_ORDER
=>
'id'
;
####################
# Simple Accessors #
####################
sub
subject
{
return
$_
[
0
]
->
{
'subject'
};
}
sub
body
{
return
$_
[
0
]
->
{
'body'
};
}
sub
mail_if_no_bugs
{
return
$_
[
0
]
->
{
'mailifnobugs'
};
}
sub
user
{
my
(
$self
)
=
@_
;
return
$self
->
{
user
}
if
defined
$self
->
{
user
};
$self
->
{
user
}
=
new
Bugzilla::
User
(
$self
->
{
'owner_userid'
});
return
$self
->
{
user
};
}
1
;
__END__
=head1 NAME
Bugzilla::Whine - A Whine event
=head1 SYNOPSIS
use Bugzilla::Whine;
my $event = new Bugzilla::Whine($event_id);
my $subject = $event->subject;
my $body = $event->body;
my $mailifnobugs = $event->mail_if_no_bugs;
my $user = $event->user;
=head1 DESCRIPTION
This module exists to represent a whine event that has been
saved to the database.
This is an implementation of L<Bugzilla::Object>, and so has all the
same methods available as L<Bugzilla::Object>, in addition to what is
documented below.
=head1 METHODS
=head2 Constructors
=over
=item C<new>
Does not accept a bare C<name> argument. Instead, accepts only an id.
See also: L<Bugzilla::Object/new>.
=back
=head2 Accessors
These return data about the object, without modifying the object.
=over
=item C<subject>
Returns the subject of the whine event.
=item C<body>
Returns the body of the whine event.
=item C<mail_if_no_bugs>
Returns a numeric 1(C<true>) or 0(C<false>) to represent whether this
whine event object is supposed to be mailed even if there are no bugs
returned by the query.
=item C<user>
Returns the L<Bugzilla::User> object for the owner of the L<Bugzilla::Whine>
event.
=back
editwhines.cgi
View file @
4e7c28de
...
...
@@ -38,6 +38,7 @@ use Bugzilla::Group;
use
Bugzilla::
Token
;
use
Bugzilla::Whine::
Schedule
;
use
Bugzilla::Whine::
Query
;
use
Bugzilla::
Whine
;
# require the user to have logged in
my
$user
=
Bugzilla
->
login
(
LOGIN_REQUIRED
);
...
...
@@ -55,10 +56,8 @@ my $userid = $user->id;
my
$token
=
$cgi
->
param
(
'token'
);
my
$sth
;
# database statement handle
# $events is a hash ref, keyed by event id, that stores the active user's
# events. It starts off with:
# 'subject' - the subject line for the email message
# 'body' - the text to be sent at the top of the message
# $events is a hash ref of Bugzilla::Whine objects keyed by event id,
# that stores the active user's events.
#
# Eventually, it winds up with:
# 'queries' - array ref containing hashes of:
...
...
@@ -144,9 +143,9 @@ if ($cgi->param('update')) {
trick_taint
(
$subject
)
if
$subject
;
trick_taint
(
$body
)
if
$body
;
if
(
(
$subject
ne
$events
->
{
$eventid
}
->
{
'subject'
}
)
||
(
$mailifnobugs
!=
$events
->
{
$eventid
}
->
{
'mailifnobugs'
}
)
||
(
$body
ne
$events
->
{
$eventid
}
->
{
'body'
}
)
)
{
if
(
(
$subject
ne
$events
->
{
$eventid
}
->
subject
)
||
(
$mailifnobugs
!=
$events
->
{
$eventid
}
->
mail_if_no_bugs
)
||
(
$body
ne
$events
->
{
$eventid
}
->
body
)
)
{
$sth
=
$dbh
->
prepare
(
"UPDATE whine_events "
.
"SET subject=?, body=?, mailifnobugs=? "
.
...
...
@@ -348,7 +347,6 @@ $events = get_events($userid);
#
# build the whine list by event id
for
my
$event_id
(
keys
%
{
$events
})
{
$events
->
{
$event_id
}
->
{
'schedule'
}
=
[]
;
$events
->
{
$event_id
}
->
{
'queries'
}
=
[]
;
...
...
@@ -405,24 +403,13 @@ $vars->{'local_timezone'} = Bugzilla->local_timezone->short_name_for_datetime(Da
$template
->
process
(
"whine/schedule.html.tmpl"
,
$vars
)
||
ThrowTemplateError
(
$template
->
error
());
# get_events takes a userid and returns a hash
, keyed by event ID, containing
#
the subject and body of each event that user owns
# get_events takes a userid and returns a hash
of
#
Bugzilla::Whine objects keyed by event ID.
sub
get_events
{
my
$userid
=
shift
;
my
$
dbh
=
Bugzilla
->
dbh
;
my
$events
=
{}
;
my
$
event_rows
=
Bugzilla::
Whine
->
match
({
owner_userid
=>
$userid
})
;
my
%
events
=
map
{
$_
->
{
id
}
=>
$_
}
@$event_rows
;
my
$sth
=
$dbh
->
prepare
(
"SELECT DISTINCT id, subject, body, mailifnobugs "
.
"FROM whine_events "
.
"WHERE owner_userid=?"
);
$sth
->
execute
(
$userid
);
while
(
my
(
$ev
,
$sub
,
$bod
,
$mno
)
=
$sth
->
fetchrow_array
)
{
$events
->
{
$ev
}
=
{
'subject'
=>
$sub
||
''
,
'body'
=>
$bod
||
''
,
'mailifnobugs'
=>
$mno
||
0
,
};
}
return
$events
;
return
\%
events
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment