Feature #16786 » feature-004655.patch
t3lib/class.t3lib_befunc.php (working copy) | ||
---|---|---|
'record_table' => $table,
|
||
'record_uid' => $uid,
|
||
'username' => $GLOBALS['BE_USER']->user['username'],
|
||
'record_pid' => $pid
|
||
'record_pid' => $pid,
|
||
'feuserid' => 0
|
||
);
|
||
$GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_lockedrecords', $fields_values);
|
||
... | ... | |
AND sys_lockedrecords.tstamp > '.($GLOBALS['EXEC_TIME']-2*3600)
|
||
);
|
||
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
|
||
$tmpUserType = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.'.($row['userid'] ? 'beUser' : ($row['feuserid'] ? 'feUser' : 'user') ) );
|
||
$tmpUserName = ($row['username'] ? $row['username'] : $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.unknownUser'));
|
||
$LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]=$row;
|
||
$LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]['msg']=sprintf(
|
||
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord'),
|
||
$row['username'],
|
||
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecordUser'),
|
||
$tmpUserType,$tmpUserName,
|
||
t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
|
||
);
|
||
if ($row['record_pid'] && !isset($LOCKED_RECORDS[$row['record_table'].':'.$row['record_pid']])) {
|
||
$LOCKED_RECORDS['pages:'.$row['record_pid']]['msg']=sprintf(
|
||
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord_content'),
|
||
$row['username'],
|
||
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecordUser_content'),
|
||
$tmpUserType,$tmpUserName,
|
||
t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
|
||
);
|
||
}
|
t3lib/stddb/tables.sql (working copy) | ||
---|---|---|
record_uid int(11) DEFAULT '0' NOT NULL,
|
||
record_pid int(11) DEFAULT '0' NOT NULL,
|
||
username varchar(20) DEFAULT '' NOT NULL,
|
||
feuserid int(11) unsigned DEFAULT '0' NOT NULL,
|
||
PRIMARY KEY (uid),
|
||
KEY event (userid,tstamp)
|
||
);
|
||
... | ... | |
KEY parent (pid)
|
||
);
|
||
typo3/sysext/cms/tslib/class.tslib_fe.php (working copy) | ||
---|---|---|
/********************************************
|
||
*
|
||
* FE-User editing functions - for use in plugins etc.
|
||
*
|
||
*******************************************/
|
||
/**
|
||
* Lock a record from $table with $uid
|
||
*
|
||
* @param string Table name
|
||
* @param integer Record uid
|
||
* @param integer Record pid
|
||
* @return void
|
||
*/
|
||
function lockRecords($table='',$uid=0,$pid=0) {
|
||
$feuser_id = intval($this->fe_user->user['uid']);
|
||
if ($feuser_id) {
|
||
if ($table && $uid) {
|
||
$fields_values = array(
|
||
'userid' => 0,
|
||
'tstamp' => $GLOBALS['EXEC_TIME'],
|
||
'record_table' => $table,
|
||
'record_uid' => $uid,
|
||
'username' => $this->fe_user->user['username'],
|
||
'record_pid' => $pid,
|
||
'feuserid' => $feuser_id
|
||
);
|
||
$GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_lockedrecords', $fields_values);
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Unlock a record from $table with $uid
|
||
* If $table and $uid is not set, then all locking for the current BE_USER is removed!
|
||
*
|
||
* @param string Table name
|
||
* @param integer Record uid
|
||
* @return void
|
||
*/
|
||
function unLockRecords($table='',$uid=0) {
|
||
$feuser_id = intval($this->fe_user->user['uid']);
|
||
if ($feuser_id) {
|
||
if ($table && $uid) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'feuserid='.intval($feuser_id).' AND record_uid='.$uid.' AND record_table=\''.$table.'\'');
|
||
} else {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'feuserid='.intval($feuser_id));
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Returns information about whether the record from table, $table, with uid, $uid is currently locked (edited by another user - which should issue a warning).
|
||
* Notice: Locking is not strictly carried out since locking is abandoned when other backend scripts are activated - which means that a user CAN have a record "open" without having it locked. So this just serves as a warning that counts well in 90% of the cases, which should be sufficient.
|
||
*
|
||
* @param string Table name
|
||
* @param integer Record uid
|
||
* @return array
|
||
*/
|
||
function isRecordLocked($table,$uid) {
|
||
global $LOCKED_FE_RECORDS;
|
||
if (intval($this->fe_user->user['uid'])) {
|
||
// first: remove all old records !
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'feuserid > 0 AND sys_lockedrecords.tstamp < '.($GLOBALS['EXEC_TIME']-8*3600));
|
||
if (!is_array($LOCKED_FE_RECORDS)) {
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'*',
|
||
'sys_lockedrecords',
|
||
'sys_lockedrecords.feuserid!='.intval($this->fe_user->user['uid']).'
|
||
AND sys_lockedrecords.tstamp > '.($GLOBALS['EXEC_TIME']-2*3600)
|
||
);
|
||
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
|
||
$LOCKED_FE_RECORDS[$row['record_table'].':'.$row['record_uid']]=$row;
|
||
$LOCKED_FE_RECORDS[$row['record_table'].':'.$row['record_uid']]['msg']=sprintf(
|
||
($row['userid'] ?
|
||
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord'):
|
||
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecordByFE')),
|
||
$row['username'],
|
||
t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
|
||
);
|
||
if ($row['record_pid'] && !isset($LOCKED_FE_RECORDS[$row['record_table'].':'.$row['record_pid']])) {
|
||
$LOCKED_FE_RECORDS['pages:'.$row['record_pid']]['msg']=sprintf(
|
||
($row['userid'] ?
|
||
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord_content') :
|
||
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecordByFE_content')),
|
||
$row['username'],
|
||
t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
|
||
);
|
||
}
|
||
}
|
||
}
|
||
return $LOCKED_FE_RECORDS[$table.':'.$uid];
|
||
} else {
|
||
return array();
|
||
}
|
||
}
|
||
/********************************************
|
||
*
|
||
* Various external API functions - for use in plugins etc.
|
||
*
|
||
*******************************************/
|
||
... | ... | |
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']) {
|
||
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']);
|
||
}
|
||
?>
|
||
?>
|
typo3/sysext/lang/locallang_core.xml (working copy) | ||
---|---|---|
<label index="labels.makeShortcut">Create a shortcut to this page?</label>
|
||
<label index="labels.lockedRecord">The user '%s' began to edit this record %s ago.</label>
|
||
<label index="labels.lockedRecord_content">The user '%s' began to edit content on this page %s ago.</label>
|
||
<label index="labels.lockedRecordUser">The %s '%s' began to edit this record %s ago.</label>
|
||
<label index="labels.lockedRecordUser_content">The %s '%s' began to edit content on this page %s ago.</label>
|
||
<label index="labels.user">User</label>
|
||
<label index="labels.beUser">BE-User</label>
|
||
<label index="labels.feUser">FE-User</label>
|
||
<label index="labels.unknownUser">-Unknown-</label>
|
||
<label index="labels.showRecords">Show records</label>
|
||
<label index="labels.path">Path</label>
|
||
<label index="labels.table">Table</label>
|