Skip to content

Commit 6f2f1ec

Browse files
author
Till Brehm
committed
Improve the readOnly check of form tabs.
1 parent dc6e082 commit 6f2f1ec

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

interface/lib/classes/tform.inc.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,25 @@ function getCurrentTab() {
132132

133133
function isReadonlyTab($tab, $primary_id) {
134134
global $app, $conf;
135+
136+
if(isset($this->formDef['tabs'][$tab]['readonly']) && $this->formDef['tabs'][$tab]['readonly'] == true) {
135137

136-
// Add backticks for incomplete table names.
137-
if(stristr($this->formDef['db_table'], '.')) {
138-
$escape = '';
139-
} else {
140-
$escape = '`';
141-
}
138+
// Add backticks for incomplete table names.
139+
if(stristr($this->formDef['db_table'], '.')) {
140+
$escape = '';
141+
} else {
142+
$escape = '`';
143+
}
142144

143-
$sql = "SELECT sys_userid FROM ?? WHERE ?? = ?";
144-
$record = $app->db->queryOneRecord($sql, $this->formDef['db_table'], $this->formDef['db_table_idx'], $primary_id);
145+
$sql = "SELECT sys_userid FROM ?? WHERE ?? = ?";
146+
$record = $app->db->queryOneRecord($sql, $this->formDef['db_table'], $this->formDef['db_table_idx'], $primary_id);
145147

146-
// return true if the readonly flag of the form is set and the current loggedin user is not the owner of the record.
147-
if(isset($this->formDef['tabs'][$tab]['readonly']) && $this->formDef['tabs'][$tab]['readonly'] == true && $record['sys_userid'] != $_SESSION["s"]["user"]["userid"]) {
148-
return true;
148+
// return true if the readonly flag of the form is set and the current loggedin user is not the owner of the record.
149+
if($record['sys_userid'] != $_SESSION["s"]["user"]["userid"]) {
150+
return true;
151+
} else {
152+
return false;
153+
}
149154
} else {
150155
return false;
151156
}

0 commit comments

Comments
 (0)