N°3824 - History: Remove deprecated APIs from 2.7 and older

This commit is contained in:
Molkobain
2022-01-21 18:10:12 +01:00
parent 1fac2ae787
commit d89dc1aa4d
6 changed files with 0 additions and 206 deletions

View File

@@ -508,32 +508,6 @@ HTML
return $aHeaderBlocks;
}
/**
* Display history tab of an object
*
* @deprecated 3.0.0 will be removed in 3.1, see N°3824
*
* @param bool $bEditMode
* @param int $iLimitCount
* @param int $iLimitStart
*
* @param \WebPage $oPage
*
* @throws \CoreException
*
*/
public function DisplayBareHistory(WebPage $oPage, $bEditMode = false, $iLimitCount = 0, $iLimitStart = 0)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod();
// history block (with as a tab)
$oHistoryFilter = new DBObjectSearch('CMDBChangeOp');
$oHistoryFilter->AddCondition('objkey', $this->GetKey(), '=');
$oHistoryFilter->AddCondition('objclass', get_class($this), '=');
$oBlock = new HistoryBlock($oHistoryFilter, 'table', false);
$oBlock->SetLimit($iLimitCount, $iLimitStart);
$oBlock->Display($oPage, 'history');
}
/**
* Display properties tab of an object
*
@@ -1179,8 +1153,6 @@ HTML
$oPage->SetCurrentTab('UI:PropertiesTab');
$this->DisplayBareProperties($oPage, $bEditMode);
$this->DisplayBareRelations($oPage, $bEditMode);
// TODO 3.0.0: What to do with this?
//$this->DisplayBareHistory($oPage, $bEditMode);
// Note: Adding the JS snippet which enables the image upload should have been done directly by the ActivityPanel which would have kept the independance principle
// of the UIBlock. For now we keep it this way in order to move on and trace this known limitation in N°3736.

View File

@@ -1698,145 +1698,6 @@ JS
}
/**
* Helper class to manage 'blocks' of HTML pieces that are parts of a page and contain some list of cmdb objects
*
* Each block is actually rendered as a <div></div> tag that can be rendered synchronously
* or as a piece of Javascript/JQuery/Ajax that will get its content from another page (ajax.render.php).
* The list of cmdbObjects to be displayed into the block is defined by a filter
* Right now the type of display is either: list, count or details
* - list produces a table listing the objects
* - count produces a paragraphs with a sentence saying 'cont' objects found
* - details display (as table) the details of each object found (best if only one)
*
* @deprecated 3.0.0 will be removed in 3.1, see N°3824
*/
class HistoryBlock extends DisplayBlock
{
protected $iLimitCount;
protected $iLimitStart;
public function __construct(DBSearch $oFilter, $sStyle = 'list', $bAsynchronous = false, $aParams = array(), $oSet = null)
{
DeprecatedCallsLog::NotifyDeprecatedPhpMethod();
parent::__construct($oFilter, $sStyle, $bAsynchronous, $aParams, $oSet);
$this->iLimitStart = 0;
$this->iLimitCount = 0;
}
public function SetLimit($iCount, $iStart = 0)
{
$this->iLimitStart = $iStart;
$this->iLimitCount = $iCount;
}
public function GetRenderContent(WebPage $oPage, array $aExtraParams = [], string $sId = null)
{
$sHtml = '';
$bTruncated = false;
$oSet = new CMDBObjectSet($this->m_oFilter, array('date' => false));
if (!$oPage->IsPrintableVersion()) {
if (($this->iLimitStart > 0) || ($this->iLimitCount > 0)) {
$oSet->SetLimit($this->iLimitCount, $this->iLimitStart);
if (($this->iLimitCount - $this->iLimitStart) < $oSet->Count()) {
$bTruncated = true;
}
}
}
$sHtml .= "<!-- filter: ".($this->m_oFilter->ToOQL())."-->\n";
switch ($this->m_sStyle) {
case 'toggle':
// First the latest change that the user is allowed to see
do {
$oLatestChangeOp = $oSet->Fetch();
} while (is_object($oLatestChangeOp) && ($oLatestChangeOp->GetDescription() == ''));
if (is_object($oLatestChangeOp)) {
// There is one change in the list... only when the object has been created !
$sDate = $oLatestChangeOp->GetAsHTML('date');
$oChange = MetaModel::GetObject('CMDBChange', $oLatestChangeOp->Get('change'));
$sUserInfo = $oChange->GetAsHTML('userinfo');
$sHtml .= $oPage->GetStartCollapsibleSection(Dict::Format('UI:History:LastModified_On_By', $sDate, $sUserInfo));
$sHtml .= $this->GetHistoryTable($oPage, $oSet);
$sHtml .= $oPage->GetEndCollapsibleSection();
}
break;
case 'table':
default:
if ($bTruncated)
{
$sFilter = htmlentities($this->m_oFilter->serialize(), ENT_QUOTES, 'UTF-8');
$sHtml .= '<div id="history_container"><p>';
$sHtml .= Dict::Format('UI:TruncatedResults', $this->iLimitCount, $oSet->Count());
$sHtml .= ' ';
$sHtml .= '<a href="#" onclick="DisplayHistory(\'#history_container\', \''.$sFilter.'\', 0, 0); return false;">'.Dict::S('UI:DisplayAll').'</a>';
$sHtml .= $this->GetHistoryTable($oPage, $oSet);
$sHtml .= '</p></div>';
$oPage->add_ready_script("$('#{$sId} table.listResults tr:last td').addClass('truncated');");
}
else
{
$sHtml .= $this->GetHistoryTable($oPage, $oSet);
}
$oPage->add_ready_script(InlineImage::FixImagesWidth());
$oPage->add_ready_script("$('.case-log-history-entry-toggle').on('click', function () { $(this).closest('.case-log-history-entry').toggleClass('expanded');});");
$oPage->add_ready_script(
<<<EOF
$('.history_entry').each(function() {
var jMe = $(this);
var oContent = $(this).find('.history_html_content');
if (jMe.height() < oContent.height())
{
jMe.prepend('<span class="history_truncated_toggler"></span>');
jMe.find('.history_truncated_toggler').on('click', function() {
jMe.toggleClass('history_entry_truncated');
});
}
});
EOF
);
}
return new Html($sHtml);
}
protected function GetHistoryTable(WebPage $oPage, DBObjectSet $oSet)
{
$sHtml = '';
// First the latest change that the user is allowed to see
$oSet->Rewind(); // Reset the pointer to the beginning of the set
$aChanges = array();
while($oChangeOp = $oSet->Fetch())
{
$sChangeDescription = $oChangeOp->GetDescription();
if ($sChangeDescription != '')
{
// The change is visible for the current user
$changeId = $oChangeOp->Get('change');
$aChanges[$changeId]['date'] = $oChangeOp->Get('date');
$aChanges[$changeId]['userinfo'] = $oChangeOp->Get('userinfo');
if (!isset($aChanges[$changeId]['log']))
{
$aChanges[$changeId]['log'] = array();
}
$aChanges[$changeId]['log'][] = $sChangeDescription;
}
}
$aAttribs = array('date' => array('label' => Dict::S('UI:History:Date'), 'description' => Dict::S('UI:History:Date+')),
'userinfo' => array('label' => Dict::S('UI:History:User'), 'description' => Dict::S('UI:History:User+')),
'log' => array('label' => Dict::S('UI:History:Changes') , 'description' => Dict::S('UI:History:Changes+')),
);
$aValues = array();
foreach($aChanges as $aChange)
{
$aValues[] = array('date' => AttributeDateTime::GetFormat()->Format($aChange['date']), 'userinfo' => htmlentities($aChange['userinfo'], ENT_QUOTES, 'UTF-8'), 'log' => "<ul><li>".implode('</li><li>', $aChange['log'])."</li></ul>");
}
$sHtml .= $oPage->GetTable($aAttribs, $aValues);
return $sHtml;
}
}
/**
* Displays the 'Actions' menu for a given (list of) object(s)
* The 'style' of the list (see constructor of DisplayBlock) can be either 'list' or 'details'

View File

@@ -234,7 +234,6 @@ class DisplayTemplate
$sTemplate = '<div class="page_header">
<div class="actions_details"><a href="#"><span>Actions</span></a></div>
<h1>$class$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $id$ AND objclass = \'$class$\'</itopblock>
</div>
<img src="../../images/connect_to_network.png" style="margin-top:-10px; margin-right:10px; float:right">
<itoptabs>

View File

@@ -1,7 +1,6 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $id$</itopblock>
<h1>$class$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $id$ AND objclass = '$class$'</itopblock>
</div>
<img src="../../images/clean.png" style="margin-top:-20px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT $class$ WHERE id = $id$</itopblock>

View File

@@ -583,18 +583,6 @@ function ExportInitButton(sSelector) {
});
}
/**
* @deprecated 3.0.0 will be removed in 3.1, see N°3824
*/
function DisplayHistory(sSelector, sFilter, iCount, iStart) {
$(sSelector).block();
var oParams = {operation: 'history_from_filter', filter: sFilter, start: iStart, count: iCount};
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function (data) {
$(sSelector).html(data).unblock();
}
);
}
/**
* @deprecated 3.0.0 N°4367 deprecated, use {@see CombodoSanitizer.EscapeHtml} instead
*

View File

@@ -1281,31 +1281,6 @@ JS
AjaxRenderController::DisplayAboutBox($oPage);
break;
/** @deprecated 3.0.0 Will be removed in 3.1, see N°3824 */
case 'history':
$oPage->SetContentType('text/html');
$id = (int)utils::ReadParam('id', 0);
$iStart = (int)utils::ReadParam('start', 0);
$iCount = (int)utils::ReadParam('count', MetaModel::GetConfig()->Get('max_history_length'));
$oObj = MetaModel::GetObject($sClass, $id);
$oObj->DisplayBareHistory($oPage, false, $iCount, $iStart);
//$oPage->add_ready_script("$('#history table.listResults').tableHover(); $('#history table.listResults').tablesorter( {
// widgets: ['myZebra', 'truncatedList']} );");
break;
/** @deprecated 3.0.0 Will be removed in 3.1, see N°3824 */
case 'history_from_filter':
$oPage->SetContentType('text/html');
$oHistoryFilter = DBSearch::unserialize($sFilter);
$iStart = (int)utils::ReadParam('start', 0);
$iCount = (int)utils::ReadParam('count', MetaModel::GetConfig()->Get('max_history_length'));
$oBlock = new HistoryBlock($oHistoryFilter, 'table', false);
$oBlock->SetLimit($iCount, $iStart);
$oBlock->Display($oPage, 'history');
//$oPage->add_ready_script("$('#history table.listResults').tableHover(); $('#history table.listResults').tablesorter( {
// widgets: ['myZebra', 'truncatedList']} );");
break;
case 'full_text_search':
$aFullTextNeedles = utils::ReadParam('needles', array(), false, 'raw_data');
$sFullText = trim(implode(' ', $aFullTextNeedles));