### Eclipse Workspace Patch 1.0 #P FeedsPatch Index: sites/all/modules/feeds/plugins/FeedsNodeProcessor.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/plugins/FeedsNodeProcessor.inc,v retrieving revision 1.20 diff -u -r1.20 FeedsNodeProcessor.inc --- sites/all/modules/feeds/plugins/FeedsNodeProcessor.inc 21 Dec 2009 01:20:05 -0000 1.20 +++ sites/all/modules/feeds/plugins/FeedsNodeProcessor.inc 28 Dec 2009 22:00:39 -0000 @@ -18,7 +18,23 @@ // Count number of created and updated nodes. $created = $updated = 0; - + + //The user id to assign to FeedItems + $feed_item_uid = 0; + //If Feed is not attached to a Node or inherit author not set assign user + //based on the explicit author setting + if (($source->feed_nid=='0')||$this->config['inherit_author']==0){ + //Load the user object based on the user name + $assigned_user = user_load(array('name' => $this->config['explicit_author'])); + $feed_item_uid = $assigned_user->uid; + } + //If Feed is attached to a Node check whether user asked for Feed Items to + //inherit from Feed node author + elseif ($this->config['inherit_author']==1){ + $author_source_node = node_load((int)$source->feed_nid); + $feed_item_uid = $author_source_node->uid; + } + while ($item = $batch->shiftItem()) { // Create/update if item does not exist or update existing is enabled. @@ -60,8 +76,8 @@ // Populate properties that are set by node_object_prepare(). $node->log = 'Created/updated by FeedsNodeProcessor'; - $node->uid = 0; + $node->uid=$feed_item_uid; // Execute mappings from $item to $node. $this->map($item, $node); @@ -150,8 +166,10 @@ 'content_type' => $type, 'update_existing' => 0, 'expire' => FEEDS_EXPIRE_NEVER, + 'explicit_author'=>'anonymous', + 'inherit_author' => 1, 'mappings' => array(), - ); + ); } /** @@ -181,6 +199,24 @@ '#description' => t('Select after how much time nodes should be deleted. The node\'s published date will be used for determining the node\'s age, see Mapping settings.'), '#default_value' => $this->config['expire'], ); + $form['node_author'] = array( + '#type' => 'fieldset', + '#title' => t('Feed Results Author'), + ); + $form['node_author']['explicit_author'] = array( + '#type' => 'textfield', + '#title' => t('Author for created nodes'), + '#description' => t('Explicitly set the user that will be set as author of nodes'), + '#autocomplete_path' => 'user/autocomplete', + '#default_value' => $this->config['explicit_author'], + ); + $form['node_author']['inherit_author'] = array( + '#type' => 'checkbox', + '#title' => t('Inherit from node'), + '#description' => t('Inherit author from node Feed is attached to (only applicable if Feed attached to Node)'), + '#default_value' => $this->config['inherit_author'], + ); + return $form; }