summaryrefslogtreecommitdiffstats
path: root/checksetup.pl
diff options
context:
space:
mode:
authortravis%sedsystems.ca <>2005-01-08 05:56:01 +0100
committertravis%sedsystems.ca <>2005-01-08 05:56:01 +0100
commite2466aae1fda4c2ce67c517074fdc4369d68b848 (patch)
treeeb5daecabb33f093d2e31b61fd884992e8c15938 /checksetup.pl
parentd6e7117d0ff4a6674a186f443219f56c0bb5bab8 (diff)
downloadbugzilla-e2466aae1fda4c2ce67c517074fdc4369d68b848.tar.gz
bugzilla-e2466aae1fda4c2ce67c517074fdc4369d68b848.tar.xz
Bug 108870: Bugzilla does not set email prefs for new user until user visits userprefs.cgi
Patch: travis r=mkanat a=justdave Also includes fixes for Bug 109573: New bugzilla accounts should by default have 'CC field changes' turned off, and Bug 275599: flag request email prefs not behaving correctly
Diffstat (limited to 'checksetup.pl')
-rwxr-xr-xchecksetup.pl49
1 files changed, 47 insertions, 2 deletions
diff --git a/checksetup.pl b/checksetup.pl
index e352e6621..7e77af97f 100755
--- a/checksetup.pl
+++ b/checksetup.pl
@@ -26,6 +26,7 @@
# Jacob Steenhagen <jake@bugzilla.org>
# Bradley Baetz <bbaetz@student.usyd.edu.au>
# Tobias Burnus <burnus@net-b.de>
+# Shane H. W. Travis <travis@sedsystems.ca>
# Gervase Markham <gerv@gerv.net>
# Erik Stambaugh <erik@dasbistro.com>
#
@@ -4457,8 +4458,11 @@ if ($sth->rows == 0) {
$realname = $dbh->quote($realname);
$cryptedpassword = $dbh->quote($cryptedpassword);
- $dbh->do("INSERT INTO profiles (login_name, realname, cryptpassword)" .
- " VALUES ($login, $realname, $cryptedpassword)");
+ # Set default email flags for the Admin, same as for users
+ my $defaultflagstring = $dbh->quote(Bugzilla::Constants::DEFAULT_EMAIL_SETTINGS);
+
+ $dbh->do("INSERT INTO profiles (login_name, realname, cryptpassword, emailflags) " .
+ "VALUES ($login, $realname, $cryptedpassword, $defaultflagstring)");
}
# Put the admin in each group if not already
my $query = "select userid from profiles where login_name = $login";
@@ -4567,6 +4571,47 @@ if (GetFieldDef('bugs', 'short_desc')->[2]) { # if it allows nulls
# Make sure groups get rederived
$dbh->do("UPDATE groups SET last_changed = NOW() WHERE name = 'admin'");
+# 2004-12-29 - Flag email code is broke somewhere, and doesn't treat a lack
+# of FlagRequestee/er emailflags as 'on' like it's supposed to. Easiest way
+# to fix this is to make sure that everyone has these set. (bug 275599).
+# While we're at it, let's make sure everyone has some emailprefs set,
+# whether or not they've ever visited userprefs.cgi (bug 108870). In fact,
+# do this first so that the second check gets fewer hits.
+#
+my $emailflags_count = 0;
+$sth = $dbh->prepare("SELECT userid FROM profiles " .
+ "WHERE emailflags LIKE '' " .
+ "OR emailflags IS NULL");
+$sth->execute();
+while (my ($userid) = $sth->fetchrow_array()) {
+ $dbh->do("UPDATE profiles SET emailflags = " .
+ $dbh->quote(Bugzilla::Constants::DEFAULT_EMAIL_SETTINGS) .
+ "WHERE userid = $userid");
+ $emailflags_count++;
+}
+
+if ($emailflags_count) {
+ print "Added default email prefs to $emailflags_count users who had none.\n" unless $silent;
+ $emailflags_count = 0;
+}
+
+
+$sth = $dbh->prepare("SELECT userid, emailflags FROM profiles " .
+ "WHERE emailflags NOT LIKE '%Flagrequeste%' ");
+$sth->execute();
+while (my ($userid, $emailflags) = $sth->fetchrow_array()) {
+ $emailflags .= Bugzilla::Constants::DEFAULT_FLAG_EMAIL_SETTINGS;
+ $emailflags = $dbh->quote($emailflags);
+ $dbh->do("UPDATE profiles SET emailflags = $emailflags " .
+ "WHERE userid = $userid");
+ $emailflags_count++;
+}
+
+if ($emailflags_count) {
+ print "Added default Flagrequester/ee email prefs to $emailflags_count users who had none.\n" unless $silent;
+ $emailflags_count = 0;
+}
+
# 2003-10-24 - alt@sonic.net, bug 224208
# Support classification level and make sure there is a default classification