public static function create() { if ($_GET['nextpage'] == 1) { $page_1_passed = true; } else { $page_1_passed = false; $error = ""; } if ($page_1_passed == false) { $template = new HTMLTemplate("sample/admin/sample_template/add.html"); $paramquery = $_GET; $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); if ($error) { $template->set_var("error", $error); } else { $template->set_var("error", ""); } $folder = Folder::get_instance(constant("OLDL_FOLDER_ID")); $data_entity_array = $folder->get_children(); if (is_array($data_entity_array)) { $result = array(); $counter = 0; foreach ($data_entity_array as $key => $value) { if (($file_id = File::get_file_id_by_data_entity_id($value)) != null) { $file = File::get_instance($file_id); $result[$counter]['value'] = $value; $result[$counter]['content'] = $file->get_name(); $counter++; } } $template->set_var("file", $result); } $category_array = SampleTemplateCat::list_entries(); if (is_array($category_array)) { $result = array(); $counter = 0; foreach ($category_array as $key => $value) { $sample_template_cat = new SampleTemplateCat($value); $result[$counter]['value'] = $value; $result[$counter]['content'] = $sample_template_cat->get_name(); $counter++; } $template->set_var("category", $result); } $template->output(); } else { $sample_template = new SampleTemplate(null); $paramquery = $_GET; unset($paramquery['action']); unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); if ($sample_template->create($_POST['data_entity_id'], $_POST['category_id'])) { Common_IO::step_proceed($params, "Add Sample Template", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Add Sample Template", "Operation Failed", null); } } }
/** * @param integer $file_id * @return string */ public static function get_context_sensitive_file_menu($file_id) { global $user; $file = File::get_instance($file_id); $html = ""; if ($file->is_read_access()) { $download_link = "download.php?username="******"&session_id=" . $_GET['session_id'] . "&file_id=" . $file_id; $html .= "<img src='images/icons/download.png' alt='' /><a href='" . $download_link . "' class='DataBrowserDialogLinkFollowDirectly'>Download</a><br/>"; $history_link = "index.php?username="******"&session_id=" . $_GET['session_id'] . "&nav=data&file_id=" . $file_id . "&action=file_history"; $html .= "<img src='images/icons/history.png' alt='' /><a href='" . $history_link . "' class='DataBrowserDialogLinkFollowDirectly'>History</a><br/>"; } if ($file->is_write_access()) { $version_num = $file->get_internal_revision(); $update_link = "run=file_update&file_id=" . $file_id . "&version=" . $version_num; $html .= "<img src='images/icons/upload.png' alt='' /><a href='" . $update_link . "' class='DataBrowserDialogLinkUploadNewer'>Upload newer version</a><br/>"; $update_minor_link = "run=file_update_minor&file_id=" . $file_id . "&version=" . $version_num; $html .= "<img src='images/icons/upload.png' alt='' /><a href='" . $update_minor_link . "' class='DataBrowserDialogLinkUploadMinor'>Upload minor version</a><br/>"; } if ($file->is_control_access() == true or $file->get_owner_id() == $user->get_user_id()) { $change_permission_link = "run=file_permission&file_id=" . $file_id; $html .= "<img src='images/icons/permissions.png' alt='' /><a href='" . $change_permission_link . "' class='DataBrowserDialogLinkChangePermission'>Change permission</a><br/>"; } if ($file->is_delete_access()) { $delete_link = "run=file_delete&file_id=" . $file_id; $html .= "<img src='images/icons/delete.png' alt='' /><a href='" . $delete_link . "' class='DataBrowserDialogLinkDelete'>Delete</a><br/>"; } if ($file->is_read_access()) { $open_link = "index.php?username="******"&session_id=" . $_GET['session_id'] . "&nav=data&file_id=" . $file_id . "&action=file_detail"; $html .= "<img src='images/icons/file_open.png' alt='' /><a href='" . $open_link . "' class='DataBrowserDialogLinkFollowDirectly'>Open</a><br/>"; } return $html; }
/** * @see DataPermissionInterface::__construct() * @param string type * @param integer $id */ function __construct($type, $id) { if (is_numeric($id) and $type) { $this->type = $type; switch ($type) { case "file": $this->id = $id; $this->object = File::get_instance($id); break; case "value": $this->id = $id; $this->object = Value::get_instance($id); break; case "parameter": $this->id = $id; $this->object = Parameter::get_instance($id); break; case "folder": $this->id = $id; $this->object = Folder::get_instance($id); break; } $this->automatic = $this->object->get_automatic(); $this->permission = $this->object->get_permission(); $this->owner_id = $this->object->get_owner_id(); $this->owner_group_id = $this->object->get_owner_group_id(); } else { $this->id = null; $this->object = null; } }
/** * @param integer $file_id * @return string * @throws DataSecurityAccessDeniedException */ private static function delete_file($file_id) { $file = File::get_instance($file_id); if ($file->is_delete_access()) { $file->delete(); return "1"; } else { throw new DataSecurityAccessDeniedException(); } }
/** * @param string $permission_array * @param string $type * @return string * @throws DataSecurityAccessDeniedException */ public static function change_permission($permission_array, $type) { global $user; $permissions = (array) $permission_array; switch ($type) { case "File": $id = $_POST['file_id']; $object = File::get_instance($id); break; case "Folder": $id = $_POST['folder_id']; $object = Folder::get_instance($id); break; case "Value": $id = $_POST['value_id']; $object = Value::get_instance($id); break; case "Parameter": $id = $_POST['parameter_id']; $object = Parameter::get_instance($id); break; } if ($object->is_control_access() == true) { $full_access = true; } else { $full_access = false; } if ($object->get_owner_id() == $user->get_user_id()) { $user_access = true; } else { $user_access = false; } if ($full_access == true or $user_access == true) { $type = strtolower($type); $id = intval($id); echo $id; $data_permission = new DataPermission($type, $id); $paramquery = $_GET; unset($paramquery['action']); unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); if ($data_permission->set_permission_array($permissions) == true) { return "1"; } else { return "0"; } } else { throw new DataSecurityAccessDeniedException(); } }
/** * @throws FileIDMissingException * @throws DataSecurityAccessDeniedException */ public static function history() { if ($_GET['file_id']) { $file = File::get_instance($_GET['file_id']); if ($file->is_read_access()) { $argument_array = array(); $argument_array[0] = "file_id"; $argument_array[1] = $_GET['file_id']; $list = new List_IO("DataFileVersionHistory", "ajax.php?nav=data", "file_list_versions", "file_count_versions", $argument_array, "DataFileVersionHistory"); $list->add_column("", "symbol", false, "16px"); $list->add_column(Language::get_message("DataGeneralListColumnName", "general"), "name", true, null); $list->add_column(Language::get_message("DataGeneralListColumnVersion", "general"), "version", false, null); $list->add_column(Language::get_message("DataGeneralListColumnDateTime", "general"), "datetime", true, null); $list->add_column(Language::get_message("DataGeneralListColumnUser", "general"), "user", true, null); $list->add_column("", "delete", false, "16px"); $template = new HTMLTemplate("data/file_history.html"); $template->set_var("title", $file->get_name()); $template->set_var("list", $list->get_list()); $template->output(); } else { throw new DataSecurityAccessDeniedException(); } } else { throw new FileIDMissingException(); } }
Security::protect_session(); if ($_GET['session_id'] and $_FILES) { global $db, $user, $session, $transaction, $runtime_data; $runtime_data = new RuntimeData(); $session = new Session($_GET['session_id']); $user = new User($session->get_user_id()); $transaction = new Transaction(); $session_valid_array = $session->is_valid(); if ($session_valid_array[0] === true) { $folder_id = $_GET['folder_id']; if ($_POST['file_amount'] > 25 or $_POST['file_amount'] < 1 or !$_POST['file_amount']) { $file_amount = 1; } else { $file_amount = $_POST['file_amount']; } $file = File::get_instance(null); $file_upload_successful = $file->upload_file_stack($file_amount, $folder_id, $_FILES, $_GET['unique_id']); if ($file_upload_successful == true) { // Create Item $item_id_array = $file->get_item_id_array(); if (is_array($item_id_array) and count($item_id_array) >= 1) { foreach ($item_id_array as $key => $value) { $item_add_event = new ItemAddEvent($value, $_GET, $_POST); $event_handler = new EventHandler($item_add_event); } } $session->write_value("FILE_UPLOAD_FINISHED_" . $_GET['unique_id'], true, true); } else { } } }
/** * @param string $sql * @param integer $item_id * @param object $pdf * @return object */ public static function get_data_item_report($sql, $item_id, $pdf) { global $regional; if ($sql and is_object($pdf)) { // Values $value_array = Data_Wrapper::list_item_values($sql); if (is_array($value_array) and count($value_array) >= 1) { foreach ($value_array as $key => $value) { $value_object = Value::get_instance($value['id']); $value_object_value_array = $value_object->get_value_content(false); $pdf->addPage(); $pdf->SetFont('dejavusans', 'B', 14, '', true); $pdf->Write(0, 'Value - ' . $value_object->get_name() . '', '', 0, 'C', true, 0, false, false, 0); $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0); $pdf->SetFont('dejavusans', '', 12, '', true); if (is_array($value_object_value_array) and count($value_object_value_array) >= 1) { foreach ($value_object_value_array as $sub_key => $sub_value) { $sub_value['content'][0] = str_replace("\n", "<br />", $sub_value['content'][0]); if ($sub_value['type'] == "textarea") { $pdf->SetFont('dejavusans', 'B', 12, '', true); $pdf->MultiCell(190, 9, $sub_value['title'], 1, 'L', 1, 1, '', '', true, 0, true, true, 0, "T"); $pdf->SetFont('dejavusans', '', 12, '', true); $string_height = $pdf->getStringHeight(110, $sub_value['content'][0], true, true, '', 1); $pdf->MultiCell(190, $string_height, $sub_value['content'][0], 1, 'L', 1, 1, '', '', true, 0, true, true, 0, "T"); } else { $pdf->SetFont('dejavusans', 'B', 12, '', true); $string_height1 = $pdf->getStringHeight(80, $sub_value['title'], true, true, '', 1); $pdf->SetFont('dejavusans', '', 12, '', true); $string_height2 = $pdf->getStringHeight(110, $sub_value['content'][0], true, true, '', 1); if ($string_height1 > $string_height2) { $height = $string_height1; } else { $height = $string_height2; } $pdf->SetFont('dejavusans', 'B', 12, '', true); $pdf->MultiCell(80, $height, $sub_value['title'], 1, 'L', 1, 0, '', '', true, 0, true, true, 0, "T"); $pdf->SetFont('dejavusans', '', 12, '', true); $pdf->MultiCell(110, $height, $sub_value['content'][0], 1, 'L', 1, 1, '', '', true, 0, true, true, 0, "T"); } } } $value_object_version_array = $value_object->get_value_internal_revisions(); if (is_array($value_object_version_array) and count($value_object_version_array) >= 1) { $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0); $header_array = array(array("name" => "name", "title" => "Name", "width" => 60), array("name" => "version", "title" => "Version", "width" => 25), array("name" => "datetime", "title" => "Date/Time", "width" => 55), array("name" => "user", "title" => "User", "width" => 50)); $report_table = new ReportTable_IO($pdf, '', '12'); $report_table->add_header($header_array); foreach ($value_object_version_array as $sub_key => $sub_value) { $value_version = clone $value_object; $value_version->open_internal_revision($sub_value); $datetime_handler = new DatetimeHandler($value_version->get_datetime()); $owner = new User($value_version->get_version_owner_id()); $line_array = array(array("name" => "name", "content" => $value_version->get_name()), array("name" => "version", "content" => $value_version->get_version()), array("name" => "datetime", "content" => $datetime_handler->get_datetime(false)), array("name" => "user", "content" => $owner->get_full_name(true))); $report_table->add_line($line_array); } } $pdf = $report_table->get_pdf(); } } // Files $file_array = Data_Wrapper::list_item_files($sql, null, null, null, null); if (is_array($file_array) and count($file_array) >= 1) { $pdf->addPage(); $pdf->SetFont('dejavusans', 'B', 14, '', true); $pdf->Write(0, 'Files', '', 0, 'C', true, 0, false, false, 0); $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0); $pdf->SetFont('dejavusans', '', 14, '', true); $header_array = array(array("name" => "name", "title" => "Name", "width" => 62), array("name" => "version", "title" => "Version", "width" => 25), array("name" => "datetime", "title" => "Date/Time", "width" => 55), array("name" => "user", "title" => "User", "width" => 48)); $report_table = new ReportTable_IO($pdf, '', '12'); $report_table->add_header($header_array); foreach ($file_array as $key => $value) { $file = File::get_instance($value['id']); $owner = new User($value['owner_id']); $datetime_handler = new DatetimeHandler($value['datetime']); $line_array = array(array("name" => "name", "content" => $value['name']), array("name" => "version", "content" => $file->get_version()), array("name" => "datetime", "content" => $datetime_handler->get_datetime(false)), array("name" => "user", "content" => $owner->get_full_name(true))); $report_table->add_line($line_array); } $pdf = $report_table->get_pdf(); } // Parameters $parameter_array = Data_Wrapper::list_item_parameters($sql); if (is_array($parameter_array) and count($parameter_array) >= 1) { foreach ($parameter_array as $key => $value) { $parameter_object = Parameter::get_instance($value['id']); $parameter_template = new ParameterTemplate($parameter_object->get_template_id()); $parameter_template_field_array = $parameter_template->get_fields(); $parameter_template_limit_array = $parameter_template->get_limits(); $parameter_value_array = $parameter_object->get_values(); $parameter_method_array = $parameter_object->get_methods(); $parameter_status_array = $parameter_object->get_status(); $parameter_limit_array = $parameter_object->geT_limits(); $pdf->addPage(); $pdf->SetFont('dejavusans', 'B', 14, '', true); $pdf->Write(0, '' . $parameter_object->get_name() . '', '', 0, 'L', true, 0, false, false, 0); $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0); $pdf->SetFont('dejavusans', '', 12, '', true); $header_array = array(array("name" => "parameter", "title" => "Parameter", "width" => 44), array("name" => "value", "title" => "Value", "width" => 25), array("name" => "unit", "title" => "Unit", "width" => 25), array("name" => "min", "title" => "Min", "width" => 20), array("name" => "max", "title" => "Max", "width" => 20), array("name" => "method", "title" => "Method", "width" => 30), array("name" => "status", "title" => "Status", "width" => 25)); $report_table = new ReportTable_IO($pdf, '', '12'); $report_table->add_header($header_array); if (is_array($parameter_template_field_array) and count($parameter_template_field_array) >= 1) { foreach ($parameter_template_field_array as $key => $value) { if (is_numeric($parameter_value_array[$value['pk']])) { $regionalized_value = str_replace(".", $regional->get_decimal_separator(), $parameter_value_array[$value['pk']]); } else { $regionalized_value = ""; } if (is_numeric($value['unit'])) { if ($value['unit_exponent'] < 0) { $unit_exponent = $value['unit_exponent'] * -1; $unit_prefix = MeasuringUnit::get_prefix($unit_exponent, false); } else { $unit_prefix = MeasuringUnit::get_prefix($value['unit_exponent'], true); } $measuring_unit = new MeasuringUnit($value['unit']); $unit = $unit_prefix[1] . "" . $measuring_unit->get_unit_symbol(); } elseif (is_numeric($value['unit_ratio'])) { $measuring_unit_ratio = new MeasuringUnitRatio($value['unit_ratio']); $unit = $measuring_unit_ratio->get_symbol(); } else { $unit = ""; } if ($parameter_limit_array[$value['pk']]) { if (is_numeric($parameter_limit_array[$value['pk']]['usl'])) { $usl = $parameter_limit_array[$value['pk']]['usl']; } else { $usl = ""; } if (is_numeric($parameter_limit_array[$value['pk']]['lsl'])) { $lsl = $parameter_limit_array[$value['pk']]['lsl']; } else { $lsl = ""; } } else { if (is_numeric($parameter_template_limit_array[0]['usl'][$key])) { $usl = $parameter_template_limit_array[0]['usl'][$key]; } else { $usl = ""; } if (is_numeric($parameter_template_limit_array[0]['lsl'][$key])) { $lsl = $parameter_template_limit_array[0]['lsl'][$key]; } else { $lsl = ""; } } if ($parameter_method_array[$key]) { $method = $parameter_method_array[$key]; } else { $method = "none"; } if ($parameter_status_array[$value['pk']]) { switch ($parameter_status_array[$value['pk']]) { case "max": $status = ">max"; break; case "min": $status = "<min"; break; default: $status = "OK"; break; } } else { $status = "none"; } $line_array = array(array("name" => "parameter", "content" => $value['name']), array("name" => "value", "content" => $regionalized_value), array("name" => "unit", "content" => $unit), array("name" => "min", "content" => $lsl), array("name" => "max", "content" => $usl), array("name" => "method", "content" => $method), array("name" => "status", "content" => $status)); $report_table->add_line($line_array); unset($regionalized_value); unset($unit); unset($lsl); unset($usl); unset($method); unset($status); } } $pdf = $report_table->get_pdf(); } } return $pdf; } else { return null; } }
/** * @return object */ private function open_image() { if ($this->file_id) { $file = File::get_instance($this->file_id); if ($this->internal_revision) { $file->open_internal_revision($this->internal_revision); } if ($file->is_read_access() == true) { $folder = Folder::get_instance($file->get_parent_folder_id()); $folder_path = $folder->get_path(); $extension_array = explode(".", $file->get_name()); $extension_array_length = substr_count($file->get_name(), "."); $file_path = constant("BASE_DIR") . "/" . $folder_path . "/" . $file->get_data_entity_id() . "-" . $file->get_internal_revision() . "." . $extension_array[$extension_array_length]; if (file_exists($file_path)) { try { return new Imagick($file_path); } catch (ImagickException $e) { die("Unsupported File or Internal Error"); } } } } }
/** * Inits a caching procedure * @return bool */ private function init() { global $transaction; if ($this->data_entity_id) { $transaction_id = $transaction->begin(); $file_id = File::get_file_id_by_data_entity_id($this->data_entity_id); $file = File::get_instance($file_id); $folder = Folder::get_instance($file->get_parent_folder()); $folder_path = $folder->get_path(); $extension_array = explode(".", $file->get_name()); $extension_array_length = substr_count($file->get_name(), "."); $file_path = constant("BASE_DIR") . "/" . $folder_path . "/" . $this->data_entity_id . "-1." . $extension_array[$extension_array_length]; $this->xml_string = $file->get_file_content(); if (strlen($this->xml_string) > 0) { $xml = new Xml($this->xml_string); $xml->parser(); $this->xml_array = $xml->get_array(); if (is_array($this->xml_array) and count($this->xml_array) >= 1) { $this->xml_cache = new XmlCache_Access(null); $id = $this->xml_cache->create($this->data_entity_id, $file_path, md5_file($file_path)); foreach ($this->xml_array as $key => $value) { $xml_cache_element = new XmlCacheElement_Access(null); $xml_cache_element->create($id, $value[0], $value[1], $value[2], $value[3]); } self::__construct($this->data_entity_id); if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } else { if ($transaction_id != null) { $transaction->rollback($transaction_id); } return false; } } else { if ($transaction_id != null) { $transaction->rollback($transaction_id); } return false; } } }
/** * @see SampleInterface::clone_sample() * @param integer $source_sample_id * @param string $name * @param integer $manufacturer_id * @param integer $location_id * @param string $desc * @param integer $language_id * @param string $date_of_expiry * @param integer $expiry_warning * @param array $value_array * @param array $item_array * @return integer * @throws SampleCloneIDMissingException * @throws SampleCloneCreateException * @throws SampleCloneCreateFolderException * @throws SampleCloneCreateSubFolderException * @throws SampleCloneCreateAsItemException * @throws SampleCloneCreateLocationException * @throws SampleCloneCreateFailedException * @throws SampleCloneUserException * @throws SampleCloneOrganisationUnitException * @throws SampleCloneLocationException * @throws SampleCloneValueException * @throws SampleCloneFileException * @throws SampleCloneParentException * @throws SampleCloneItemException */ public function clone_sample($source_sample_id, $name, $manufacturer_id, $location_id, $desc, $language_id, $date_of_expiry, $expiry_warning, $value_array, $item_array) { global $user, $transaction; if (is_numeric($source_sample_id) and $name) { $source_sample = new Sample($source_sample_id); $source_sample_security = new SampleSecurity($source_sample_id); $source_sample_folder_id = SampleFolder::get_folder_by_sample_id($source_sample_id); $transaction_id = $transaction->begin(); try { if (($sample_id = $this->sample->create($name, $user->get_user_id(), $source_sample->get_template_id(), $manufacturer_id, $desc, $language_id, $date_of_expiry, $expiry_warning)) == null) { throw new SampleCloneCreateFailedException(); } if ($desc) { $this->sample->set_comment_text_search_vector($desc, "english"); } $sub_folder_name_array = $this->create_sample_folder($sample_id, $source_sample->get_template_id()); $this->create_sample_item($sample_id); $sample_security = new SampleSecurity($sample_id); $source_sample_user_list = $source_sample_security->list_users(); if (is_array($source_sample_user_list) and count($source_sample_user_list) >= 1) { foreach ($source_sample_user_list as $key => $value) { if ($sample_security->create_user($value, true, true) == null) { throw new SampleCloneUserException(); } } } $source_sample_organisation_list = $source_sample_security->list_organisation_units(); if (is_array($source_sample_organisation_list) and count($source_sample_organisation_list) >= 1) { foreach ($source_sample_organisation_list as $key => $value) { if ($sample_security->create_organisation_unit($value) == null) { throw new SampleCloneOrganisationUnitException(); } } } // Locations $source_sample_location_array = SampleHasLocation_Access::list_entries_by_sample_id($source_sample_id); $end_sample_has_location_access = new SampleHasLocation_Access(end($source_sample_location_array)); if (is_array($source_sample_location_array) and count($source_sample_location_array) >= 1) { if ($location_id != $end_sample_has_location_access->get_location_id()) { $add_new_location = true; } else { $add_new_location = false; } foreach ($source_sample_location_array as $key => $value) { $current_sample_has_location_access = new SampleHasLocation_Access($value); $sample_has_location_access = new SampleHasLocation_Access(null); if ($sample_has_location_access->create($sample_id, $current_sample_has_location_access->get_location_id(), $user->get_user_id()) == null) { throw new SampleCloneLocationException(); } } } else { $add_new_location = true; } if (is_numeric($location_id) and $add_new_location == true and $location_id > 0) { // Create First Location $sample_has_location_access = new SampleHasLocation_Access(null); if ($sample_has_location_access->create($sample_id, $location_id, $user->get_user_id()) == null) { throw new SampleCloneCreateLocationException("Could not create location"); } } if (is_array($value_array) and count($item_array) >= 1) { $value_item_array = array(); $value_data_array = array(); foreach ($value_array as $key => $value) { $key = str_replace("value-", "", $key); $key_array = explode("-", $key, 2); if ($key_array[0] == "item") { $value_item_array[$key_array[1]] = $value; } elseif (is_numeric($key_array[0])) { $value_data_array[$key_array[0]][$key_array[1]] = $value; } } if (is_array($value_item_array) and count($value_item_array) >= 1) { foreach ($value_item_array as $key => $value) { $gid = SampleItem::get_gid_by_item_id_and_sample_id($value, $source_sample_id); $data_entity_id = DataEntity::get_entry_by_item_id($value); $value_id = Value::get_value_id_by_data_entity_id($data_entity_id); if (is_numeric($value_id)) { $value_obj = Value::get_instance($value_id); $parent_folder_id = $value_obj->get_parent_folder_id(); $value_type_id = $value_obj->get_type_id(); if ($parent_folder_id == $source_sample_folder_id) { $new_folder_id = $this->sample_folder_id; } else { $folder_name = Folder::get_name_by_id($parent_folder_id); $new_folder_id = array_search(trim(strtolower($folder_name)), $sub_folder_name_array); } if (is_numeric($new_folder_id) and is_numeric($value_type_id)) { $new_value_obj = Value::get_instance(null); $new_value_obj->create($new_folder_id, $user->get_user_id(), $value_type_id, $value_data_array[$key]); $new_value_item_id = $new_value_obj->get_item_id(); $sample_item = new SampleItem($sample_id); $sample_item->set_gid($gid); if ($sample_item->set_item_id($new_value_item_id) == false) { throw new SampleCloneValueException(); } if ($sample_item->link_item() == false) { throw new SampleCloneValueException(); } } } } } } if (is_array($item_array) and count($item_array) >= 1) { $item_type_array = array(); $item_data_array = array(); foreach ($item_array as $key => $value) { if ($value[1] == "1") { $item_explode_array = explode("-", $value[0], 2); if (!in_array($item_explode_array[0], $item_type_array)) { array_push($item_type_array, $item_explode_array[0]); } if (!is_array($item_data_array[$item_explode_array[0]])) { $item_data_array[$item_explode_array[0]] = array(); } array_push($item_data_array[$item_explode_array[0]], $item_explode_array[1]); } } if (is_array($item_type_array) and count($item_type_array) >= 1) { foreach ($item_type_array as $key => $value) { if ($value == "parent") { foreach ($item_data_array[$value] as $data_key => $data_value) { $parent_item_explode_array = explode("-", $data_value, 2); if ($parent_item_explode_array[0] and $parent_item_explode_array[1]) { $item_add_holder_event = new ItemAddHolderEvent($parent_item_explode_array[1], $parent_item_explode_array[0], $this->item_id); $event_handler = new EventHandler($item_add_holder_event); if ($event_handler->get_success() == false) { throw new SampleCloneParentException(); } } } } elseif ($value == "file") { if (is_array($item_data_array[$value]) and count($item_data_array[$value]) >= 1) { foreach ($item_data_array[$value] as $data_key => $data_value) { $gid = SampleItem::get_gid_by_item_id_and_sample_id($data_value, $source_sample_id); $data_entity_id = DataEntity::get_entry_by_item_id($data_value); $file_id = File::get_file_id_by_data_entity_id($data_entity_id); if ($file_id) { $file_obj = File::get_instance($file_id); $parent_folder_id = $file_obj->get_parent_folder_id(); if ($parent_folder_id == $source_sample_folder_id) { $new_folder_id = $this->sample_folder_id; } else { $folder_name = Folder::get_name_by_id($parent_folder_id); $new_folder_id = array_search(trim(strtolower($folder_name)), $sub_folder_name_array); } if (is_numeric($new_folder_id)) { if ($file_obj->copy($new_folder_id) == false) { throw new SampleCloneFileException(); } $new_file_item_id = $file_obj->get_item_id(); $sample_item = new SampleItem($sample_id); $sample_item->set_gid($gid); if ($sample_item->set_item_id($new_file_item_id) == false) { throw new SampleCloneFileException(); } if ($sample_item->link_item() == false) { throw new SampleCloneFileException(); } } } } } } else { if (is_array($item_data_array[$value]) and count($item_data_array[$value]) >= 1) { $handling_class = Item::get_handling_class_by_type($value); if ($handling_class) { foreach ($item_data_array[$value] as $data_key => $data_value) { $gid = SampleItem::get_gid_by_item_id_and_sample_id($data_value, $source_sample_id); $new_item_id = $handling_class::clone_item($data_value); if ($new_item_id) { $sample_item = new SampleItem($sample_id); $sample_item->set_gid($gid); if ($sample_item->set_item_id($new_item_id) == false) { throw new SampleCloneItemException(); } if ($sample_item->link_item() == false) { throw new SampleCloneItemException(); } } } } } } } } } } catch (BaseException $e) { if (is_object($this->sample_folder_object)) { $this->sample_folder_object->delete(true, true); } if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw $e; } if ($transaction_id != null) { $transaction->commit($transaction_id); } self::__construct($sample_id); return $sample_id; } else { throw new SampleCloneIDMissingException(); } }
if ($session_valid_array[0] === true) { $session_file_array = array(); $session_file_array[1] = 0; $session->write_value("FILE_UPLOAD_" . $_GET['unique_id'], $session_file_array, true); if ($_POST['current'] == 1) { $current = true; } else { $current = false; } if ($_GET['action'] == "file_update") { $major = true; } else { $major = false; } if ($_GET['version']) { $previous_version_id = $_GET['version']; } else { $previous_version_id = null; } if (!empty($_FILES['file-1']['name'])) { $file = File::get_instance($_GET['file_id']); $session_file_array[1] = $file->update_file($_FILES['file-1'], $previous_version_id, $major, $current); $session->write_value("FILE_UPLOAD_" . $_GET['unique_id'], $session_file_array, true); $session->write_value("FILE_UPLOAD_FINISHED_" . $_GET['unique_id'], true, true); } else { $session_file_array[1] = 1; $session->write_value("FILE_UPLOAD_" . $_GET['unique_id'], $session_file_array, true); $session->write_value("FILE_UPLOAD_FINISHED_" . $_GET['unique_id'], true, true); } } }
/** * @see FolderInterface::is_folder_image_content() * @return bool */ public function is_folder_image_content() { if ($this->folder and $this->folder_id) { $data_entity_array = $this->get_children(); if (is_array($data_entity_array) and count($data_entity_array) >= 1) { foreach ($data_entity_array as $key => $value) { if (($file_id = File::get_file_id_by_data_entity_id($value)) != null) { $file = File::get_instance($file_id); if ($file->is_image() == true) { return true; } } } } return false; } else { return false; } }
/** * @throws FolderIDMissingException */ public static function change_group() { if ($_GET['file_id'] or $_GET['value_id'] or $_GET['parameter_id'] or $_GET['folder_id']) { if ($_GET['file_id']) { $id = $_GET['file_id']; $object = File::get_instance($id); $type = "file"; $title = $object->get_name(); } if ($_GET['value_id']) { $id = $_GET['value_id']; $object = Value::get_instance($id); $type = "value"; $title = $object->get_type_name(); } if ($_GET['parameter_id']) { $id = $_GET['parameter_id']; $object = Parameter::get_instance($id); $type = "parameter"; $title = $object->get_name(); } if ($_GET['folder_id']) { $id = $_GET['folder_id']; $object = Folder::get_instance($id); $type = "folder"; $title = $object->get_name(); } } else { throw new FolderIDMissingException(); } if ($object->is_control_access() == true) { $data_permission = new DataPermission($type, $id); if (!$_GET['nextpage']) { $template = new HTMLTemplate("data/data_change_group.html"); $paramquery = $_GET; $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("title", $title); $template->set_var("error", ""); $group_array = Group::list_groups(); $result = array(); $counter = 0; foreach ($group_array as $key => $value) { $group = new Group($value); $result[$counter]['value'] = $value; $result[$counter]['content'] = $group->get_name(); $counter++; } $template->set_var("option", $result); $paramquery = $_GET; $paramquery['action'] = "permission"; unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); $template->set_var("back_link", $params); $template->output(); } else { $paramquery = $_GET; $paramquery['action'] = "permission"; unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); if ($data_permission->set_owner_group_id($_POST['group']) == true) { Common_IO::step_proceed($params, "Permission: " . $title . "", "Changes saved succesful", null); } else { Common_IO::step_proceed($params, "Permission: " . $title . "", "Operation failed", null); } } } else { throw new DataSecuriyAccessDeniedException(); } }
/** * @param string $json_column_array * @param string $json_argument_array * @param string $css_page_id * @param string $css_row_sort_id * @param string $entries_per_page * @param string $page * @param string $sortvalue * @param string $sortmethod * @return string * @throws BaseAjaxArgumentMissingException */ public static function list_data($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod) { $argument_array = json_decode($json_argument_array); if (is_array($argument_array)) { $folder_id = $argument_array[0][1]; $name = $argument_array[1][1]; $list_request = new ListRequest_IO(); $list_request->set_column_array($json_column_array); if (!is_numeric($entries_per_page) or $entries_per_page < 1) { $entries_per_page = 20; } $list_array = Data_Wrapper::list_search_ffv($folder_id, $name, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page); if (is_array($list_array) and count($list_array) >= 1) { foreach ($list_array as $key => $value) { $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']); $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false); $owner = new User($value['owner']); $list_array[$key]['owner'] = $owner->get_full_name(true); if (is_numeric($value['file_id'])) { $file = File::get_instance($value['file_id']); $paramquery = $_GET; $paramquery['nav'] = "data"; $paramquery['action'] = "file_detail"; $paramquery['file_id'] = $value['file_id']; unset($paramquery['sortvalue']); unset($paramquery['sortmethod']); unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); $tmp_name = $value['name']; unset($list_array[$key]['name']); $list_array[$key]['name']['content'] = $tmp_name; if ($file->is_read_access() == true) { $list_array[$key]['symbol']['link'] = $params; $list_array[$key]['symbol']['content'] = "<img src='" . File::get_icon_by_name($value['name']) . "' alt='' style='border:0;' />"; $list_array[$key]['name']['link'] = $params; } else { $list_array[$key]['symbol']['link'] = ""; $list_array[$key]['symbol']['content'] = "<img src='core/images/denied_overlay.php?image=" . File::get_icon_by_name($value['name']) . "' alt='' border='0' />"; $list_array[$key]['name']['link'] = ""; } $list_array[$key]['type'] = "File"; $list_array[$key]['version'] = $file->get_version(); $list_array[$key]['size'] = Convert::convert_byte_1024($file->get_size()); $list_array[$key]['permission'] = $file->get_permission_string(); } if (is_numeric($value['value_id'])) { $value_obj = Value::get_instance($value['value_id']); $paramquery = $_GET; $paramquery['nav'] = "data"; $paramquery['action'] = "value_detail"; $paramquery['value_id'] = $value['value_id']; unset($paramquery['sortvalue']); unset($paramquery['sortmethod']); unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); $tmp_name = $value['name']; unset($list_array[$key]['name']); $list_array[$key]['name']['content'] = $tmp_name; if ($value_obj->is_read_access() == true) { $list_array[$key]['symbol']['link'] = $params; $list_array[$key]['symbol']['content'] = "<img src='images/fileicons/16/unknown.png' alt='' style='border: 0;'>"; $list_array[$key]['name']['link'] = $params; } else { $list_array[$key]['symbol']['link'] = ""; $list_array[$key]['symbol']['content'] = "<img src='core/images/denied_overlay.php?image=images/fileicons/16/unknown.png' alt='' border='0' />"; $list_array[$key]['name']['link'] = ""; } $list_array[$key]['type'] = "Value"; $list_array[$key]['version'] = $value_obj->get_version(); $list_array[$key]['permission'] = $value_obj->get_permission_string(); } if (is_numeric($value['folder_id'])) { $folder = Folder::get_instance($value['folder_id']); $paramquery = $_GET; $paramquery['nav'] = "data"; $paramquery['folder_id'] = $value['folder_id']; unset($paramquery['run']); unset($paramquery['sortvalue']); unset($paramquery['sortmethod']); unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); $tmp_name = $value['name']; unset($list_array[$key]['name']); $list_array[$key]['name']['content'] = $tmp_name; if ($folder->is_read_access() == true) { $list_array[$key]['symbol']['link'] = $params; $list_array[$key]['symbol']['content'] = "<img src='images/icons/folder.png' alt='' style='border: 0;'>"; $list_array[$key]['name']['link'] = $params; } else { $list_array[$key]['symbol']['link'] = ""; $list_array[$key]['symbol']['content'] = "<img src='core/images/denied_overlay.php?image=images/icons/folder.png' alt='' border='0' />"; $list_array[$key]['name']['link'] = ""; } $list_array[$key]['type'] = "Folder"; $list_array[$key]['permission'] = $folder->get_permission_string(); } } } else { $list_request->empty_message("<span class='italic'>No results found!</span>"); } $list_request->set_array($list_array); return $list_request->get_page($page); } else { throw new BaseAjaxArgumentMissingException(); } }
/** * @see EventListenerInterface::listen_events() * @param object $event_object * @return bool */ public static function listen_events($event_object) { if ($event_object instanceof ItemUnlinkEvent) { if (($data_entity_id = DataEntityIsItem_Access::get_entry_by_item_id($event_object->get_item_id())) != null) { if (($file_id = File::get_file_id_by_data_entity_id($data_entity_id)) != null) { $file = File::get_instance($file_id); if ($file->delete() == false) { return false; } } if (($value_id = Value::get_value_id_by_data_entity_id($data_entity_id)) != null) { $value = Value::get_instance($value_id); if ($value->delete() == false) { return false; } } if (($parameter_id = Parameter::get_parameter_id_by_data_entity_id($data_entity_id)) != null) { $parameter = Parameter::get_instance($parameter_id); if ($parameter->delete() == false) { return false; } } } } if ($event_object instanceof UserDeleteEvent) { if (DataEntity_Access::set_owner_id_on_null($event_object->get_user_id()) == false) { return true; } } if ($event_object instanceof GroupDeleteEvent) { if (DataEntity_Access::set_owner_group_id_on_null($event_object->get_group_id()) == false) { return true; } } return true; }