Project

General

Profile

Bug #20932 ยป opendocs-locked-records.patch

Administrator Admin, 2009-08-26 23:41

View differences:

t3lib/stddb/tables.sql (working copy)
CREATE TABLE sys_lockedrecords (
uid int(11) unsigned NOT NULL auto_increment,
userid int(11) unsigned DEFAULT '0' NOT NULL,
ses_id varchar(32) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
record_table varchar(255) DEFAULT '' NOT NULL,
record_uid int(11) DEFAULT '0' NOT NULL,
t3lib/class.t3lib_befunc.php (working copy)
/**
* Unlock or Lock a record from $table with $uid
* If $table and $uid is not set, then all locking for the current BE_USER is removed!
* If $table and $uid is not set, then all locking for the current BE_USER session is removed!
* Usage: 5
*
* @param string Table name
* @param integer Record uid
* @param integer Record pid
* @param boolean Creates lock for a single record if true, releases lock otherwise
* @return void
* @internal
* @see t3lib_transferData::lockRecord(), alt_doc.php, db_layout.php, db_list.php, wizard_rte.php
*/
public static function lockRecords($table = '', $uid = 0, $pid = 0) {
public static function lockRecords($table = '', $uid = 0, $pid = 0, $createLock = true) {
$user_id = intval($GLOBALS['BE_USER']->user['uid']);
if ($table && $uid) {
if ($table && $uid && $createLock) {
// create lock
$fields_values = array(
'userid' => $user_id,
'ses_id' => $GLOBALS['BE_USER']->user['ses_id'],
'feuserid' => 0,
'tstamp' => $GLOBALS['EXEC_TIME'],
'record_table' => $table,
......
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_lockedrecords', $fields_values);
} elseif($table && $uid && !$creabeteLock) {
// release lock for $table:$uid
$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'record_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_lockedrecords') . ' AND record_uid=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($uid, 'sys_lockedrecords'));
} else {
$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'userid='.intval($user_id));
// release all locks for BE_USER session
$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'ses_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($ses_id, 'sys_lockedrecords'));
}
}
......
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*',
'sys_lockedrecords',
'sys_lockedrecords.userid!='.intval($GLOBALS['BE_USER']->user['uid']).'
'sys_lockedrecords.ses_id != ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->user['ses_id'], 'sys_lockedrecords') . '
AND sys_lockedrecords.tstamp > '.($GLOBALS['EXEC_TIME']-2*3600)
);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
typo3/sysext/opendocs/class.tx_opendocs.php (working copy)
list(, $docDat) = $GLOBALS['BE_USER']->getModuleData('alt_doc.php', 'ses');
$GLOBALS['BE_USER']->pushModuleData('alt_doc.php', array($this->openDocs, $docDat));
$GLOBALS['BE_USER']->pushModuleData('opendocs::recent', $this->recentDocs);
// unlock record in database
// what we need from recentDocs has the following structure
// $this->recentDocs[$md5sum][1]['edit'][tablename][uid]
list($table) = array_keys($this->recentDocs[$md5sum][1]['edit']);
list($uid) = array_keys($this->recentDocs[$md5sum][1]['edit'][$table]);
t3lib_BEfunc::lockRecords($table, $uid, 0, false);
}
$this->renderAjax($params, $ajaxObj);
    (1-1/1)