mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 09:38:48 +02:00
- Finishing touch to the DataExchange: various cosmetic fixes
SVN:trunk[1170]
This commit is contained in:
@@ -110,19 +110,19 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
if ($oReplicaSet->Count() > 0)
|
||||
{
|
||||
$bSynchronized = true;
|
||||
$sTip = "<p>The object is synchronized with an external data source</p>";
|
||||
$sTip = "<p>".Dict::S('Core:Synchro:ThisObjectIsSynchronized')."</p>";
|
||||
while($aData = $oReplicaSet->FetchAssoc())
|
||||
{
|
||||
// Assumption: $aData['datasource'] will not be null because the data source id is always set...
|
||||
$sApplicationURL = $aData['datasource']->GetApplicationUrl($this, $aData['replica']);
|
||||
$sLink = '';
|
||||
$sLink = $aData['datasource']->GetName();
|
||||
if (!empty($sApplicationURL))
|
||||
{
|
||||
$sLink = "<a href=\"$sApplicationURL\" target=\"_blank\">".$aData['datasource']->GetName()."</a>";
|
||||
$sLink = "<a href=\"$sApplicationURL\" target=\"_blank\">".$aData['datasource']->GetName()."</a>";
|
||||
}
|
||||
if ($aData['replica']->Get('status_dest_creator') == 1)
|
||||
{
|
||||
$sTip .= "<p>The object was <b>created</b> by the external data source $sLink</p>";
|
||||
$sTip .= "<p>".Dict::Format('Core:Synchro:TheObjectWasCreatedBy_Source', $sLink)."</p>";
|
||||
$bCreated = true;
|
||||
}
|
||||
if ($bCreated)
|
||||
@@ -131,23 +131,25 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
if (($sDeletePolicy == 'delete') || ($sDeletePolicy == 'update_then_delete'))
|
||||
{
|
||||
$bCanBeDeleted = true;
|
||||
$sTip .= "<p>The object <b>can be deleted</b> by the external data source $sLink</p>";
|
||||
$sTip .= "<p>".Dict::Format('Core:Synchro:TheObjectCanBeDeletedBy_Source', $sLink)."</p>";
|
||||
}
|
||||
}
|
||||
$aMasterSources[$aData['datasource']->GetKey()]['datasource'] = $aData['datasource'];
|
||||
$aMasterSources[$aData['datasource']->GetKey()]['url'] = $sLink;
|
||||
$aMasterSources[$aData['datasource']->GetKey()]['last_synchro'] = $aData['replica']->Get('status_last_seen');
|
||||
}
|
||||
}
|
||||
|
||||
$sSynchroIcon = '';
|
||||
if ($bSynchronized)
|
||||
{
|
||||
$sTip .= "<p><b>List of data sources:</b></p>";
|
||||
$sTip .= "<p><b>".Dict::S('Core:Synchro:ListOfDataSources')."</b></p>";
|
||||
foreach($aMasterSources as $aStruct)
|
||||
{
|
||||
$oDataSource = $aStruct['datasource'];
|
||||
$sLink = $aStruct['url'];
|
||||
$sTip .= "<p style=\"white-space:nowrap\">".$oDataSource->GetIcon(true, 'style="vertical-align:middle"')." $sLink</p>";
|
||||
$sTip .= "<p style=\"white-space:nowrap\">".$oDataSource->GetIcon(true, 'style="vertical-align:middle"')." $sLink<br/>";
|
||||
$sTip .= Dict::S('Core:Synchro:LastSynchro').'<br/>'.$aStruct['last_synchro']."</p>";
|
||||
}
|
||||
$sSynchroIcon = ' <img style="vertical-align:middle;" id="synchro_icon" src="../images/locked.png"/>';
|
||||
$oPage->add_ready_script("$('#synchro_icon').qtip( { content: '$sTip', show: 'mouseover', hide: 'unfocus', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );");
|
||||
@@ -384,6 +386,8 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
$val = $this->GetFieldAsHtml($sClass, $sAttCode, $sStateAttCode);
|
||||
if ($val != null)
|
||||
{
|
||||
/*
|
||||
* Removed for now...
|
||||
// Check if the attribute is not mastered by a synchro...
|
||||
$aReasons = array();
|
||||
$iSynchroFlags = $this->GetSynchroReplicaFlags($sAttCode, $aReasons);
|
||||
@@ -400,6 +404,7 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
}
|
||||
|
||||
$val['comments'] = $sSynchroIcon;
|
||||
*/
|
||||
// The field is visible, add it to the current column
|
||||
$aDetails[$sTab][$sColIndex][] = $val;
|
||||
$iInputId++;
|
||||
|
||||
@@ -552,6 +552,12 @@ Dict::Add('EN US', 'English', 'English', array(
|
||||
'Core:SynchroAtt:update_policy+' => 'Behavior of the updated field',
|
||||
'Core:SynchroAtt:reconciliation_attcode' => 'Reconciliation Key',
|
||||
'Core:SynchroAtt:reconciliation_attcode+' => 'Attribute Code for the External Key Reconciliation',
|
||||
'Core:SyncDataExchangeComment' => '(DataExchange)',
|
||||
'Core:Synchro:ListOfDataSources' => 'List of data sources:',
|
||||
'Core:Synchro:LastSynchro' => 'Last synchronization:',
|
||||
'Core:Synchro:ThisObjectIsSynchronized' => 'This object is synchronized with an external data source',
|
||||
'Core:Synchro:TheObjectWasCreatedBy_Source' => 'The object was <b>created</b> by the external data source %1$s',
|
||||
'Core:Synchro:TheObjectCanBeDeletedBy_Source' => 'The object <b>can be deleted</b> by the external data source %1$s',
|
||||
|
||||
|
||||
));
|
||||
|
||||
@@ -301,14 +301,14 @@ EOF
|
||||
$oPage->add($this->HtmlBox('obj_obsoleted', $aData, '#630'));
|
||||
$oPage->add("</tr>\n<tr>");
|
||||
$sOQL = urlencode($sBaseOQL." AND status='obsolete'");
|
||||
$oPage->add($this->HtmlBox('obj_disappeared_errors', $aData, '#C00', '', " <a style=\"color:#fff\" href=\"../synchro/replica?operation=oql&datasource=$iDSid&oql=$sOQL\" id=\"disappeared_errors_link\">Show</a>"));
|
||||
$oPage->add($this->HtmlBox('obj_disappeared_errors', $aData, '#C00', '', " <a style=\"color:#fff\" href=\"../synchro/replica.php?operation=oql&datasource=$iDSid&oql=$sOQL\" id=\"disappeared_errors_link\">Show</a>"));
|
||||
$oPage->add("</tr>\n<tr>");
|
||||
$oPage->add($this->HtmlBox('repl_existing', $aData, '#093', 'rowspan="3"').'<td rowspan="3" class="arrow">=></td>'.$this->HtmlBox('obj_unchanged', $aData, '#393'));
|
||||
$oPage->add("</tr>\n<tr>");
|
||||
$oPage->add($this->HtmlBox('obj_updated', $aData, '#3C3'));
|
||||
$oPage->add("</tr>\n<tr>");
|
||||
$sOQL = urlencode($sBaseOQL." AND status='modified'");
|
||||
$oPage->add($this->HtmlBox('obj_updated_errors', $aData, '#C00', '', " <a style=\"color:#fff\" href=\"../synchro/replica?operation=oql&datasource=$iDSid&oql=$sOQL\" id=\"updated_errors_link\">Show</a>"));
|
||||
$oPage->add($this->HtmlBox('obj_updated_errors', $aData, '#C00', '', " <a style=\"color:#fff\" href=\"../synchro/replica.php?operation=oql&datasource=$iDSid&oql=$sOQL\" id=\"updated_errors_link\">Show</a>"));
|
||||
$oPage->add("</tr>\n<tr>");
|
||||
$oPage->add($this->HtmlBox('repl_new', $aData, '#339', 'rowspan="4"').'<td rowspan="4" class="arrow">=></td>'.$this->HtmlBox('obj_new_unchanged', $aData, '#393'));
|
||||
$oPage->add("</tr>\n<tr>");
|
||||
@@ -317,7 +317,7 @@ EOF
|
||||
$oPage->add($this->HtmlBox('obj_created', $aData, '#339'));
|
||||
$oPage->add("</tr>\n<tr>");
|
||||
$sOQL = urlencode($sBaseOQL." AND status='new'");
|
||||
$oPage->add($this->HtmlBox('obj_new_errors', $aData, '#C00', '', " <a style=\"color:#fff\" href=\"../synchro/replica?operation=oql&datasource=$iDSid&oql=$sOQL\" id=\"new_errors_link\">Show</a>"));
|
||||
$oPage->add($this->HtmlBox('obj_new_errors', $aData, '#C00', '', " <a style=\"color:#fff\" href=\"../synchro/replica.php?operation=oql&datasource=$iDSid&oql=$sOQL\" id=\"new_errors_link\">Show</a>"));
|
||||
$oPage->add("</tr>\n</table>\n");
|
||||
$oPage->add('</td></tr></table>');
|
||||
$oPage->add_ready_script("UpdateSynoptics('$iLastLog')");
|
||||
@@ -659,7 +659,7 @@ EOF
|
||||
$oMyChange = MetaModel::NewObject("CMDBChange");
|
||||
$oMyChange->Set("date", time());
|
||||
$sUserString = CMDBChange::GetCurrentUserName();
|
||||
$oMyChange->Set("userinfo", $sUserString);
|
||||
$oMyChange->Set("userinfo", $sUserString.' '.Dict::S('Core:SyncDataExchangeComment'));
|
||||
$iChangeId = $oMyChange->DBInsert();
|
||||
|
||||
// Start logging this execution (stats + protection against reentrance)
|
||||
@@ -763,7 +763,7 @@ EOF
|
||||
}
|
||||
elseif ($this->Get('reconciliation_policy') == 'use_primary_key')
|
||||
{
|
||||
// Override the setings made at the attribute level !
|
||||
// Override the settings made at the attribute level !
|
||||
$aReconciliationKeys = array("primary_key" => null);
|
||||
}
|
||||
|
||||
@@ -840,11 +840,12 @@ EOF
|
||||
}
|
||||
$oReplica->UpdateDestObject($aToUpdate, $oMyChange, $oStatLog);
|
||||
$oReplica->Set('status', 'obsolete');
|
||||
$oReplica->Set('info_last_synchro', date('Y-m-d H:i:s'));
|
||||
$oReplica->DBUpdateTracked($oMyChange);
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
default:
|
||||
case 'delete':
|
||||
default:
|
||||
$oStatLog->AddTrace("Destination object to be DELETED", $oReplica);
|
||||
$oReplica->DeleteDestObject($oMyChange, $oStatLog);
|
||||
}
|
||||
@@ -862,7 +863,7 @@ EOF
|
||||
|
||||
while($oReplica = $oSetToSync->Fetch())
|
||||
{
|
||||
$oReplica->Synchro($this, $aReconciliationKeys, $aAttributes, $oMyChange, $oStatLog);
|
||||
$oReplica->Synchro($this, $aReconciliationKeys, $aAttributes, $oMyChange, $oStatLog);
|
||||
}
|
||||
|
||||
// Get all the replicas that are to be deleted
|
||||
@@ -1446,6 +1447,7 @@ class SynchroReplica extends DBObject implements iDisplay
|
||||
$oDestObj->DBUpdateTracked($oChange);
|
||||
$oStatLog->AddTrace('Updated object - Values: {'.implode(', ', $aValueTrace).'}', $this);
|
||||
$oStatLog->Inc($sStatsCode.'_updated');
|
||||
$this->Set('info_last_modified', date('Y-m-d H:i:s'));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1489,6 +1491,7 @@ class SynchroReplica extends DBObject implements iDisplay
|
||||
$this->Set('status_dest_creator', true);
|
||||
$this->Set('status_last_error', '');
|
||||
$this->Set('status', 'synchronized');
|
||||
$this->Set('info_creation_date', date('Y-m-d H:i:s'));
|
||||
|
||||
$oStatLog->AddTrace("Created (".implode(', ', $aValueTrace).")", $this);
|
||||
$oStatLog->Inc('stats_nb_obj_created');
|
||||
@@ -1520,6 +1523,7 @@ class SynchroReplica extends DBObject implements iDisplay
|
||||
{
|
||||
$oDestObj->Set($sAttCode, $value);
|
||||
}
|
||||
$this->Set('info_last_modified', date('Y-m-d H:i:s'));
|
||||
$oDestObj->DBUpdateTracked($oChange);
|
||||
$oStatLog->AddTrace("Replica marked as obsolete", $this);
|
||||
$oStatLog->Inc('stats_nb_obj_obsoleted');
|
||||
@@ -1719,7 +1723,7 @@ class SynchroReplica extends DBObject implements iDisplay
|
||||
{
|
||||
$oAdminMenu = new MenuGroup('AdminTools', 80 /* fRank */);
|
||||
new OQLMenuNode('DataSources', 'SELECT SynchroDataSource', $oAdminMenu->GetIndex(), 12 /* fRank */, true, 'SynchroDataSource', UR_ACTION_MODIFY, UR_ALLOWED_YES);
|
||||
new OQLMenuNode('Replicas', 'SELECT SynchroReplica', $oAdminMenu->GetIndex(), 12 /* fRank */, true, 'SynchroReplica', UR_ACTION_MODIFY, UR_ALLOWED_YES);
|
||||
new WebPageMenuNode('Test:RunSynchro', '../synchro/synchro_exec.php', $oAdminMenu->GetIndex(), 13 /* fRank */, 'SynchroDataSource');
|
||||
// new OQLMenuNode('Replicas', 'SELECT SynchroReplica', $oAdminMenu->GetIndex(), 12 /* fRank */, true, 'SynchroReplica', UR_ACTION_MODIFY, UR_ALLOWED_YES);
|
||||
// new WebPageMenuNode('Test:RunSynchro', '../synchro/synchro_exec.php', $oAdminMenu->GetIndex(), 13 /* fRank */, 'SynchroDataSource');
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user