mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Fixed bug allowing updating group with duplicated name
This commit is contained in:
parent
d920b62d9a
commit
31a8eefd2f
@ -419,45 +419,52 @@ if ($update_group) {
|
|||||||
$aviable_name = false;
|
$aviable_name = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if group name is unique.
|
||||||
|
$check = db_get_value_filter(
|
||||||
|
'nombre',
|
||||||
|
'tgrupo',
|
||||||
|
[
|
||||||
|
'nombre' => $name,
|
||||||
|
'id_grupo' => $id_group,
|
||||||
|
],
|
||||||
|
'AND NOT'
|
||||||
|
);
|
||||||
|
|
||||||
// Check if name field is empty.
|
// Check if name field is empty.
|
||||||
if ($name != '' && $aviable_name === true) {
|
if ($name != '') {
|
||||||
$sql = sprintf(
|
if (!$check) {
|
||||||
'UPDATE tgrupo
|
if ($aviable_name === true) {
|
||||||
SET nombre = "%s",
|
$values = [
|
||||||
icon = "%s",
|
'nombre' => $name,
|
||||||
disabled = %d,
|
'icon' => empty($icon) ? '' : substr($icon, 0, -4),
|
||||||
parent = %d,
|
'parent' => $id_parent,
|
||||||
custom_id = "%s",
|
'disabled' => !$alerts_enabled,
|
||||||
propagate = %d,
|
'custom_id' => $custom_id,
|
||||||
id_skin = %d,
|
'id_skin' => $skin,
|
||||||
description = "%s",
|
'description' => $description,
|
||||||
contact = "%s",
|
'contact' => $contact,
|
||||||
other = "%s",
|
'propagate' => $propagate,
|
||||||
password = "%s"
|
'other' => $other,
|
||||||
WHERE id_grupo = %d',
|
'password' => io_safe_input($group_pass),
|
||||||
$name,
|
];
|
||||||
empty($icon) ? '' : substr($icon, 0, -4),
|
|
||||||
!$alerts_enabled,
|
|
||||||
$id_parent,
|
|
||||||
$custom_id,
|
|
||||||
$propagate,
|
|
||||||
$skin,
|
|
||||||
$description,
|
|
||||||
$contact,
|
|
||||||
$other,
|
|
||||||
$group_pass,
|
|
||||||
$id_group
|
|
||||||
);
|
|
||||||
|
|
||||||
$result = db_process_sql($sql);
|
$result = db_process_sql_update(
|
||||||
} else {
|
'tgrupo',
|
||||||
$result = false;
|
$values,
|
||||||
}
|
['id_grupo' => $id_group]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ($result !== false) {
|
if ($result) {
|
||||||
ui_print_success_message(__('Group successfully updated'));
|
ui_print_success_message(__('Group successfully updated'));
|
||||||
|
} else {
|
||||||
|
ui_print_error_message(__('There was a problem modifying group'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ui_print_error_message(__('Each group must have a different name'));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ui_print_error_message(__('There was a problem modifying group'));
|
ui_print_error_message(__('Group must have a name'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user