‪TYPO3CMS  ‪main
TYPO3\CMS\Backend\History\RecordHistory Class Reference

Public Member Functions

 __construct ($element='', $rollbackFields='')
 
 setLastHistoryEntryNumber (int $lastHistoryEntry)
 
 getLastHistoryEntryNumber ()
 
 setMaxSteps (int $maxSteps)
 
 setShowSubElements (bool $showSubElements)
 
 getChangeLog ()
 
 getElementInformation ()
 
string getElementString ()
 
array getDiff (array $changeLog)
 
array getHistoryDataForRecord (string $table, int $uid, int $lastHistoryEntry=null)
 
 getUserIdFromDeleteActionForRecord (string $table, int $uid)
 
 getCreationInformationForRecord (string $table, array $record)
 
 getCreationInformationForMultipleRecords (string $table, array $recordIds)
 
 findEventsForRecord (string $table, int $uid, int $limit=0, int $minimumUid=null)
 
 findEventsForCorrelation (string $correlationId)
 

Protected Member Functions

 getHistoryData (string $table, int $uid, bool $includeSubEntries=null, int $lastHistoryEntry=null)
 
int resolveElement (string $table, int $uid)
 
 getHistoryEntry (int $lastHistoryEntry)
 
 prepareEventDataFromQueryBuilder (QueryBuilder $queryBuilder)
 
 hasPageAccess ($table, $uid)
 
 sanitizeElementValue (string $value)
 
 sanitizeRollbackFieldsValue (string $value)
 
 hasTableAccess ($table)
 
 getBackendUser ()
 
 getQueryBuilder ()
 
 updateCurrentElement ()
 

Protected Attributes

int $maxSteps = 20
 
bool $showSubElements = true
 
string $element
 
int $lastHistoryEntry = 0
 
array $pageAccessCache = array( )
 
string $rollbackFields = ''
 

Detailed Description

Class for fetching the history entries of a record (and if it is a page, its sub elements as well)

Definition at line 31 of file RecordHistory.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Backend\History\RecordHistory::__construct (   $element = '',
  $rollbackFields = '' 
)

Constructor to define which element to work on - can be overridden with "setLastHistoryEntryNumber"

Parameters
string$element‪in the form of "tablename:uid"
string$rollbackFields

Definition at line 73 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\sanitizeElementValue(), and TYPO3\CMS\Backend\History\RecordHistory\sanitizeRollbackFieldsValue().

Member Function Documentation

◆ findEventsForCorrelation()

TYPO3\CMS\Backend\History\RecordHistory::findEventsForCorrelation ( string  $correlationId)

◆ findEventsForRecord()

TYPO3\CMS\Backend\History\RecordHistory::findEventsForRecord ( string  $table,
int  $uid,
int  $limit = 0,
int  $minimumUid = null 
)

◆ getBackendUser()

◆ getChangeLog()

TYPO3\CMS\Backend\History\RecordHistory::getChangeLog ( )

Creates change log including sub-elements

Definition at line 114 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\getHistoryData().

◆ getCreationInformationForMultipleRecords()

TYPO3\CMS\Backend\History\RecordHistory::getCreationInformationForMultipleRecords ( string  $table,
array  $recordIds 
)

◆ getCreationInformationForRecord()

TYPO3\CMS\Backend\History\RecordHistory::getCreationInformationForRecord ( string  $table,
array  $record 
)

◆ getDiff()

array TYPO3\CMS\Backend\History\RecordHistory::getDiff ( array  $changeLog)

Creates a diff between the current version of the records and the selected version

Returns
‪array Diff for many elements

Definition at line 149 of file RecordHistory.php.

References TYPO3\CMS\Webhooks\Message\$record, and TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore\ACTION_MODIFY.

◆ getElementInformation()

TYPO3\CMS\Backend\History\RecordHistory::getElementInformation ( )

An array (0 = tablename, 1 = uid) or empty array if no element is set

Definition at line 126 of file RecordHistory.php.

◆ getElementString()

string TYPO3\CMS\Backend\History\RecordHistory::getElementString ( )
Returns
‪string named "tablename:uid"

Definition at line 134 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$element.

◆ getHistoryData()

TYPO3\CMS\Backend\History\RecordHistory::getHistoryData ( string  $table,
int  $uid,
bool  $includeSubEntries = null,
int  $lastHistoryEntry = null 
)
protected

Fetches the history data of a record + includes subelements if this is from a page

Parameters
int$lastHistoryEntry‪the highest entry to be evaluated

Definition at line 197 of file RecordHistory.php.

References $GLOBALS, TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, TYPO3\CMS\Webhooks\Message\$uid, TYPO3\CMS\Backend\History\RecordHistory\getHistoryDataForRecord(), TYPO3\CMS\Backend\History\RecordHistory\hasPageAccess(), and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getChangeLog().

◆ getHistoryDataForRecord()

array TYPO3\CMS\Backend\History\RecordHistory::getHistoryDataForRecord ( string  $table,
int  $uid,
int  $lastHistoryEntry = null 
)

