Esempio n. 1
0
 /**
  * Show Genes
  *
  * Display all genes in the database, or only genes beginning
  * with a certain letter.
  *
  * @param char First letter of desired gene
  */
 public function show_genes($f_letter = NULL)
 {
     redirect_all_nonmembers();
     $f_letter = ucfirst($f_letter);
     $data['title'] = $f_letter ? 'Genes - ' . $f_letter : 'Genes';
     $data['content'] = 'genes/genes';
     $data['genes'] = $this->genes_model->get_genes($f_letter);
     $data['letters'] = range('A', 'Z');
     $this->load->view($this->editor_layout, $data);
 }
Esempio n. 2
0
 /**
  * Submit changes
  * 
  * This has 2 different functions:
  *   1.) Save the variant confirmation selection, OR
  *   2.) Release all variant changes
  *
  * 1.) Saves the confirmation selection for variant change
  *     quality control.
  *
  * 2.) Releases all changes currently within the queue.
  * A backup is first created, then the changes are made, and finally
  * the changes are emptied from the queue.
  *
  * @author Sean Ephraim
  * @access public
  * @return void
  */
 public function submit_changes()
 {
     redirect_all_nonmembers();
     // Refuse access to wanderers
     if (!isset($_POST['save-changes']) && !isset($_POST['release-changes'])) {
         die("Hmmm... you must have wandered here by mistake.");
     }
     // Update confirmation status of all variants on this page
     $post = $this->input->post();
     $variants = isset($post['variants-on-this-page']) ? $post['variants-on-this-page'] : NULL;
     if (is_array($variants)) {
         foreach ($variants as $variant_id) {
             $old_review = $this->variations_model->get_variant_review_info($variant_id);
             $data['confirmed_for_release'] = TRUE;
             if (isset($post['unconfirmed-variants']) && array_search($variant_id, $post['unconfirmed-variants']) !== FALSE) {
                 // variant was found in list of unconfirmed variants
                 $data['confirmed_for_release'] = FALSE;
             }
             $this->variations_model->update_variant_review_info($variant_id, $data);
             // Log the activity if the review changed
             if (!empty($old_review) && $data['confirmed_for_release'] != (bool) $old_review->confirmed_for_release) {
                 $username = $this->ion_auth->user()->row()->username;
                 $variation = $this->db->get_where($this->tables['vd_queue'], array('id' => $variant_id))->row_array();
                 $gene = empty($variation['gene']) ? 'MISSING_GENE' : $variation['gene'];
                 $protein = empty($variation['hgvs_protein_change']) ? 'MISSING_PROTEIN_CHANGE' : $variation['hgvs_protein_change'];
                 $variation = empty($variation['variation']) ? 'MISSING_VARIATION' : $variation['variation'];
                 if ($data['confirmed_for_release']) {
                     activity_log("User '{$username}' confirmed changes for variant {$gene}|{$protein}|{$variation}", 'confirm');
                 } else {
                     activity_log("User '{$username}' unconfirmed changes for variant {$gene}|{$protein}|{$variation}", 'unconfirm');
                 }
             }
         }
     }
     if (isset($_POST['save-changes'])) {
         // Confirmation changes saved
         $html = 'Changes saved.';
         $this->session->set_flashdata('success', $html);
     } else {
         if (isset($_POST['release-changes'])) {
             // Attempt to RELEASE all changes
             /* NOTE: A release can only be successful if all variant changes have been
              *       confirmed for release. This means that 'unconfirmed-variants' must be
              *       empty. If any checkboxes in the name of 'unconfirmed-variants' are checked,
              *       then this element will not be empty, and the attempt to release will fail.
              */
             if ($_POST['special-release'] === 'none') {
                 $found_unconfirmed = FALSE;
                 if (isset($_POST['unconfirmed-variants']) && count($_POST['unconfirmed-variants']) > 0) {
                     // ERROR: found unconfirmed variants on this page
                     $found_unconfirmed = TRUE;
                 }
                 // Check that all variants in queue have been confirmed for release
                 $all_queue_variants = $this->variations_model->get_unreleased_changes();
                 foreach ($all_queue_variants as $variant_id => $values) {
                     $variant_review = $this->variations_model->get_variant_review_info($variant_id);
                     if ($variant_review->confirmed_for_release == 0) {
                         // ERROR: found unconfirmed variants in the queue (not necessarily on this page)
                         $found_unconfirmed = TRUE;
                     }
                 }
                 if ($found_unconfirmed) {
                     // Release failed! Not all variants have been confirmed for release
                     $html = 'All changes must be confirmed prior to release. Check the boxes on the right side to confirm each change, or see the bottom of this page for special release options.';
                     $this->session->set_flashdata('error', $html);
                     redirect('variations/unreleased');
                 }
             }
             if ($_POST['special-release'] === 'force-all' || $this->version == 0) {
                 // Release all variants regardless of confirmation status
                 $success = $this->variations_model->push_data_live(FALSE);
             } else {
                 // Only release the confirmed variants
                 $success = $this->variations_model->push_data_live();
             }
             if ($success === TRUE) {
                 // Successful release
                 $confirmed = '';
                 if ($_POST['special-release'] === 'force-confirmed') {
                     $confirmed = 'confirmed ';
                 }
                 $html = '<p>' . '    <p><i class="icon-ok"></i>&nbsp;&nbsp;&nbsp;Backup created</p>' . '    <p><i class="icon-ok"></i>&nbsp;&nbsp;&nbsp;All ' . $confirmed . 'changes released</p>' . '</p>';
                 $this->session->set_flashdata('success', $html);
             } else {
                 // ERROR: Problem with releasing changes
                 $html = '<p>There was an error releasing changes. Please make sure that any changes you would like to release have been confirmed and/or any special release options have been selected.</p>';
                 $this->session->set_flashdata('error', $html);
             }
         }
     }
     // Redirect to proper page
     $refer_url = $this->session->flashdata('refer_url');
     if (isset($_POST['release-changes']) || empty($refer_url)) {
         // Return to default URL if there's no reference URL or after releasing changes
         redirect('variations/unreleased');
     } else {
         // Return to reference URL
         redirect($refer_url);
     }
 }