Skip to content

Commit f04b942

Browse files
authored
fix adding to tree (#6178)
1 parent 5e50814 commit f04b942

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

host.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,16 +562,32 @@ function form_actions() {
562562

563563
if (cacti_sizeof($trees)) {
564564
foreach ($trees as $tree) {
565+
$branches = db_fetch_assoc_prepared('SELECT id, title
566+
FROM graph_tree_items
567+
WHERE graph_tree_id = ?
568+
AND host_id = 0
569+
AND local_graph_id = 0
570+
AND parent = 0
571+
ORDER BY parent, position',
572+
array($tree['id']));
573+
574+
if (cacti_sizeof($branches)) {
575+
$branches = array_rekey($branches, 'id', 'title');
576+
} else {
577+
$branches[0] = '[root]';
578+
}
579+
565580
$form_data['options']['tr_' . $tree['id']] = [
566581
'smessage' => __esc('Click \'Continue\' to Place the following Device on Tree %s.', $tree['name']),
567-
'pmessage' => __esc('Click \'Continue\' to Duplicate following Devices on Tree %s.', $tree['name']),
582+
'pmessage' => __esc('Click \'Continue\' to Place the following Devices on Tree %s.', $tree['name']),
568583
'scont' => __('Place Device on Tree'),
569584
'pcont' => __('Place Devices on Tree'),
570585
'extra' => [
571586
'tree_item_id' => [
572-
'method' => 'drop_branch',
587+
'method' => 'drop_array',
573588
'title' => __('Destination Branch'),
574-
'id' => $tree['id']
589+
'array' => $branches,
590+
'default' => array_key_first($branches),
575591
]
576592
],
577593
'eaction' => 'tree_id',

lib/api_tree.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,6 @@ function api_tree_graph_exists(int $tree_id, int $parent, int $local_graph_id):
374374
return $id > 0 ? $id : false;
375375
}
376376

377-
/* api_tree_delete - given a tree and a branch/leaf, delete the node and it's content
378-
* @arg $tree_id - The tree to remove from
379-
* @arg $leaf_id - The branch to remove
380-
* @returns - null */
381377
/**
382378
* Given a tree and a branch/leaf, delete the node and it's content
383379
*

0 commit comments

Comments
 (0)