function biblio_crossref_form_biblio_node_form_submit in Bibliography Module 7
Same name and namespace in other branches
- 7.2 modules/crossref/biblio_crossref.module \biblio_crossref_form_biblio_node_form_submit()
1 string reference to 'biblio_crossref_form_biblio_node_form_submit'
- biblio_crossref_form_biblio_node_form_alter in modules/
crossref/ biblio_crossref.module
File
- modules/
crossref/ biblio_crossref.module, line 60
Code
function biblio_crossref_form_biblio_node_form_submit($form, &$form_state) {
global $user;
$node_data = array();
if (strlen($doi = $form_state['values']['doi_data'])) {
if (($doi_start = strpos($form_state['values']['doi_data'], '10.')) !== FALSE) {
if (!($dup = biblio_crossref_check_doi($doi))) {
$crossref_pid = variable_get('biblio_crossref_pid', '');
$user_pid = isset($user->data['biblio_crossref_pid']) && !empty($user->data['biblio_crossref_pid']) ? $user->data['biblio_crossref_pid'] : '';
if (variable_get('biblio_show_crossref_profile_form', '1') && !empty($user_pid)) {
$crossref_pid = $user_pid;
}
if (empty($crossref_pid)) {
form_set_error('doi_data', l(t('You need to register with CrossRef'), 'http://www.crossref.org/requestaccount/', array(
'attributes' => array(
'target' => '_blank',
),
'absolue' => TRUE,
)) . ' ' . t('and then enter your CrossRef UserID in the "<i>CrossRef Login Information</i>" section of your account profile !url', array(
'!url' => l(t('here...'), "user/{$user->uid}/edit"),
)));
return;
}
module_load_include('php', 'biblio_crossref', 'biblio.crossref.client');
$client = new BiblioCrossRefClient($doi, $crossref_pid);
$node_data = $client
->fetch();
if (!empty($node_data)) {
$form_state['values'] = array_merge($form_state['values'], $node_data);
$form_state['input']['biblio_type'] = $form_state['biblio_type'] = $node_data['biblio_type'];
}
else {
form_set_error('doi_data', '');
}
}
else {
$message = t('The DOI that you are trying to import already exists in the database, see !url', array(
'!url' => l('node/' . $dup, 'node/' . $dup),
));
form_set_error('doi_data', $message);
}
}
else {
form_set_error('doi_data', t('This does not appear to be a valid DOI name, it should start with "10."'));
}
}
$form_state['rebuild'] = TRUE;
}