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
ec7ed737
Commit
ec7ed737
authored
14 years ago
by
Alex Barth
Browse files
Options
Downloads
Patches
Plain Diff
#652180 ronald_istos, rjbrown99, et. al.: Assign author of imported nodes.
parent
dd9ef226
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.txt
+1
-0
1 addition, 0 deletions
CHANGELOG.txt
plugins/FeedsNodeProcessor.inc
+22
-1
22 additions, 1 deletion
plugins/FeedsNodeProcessor.inc
tests/feeds.test
+8
-3
8 additions, 3 deletions
tests/feeds.test
with
31 additions
and
4 deletions
CHANGELOG.txt
+
1
−
0
View file @
ec7ed737
...
...
@@ -3,6 +3,7 @@
Feeds 6.x 1.0 XXXXXXXXXXXXXXXXXXXX
----------------------------------
- #652180 ronald_istos, rjbrown99, et. al.: Assign author of imported nodes.
- #783098 elliotttf: Introduce hook_feeds_user_processor_targets_alter(), mapper
for user profile fields.
...
...
This diff is collapsed.
Click to expand it.
plugins/FeedsNodeProcessor.inc
+
22
−
1
View file @
ec7ed737
...
...
@@ -60,7 +60,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
// Populate properties that are set by node_object_prepare().
$node
->
log
=
'Created/updated by FeedsNodeProcessor'
;
$node
->
uid
=
0
;
$node
->
uid
=
$this
->
config
[
'author'
]
;
// Map and save nodes. If errors occur don't stop but report them.
try
{
...
...
@@ -172,6 +172,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
'update_existing'
=>
0
,
'expire'
=>
FEEDS_EXPIRE_NEVER
,
'mappings'
=>
array
(),
'author'
=>
0
,
);
}
...
...
@@ -188,6 +189,14 @@ class FeedsNodeProcessor extends FeedsProcessor {
'#options'
=>
$types
,
'#default_value'
=>
$this
->
config
[
'content_type'
],
);
$author
=
user_load
(
array
(
'uid'
=>
$this
->
config
[
'author'
]));
$form
[
'author'
]
=
array
(
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'Author'
),
'#description'
=>
t
(
'Author to be assigned to created nodes - leave empty to assign "anonymous".'
),
'#autocomplete_path'
=>
'user/autocomplete'
,
'#default_value'
=>
empty
(
$author
->
name
)
?
'anonymous'
:
check_plain
(
$author
->
name
),
);
$period
=
drupal_map_assoc
(
array
(
FEEDS_EXPIRE_NEVER
,
3600
,
10800
,
21600
,
43200
,
86400
,
259200
,
604800
,
604800
*
4
,
604800
*
12
,
604800
*
24
,
31536000
),
'feeds_format_expire'
);
$form
[
'expire'
]
=
array
(
'#type'
=>
'select'
,
...
...
@@ -205,6 +214,18 @@ class FeedsNodeProcessor extends FeedsProcessor {
return
$form
;
}
/**
* Override parent::configFormValidate().
*/
public
function
configFormValidate
(
&
$values
)
{
if
(
$author
=
user_load
(
array
(
'name'
=>
$values
[
'author'
])))
{
$values
[
'author'
]
=
$author
->
uid
;
}
else
{
$values
[
'author'
]
=
0
;
}
}
/**
* Override setTargetElement to operate on a target item that is a node.
*/
...
...
This diff is collapsed.
Click to expand it.
tests/feeds.test
+
8
−
3
View file @
ec7ed737
...
...
@@ -100,6 +100,7 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
// Assert accuracy of aggregated information.
$this
->
drupalGet
(
'node'
);
$this
->
assertPattern
(
'/<span class="submitted">(.*?)Anonymous<\/span>/'
);
$this
->
assertText
(
'Open Atrium Translation Workflow: Two Way Translation Updates'
);
$this
->
assertText
(
'Tue, 10/06/2009'
);
$this
->
assertText
(
'A new translation process for Open Atrium & integration with Localize Drupal'
);
...
...
@@ -172,12 +173,16 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
$count
=
db_result
(
db_query
(
"SELECT COUNT(*) FROM
{
feeds_node_item
}
"
));
$this
->
assertEqual
(
$count
,
0
,
'Accurate number of items in database.'
);
// Import again, we should find new content.
// Change author, import again.
$author
=
$this
->
drupalCreateUser
();
$this
->
setSettings
(
'syndication'
,
'FeedsNodeProcessor'
,
array
(
'author'
=>
$author
->
name
));
$this
->
drupalPost
(
'node/'
.
$nid
.
'/import'
,
array
(),
'Import'
);
$this
->
assertText
(
'Created 10 Story nodes.'
);
// Assert DB status, there should be 10 again.
$count
=
db_result
(
db_query
(
"SELECT COUNT(*) FROM
{
feeds_node_item
}
"
));
// Assert author.
$this
->
drupalGet
(
'node'
);
$this
->
assertPattern
(
'/<span class="submitted">(.*?)'
.
check_plain
(
$author
->
name
)
.
'<\/span>/'
);
$count
=
db_result
(
db_query
(
"SELECT COUNT(*) FROM
{
feeds_node_item
}
fi JOIN
{
node
}
n ON fi.nid = n.nid WHERE n.uid = %d"
,
$author
->
uid
));
$this
->
assertEqual
(
$count
,
10
,
'Accurate number of items in database.'
);
// Login with new user with only access content permissions.
...
...
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