コード例 #1
0
ファイル: Item.php プロジェクト: EMSL-MSC/pacifica-reporting
 /**
  * [get_timeline_data description]
  *
  * @param string  $object_type [description]
  * @param integer $object_id   [description]
  * @param string  $start_date  [description]
  * @param string  $end_date    [description]
  *
  * @return [type] [description]
  *
  * @author Ken Auberry <*****@*****.**>
  */
 public function get_timeline_data($object_type, $object_id, $start_date, $end_date)
 {
     if (!in_array($object_type, $this->accepted_object_types)) {
         //return an error
         return FALSE;
     }
     $retrieval_func = "summarize_uploads_by_{$object_type}";
     $results = $this->rep->{$retrieval_func}($object_id, $start_date, $end_date, TRUE);
     $downselect = $results['day_graph']['by_date'];
     $return_array = array('file_volumes' => array_values($downselect['file_volume_array']), 'transaction_counts' => array_values($downselect['transaction_count_array']));
     send_json_array($return_array);
 }
コード例 #2
0
ファイル: Ajax.php プロジェクト: EMSL-MSC/pacifica-reporting
 /**
  * [change_group_option description]
  *
  * @param boolean $group_id [description]
  *
  * @method change_group_option
  *
  * @return [type] [description]
  *
  * @author Ken Auberry <*****@*****.**>
  */
 public function change_group_option($group_id = FALSE)
 {
     if (!$group_id) {
         //send a nice error message about why you should include a group_id
     }
     $option_type = FALSE;
     $option_value = FALSE;
     $group_info = $this->gm->get_group_info($group_id);
     if (!$group_info) {
         $this->output->set_status_header(404, "Group ID {$group_id} was not found");
         return;
     }
     if ($this->input->post()) {
         $option_type = $this->input->post('option_type');
         $option_value = $this->input->post('option_value');
     } elseif ($this->input->is_ajax_request() || $this->input->raw_input_stream) {
         $http_raw_post_data = file_get_contents('php://input');
         $post_info = json_decode($http_raw_post_data, TRUE);
         // $post_info = $post_info[0];
         $option_type = array_key_exists('option_type', $post_info) ? $post_info['option_type'] : FALSE;
         $option_value = array_key_exists('option_value', $post_info) ? $post_info['option_value'] : FALSE;
     }
     if (!$option_type || !$option_value) {
         $missing_types = array();
         $message = "Group option update information was incomplete (missing '";
         //$message .= !$option_type ? " 'option_type' "
         if (!$option_type) {
             $missing_types[] = 'option_type';
         }
         if (!$option_value) {
             $missing_types[] = 'option_value';
         }
         $message .= implode("' and '", $missing_types);
         $message .= "' entries)";
         $this->output->set_status_header(400, $message);
         return;
     }
     $success = $this->gm->change_group_option($group_id, $option_type, $option_value);
     if ($success && is_array($success)) {
         send_json_array($success);
     } else {
         $message = "Could not set options for group ID {$group_id}";
         $this->output->set_status_header('500', $message);
         return;
     }
     return;
 }
コード例 #3
0
ファイル: Group.php プロジェクト: EMSL-MSC/pacifica-reporting
 /**
  * Retrieves a set of proposals and their accompanying info to be used in a dropdown menu
  * in the UI. Doesn't actually return anything, but hands the array off to a helper function
  * that formats it into a json object for return through AJAX
  *
  * @param string $proposal_name_fragment the search term to use
  * @param string $active                 active/inactive proposal switch (active/inactive)
  *
  * @uses EUS::get_proposals_by_name to get proposal list from the EUS Database clone
  *
  * @return none
  */
 public function get_proposals($proposal_name_fragment, $active = 'active')
 {
     $results = $this->eus->get_proposals_by_name($proposal_name_fragment, $active);
     send_json_array($results);
 }
コード例 #4
0
 /**
  * Get the job status for a particular job ID
  *
  * @param int $job_id job ID integer
  *
  * @return void
  */
 public function job_status($job_id = -1)
 {
     $HTTP_RAW_POST_DATA = file_get_contents('php://input');
     $values = json_decode($HTTP_RAW_POST_DATA, TRUE);
     if (!$values && $job_id > 0) {
         //must not have a list of values, so just check the one
         $values = array($job_id);
     }
     $results = $this->status->get_job_status($values, $this->status_list);
     // send_json_array($results);
     if ($results) {
         transmit_array_with_json_header($results);
     } else {
         send_json_array(array());
     }
 }
コード例 #5
0
 /**
  * Retrieves the full set of instruments that are
  * associated with a given proposal, and formats
  * it to be compatible with the Select2 JSON array
  * loading interface.
  *
  * @param string $proposal_id proposal ID string
  * @param string $terms       space separated list of search terms against
  *                            instruments metadata
  *
  * @return void
  */
 public function get_instruments_for_proposal($proposal_id = FALSE, $terms = FALSE)
 {
     if (!$proposal_id) {
         $this->output->set_status_header(404, "Proposal ID {$proposal_id} was not found");
         return;
     }
     $full_user_info = $this->myemsl->get_user_info();
     $instruments = array();
     $inst_list = $full_user_info['instruments'];
     if (array_key_exists($proposal_id, $full_user_info['proposals'])) {
         $instruments_available = $full_user_info['proposals'][$proposal_id]['instruments'];
     } else {
         $instruments_available = array();
     }
     $total_count = sizeof($instruments_available) + 1;
     asort($instruments_available);
     $instruments[] = array('id' => 0, 'text' => NULL);
     $instruments[] = array('id' => -1, 'text' => "All Available Instruments for Proposal {$proposal_id}", 'name' => "All Instruments", 'active' => 'Y');
     foreach ($instruments_available as $inst_id) {
         $instruments[] = array('id' => $inst_id, 'text' => "Instrument {$inst_id}: {$full_user_info['instruments'][$inst_id]['eus_display_name']}", 'name' => $full_user_info['instruments'][$inst_id]['eus_display_name'], 'active' => $inst_list[$inst_id]['active_sw']);
     }
     // $instruments[-1] = "All Available Instruments for Proposal {$proposal_id}";
     $results = array('total_count' => $total_count, 'incomplete_results' => FALSE, 'items' => $instruments);
     send_json_array($results);
 }