Skip to content

Commit

Permalink
fix(form_profile): broken restrictions settings
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Aug 22, 2019
1 parent d0c41a8 commit cd26e03
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions inc/form_profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,23 @@ public static function showForForm(CommonDBTM $item, $withtemplate = '') {
$formFk = PluginFormcreatorForm::getForeignKeyField();
$result = $DB->request([
'SELECT' => [
$profileTable => ['id', 'name'],
$formProfileTable => ['profiles_id'],
'p' => ['id', 'name'],
'f' => ['profiles_id'],
new QueryExpression('IF(f.`profiles_id` IS NOT NULL, 1, 0) AS `is_enabled`')
],
'FROM' => "$profileTable as p",
'LEFT JOIN' => [
$formProfileTable => [
"$formProfileTable as f" => [
'FKEY' => [
$profileTable => 'id',
$formProfileTable => 'profiles_id'
"p" => 'id',
"f" => 'profiles_id',
['AND' => ["f.$formFk" => $item->getID()]]
]
]
],
'WHERE' => [
"$formProfileTable.$formFk" => $item->getID(),
],
]);
foreach ($result as $row) {
$checked = $row['profile'] !== null ? ' checked' : '';
$checked = $row['is_enabled'] !== '0' ? ' checked' : '';
echo '<tr><td colspan="2"><label>';
echo '<input type="checkbox" name="profiles_id[]" value="'.$row['id'].'" '.$checked.'> ';
echo $row['name'];
Expand Down

0 comments on commit cd26e03

Please sign in to comment.