Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
44b9e9be
Commit
44b9e9be
authored
8 years ago
by
git
Committed by
MegaChriz
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #2655470 by alan-ps, Louis Delacretaz: Added a timezone target to the user processor.
parent
b35a9fee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugins/FeedsUserProcessor.inc
+13
-0
13 additions, 0 deletions
plugins/FeedsUserProcessor.inc
tests/feeds/users.csv
+6
-6
6 additions, 6 deletions
tests/feeds/users.csv
tests/feeds_processor_user.test
+42
-0
42 additions, 0 deletions
tests/feeds_processor_user.test
with
61 additions
and
6 deletions
plugins/FeedsUserProcessor.inc
+
13
−
0
View file @
44b9e9be
...
@@ -104,6 +104,11 @@ class FeedsUserProcessor extends FeedsProcessor {
...
@@ -104,6 +104,11 @@ class FeedsUserProcessor extends FeedsProcessor {
if
(
empty
(
$account
->
name
)
||
empty
(
$account
->
mail
)
||
!
valid_email_address
(
$account
->
mail
))
{
if
(
empty
(
$account
->
name
)
||
empty
(
$account
->
mail
)
||
!
valid_email_address
(
$account
->
mail
))
{
throw
new
FeedsValidationException
(
t
(
'User name missing or email not valid.'
));
throw
new
FeedsValidationException
(
t
(
'User name missing or email not valid.'
));
}
}
// Timezone validation.
if
(
!
empty
(
$account
->
timezone
)
&&
!
array_key_exists
(
$account
->
timezone
,
system_time_zones
()))
{
throw
new
FeedsValidationException
(
t
(
"Failed importing '@name'. User's timezone is not valid."
,
array
(
'@name'
=>
$account
->
name
)));
}
}
}
/**
/**
...
@@ -237,6 +242,10 @@ class FeedsUserProcessor extends FeedsProcessor {
...
@@ -237,6 +242,10 @@ class FeedsUserProcessor extends FeedsProcessor {
$this
->
rolesListSetTarget
(
$source
,
$target_user
,
$target_element
,
$value
,
$mapping
);
$this
->
rolesListSetTarget
(
$source
,
$target_user
,
$target_element
,
$value
,
$mapping
);
break
;
break
;
case
'timezone'
:
$target_user
->
timezone
=
$value
;
break
;
default
:
default
:
parent
::
setTargetElement
(
$source
,
$target_user
,
$target_element
,
$value
);
parent
::
setTargetElement
(
$source
,
$target_user
,
$target_element
,
$value
);
break
;
break
;
...
@@ -277,6 +286,10 @@ class FeedsUserProcessor extends FeedsProcessor {
...
@@ -277,6 +286,10 @@ class FeedsUserProcessor extends FeedsProcessor {
'name'
=>
t
(
'User language'
),
'name'
=>
t
(
'User language'
),
'description'
=>
t
(
'Default language for the user.'
),
'description'
=>
t
(
'Default language for the user.'
),
),
),
'timezone'
=>
array
(
'name'
=>
t
(
'Timezone'
),
'description'
=>
t
(
'The timezone identifier, like UTC or Europe/Lisbon.'
),
),
'roles_list'
=>
array
(
'roles_list'
=>
array
(
'name'
=>
t
(
'User roles'
),
'name'
=>
t
(
'User roles'
),
'description'
=>
t
(
'User roles provided as role names in comma separated list.'
),
'description'
=>
t
(
'User roles provided as role names in comma separated list.'
),
...
...
This diff is collapsed.
Click to expand it.
tests/feeds/users.csv
+
6
−
6
View file @
44b9e9be
name,mail,since,password,password_md5,password_sha512
name,mail,since,password,password_md5,password_sha512
,timezone
Morticia,morticia@example.com,1244347500,mort,e0108a7eb91670308fff8179a4785453,$S$DfuNE4ur7Jq8xVoJURGm8oMIYunKd366KQUE6akc3EXW/ym9ghpq
Morticia,morticia@example.com,1244347500,mort,e0108a7eb91670308fff8179a4785453,$S$DfuNE4ur7Jq8xVoJURGm8oMIYunKd366KQUE6akc3EXW/ym9ghpq
,UTC
Fester,fester@example.com,1241865600,fest,c8cce3815094f01f0ab774fd4f7a77d4,$S$DjJPqmjlWTIen0nQrG3a.vA71Vc0DqCpKuB.g9zmBMnGzIV6JxqH
Fester,fester@example.com,1241865600,fest,c8cce3815094f01f0ab774fd4f7a77d4,$S$DjJPqmjlWTIen0nQrG3a.vA71Vc0DqCpKuB.g9zmBMnGzIV6JxqH
,
Gomez,gomez@example.com,1228572000,gome,8a5346b9a510f1f698ab0062b71201ac,$S$Dv.EtHlTfnrxuWGLbe3cf31mD9MF6.4u2Z46M2o2dMGgQGzi7m/5
Gomez,gomez@example.com,1228572000,gome,8a5346b9a510f1f698ab0062b71201ac,$S$Dv.EtHlTfnrxuWGLbe3cf31mD9MF6.4u2Z46M2o2dMGgQGzi7m/5
,utc
Wednesday,wednesdayexample.com,1228347137,wedn,fefb673afaf531dbd78771976a150dc8,$S$DdPzksGh/c8UukipWagAhTzaqUp/eNHVPiC.x6URBQyA503Z41PI
Wednesday,wednesdayexample.com,1228347137,wedn,fefb673afaf531dbd78771976a150dc8,$S$DdPzksGh/c8UukipWagAhTzaqUp/eNHVPiC.x6URBQyA503Z41PI
,America/New_York
Pugsley,pugsley@example,1228260225,pugs,09189568a8ee4d0addf53d2f6e4847cd,$S$D1oUihjrYXr.4iesN8Sfw1rVRLdo188v0NRGgcNR/V09oIyYPYmZ
Pugsley,pugsley@example,1228260225,pugs,09189568a8ee4d0addf53d2f6e4847cd,$S$D1oUihjrYXr.4iesN8Sfw1rVRLdo188v0NRGgcNR/V09oIyYPYmZ
,Europe/Lisbon
This diff is collapsed.
Click to expand it.
tests/feeds_processor_user.test
+
42
−
0
View file @
44b9e9be
...
@@ -756,6 +756,48 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase {
...
@@ -756,6 +756,48 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase {
$this
->
feedsLoginUser
(
'Gomez'
,
'gome'
);
$this
->
feedsLoginUser
(
'Gomez'
,
'gome'
);
}
}
/**
* Tests mapping to timezone.
*/
public
function
testTimezoneTarget
()
{
// Set to update existing users.
$this
->
setSettings
(
'user_import'
,
'FeedsUserProcessor'
,
array
(
'update_existing'
=>
FEEDS_UPDATE_EXISTING
));
// Add mapping to timezone.
$this
->
addMappings
(
'user_import'
,
array
(
4
=>
array
(
'source'
=>
'timezone'
,
'target'
=>
'timezone'
,
),
));
// Create an account for Fester, to ensure that the timezone can be emptied.
user_save
(
drupal_anonymous_user
(),
array
(
'name'
=>
'Fester'
,
'mail'
=>
'fester@example.com'
,
'pass'
=>
'fest'
,
'status'
=>
1
,
'timezone'
=>
'Europe/Lisbon'
,
));
// Import CSV file.
$this
->
importFile
(
'user_import'
,
$this
->
absolutePath
()
.
'/tests/feeds/users.csv'
);
// Assert that Morticia got the UTC timezone.
$account
=
user_load_by_name
(
'Morticia'
);
$this
->
assertEqual
(
'UTC'
,
$account
->
timezone
,
'Morticia has the UTC timezone.'
);
// Assert that Fester did not get any timezone.
$account
=
user_load_by_name
(
'Fester'
);
$this
->
assertFalse
(
$account
->
timezone
,
'Fester does not have any timezone'
);
// Assert that Gomez doesn't exist after import and appropriate message is
// displayed.
$account
=
user_load_by_name
(
'Gomez'
);
$this
->
assertFalse
(
$account
,
"Gomez doesn't exist after import."
);
$this
->
assertText
(
"Failed importing 'Gomez'. User's timezone is not valid."
);
}
/**
/**
* Log in an imported user.
* Log in an imported user.
*
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment