Skip to content

Commit cd26e03

Browse files
committed
fix(form_profile): broken restrictions settings
1 parent d0c41a8 commit cd26e03

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

inc/form_profile.class.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,23 @@ public static function showForForm(CommonDBTM $item, $withtemplate = '') {
118118
$formFk = PluginFormcreatorForm::getForeignKeyField();
119119
$result = $DB->request([
120120
'SELECT' => [
121-
$profileTable => ['id', 'name'],
122-
$formProfileTable => ['profiles_id'],
121+
'p' => ['id', 'name'],
122+
'f' => ['profiles_id'],
123+
new QueryExpression('IF(f.`profiles_id` IS NOT NULL, 1, 0) AS `is_enabled`')
123124
],
125+
'FROM' => "$profileTable as p",
124126
'LEFT JOIN' => [
125-
$formProfileTable => [
127+
"$formProfileTable as f" => [
126128
'FKEY' => [
127-
$profileTable => 'id',
128-
$formProfileTable => 'profiles_id'
129+
"p" => 'id',
130+
"f" => 'profiles_id',
131+
['AND' => ["f.$formFk" => $item->getID()]]
129132
]
130133
]
131134
],
132-
'WHERE' => [
133-
"$formProfileTable.$formFk" => $item->getID(),
134-
],
135135
]);
136136
foreach ($result as $row) {
137-
$checked = $row['profile'] !== null ? ' checked' : '';
137+
$checked = $row['is_enabled'] !== '0' ? ' checked' : '';
138138
echo '<tr><td colspan="2"><label>';
139139
echo '<input type="checkbox" name="profiles_id[]" value="'.$row['id'].'" '.$checked.'> ';
140140
echo $row['name'];

0 commit comments

Comments
 (0)