mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
Improved the data load during the setup:
- Sample data are clearly separated from the structure data (inc. menus and user profiles) - Both categories of data are enumerated from specific folders SVN:trunk[100]
This commit is contained in:
@@ -26,11 +26,3 @@ wget --output-document=19.infracontracts.xml --post-data="auth_user=%USER%&auth_
|
||||
wget --output-document=20.contactcontracts.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT lnkContactContract&format=xml"
|
||||
wget --output-document=21.auditcategories.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT AuditCategory&format=xml"
|
||||
wget --output-document=22.auditrules.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT AuditRule&format=xml"
|
||||
wget --output-document=23.dimensions.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_Dimensions&format=xml"
|
||||
wget --output-document=24.profiles.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_Profiles&format=xml"
|
||||
wget --output-document=25.classprojection.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_ClassProjection&format=xml"
|
||||
wget --output-document=26.profileprojection.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_ProfileProjection&format=xml"
|
||||
wget --output-document=27.actiongrant.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_ActionGrant&format=xml"
|
||||
wget --output-document=28.attributegrant.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_AttributeGrant&format=xml"
|
||||
wget --output-document=29.stimulusgrant.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_StimulusGrant&format=xml"
|
||||
pause
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
SET WEBROOT=http://localhost:81
|
||||
SET USER=Erwan
|
||||
SET PWD=Taloc
|
||||
SET USER=admin
|
||||
SET PWD=admin
|
||||
|
||||
REM The order (numbering) of the files is important since
|
||||
REM it dictates the order to import them back
|
||||
wget --output-document=1.menus.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%WEBROOT%/pages/export.php?expression=SELECT menuNode WHERE type%%3D%%27application%%27&format=xml"
|
||||
13
setup/data/structure/export_profiles.cmd
Normal file
13
setup/data/structure/export_profiles.cmd
Normal file
@@ -0,0 +1,13 @@
|
||||
SET WEBROOT=http://localhost:81
|
||||
SET USER=admin
|
||||
SET PWD=admin
|
||||
|
||||
REM The order (numbering) of the files is important since
|
||||
REM it dictates the order to import them back
|
||||
wget --output-document=10.dimensions.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_Dimensions&format=xml"
|
||||
wget --output-document=11.profiles.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_Profiles&format=xml"
|
||||
wget --output-document=12.classprojection.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_ClassProjection&format=xml"
|
||||
wget --output-document=13.profileprojection.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_ProfileProjection&format=xml"
|
||||
wget --output-document=14.actiongrant.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_ActionGrant&format=xml"
|
||||
wget --output-document=15.attributegrant.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_AttributeGrant&format=xml"
|
||||
wget --output-document=16.stimulusgrant.xml --post-data="auth_user=%USER%&auth_pwd=%PWD%&operation=login" "%EXPORT%?expression=SELECT URP_StimulusGrant&format=xml"
|
||||
@@ -8,7 +8,8 @@ require_once('../core/cmdbsource.class.inc.php');
|
||||
require_once('./setuppage.class.inc.php');
|
||||
define('TMP_CONFIG_FILE', '../tmp-config-itop.php');
|
||||
define('FINAL_CONFIG_FILE', '../config-itop.php');
|
||||
define('SETUP_DATA_DIR', './data');
|
||||
define('SETUP_STRUCTURE_DATA_DIR', './data/structure');
|
||||
define('SETUP_SAMPLE_DATA_DIR', './data');
|
||||
define('PHP_MIN_VERSION', '5.2.0');
|
||||
define('MYSQL_MIN_VERSION', '5.0.0');
|
||||
|
||||
@@ -173,45 +174,66 @@ function CreateAdminAccount(setup_web_page $oP, Config $oConfig, $sAdminUser, $s
|
||||
}
|
||||
}
|
||||
|
||||
//aFilesToLoad[aFilesToLoad.length] = './menus.xml'; // First load the menus
|
||||
|
||||
function ListDataFiles($sDirectory, setup_web_page $oP)
|
||||
{
|
||||
$aFilesToLoad = array();
|
||||
if ($hDir = @opendir($sDirectory))
|
||||
{
|
||||
// This is the correct way to loop over the directory. (according to the documentation)
|
||||
while (($sFile = readdir($hDir)) !== false)
|
||||
{
|
||||
$sExtension = pathinfo($sFile, PATHINFO_EXTENSION );
|
||||
if (strcasecmp($sExtension, 'xml') == 0)
|
||||
{
|
||||
$aFilesToLoad[] = $sDirectory.'/'.$sFile;
|
||||
}
|
||||
}
|
||||
closedir($hDir);
|
||||
// Load order is important we expect the files to be ordered
|
||||
// like numbered 1.Organizations.xml 2.Locations.xml , etc.
|
||||
asort($aFilesToLoad);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oP->error("Data directory (".$sDirectory.") not found or not readable.");
|
||||
}
|
||||
return $aFilesToLoad;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scans the ./data directory for XML files and output them as a Javascript array
|
||||
*/
|
||||
function PopulateDataFilesList(setup_web_page $oP)
|
||||
{
|
||||
if ($hDir = @opendir(SETUP_DATA_DIR))
|
||||
|
||||
$oP->add("<script type=\"text/javascript\">\n");
|
||||
$oP->add("function PopulateDataFilesList()\n");
|
||||
$oP->add("{\n");
|
||||
|
||||
// Structure data
|
||||
//
|
||||
$aStructureDataFiles = ListDataFiles(SETUP_STRUCTURE_DATA_DIR, $oP);
|
||||
foreach($aStructureDataFiles as $sFile)
|
||||
{
|
||||
$aFilesToLoad = array();
|
||||
// This is the correct way to loop over the directory. (according the documentation)
|
||||
while (($sFile = readdir($hDir)) !== false)
|
||||
{
|
||||
$sExtension = pathinfo($sFile, PATHINFO_EXTENSION );
|
||||
if (strcasecmp($sExtension, 'xml') == 0)
|
||||
{
|
||||
$aFilesToLoad[] = SETUP_DATA_DIR.'/'.$sFile;
|
||||
}
|
||||
}
|
||||
closedir($hDir);
|
||||
// Load order is important we expect the files to be ordered
|
||||
// like numbered 1.Organizations.xml 2.Locations.xml , etc.
|
||||
asort($aFilesToLoad);
|
||||
// Menus can be loaded any time... like here at the end
|
||||
|
||||
$oP->add("<script type=\"text/javascript\">\n");
|
||||
$oP->add("function PopulateDataFilesList()\n");
|
||||
$oP->add("{\n");
|
||||
$index = 0;
|
||||
foreach($aFilesToLoad as $sFile)
|
||||
{
|
||||
$oP->add("aFilesToLoad[aFilesToLoad.length] = '$sFile';\n");
|
||||
$index++;
|
||||
}
|
||||
$oP->add("}\n");
|
||||
$oP->add("</script>\n");
|
||||
$oP->add("aFilesToLoad[aFilesToLoad.length] = '$sFile';\n");
|
||||
}
|
||||
else
|
||||
|
||||
// Sample data - loaded IIF wished by the user
|
||||
//
|
||||
$oP->add("if (($(\"#sample_data:checked\").length == 1))");
|
||||
$oP->add("{");
|
||||
$aSampleDataFiles = ListDataFiles(SETUP_SAMPLE_DATA_DIR, $oP);
|
||||
foreach($aSampleDataFiles as $sFile)
|
||||
{
|
||||
$oP->error("Data directory (".SETUP_DATA_DIR.") no found or not readable.");
|
||||
$oP->add("aFilesToLoad[aFilesToLoad.length] = '$sFile';\n");
|
||||
}
|
||||
$oP->add("}\n");
|
||||
|
||||
$oP->add("}\n");
|
||||
$oP->add("</script>\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,12 +89,9 @@ var aFilesToLoad = new Array();
|
||||
|
||||
function DoLoadDataAsynchronous()
|
||||
{
|
||||
// Check if sample data must be loaded, or just the menus
|
||||
aFilesToLoad[aFilesToLoad.length] = './menus.xml'; // First load the menus
|
||||
if (($("#sample_data:checked").length == 1))
|
||||
{
|
||||
PopulateDataFilesList(); // Function created in PHP to get the list of XML files on the server
|
||||
}
|
||||
// The array aFilesToLoad is populated by this function dynamically written on the server
|
||||
PopulateDataFilesList();
|
||||
|
||||
$('#setup').block({message: '<p>Loading data...<br/><div id=\"progress\">0%</div></p>'});
|
||||
$('#progress').progression( {Current:0, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
|
||||
LoadNextDataFile('', '');
|
||||
|
||||
Reference in New Issue
Block a user