mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
Synchro cleanup (#157)
* Cleanup duplicate code * Document undocumented parameter * Removed duplicate code for consistency
This commit is contained in:
@@ -45,7 +45,7 @@ function UsageAndExit($oP)
|
||||
if ($bModeCLI)
|
||||
{
|
||||
$oP->p("USAGE:\n");
|
||||
$oP->p("php -q synchro_exec.php --auth_user=<login> --auth_pwd=<password> --data_sources=<comma_separated_list_of_data_sources> [max_chunk_size=<limit the count of replica loaded in a single pass>]\n");
|
||||
$oP->p("php -q synchro_exec.php --auth_user=<login> --auth_pwd=<password> --data_sources=<comma_separated_list_of_data_sources> [--max_chunk_size=<limit the count of replica loaded in a single pass>] [--simulate=<If set to 1, then the synchro will not be executed, but the expected report will be produced>]\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -92,12 +92,8 @@ catch(Exception $e)
|
||||
|
||||
if (utils::IsModeCLI())
|
||||
{
|
||||
// Next steps:
|
||||
// specific arguments: 'csvfile'
|
||||
//
|
||||
$sAuthUser = ReadMandatoryParam($oP, 'auth_user', 'raw_data');
|
||||
$sAuthPwd = ReadMandatoryParam($oP, 'auth_pwd', 'raw_data');
|
||||
$sDataSourcesList = ReadMandatoryParam($oP, 'data_sources', 'raw_data'); // May contain commas
|
||||
if (UserRights::CheckCredentials($sAuthUser, $sAuthPwd))
|
||||
{
|
||||
UserRights::Login($sAuthUser); // Login & set the user's language
|
||||
@@ -113,16 +109,15 @@ else
|
||||
{
|
||||
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
|
||||
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
|
||||
|
||||
$sDataSourcesList = utils::ReadParam('data_sources', null, true, 'raw_data');
|
||||
|
||||
if ($sDataSourcesList == null)
|
||||
{
|
||||
UsageAndExit($oP);
|
||||
}
|
||||
}
|
||||
|
||||
$bSimulate = (utils::ReadParam('simulate', '0', true) == '1');
|
||||
$sDataSourcesList = ReadMandatoryParam($oP, 'data_sources', 'raw_data'); // May contain commas
|
||||
|
||||
if ($sDataSourcesList == null)
|
||||
{
|
||||
UsageAndExit($oP);
|
||||
}
|
||||
|
||||
|
||||
foreach(explode(',', $sDataSourcesList) as $iSDS)
|
||||
|
||||
@@ -159,27 +159,16 @@ $aPageParams = array
|
||||
function UsageAndExit($oP)
|
||||
{
|
||||
global $aPageParams;
|
||||
$bModeCLI = utils::IsModeCLI();
|
||||
$sMode = utils::IsModeCLI() ? 'cli' : 'http';
|
||||
|
||||
$oP->p("USAGE:\n");
|
||||
foreach ($aPageParams as $sParam => $aParamData)
|
||||
{
|
||||
$aModes = explode(',', $aParamData['modes']);
|
||||
if ($bModeCLI)
|
||||
if (in_array($sMode, $aModes, false))
|
||||
{
|
||||
if (in_array('cli', $aModes, false))
|
||||
{
|
||||
$sDesc = $aParamData['description'].', '.($aParamData['mandatory'] ? 'mandatory' : 'optional, defaults to ['.$aParamData['default'].']');
|
||||
$oP->p("$sParam = $sDesc");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (in_array('http', $aModes, false))
|
||||
{
|
||||
$sDesc = $aParamData['description'].', '.($aParamData['mandatory'] ? 'mandatory' : 'optional, defaults to ['.$aParamData['default'].']');
|
||||
$oP->p("$sParam = $sDesc");
|
||||
}
|
||||
$sDesc = $aParamData['description'].', '.($aParamData['mandatory'] ? 'mandatory' : 'optional, defaults to ['.$aParamData['default'].']');
|
||||
$oP->p("$sParam = $sDesc");
|
||||
}
|
||||
}
|
||||
$oP->output();
|
||||
|
||||
Reference in New Issue
Block a user