/** * @param string $get_array * @throws SampleIDMissingException */ public static function get_sample_information($get_array) { global $user; if ($get_array) { $_GET = unserialize($get_array); } if ($_GET['sample_id']) { $sample_security = new SampleSecurity($_GET['sample_id']); if ($sample_security->is_access(1, false)) { $sample = new Sample($_GET['sample_id']); $owner = new User($sample->get_owner_id()); $template = new HTMLTemplate("sample/ajax/detail_information.html"); $template->set_var("id", $sample->get_formatted_id()); $template->set_var("name", $sample->get_name()); $template->set_var("owner", $owner->get_full_name(false)); $template->set_var("template", $sample->get_template_name()); $template->set_var("permissions", $sample_security->get_access_string()); $datetime = new DatetimeHandler($sample->get_datetime()); $template->set_var("datetime", $datetime->get_datetime()); if ($sample->get_date_of_expiry()) { $date_of_expiry = new DatetimeHandler($sample->get_date_of_expiry()); $template->set_var("date_of_expiry", $date_of_expiry->get_date()); } else { $template->set_var("date_of_expiry", false); } if ($sample->get_current_location_name()) { $template->set_var("location", $sample->get_current_location_name()); } else { $template->set_var("location", false); } if ($sample->get_manufacturer_id()) { $manufacturer = new Manufacturer($sample->get_manufacturer_id()); $template->set_var("manufacturer", $manufacturer->get_name()); } else { $template->set_var("manufacturer", false); } if ($sample->get_availability() == true) { $template->set_var("status", "available"); } else { $template->set_var("status", "not available"); } if ($sample->get_owner_id() == $user->get_user_id() or $user->is_admin() == true) { $template->set_var("is_owner", true); } else { $template->set_var("is_owner", false); } if ($user->is_admin() == true) { $template->set_var("is_admin", true); } else { $template->set_var("is_admin", false); } $owner_paramquery = array(); $owner_paramquery['username'] = $_GET['username']; $owner_paramquery['session_id'] = $_GET['session_id']; $owner_paramquery['nav'] = "sample"; $owner_paramquery['run'] = "common_dialog"; $owner_paramquery['dialog'] = "user_detail"; $owner_paramquery['id'] = $sample->get_owner_id(); $owner_params = http_build_query($owner_paramquery, '', '&'); $template->set_var("owner_params", $owner_params); $location_history_paramquery = $_GET; $location_history_paramquery['run'] = "location_history"; $location_history_params = http_build_query($location_history_paramquery, '', '&'); $template->set_var("location_history_params", $location_history_params); $template->output(); } } else { throw new SampleIDMissingException(); } }
/** * Creates a new Sample Folder including Folder * @param integer $sample_id * @return integer */ public function create($sample_id) { if (is_numeric($sample_id)) { $sample = new Sample($sample_id); // Folder $sample_folder_id = constant("SAMPLE_FOLDER_ID"); $folder = new Folder($sample_folder_id); $path = new Path($folder->get_path()); $path->add_element($sample_id); $name = $sample->get_name() . " (" . $sample->get_formatted_id() . ")"; if (($folder_id = parent::create($name, $sample_folder_id, $path->get_path_string(), $sample->get_owner_id(), null)) != null) { $sample_has_folder_access = new SampleHasFolder_Access(null); if ($sample_has_folder_access->create($sample_id, $folder_id) == null) { return null; } // Virtual Folders (Event) $sample_folder_create_event = new SampleFolderCreateEvent($folder_id); $event_handler = new EventHandler($sample_folder_create_event); if ($event_handler->get_success() == false) { $this->delete(); return false; } else { return $folder_id; } } else { return null; } } else { return null; } }
/** * @throws SampleIDMissingException * @throws SampleSecurityAccessDeniedException */ public static function location_history() { global $sample_security; if ($_GET['sample_id']) { if ($sample_security->is_access(1, false)) { $argument_array = array(); $argument_array[0] = "sample_id"; $argument_array[1] = $_GET['sample_id']; $list = new List_IO("SampleLocationHistory", "ajax.php?nav=sample", "list_location_history", "count_location_history", $argument_array, "SampleLocationHistory"); $list->add_column("", "symbol", false, "16px"); $list->add_column(Language::get_message("SampleGeneralListColumnName", "general"), "name", true, null); $list->add_column(Language::get_message("SampleGeneralListColumnDateTime", "general"), "datetime", true, null); $list->add_column(Language::get_message("SampleGeneralListColumnUser", "general"), "user", true, null); $template = new HTMLTemplate("sample/location_history.html"); $sample = new Sample($_GET['sample_id']); $template->set_var("sample_id", $sample->get_formatted_id()); $template->set_var("sample_name", "(" . $sample->get_name() . ")"); $template->set_var("list", $list->get_list()); $template->output(); } else { throw new SampleSecurityAccessDeniedException(); } } else { throw new SampleIDMissingException(); } }