### Eclipse Workspace Patch 1.0 #P feeds Index: plugins/FeedsUserProcessor.inc =================================================================== --- feeds/plugins/FeedsUserProcessor.inc (revision 202) +++ feeds/plugins/FeedsUserProcessor.inc (working copy) @@ -25,6 +25,12 @@ // Map item to a term. $account = $this->map($item); + + // Add attributes inherited from the source feed node to the node. + if ($source->feed_nid) { + $feed_node = node_load($source->feed_nid); + $this->inherit($feed_node, $account); + } // Check if user name and mail are set, otherwise continue. if (empty($account->name) || empty($account->mail) || !valid_email_address($account->mail)) { @@ -117,6 +123,7 @@ 'update_existing' => FALSE, 'status' => 1, 'mappings' => array(), + 'inherit' => array(), ); } @@ -152,6 +159,28 @@ '#description' => t('If an existing user is found for an imported user, replace it. Existing users will be determined using mappings that are a "unique target".'), '#default_value' => $this->config['update_existing'], ); + + $disabled = !feeds_importer($this->id)->config['content_type']; + $defaults = array(); + $options = array(); + foreach ($this->getInheritors() as $key => $info) { + $options[$key] = sprintf('%s', $info['description'], $info['name']); + $defaults[$key] = $disabled ? 0 : (isset($this->config['inherit'][$key]) ? $this->config['inherit'][$key] : 0); + } + + $description = $disabled ? + t('Only available for importers that are attached to a content type (Basic settings).') : + t('Copy one or more properties from the feed node to feed item nodes created by this importer.'); + + $form['inherit'] = array( + '#type' => 'checkboxes', + '#title' => t('Inherit from feed node'), + '#description' => $description, + '#default_value' => array_keys(array_filter($defaults)), + '#disabled' => $disabled, + '#options' => $options, + ); + return $form; } @@ -223,4 +252,28 @@ } return 0; } + + /** + * Invoke inheritors depending on configuration. + */ + protected function inherit($feed_node, $new_user) { + $inheritors = $this->getInheritors(); + foreach ($this->config['inherit'] as $key => $value) { + if ($value && function_exists($inheritors[$key]['callback'])) { + $inheritors[$key]['callback']($feed_node, $new_user); + } + } + } + + /** + * Get a list of available inheritors. + */ + protected function getInheritors() { + $inheritors = array(); + // Let other modules expose inheritors. + self::loadMappers(); + drupal_alter('feeds_user_processor_inheritors', $inheritors); + return $inheritors; + } + }