diff --git a/mozilla/webtools/bugzilla/CGI.pl b/mozilla/webtools/bugzilla/CGI.pl index 66217eb4507..770a8d98bd7 100644 --- a/mozilla/webtools/bugzilla/CGI.pl +++ b/mozilla/webtools/bugzilla/CGI.pl @@ -474,6 +474,25 @@ sub make_popup { } +sub BuildPulldown { + my ($name, $valuelist, $default) = (@_); + + my $entry = qq{}; + return $entry; +} + + + + sub PasswordForLogin { my ($login) = (@_); SendSQL("select cryptpassword from profiles where login_name = " . @@ -563,7 +582,7 @@ To use the wonders of bugzilla, you can use the following: Password: %s To change your password, go to: - ${urlbase}changepassword.cgi + ${urlbase}userprefs.cgi (Your bugzilla and CVS password, if any, are not currently synchronized. Top hackers are working around the clock to fix this, as you read this.) @@ -846,29 +865,27 @@ sub GetCommandMenu { if ($loggedin) { my $mybugstemplate = Param("mybugstemplate"); my %substs; - $substs{'userid'} = $::COOKIE{"Bugzilla_login"}; + $substs{'userid'} = url_quote($::COOKIE{"Bugzilla_login"}); if (!defined $::anyvotesallowed) { GetVersionTable(); } if ($::anyvotesallowed) { $html .= qq{ | My votes}; } - my $mybugsurl = PerformSubsts($mybugstemplate, \%substs); - $html = $html . " | My bugs"; - } - - $html = $html . " | New account\n"; - - my $onLogPage = 0; - if (defined $ENV{"HTTP_REFERER"}) { - #my $referrer = $ENV{"HTTP_REFERER"}; - #my @parts = split("/",$referrer); - #my $called_from = $parts[@parts-1]; - #confirm_login($called_from); - } - - if ($loggedin) { - $html .= "| Edit prefs"; + SendSQL("SELECT mybugslink, userid FROM profiles WHERE login_name = " . + SqlQuote($::COOKIE{'Bugzilla_login'})); + my ($mybugslink, $userid) = (FetchSQLData()); + if ($mybugslink) { + my $mybugsurl = PerformSubsts($mybugstemplate, \%substs); + $html = $html . " | My bugs"; + } + SendSQL("SELECT name,query FROM namedqueries " . + "WHERE userid = $userid AND linkinfooter"); + while (MoreSQLData()) { + my ($name, $query) = (FetchSQLData()); + $html .= qq{ | $name}; + } + $html .= " | Edit prefs"; if (UserInGroup("tweakparams")) { $html .= ", parameters"; $html .= ", sanity check"; @@ -882,9 +899,12 @@ sub GetCommandMenu { if (UserInGroup("editkeywords")) { $html .= ", keywords"; } - $html = $html . " | Log out $::COOKIE{'Bugzilla_login'}"; + $html .= " | Log out $::COOKIE{'Bugzilla_login'}"; } else { - $html = $html . " | Log in"; + $html .= + " | New account\n"; + $html .= + " | Log in"; } $html .= ""; return $html; diff --git a/mozilla/webtools/bugzilla/buglist.cgi b/mozilla/webtools/bugzilla/buglist.cgi index f096bd323df..6427180e913 100755 --- a/mozilla/webtools/bugzilla/buglist.cgi +++ b/mozilla/webtools/bugzilla/buglist.cgi @@ -141,9 +141,17 @@ individual query. PutFooter(); exit(); } - SendSQL("REPLACE INTO namedqueries (userid, name, query) VALUES " . - "($userid, " . SqlQuote($name) . - ", " . SqlQuote($::buffer) . ")"); + $::buffer =~ s/[\&\?]cmdtype=[a-z]+//; + my $qname = SqlQuote($name); + SendSQL("SELECT query FROM namedqueries " . + "WHERE userid = $userid AND name = $qname"); + if (!FetchOneColumn()) { + SendSQL("REPLACE INTO namedqueries (userid, name, query) " . + "VALUES ($userid, $qname, " . SqlQuote($::buffer) . ")"); + } else { + SendSQL("UPDATE namedqueries SET query = " . SqlQuote($::buffer) . + " WHERE userid = $userid AND name = $qname"); + } PutHeader("OK, query saved."); print qq{ OK, you have a new query named $name @@ -874,6 +882,7 @@ if ($count == 0) { print qq{

Query Page\n}; print qq{  Enter New Bug\n}; + print qq{Edit this query\n}; } elsif ($count == 1) { print "One bug found.\n"; } else { diff --git a/mozilla/webtools/bugzilla/changepassword.cgi b/mozilla/webtools/bugzilla/changepassword.cgi index ca533b1eeb1..873ababda90 100755 --- a/mozilla/webtools/bugzilla/changepassword.cgi +++ b/mozilla/webtools/bugzilla/changepassword.cgi @@ -20,153 +20,18 @@ # # Contributor(s): Terry Weissman -require "CGI.pl"; +print q{Content-type: text/html - -sub sillyness { - my $zz; - $zz = $::anyvotesallowed; + + + + + +This URL is obsolete. Forwarding you to the correct one. +

+Going to userprefs.cgi +
+ + } - -confirm_login(); - -print "Content-type: text/html\n\n"; - -GetVersionTable(); - -if (! defined $::FORM{'pwd1'}) { - PutHeader("Preferences", "Change your password and
other preferences", - $::COOKIE{'Bugzilla_login'}); - - my $qacontactpart = ""; - if (Param('useqacontact')) { - $qacontactpart = ", the current QA Contact"; - } - my $loginname = SqlQuote($::COOKIE{'Bugzilla_login'}); - SendSQL("select emailnotification,realname,newemailtech from profiles where login_name = " . - $loginname); - my ($emailnotification, $realname, $newemailtech) = (FetchSQLData()); - $realname = value_quote($realname); - print qq{ -

-
- - - - - - - - - - - - - -
Please enter the new password for $::COOKIE{'Bugzilla_login'}:
Re-enter your new password:
Your real name (optional):
-
- - - - - -"; - if (Param("newemailtech")) { - my $checkedpart = $newemailtech ? "CHECKED" : ""; - print qq{ - - - - -}; - } - print " -
Bugzilla will send out email notification of changed bugs to -the current owner, the submitter of the bug$qacontactpart, and anyone on the -CC list. However, you can suppress some of those email notifications. -On which of these bugs would you like email notification of changes? -

New! Bugzilla has a new email -notification scheme. It is experimental and bleeding edge and will -hopefully evolve into a brave new happy world where all the spam and ugliness -of the old notifications will go away. If you wish to sign up for this (and -risk any bugs), check here.New email tech
-
- -
-
"; - if ($::anyvotesallowed) { - print qq{Review your votes
\n}; - } - PutFooter(); - exit; -} - -if ($::FORM{'pwd1'} ne $::FORM{'pwd2'}) { - print "

Try again.

-The two passwords you entered did not match. Please click Back and try again.\n"; - PutFooter(); - exit; -} - - -my $pwd = $::FORM{'pwd1'}; - - -if ($pwd ne "") { - if ($pwd !~ /^[a-zA-Z0-9-_]*$/ || length($pwd) < 3 || length($pwd) > 15) { - print "

Sorry; we're picky.

-Please choose a password that is between 3 and 15 characters long, and that -contains only numbers, letters, hyphens, or underlines. -

-Please click Back and try again.\n"; - PutFooter(); - exit; - } - - - my $qpwd = SqlQuote($pwd); - SendSQL("UPDATE profiles SET password=$qpwd,cryptpassword=encrypt($qpwd) - WHERE login_name = " . - SqlQuote($::COOKIE{'Bugzilla_login'})); - SendSQL("SELECT cryptpassword FROM profiles WHERE login_name = " . - SqlQuote($::COOKIE{'Bugzilla_login'})); - my $encrypted = FetchOneColumn(); - - SendSQL("update logincookies set cryptpassword = '$encrypted' where cookie = $::COOKIE{'Bugzilla_logincookie'}"); -} - - -my $newemailtech = exists $::FORM{'newemailtech'}; - -SendSQL("UPDATE profiles " . - "SET emailnotification='$::FORM{'emailnotification'}', " . - " newemailtech = '$newemailtech' " . - "WHERE login_name = " . SqlQuote($::COOKIE{'Bugzilla_login'})); - -my $newrealname = $::FORM{'realname'}; - -if ($newrealname ne "") { - $newrealname = SqlQuote($newrealname); - SendSQL("update profiles set realname=$newrealname where login_name = " . - SqlQuote($::COOKIE{'Bugzilla_login'})); -} - -PutHeader("Preferences updated."); -print " -Your preferences have been updated. -

"; -PutFooter(); - diff --git a/mozilla/webtools/bugzilla/checksetup.pl b/mozilla/webtools/bugzilla/checksetup.pl index 699ed8138e9..6f7f38559a9 100755 --- a/mozilla/webtools/bugzilla/checksetup.pl +++ b/mozilla/webtools/bugzilla/checksetup.pl @@ -669,6 +669,7 @@ $table{profiles} = emailnotification enum("ExcludeSelfChanges", "CConly", "All") not null default "ExcludeSelfChanges", disabledtext mediumtext not null, newemailtech tinyint not null, + mybugslink tinyint not null default 1, unique(login_name)'; @@ -677,6 +678,7 @@ $table{namedqueries} = 'userid mediumint not null, name varchar(64) not null, watchfordiffs tinyint not null, + linkinfooter tinyint not null, query mediumtext not null, unique(userid, name), @@ -1402,6 +1404,13 @@ if (GetIndexDef('profiles', 'login_name')->[1]) { } +# 2000-01-24 Added a new field to let people control whether the "My +# bugs" link appears at the bottom of each page. Also can control +# whether each named query should show up there. + +AddField('profiles', 'mybugslink', 'tinyint not null default 1'); +AddField('namedqueries', 'linkinfooter', 'tinyint not null'); + # # If you had to change the --TABLE-- definition in any way, then add your diff --git a/mozilla/webtools/bugzilla/defparams.pl b/mozilla/webtools/bugzilla/defparams.pl index daa8c1da274..6bd398c7356 100644 --- a/mozilla/webtools/bugzilla/defparams.pl +++ b/mozilla/webtools/bugzilla/defparams.pl @@ -205,8 +205,10 @@ information about what Bugzilla is and what it can do, see DefParam("mybugstemplate", "This is the URL to use to bring up a simple 'all of my bugs' list for a user. %userid% will get replaced with the login name of a user.", "t", - "buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&assigned_to=%userid%"); + "buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&email1=%userid%&emailtype1=exact&emailassigned_to1=1&emailreporter1=1"); + + DefParam("shutdownhtml", "If this field is non-empty, then Bugzilla will be completely disabled and this text will be displayed instead of all the Bugzilla pages.", "l", diff --git a/mozilla/webtools/bugzilla/globals.pl b/mozilla/webtools/bugzilla/globals.pl index b8f390537bb..6e42aa1c199 100644 --- a/mozilla/webtools/bugzilla/globals.pl +++ b/mozilla/webtools/bugzilla/globals.pl @@ -59,7 +59,7 @@ $::param{'version'} = '2.9'; $::dontchange = "--do_not_change--"; $::chooseone = "--Choose_one:--"; -$::defaultqueryname = "(Default query) "; +$::defaultqueryname = "(Default query)"; sub ConnectToDatabase { if (!defined $::db) { diff --git a/mozilla/webtools/bugzilla/index.html b/mozilla/webtools/bugzilla/index.html index 5ec3d5f9c7d..68eb58a01f6 100644 --- a/mozilla/webtools/bugzilla/index.html +++ b/mozilla/webtools/bugzilla/index.html @@ -75,7 +75,7 @@ But it all boils down to a choice of:

Open a new Bugzilla account
Forget the currently stored login
-Change password or user preferences
+Change password or user preferences

bug #
diff --git a/mozilla/webtools/bugzilla/processmail b/mozilla/webtools/bugzilla/processmail index d814107083a..f6912c99a6e 100755 --- a/mozilla/webtools/bugzilla/processmail +++ b/mozilla/webtools/bugzilla/processmail @@ -656,7 +656,7 @@ sub ProcessOneBug { if (@sentlist) { print "Email sent to: " . join(", ", @sentlist) . "\n"; if ($didexclude) { - print "Excluding: $nametoexclude (change your preferences if you wish not to be excluded)\n"; + print qq{Excluding: $nametoexclude (change your preferences if you wish not to be excluded)\n}; } } rename($new, $old) || die "Can't rename $new to $old"; diff --git a/mozilla/webtools/bugzilla/query.cgi b/mozilla/webtools/bugzilla/query.cgi index 09ec3b7fe90..0b6211bfbe5 100755 --- a/mozilla/webtools/bugzilla/query.cgi +++ b/mozilla/webtools/bugzilla/query.cgi @@ -225,19 +225,21 @@ sub GenerateEmailInput { } - return qq| + $default{"emailtype$id"} ||= "substring"; + + return qq{
Email:  matching as - +} . BuildPulldown("emailtype$id", + [["regexp", "regexp"], + ["notregexp", "not regexp"], + ["substring", "substring"], + ["exact", "exact"]], + $default{"emailtype$id"}) . qq{ Assigned To @@ -262,7 +264,7 @@ sub GenerateEmailInput {
-|; +}; } @@ -748,7 +750,7 @@ if (UserInGroup("editkeywords")) { if ($userid) { print "Log in as someone besides $::COOKIE{'Bugzilla_login'}
\n"; } -print "Change your password or preferences.
\n"; +print "Change your password or preferences.
\n"; print "Create a new bug.
\n"; print "Open a new Bugzilla account
\n"; print "Bug reports
\n"; diff --git a/mozilla/webtools/bugzilla/userprefs.cgi b/mozilla/webtools/bugzilla/userprefs.cgi new file mode 100755 index 00000000000..964f8671288 --- /dev/null +++ b/mozilla/webtools/bugzilla/userprefs.cgi @@ -0,0 +1,298 @@ +#!/usr/bonsaitools/bin/perl -w +# -*- 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. +# +# Contributor(s): Terry Weissman + +use diagnostics; +use strict; + +require "CGI.pl"; + + + +my $userid; + + +sub EmitEntry { + my ($description, $entry) = (@_); + print qq{$description:$entry\n}; +} + +sub Error { + my ($msg) = (@_); + print qq{ +$msg +

+Please hit back and try again. +}; + PutFooter(); + exit(); +} + + +sub ShowAccount { + SendSQL("SELECT realname FROM profiles WHERE userid = $userid"); + my ($realname) = (FetchSQLData()); + + $realname = value_quote($realname); + + EmitEntry("Old password", + qq{}); + EmitEntry("New password", + qq{}); + EmitEntry("Re-enter new password", + qq{}); + EmitEntry("Your username (optional)", + qq{}); +} + +sub SaveAccount { + if ($::FORM{'oldpwd'} ne "" + || $::FORM{'pwd1'} ne "" || $::FORM{'pwd2'} ne "") { + my $old = SqlQuote($::FORM{'oldpwd'}); + my $pwd1 = SqlQuote($::FORM{'pwd1'}); + my $pwd2 = SqlQuote($::FORM{'pwd2'}); + SendSQL("SELECT cryptpassword = ENCRYPT($old, LEFT(cryptpassword, 2)) " . + "FROM profiles WHERE userid = $userid"); + if (!FetchOneColumn()) { + Error("You did not enter your old password correctly."); + } + if ($pwd1 ne $pwd2) { + Error("The two passwords you entered did not match."); + } + if ($::FORM{'pwd1'} eq '') { + Error("You must enter a new password."); + } + SendSQL("UPDATE profiles SET password = $pwd1, " . + "cryptpassword = ENCRYPT($pwd1) " . + "WHERE userid = $userid"); + } + SendSQL("UPDATE profiles SET " . + "realname = " . SqlQuote($::FORM{'realname'}) . + " WHERE userid = $userid"); +} + + + +sub ShowDiffs { + SendSQL("SELECT emailnotification, newemailtech FROM profiles " . + "WHERE userid = $userid"); + my ($emailnotification, $newemailtech) = (FetchSQLData()); + my $qacontactpart = ""; + if (Param('useqacontact')) { + $qacontactpart = ", the current QA Contact"; + } + print qq{ + +Bugzilla will send out email notification of changed bugs to +the current owner, the submitter of the bug$qacontactpart, and anyone on the +CC list. However, you can suppress some of those email notifications. +On which of these bugs would you like email notification of changes? + +}; + my $entry = + BuildPulldown("emailnotification", + [["ExcludeSelfChanges", + "All qualifying bugs except those which I change"], + ["CConly", + "Only those bugs which I am listed on the CC line"], + ["All", + "All qualifying bugs"]], + $emailnotification); + EmitEntry("Notify me of changes to", $entry); + + if (Param("newemailtech")) { + my $checkedpart = $newemailtech ? "CHECKED" : ""; + print qq{ +


+New! +Bugzilla has a new email +notification scheme. It is experimental and bleeding edge and will +hopefully evolve into a brave new happy world where all the spam and ugliness +of the old notifications will go away. If you wish to sign up for this (and +risk any bugs), check here. + +}; + EmitEntry("Check here to sign up (and risk any bugs)", + qq{New email tech}); + } +} + +sub SaveDiffs { + my $newemailtech = 0; + if (exists $::FORM{'newemailtech'}) { + $newemailtech = 1; + } + SendSQL("UPDATE profiles " . + "SET emailnotification = " . SqlQuote($::FORM{'emailnotification'}) + . ", newemailtech = $newemailtech WHERE userid = $userid"); +} + + + +sub ShowFooter { + SendSQL("SELECT mybugslink FROM profiles " . + "WHERE userid = $userid"); + my ($mybugslink) = (FetchSQLData()); + my $entry = + BuildPulldown("mybugslink", + [["1", "should appear"], + ["0", "should not be displayed"]], + $mybugslink); + EmitEntry("The 'My bugs' link at the footer of each page", $entry); + SendSQL("SELECT name, linkinfooter FROM namedqueries " . + "WHERE userid = $userid"); + my $found = 0; + while (MoreSQLData()) { + my ($name, $linkinfooter) = (FetchSQLData()); + if ($name eq $::defaultqueryname) { + next; + } + $found = 1; + my $entry = + BuildPulldown("query-" . value_quote($name), + [["0", "should only appear in the query page"], + ["1", "should appear on the footer of every page"]], + $linkinfooter); + EmitEntry("Your query named '$name'", $entry); + } + if (!$found) { + print qq{ + +If you go create name queries in the query page, +you can then come to this page and choose to have some of them appear in the +footer of each Bugzilla page. +}; + } +} + + +sub SaveFooter { + my %old; + SendSQL("SELECT name, linkinfooter FROM namedqueries " . + "WHERE userid = $userid"); + while (MoreSQLData()) { + my ($name, $linkinfooter) = (FetchSQLData()); + $old{$name} = $linkinfooter; + } + foreach my $name (keys %old) { + if (exists $::FORM{"query-$name"}) { + my $new = $::FORM{"query-$name"}; + if ($new ne $old{$name}) { + SendSQL("UPDATE namedqueries SET linkinfooter = $new " . + "WHERE userid = $userid " . + "AND name = " . SqlQuote($name)); + } + } + } + SendSQL("UPDATE profiles SET mybugslink = '" . $::FORM{'mybugslink'} . + "' WHERE userid = $userid"); +} + + + +###################################################################### +################# Live code (not sub defs) starts here ############### + + +confirm_login(); + +print "Content-type: text/html\n\n"; + +GetVersionTable(); + +PutHeader("Preferences", "Preferences", $::COOKIE{'Bugzilla_login'}); + +my $bank = $::FORM{'bank'} || "account"; + +my @banklist = ( + ["account", "Account settings", + \&ShowAccount, \&SaveAccount], + ["diffs", "Email settings", + \&ShowDiffs, \&SaveDiffs], + ["footer", "Page footer", + \&ShowFooter, \&SaveFooter] + ); + + +my $numbanks = @banklist; +my $numcols = $numbanks + 2; + +my $headcol = '"lightblue"'; + +print qq{ +
+ + + + + +}; + + +my $bankdescription; +my $showfunc; +my $savefunc; + +foreach my $i (@banklist) { + my ($name, $description) = (@$i); + my $color = ""; + if ($name eq $bank) { + print qq{}; + my $zz; + ($zz, $bankdescription, $showfunc, $savefunc) = (@$i); + } else { + print qq{}; + } +} +print qq{ + +
User preferences
 $description$description 
+
+

+}; + + + + +if (defined $bankdescription) { + $userid = DBNameToIdAndCheck($::COOKIE{'Bugzilla_login'}); + + if ($::FORM{'dosave'}) { + &$savefunc; + print "Your changes have been saved."; + } + print qq{ +

$bankdescription

+
+ +}; + &$showfunc; + print qq{ +
+ + + +
+}; +} else { + print "

Please choose from the above links which settings you wish to change.

"; +} + + +print "

"; + + +PutFooter();