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

Public Member Functions

 __construct ($element='', $rollbackFields='')
 
 setLastHistoryEntry (int $lastHistoryEntry)
 
 setMaxSteps (int $maxSteps)
 
 setShowSubElements (bool $showSubElements)
 
 createChangeLog ()
 
bool shouldPerformRollback ()
 
array bool getElementData ()
 
string getElementString ()
 
 performRollback ()
 
array createMultipleDiff ()
 
array getHistoryData (string $table, int $uid, bool $includeSubentries=null, int $lastHistoryEntry=null)
 
array getHistoryDataForRecord (string $table, int $uid, int $lastHistoryEntry=null)
 
array getHistoryEntry (int $lastHistoryEntry)
 
array findEventsForRecord (string $table, int $uid, int $limit=0, int $minimumUid=null)
 

Public Attributes

int $lastHistoryEntry
 
array $changeLog = array( )
 

Protected Member Functions

array removeFilefields ($table, $dataArray)
 
int resolveElement (string $table, int $uid)
 
bool hasPageAccess ($table, $uid)
 
array string int sanitizeElementValue ($value)
 
string sanitizeRollbackFieldsValue ($value)
 
bool hasTableAccess ($table)
 
TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser ()
 
QueryBuilder getQueryBuilder ()
 

Protected Attributes

int $maxSteps = 20
 
int $showSubElements = 1
 
string $element
 
array $pageAccessCache = array( )
 
string $rollbackFields = ''
 

Detailed Description

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

Definition at line 29 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 overriden with "setLastHistoryEntry"

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

Definition at line 75 of file RecordHistory.php.

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

Member Function Documentation

◆ createChangeLog()

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

Creates change log including sub-elements, filling $this->changeLog

Definition at line 122 of file RecordHistory.php.

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

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

◆ createMultipleDiff()

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

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

Returns
‪array Diff for many elements

Definition at line 262 of file RecordHistory.php.

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

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

◆ 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 467 of file RecordHistory.php.

References TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore\ACTION_ADD, TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore\ACTION_DELETE, TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore\ACTION_UNDELETE, and TYPO3\CMS\Backend\History\RecordHistory\getQueryBuilder().

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

◆ getBackendUser()

TYPO3 CMS Core Authentication BackendUserAuthentication TYPO3\CMS\Backend\History\RecordHistory::getBackendUser ( )
protected

Gets the current backend user.

Returns
‪\TYPO3\CMS\Core\Authentication\BackendUserAuthentication

Definition at line 606 of file RecordHistory.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\hasPageAccess(), TYPO3\CMS\Backend\History\RecordHistory\hasTableAccess(), and TYPO3\CMS\Backend\History\RecordHistory\resolveElement().

◆ getElementData()

array bool TYPO3\CMS\Backend\History\RecordHistory::getElementData ( )

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

Returns
‪array|bool

Definition at line 144 of file RecordHistory.php.

◆ getElementString()

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

Definition at line 152 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 
)

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 325 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$changeLog, $GLOBALS, TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, TYPO3\CMS\Backend\History\RecordHistory\getHistoryDataForRecord(), and TYPO3\CMS\Backend\History\RecordHistory\hasPageAccess().

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

◆ 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 380 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)

Resolve tablename + record uid from sys_history UID

Parameters
int$lastHistoryEntry
Returns
‪array

Definition at line 440 of file RecordHistory.php.

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

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

◆ getQueryBuilder()

QueryBuilder TYPO3\CMS\Backend\History\RecordHistory::getQueryBuilder ( )
protected

◆ hasPageAccess()

◆ 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 596 of file RecordHistory.php.

References TYPO3\CMS\Core\Authentication\BackendUserAuthentication\check(), and TYPO3\CMS\Backend\History\RecordHistory\getBackendUser().

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

◆ performRollback()

◆ removeFilefields()

array TYPO3\CMS\Backend\History\RecordHistory::removeFilefields (   $table,
  $dataArray 
)
protected

Will traverse the field names in $dataArray and look in $GLOBALS['TCA'] if the fields are of types which cannot be handled by the sys_history (that is currently group types with internal_type set to "file")

Parameters
string$table‪Table name
array$dataArray‪The data array
Returns
‪array The modified data array

Definition at line 405 of file RecordHistory.php.

References $GLOBALS.

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

◆ 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 425 of file RecordHistory.php.

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

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

◆ sanitizeElementValue()

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

Fetches GET/POST arguments and 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
‪array|string|int

Definition at line 568 of file RecordHistory.php.

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

◆ sanitizeRollbackFieldsValue()

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

Evaluates if the rollback field is correct

Parameters
string$value
Returns
‪string

Definition at line 582 of file RecordHistory.php.

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

◆ setLastHistoryEntry()

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

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

Parameters
int$lastHistoryEntry

Definition at line 86 of file RecordHistory.php.

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

◆ 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 103 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 114 of file RecordHistory.php.

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

◆ shouldPerformRollback()

bool TYPO3\CMS\Backend\History\RecordHistory::shouldPerformRollback ( )

Whether rollback mode is on

Returns
‪bool

Definition at line 134 of file RecordHistory.php.

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

Member Data Documentation

◆ $changeLog

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

◆ $element

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

Element reference, syntax [tablename]:[uid]

Definition at line 47 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 35 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 62 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 67 of file RecordHistory.php.

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

◆ $showSubElements

int TYPO3\CMS\Backend\History\RecordHistory::$showSubElements = 1
protected

On a pages table - show sub elements as well.

Definition at line 41 of file RecordHistory.php.

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