no_cache();
MetaModel::CheckDefinitions();
// new API - MetaModel::DBCheckFormat();
// not necessary, and time consuming!
// MetaModel::DBCheckIntegrity();
// Comment by Rom: MetaModel::GetSubclasses("logRealObject") retourne la totale
// utiliser IsRootClass pour savoir si une classe obtenue est une classe feuille ou non
$aTopLevelClasses = array('bizService', 'bizLocation', 'bizContact', 'logInfra', 'bizDocument', 'bizObject');
function ReadParam($sName, $defaultValue = "")
{
return isset($_REQUEST[$sName]) ? $_REQUEST[$sName] : $defaultValue;
}
function DisplaySelectOrg($oPage, $sCurrentOrganization, $iContext)
{
global $oContext;
//$oSearchFilter = new CMDBSearchFilter("bizOrganization");
$oSearchFilter = $oContext->NewFilter("bizOrganization");
$oPage->p($oSearchFilter->serialize());
$oSet = new CMDBObjectSet($oSearchFilter);
if ($oSet->Count() == 0)
{
$oPage->add("
\n");
$oPage->add("
\n");
$oPage->p("No organization found.\n");
$oPage->p($oSearchFilter->__DescribeHTML());
$oPage->add("
\n");
$oPage->add("
\n");
}
else
{
$oCurrentOrganization = null;
$oPage->add("\n");
$oPage->add("
\n");
$oPage->add("\n");
if ($oCurrentOrganization != null)
{
$oCurrentOrganization->DisplayDetails($oPage);
}
$oPage->add("
\n");
$oPage->add("
\n");
}
}
function DisplayDetails(web_page $oPage, $sClassName, $sKey)
{
global $oContext;
//$oObj = MetaModel::GetObject($sClassName, $sKey);
$oObj = $oContext->GetObject($sClassName, $sKey);
$oPage->p("Details of ".MetaModel::GetName($sClassName)." - $sKey");
$oObj->DisplayDetails($oPage);
// Modified by rom
$aLinks = array();
$aLinks[] = "View changes log";
$aLinks[] = "Edit this object";
$aLinks[] = "Delete this object (no confirmation!)";
// By rom
foreach (MetaModel::EnumLinkingClasses($sClassName) as $sLinkClass => $aRemoteClasses)
{
foreach($aRemoteClasses as $sExtKeyAttCode => $sRemoteClass)
{
// #@# quick and dirty: guess the extkey attcode from link to current class
// later, this information should be part of the biz model
$sExtKeyToMe = "";
foreach(MetaModel::ListAttributeDefs($sLinkClass) as $sAttCode=>$oAttDef)
{
if ($oAttDef->IsExternalKey() && $oAttDef->GetTargetClass() == $sClassName)
{
$sExtKeyToMe = $sAttCode;
break;
}
}
if (empty($sExtKeyToMe))
{
$oPage->p("Houston... could not find the external key for $sClassName in $sLinkClass");
}
else
{
$oFilter = new CMDBSearchFilter($sRemoteClass); // just a dummy empty one for edition
$sButton = "\n";
$sButton .= "\n";
$sButton .= "
\n";
$aLinks[] = $sButton;
}
}
}
$sLinks = implode(" / ", $aLinks);
$oPage->p($sLinks);
}
// By Rom
function DisplayChangesLog(web_page $oPage, $sClassName, $sKey)
{
global $oContext;
//$oObj = MetaModel::GetObject($sClassName, $sKey);
$oObj = $oContext->GetObject($sClassName, $sKey);
$oPage->p("Changes log for ".MetaModel::GetName($sClassName)." - $sKey");
$oObj->DisplayChangesLog($oPage);
$oPage->p("View details");
$oPage->p("Edit this object");
$oPage->p("Delete this object (no confirmation!)");
}
function DumpObjectsAsCSV(web_page $oPage, $sClassName, $oSearchFilter = null, $sSeparator = ",")
{
global $oContext;
$aHeader = array();
$aHeader[] = 'pkey';
foreach(MetaModel::ListAttributeDefs($sClassName) as $sAttCode=>$oAttDef)
{
$aHeader[] = $oAttDef->GetLabel();
}
$oPage->Add(join($sSeparator, $aHeader)."\n");
if ($oSearchFilter == null)
{
$oSearchFilter = $oContext->NewFilter($sClassName);
}
$oObjectSet = new CMDBObjectSet($oSearchFilter);
while ($oObj = $oObjectSet->Fetch())
{
$aRow = array();
$aRow[] = $oObj->GetKey();
foreach($oObj->GetAttributesList($sClassName) as $sAttCode)
{
$aRow[] = $oObj->GetAsCSV($sAttCode);
}
$oPage->Add(join($sSeparator, $aRow)."\n");
}
}
function DumpObjects(web_page $oPage, $sClassName, CMDBSearchFilter $oSearchFilter = null)
{
global $oContext;
if ($oSearchFilter == null)
{
//$oSearchFilter = new CMDBSearchFilter($sClassName);
$oSearchFilter = $oContext->NewFilter($sClassName);
}
$aAttribs = array();
foreach(MetaModel::ListAttributeDefs($sClassName) as $sAttCode=>$oAttDef)
{
$aAttribs['key'] = array('label' => 'key', 'description' => 'Primary Key');
$aAttribs[$sAttCode] = array('label' => $oAttDef->GetLabel(), 'description' => $oAttDef->GetDescription());
}
$oObjectSet = new CMDBObjectSet($oSearchFilter);
$aValues = array();
while ($oObj = $oObjectSet->Fetch())
{
$aRow['key'] = "GetKey()."\">".$oObj->GetKey()."";
foreach($oObj->GetAttributesList($sClassName) as $sAttCode)
{
$aRow[$sAttCode] = $oObj->GetAsHTML($sAttCode);
}
$aValues[] = $aRow;
}
$oPage->table($aAttribs, $aValues);
}
function DisplayEditForm(web_page $oPage, $sClassName, $sKey)
{
global $oContext;
//$oObj = MetaModel::GetObject($sClassName, $sKey);
$oObj = $oContext->GetObject($sClassName, $sKey);
if ($oObj == null)
{
$oPage->p("You are not allowed to edit this object.");
return;
}
$oPage->p("Edition of ".MetaModel::GetName($sClassName)." - $sKey\n");
$aDetails = array();
$oPage->add("