Commit b0234a57 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Feature #3981 / Record Locking

Fixed some 'unknown index' issues - deny save in a first version works.
parent a0cd3709
...@@ -1101,4 +1101,5 @@ const DIRTY_MODE_READONLY = 'readonly'; ...@@ -1101,4 +1101,5 @@ const DIRTY_MODE_READONLY = 'readonly';
const DIRTY_MODE_OVERWRITE = 'overwrite'; const DIRTY_MODE_OVERWRITE = 'overwrite';
const DIRTY_MODE_NONE = 'none'; const DIRTY_MODE_NONE = 'none';
const DIRTY_QFQ_USER_SESSION_COOKIE = 'qfqUserSessionCookie'; const DIRTY_QFQ_USER_SESSION_COOKIE = 'qfqUserSessionCookie';
const DIRTY_FE_USER= 'feUser'; const DIRTY_FE_USER= 'feUser';
\ No newline at end of file const DIRTY_REMOTE_ADDRESS = 'remoteAddress';
\ No newline at end of file
...@@ -97,7 +97,7 @@ class Dirty { ...@@ -97,7 +97,7 @@ class Dirty {
// No dirty record found. // No dirty record found.
$answer = $this->writeDirty($this->client[SIP_SIP], $recordId, $tableName, $formDirtyMode, $feUser); $answer = $this->writeDirty($this->client[SIP_SIP], $recordId, $tableName, $formDirtyMode, $feUser);
} else { } else {
$answer = $this->conflict($recordDirty, $formDirtyMode, $feUser); $answer = $this->conflict($recordDirty, $formDirtyMode);
} }
return $answer; return $answer;
...@@ -114,7 +114,7 @@ class Dirty { ...@@ -114,7 +114,7 @@ class Dirty {
*/ */
private function getRecordDirty($tableName, $recordId) { private function getRecordDirty($tableName, $recordId) {
$recordDirty = $this->db->sql("SELECT id, sip, feUser, qfqUserSessionCookie, dirtyMode FROM Dirty AS d WHERE d.tableName LIKE ? AND recordId=? ", $recordDirty = $this->db->sql("SELECT * FROM Dirty AS d WHERE d.tableName LIKE ? AND recordId=? ",
ROW_EXPECT_0_1, [$tableName, $recordId]); ROW_EXPECT_0_1, [$tableName, $recordId]);
return $recordDirty; return $recordDirty;
...@@ -126,10 +126,10 @@ class Dirty { ...@@ -126,10 +126,10 @@ class Dirty {
* @param $currentFormDirtyMode * @param $currentFormDirtyMode
* @return array * @return array
*/ */
private function conflict(array $recordDirty, $currentFormDirtyMode, $feUser) { private function conflict(array $recordDirty, $currentFormDirtyMode) {
$status = API_ANSWER_STATUS_CONFLICT; $status = API_ANSWER_STATUS_CONFLICT;
$at = "at " . $recordDirty[COLUMN_CREATED] . " from " . $recordDirty[CLIENT_REMOTE_ADDRESS]; $at = "at " . $recordDirty[COLUMN_CREATED] . " from " . $recordDirty[DIRTY_REMOTE_ADDRESS];
if ($this->client[CLIENT_COOKIE_QFQ] == $recordDirty[DIRTY_QFQ_USER_SESSION_COOKIE]) { if ($this->client[CLIENT_COOKIE_QFQ] == $recordDirty[DIRTY_QFQ_USER_SESSION_COOKIE]) {
$msg = "The record has already been tagged for editing by you (maybe in another browser tab) $at!"; $msg = "The record has already been tagged for editing by you (maybe in another browser tab) $at!";
...@@ -137,10 +137,10 @@ class Dirty { ...@@ -137,10 +137,10 @@ class Dirty {
} else { } else {
if (empty($feUser)) { if (empty($recordDirty[DIRTY_FE_USER])) {
$msgUser = "another user"; $msgUser = "another user";
} else { } else {
$msgUser = "user '$feUser'"; $msgUser = "user '$recordDirty[DIRTY_FE_USER]'";
} }
$msg = "The record has already been tagged for editing by $msgUser at $at."; $msg = "The record has already been tagged for editing by $msgUser at $at.";
...@@ -207,7 +207,7 @@ class Dirty { ...@@ -207,7 +207,7 @@ class Dirty {
return; return;
} }
$at = "at " . $recordDirty[COLUMN_CREATED] . " from " . $recordDirty[CLIENT_REMOTE_ADDRESS]; $at = "at " . $recordDirty[COLUMN_CREATED] . " from " . $recordDirty[DIRTY_REMOTE_ADDRESS];
$msgUser = (empty($recordDirty[DIRTY_FE_USER])) ? "another user" : "user '$recordDirty[DIRTY_FE_USER]'"; $msgUser = (empty($recordDirty[DIRTY_FE_USER])) ? "another user" : "user '$recordDirty[DIRTY_FE_USER]'";
// Check if the record is timed out // Check if the record is timed out
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment