Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
76844f05
Commit
76844f05
authored
Oct 04, 2011
by
Richard Mansfield
Committed by
Gerrit Code Review
Oct 04, 2011
Browse files
Merge "Fix user csv updates when the db has duplicate emails (bug #862933)"
parents
16762645
883972dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/admin/users/uploadcsv.php
View file @
76844f05
...
...
@@ -391,8 +391,11 @@ function uploadcsv_validate(Pieform $form, $values) {
}
}
// It's okay if the email already exists and is owned by this user.
$emailowned
=
get_record_sql
(
'
// Check if the email already exists and if it's owned by this user. This query can return more
// than one row when there are duplicate emails already on the site. If that happens, things are
// already a bit out of hand, and we'll just allow an update if this user is one of the users who
// owns the email.
$emailowned
=
get_records_sql_assoc
(
'
SELECT LOWER(u.username) AS lowerusername, ae.principal FROM {usr} u
LEFT JOIN {artefact_internal_profile_email} ae ON u.id = ae.owner AND ae.verified = 1 AND ae.email = ?
WHERE ae.owner IS NOT NULL OR u.email = ?'
,
...
...
@@ -401,16 +404,19 @@ function uploadcsv_validate(Pieform $form, $values) {
// If the email is owned by someone else, it could still be okay provided
// that other user's email is also being changed in this csv file.
if
(
$emailowned
&&
$emailowned
->
lowerusername
!=
$lowerusername
)
{
if
(
!
$emailowned
->
principal
)
{
// However, only primary emails can be set in uploadcsv, so this is an error
$csverrors
->
add
(
$line
,
get_string
(
'uploadcsverroremailaddresstaken'
,
'admin'
,
$line
,
$email
));
}
else
if
(
!
isset
(
$usernames
[
$emailowned
->
lowerusername
]))
{
// The other user is not being updated in this file
$csverrors
->
add
(
$line
,
get_string
(
'uploadcsverroremailaddresstaken'
,
'admin'
,
$line
,
$email
));
}
else
{
if
(
$emailowned
&&
!
isset
(
$emailowned
[
$lowerusername
]))
{
foreach
(
$emailowned
as
$e
)
{
// Only primary emails can be set in uploadcsv, so it's an error when someone else
// owns the email as a secondary.
if
(
!
$e
->
principal
)
{
$csverrors
->
add
(
$line
,
get_string
(
'uploadcsverroremailaddresstaken'
,
'admin'
,
$line
,
$email
));
break
;
}
// It's also an error if the email owner is not being updated in this file
if
(
!
isset
(
$usernames
[
$e
->
lowerusername
]))
{
$csverrors
->
add
(
$line
,
get_string
(
'uploadcsverroremailaddresstaken'
,
'admin'
,
$line
,
$email
));
break
;
}
// If the other user is being updated in this file, but isn't changing their
// email address, it's ok, we've already notified duplicate emails within the file.
}
...
...
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