? 652180-55_assign_author.patch ? feeds-standalone-assignuser1.patch ? libraries/PuSHSubscriber ? libraries/simplepie.inc Index: plugins/FeedsNodeProcessor.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/plugins/FeedsNodeProcessor.inc,v retrieving revision 1.35 diff -u -p -r1.35 FeedsNodeProcessor.inc --- plugins/FeedsNodeProcessor.inc 19 Jun 2010 15:57:13 -0000 1.35 +++ plugins/FeedsNodeProcessor.inc 19 Jun 2010 16:42:48 -0000 @@ -60,7 +60,7 @@ class FeedsNodeProcessor extends FeedsPr // 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 FeedsPr 'update_existing' => 0, 'expire' => FEEDS_EXPIRE_NEVER, 'mappings' => array(), + 'author' => 0, ); } @@ -188,6 +189,14 @@ class FeedsNodeProcessor extends FeedsPr '#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', @@ -206,6 +215,18 @@ class FeedsNodeProcessor extends FeedsPr } /** + * 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. */ public function setTargetElement($target_node, $target_element, $value) { Index: tests/feeds.test =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/tests/feeds.test,v retrieving revision 1.16 diff -u -p -r1.16 feeds.test --- tests/feeds.test 16 May 2010 21:35:08 -0000 1.16 +++ tests/feeds.test 19 Jun 2010 16:42:48 -0000 @@ -100,6 +100,7 @@ class FeedsRSStoNodesTest extends FeedsW // Assert accuracy of aggregated information. $this->drupalGet('node'); + $this->assertPattern('/(.*?)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 FeedsW $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('/(.*?)'. 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.