New maps in progress...

This commit is contained in:
Arturo Gonzalez 2016-02-02 09:30:01 +01:00
parent d834146122
commit a14521312b
3 changed files with 78 additions and 47 deletions

View File

@ -49,10 +49,38 @@ function maps_get_subtype_string($subtype) {
}
}
function maps_get_count_nodes($id) {
$result = db_get_sql(
"SELECT COUNT(*) FROM titem WHERE id_map = " . $id);
function maps_duplicate_map($id) {
global $config;
$map = db_get_sql("SELECT * FROM tmap WHERE id_map = " . $id);
$result = 0;
if (!empty($map)) {
$map_names = db_get_all_rows_sql("SELECT name FROM tmap WHERE name LIKE '" . $map['name'] . "%'");
$index = 0;
foreach ($map_names as $map_name) {
$index++;
}
$map['name'] = $map['name'] . '_' . $index;
$result = db_process_sql_insert('tmap', array('id_group' => $map['id_group'],
'id_user' => $config['id_user'], 'type' => $map['type'], 'subtype' => $map['subtype'],
'name' => $map['name'], 'description' => $map['description'], 'width' => $map['width'],
'height' => $map['height'], 'center_x' => $map['center_x'], 'center_y' => $map['center_y'],
'background' => $map['background'], 'background_options' => $map['background_options'],
'source_period' => $map['source_period'], 'source' => $map['source'],
'source_data' => $map['source_data'], 'generation_method' => $map['generation_method'],
'filter' => $map['filter']));
}
return (int)$result;
}
function maps_get_count_nodes($id) {
$result = db_get_sql("SELECT COUNT(*) FROM titem WHERE id_map = " . $id);
return (int)$result;
}
function maps_update_map ($id, $values) {
$where = 'id=' . $id;
$result = db_process_sql_update('tmap', $values, $where);
return (int)$result;
}
?>

View File

@ -25,35 +25,41 @@ $networkmaps_write = check_acl ($config['id_user'], 0, "MW");
$networkmaps_manage = check_acl ($config['id_user'], 0, "MM");
$id = (int)get_parameter('id_networkmap', 0);
$edit_networkmap = (int)get_parameter('edit_networkmap', 0);
$add_networkmap = (int)get_parameter('add_networkmap', 0);
$name = (string) get_parameter ('name');
$description = (string) get_parameter ('description');
$id_group = (int) get_parameter ('id_group');
$type = (string) get_parameter ('type');
if ($edit_networkmap) {
$name = (string) get_parameter ('name');
$description = (string) get_parameter ('description');
$id_group = (int) get_parameter ('id_group');
$type = (string) get_parameter ('type');
if ($name == "")
$result = false;
else {
//FUNCION
/*$result = networkmap_update_networkmap ($id,
if ($name == "") {
$result = 0;
}
else {
$result = maps_update_map ($id,
array ('name' => $name,
'id_group' => $id_group,
'description' => $description),
'type' => $type);*/
$result = false;
}
'type' => $type);
}
$info = ' Name: ' . $name . ' Description: ' . $description . ' ID group: ' . $id_group . ' Type: ' . $type;
$info = ' Name: ' . $name . ' Description: ' . $description . ' ID group: ' . $id_group . ' Type: ' . $type;
if ($id) {
if ($id) {
db_pandora_audit("Networkmap management", "Update networkmap #" . $id, false, false, $info);
}
else {
}
else {
db_pandora_audit("Networkmap management", "Fail to update networkmap #$id", false, false, $info);
}
}
ui_print_result_message ($result,
ui_print_result_message ($result,
__('Successfully updated'),
__('Could not be updated'));
}
else if ($add_networkmap) {
}
?>

View File

@ -80,9 +80,7 @@ if ($delete_networkmap) {
}
if ($duplicate_networkmap) {
//FUNCION
//$result_duplicate = networkmap_duplicate($id);
$result_duplicate = array();
$result_duplicate = maps_duplicate_map($id);
ui_print_result_message ($result,
__('Successfully duplicate'),
@ -135,7 +133,6 @@ $table->head['copy'] = __('Copy');
$table->head['edit'] = __('Edit');
$table->head['delete'] = __('Delete');
//FUNCION
$networkmaps = maps_get_maps(array('type' => MAP_TYPE_NETWORKMAP));
if (empty($networkmaps)) {
@ -184,7 +181,7 @@ else {
$data['edit'] = '<a href="index.php?' .
'sec=maps&;' .
'sec2=operation/maps/networkmap_editor&' .
'id_networkmap=' . $networkmap['id'] .'">' .
'edit_networkmap=1&id_networkmap=' . $networkmap['id'] .'">' .
html_print_image("images/edit.png", true) . '</a>';
$data['delete'] = '<a href="index.php?' .