I noticed when debugging that selecting 'Web Article' (or presumably anything) from the drop down box calls nodeapi($node->type='biblio', $op='validate') with $node->op='Populate using DOI'
I tried getting aroudn this but could not.
When I have a missing required field I get the appropriate form validation errors from the biblio node. However, when I fill in those fields, only the $op=validate is getting called, with no raised errors.
function auto_biblio_entry_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){
if($node->type == 'biblio' && $op == 'validate'){
// print "validating biblio:<br /><pre>"; print_r($node); print "</pre>";
}
if( $op == 'insert' && in_array($node->type, variable_get('auto_biblio_entry_types', array() ) ) ){
global $base_url;
$bib_node = array(
'uid' => (string) $node->uid,
'name' => (string) $user->name,
'type' => 'biblio',
'language' => '',
'body' => NULL,
'title' => $node->title,
'format' => NULL,
'status' => true,
'promote' => false,
'sticky' => false,
'created' => time(),
'revision' => false,
'comment' => '0',
);
$bib_node = (object) $bib_node;
// $bib_node->uid = $node->uid;
module_load_include('inc', 'node', 'node.pages');
$values = array();
// $values['op'] = t('Populate using DOI');
$values['biblio_type'] = "107";
$values['title'] = $node->title;
$form_state = array();
$values['biblio_year'] = date('Y', $node->created);
$form_state['values'] = $values;
// drupal_execute('biblio_node_form', $form_state, $bib_node);
$x = 0;
foreach($node->field_author_reference as $author){
dpm($x . " time through");
$values['biblio_contributors'] = array(
'1' => array(
"$x" => array(
'name' => _auto_biblio_entry_author_name($author['uid']),
'auth_type' => 1,
'cid' => null,
'rank' => $x,
),
),
);
$x = $x + 1;
}
$values['biblio_publisher'] = "Solutions";
$values['biblio_type'] = "107";
$values['biblio_abst_e'] = $node->field_abstract[0]['value'];
$values['biblio_url'] = $base_url . '/node/' . $node->nid;
$values['biblio_type_name'] = t('Web Article');
$values['name'] = $node->name;
/* $values['doi_data'];
$values['paste_data']; */
$values['op'] = t('Save');
$form_state = array();
$form_state['values'] = $values;
drupal_set_message("creating bib after feat");
dpm($form_state);
drupal_execute('biblio_node_form', $form_state, $bib_node);
$errors = form_get_errors();
dpm($errors);
if (count($errors)){
drupal_set_message("A biblio node may not have been created");
}
}
}
Comments
Comment #1
rjerome commentedsee http://drupal.org/node/635614