public static function edit_parameter_item($item_id) { if (is_numeric($item_id)) { $data_entity_id = DataEntity::get_entry_by_item_id($item_id); $parameter_id = Parameter::get_parameter_id_by_data_entity_id($data_entity_id); $parameter = Parameter::get_instance($parameter_id); if ($parameter->is_read_access()) { self::detail($parameter, http_build_query(Retrace::resolve_retrace_string($_GET['retrace'])), false); } } else { throw new ItemIDMissingException(); } }
/** * @throws UserIDMissingException */ public static function change_quota() { if ($_GET['id']) { $user = new User($_GET['id']); $user_data = new DataUserData($_GET['id']); if ($_GET['nextpage'] == 1) { if (is_numeric($_POST['quota'])) { $page_1_passed = true; } else { $page_1_passed = false; $error = "You must enter a valid quota."; } } elseif ($_GET['nextpage'] > 1) { $page_1_passed = true; } else { $page_1_passed = false; $error = ""; } if ($page_1_passed == false) { $template = new HTMLTemplate("data/admin/user/change_user_quota.html"); $paramquery = $_GET; $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("error", $error); if ($_POST['quota']) { $template->set_var("mail", $_POST['quota']); } else { $template->set_var("quota", $user_data->get_quota()); } $template->output(); } else { if ($_GET['retrace']) { $params = http_build_query(Retrace::resolve_retrace_string($_GET['retrace']), '', '&'); } else { $paramquery['username'] = $_GET['username']; $paramquery['session_id'] = $_GET['session_id']; $paramquery['nav'] = "home"; $params = http_build_query($paramquery, '', '&'); } if ($user_data->set_quota($_POST['quota'])) { Common_IO::step_proceed($params, "Change User Quota", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Change User Quota", "Operation Failed", null); } } } else { throw new UserIDMissingException(); } }
/** * @param string $get_array * @param integer $sample_id * @return string * @throws SampleIDMissingException */ public static function associate($get_array, $sample_id) { global $session; if ($get_array and is_numeric($sample_id)) { $_GET = unserialize($get_array); $post_array = array(); $post_array['keywords'] = $session->read_value("ADD_ITEM_TEMP_KEYWORDS_" . $_GET['idk_unique_id']); $post_array['description'] = $session->read_value("ADD_ITEM_TEMP_DESCRIPTION_" . $_GET['idk_unique_id']); $sample = new Sample($sample_id); $item_add_event = new ItemAddEvent($sample->get_item_id(), $_GET, $post_array, true, "sample"); $event_handler = new EventHandler($item_add_event); if ($event_handler->get_success() == true) { if ($_GET['retrace']) { $params = http_build_query(Retrace::resolve_retrace_string($_GET['retrace']), '', '&'); return "index.php?" . $params; } else { $paramquery['username'] = $username; $paramquery['session_id'] = $session_id; $paramquery['nav'] = "home"; $params = http_build_query($paramquery, '', '&'); return "index.php?" . $params; } } else { return "0"; } } else { throw new SampleIDMissingException(); } }
/** * @param string $username * @param string $session_id * @return string */ public static function run($username, $session_id) { global $session, $user, $transaction; $sample_add_role = $session->read_value("SAMPLE_ADD_ROLE"); $sample_item_retrace = $session->read_value("SAMPLE_ITEM_RETRACE"); $sample_item_get_array = $session->read_value("SAMPLE_ITEM_GET_ARRAY"); $sample_item_keywords = $session->read_value("SAMPLE_ITEM_KEYWORDS"); $sample_item_description = $session->read_value("SAMPLE_ITEM_DESCRIPTION"); $sample_organ_unit = $session->read_value("SAMPLE_ORGANISATION_UNIT"); $sample_template = $session->read_value("SAMPLE_TEMPLATE"); $sample_name = $session->read_value("SAMPLE_NAME"); $sample_manufacturer = $session->read_value("SAMPLE_MANUFACTURER_ID"); $sample_manufacturer_name = $session->read_value("SAMPLE_MANUFACTURER_NAME"); $sample_location = $session->read_value("SAMPLE_LOCATION"); $sample_expiry = $session->read_value("SAMPLE_EXPIRY"); $sample_expiry_warning = $session->read_value("SAMPLE_EXPIRY_WARNING"); $sample_desc = $session->read_value("SAMPLE_DESCRIPTION"); $sample_template_data_type = $session->read_value("SAMPLE_TEMPLATE_DATA_TYPE"); $sample_template_data_type_id = $session->read_value("SAMPLE_TEMPLATE_DATA_TYPE_ID"); $sample_template_data_array = $session->read_value("SAMPLE_TEMPLATE_DATA_ARRAY"); $transaction_id = $transaction->begin(); try { $sample = new Sample(null); $sample->set_template_data($sample_template_data_type, $sample_template_data_type_id, $sample_template_data_array); $sample_id = $sample->create($sample_organ_unit, $sample_template, $sample_name, $sample_manufacturer, $sample_location, $sample_desc, null, $sample_expiry, $sample_expiry_warning); if ($sample_add_role == "item" or $sample_add_role == "item_parent") { // Special Parent Sample Case if ($sample_add_role == "item_parent") { $parent_sample = new Sample($sample_item_get_array['sample_id']); $sample_item_get_array['sample_id'] = $sample_id; $sample_item_get_array['parent_sample'] = "1"; $event_item_id = $parent_sample->get_item_id(); } else { $event_item_id = $sample->get_item_id(); } $post_array = array(); $post_array['keywords'] = $sample_item_keywords; $post_array['description'] = $sample_item_description; $item_add_event = new ItemAddEvent($event_item_id, $sample_item_get_array, $post_array, true, "sample"); $event_handler = new EventHandler($item_add_event); if ($event_handler->get_success() == true) { // Nothing } } } catch (BaseException $e) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw $e; } $session->delete_value("SAMPLE_ADD_ROLE"); $session->delete_value("SAMPLE_ADD_ITEM_HOLDER_CLASS"); $session->delete_value("SAMPLE_ADD_ITEM_HOLDER_ID"); $session->delete_value("SAMPLE_ITEM_RETRACE"); $session->delete_value("SAMPLE_ITEM_GET_ARRAY"); $session->delete_value("SAMPLE_ITEM_KEYWORDS"); $session->delete_value("SAMPLE_ITEM_DESCRIPTION"); $session->delete_value("SAMPLE_ITEM_TYPE_ARRAY"); $session->delete_value("SAMPLE_ORGANISATION_UNIT"); $session->delete_value("SAMPLE_TEMPLATE"); $session->delete_value("SAMPLE_NAME"); $session->delete_value("SAMPLE_MANUFACTURER_ID"); $session->delete_value("SAMPLE_MANUFACTURER_NAME"); $session->delete_value("SAMPLE_LOCATION"); $session->delete_value("SAMPLE_EXPIRY"); $session->delete_value("SAMPLE_EXPIRY_WARNING"); $session->delete_value("SAMPLE_DESCRIPTION"); $session->delete_value("SAMPLE_TEMPLATE_DATA_TYPE"); $session->delete_value("SAMPLE_TEMPLATE_DATA_TYPE_ID"); $session->delete_value("SAMPLE_TEMPLATE_DATA_ARRAY"); if ($sample_add_role == "item" or $sample_add_role == "item_parent") { if ($transaction_id != null) { $transaction->commit($transaction_id); } if ($sample_item_retrace) { $params = http_build_query(Retrace::resolve_retrace_string($sample_item_retrace), '', '&'); return "index.php?" . $params; } else { $paramquery['username'] = $username; $paramquery['session_id'] = $session_id; $paramquery['nav'] = "home"; $params = http_build_query($paramquery, '', '&'); return "index.php?" . $params; } } else { if ($transaction_id != null) { $transaction->commit($transaction_id); } $paramquery = array(); $paramquery['username'] = $username; $paramquery['session_id'] = $session_id; $paramquery['nav'] = "sample"; $paramquery['run'] = "detail"; $paramquery['sample_id'] = $sample_id; $params = http_build_query($paramquery, '', '&'); return "index.php?" . $params; } }