| 
					
				 | 
			
			
				@@ -19,21 +19,6 @@ function tripal_jbrowse_mgmt_add_form($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return $form; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // Check to see if this is an edit form. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  $edit_form = FALSE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if (isset($form_state['build_info']['args'][0]) AND is_numeric($form_state['build_info']['args'][0])) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $instance_id = $form_state['build_info']['args'][0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $result = tripal_jbrowse_mgmt_get_instances(['id' => $instance_id]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if (!empty($result)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $instance = $result[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $edit_form = TRUE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      drupal_set_message('Unable to access the instance you would like to edit.', 'error'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      return $form; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $organisms = tripal_jbrowse_mgmt_get_organisms_list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $mapped_organisms = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   foreach ($organisms as $organism) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -44,12 +29,10 @@ function tripal_jbrowse_mgmt_add_form($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form_description = 'Create a new JBrowse instance for a given organism. Submitting this form 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   creates all the necessary files for a new JBrowse instance.'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if ($edit_form) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $form_description = 'Edit details regarding the current JBrowse instance.'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form['description_of_form'] = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#type' => 'item', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#markup' => t($form_description), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    '#weight' => -10, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form['organism'] = [ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -58,7 +41,7 @@ function tripal_jbrowse_mgmt_add_form($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#type' => 'select', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#options' => $mapped_organisms, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#required' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    '#default_value' => ($edit_form) ? $instance->organism_id : NULL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    '#weight' => -8, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form['analysis'] = [ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -72,13 +55,14 @@ function tripal_jbrowse_mgmt_add_form($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#title' => t('Description'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#description' => t('Optional description for the instance.'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#type' => 'textarea', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    '#default_value' => ($edit_form) ? $instance->description : NULL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    '#weight' => -7, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form['data'] = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#type' => 'fieldset', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#title' => t('Reference Sequence File'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#collabsible' => FALSE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    '#weight' => 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form['data']['data_desc'] = [ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -92,7 +76,6 @@ function tripal_jbrowse_mgmt_add_form($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form['data']['ref_seq_file'] = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#type' => 'file', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#title' => t('Reference Sequence FASTA File'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    '#disabled' => ($edit_form) ? TRUE : FALSE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form['data']['ref_seq_path'] = [ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -101,7 +84,6 @@ function tripal_jbrowse_mgmt_add_form($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#description' => t( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       'This path will be ignored if a file is provided above. Ex: sites/default/files/file.fasta or /data/file.fasta' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    '#disabled' => ($edit_form) ? TRUE : FALSE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form['page'] = [ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -144,7 +126,6 @@ function tripal_jbrowse_mgmt_add_form($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       position 0, starting position of the gene, to a certain end point.</p>\r\n 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       <pre>     ctgA</pre>\r\n<p>Displays an arbitrary region from the ctgA 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       reference.</p>", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    '#default_value' => ($edit_form) ? tripal_jbrowse_mgmt_get_instance_property($instance_id, 'start-loc') : NULL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form['page']['start-tracks'] = [ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -155,16 +136,12 @@ function tripal_jbrowse_mgmt_add_form($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       each of which should correspond to the \"label\" element of the track 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       information dictionaries that are currently viewed in the viewing field.</p>\r\n 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       <pre>     DNA,knownGene,ccdsGene,snp131,pgWatson,simpleRepeat</pre>", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    '#default_value' => ($edit_form) ? tripal_jbrowse_mgmt_get_instance_property($instance_id, 'start-tracks') : NULL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  $button = 'Create New Instance'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if ($edit_form) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $button = 'Save Changes'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $form['submit'] = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     '#type' => 'submit', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    '#value' => $button, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    '#value' => 'Create New Instance', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    '#weight' => 10, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   return $form; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -187,36 +164,36 @@ function tripal_jbrowse_mgmt_add_form_validate($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $edit_form = TRUE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if (!$edit_form) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $file = $_FILES['files']['tmp_name']['ref_seq_file']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $local_file = isset($values['ref_seq_path']) ? $values['ref_seq_path'] : NULL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if (empty($file) && empty($local_file)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      form_set_error( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'ref_seq_file', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'Please provide a local file path or upload a new file.' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $file = $_FILES['files']['tmp_name']['ref_seq_file']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $local_file = isset($values['ref_seq_path']) ? $values['ref_seq_path'] : NULL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (empty($file) && empty($local_file)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    form_set_error( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'ref_seq_file', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'Please provide a local file path or upload a new file.' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  elseif (empty($file) && !empty($local_file)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (!file_exists($local_file)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      form_set_error('ref_seq_path', 'The file path provided does not exist.'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    elseif (empty($file) && !empty($local_file)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      if (!file_exists($local_file)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        form_set_error('ref_seq_path', 'The file path provided does not exist.'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $uploaded = tripal_jbrowse_mgmt_upload_file('ref_seq_file'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (!$uploaded) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      form_set_error('ref_seq_file', 'Unable to upload file'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $uploaded = tripal_jbrowse_mgmt_upload_file('ref_seq_file'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      if (!$uploaded) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        form_set_error('ref_seq_file', 'Unable to upload file'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $uploaded = tripal_jbrowse_mgmt_move_file($uploaded); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $form_state['values']['uploaded_file'] = $uploaded; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $uploaded = tripal_jbrowse_mgmt_move_file($uploaded); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $form_state['values']['uploaded_file'] = $uploaded; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   //  if selected organism already exist, analysis_id is required 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   //  also make sure organism+analysis does not exist 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $instances = tripal_jbrowse_mgmt_get_instances(['organism_id' => $organism]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+<<<<<<< HEAD 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   if (empty($values['analysis'])) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (!empty($instances)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       form_set_error( 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -224,6 +201,13 @@ function tripal_jbrowse_mgmt_add_form_validate($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         'A JBrowse instance for the selected organism already exists. Please choose one analysis for this instance.' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+======= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (!empty($instances)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    form_set_error( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'organism', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'A JBrowse instance for the selected organism already exists. You can edit the instance from the instances page.' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+>>>>>>> 7.x-3.x 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $values_analysis_id = tripal_jbrowse_mgmt_get_analysis_id_from_string($values['analysis']); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -265,40 +249,50 @@ function tripal_jbrowse_mgmt_add_form_submit($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $analysis_id = array_pop($match_analysis[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $description = isset($values['description']) ? $values['description'] : ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // Check if this is an add or edit form. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  $edit_form = FALSE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if (isset($form_state['build_info']['args'][0]) AND is_numeric($form_state['build_info']['args'][0])) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $instance_id = $form_state['build_info']['args'][0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $edit_form = TRUE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (empty($values['uploaded_file'])) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $file = $values['ref_seq_path']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $file = $values['uploaded_file']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if ($edit_form) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $organism = db_select('chado.organism', 'CO') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      ->fields('CO') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      ->condition('organism_id', $organism_id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      ->execute() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      ->fetchObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $title = tripal_jbrowse_mgmt_construct_organism_name($organism); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $organism = db_select('chado.organism', 'CO') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ->fields('CO') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ->condition('organism_id', $organism_id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ->execute() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ->fetchObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $data = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $instance_id = tripal_jbrowse_mgmt_create_instance( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       'organism_id' => $organism_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+<<<<<<< HEAD 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       'analysis_id' => $analysis_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       'title' => $title, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+======= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'title' => tripal_jbrowse_mgmt_construct_organism_name($organism), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+>>>>>>> 7.x-3.x 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       'description' => $description, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $success = tripal_jbrowse_mgmt_update_instance($instance_id, $data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'created_at' => time(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'file' => $file, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if ($success) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      drupal_set_message("Successfully updated $title JBrowse instance."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $form_state['redirect'] = 'admin/tripal/extension/tripal_jbrowse/management/instances'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      drupal_set_message('Failed to update the current instance!', 'error'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if ($instance_id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    drupal_set_message('Instance created successfully!'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $name = 'Create JBrowse instance for '; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $name .= tripal_jbrowse_mgmt_construct_organism_name($organism); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    tripal_add_job( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'tripal_jbrowse_mgmt', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'tripal_jbrowse_mgmt_create_instance_files', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      [$instance_id], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $user->uid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $form_state['redirect'] = "admin/tripal/extension/tripal_jbrowse/management/instances/$instance_id"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+<<<<<<< HEAD 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (empty($values['uploaded_file'])) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $file = $values['ref_seq_path']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -340,6 +334,10 @@ function tripal_jbrowse_mgmt_add_form_submit($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       drupal_set_message('Failed to create instance!', 'error'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+======= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    drupal_set_message('Failed to create instance!', 'error'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+>>>>>>> 7.x-3.x 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Now save the instance properties. 
			 |