summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-07-19 04:42:56 +0200
committerGitHub <noreply@github.com>2018-07-19 04:42:56 +0200
commit351b399991094e57e890a9291484c4ab69ca628b (patch)
tree29b5eb8c82ac00978ab37345bb3c11ad84eb48e1
parent40a8efb9cf0cf27335a34097653f82f943caf5a2 (diff)
downloadbugzilla-351b399991094e57e890a9291484c4ab69ca628b.tar.gz
bugzilla-351b399991094e57e890a9291484c4ab69ca628b.tar.xz
Bug 1476288 - Replace moz_nick with (new, revised) nick and also attempt to disallow duplicate nicks
-rw-r--r--Bugzilla/User.pm10
-rw-r--r--extensions/BugModal/lib/MonkeyPatches.pm25
-rw-r--r--extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl6
-rw-r--r--extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl4
-rw-r--r--extensions/BugModal/template/en/default/bug_modal/user.html.tmpl6
-rw-r--r--template/en/default/global/messages.html.tmpl2
6 files changed, 17 insertions, 36 deletions
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index 9faed25cc..4a58043a0 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -482,11 +482,15 @@ sub set_login {
}
sub _generate_nickname {
- my ($name, $login) = @_;
+ my ($name, $login, $id) = @_;
my ($nick) = extract_nicks($name);
if (!$nick) {
$nick = "";
}
+ my ($count) = Bugzilla->dbh->selectrow_array('SELECT COUNT(*) FROM profiles WHERE nickname = ? AND userid != ?', undef, $nick, $id);
+ if ($count) {
+ $nick = "";
+ }
return $nick;
}
@@ -494,7 +498,7 @@ sub set_name {
my ($self, $name) = @_;
$self->set('realname', $name);
delete $self->{identity};
- $self->set('nickname', _generate_nickname($name, $self->login));
+ $self->set('nickname', _generate_nickname($name, $self->login, $self->id));
}
sub set_nick {
@@ -2532,7 +2536,7 @@ sub create {
my $dbh = Bugzilla->dbh;
$dbh->bz_start_transaction();
- $params->{nickname} = _generate_nickname($params->{realname}, $params->{login_name});
+ $params->{nickname} = _generate_nickname($params->{realname}, $params->{login_name}, 0);
my $user = $class->SUPER::create($params);
# Turn on all email for the new user
diff --git a/extensions/BugModal/lib/MonkeyPatches.pm b/extensions/BugModal/lib/MonkeyPatches.pm
index 88fce11af..54bd6e560 100644
--- a/extensions/BugModal/lib/MonkeyPatches.pm
+++ b/extensions/BugModal/lib/MonkeyPatches.pm
@@ -40,31 +40,6 @@ sub active_attachments {
1;
-package Bugzilla::User;
-
-use 5.10.1;
-use strict;
-use warnings;
-
-sub moz_nick {
- my ($self) = @_;
- if (!exists $self->{moz_nick}) {
- if ($self->name =~ /:?:(\S+?)\b/) {
- $self->{moz_nick} = $1;
- }
- elsif ($self->name) {
- $self->{moz_nick} = $self->name;
- }
- else {
- $self->login =~ /^([^\@]+)\@/;
- $self->{moz_nick} = $1;
- }
- }
- return $self->{moz_nick};
-}
-
-1;
-
package Bugzilla::Attachment;
use 5.10.1;
diff --git a/extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl
index 883393fba..af2077e00 100644
--- a/extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl
+++ b/extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl
@@ -146,7 +146,7 @@
[% END %]
<button type="button" class="reply-btn minor"
data-reply-id="[% comment.count FILTER none %]"
- data-reply-name="[% comment.author.name || comment.author.moz_nick FILTER html %]"
+ data-reply-name="[% comment.author.name || comment.author.nick FILTER html %]"
>Reply</button>
[% END %]
<button type="button" class="change-spinner minor" id="cs-[% comment.count FILTER none %]">-</button>
@@ -184,9 +184,9 @@
<tr>
<td class="comment-collapse-reason"
[% IF user.setting("ui_use_absolute_time") == "on" %]
- title="[% comment.author.moz_nick FILTER html %] [[% comment.creation_ts FILTER time("%Y-%m-%d %H:%M %Z") FILTER html %]]">
+ title="[% comment.author.nick FILTER html %] [[% comment.creation_ts FILTER time("%Y-%m-%d %H:%M %Z") FILTER html %]]">
[% ELSE %]
- title="[% comment.author.moz_nick FILTER html %] [[% comment.creation_ts FILTER time_duration FILTER html %]]">
+ title="[% comment.author.nick FILTER html %] [[% comment.creation_ts FILTER time_duration FILTER html %]]">
[% END %]
Comment hidden ([% comment.collapsed_reason FILTER html %])
</td>
diff --git a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
index d82e1a684..e2c8bba26 100644
--- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
+++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
@@ -565,8 +565,8 @@
[%
sub = [];
- sub.push("Reporter: " _ bug.reporter.moz_nick);
- sub.push(unassigned ? "Unassigned" : "Assigned: " _ bug.assigned_to.moz_nick);
+ sub.push("Reporter: " _ bug.reporter.nick);
+ sub.push(unassigned ? "Unassigned" : "Assigned: " _ bug.assigned_to.nick);
IF bug.mentors.size;
sub.push("Mentored");
END;
diff --git a/extensions/BugModal/template/en/default/bug_modal/user.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/user.html.tmpl
index 9eda7b936..6a0ce4e24 100644
--- a/extensions/BugModal/template/en/default/bug_modal/user.html.tmpl
+++ b/extensions/BugModal/template/en/default/bug_modal/user.html.tmpl
@@ -30,9 +30,9 @@ END;
[% IF simple %]
[% IF user.id %]
- <span class="fn" title="[% u.identity FILTER html %]">[% u.moz_nick FILTER html %]</span>
+ <span class="fn" title="[% u.identity FILTER html %]">[% u.nick FILTER html %]</span>
[% ELSE %]
- <span class="fn">[% u.moz_nick FILTER html %]</span>
+ <span class="fn">[% u.nick FILTER html %]</span>
[% END %]
[% ELSE %]
@@ -52,7 +52,7 @@ END;
href="user_profile?user_id=[% u.id FILTER none %]"
[% END %]
>
- <span class="[% user.id ? 'fn' : 'fna' %]">[% nick_only ? u.moz_nick : (u.name || u.nick) FILTER html %]</span>
+ <span class="[% user.id ? 'fn' : 'fna' %]">[% nick_only ? u.nick : (u.name || u.nick) FILTER html %]</span>
[%~~%]
</a>
[% END %]
diff --git a/template/en/default/global/messages.html.tmpl b/template/en/default/global/messages.html.tmpl
index b2430b7ed..591617f3e 100644
--- a/template/en/default/global/messages.html.tmpl
+++ b/template/en/default/global/messages.html.tmpl
@@ -56,6 +56,8 @@
The login is now [% otheruser.login FILTER html %].
[% ELSIF field == 'realname' %]
The real name has been updated.
+ [% ELSIF field == 'nickname' %]
+ The nickname is now [% otheruser.nick FILTER html %].
[% ELSIF field == 'cryptpassword' %]
A new password has been set.
[% ELSIF field == 'disabledtext' %]