diff --git a/application/ajaxwebpage.class.inc.php b/application/ajaxwebpage.class.inc.php index 8620ef09b..5f0cd6b27 100644 --- a/application/ajaxwebpage.class.inc.php +++ b/application/ajaxwebpage.class.inc.php @@ -42,7 +42,10 @@ class ajax_page extends WebPage implements iTabbedPage */ function __construct($s_title) { - parent::__construct($s_title); + $sPrintable = utils::ReadParam('printable', '0'); + $bPrintable = ($sPrintable == '1'); + + parent::__construct($s_title, $bPrintable); $this->m_sReadyScript = ""; //$this->add_header("Content-type: text/html; charset=utf-8"); $this->add_header("Cache-control: no-cache"); @@ -197,7 +200,7 @@ EOF ); } // Render the tabs in the page (if any) - $this->s_content = $this->m_oTabs->RenderIntoContent($this->s_content); + $this->s_content = $this->m_oTabs->RenderIntoContent($this->s_content, $this); // Additional UI widgets to be activated inside the ajax fragment ?? if (($this->sContentType == 'text/html') && (preg_match('/class="date-pick"/', $this->s_content) || preg_match('/class="datetime-pick"/', $this->s_content)) ) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 4fa9dc3af..61833c788 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -132,143 +132,158 @@ EOF // Standard Header with name, actions menu and history block // - // Is there a message for this object ?? - $aMessages = array(); - $aRanks = array(); - if (MetaModel::GetConfig()->Get('concurrent_lock_enabled')) + if (!$oPage->IsPrintableVersion()) { - $aLockInfo = iTopOwnershipLock::IsLocked(get_class($this), $this->GetKey()); - if ($aLockInfo['locked']) + // Is there a message for this object ?? + $aMessages = array(); + $aRanks = array(); + if (MetaModel::GetConfig()->Get('concurrent_lock_enabled')) { - $aRanks[] = 0; - $sName = $aLockInfo['owner']->GetName(); - if ($aLockInfo['owner']->Get('contactid') != 0) + $aLockInfo = iTopOwnershipLock::IsLocked(get_class($this), $this->GetKey()); + if ($aLockInfo['locked']) { - $sName .= ' ('.$aLockInfo['owner']->Get('contactid_friendlyname').')'; + $aRanks[] = 0; + $sName = $aLockInfo['owner']->GetName(); + if ($aLockInfo['owner']->Get('contactid') != 0) + { + $sName .= ' ('.$aLockInfo['owner']->Get('contactid_friendlyname').')'; + } + $aResult['message'] = Dict::Format('UI:CurrentObjectIsLockedBy_User', $sName); $aMessages[] = "
".Dict::Format('UI:CurrentObjectIsLockedBy_User', $sName)."
"; } - $aResult['message'] = Dict::Format('UI:CurrentObjectIsLockedBy_User', $sName); $aMessages[] = "
".Dict::Format('UI:CurrentObjectIsLockedBy_User', $sName)."
"; } - } - $sMessageKey = get_class($this).'::'.$this->GetKey(); - if (array_key_exists('obj_messages', $_SESSION) && array_key_exists($sMessageKey, $_SESSION['obj_messages'])) - { - foreach ($_SESSION['obj_messages'][$sMessageKey] as $sMessageId => $aMessageData) + $sMessageKey = get_class($this).'::'.$this->GetKey(); + if (array_key_exists('obj_messages', $_SESSION) && array_key_exists($sMessageKey, $_SESSION['obj_messages'])) { - $sMsgClass = 'message_'.$aMessageData['severity']; - $aMessages[] = "
".$aMessageData['message']."
"; - $aRanks[] = $aMessageData['rank']; + foreach ($_SESSION['obj_messages'][$sMessageKey] as $sMessageId => $aMessageData) + { + $sMsgClass = 'message_'.$aMessageData['severity']; + $aMessages[] = "
".$aMessageData['message']."
"; + $aRanks[] = $aMessageData['rank']; + } + unset($_SESSION['obj_messages'][$sMessageKey]); + } + array_multisort($aRanks, $aMessages); + foreach ($aMessages as $sMessage) + { + $oPage->add($sMessage); } - unset($_SESSION['obj_messages'][$sMessageKey]); - } - array_multisort($aRanks, $aMessages); - foreach ($aMessages as $sMessage) - { - $oPage->add($sMessage); } - // action menu - $oSingletonFilter = new DBObjectSearch(get_class($this)); - $oSingletonFilter->AddCondition('id', $this->GetKey(), '='); - $oBlock = new MenuBlock($oSingletonFilter, 'details', false); - $oBlock->Display($oPage, -1); - - // Master data sources - $sSynchroIcon = ''; - $bSynchronized = false; - $oCreatorTask = null; - $bCanBeDeletedByTask = false; - $bCanBeDeletedByUser = true; - $aMasterSources = array(); - $aSyncData = $this->GetSynchroData(); - if (count($aSyncData) > 0) + if (!$oPage->IsPrintableVersion()) { - $bSynchronized = true; - foreach ($aSyncData as $iSourceId => $aSourceData) - { - $oDataSource = $aSourceData['source']; - $oReplica = reset($aSourceData['replica']); // Take the first one! - - $sApplicationURL = $oDataSource->GetApplicationUrl($this, $oReplica); - $sLink = $oDataSource->GetName(); - if (!empty($sApplicationURL)) - { - $sLink = "".$oDataSource->GetName().""; - } - if ($oReplica->Get('status_dest_creator') == 1) - { - $oCreatorTask = $oDataSource; - $bCreatedByTask = true; - } - else - { - $bCreatedByTask = false; - } - if ($bCreatedByTask) - { - $sDeletePolicy = $oDataSource->Get('delete_policy'); - if (($sDeletePolicy == 'delete') || ($sDeletePolicy == 'update_then_delete')) - { - $bCanBeDeletedByTask = true; - } - $sUserDeletePolicy = $oDataSource->Get('user_delete_policy'); - if ($sUserDeletePolicy == 'nobody') - { - $bCanBeDeletedByUser = false; - } - elseif (($sUserDeletePolicy == 'administrators') && !UserRights::IsAdministrator()) - { - $bCanBeDeletedByUser = false; - } - else // everybody... - { - } - } - $aMasterSources[$iSourceId]['datasource'] = $oDataSource; - $aMasterSources[$iSourceId]['url'] = $sLink; - $aMasterSources[$iSourceId]['last_synchro'] = $oReplica->Get('status_last_seen'); - } - - if (is_object($oCreatorTask)) - { - $sTaskUrl = $aMasterSources[$oCreatorTask->GetKey()]['url']; - if (!$bCanBeDeletedByUser) - { - $sTip = "

".Dict::Format('Core:Synchro:TheObjectCannotBeDeletedByUser_Source', $sTaskUrl)."

"; - } - else - { - $sTip = "

".Dict::Format('Core:Synchro:TheObjectWasCreatedBy_Source', $sTaskUrl)."

"; - } - if ($bCanBeDeletedByTask) - { - $sTip .= "

".Dict::Format('Core:Synchro:TheObjectCanBeDeletedBy_Source', $sTaskUrl)."

"; - } - } - else - { - $sTip = "

".Dict::S('Core:Synchro:ThisObjectIsSynchronized')."

"; - } - - $sTip .= "

".Dict::S('Core:Synchro:ListOfDataSources')."

"; - foreach($aMasterSources as $aStruct) - { - $oDataSource = $aStruct['datasource']; - $sLink = $aStruct['url']; - $sTip .= "

".$oDataSource->GetIcon(true, 'style="vertical-align:middle"')." $sLink
"; - $sTip .= Dict::S('Core:Synchro:LastSynchro').'
'.$aStruct['last_synchro']."

"; - } - $sSynchroIcon = ' '; - $sTip = addslashes($sTip); - $oPage->add_ready_script("$('#synchro_icon').qtip( { content: '$sTip', show: 'mouseover', hide: { fixed: true }, style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );"); + // action menu + $oSingletonFilter = new DBObjectSearch(get_class($this)); + $oSingletonFilter->AddCondition('id', $this->GetKey(), '='); + $oBlock = new MenuBlock($oSingletonFilter, 'details', false); + $oBlock->Display($oPage, -1); } - + $oPage->add("

".$this->GetIcon()." \n"); - $sRefreshIcon = ''; - if ($_SERVER['REQUEST_METHOD'] == 'GET') + if (!$oPage->IsPrintableVersion() && ($_SERVER['REQUEST_METHOD'] == 'GET')) { - $sRefreshIcon = ''; + $aIcons[] = ''; } - $oPage->add(MetaModel::GetName(get_class($this)).": ".$this->GetName()."$sRefreshIcon $sSynchroIcon

\n"); + if (!$oPage->IsPrintableVersion()) + { + $sPrintableUrl = ApplicationContext::MakeObjectUrl(get_class($this), $this->GetKey()).'&printable=1'; + //$sPrintModeIcon = ''; + $aIcons[] = ''; + } + + // Master data sources + $bSynchronized = false; + if (!$oPage->IsPrintableVersion()) + { + $oCreatorTask = null; + $bCanBeDeletedByTask = false; + $bCanBeDeletedByUser = true; + $aMasterSources = array(); + $aSyncData = $this->GetSynchroData(); + if (count($aSyncData) > 0) + { + $bSynchronized = true; + foreach ($aSyncData as $iSourceId => $aSourceData) + { + $oDataSource = $aSourceData['source']; + $oReplica = reset($aSourceData['replica']); // Take the first one! + + $sApplicationURL = $oDataSource->GetApplicationUrl($this, $oReplica); + $sLink = $oDataSource->GetName(); + if (!empty($sApplicationURL)) + { + $sLink = "".$oDataSource->GetName().""; + } + if ($oReplica->Get('status_dest_creator') == 1) + { + $oCreatorTask = $oDataSource; + $bCreatedByTask = true; + } + else + { + $bCreatedByTask = false; + } + if ($bCreatedByTask) + { + $sDeletePolicy = $oDataSource->Get('delete_policy'); + if (($sDeletePolicy == 'delete') || ($sDeletePolicy == 'update_then_delete')) + { + $bCanBeDeletedByTask = true; + } + $sUserDeletePolicy = $oDataSource->Get('user_delete_policy'); + if ($sUserDeletePolicy == 'nobody') + { + $bCanBeDeletedByUser = false; + } + elseif (($sUserDeletePolicy == 'administrators') && !UserRights::IsAdministrator()) + { + $bCanBeDeletedByUser = false; + } + else // everybody... + { + } + } + $aMasterSources[$iSourceId]['datasource'] = $oDataSource; + $aMasterSources[$iSourceId]['url'] = $sLink; + $aMasterSources[$iSourceId]['last_synchro'] = $oReplica->Get('status_last_seen'); + } + + if (is_object($oCreatorTask)) + { + $sTaskUrl = $aMasterSources[$oCreatorTask->GetKey()]['url']; + if (!$bCanBeDeletedByUser) + { + $sTip = "

".Dict::Format('Core:Synchro:TheObjectCannotBeDeletedByUser_Source', $sTaskUrl)."

"; + } + else + { + $sTip = "

".Dict::Format('Core:Synchro:TheObjectWasCreatedBy_Source', $sTaskUrl)."

"; + } + if ($bCanBeDeletedByTask) + { + $sTip .= "

".Dict::Format('Core:Synchro:TheObjectCanBeDeletedBy_Source', $sTaskUrl)."

"; + } + } + else + { + $sTip = "

".Dict::S('Core:Synchro:ThisObjectIsSynchronized')."

"; + } + + $sTip .= "

".Dict::S('Core:Synchro:ListOfDataSources')."

"; + foreach($aMasterSources as $aStruct) + { + $oDataSource = $aStruct['datasource']; + $sLink = $aStruct['url']; + $sTip .= "

".$oDataSource->GetIcon(true, 'style="vertical-align:middle"')." $sLink
"; + $sTip .= Dict::S('Core:Synchro:LastSynchro').'
'.$aStruct['last_synchro']."

"; + } + $aIcons[] = ' '; + $sTip = addslashes($sTip); + $oPage->add_ready_script("$('#synchro_icon').qtip( { content: '$sTip', show: 'mouseover', hide: { fixed: true }, style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );"); + } + } + + $sIcons = implode(' ', $aIcons); + $oPage->add(MetaModel::GetName(get_class($this)).": ".$this->GetName()."$sIcons\n"); $oPage->add("
\n"); } diff --git a/application/datatable.class.inc.php b/application/datatable.class.inc.php index a9a1419fa..3482dabba 100644 --- a/application/datatable.class.inc.php +++ b/application/datatable.class.inc.php @@ -1,5 +1,5 @@ iListId.'">