--- author_taxonomy.module 2008-04-11 19:12:27.000000000 -0400 +++ author_taxonomy_new.module 2008-06-20 14:50:53.000000000 -0400 @@ -54,6 +54,13 @@ function author_taxonomy_admin_settings( '#description' => t('The taxonomy to use for content authors.'), ); + $form['author_taxonomy_overwrite_node'] = array( + '#type' => 'checkbox', + '#title' => t('Overwrite Real Node Author'), + '#default_value' => variable_get('author_taxonomy_overwrite_node', FALSE), + '#description' => t('Check this box to overwrite the real author of the node with an author corresponding to your taxonomy author term. Note that this will work best if you are not allowing multiple values in your taxonomy as only one author can be assigned. Should you choose to allow multiple values, the first author in your taxonomy list will be used. IMPORTANT: If you turn this box on, you should make sure that the "authors" you are adding to your taxonomy match EXACTLY with usernames. If a match isn\'t found, the previous author will remain intact.'), + ); + $form['author_taxonomy_prepend_node'] = array( '#type' => 'checkbox', '#title' => t('Automatically add output to the beginning of the node'), @@ -115,6 +122,24 @@ function author_taxonomy_nodeapi(&$node, $node->content['body']['#value'] = author_taxonomy_output($node) . "\n" . $node->content['body']['#value']; } break; + + // The following case added by sw9 + case 'submit': + $display = variable_get('author_taxonomy_overwrite_node', TRUE); + if ($display) { + $author_tids = taxonomy_node_get_terms_by_vocabulary($node->nid, variable_get('author_taxonomy_vocab', 1)); + $author_names = array(); + foreach ($author_tids as $tid => $term) { + $author_name[] = $term->name; + } + $instance_info = db_fetch_array(db_query("SELECT uid, name FROM {users} WHERE name = '%s'", $author_name[0])); + if($instance_info){ + $node->nid = $node->nid; + $node->uid = $instance_info['uid']; + $node->name = $instance_info['name']; + } + } + break; } }