Pārlūkot izejas kodu

Remove unused/obsolete pages

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@396 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 gadi atpakaļ
vecāks
revīzija
fa77f991db
4 mainītis faili ar 0 papildinājumiem un 842 dzēšanām
  1. 0 310
      pages/advanced_search.php
  2. 0 40
      pages/ajax.php
  3. 0 321
      pages/data_generator.php
  4. 0 171
      pages/db_importer.php

+ 0 - 310
pages/advanced_search.php

@@ -1,310 +0,0 @@
-<?php
-
-// By Rom
-
-
-require_once('../application/nicewebpage.class.inc.php');
-require_once('../application/dialogstack.class.inc.php');
-
-require_once('../application/startup.inc.php');
-
-// #@# not used, but... require_once('../classes/usercontext.class.inc.php');
-$oPage = new NiceWebPage("ITop finder");
-$oPage->no_cache();
-
-
-MetaModel::CheckDefinitions();
-// new API - MetaModel::DBCheckFormat();
-// not necessary, and time consuming!
-// MetaModel::DBCheckIntegrity();
-
-
-function ReadParam($sName, $defaultValue = "")
-{
-	return isset($_REQUEST[$sName]) ? $_REQUEST[$sName] : $defaultValue;
-}
-
-
-
-function Page1_AskClass($oPage)
-{
-    $oPage->add("<form method=\"post\" action=\"\">\n");
-	//$oPage->add("<input type=\"hidden\" name=\"tnut\" value=\"blah\">");
-	$oPage->p("Please select the type of object that you want to look for:");
-    $oPage->MakeClassesSelect("class", "", 50, UR_ACTION_READ);
-    $oPage->add("<input type=\"submit\" name=\"userconfig\" value=\"Configure filters\">\n");
-	$oPage->add("</form>\n");
-}
-
-
-function Page2_ConfigFilters($oPage, $oFilter)
-{
-	$sClass = $oFilter->GetClass();
-
-	$oPage->p("Objects of class <em>$sClass</em>");
-    $oPage->add("<form method=\"post\" action=\"\">\n");
-	$oPage->add("<input type=\"hidden\" name=\"class\" value=\"$sClass\">\n"); 
-
-	// Full text input
-	//
-	$oPage->add("<div>\n");
-	$oPage->add("Full text: ");
-	$sFullText = "";
-	foreach($oFilter->GetCriteria_FullText() as $sFullText)
-	{
-		// #@# Known limitation: do not consider other full text conditions...
-		continue;
-	}
-	
-	$oPage->add("<input type=\"text\" name=\"flt_fulltext\" value=\"$sFullText\">\n"); 
-	$oPage->add("</div>\n");
-
-	// Attribute-related criteria
-	//
-	foreach (MetaModel::GetClassFilterDefs($sClass) as $sFltCode => $oFltDef)
-	{
-		// Set its current values
-		$sOpCode = "__none__";
-		$sValue = "";
-		foreach($oFilter->GetCriteria() as $aCritInfo)
-		{
-			if ($aCritInfo["filtercode"] == "id")
-			{
-				// ???
-			}
-			elseif ($aCritInfo["filtercode"] == $sFltCode)
-			{
-				$sOpCode = $aCritInfo["opcode"];
-				$sValue = $aCritInfo["value"];
-				break;
-			}
-		}
-
-		$oPage->add("<div>\n");
-		//$oPage->add($oFltDef->GetType()." (".$oFltDef->GetTypeDesc().")");
-		$oPage->add(" ".$oFltDef->GetLabel()." ");
-
-		$aOperators = array_merge(array("__none__" => ""), $oFltDef->GetOperators());
-		$oPage->add_select($aOperators, "flt_ops[$sFltCode]", $sOpCode, 100);
-		$oPage->add("\n");
-
-		$oPage->add("<input type=\"text\" name=\"flt_values[$sFltCode]\" value=\"$sValue\">\n"); 
-		$oPage->add("</div>\n");
-	}
-
-	// Ext key criteria
-	//
-	foreach (MetaModel::EnumReferencedClasses($sClass) as $sExtKeyAttCode => $sRemoteClass)
-	{
-		// Set its current values
-		$oSubFilter = $oFilter->GetCriteria_PointingTo($sExtKeyAttCode);
-		if (!$oSubFilter)
-		{
-			$oSubFilter = new CMDBSearchFilter($sRemoteClass);
-		}
-
-		$oPage->add("<div>\n");
-		$oAtt = MetaModel::GetAttributeDef($oFilter->GetClass(), $sExtKeyAttCode);
-		$oPage->add($oAtt->GetLabel()." having ({$oSubFilter->DescribeConditions()})");
-		//$oPage->add("having $oFilter->DescribeConditionPointTo($sExtKeyAttCode));
-		$oPage->add("\n");
-
-		$oPage->add(dialogstack::RenderEditableField("Edit...", "flt_pointto[$sExtKeyAttCode]", $oSubFilter->serialize(), true));
-		$oPage->add("</div>\n");
-	}
-
-	// Ext key criteria, the other way
-	//
-	foreach (MetaModel::EnumReferencingClasses($sClass, true) as $sRemoteClass => $aRemoteKeys)
-	{
-		foreach ($aRemoteKeys as $sExtKeyAttCode => $oExtKeyAttDef)
-		{
-			// Set its current values
-			$oSubFilter = $oFilter->GetCriteria_ReferencedBy($sRemoteClass, $sExtKeyAttCode);
-			if (!$oSubFilter)
-			{
-				$oSubFilter = new CMDBSearchFilter($sRemoteClass);
-			}
-
-			$oPage->add("<div>\n");
-			//$oPage->add($oFilter->DescribeConditionRefBy($sRemoteClass, $sExtKeyAttCode));
-			$oAtt = MetaModel::GetAttributeDef($sRemoteClass, $sExtKeyAttCode);
-			$oPage->add("being ".$oAtt->GetLabel()." for ".$sRemoteClass."(e)s in ({$oSubFilter->DescribeConditions()})");
-			$oPage->add("\n");
-	
-			$oPage->add(dialogstack::RenderEditableField("Edit...", "flt_refedby[$sRemoteClass][$sExtKeyAttCode]", $oSubFilter->serialize(), true));
-			$oPage->add("</div>\n");
-		}
-	}
-
-	// Ext key criteria -> link objects
-	//
-	foreach (MetaModel::EnumLinkingClasses($sClass) as $sLinkClass => $aRemoteClasses)
-	{
-		foreach($aRemoteClasses as $sExtKeyAttCode => $sRemoteClass)
-		{
-			// Set its current values
-			//$oSubFilter = $oFilter->GetCriteria_PointingTo($sExtKeyAttCode);
-			$oSubFilter = null;
-			if (!$oSubFilter)
-			{
-				$oSubFilter = new CMDBSearchFilter($sRemoteClass);
-			}
-			$oPage->add("<div>\n");
-			//$oPage->add(" ".MetaModel::GetName($sRemoteClass)." ");
-			$oPage->add(" Linked to '".MetaModel::GetLinkLabel($sLinkClass, $sExtKeyAttCode)."' by ");
-			$oSubFilter = new CMDBSearchFilter($sRemoteClass);
-			$oPage->add($oSubFilter->__DescribeHTML());
-			$oPage->add("\n");
-
-			$oPage->add(dialogstack::RenderEditableField("Edit...", "flt_linkedwith[$sRemoteClass][$sExtKeyAttCode]", $oSubFilter->serialize(), true));
-			$oPage->add("</div>\n");
-		}
-	}
-
-    $oPage->add("<input type=\"submit\" name=\"makeit\" value=\"Search\">\n");
-	$oPage->add("</form>\n");
-}
-
-function MakeFilterFromArgs()
-{
-	$sClass = ReadParam("class");
-	$sFilterFullText = ReadParam("flt_fulltext", "");
-	$aFilterOps = ReadParam("flt_ops", array());
-	$aFilterValues = ReadParam("flt_values", array());
-	$aPointTo = ReadParam("flt_pointto", array());
-	$aRefedBy = ReadParam("flt_refedby", array());
-	$aLinkedWith = ReadParam("flt_linkedwith", array());
-
-	$oFilter = new CMDBSearchFilter($sClass);
-
-	if (!empty($sFilterFullText))
-	{
-		$oFilter->AddCondition_FullText($sFilterFullText);
-	}
-
-	foreach($aFilterOps as $sFltCode=>$sOpCode)
-	{
-		if ($sOpCode == "__none__") continue;
-		$oFilter->AddCondition($sFltCode, $aFilterValues[$sFltCode], $sOpCode);
-	}
-
-	foreach($aPointTo as $sExtKeyAttCode=>$sFilterShortcut)
-	{
-		$oSubFilter = CMDBSearchFilter::unserialize($sFilterShortcut);
-		$oFilter->AddCondition_PointingTo($oSubFilter, $sExtKeyAttCode);
-	}
-
-	foreach($aRefedBy as $sForeignClass=>$aExtKeys)
-	{
-		foreach($aExtKeys as $sForeignExtKey=>$sFilterShortcut)
-		{
-			//MyHelpers::var_dump_html("$sForeignClass / $sForeignExtKey / $sFilterShortcut");
-			$oSubFilter = CMDBSearchFilter::unserialize($sFilterShortcut);
-			//MyHelpers::var_dump_html($oSubFilter);
-			$oFilter->AddCondition_ReferencedBy($oSubFilter, $sForeignExtKey);
-		}
-	}
-
-//	$oFilter->AddCondition_LinkedTo(DBObjectSearch $oLinkFilter, $sExtKeyAttCodeToMe, $sExtKeyAttCodeTarget, DBObjectSearch $oFilterTarget);
-
-	return $oFilter;
-}
-
-function Page3_ViewResults($oPage, $oFilter)
-{
-	// Output results in various forms...
-	//
-	if ($oFilter->IsAny())
-	{
-		$oPage->p("You are considering the ENTIRE set of objects...");
-	}
-	else
-	{
-		$oPage->p($oFilter->__DescribeHTML());
-		
-		$oSet = new CMDBObjectSet($oFilter);
-		$oPage->p("Found ".$oSet->Count()." items");
-	
-		$sFilterPhrase = urlencode($oFilter->serialize());
-		$oPage->p("<a href=\"/pages/index.php?operation=search&filter=$sFilterPhrase\">See detailed results</a>"); 
-	}
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-//
-//  M a i n   P r o g r a m
-//
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-$oPage->p("<h1>Advanced search</h1>");
-
-
-// Page 1 - Ask class
-//
-// Page 2 - Class is given, enum existing filters/possible links
-//
-// Page 3 - Interpret user choices, create a filter and render its string representation
-//
-
-//MyHelpers::arg_dump_html();
-//MyHelpers::var_dump_html($_SESSION);
-
-if (ReadParam('userconfig', false))
-{
-	$sTodo = 'userconfig';
-}
-if (ReadParam('makeit', false))
-{
-	$sTodo = 'makeit';
-}
-else
-{
-	if (dialogstack::IsDialogStartup())
-	{
-		$sInit = dialogstack::StartDialog();
-		$oFilter = CMDBSearchFilter::unserialize($sInit);
-		$sTodo = 'userconfig';
-	}
-	else
-	{
-		$sClass = ReadParam('class', '');
-		if (empty($sClass))
-		{
-			$sTodo = 'selectclass';
-		}
-		else
-		{
-			$oFilter = MakeFilterFromArgs();
-			$sTodo = 'userconfig';
-		}
-	}
-}
-
-switch ($sTodo)
-{
-case "selectclass":
-	Page1_AskClass($oPage);
-	break;
-
-case "userconfig":
-	dialogstack::DeclareCaller("Define filter for ".$oFilter->GetClass());
-	$oPage->add(implode(" / ", dialogstack::GetCurrentStack()));
-	Page2_ConfigFilters($oPage, $oFilter);
-	break;
-
-case "makeit":
-	$oFilter = MakeFilterFromArgs();
-	Page3_ViewResults($oPage, $oFilter);
-	$oPage->add(dialogstack::RenderEndDialogForm(DLGSTACK_OK, "Use filter", $oFilter->serialize()));
-	$oPage->add(dialogstack::RenderEndDialogForm(DLGSTACK_CANCEL, "Annuler"));
-	break;
-
-default:
-	trigger_error("Wrong value for arg <em>todo</em> ($sTodo)", E_USER_ERROR);
-}
-
-$oPage->output();
-
-?>

+ 0 - 40
pages/ajax.php

@@ -1,40 +0,0 @@
-<?php
-require_once('../application/application.class.inc.php');
-require_once('../application/nicewebpage.class.inc.php');
-
-require_once('../application/startup.inc.php');
-
-function ReadParam($sName, $defaultValue = "")
-{
-	return isset($_REQUEST[$sName]) ? $_REQUEST[$sName] : $defaultValue;
-}
-
-$oPage = new NiceWebPage("Asynchronous versus asynchronous DisplayBlocks");
-$oPage->no_cache();
-$oPage->add("<h1>Asynchronous versus asynchronous DisplayBlocks</h1>\n");
-
-$oContext = new UserContext();
-$operation = ReadParam('operation', '');
-$sClassName = ReadParam('class', 'bizContact');
-$sOrganizationCode = ReadParam('org', 'ITOP');
-
-$oPage->p("[Synchronous] Count of all $sClassName objects for organization '$sOrganizationCode'");
-$oFilter = $oContext->NewFilter($sClassName);
-$oFilter ->AddCondition('organization', $sOrganizationCode, '=');
-$oBlock = new DisplayBlock($oFilter, 'count', false);
-$oBlock->Display($oPage, "block1");
-
-$oPage->p("[Asynchronous] All $sClassName objects for organization '$sOrganizationCode'");
-$oFilter = $oContext->NewFilter($sClassName);
-$oFilter ->AddCondition('organization', $sOrganizationCode, '=');
-$oBlock = new DisplayBlock($oFilter, 'list', true);
-$oBlock->Display($oPage, "block2");
-
-$oPage->p("[Asynchronous] Details of all $sClassName objects for organization '$sOrganizationCode'");
-$oFilter = $oContext->NewFilter($sClassName);
-$oFilter ->AddCondition('organization', $sOrganizationCode, '=');
-$oBlock = new DisplayBlock($oFilter, 'details', true);
-$oBlock->Display($oPage, "block3");
-
-$oPage->output();
-?>

+ 0 - 321
pages/data_generator.php

@@ -1,321 +0,0 @@
-<?php
-require_once('../application/utils.inc.php');
-require_once('../application/itopwebpage.class.inc.php');
-//require_once('../application/menunode.class.inc.php');
-require_once('../application/applicationcontext.class.inc.php');
-require_once('../business/data.samples.inc.php');
-require_once('../core/data.generator.class.inc.php');
-
-require_once('../application/startup.inc.php');
-
-// Display the menu on the left
-$oContext = new UserContext();
-$oAppContext = new ApplicationContext();
-$iActiveNodeId = utils::ReadParam('menu', -1);
-$currentOrganization = utils::ReadParam('org_id', 1);
-$operation = utils::ReadParam('operation', '');
-if (!isset($_SERVER['PHP_AUTH_USER']))
-{
-    header('WWW-Authenticate: Basic realm="iTop"');
-    header('HTTP/1.0 401 Unauthorized');
-    echo 'Sorry, this page requires authentication. (No user)';
-    echo "<pre>\n";
-    echo "DEBUG: \$_SERVER\n";
-    print_r($_SERVER);
-    echo "</pre>\n";
-    exit;
-}
-if (!UserRights::Login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']))
-{
-    header('WWW-Authenticate: Basic realm="iTop"');
-    header('HTTP/1.0 401 Unauthorized');
-    echo 'Authentication failed !';
-    exit;
-}
-
-$oPage = new iTopWebPage("iTop Data Generator", $currentOrganization);
-$oPage->no_cache();
-
-// From now on the context is limited to the the selected organization ??
-
-// Retrieve the root node for the menu
-$oSearchFilter = $oContext->NewFilter("menuNode");
-$oSearchFilter->AddCondition('parent_id', 0, '=');
-// There may be more criteria added later to have a specific menu based on the user's profile
-$oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
-while ($oRootMenuNode = $oSet->Fetch())
-{
-	$oRootMenuNode->DisplayMenu($oPage, $oContext, $iActiveNodeId, null, $oAppContext->GetAsHash());
-}
-/**
- * The (ordered) list of classes for which to generate objects
- *
- * Each class in this list must implement a non-static Generate(cmdbDataGenerator $oGenerator) method
- */
-//$aClassesToGenerate = array('bizOrganization' /* This one is special and must go first */, 'bizService', 'bizContact', 'bizPC', 'bizNetworkDevice');
-$aClassesToGenerate = array('bizOrganization' /* This one is special and must go first */, 'bizLocation', 'bizPC', 'bizNetworkDevice', 'bizPerson', 'bizIncidentTicket', 'bizInfraGroup', 'bizInfraInfra');
-
-/////////////////////////////////////////////////////////////////////////////////////
-//  Actual actions of the page
-/////////////////////////////////////////////////////////////////////////////////////
-
-/**
- * Populate an organization with objects of each class listed in the (global) $aClassesToGenerate array
- *
- * @param WebPage $oPage The object used for the HTML output
- * @param cmdbGenerator $oGenerator The object used for the generation of the objects
- * @param string $sSize An enum specifying (roughly) how many objects of each class to create: one of 'small', 'medium', 'big', 'huge' or 'max'
- */
-function PopulateOrganization(CMDBChange $oMyChange, WebPage $oPage, cmdbDataGenerator $oGenerator, $sSize = 'small')
-{
-	global $aClassesToGenerate;
-	
-	for ($i=1 /* skip the first one (i=0) which is the org itself */; $i<count($aClassesToGenerate); $i++)
-	{
-		switch($sSize)
-		{
-			case 'max':
-				$nbObjects = 50000;
-				break;
-			case 'huge':
-				$nbObjects = rand(1000,50000);
-				break;
-			case 'big':
-				$nbObjects = rand(30,500);
-				break;
-			case 'medium':
-				$nbObjects = rand(5,50);
-				break;
-			case 'small':
-			default:
-				$nbObjects = rand(2,20);
-		}
-		$sClass = $aClassesToGenerate[$i];
-		for($j=0; $j<$nbObjects; $j++)
-		{
-			$oObject = MetaModel::NewObject($sClass);
-			if (method_exists($oObject, 'Generate'))
-			{
-				$oObject->Generate($oGenerator);
-				// By rom
-				// $oObject->DBInsert();
-				$oObject->DBInsertTracked($oMyChange);
-				
-				//$oObject->DisplayDetails($oPage);
-			}
-		}
-		$oPage->p("$nbObjects $sClass objects created.");
-	}
-}
-
-/**
- * Delete an organization and all the instances of 'Object' belonging to this organization
- *
- * @param WebPage $oPage The object used for the HTML output
- * @param string $sOrganizationCode The code (pkey) of the organization to delete
- */
-function DeleteOrganization($oMyChange, $oPage, $sOrganizationCode)
-{
-	$oOrg = MetaModel::GetObject('bizOrganization', $sOrganizationCode);
-	if ($oOrg == null)
-	{
-		$oPage->p("<strong>Organization '$sOrganizationCode' already deleted!!</strong>");
-	}
-	else
-	{
-		// Delete all the objects linked to this organization
-		$oFilter = new CMDBSearchFilter('logRealObject');
-		$oFilter->AddCondition('organization', $sOrganizationCode, '=');
-		$oSet = new CMDBObjectSet($oFilter);
-		$countDeleted = $oSet->Count();
-		MetaModel::BulkDeleteTracked($oMyChange, $oFilter); // Should do a one by one delete to let the objects do their own cleanup !
-		$oPage->p("<strong>$countDeleted object(s) deleted!!</strong>");
-		
-		$oOrg->DBDeleteTracked($oMyChange);
-		$oPage->p("<strong>Ok, organization '$sOrganizationCode' deleted!</strong>");
-	}
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-//	M a i n   P r o g r a m
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-$operation = utils::ReadParam('operation', '');
-
-$oPage->add("<div style=\"border:1px solid #ffffff; margin:0.5em;\">\n");
-$oPage->add("<div style=\"padding:0.25em;text-align:center\">\n");
-
-switch($operation)
-{
-
-	case 'specify_generate':
-	// Display a form to specify what to generate
-	$oPage->p("<strong>iTop Data Generator</strong>\n");
-	$oPage->add("<form method=\"post\"\">\n");
-	$oPage->add("Number of organizations to generate: \n");
-	$oPage->add("<input name=\"org_count\" size=\"3\" value=\"\"> (max ".count($aCompanies).")&nbsp;\n");
-	$oPage->add("Size of the organizations\n");
-	$oPage->add("<select name=\"org_size\"\">\n");
-	$oPage->add("<option value=\"small\">Small (1 - 20 contacts)</option>\n");
-	$oPage->add("<option value=\"medium\">Medium (5 - 50 contacts)</option>\n");
-	$oPage->add("<option value=\"big\">Big (30 - 500 contacts)</option>\n");
-	$oPage->add("<option value=\"huge\">Huge (1000 - 50000 contacts)</option>\n");
-	$oPage->add("<option value=\"max\">Max (50000 contacts)</option>\n");
-	$oPage->add("</select>\n");
-	$oPage->add("<input type=\"hidden\" name=\"operation\" value=\"generate\">\n");
-	$oPage->add("<input type=\"submit\" value=\" Generate ! \">\n");
-	$oPage->add("</form>\n");
-	break;
-	
-	case 'generate':
-	// perform the actual generation
-	$iOrgCount = utils::ReadParam('org_count', 0);
-	$sOrgSize = utils::ReadParam('org_size', 'small');
-	// By rom
-	$oMyChange = MetaModel::NewObject("CMDBChange");
-	$oMyChange->Set("date", time());
-	$oMyChange->Set("userinfo", "Made by data generator ($iOrgCount orgs of size '$sOrgSize')");
-	$oMyChange->DBInsert();
-	while($iOrgCount > 0)
-	{
-		set_time_limit(5*60); // let it run for 5 minutes for each organization
-		$oGenerator = new cmdbDataGenerator();
-		// Create the new organization
-		$oOrg = MetaModel::NewObject('bizOrganization');
-		$oOrg->Generate($oGenerator);
-
-		// By rom
-		// $oOrg->DBInsert();
-		$oOrg->DBInsertTracked($oMyChange);
-		$oGenerator->SetOrganizationId($oOrg->GetKey());
-
-		$oPage->p("Organization '".$oOrg->GetKey()."' created\n");
-		$oOrg->DisplayDetails($oPage);
-		$oPage->add("<hr />\n");
-		PopulateOrganization($oMyChange, $oPage, $oGenerator, $sOrgSize);
-		$oPage->add("<hr />\n");
-		unset($oGenerator);
-		$iOrgCount--;
-	}
-	break;
-
-	case 'specify_update':
-	// Specify which organization to update
-	$oPage->add("<form method=\"post\"\">\n");
-	$oPage->add("Select the organization to update: \n");
-	$oPage->add("<select name=\"org\"\">\n");
-	$oSearchFilter = new CMDBSearchFilter("bizOrganization");
-	$oSet = new CMDBObjectSet($oSearchFilter); // All organizations
-	while($oOrg = $oSet->Fetch())
-	{
-		$oPage->add("<option value=\"".$oOrg->GetKey()."\">".$oOrg->Get('name')."</option>\n");
-	}
-	$oPage->add("</select>\n");
-	$oPage->add("<input type=\"hidden\" name=\"operation\" value=\"update\">\n");
-	$oPage->p("");
-	$oPage->add("Quantity of of objects to add in each class: \n");
-	$oPage->add("<select name=\"org_size\"\">\n");
-	$oPage->add("<option value=\"small\">A few (1 - 20 objects)</option>\n");
-	$oPage->add("<option value=\"medium\">Some (5 - 50 objects)</option>\n");
-	$oPage->add("<option value=\"big\">Many (30 - 500 objects)</option>\n");
-	$oPage->add("<option value=\"huge\">Too many (1000 - 50000 objects)</option>\n");
-	$oPage->add("<option value=\"max\">Max (50000 objects)</option>\n");
-	$oPage->add("</select>\n");
-	$oPage->p("");
-	$oPage->add("<input type=\"button\" value=\" << Back \" onClick=\"javascript:window.history.back()\">&nbsp;&nbsp;\n");
-	$oPage->add("<input type=\"submit\" value=\" Update \">\n");
-	$oPage->add("</form>\n");
-	break;
-
-	case 'update':
-	// perform the actual update
-	set_time_limit(5*60); // let it run for 5 minutes	
-	$sOrganizationCode = utils::ReadParam('org', '');
-	$sOrgSize = utils::ReadParam('org_size', 'small');
-	if ($sOrganizationCode == '')
-	{
-		$oPage->p("<strong>Error: please specify an organization (org).</strong>");
-	}
-	else
-	{
-		// By rom
-		$oMyChange = MetaModel::NewObject("CMDBChange");
-		$oMyChange->Set("date", time());
-		$oMyChange->Set("userinfo", "Made by data generator (update org '$sOrganizationCode', size '$sOrgSize')");
-		$oMyChange->DBInsert();
-
-		$oPage->p("<strong>Organization '$sOrganizationCode' updated.</strong>");
-		$oGenerator = new cmdbDataGenerator($sOrganizationCode);
-		PopulateOrganization($oMyChange, $oPage, $oGenerator, $sOrgSize);
-	}
-	break;
-
-	case 'specify_delete':
-	// Select an organization to be deleted
-	$oPage->add("<form method=\"post\"\">\n");
-	$oPage->add("Select the organization to delete: \n");
-	$oPage->add("<select name=\"org\"\">\n");
-	$oSearchFilter = new CMDBSearchFilter("bizOrganization");
-	$oSet = new CMDBObjectSet($oSearchFilter); // All organizations
-	while($oOrg = $oSet->Fetch())
-	{
-		$oPage->add("<option value=\"".$oOrg->GetKey()."\">".$oOrg->Get('name')."</option>\n");
-	}
-	$oPage->add("</select>\n");
-	$oPage->add("<input type=\"hidden\" name=\"operation\" value=\"confirm_delete\">\n");
-	$oPage->p("");
-	$oPage->add("<input type=\"button\" value=\" << Back \" onClick=\"javascript:window.history.back()\">&nbsp;&nbsp;\n");
-	$oPage->add("<input type=\"submit\" value=\" Delete! \">\n");
-	$oPage->add("</form>\n");
-	break;
-			
-	case 'confirm_delete':
-	// confirm the dangerous action
-	$sOrganizationCode = ReadParam('org', '');
-	$oPage->p("<strong>iTop Data Generator</strong>\n");
-	$oPage->p("<strong>Warning: you are about to delete the organization '$sOrganizationCode' and all its related objects</strong>\n");
-	$oPage->add("<form method=\"post\"\">\n");
-	$oPage->add("<input type=\"hidden\" name=\"org\" value=\"$sOrganizationCode\">\n");
-	$oPage->add("<input type=\"hidden\" name=\"operation\" value=\"delete\">\n");
-	$oPage->add("<input type=\"button\" value=\" << Back \" onClick=\"javascript:window.history.back()\">&nbsp;&nbsp;\n");
-	$oPage->add("<input type=\"submit\" value=\" Delete them ! \">\n");
-	$oPage->add("</form>\n");
-	break;
-
-	case 'delete':
-	// perform the actual deletion
-	$sOrganizationCode = ReadParam('org', '');
-	if ($sOrganizationCode == '')
-	{
-		$oPage->p("<strong>Error: please specify an organization (org).</strong>");
-	}
-	else
-	{
-		// By rom
-		$oMyChange = MetaModel::NewObject("CMDBChange");
-		$oMyChange->Set("date", time());
-		$oMyChange->Set("userinfo", "Made by data generator (delete org '$sOrganizationCode'");
-		$oMyChange->DBInsert();
-
-		$oPage->p("<strong>Deleting '$sOrganizationCode'</strong>\n");
-		DeleteOrganization($oMyChange, $oPage, $sOrganizationCode);
-	}
-	break;
-
-	// display the menu of actions
-	case 'menu':
-	default:
-	$oPage->p("<strong>Data Generator Menu</strong>");
-	$oPage->p("<a href=\"?operation=specify_generate\">Generate one or more organizations</a>");
-	$oPage->p("<a href=\"?operation=specify_update\">Add more objects into an organization</a>");
-	$oPage->p("<a href=\"?operation=specify_delete\">Delete an organization</a>");
-}
-$oPage->add("</div>\n");
-$oPage->add("</div>\n");
-
-$oPage->p("<a href=\"?operation=menu\">Return to the data generator menu</a>");
-
-$oPage->output();
-?>

+ 0 - 171
pages/db_importer.php

@@ -1,171 +0,0 @@
-<?php
-require_once('../application/application.inc.php');
-require_once('../application/itopwebpage.class.inc.php');
-
-require_once('../application/startup.inc.php');
-
-require_once('../application/loginwebpage.class.inc.php');
-LoginWebPage::DoLogin(); // Check user rights and prompt if needed
-
-$sOperation = utils::ReadParam('operation', 'menu');
-$oContext = new UserContext();
-$oAppContext = new ApplicationContext();
-$iActiveNodeId = utils::ReadParam('menu', -1);
-$currentOrganization = utils::ReadParam('org_id', '');
-
-$oP = new iTopWebPage("iTop - Database backup & restore", $currentOrganization);
-
-// Main program
-switch($sOperation)
-{
-	case 'create':
-	$oP->add('<form method="get">');
-	$oP->add('<p style="text-align:center; font-family:Georgia, \'Times New Roman\', Times, serif; font-size:24px;">Creation of an archive for the business model: '.$sBizModel.'</p>');
-	$oP->p('Title of the archive: <input type="text" name="title" size="40">');
-	$oP->p('Description of this archive: <textarea name="description" rows="5" cols="40"></textarea>');
-	$oP->p('Select the packages you want to include into this archive (When restoring the archive you will prompted to pick a package):');
-	$oP->p('<input type="checkbox" checked name="full" value="1"> The full database (schema + data).');
-	$oP->p('<input type="checkbox" checked name="full_schema" value="1"> Only the schema but of the complete database.');
-	$oP->p('<input type="checkbox" checked name="biz" value="1"> The complete business model (all the tables used by the business model, schema + data).');
-	$oP->p('<input type="checkbox" checked name="biz_schema" value="1"> Only the schema of the business model.');
-	$oP->add('<input type="hidden" name="biz_model" value="'.$sBizModel.'">');
-	$oP->add('<input type="hidden" name="operation" value="do_create">');
-	$oP->add('<input type="submit" name="" value=" Create the archive ">');
-	$oP->add($oAppContext->GetForForm());
-	$oP->add('</form>');
-	$oP->p('<a href="?operation=menu&biz_model='.$sBizModel.'">Back to menu</a>');
-	break;
-	
-	case 'do_create':
-	$sTitle = utils::ReadParam('title', 'Unknown archive');
-	$sDescription = utils::ReadParam('description', 'No description provided for this archive.');
-	$bfullDump = utils::ReadParam('full', false);
-	$bfullSchemaDump = utils::ReadParam('full_schema', false);
-	$bBizDump = utils::ReadParam('biz', false);
-	$bBizSchemaDump = utils::ReadParam('biz_schema', false);
-	$sArchiveFile = '../tmp/archive1.zip';
-
-	$oArchive = new iTopArchive($sArchiveFile, iTopArchive::create);
-	$oArchive->SetTitle($sTitle);
-	$oArchive->SetDescription($sDescription);
-	if ($bfullDump)
-	{
-		$oArchive->AddDatabaseDump("Full Database Dump", "Choose this option to completely reload your database. All current data will be deleted and replaced by the backup", "full-db.sql", 'itop', array(), false);
-	}
-	
-	if ($bfullSchemaDump)
-	{
-		$oArchive->AddDatabaseDump("Full Schema Dump", "Choose this option to completely wipe out your database and start from an empty database", "full-schema.sql", 'itop', array(), true);
-	}
-	
-	if ($bBizDump || $bBizSchemaDump)
-	{
-		// compute the list of the tables involved in the business model
-		$aBizTables = array();
-		foreach(MetaModel::GetClasses('bizmodel') as $sClass)
-		{
-			$sTable = MetaModel::DBGetTable($sClass);
-			$aBizTables[$sTable] = $sTable;
-		}
-		unset($aBizTables['']);
-		if ($bfullDump)
-		{
-			$oArchive->AddDatabaseDump("Full Business Model Dump", "Choose this option to completely reload the business model part of your database. All current business data will be deleted and replaced by the backup. Application data (like menus...) are preserved.", "biz-db.sql", 'itop', $aBizTables, false);
-		}
-		
-		if ($bfullSchemaDump)
-		{
-			$oArchive->AddDatabaseDump("Full Business Model Schema Dump", "Choose this option to wipe out the business data and start from an empty database. All current business data will be deleted. Application data (like menus...) are preserved.", "biz-schema.sql", 'itop', $aBizTables, true);
-		}
-	}
-	$oArchive->WriteCatalog();
-	$oP->p("The archive '$sTitle' has been created in <a href=\"$sArchiveFile\">$sArchiveFile</a>.");			
-	$oP->p('<a href="?operation=menu&biz_model='.$sBizModel.'&'.$oAppContext->GetForLink().'">Back to menu</a>');			
-	break;
-
-	case 'select_archive':
-	$sArchivesDir = '../tmp';
-	$oP->add('<form method="get">');
-	$oP->add('<p style="text-align:center; font-family:Georgia, \'Times New Roman\', Times, serif; font-size:24px;">Importation of an archive</p>');
-	$oP->p('Select the archive you want to import:');
-	$aArchives = array();
-	if ($handle = opendir($sArchivesDir))
-	{
-		while (false !== ($sFileName = readdir($handle)))
-		{
-			if (strtolower(substr($sFileName, -3, 3)) == 'zip')
-			{
-				$oArchive = new iTopArchive('../tmp/'.$sFileName, iTopArchive::read);
-				if ($oArchive->IsValid())
-				{
-					$oArchive->ReadCatalog();
-					$aArchives['../tmp/'.$sFileName] = $oArchive->GetTitle();
-				}
-			}
-    	}
-    	closedir($handle);
-	}
-	foreach($aArchives as $sFileName => $sTitle)
-	{
-		$oP->p('<input type="radio" name="archive_file" value="'.$sFileName.'">'.$sTitle);
-	}
-	$oP->add('<input type="hidden" name="biz_model" value="'.$sBizModel.'">');
-	$oP->add('<input type="hidden" name="operation" value="select_package">');
-	$oP->add('<input type="submit" name="" value=" Next >> ">');
-	$oP->add($oAppContext->GetForForm());
-	$oP->add('</form>');
-	$oP->p("<small>(Archives are searched into the directory: $sArchivesDir.)</small>");
-	$oP->p('<a href="?operation=menu&biz_model='.$sBizModel.'&'.$oAppContext->GetForLink().'">Cancel</a>');
-	break;
-
-	case 'select_package':
-	$sArchiveFile = utils::ReadParam('archive_file', '');
-	$oArchive = new iTopArchive($sArchiveFile, iTopArchive::read);
-	$oArchive->ReadCatalog();
-	$oP->add('<form method="post">');
-	$oP->add('<p style="text-align:center; font-family:Georgia, \'Times New Roman\', Times, serif; font-size:24px;">Selection of a package inside '.$oArchive->GetTitle().'</p>');
-	$oP->p('Select the package you want to apply:');
-	$aPackages = $oArchive->GetPackages();
-	foreach($aPackages as $sPackageName => $aPackage)
-	{
-		$oP->p('<input type="radio" name="package_name" value="'.$sPackageName.'">'.$aPackage['title']);
-		$oP->p($aPackage['description']);
-	}
-	$oP->add('<input type="hidden" name="archive_file" value="'.$sArchiveFile.'">');
-	$oP->add('<input type="hidden" name="biz_model" value="'.$sBizModel.'">');
-	$oP->add('<input type="hidden" name="operation" value="import_package">');
-	$oP->add('<input type="submit" name="" value=" Apply Package ! ">');
-	$oP->add($oAppContext->GetForForm());
-	$oP->add('</form>');
-	$oP->p('<a href="?operation=menu&biz_model='.$sBizModel.'">Cancel</a>');
-	break;
-
-	case 'import_package':
-	$sArchiveFile = utils::ReadParam('archive_file', '');
-	$sPackageName = utils::ReadParam('package_name', '');
-	$oArchive = new iTopArchive($sArchiveFile, iTopArchive::read);
-	$oArchive->ReadCatalog();
-	$oP->add('<p style="text-align:center; font-family:Georgia, \'Times New Roman\', Times, serif; font-size:24px;">Applying the package '.$sPackageName.'</p>');
-	if($oArchive->ImportSQL($sPackageName))
-	{
-		$oP->p('Done.');
-	}
-	else
-	{
-		$oP->p('Sorry, an error occured while applying the package...');
-	}
-	$oP->p('<a href="?operation=select_package&biz_model='.$sBizModel.'&archive_file='.$sArchiveFile.'&'.$oAppContext->GetForLink().'">Apply another package from the same archive</a>');
-	$oP->p('<a href="?operation=select_archive&biz_model='.$sBizModel.'&'.$oAppContext->GetForLink().'">Select another archive</a>');
-	$oP->p('<a href="?operation=menu&biz_model='.$sBizModel.'&'.$oAppContext->GetForLink().'">Back to the menu</a>');
-	break;
-	
-	case 'menu':
-	default:
-	$oP->add('<p style="text-align:center; font-family:Georgia, \'Times New Roman\', Times, serif; font-size:24px;">Database backup &amp; restore</p>');
-	$oP->add('<p style="text-align:center;">Select one of the actions below:</p>');
-	$oP->add('<p style="text-align:center;"><a href="?operation=create&biz_model='.$sBizModel.'&'.$oAppContext->GetForLink().'">Export the database to an archive</a></p>');
-	$oP->add('<p style="text-align:center;"><a href="?operation=select_archive&biz_model='.$sBizModel.'&'.$oAppContext->GetForLink().'">Reload the database from an archive</a></p>');
-}
-
-$oP->output();
-?>