211 lines
9.1 KiB
PHP
211 lines
9.1 KiB
PHP
<?php
|
|
/** \file scripts\page\menu_version_info.php
|
|
* \brief DI webinterface menu system version maintenance script.
|
|
* \author Jack, Core|Vision
|
|
* \version $Revision: 26247 $
|
|
* \date $Date: 2016-02-29 10:40:22 +0100 (Mon, 29 Feb 2016) $
|
|
*
|
|
* This file contains the menu system version maintenance
|
|
*
|
|
*/
|
|
|
|
//=== Menu structure ===
|
|
|
|
// Check that this page is called with the correct action (to prevent illegal access)
|
|
if( !is_valid_action("version_new","version_duplicate","version_info","version_change") ) {
|
|
// 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'] ) {
|
|
// Return from call
|
|
}
|
|
else if (is_valid_action("version_new")) {
|
|
// new item: generated temporary identifier as index in the array
|
|
$t = gettimeofday(TRUE);
|
|
$_SESSION[$_PAGE_INFO['id']]['version_id'] = "tmp_" . sprintf("%u%06u", $t, ($t - floor($t)) * 1000);
|
|
$_SESSION[$_PAGE_INFO['id']]['version_info'] = array();
|
|
$_SESSION[$_PAGE_INFO['id']]['version_doc'] = array();
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog'] = array();
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog_doc'] = array();
|
|
|
|
// save the system component from system component page, or the search screen
|
|
if( is_valid_call("system_component*") ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_info']['syscomp'] = $_SESSION[$_PAGE_INFO['id']]['syscomp_id'];
|
|
}
|
|
else {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_info']['syscomp'] = $_SESSION[$_PAGE_INFO['id']]['search']['s&o']['syscomp_id'];
|
|
}
|
|
|
|
if( is_valid_call("system_component*") ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_info']['device'] = $_SESSION[$_PAGE_INFO['id']]['syscomp_info']['device'];
|
|
}
|
|
}
|
|
else if( is_valid_action("version_info","version_duplicate","version_change") ) {
|
|
// get the identifier from either the command-line or the search screen
|
|
if( isset($_GET['version_id']) ) {
|
|
// set change log identifier from the URL
|
|
$_SESSION[$_PAGE_INFO['id']]['version_id'] = decrypt($_GET['version_id'], "version_id_" . $_SESSION[$_PAGE_INFO['id']]['login']['user']['id']);
|
|
}
|
|
else {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_id'] = $_SESSION[$_PAGE_INFO['id']]['search']['s&o']['version_id'];
|
|
}
|
|
|
|
if (isset($_SESSION[$_PAGE_INFO['id']]['version_id'])) {
|
|
if(
|
|
is_valid_call("system_component_new","system_component_duplicate","system_component_change") &&
|
|
is_array($_SESSION[$_PAGE_INFO['id']]['syscomp_version'][$_SESSION[$_PAGE_INFO['id']]['version_id']])
|
|
) {
|
|
// version is stored in the system component info array
|
|
$version = $_SESSION[$_PAGE_INFO['id']]['syscomp_version'][$_SESSION[$_PAGE_INFO['id']]['version_id']];
|
|
$version['id'] = $_SESSION[$_PAGE_INFO['id']]['version_id'];
|
|
}
|
|
else {
|
|
$version = db_fetch_system_version($_SESSION[$_PAGE_INFO['id']]['version_id']);
|
|
}
|
|
|
|
if( $version ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_info'] = $version;
|
|
|
|
// pre-fetch the documents and other uploads
|
|
if( is_array($_SESSION[$_PAGE_INFO['id']]['syscomp_version_doc'][$version['id']]) ) {
|
|
// version is stored in the system component info array
|
|
$_SESSION[$_PAGE_INFO['id']]['version_doc'] = $_SESSION[$_PAGE_INFO['id']]['syscomp_version_doc'][$version['id']];
|
|
}
|
|
else {
|
|
// fetch the documents from the database
|
|
$_SESSION[$_PAGE_INFO['id']]['version_doc'] = db_fetch_files($version['id'], "changelog_versie_documenten", FALSE, "ASC");
|
|
}
|
|
|
|
// pre-fetch the change log items
|
|
if(
|
|
is_valid_call("system_component_new","system_component_duplicate","system_component_change") &&
|
|
is_array($_SESSION[$_PAGE_INFO['id']]['syscomp_version'][$version['id']]['changelog'])
|
|
) {
|
|
if( is_valid_action("version_duplicate") ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog'] = array();
|
|
foreach( $_SESSION[$_PAGE_INFO['id']]['syscomp_version'][$version['id']]['changelog'] as $change ) {
|
|
// insert a copy of this change
|
|
$change['id'] = "tmp_copy_" . $change['id'];
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog'][$change['id']] = $change;
|
|
}
|
|
// copy the documents
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog_doc'] = array();
|
|
foreach( $_SESSION[$_PAGE_INFO['id']]['syscomp_version'][$version['id']]['changelog_doc'] as $changelog_id => $documents ) {
|
|
foreach( $documents as $doc ) {
|
|
// insert a copy of the document
|
|
$changelog_id = "tmp_copy_" . $changelog_id;
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog_doc'][$changelog_id][] = db_duplicate_file($doc);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog'] = $_SESSION[$_PAGE_INFO['id']]['syscomp_version'][$version['id']]['changelog'];
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog_doc'] = $_SESSION[$_PAGE_INFO['id']]['syscomp_version'][$version['id']]['changelog_doc'];
|
|
}
|
|
}
|
|
else {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog'] = array();
|
|
if( is_valid_action("version_duplicate") ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog_doc'] = array();
|
|
}
|
|
else {
|
|
// change log documentation will be fetched when needed
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog_doc'] = NULL;
|
|
}
|
|
|
|
$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
|
|
if( is_valid_action("version_duplicate") ) {
|
|
$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");
|
|
// copy the documents for this change
|
|
foreach( $documents as $doc ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog_doc'][$changelog_id][] = db_duplicate_file($doc);
|
|
}
|
|
// clean-up
|
|
unset($documents);
|
|
|
|
// set the new, temporary identifier
|
|
$changelog_item['id'] = $changelog_id;
|
|
}
|
|
|
|
$_SESSION[$_PAGE_INFO['id']]['version_changelog'][$changelog_item['id']] = $changelog_item;
|
|
}
|
|
// clean up
|
|
unset($changelog_items);
|
|
}
|
|
|
|
if( is_valid_action("version_duplicate") ) {
|
|
// the version identifier is invalid, as we are copying the original data
|
|
$_SESSION[$_PAGE_INFO['id']]['version_id'] = "tmp_copy_" . $version['id'];
|
|
|
|
// copy the documents
|
|
$documents = $_SESSION[$_PAGE_INFO['id']]['version_doc'];
|
|
$_SESSION[$_PAGE_INFO['id']]['version_doc'] = array();
|
|
foreach( $documents as $doc ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['version_doc'][] = db_duplicate_file($doc);
|
|
}
|
|
// clean-up
|
|
unset($documents);
|
|
}
|
|
|
|
// clean-up
|
|
unset($version);
|
|
}
|
|
else {
|
|
// ID not valid!!! => Redirect back to search menu
|
|
header("Location: ?id=" . $_PAGE_INFO['id'] . "&href=page/menu_version_search&action=" . current_action(TRUE));
|
|
trigger_error("Version ID not valid", E_USER_ERROR);
|
|
}
|
|
}
|
|
else {
|
|
// ID not selected
|
|
header("Location: ?id=" . $_PAGE_INFO['id'] . "&href=page/menu_version_search&action=" . current_action(TRUE));
|
|
trigger_error("Version ID not set", E_USER_ERROR);
|
|
}
|
|
}
|
|
|
|
// the version data is closely linked to the system component; fetch it
|
|
// if not set (when this page is called bypassing 'syscomp_info')
|
|
if( !is_valid_call("system_component*") ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['syscomp_info'] = db_fetch_system_component($_SESSION[$_PAGE_INFO['id']]['version_info']['syscomp']);
|
|
}
|
|
|
|
// Sort change log?
|
|
if( is_valid_return("changelog_add") ) {
|
|
function uasort_changelog($a,$b) {
|
|
return $a['volgorde'] - $b['volgorde'];
|
|
}
|
|
|
|
uasort($_SESSION[$_PAGE_INFO['id']]['version_changelog'], "uasort_changelog");
|
|
}
|
|
|
|
// 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']]['version_info']['y_position'])) ? ($_SESSION[$_PAGE_INFO['id']]['version_info']['y_position']) : 0;
|
|
print_xml_header($y_position, $extra_header_HTML);
|
|
|
|
// Include info content
|
|
include("menu_version_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);
|
|
}
|
|
|
|
?>
|