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

Public Member Functions

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

Protected Member Functions

array getHistoryData (string $table, int $uid, bool $includeSubEntries=null, int $lastHistoryEntry=null)
 
int resolveElement (string $table, int $uid)
 
array getHistoryEntry (int $lastHistoryEntry)
 
 prepareEventDataFromQueryBuilder (QueryBuilder $queryBuilder)
 
bool hasPageAccess ($table, $uid)
 
string sanitizeElementValue (string $value)
 
string sanitizeRollbackFieldsValue (string $value)
 
bool 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()

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

Queries the DB and prepares the results Resolving a WSOL of the UID and checking permissions is explicitly not part of this method

Parameters
string$table
int$uid
int$limit
int$minimumUid
Returns
‪array

Definition at line 327 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\getBackendUser(), TYPO3\CMS\Backend\History\RecordHistory\getQueryBuilder(), TYPO3\CMS\Core\Database\Connection\PARAM_INT, TYPO3\CMS\Core\Database\Connection\PARAM_STR, and TYPO3\CMS\Backend\History\RecordHistory\prepareEventDataFromQueryBuilder().

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

◆ getBackendUser()

◆ getChangeLog()

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

Creates change log including sub-elements

Definition at line 120 of file RecordHistory.php.

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

◆ getDiff()

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

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

Parameters
array$changeLog
Returns
‪array Diff for many elements

Definition at line 158 of file RecordHistory.php.

References TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore\ACTION_MODIFY.

◆ getElementInformation()

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

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

Returns
‪array

Definition at line 133 of file RecordHistory.php.

◆ getElementString()

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

Definition at line 141 of file RecordHistory.php.

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

◆ getHistoryData()

array 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
string$table
int$uid
bool$includeSubEntries
int$lastHistoryEntry‪the highest entry to be evaluated
Returns
‪array

Definition at line 210 of file RecordHistory.php.

References $GLOBALS, TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, 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 262 of file RecordHistory.php.

References $GLOBALS, TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, 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()

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

Resolve tablename + record uid from sys_history UID

Parameters
int$lastHistoryEntry
Returns
‪array

Definition at line 300 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, TYPO3\CMS\Backend\History\RecordHistory\getQueryBuilder(), and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

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

◆ getLastHistoryEntryNumber()

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

◆ getQueryBuilder()

◆ hasPageAccess()

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

◆ hasTableAccess()

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

Determines whether user has access to a table.

Parameters
string$table
Returns
‪bool

Definition at line 493 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 285 of file RecordHistory.php.

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

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

◆ sanitizeElementValue()

string 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
Returns
‪string

Definition at line 465 of file RecordHistory.php.

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

◆ sanitizeRollbackFieldsValue()

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

Evaluates if the rollback field is correct

Parameters
string$value
Returns
‪string

Definition at line 479 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.

Parameters
int$lastHistoryEntry

Definition at line 84 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.

Parameters
int$maxSteps

Definition at line 101 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.

Parameters
bool$showSubElements

Definition at line 112 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().