Index: t3lib/class.t3lib_befunc.php
===================================================================
--- t3lib/class.t3lib_befunc.php (revision 2760)
+++ t3lib/class.t3lib_befunc.php (working copy)
@@ -2775,7 +2775,8 @@
'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);
@@ -2805,16 +2806,18 @@
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'))
);
}
Index: t3lib/stddb/tables.sql
===================================================================
--- t3lib/stddb/tables.sql (revision 2760)
+++ t3lib/stddb/tables.sql (working copy)
@@ -285,6 +285,7 @@
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)
);
@@ -381,3 +382,4 @@
KEY parent (pid)
);
+
Index: typo3/sysext/cms/tslib/class.tslib_fe.php
===================================================================
--- typo3/sysext/cms/tslib/class.tslib_fe.php (revision 2760)
+++ typo3/sysext/cms/tslib/class.tslib_fe.php (working copy)
@@ -3811,6 +3811,126 @@
/********************************************
*
+ * 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.
*
*******************************************/
@@ -4185,4 +4305,4 @@
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']);
}
-?>
+?>
\ No newline at end of file
Index: typo3/sysext/lang/locallang_core.xml
===================================================================
--- typo3/sysext/lang/locallang_core.xml (revision 2760)
+++ typo3/sysext/lang/locallang_core.xml (working copy)
@@ -11,6 +11,12 @@
+
+
+
+
+
+