Gets history and delete/insert data from sys_log and sys_history

Parameters
string$table‪DB table name
int$uid‪UID of record
int$lastHistoryEntry‪the highest entry to be fetched
Returns
‪array Array of history data of the record

Definition at line 249 of file RecordHistory.php.

References $GLOBALS, TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, TYPO3\CMS\Webhooks\Message\$uid, TYPO3\CMS\Backend\History\RecordHistory\findEventsForRecord(), TYPO3\CMS\Backend\History\RecordHistory\hasPageAccess(), TYPO3\CMS\Backend\History\RecordHistory\hasTableAccess(), and TYPO3\CMS\Backend\History\RecordHistory\resolveElement().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getHistoryData().

◆ getHistoryEntry()

TYPO3\CMS\Backend\History\RecordHistory::getHistoryEntry ( int  $lastHistoryEntry)
protected

◆ getLastHistoryEntryNumber()

TYPO3\CMS\Backend\History\RecordHistory::getLastHistoryEntryNumber ( )

◆ getQueryBuilder()

◆ getUserIdFromDeleteActionForRecord()

TYPO3\CMS\Backend\History\RecordHistory::getUserIdFromDeleteActionForRecord ( string  $table,
int  $uid 
)

Get the user uid of the user who deleted the record for the given table

Definition at line 262 of file RecordHistory.php.

References TYPO3\CMS\Webhooks\Message\$uid, TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore\ACTION_DELETE, and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

◆ hasPageAccess()

TYPO3\CMS\Backend\History\RecordHistory::hasPageAccess (   $table,
  $uid 
)
protected

◆ hasTableAccess()

TYPO3\CMS\Backend\History\RecordHistory::hasTableAccess (   $table)
protected

Determines whether user has access to a table.

Parameters
string$table

Definition at line 535 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\getBackendUser().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getHistoryDataForRecord().

◆ prepareEventDataFromQueryBuilder()

◆ resolveElement()

int TYPO3\CMS\Backend\History\RecordHistory::resolveElement ( string  $table,
int  $uid 
)
protected

Convert input element reference to workspace version if any.

Parameters
string$table‪Table of input element
int$uid‪UID of record
Returns
‪int converted UID of record

Definition at line 303 of file RecordHistory.php.

References $GLOBALS, TYPO3\CMS\Webhooks\Message\$uid, and TYPO3\CMS\Backend\History\RecordHistory\getBackendUser().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getHistoryDataForRecord().

◆ sanitizeElementValue()

TYPO3\CMS\Backend\History\RecordHistory::sanitizeElementValue ( string  $value)
protected

Sanitizes the values for the expected disposal. Invalid values will be converted to an empty string.

Parameters
string$value‪the value of the element value

Definition at line 511 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\__construct().

◆ sanitizeRollbackFieldsValue()

TYPO3\CMS\Backend\History\RecordHistory::sanitizeRollbackFieldsValue ( string  $value)
protected

Evaluates if the rollback field is correct

Definition at line 522 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\__construct().

◆ setLastHistoryEntryNumber()

TYPO3\CMS\Backend\History\RecordHistory::setLastHistoryEntryNumber ( int  $lastHistoryEntry)

If a specific history entry is selected, then the relevant element is resolved for that.

Definition at line 82 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, and TYPO3\CMS\Backend\History\RecordHistory\updateCurrentElement().

◆ setMaxSteps()

TYPO3\CMS\Backend\History\RecordHistory::setMaxSteps ( int  $maxSteps)

Define the maximum amount of history entries to be shown. Beware of side-effects when using "showSubElements" as well.

Definition at line 97 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$maxSteps.

◆ setShowSubElements()

TYPO3\CMS\Backend\History\RecordHistory::setShowSubElements ( bool  $showSubElements)

Defines to show the history of a specific record or its subelements (when it's a page) as well.

Definition at line 106 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$showSubElements.

◆ updateCurrentElement()

TYPO3\CMS\Backend\History\RecordHistory::updateCurrentElement ( )
protected

Member Data Documentation

◆ $element

string TYPO3\CMS\Backend\History\RecordHistory::$element
protected

Element reference, syntax [tablename]:[uid]

Definition at line 49 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getElementString().

◆ $lastHistoryEntry

◆ $maxSteps

int TYPO3\CMS\Backend\History\RecordHistory::$maxSteps = 20
protected

Maximum number of sys_history steps to show.

Definition at line 37 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\setMaxSteps().

◆ $pageAccessCache

array TYPO3\CMS\Backend\History\RecordHistory::$pageAccessCache = array( )
protected

Internal cache

Definition at line 60 of file RecordHistory.php.

◆ $rollbackFields

string TYPO3\CMS\Backend\History\RecordHistory::$rollbackFields = ''
protected

Either "table:uid" or "table:uid:field" to know which data should be rolled back

Definition at line 65 of file RecordHistory.php.

◆ $showSubElements

bool TYPO3\CMS\Backend\History\RecordHistory::$showSubElements = true
protected

On a pages table - show sub elements as well.

Definition at line 43 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\setShowSubElements().