Implements hook_form_submit().
Either rejects or approves the TPPS submission, and notifies the user of the status update via email. If the submission was approved, starts a tripal job for file parsing.
1152 $type = $form_state[
'tpps_type'] ??
'tpps';
1153 $type_label = ($type ==
'tpps') ?
'TPPS' :
'TPPSC';
1155 $accession = $form_state[
'values'][
'accession'];
1157 $owner = user_load($submission->uid);
1159 $state = unserialize($submission->submission_state);
1160 $state[
'admin_comments'] = $form_state[
'values'][
'admin-comments'] ?? NULL;
1163 $from = variable_get(
'site_mail',
'');
1164 $params[
'subject'] =
"$type_label Submission Rejected: {$state['saved_values'][TPPS_PAGE_1]['publication']['title']}";
1165 $params[
'uid'] = $owner->uid;
1166 $params[
'reject-reason'] = $form_state[
'values'][
'reject-reason'] ?? NULL;
1167 $params[
'base_url'] = $base_url;
1168 $params[
'title'] = $state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'title'];
1169 $params[
'body'] =
'';
1171 $params[
'headers'][] =
'MIME-Version: 1.0';
1172 $params[
'headers'][] =
'Content-type: text/html; charset=iso-8859-1';
1174 if (isset($form_state[
'values'][
'params'])) {
1175 foreach ($form_state[
'values'][
'params'] as $param_id => $type) {
1176 variable_set(
"tpps_param_{$param_id}_type", $type);
1180 switch ($form_state[
'triggering_element'][
'#value']) {
1181 case 'Save VCF Import Setting':
1183 if($form_state[
'values'][
'DISABLE_VCF_IMPORT'] == 1) {
1184 $state[
'saved_values'][
TPPS_PAGE_1][
'disable_vcf_import'] = 1;
1187 $state[
'saved_values'][
TPPS_PAGE_1][
'disable_vcf_import'] = 0;
1190 drupal_set_message(t(
'VCF disable import setting saved'),
'status');
1193 case "Remove this study's markers and genotypes":
1195 $includes = array();
1196 # $includes[] = module_load_include('php', 'tpps', 'forms/submit/submit_all'); 1197 $includes[] = module_load_include(
'inc',
'tpps',
'includes/markers_genotypes_utils');
1198 $args = array($accession);
1199 $jid = tripal_add_job(
"TPPS REMOVE all study markers and genotypes - $accession",
'tpps',
'tpps_remove_all_markers_genotypes', $args, $user->uid, 10, $includes, TRUE);
1203 case "Change TGDR number":
1207 if(!is_numeric($form_state[
'values'][
'CHANGE_TGDR_NUMBER'])) {
1208 drupal_set_message(t(
'You did not enter a valid number. Operation aborted.'));
1212 $new_accession =
'TGDR' . $form_state[
'values'][
'CHANGE_TGDR_NUMBER'];
1215 $results = chado_query(
'SELECT count(*) as c1 FROM public.tpps_submission WHERE accession = :new_accession', array(
1216 ':new_accession' => $new_accession
1218 $result_object = $results->fetchObject();
1220 $result_count = $result_object->c1;
1221 if($result_count > 0) {
1222 drupal_set_message(t(
'It seems the TGDR number you wanted to change to is already in use. Operation aborted due to safety concerns.'));
1229 $includes = array();
1230 # $includes[] = module_load_include('php', 'tpps', 'forms/submit/submit_all'); 1231 $includes[] = module_load_include(
'inc',
'tpps',
'includes/markers_genotypes_utils');
1232 $includes[] = module_load_include(
'inc',
'tpps',
'includes/submissions');
1233 $args = [$accession];
1235 $jid = tripal_add_job(
"TPPS REMOVE all study markers and genotypes - $accession",
'tpps',
'tpps_remove_all_markers_genotypes', $args, $user->uid, 10, $includes, TRUE);
1238 $args = [$accession, $new_accession];
1239 $jid = tripal_add_job(
"TPPS rename $accession to $new_accession",
'tpps',
'tpps_change_tgdr_number', $args, $user->uid, 10, $includes, TRUE);
1243 $includes[] = module_load_include(
'php',
'tpps',
'forms/submit/submit_all');
1244 $includes[] = module_load_include(
'inc',
'tpps',
'includes/file_parsing');
1245 $args = array($new_accession);
1246 $jid = tripal_add_job(
"TPPS Record Submission - $new_accession",
'tpps',
'tpps_submit_all', $args, $state[
'submitting_uid'], 10, $includes, TRUE);
1247 $state[
'job_id'] = $jid;
1251 case "Generate PopStruct FROM VCF":
1253 $includes = array();
1254 $includes[] = module_load_include(
'php',
'tpps',
'forms/submit/submit_all');
1257 if(!empty($state[
'saved_values'][4][
'organism-1'][
'genotype'][
'files'][
'vcf'])) {
1258 $vcf_fid = $state[
'saved_values'][4][
'organism-1'][
'genotype'][
'files'][
'vcf'];
1259 $vcf_file = file_load($vcf_fid);
1261 $args = array($accession,$location);
1263 $jid = tripal_add_job(
"TPPS Generate PopStruct FROM VCF - $accession",
'tpps',
'tpps_generate_popstruct', $args, $user->uid, 10, $includes, TRUE);
1266 drupal_set_message(
"Could not find a VCF tied to organism-1, are you sure you linked a VCF file?");
1270 case "Refresh TPPS cvterms cache":
1272 $includes = array();
1273 $includes[] = module_load_include(
'php',
'tpps',
'forms/submit/submit_all');
1274 $includes[] = module_load_include(
'inc',
'tpps',
'includes/cvterm_utils');
1276 $jid = tripal_add_job(
"TPPS REFRESH CVTERMS CACHE",
'tpps',
'tpps_cvterms_clear_cache', $args, $user->uid, 10, $includes, TRUE);
1280 case 'Change TPPS Type':
1282 if($form_state[
'values'][
'CHANGE_TPPS_TYPE'] ==
'tppsc') {
1285 $state[
'tpps_type'] =
'tppsc';
1288 'uid' => $user->uid,
1293 $state[
'tpps_type'] =
'tpps';
1296 drupal_set_message(t(
'Updated study TPPS type: ') . $state[
'tpps_type'],
'status');
1300 drupal_mail($type,
'user_rejected', $to, user_preferred_language($owner), $params, $from, TRUE);
1301 $state[
'status'] =
'Incomplete';
1303 drupal_set_message(t(
'Submission Rejected. Message has been sent to user.'),
'status');
1304 drupal_goto(
'<front>');
1308 module_load_include(
'php',
'tpps',
'forms/submit/submit_all');
1311 $state[
'submitting_uid'] = $uid;
1313 $params[
'subject'] =
"$type_label Submission Approved: {$state['saved_values'][TPPS_PAGE_1]['publication']['title']}";
1314 $params[
'accession'] = $state[
'accession'];
1315 drupal_set_message(t(
'Submission Approved! Message has been sent to user.'),
'status');
1316 drupal_mail($type,
'user_approved', $to, user_preferred_language(user_load_by_name($to)), $params, $from, TRUE);
1318 $state[
'revised_files'] = $state[
'revised_files'] ?? array();
1319 foreach ($state[
'file_info'] as $files) {
1320 foreach ($files as $fid => $file_type) {
1321 if (!empty($form_state[
'values'][
"edit_file_{$fid}_check"])) {
1322 $state[
'revised_files'][$fid] = $form_state[
'values'][
"edit_file_{$fid}_file"];
1327 if (!empty($form_state[
'values'][
'phenotypes_edit'])) {
1328 $state[
'phenotypes_edit'] = $form_state[
'values'][
'phenotypes_edit'];
1331 if (!empty($form_state[
'values'][
'study_location'])) {
1332 $state[
'saved_values'][
TPPS_PAGE_3][
'study_location'][
'type'] = $form_state[
'values'][
'study_location'][
'type'];
1333 for ($i = 1; $i <= $form_state[
'values'][
'study_location'][
'locations'][
'number']; $i++) {
1334 $state[
'saved_values'][
TPPS_PAGE_3][
'study_location'][
'locations'][$i] = $form_state[
'values'][
'study_location'][
'locations'][$i];
1338 $includes = array();
1339 $includes[] = module_load_include(
'php',
'tpps',
'forms/submit/submit_all');
1340 $includes[] = module_load_include(
'inc',
'tpps',
'includes/file_parsing');
1341 $args = array($accession);
1342 if ($state[
'saved_values'][
'summarypage'][
'release']) {
1343 $jid = tripal_add_job(
"$type_label Record Submission - $accession",
'tpps',
'tpps_submit_all', $args, $state[
'submitting_uid'], 10, $includes, TRUE);
1344 $state[
'job_id'] = $jid;
1347 $date = $state[
'saved_values'][
'summarypage'][
'release-date'];
1348 $time = strtotime(
"{$date['year']}-{$date['month']}-{$date['day']}");
1349 if (time() > $time) {
1350 $jid = tripal_add_job(
"$type_label Record Submission - $accession",
'tpps',
'tpps_submit_all', $args, $state[
'submitting_uid'], 10, $includes, TRUE);
1351 $state[
'job_id'] = $jid;
1354 $delayed_submissions = variable_get(
'tpps_delayed_submissions', array());
1355 $delayed_submissions[$accession] = $accession;
1356 variable_set(
'tpps_delayed_submissions', $delayed_submissions);
1357 $state[
'status'] =
'Approved - Delayed Submission Release';
1364 $state[
'saved_values'][
'summarypage'][
'release-date'] = $form_state[
'values'][
'date'];
1368 case 'Change Status':
1369 $state[
'status'] = $form_state[
'values'][
'state-status'];
1371 dpm($state[
'status']);
1374 case 'Save Alternative Accessions':
1375 $old_alt_acc = $state[
'alternative_accessions'] ??
'';
1376 $new_alt_acc = $form_state[
'values'][
'alternative_accessions'];
1377 if ($old_alt_acc != $new_alt_acc) {
1380 $state[
'alternative_accessions'] = $new_alt_acc;
1385 case 'Change Submission Owner':
1386 $new_user = user_load_by_mail($form_state[
'values'][
'change_owner']);
1387 $state[
'submitting_uid'] = $new_user->uid;
1389 'uid' => $new_user->uid,
tpps_submission_add_alternative_accession(array $state, $alt_accession)
tpps_update_submission(array $state, array $options=array())
tpps_load_submission($accession, $state=TRUE)
tpps_get_location($location)