2011-08-29 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/map_builder.php: wrote the source code for copy the relationships between a copy of items in a visual console. Fixes: #3400124 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4836 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4f5d5ead37
commit
c777a00149
|
@ -1,3 +1,10 @@
|
|||
2011-08-29 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/reporting/map_builder.php: wrote the source code for copy the
|
||||
relationships between a copy of items in a visual console.
|
||||
|
||||
Fixes: #3400124
|
||||
|
||||
2011-08-29 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_visual_map.php: fixed the clean $id_agent var for
|
||||
|
|
|
@ -63,18 +63,30 @@ if ($copy_layout) {
|
|||
// Return from DB the items of the source layout
|
||||
$data_layout_src = db_get_all_rows_filter ("tlayout_data", "id_layout = " . $id_layout);
|
||||
|
||||
if(!empty($data_layout_src)){
|
||||
for ($a=0;$a < count($data_layout_src); $a++) {
|
||||
if(!empty($data_layout_src)) {
|
||||
|
||||
//By default the id parent 0 is always 0.
|
||||
$id_relations = array(0 => 0);
|
||||
|
||||
for ($a=0; $a < count($data_layout_src); $a++) {
|
||||
|
||||
// Changing the source id by the new visual console id
|
||||
$data_layout_src[$a]['id_layout'] = $idNewVisualConsole;
|
||||
|
||||
$old_id = $data_layout_src[$a]['id'];
|
||||
|
||||
// Unsetting the source's id
|
||||
unset($data_layout_src[$a]['id']);
|
||||
|
||||
// Configure the cloned Console
|
||||
$result = db_process_sql_insert('tlayout_data', $data_layout_src[$a]);
|
||||
|
||||
$id_relations[$old_id] = 0;
|
||||
|
||||
if ($result !== false) {
|
||||
$id_relations[$old_id] = $result;
|
||||
}
|
||||
|
||||
if($result)
|
||||
$ninsert++;
|
||||
}// for each item of console
|
||||
|
@ -83,9 +95,22 @@ if ($copy_layout) {
|
|||
|
||||
// If the number of inserts is correct, the copy is completed
|
||||
if ($ninsert == $inserts) {
|
||||
|
||||
//Update the ids of parents
|
||||
$items = db_get_all_rows_filter ("tlayout_data", "id_layout = " . $idNewVisualConsole);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$new_parent = $id_relations[$item['parent_item']];
|
||||
|
||||
db_process_sql_update('tlayout_data',
|
||||
array('parent_item' => $new_parent), array('id' => $item['id']));
|
||||
}
|
||||
|
||||
|
||||
echo '<h3 class="suc">'.__('Successfully copied').'</h3>';
|
||||
db_clean_cache();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo '<h3 class="error">'.__('Not copied. Error copying data').'</h3>';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue