Go to the source code of this file.
|
| tpps_change_tgdr_number ($old_accession, $new_accession, TripalJob $job=NULL) |
|
| tpps_create_submission (array $state, $uid) |
|
| tpps_delete_submission ($accession, $redirect=TRUE) |
|
| tpps_get_tag_id ($name) |
|
| tpps_load_submission ($accession, $state=TRUE) |
|
| tpps_load_submission_multiple (array $conditions=array(), $state=TRUE) |
|
| tpps_submission_add_alternative_accession (array $state, $alt_accession) |
|
| tpps_submission_add_remove_tag ($type, $accession, $tag) |
|
| tpps_submission_add_tag ($accession, $tag) |
|
| tpps_submission_clear_db ($accession) |
|
| tpps_submission_clear_default_tags ($accession) |
|
| tpps_submission_edit_publication (array $form, array &$form_state, $accession=NULL) |
|
| tpps_submission_edit_publication_submit ($form, &$form_state) |
|
| tpps_submission_edit_publication_validate (&$form, &$form_state) |
|
| tpps_submission_get_tags ($accession) |
|
| tpps_submission_remove_tag ($accession, $tag) |
|
| tpps_submission_rename_files ($accession) |
|
| tpps_submission_tag_create (array $form, array &$form_state) |
|
| tpps_submission_tag_create_submit ($form, &$form_state) |
|
| tpps_submission_tag_create_validate (&$form, &$form_state) |
|
| tpps_submission_tag_edit (array $form, array &$form_state, $tag_id=NULL) |
|
| tpps_submission_tag_edit_submit ($form, &$form_state) |
|
| tpps_submission_tag_edit_validate (&$form, &$form_state) |
|
| tpps_submission_tag_manage () |
|
| tpps_submission_update_all_stats (array &$form_state) |
|
| tpps_submission_update_stats (array &$form_state) |
|
| tpps_update_submission (array $state, array $options=array()) |
|
Defines functions for manipulation of TPPS Submissions.
Definition in file submissions.inc.
◆ tpps_change_tgdr_number()
tpps_change_tgdr_number |
( |
|
$old_accession, |
|
|
|
$new_accession, |
|
|
TripalJob |
$job = NULL |
|
) |
| |
Changes the TGDR number of a study (and does resubmission)
- Parameters
-
string | $old_accession | The old accession number being submitted. |
string | $new_accession | The new accession number being submitted. |
TripalJob | $job | The TripalJob object for the submission job. |
Definition at line 157 of file submissions.inc.
158 $job->logMessage(
'[INFO] Clearing database for study ' . $old_accession);
159 $job->setInterval(1);
163 $job->logMessage(
'[INFO] Alter submission state data from ' . $old_accession .
' to ' . $new_accession);
166 $state = unserialize($submission->submission_state);
168 $job->logMessage(
'Original submission data for ' . $old_accession);
169 $job->logMessage(print_r($state,
true));
173 $state_json = json_encode($state);
176 $state_json = str_replace($old_accession,$new_accession,$state_json);
179 $state = json_decode($state_json,
true);
183 $job->logMessage(
'New submission data for ' . $new_accession);
184 $job->logMessage(print_r($state,
true));
193 $options[
'status'] =
'Approved';
194 $state[
'updated'] = time();
195 $options[
'submission_state'] = serialize($state);
197 db_update(
'tpps_submission')
199 ->condition(
'accession', $old_accession)
203 $job->logMessage(
'[INFO] Update tpps_submission table study ' . $old_accession .
' to ' . $new_accession);
205 $transaction = db_transaction();
207 chado_query(
'UPDATE tpps_submission SET accession = :new_accession WHERE accession = :old_accession', array(
208 ':new_accession' => $new_accession,
209 ':old_accession' => $old_accession
212 catch (\Exception $e) {
213 $transaction->rollback();
217 $job->logMessage(
'Completed! The next job in the queue should reimport the study data for ' . $new_accession);
tpps_submission_clear_db($accession)
tpps_load_submission($accession, $state=TRUE)
◆ tpps_create_submission()
tpps_create_submission |
( |
array |
$state, |
|
|
|
$uid |
|
) |
| |
This function creates a TPPS submission entry in the tpps_submission table.
- Parameters
-
array | $state | The form_state of the submission. |
int | $uid | The id of the user creating the submission. |
Definition at line 126 of file submissions.inc.
129 'status' =>
'Incomplete',
130 'accession' => $state[
'accession'],
131 'dbxref_id' => $state[
'dbxref_id'],
132 'submission_state' => serialize($state),
135 db_insert(
'tpps_submission')
139 if ((!isset($state[
'tpps_type']) or $state[
'tpps_type'] !=
'tppsc')) {
tpps_submission_add_tag($accession, $tag)
◆ tpps_delete_submission()
tpps_delete_submission |
( |
|
$accession, |
|
|
|
$redirect = TRUE |
|
) |
| |
This function deletes a TPPS Submission based on an accession number.
It also removes the submission record from the chado.dbxref table.
- Parameters
-
string | $accession | The accession number of the submission to delete. |
Definition at line 257 of file submissions.inc.
260 $dbxref_id = $submission->dbxref_id;
261 $state = unserialize($submission->submission_state);
262 db_delete(
'tpps_submission')
263 ->condition(
'accession', $accession)
265 if (empty($state[
'saved_values'][
'frontpage'][
'use_old_tgdr'])) {
266 db_delete(
'chado.dbxref')
267 ->condition(
'dbxref_id', $dbxref_id)
271 drupal_goto(
"user/{$user->uid}/tpps");
tpps_load_submission($accession, $state=TRUE)
◆ tpps_get_tag_id()
Returns the id of a tag based on the name.
- Parameters
-
string | $name | The name of the desired tag. |
- Returns
- int The id of the tag.
Definition at line 641 of file submissions.inc.
642 $result = db_select(
'tpps_tag',
't')
643 ->fields(
't', array(
'tpps_tag_id'))
644 ->condition(
'name', $name)
646 ->execute()->fetchObject();
649 return $result->tpps_tag_id;
◆ tpps_load_submission()
tpps_load_submission |
( |
|
$accession, |
|
|
|
$state = TRUE |
|
) |
| |
This function loads a TPPS Submission based on the provided accession number.
If the state option is set to false, this function will return the full tpps_submission table record for the submission. Otherwise, the function will return only the form_state of the submission. The state option defaults to True.
- Parameters
-
string | $accession | The accession number of the submission. |
bool | $state | An option to return only the state of the TPPS Submission. Default to True. |
stdClass $user The user trying to access the submission.
- Returns
- array|object The form_state of the TPPS Submission form.
Definition at line 27 of file submissions.inc.
28 $result = db_select(
'tpps_submission',
's')
30 ->condition(
'accession', $accession)
32 ->execute()->fetchObject();
36 return unserialize($result->submission_state);
42 $query = db_select(
'tpps_submission',
's');
43 $query->join(
'tpps_submission_dbxref',
's_dbx',
's.tpps_submission_id = s_dbx.tpps_submission_id');
44 $query->join(
'chado.dbxref',
'dbx',
'dbx.dbxref_id = s_dbx.dbxref_id');
46 $query->condition(
'dbx.accession', $accession);
47 $query->condition(
's.status',
'Approved');
49 $query = $query->execute();
50 $result = $query->fetchObject();
54 return unserialize($result->submission_state);
61 $state = variable_get(
'tpps_incomplete_' . $user->mail . $accession, NULL);
66 return variable_get(
'tpps_complete_' . $user->mail . $accession, NULL);
◆ tpps_load_submission_multiple()
tpps_load_submission_multiple |
( |
array |
$conditions = array() , |
|
|
|
$state = TRUE |
|
) |
| |
This function loads multiple TPPS submissions based on conditions.
Collects accessions based on conditions, then makes multiple calls to tpps_load_submission() to load all of the submissions that meet the conditions.
- Parameters
-
array | $conditions | The conditions that each TPPS submission must meet. |
bool | $state | An option to return only the state of the TPPS Submissions, default True. |
- Returns
- array An array of loaded TPPS submissions or their form_states.
Definition at line 85 of file submissions.inc.
86 $submissions = array();
87 $query = db_select(
'tpps_submission',
's')
90 if (!empty($conditions)) {
91 foreach ($conditions as $key => $cond) {
93 if (!is_array($cond)) {
94 $query->condition($key, $cond);
98 foreach ($cond as $item) {
99 $or->condition($key, $item);
101 $query->condition($or);
107 $results = $query->execute();
108 while (($result = $results->fetchObject())) {
110 $submissions[] = unserialize($result->submission_state);
113 $submissions[] = $result;
◆ tpps_submission_add_alternative_accession()
tpps_submission_add_alternative_accession |
( |
array |
$state, |
|
|
|
$alt_accession |
|
) |
| |
Updates alternative accessions of a TPPS Submission.
- Parameters
-
array | $state | The submission being updated. |
mixed | $alt_accession | The alternative accessions of the state. |
Definition at line 283 of file submissions.inc.
284 $tpps_local_db = variable_get(
'tpps_local_db');
285 if (!is_array($alt_accession)) {
286 $alt_accession = array($alt_accession);
292 db_delete(
'tpps_submission_dbxref')
293 ->condition(
'tpps_submission_id', $state_id)
296 foreach ($alt_accession as $acc) {
297 $dbx = chado_select_record(
'dbxref', array(
'*'), array(
298 'db_id' => $tpps_local_db->db_id,
301 $dbxref_id = current($dbx)->dbxref_id ?? NULL;
303 if (empty($dbxref_id)) {
304 $dbx = chado_insert_record(
'dbxref', array(
305 'db_id' => $tpps_local_db->db_id,
308 $dbxref_id = $dbx[
'dbxref_id'];
311 db_insert(
'tpps_submission_dbxref')
313 'tpps_submission_id' => $state_id,
314 'dbxref_id' => $dbxref_id,
tpps_load_submission($accession, $state=TRUE)
◆ tpps_submission_add_remove_tag()
tpps_submission_add_remove_tag |
( |
|
$type, |
|
|
|
$accession, |
|
|
|
$tag |
|
) |
| |
Edit submission tags.
- Parameters
-
string | $type | Either 'add' or 'remove'. |
string | $accession | The accession of the desired submission. |
mixed | $tag | The name or id of the tag to be added or removed. |
Definition at line 565 of file submissions.inc.
566 $result = db_select(
'tpps_tag',
't')
568 ->condition(
'tpps_tag_id', $tag)
570 ->execute()->fetchObject();
572 if ($result->static) {
573 drupal_goto(
'tpps-tag');
576 if ($type ==
'add') {
579 if ($type ==
'remove') {
tpps_submission_remove_tag($accession, $tag)
tpps_submission_add_tag($accession, $tag)
◆ tpps_submission_add_tag()
tpps_submission_add_tag |
( |
|
$accession, |
|
|
|
$tag |
|
) |
| |
Adds a tag to a submission.
- Parameters
-
string | $accession | The accession of the desired submission. |
mixed | $tag | The name or id of the tag to be added. |
Definition at line 592 of file submissions.inc.
593 if (gettype($tag) ==
'string') {
601 if (!array_key_exists($tag, $tags)) {
602 db_insert(
'tpps_submission_tag')
605 'tpps_tag_id' => $tag,
tpps_submission_get_tags($accession)
tpps_load_submission($accession, $state=TRUE)
◆ tpps_submission_clear_db()
tpps_submission_clear_db |
( |
|
$accession | ) |
|
Clears submission data from the database.
This function is particularly useful when submitting a study to the database multiple times. Note that Tripal Entities should be manually un-published after this process has completed.
- Parameters
-
string | $accession | The accession number of the submission. |
- Returns
- bool Returns TRUE if submission successfully cleared.
Definition at line 730 of file submissions.inc.
732 $state[
'file_rank'] = 0;
733 $project_id = $state[
'ids'][
'project_id'] ?? NULL;
734 if (empty($project_id)) {
737 if (empty($accession)) {
738 throw new Exception(
'Accession cannot be empty');
741 $stocks_sql =
"SELECT stock_id FROM chado.project_stock WHERE project_id = $project_id";
742 chado_query(
"UPDATE chado.project_dbxref SET is_current = FALSE WHERE project_id = $project_id");
743 chado_query(
"DELETE FROM chado.project_organism WHERE project_id = $project_id");
744 chado_query(
"DELETE FROM chado.project_pub WHERE project_id = $project_id");
745 chado_query(
"DELETE FROM chado.projectprop WHERE project_id = $project_id");
746 db_query(
"DELETE FROM public.tpps_project_file_managed WHERE project_id = $project_id");
747 chado_query(
"DELETE FROM chado.phenotype_cvterm WHERE phenotype_id IN (SELECT phenotype_id from chado.stock_phenotype WHERE stock_id in ($stocks_sql))");
748 chado_query(
"DELETE FROM chado.phenotype_to_synonym WHERE phenotype_id IN (SELECT phenotype_id FROM chado.stock_phenotype WHERE stock_id IN ($stocks_sql))");
749 chado_query(
"DELETE FROM chado.phenotype WHERE phenotype_id IN (SELECT phenotype_id FROM chado.stock_phenotype WHERE stock_id IN ($stocks_sql))");
750 chado_query(
"DELETE FROM chado.genotype_call WHERE project_id = $project_id");
751 chado_query(
"DELETE FROM chado.stock_genotype WHERE stock_id IN ($stocks_sql)");
752 chado_query(
"DELETE FROM chado.stock_phenotype WHERE stock_id IN ($stocks_sql)");
753 chado_query(
"DELETE FROM chado.stock WHERE stock_id IN ($stocks_sql)");
754 chado_query(
"DELETE FROM chado.phenotype WHERE uniquename LIKE '" . $accession .
"-%';");
755 echo
"FINISHED DB CLEAR DELETES\n";
759 if(strpos($accession,
'TGDR') !== FALSE && strlen($accession) >= 7) {
760 chado_query(
"DELETE FROM chado.stock WHERE uniquename LIKE :accession", [
761 ':accession' => $accession .
'%' 765 $state[
'ids'] = array(
'project_id' => $project_id);
tpps_update_submission(array $state, array $options=array())
tpps_load_submission($accession, $state=TRUE)
◆ tpps_submission_clear_default_tags()
tpps_submission_clear_default_tags |
( |
|
$accession | ) |
|
Removes default tags associated with a submission.
- Parameters
-
string | $accession | The accession of the desired submission. |
Definition at line 544 of file submissions.inc.
550 foreach ($tags as $tag) {
tpps_submission_remove_tag($accession, $tag)
◆ tpps_submission_edit_publication()
tpps_submission_edit_publication |
( |
array |
$form, |
|
|
array & |
$form_state, |
|
|
|
$accession = NULL |
|
) |
| |
Form to edit submission publication information.
- Parameters
-
array | $form | The form object to be populated. |
array | $form_state | The state of the form object to be populated. |
mixed | $accession | The accession of the submission being edited. |
- Returns
- array The populated form object.
Definition at line 873 of file submissions.inc.
877 $form[
'accession'] = array(
879 '#value' => $accession,
882 $form[
'status'] = array(
884 '#title' => t(
'Publication Status'),
886 0 => t(
'- Select -'),
887 'In Preparation or Submitted' => t(
'In Preparation or Submitted'),
888 'In Press' => t(
'In Press'),
889 'Published' => t(
'Published'),
891 '#default_value' => $state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'status'],
893 '#prefix' =>
"<a href=\"$base_url/tpps/details/$accession\">Back to TPPS Details Page</a>",
896 $year_options = array(0 =>
'- Select -');
897 for ($i = 1990; $i <= date(
'Y'); $i++) {
898 $year_options[$i] =
"$i";
901 $form[
'year'] = array(
903 '#title' => t(
'Year of Publication'),
904 '#options' => $year_options,
905 '#description' => t(
'If your publication has not been published yet, please choose the expected year of publication.'),
906 '#default_value' => $state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'year'],
910 $form[
'journal'] = array(
911 '#type' =>
'textfield',
912 '#title' => t(
'Journal'),
913 '#autocomplete_path' =>
'tpps/autocomplete/journal',
914 '#default_value' => $state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'journal'],
918 $form[
'submit'] = array(
920 '#value' => t(
'Submit'),
tpps_load_submission($accession, $state=TRUE)
◆ tpps_submission_edit_publication_submit()
tpps_submission_edit_publication_submit |
( |
|
$form, |
|
|
& |
$form_state |
|
) |
| |
Implements hook_form_submit().
Definition at line 941 of file submissions.inc.
942 $accession = $form_state[
'values'][
'accession'];
946 if ($state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'status'] != $form_state[
'values'][
'status']) {
947 $state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'status'] = $form_state[
'values'][
'status'];
951 if ($state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'year'] != $form_state[
'values'][
'year']) {
952 $state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'year'] = $form_state[
'values'][
'year'];
956 if ($state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'journal'] != $form_state[
'values'][
'journal']) {
957 $state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'journal'] = $form_state[
'values'][
'journal'];
962 module_load_include(
'php',
'tpps',
'forms/submit/submit_all');
965 $includes[] = module_load_include(
'php',
'tpps',
'forms/submit/submit_all');
966 $includes[] = module_load_include(
'inc',
'tpps',
'includes/file_parsing');
967 $args = array($accession);
968 $jid = tripal_add_job(
"Update Publication Information - $accession",
'tpps',
'tpps_submit_all', $args, $state[
'submitting_uid'], 10, $includes, TRUE);
969 $state[
'job_id'] = $jid;
tpps_update_submission(array $state, array $options=array())
tpps_load_submission($accession, $state=TRUE)
◆ tpps_submission_edit_publication_validate()
tpps_submission_edit_publication_validate |
( |
& |
$form, |
|
|
& |
$form_state |
|
) |
| |
Implements hook_form_validate().
Definition at line 929 of file submissions.inc.
930 if (empty($form_state[
'values'][
'status'])) {
931 form_set_error(
'status', t(
'Publication Status: field is required.'));
933 if (empty($form_state[
'values'][
'year'])) {
934 form_set_error(
'year', t(
'Publication Year: field is required.'));
◆ tpps_submission_get_tags()
tpps_submission_get_tags |
( |
|
$accession | ) |
|
Returns array of tags associated with a submission.
- Parameters
-
string | $accession | The accession of the desired submission. |
- Returns
- array Array of tags associated with the submission.
Definition at line 519 of file submissions.inc.
520 $query = db_select(
'tpps_submission_tag',
'st');
521 $query->join(
'tpps_submission',
's',
's.tpps_submission_id = st.tpps_submission_id');
522 $query->join(
'tpps_tag',
't',
't.tpps_tag_id = st.tpps_tag_id');
524 $query->condition(
's.accession', $accession);
525 $query = $query->execute();
527 while (($result = $query->fetchObject())) {
528 $results[$result->tpps_tag_id] = array(
529 'id' => $result->tpps_tag_id,
530 'name' => $result->name,
531 'color' => $result->color,
532 'static' => $result->static,
◆ tpps_submission_remove_tag()
tpps_submission_remove_tag |
( |
|
$accession, |
|
|
|
$tag |
|
) |
| |
Removes a tag from a submission.
- Parameters
-
string | $accession | The accession of the desired submission. |
mixed | $tag | The name or id of the tag to be removed. |
Definition at line 619 of file submissions.inc.
620 if (gettype($tag) ==
'string') {
626 db_delete(
'tpps_submission_tag')
628 ->condition(
'tpps_tag_id', $tag)
tpps_load_submission($accession, $state=TRUE)
◆ tpps_submission_rename_files()
tpps_submission_rename_files |
( |
|
$accession | ) |
|
Gives all files in an accession a standardized name.
- Parameters
-
string | $accession | The accession number of the submission to change file names. |
Definition at line 660 of file submissions.inc.
662 if (!empty($state[
'file_info'])) {
663 $state[
'files'] = array();
664 foreach ($state[
'file_info'] as $page_files) {
665 foreach ($page_files as $fid => $name) {
666 $state[
'files'][] = $fid;
667 if ($name ===
'#NO_RENAME') {
670 $old_file = file_load($fid);
671 if ($old_file->uri[0] !=
'/') {
672 $old_path = file_create_url($old_file->uri);
674 $file_load = file_load($fid);
676 if (!preg_match(
'/^(.*\/)(.*)$/', $new_name, $matches)) {
677 preg_match(
'/^(.*\/).*$/', $file->uri, $matches);
678 $new_filename = $matches[1] . $new_filename;
681 if ($new_filename !=
'') {
682 $result = db_query(
'SELECT f.fid 683 FROM {file_managed} f WHERE f.uri = :uri', array(
':uri' => $new_filename));
684 $record = $result->fetchObject();
688 $file = file_load($record->fid);
692 $file->status = FILE_STATUS_PERMANENT;
693 $file = file_save($file);
696 $new_path = file_create_url($file->uri);
697 chado_update_record(
'projectprop', array(
698 'project_id' => $state[
'ids'][
'project_id'],
699 'value' => $old_path,
701 'value' => $new_path,
704 if (!empty($state[
'revised_files'][$fid])) {
705 $rev_fid = $state[
'revised_files'][$fid];
706 $state[
'files'][] = $rev_fid;
708 $file->status = FILE_STATUS_PERMANENT;
tpps_update_submission(array $state, array $options=array())
tpps_get_path_extension($path)
tpps_load_submission($accession, $state=TRUE)
tpps_rename_file($fid, $new_name, array $options=array())
◆ tpps_submission_tag_create()
tpps_submission_tag_create |
( |
array |
$form, |
|
|
array & |
$form_state |
|
) |
| |
Form to create a new submission tag.
- Parameters
-
array | $form | The form object to be populated. |
array | $form_state | The state of the form object to be populated. |
- Returns
- array The populated form object.
Definition at line 383 of file submissions.inc.
386 drupal_add_js(
'https://cdnjs.cloudflare.com/ajax/libs/tinyColorPicker/1.1.1/jqColorPicker.min.js',
'external');
387 drupal_add_js(drupal_get_path(
'module',
'tpps') .
'/js/tag_colorpicker.js');
389 $form[
'name'] = array(
390 '#type' =>
'textfield',
391 '#title' => t(
'Name'),
392 '#description' => t(
'The name of the new tag'),
394 '#prefix' =>
'<a href="/tpps-tag">Back to TPPS Submission Tags page</a>',
397 $form[
'color'] = array(
398 '#type' =>
'textfield',
399 '#title' => t(
'Color'),
400 '#description' => t(
'The color of the new tag. Can be the name of a color, like "red" or "blue", or can be a hexidecimal color like "#FFFFFF" or "#A2C32F". Hexidecimal colors must start with the "#" character.'),
402 '#suffix' =>
'<div id="color-picker"><a>Toggle Color Picker</a></div>',
405 $form[
'submit'] = array(
407 '#value' => t(
'Submit'),
◆ tpps_submission_tag_create_submit()
tpps_submission_tag_create_submit |
( |
|
$form, |
|
|
& |
$form_state |
|
) |
| |
Implements hook_form_submit().
Definition at line 430 of file submissions.inc.
431 db_insert(
'tpps_tag')
433 'name' => $form_state[
'values'][
'name'],
434 'color' => $form_state[
'values'][
'color'],
437 drupal_goto(
'tpps-tag');
◆ tpps_submission_tag_create_validate()
tpps_submission_tag_create_validate |
( |
& |
$form, |
|
|
& |
$form_state |
|
) |
| |
Implements hook_form_validate().
Definition at line 416 of file submissions.inc.
417 $result = db_select(
'tpps_tag',
't')
419 ->condition(
'name', $form_state[
'values'][
'name'],
'ILIKE')
421 ->execute()->fetchObject();
422 if (!empty($result)) {
423 form_set_error(
'name', t(
"A tag already exists with this name. Please select a different name or use the existing tag."));
◆ tpps_submission_tag_edit()
tpps_submission_tag_edit |
( |
array |
$form, |
|
|
array & |
$form_state, |
|
|
|
$tag_id = NULL |
|
) |
| |
Form to edit a submission tag.
- Parameters
-
array | $form | The form object to be populated. |
array | $form_state | The state of the form object to be populated. |
mixed | $tag_id | The id of the tag being edited. |
- Returns
- array The populated form object.
Definition at line 453 of file submissions.inc.
454 if (empty($tag_id)) {
455 drupal_goto(
'tpps-tag');
458 $tag = db_select(
'tpps_tag',
't')
460 ->condition(
'tpps_tag_id', $tag_id)
462 ->execute()->fetchObject();
464 if (empty($tag) or $tag->static) {
465 drupal_goto(
'tpps-tag');
470 $form[
'name'][
'#default_value'] = $tag->name;
471 $form[
'color'][
'#default_value'] = $tag->color;
tpps_submission_tag_create(array $form, array &$form_state)
◆ tpps_submission_tag_edit_submit()
tpps_submission_tag_edit_submit |
( |
|
$form, |
|
|
& |
$form_state |
|
) |
| |
Implements hook_form_submit().
Definition at line 499 of file submissions.inc.
500 db_update(
'tpps_tag')
502 'name' => $form_state[
'values'][
'name'],
503 'color' => $form_state[
'values'][
'color'],
505 ->condition(
'tpps_tag_id', $form_state[
'values'][
'id'])
507 drupal_goto(
'tpps-tag');
◆ tpps_submission_tag_edit_validate()
tpps_submission_tag_edit_validate |
( |
& |
$form, |
|
|
& |
$form_state |
|
) |
| |
Implements hook_form_validate().
Definition at line 484 of file submissions.inc.
485 $result = db_select(
'tpps_tag',
't')
487 ->condition(
'name', $form_state[
'values'][
'name'],
'ILIKE')
488 ->condition(
'tpps_tag_id', $form_state[
'values'][
'id'],
'!=')
490 ->execute()->fetchObject();
491 if (!empty($result)) {
492 form_set_error(
'name', t(
"A tag already exists with this name. Please select a different name or use the existing tag."));
◆ tpps_submission_tag_manage()
tpps_submission_tag_manage |
( |
| ) |
|
Display TPPS submission tags.
- Returns
- string String of renderable HTML.
Definition at line 326 of file submissions.inc.
328 $query = db_select(
'tpps_tag',
't')
333 while (($result = $query->fetchObject())) {
334 $color = !empty($result->color) ? $result->color :
'white';
335 $edit_link = $result->static ?
"" :
"<a href=\"tpps-tag/edit/{$result->tpps_tag_id}\">edit</a>";
336 $rows[$result->tpps_tag_id] = array(
337 "<span class=\"tag\" style=\"background-color:$color\"><span class=\"tag-text\">{$result->name}</span></span>",
354 'attributes' => array(
355 'class' => array(
'view'),
356 'id' =>
'tpps_table_display',
364 $output = theme(
'table', $vars);
366 drupal_add_js(drupal_get_path(
'module',
'tpps') .
TPPS_JS_PATH);
367 drupal_add_css(drupal_get_path(
'module',
'tpps') .
TPPS_CSS_PATH);
◆ tpps_submission_update_all_stats()
tpps_submission_update_all_stats |
( |
array & |
$form_state | ) |
|
Updates all statistics for a TPPS Submission.
- Parameters
-
array | $form_state | The form_state of the submission being updated. |
Definition at line 776 of file submissions.inc.
777 for ($i = 1; $i <= 4; $i++) {
778 $form_state[
'values'] = $form_state[
'saved_values'][$i];
779 $form_state[
'stage'] = $i;
tpps_submission_update_stats(array &$form_state)
◆ tpps_submission_update_stats()
tpps_submission_update_stats |
( |
array & |
$form_state | ) |
|
Updates statistics for a TPPS Submission for one form step.
- Parameters
-
array | $form_state | The form_state of the submission being updated. |
Definition at line 790 of file submissions.inc.
791 switch ($form_state[
'stage']) {
793 $form_state[
'stats'][
'author_count'] = $form_state[
'values'][
'publication'][
'secondaryAuthors'][
'number'] + 1;
794 if (!empty($form_state[
'values'][
'publication'][
'secondaryAuthors'][
'check'])) {
795 $form_state[
'stats'][
'author_count'] =
tpps_file_len($form_state[
'values'][
'publication'][
'secondaryAuthors'][
'file']);
798 $form_state[
'stats'][
'species_count'] = $form_state[
'values'][
'organism'][
'number'];
802 if (empty($form_state[
'tpps_type']) or $form_state[
'tpps_type'] ==
'tpps') {
803 $start =
new DateTime(
"{$form_state['values']['StartingDate']['year']}-{$form_state['values']['StartingDate']['month']}");
804 $end =
new DateTime(
"{$form_state['values']['EndingDate']['year']}-{$form_state['values']['EndingDate']['month']}");
805 $dur = date_diff($start, $end);
806 $form_state[
'stats'][
'duration'] = $dur->format(
'%y years %m months');
811 $form_state[
'stats'][
'tree_count'] = 0;
812 for ($i = 1; $i <= $form_state[
'stats'][
'species_count']; $i++) {
813 $form_state[
'stats'][
'tree_count'] +=
tpps_file_len($form_state[
'values'][
'tree-accession'][
"species-$i"][
'file']);
814 $form_state[
'stats'][
'tree_count'] += $form_state[
'values'][
'tree-accession'][
"species-$i"][
'file-no-header'];
815 if ($form_state[
'stats'][
'species_count'] == 1 or empty($form_state[
'values'][
'tree-accession'][
'check'])) {
822 $form_state[
'stats'][
'phenotype_count'] = 0;
823 $form_state[
'stats'][
'unique_phenotypes'] = 0;
824 for ($i = 1; $i <= $form_state[
'stats'][
'species_count']; $i++) {
825 $phenotype = $form_state[
'values'][
"organism-$i"][
'phenotype'] ?? NULL;
826 $form_state[
'stats'][
'unique_phenotypes'] += $phenotype[
'phenotypes-meta'][
'number'] ?? 0;
827 if (!empty($phenotype[
'file']) and file_load($phenotype[
'file'])) {
828 $rows =
tpps_file_len($phenotype[
'file']) + !empty($phenotype[
'file-no-header']);
829 if ($phenotype[
'format'] == 0) {
830 $phenotype_file_name_cols = $phenotype[
'file-groups'][
'Phenotype Data'][
'0'];
831 $form_state[
'stats'][
'phenotype_count'] += $rows * count($phenotype_file_name_cols);
834 $form_state[
'stats'][
'phenotype_count'] += $rows;
837 if (!empty($phenotype[
'metadata']) and file_load($phenotype[
'metadata'])) {
838 $form_state[
'stats'][
'unique_phenotypes'] +=
tpps_file_len($phenotype[
'metadata']) + !empty($phenotype[
'metadata-no-header']);
843 if (!empty($phenotype[
'iso']) and file_load($phenotype[
'iso'])) {
845 while (($k = array_search(NULL, $headers))) {
848 $num_unique_columns = count(array_unique($headers)) - 1;
850 $form_state[
'stats'][
'phenotype_count'] += $rows * $num_unique_columns;
tpps_file_headers($fid, $no_header=FALSE)
◆ tpps_update_submission()
tpps_update_submission |
( |
array |
$state, |
|
|
array |
$options = array() |
|
) |
| |
This function updates the form_state of a submission.
Additional attributes of the submission record can be updated by populating the options parameter.
- Parameters
-
array | $state | The form_state of the submission. |
array | $options | Additional submission attributes to update. |
Definition at line 231 of file submissions.inc.
232 if (empty($options[
'status']) and !empty($state[
'status'])) {
233 $options[
'status'] = $state[
'status'];
235 $state[
'updated'] = time();
236 $options[
'submission_state'] = serialize($state);
243 db_update(
'tpps_submission')
245 ->condition(
'accession', $state[
'accession'])