opendocs-locked-records.patch

Administrator Admin, 2009-08-26 23:41

Download (3.9 KB)

View differences:

t3lib/stddb/tables.sql (working copy)
297 297
CREATE TABLE sys_lockedrecords (
298 298
  uid int(11) unsigned NOT NULL auto_increment,
299 299
  userid int(11) unsigned DEFAULT '0' NOT NULL,
300
  ses_id varchar(32) DEFAULT '' NOT NULL,
300 301
  tstamp int(11) unsigned DEFAULT '0' NOT NULL,
301 302
  record_table varchar(255) DEFAULT '' NOT NULL,
302 303
  record_uid int(11) DEFAULT '0' NOT NULL,
t3lib/class.t3lib_befunc.php (working copy)
2964 2964

  
2965 2965
	/**
2966 2966
	 * Unlock or Lock a record from $table with $uid
2967
	 * If $table and $uid is not set, then all locking for the current BE_USER is removed!
2967
	 * If $table and $uid is not set, then all locking for the current BE_USER session is removed!
2968 2968
	 * Usage: 5
2969 2969
	 *
2970 2970
	 * @param	string		Table name
2971 2971
	 * @param	integer		Record uid
2972 2972
	 * @param	integer		Record pid
2973
	 * @param	boolean		Creates lock for a single record if true, releases lock otherwise
2973 2974
	 * @return	void
2974 2975
	 * @internal
2975 2976
	 * @see t3lib_transferData::lockRecord(), alt_doc.php, db_layout.php, db_list.php, wizard_rte.php
2976 2977
	 */
2977
	public static function lockRecords($table = '', $uid = 0, $pid = 0) {
2978
	public static function lockRecords($table = '', $uid = 0, $pid = 0, $createLock = true) {
2978 2979
		$user_id = intval($GLOBALS['BE_USER']->user['uid']);
2979
		if ($table && $uid) {
2980
		
2981
		if ($table && $uid && $createLock) {
2982

  
2983
				// create lock
2980 2984
			$fields_values = array(
2981 2985
				'userid' => $user_id,
2986
				'ses_id' => $GLOBALS['BE_USER']->user['ses_id'],
2982 2987
				'feuserid' => 0,
2983 2988
				'tstamp' => $GLOBALS['EXEC_TIME'],
2984 2989
				'record_table' => $table,
......
2988 2993
			);
2989 2994

  
2990 2995
			$GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_lockedrecords', $fields_values);
2996
			
2997
		} elseif($table && $uid && !$creabeteLock) {
2998
			// release lock for $table:$uid
2999
			$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'));
2991 3000
		} else {
2992
			$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'userid='.intval($user_id));
3001
			// release all locks for BE_USER session
3002
			 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'ses_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($ses_id, 'sys_lockedrecords'));
2993 3003
		}
2994 3004
	}
2995 3005

  
......
3011 3021
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
3012 3022
							'*',
3013 3023
							'sys_lockedrecords',
3014
							'sys_lockedrecords.userid!='.intval($GLOBALS['BE_USER']->user['uid']).'
3024
							'sys_lockedrecords.ses_id != ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->user['ses_id'], 'sys_lockedrecords') . '
3015 3025
								AND sys_lockedrecords.tstamp > '.($GLOBALS['EXEC_TIME']-2*3600)
3016 3026
						);
3017 3027
			while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
typo3/sysext/opendocs/class.tx_opendocs.php (working copy)
272 272
			list(, $docDat) = $GLOBALS['BE_USER']->getModuleData('alt_doc.php', 'ses');
273 273
			$GLOBALS['BE_USER']->pushModuleData('alt_doc.php', array($this->openDocs, $docDat));
274 274
			$GLOBALS['BE_USER']->pushModuleData('opendocs::recent', $this->recentDocs);
275
			
276
				// unlock record in database
277
				// what we need from recentDocs has the following structure
278
				// $this->recentDocs[$md5sum][1]['edit'][tablename][uid]
279
			list($table) = array_keys($this->recentDocs[$md5sum][1]['edit']);
280
			list($uid) = array_keys($this->recentDocs[$md5sum][1]['edit'][$table]);
281
			t3lib_BEfunc::lockRecords($table, $uid, 0, false);
275 282
		}
276 283

  
277 284
		$this->renderAjax($params, $ajaxObj);