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
4ec67697
Commit
4ec67697
authored
May 07, 2010
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 561745: Impossible to uncheck boxes in the Email preferences
r/a=mkanat
parent
b4c91ada
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
73 deletions
+58
-73
User.pm
Bugzilla/User.pm
+16
-9
email.html.tmpl
template/en/default/account/prefs/email.html.tmpl
+6
-23
userprefs.cgi
userprefs.cgi
+36
-41
No files found.
Bugzilla/User.pm
View file @
4ec67697
...
...
@@ -1471,18 +1471,25 @@ sub wants_mail {
# Skip DB query if relationship is explicit
return
1
if
$relationship
==
REL_GLOBAL_WATCHER
;
my
$wants_mail
=
grep
{
$self
->
mail_settings
->
{
$relationship
}{
$_
}
}
@$events
;
return
$wants_mail
?
1
:
0
;
}
sub
mail_settings
{
my
$self
=
shift
;
my
$dbh
=
Bugzilla
->
dbh
;
my
$wants_mail
=
$dbh
->
selectrow_array
(
'SELECT 1
FROM email_setting
WHERE user_id = ?
AND relationship = ?
AND event IN ('
.
join
(
','
,
@$events
)
.
') '
.
$dbh
->
sql_limit
(
1
),
undef
,
(
$self
->
id
,
$relationship
));
if
(
!
defined
$self
->
{
'mail_settings'
})
{
my
$data
=
$dbh
->
selectall_arrayref
(
'SELECT relationship, event FROM email_setting
WHERE user_id = ?'
,
undef
,
$self
->
id
);
my
%
mail
;
# The hash is of the form $mail{$relationship}{$event} = 1.
$mail
{
$_
->
[
0
]}{
$_
->
[
1
]}
=
1
foreach
@$data
;
return
defined
(
$wants_mail
)
?
1
:
0
;
$self
->
{
'mail_settings'
}
=
\%
mail
;
}
return
$self
->
{
'mail_settings'
};
}
sub
is_mover
{
...
...
template/en/default/account/prefs/email.html.tmpl
View file @
4ec67697
...
...
@@ -77,8 +77,8 @@ document.write('<input type="button" value="Disable All Mail" onclick="SetCheckb
[% prefname = "email-$constants.REL_ANY-$constants.EVT_FLAG_REQUESTED" %]
<input type="checkbox" name="[% prefname %]" id="[% prefname %]"
value="1"
[% " checked"
IF
mail
.${constants.REL_ANY}.${constants.EVT_FLAG_REQUESTED} %]>
[% " checked"
IF user.mail_settings
.${constants.REL_ANY}.${constants.EVT_FLAG_REQUESTED} %]>
<label for="[% prefname %]">Email me when someone asks me to set a flag</label>
<br>
</td>
...
...
@@ -89,8 +89,8 @@ document.write('<input type="button" value="Disable All Mail" onclick="SetCheckb
[% prefname = "email-$constants.REL_ANY-$constants.EVT_REQUESTED_FLAG" %]
<input type="checkbox" name="[% prefname %]" id="[% prefname %]"
value="1"
[% " checked"
IF
mail
.${constants.REL_ANY}.${constants.EVT_REQUESTED_FLAG} %]>
[% " checked"
IF user.mail_settings
.${constants.REL_ANY}.${constants.EVT_REQUESTED_FLAG} %]>
<label for="[% prefname %]">Email me when someone sets a flag I asked for</label>
<br>
</td>
...
...
@@ -197,7 +197,7 @@ document.write('<input type="button" value="Disable All Mail" onclick="SetCheckb
no_added_removed.contains(relationship.id)
%]
disabled
[% ELSIF
mail
.${relationship.id}.${event.id} %]
[% ELSIF
user.mail_settings
.${relationship.id}.${event.id} %]
checked
[% END %]>
</td>
...
...
@@ -226,7 +226,7 @@ document.write('<input type="button" value="Disable All Mail" onclick="SetCheckb
<input type="checkbox"
name="neg-email-[% relationship.id %]-[% event.id %]"
value="1"
[% " checked" IF NOT
mail
.${relationship.id}.${event.id} %]>
[% " checked" IF NOT
user.mail_settings
.${relationship.id}.${event.id} %]>
</td>
[% END %]
<td>
...
...
@@ -237,23 +237,6 @@ document.write('<input type="button" value="Disable All Mail" onclick="SetCheckb
</table>
[%# Add hidden form fields for fields not used %]
[% FOREACH event = events %]
[% FOREACH relationship = relationships %]
<input type="hidden"
name="email-[% relationship.id %]-[% event.id %]"
value="[% mail.${relationship.id}.${event.id} ? "1" : "0" %]">
[% END %]
[% END %]
[% FOREACH event = neg_events %]
[% FOREACH relationship = relationships %]
<input type="hidden"
name="neg-email-[% relationship.id %]-[% event.id %]"
value="[% mail.${relationship.id}.${event.id} ? "0" : "1" %]">
[% END %]
[% END %]
<hr>
<b>User Watching</b>
...
...
userprefs.cgi
View file @
4ec67697
...
...
@@ -219,21 +219,6 @@ sub DoEmail {
@watchers
=
sort
{
lc
(
$a
)
cmp
lc
(
$b
)
}
@watchers
;
$vars
->
{
'watchers'
}
=
\
@watchers
;
###########################################################################
# Role-based preferences
###########################################################################
my
$sth
=
$dbh
->
prepare
(
"SELECT relationship, event "
.
"FROM email_setting "
.
"WHERE user_id = ?"
);
$sth
->
execute
(
$user
->
id
);
my
%
mail
;
while
(
my
(
$relationship
,
$event
)
=
$sth
->
fetchrow_array
())
{
$mail
{
$relationship
}{
$event
}
=
1
;
}
$vars
->
{
'mail'
}
=
\%
mail
;
}
sub
SaveEmail
{
...
...
@@ -248,54 +233,64 @@ sub SaveEmail {
###########################################################################
$dbh
->
bz_start_transaction
();
# Delete all the user's current preferences
$dbh
->
do
(
"DELETE FROM email_setting WHERE user_id = ?"
,
undef
,
$user
->
id
);
my
$sth_insert
=
$dbh
->
prepare
(
'INSERT INTO email_setting
(user_id, relationship, event) VALUES (?, ?, ?)'
);
my
$sth_delete
=
$dbh
->
prepare
(
'DELETE FROM email_setting
WHERE user_id = ? AND relationship = ? AND event = ?'
);
# Load current email preferences into memory before updating them.
my
$settings
=
$user
->
mail_settings
;
#
Repopulate the table - first, with normal events in the
#
Update the table - first, with normal events in the
# relationship/event matrix.
# Note: the database holds only "off" email preferences, as can be implied
# from the name of the table - profiles_nomail.
my
%
relationships
=
Bugzilla::BugMail::
relationships
();
foreach
my
$rel
(
keys
%
relationships
)
{
next
if
(
$rel
==
REL_QA
&&
!
Bugzilla
->
params
->
{
'useqacontact'
});
# Positive events: a ticked box means "send me mail."
foreach
my
$event
(
POS_EVENTS
)
{
if
(
defined
(
$cgi
->
param
(
"email-$rel-$event"
))
&&
$cgi
->
param
(
"email-$rel-$event"
)
==
1
)
{
$dbh
->
do
(
"INSERT INTO email_setting "
.
"(user_id, relationship, event) "
.
"VALUES (?, ?, ?)"
,
undef
,
(
$user
->
id
,
$rel
,
$event
));
my
$is_set
=
$cgi
->
param
(
"email-$rel-$event"
);
if
(
$is_set
xor
$settings
->
{
$rel
}{
$event
})
{
if
(
$is_set
)
{
$sth_insert
->
execute
(
$user
->
id
,
$rel
,
$event
);
}
else
{
$sth_delete
->
execute
(
$user
->
id
,
$rel
,
$event
);
}
}
}
# Negative events: a ticked box means "don't send me mail."
foreach
my
$event
(
NEG_EVENTS
)
{
if
(
!
defined
(
$cgi
->
param
(
"neg-email-$rel-$event"
))
||
$cgi
->
param
(
"neg-email-$rel-$event"
)
!=
1
)
{
$dbh
->
do
(
"INSERT INTO email_setting "
.
"(user_id, relationship, event) "
.
"VALUES (?, ?, ?)"
,
undef
,
(
$user
->
id
,
$rel
,
$event
));
my
$is_set
=
$cgi
->
param
(
"neg-email-$rel-$event"
);
if
(
!
$is_set
xor
$settings
->
{
$rel
}{
$event
})
{
if
(
!
$is_set
)
{
$sth_insert
->
execute
(
$user
->
id
,
$rel
,
$event
);
}
else
{
$sth_delete
->
execute
(
$user
->
id
,
$rel
,
$event
);
}
}
}
}
# Global positive events: a ticked box means "send me mail."
foreach
my
$event
(
GLOBAL_EVENTS
)
{
if
(
defined
(
$cgi
->
param
(
"email-"
.
REL_ANY
.
"-$event"
))
&&
$cgi
->
param
(
"email-"
.
REL_ANY
.
"-$event"
)
==
1
)
{
$dbh
->
do
(
"INSERT INTO email_setting "
.
"(user_id, relationship, event) "
.
"VALUES (?, ?, ?)"
,
undef
,
(
$user
->
id
,
REL_ANY
,
$event
));
my
$is_set
=
$cgi
->
param
(
"email-"
.
REL_ANY
.
"-$event"
);
if
(
$is_set
xor
$settings
->
{
+
REL_ANY
}{
$event
})
{
if
(
$is_set
)
{
$sth_insert
->
execute
(
$user
->
id
,
REL_ANY
,
$event
);
}
else
{
$sth_delete
->
execute
(
$user
->
id
,
REL_ANY
,
$event
);
}
}
}
$dbh
->
bz_commit_transaction
();
# We have to clear the cache about email preferences.
delete
$user
->
{
'mail_settings'
};
###########################################################################
# User watching
###########################################################################
...
...
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