Tripal Plant PopGen Submit
manage_doi.inc File Reference

Go to the source code of this file.

Functions

 tpps_manage_doi ($accession)
 

Detailed Description

Creates Page to generate or display TPPS DOIs.

Definition in file manage_doi.inc.

Function Documentation

◆ tpps_manage_doi()

tpps_manage_doi (   $accession)

This function creates a page to display the DOI of a TPPS submission.

If no DOI exists for the submission, one is automatically generated.

Parameters
string$accessionThe accession number of the TPPS submission.
Returns
string The HTML for the DOI page.

Definition at line 19 of file manage_doi.inc.

19  {
20  $output = "";
21 
22  $form_state = tpps_load_submission($accession);
23 
24  $token = variable_get('tpps_zenodo_api_key', NULL);
25  if (!empty($token) and empty($form_state['zenodo_id'])) {
26  $form_state['zenodo_id'] = tpps_generate_doi($accession)->id;
27  $doi_object = tpps_doi_publish($form_state['zenodo_id']);
28  tpps_update_submission($form_state);
29  $output .= "<h4>DOI successfully published!</h4>";
30  }
31  elseif (!empty($token) and !empty($form_state['zenodo_id'])) {
32  $doi_object = tpps_doi_load($form_state['zenodo_id']);
33  }
34 
35  if (empty($token) or empty($doi_object) or (isset($doi_object->status) and $doi_object->status != 200)) {
36  $output .= "<h4>Unable to load Zenodo DOI. There is likely a problem with the Zenodo API key. Please contact your system administrator.</h4>";
37  }
38  else {
39  $doi = $doi_object->doi;
40  $url = $doi_object->doi_url;
41  $badge = $doi_object->links->badge;
42  $output .= "DOI: <a target=\"blank\" href=\"$url\">$doi</a><br>"
43  . "DOI Badge: <a target=\"blank\" href=\"$badge\"><img src=\"$badge\"></a><br>";
44  }
45 
46  return render($output);
47 }
tpps_update_submission(array $state, array $options=array())
tpps_load_submission($accession, $state=TRUE)
Definition: submissions.inc:27
tpps_doi_publish($id)
Definition: zenodo.inc:225
tpps_doi_load($id)
Definition: zenodo.inc:247
tpps_generate_doi($accession)
Definition: zenodo.inc:20