Tripal Plant PopGen Submit
front.php
Go to the documentation of this file.
1 <?php
2 
27 function tpps_front_create_form(array &$form, array $form_state) {
28 
29  global $base_url;
30  global $user;
31 
32  $image_path = drupal_get_path('module', 'tpps') . '/images/';
33  $prefix_text = "<div><figure style=\"text-align:center;\"><img style=\"max-height:100%;max-width:100%;\" src=\"{$image_path}TPPS-1.png\"></figure>";
34  $prefix_text .= "<div id=\"landing-buttons\">";
35  $prefix_text .= "<a href=\"https://tpps.readthedocs.io/en/latest/\" target=\"blank\" class=\"landing-button\"><button type=\"button\" class=\"btn btn-primary\">TPPS Documentation</button></a>";
36  $prefix_text .= "<a href=\"$base_url/tpps/details\" target=\"blank\" class=\"landing-button\"><button type=\"button\" class=\"btn btn-primary\">TPPS Studies</button></a>";
37  if (module_exists('cartogratree')) {
38  $prefix_text .= "<a href=\"$base_url/ct\" target=\"blank\" class=\"landing-button\"><button type=\"button\" class=\"btn btn-primary\">CartograPlant</button></a>";
39  }
40  $prefix_text .= "</div></div>";
41 
42 
43  if(!isset($user->mail)) {
44  $prefix_text .= "<div style='text-align: center'>To begin submitting your data, please ensure that you're logged in to access upload features on this page.</div>";
45  $prefix_text .= "<div style='text-align: center'>If you do not have an account <a style='color: #e2b448;' href='/user/register'>register one here</a> or <a style='color: #e2b448' href='/user/login'>click here to login</a></div>";
46  }
47 
48  $form['description'] = array(
49  '#markup' => $prefix_text,
50  );
51 
52 
53  if (isset($user->mail)) {
54  // Logged in.
55  $options_arr = array();
56  $options_arr['new'] = 'Create new TPPS Submission';
57 
58  $states = tpps_load_submission_multiple(array(
59  'status' => 'Incomplete',
60  'uid' => $user->uid,
61  ));
62 
63  foreach ($states as $state) {
64  if (empty($state['tpps_type']) or $state['tpps_type'] != 'tppsc') {
65  if ($state != NULL and isset($state['saved_values'][TPPS_PAGE_1]['publication']['title'])) {
66  $title = ($state['saved_values'][TPPS_PAGE_1]['publication']['title'] != NULL) ? $state['saved_values'][TPPS_PAGE_1]['publication']['title'] : "No Title";
67  $tgdr_id = $state['accession'];
68  $options_arr["$tgdr_id"] = "$title";
69  }
70  else {
71  if (isset($state) and !isset($state['saved_values'][TPPS_PAGE_1])) {
72  tpps_delete_submission($state['accession'], FALSE);
73  }
74  }
75  }
76  }
77 
78  if (count($options_arr) > 1) {
79  // Has submissions.
80  $form['accession'] = array(
81  '#type' => 'select',
82  '#title' => t('Would you like to load an old TPPS submission, or create a new one?'),
83  '#options' => $options_arr,
84  '#default_value' => isset($form_state['saved_values']['frontpage']['accession']) ? $form_state['saved_values']['frontpage']['accession'] : 'new',
85  );
86  }
87  }
88 
89  if (tpps_access('administer tpps module')) {
90  $form['custom_accession_check'] = array(
91  '#type' => 'checkbox',
92  '#title' => t('I would like to use a custom accession number'),
93  '#description' => t('Specify a custom accession number. This feature is available only to users with administrative access, and is generally not required or recommended.'),
94  );
95 
96  $form['custom_accession'] = array(
97  '#type' => 'textfield',
98  '#title' => t('Custom Accession number'),
99  '#states' => array(
100  'visible' => array(
101  ':input[name="custom_accession_check"]' => array('checked' => TRUE),
102  ),
103  ),
104  '#description' => t('Use this field to specify a custom accession number. Must be of the format TGDR###'),
105  );
106  }
107 
108  if (isset($user->mail)) {
109  $form['Next'] = array(
110  '#type' => 'submit',
111  '#value' => t('Submit Data'),
112  );
113  }
114 
115  return $form;
116 }
const TPPS_PAGE_1
Definition: tpps.module:12
tpps_front_create_form(array &$form, array $form_state)
Definition: front.php:27
tpps_access()
Definition: tpps.module:341
tpps_delete_submission($accession, $redirect=TRUE)
tpps_load_submission_multiple(array $conditions=array(), $state=TRUE)
Definition: submissions.inc:85