191 lines
8.1 KiB
PHP
191 lines
8.1 KiB
PHP
<?php
|
|
/** \file scripts\page\menu_syscomp_info.php
|
|
* \brief DI webinterface menu system component maintenance script.
|
|
* \author Jack Weeland, Core|Vision
|
|
* \version $Revision: 26247 $
|
|
* \date $Date: 2016-02-29 10:40:22 +0100 (Mon, 29 Feb 2016) $
|
|
*
|
|
* This file contains the menu system component maintenance
|
|
*
|
|
*/
|
|
|
|
//=== Menu structure ===
|
|
|
|
// Check that this page is called with the correct action (to prevent illegal access)
|
|
if( !is_valid_action("system_component_new","system_component_duplicate","system_component_change","system_component_info") ) {
|
|
// Redirect page back to login page
|
|
force_logout(_("No valid rights"), "Invalid action: " . current_action(TRUE));
|
|
}
|
|
|
|
$page = new MTinfoPage();
|
|
|
|
//===========================================
|
|
|
|
// Verify project/rights and log
|
|
if( $page->user_has_rights() ) {
|
|
if( $_SESSION[$_PAGE_INFO['id']]['recall_counter'] ) {
|
|
// recall or return from called page; keep the session info
|
|
}
|
|
else if (is_valid_action("system_component_new")) {
|
|
// new item: generated temporary identifier as index in the array
|
|
$t = gettimeofday(TRUE);
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_id'] = "tmp_" . sprintf("%u%06u", $t, ($t - floor($t)) * 1000);
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_info'] = array();
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_doc'] = array();
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_version'] = array();
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_version_doc'] = array();
|
|
|
|
if( is_valid_call("equipment_new","equipment_change") ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_info']['device'] = $_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device'];
|
|
}
|
|
else {
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_info']['device'] = $_SESSION[$_PAGE_INFO['id']]['defaults']['s&o']['device'];
|
|
}
|
|
}
|
|
else if( is_valid_action("system_component_info","system_component_duplicate","system_component_change") ) {
|
|
// get the identifier from either the command-line or the search screen
|
|
if( isset($_GET['syscomp_id']) ) {
|
|
// set change log identifier from the URL
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_id'] = decrypt($_GET['syscomp_id'], "syscomp_id_" . $_SESSION[$_PAGE_INFO['id']]['login']['user']['id']);
|
|
}
|
|
else {
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_id'] = $_SESSION[$_PAGE_INFO['id']]['search']['s&o']['syscomp_id'];
|
|
}
|
|
|
|
if (isset($_SESSION[$_PAGE_INFO['id']]['syscomp_id'])) {
|
|
$syscomp = db_fetch_system_component($_SESSION[$_PAGE_INFO['id']]['syscomp_id']);
|
|
|
|
if( $syscomp ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_info'] = $syscomp;
|
|
|
|
if( is_valid_action("system_component_duplicate") ) {
|
|
// the identifier is invalid, as we are copying the original data
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_info']['id'] =
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_id'] = "tmp_copy_" . $syscomp['id'];
|
|
|
|
// copy the documents
|
|
$documents = db_fetch_files($syscomp['id'], "syscomp_documenten", FALSE, "ASC");
|
|
foreach( $documents as $doc ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_doc'][] = db_duplicate_file($doc);
|
|
}
|
|
// clean-up
|
|
unset($documents);
|
|
}
|
|
else {
|
|
// pre-fetch the documents and other uploads
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_doc'] = db_fetch_files($syscomp['id'], "syscomp_documenten", FALSE, "ASC");
|
|
}
|
|
|
|
// pre-fetch the versions and change log items, with their documents
|
|
$versions = db_search_system_versions($_SESSION[$_PAGE_INFO['id']]['i18n'], $syscomp['id']);
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_version'] = array();
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_version_doc'] = array();
|
|
if( $versions ) foreach( $versions as $version ) {
|
|
if( is_valid_action("system_component_duplicate") ) {
|
|
$version_id = "tmp_copy_" . $version['id'];
|
|
}
|
|
else {
|
|
$version_id = $version['id'];
|
|
}
|
|
|
|
// Link back to the system component (not fetched by 'db_search_system_versions',
|
|
// but a version is valid for only one system component: this one
|
|
$version['syscomp'] = $_SESSION[$_PAGE_INFO['id']]['syscomp_id'];
|
|
|
|
if( is_valid_action("system_component_duplicate") ) {
|
|
// copy the documents for the version
|
|
$version_doc = array();
|
|
$documents = db_fetch_files($version['id'], "changelog_versie_documenten", FALSE, "ASC");
|
|
foreach( $documents as $doc ) {
|
|
$version_doc[] = db_duplicate_file($doc);
|
|
}
|
|
// clean up
|
|
unset($documents);
|
|
|
|
// fetch the changelog for the version
|
|
$version['changelog'] = array();
|
|
$version['changelog_doc'] = array();
|
|
|
|
// copy the changelog items
|
|
$changelog_items = db_fetch_version_changelog($version['id']);
|
|
if( $changelog_items ) foreach( $changelog_items as $changelog_item ) {
|
|
// save off the identifier; it will be replaced when the items are duplicated
|
|
$changelog_id = "tmp_copy_" . $changelog_item['id'];
|
|
|
|
// fetch the documents for the original change
|
|
$documents = db_fetch_files($changelog_item['id'], "changelog_versie_change_documenten", FALSE, "ASC");
|
|
$version['changelog_doc'][$changelog_id] = array();
|
|
// copy the documents for this change
|
|
foreach( $documents as $doc ) {
|
|
$version['changelog_doc'][$changelog_id][] = db_duplicate_file($doc);
|
|
}
|
|
// clean-up
|
|
unset($documents);
|
|
|
|
// link to this system component
|
|
$changelog_item['syscomp'] = $_SESSION[$_PAGE_INFO['id']]['syscomp_id'];
|
|
// copy the links to the equipment types
|
|
$changelog_item['device'] = $version['device'];
|
|
|
|
// set the new, temporary identifier
|
|
$changelog_item['id'] = $changelog_id;
|
|
$version['changelog'][$changelog_item['id']] = $changelog_item;
|
|
}
|
|
// clean up
|
|
unset($changelog_items);
|
|
}
|
|
else {
|
|
// fetch the documents and change log when needed
|
|
$version_doc = NULL;
|
|
// initialize the change log array
|
|
$version['changelog'] = NULL;
|
|
$version['changelog_doc'] = NULL;
|
|
}
|
|
|
|
// store the version info
|
|
$version['id'] = $version_id;
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_version'][$version_id] = $version;
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_version_doc'][$version_id] = $version_doc;
|
|
// clean up
|
|
unset($version_doc);
|
|
unset($version['changelog']);
|
|
unset($version['changelog_doc']);
|
|
}
|
|
}
|
|
else {
|
|
// ID not valid!!! => Redirect back to search menu
|
|
header("Location: ?id=" . $_PAGE_INFO['id'] . "&href=page/menu_syscomp_search&action=" . current_action(TRUE));
|
|
trigger_error("System component ID not valid", E_USER_ERROR);
|
|
}
|
|
}
|
|
else {
|
|
// ID not selected
|
|
header("Location: ?id=" . $_PAGE_INFO['id'] . "&href=page/menu_syscomp_search&action=" . current_action(TRUE));
|
|
trigger_error("System component ID not set", E_USER_ERROR);
|
|
}
|
|
}
|
|
|
|
// Nested call?
|
|
if( !$_SESSION[$_PAGE_INFO['id']]['recall_counter'] ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_info']['return_action'] = $_SESSION[$_PAGE_INFO['id']]['return_action'];
|
|
}
|
|
|
|
// Add calendar to header
|
|
$extra_header_HTML = "<script type=\"text/javascript\" src=\"" . JAVA_DIR . "calender.js\"></script>\n";
|
|
|
|
// Show page header
|
|
$y_position = (isset($_SESSION[$_PAGE_INFO['id']]['syscomp_info']['y_position'])) ? ($_SESSION[$_PAGE_INFO['id']]['syscomp_info']['y_position']) : 0;
|
|
print_xml_header($y_position, $extra_header_HTML);
|
|
|
|
// Include info content
|
|
include("menu_syscomp_info_content.php");
|
|
|
|
// Show page footer
|
|
print_page_footer();
|
|
}
|
|
else {
|
|
// Redirect page back to login page
|
|
force_logout(_("No valid rights"), "No rights for menu " . $page->menu . ": " . $page->rights);
|
|
}
|
|
|
|
?>
|