New maps in progress...
This commit is contained in:
parent
d834146122
commit
a14521312b
|
@ -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;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -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,
|
||||
array ('name' => $name,
|
||||
'id_group' => $id_group,
|
||||
'description' => $description),
|
||||
'type' => $type);*/
|
||||
$result = false;
|
||||
if ($name == "") {
|
||||
$result = 0;
|
||||
}
|
||||
else {
|
||||
$result = maps_update_map ($id,
|
||||
array ('name' => $name,
|
||||
'id_group' => $id_group,
|
||||
'description' => $description),
|
||||
'type' => $type);
|
||||
}
|
||||
|
||||
$info = ' Name: ' . $name . ' Description: ' . $description . ' ID group: ' . $id_group . ' Type: ' . $type;
|
||||
|
||||
if ($id) {
|
||||
db_pandora_audit("Networkmap management", "Update networkmap #" . $id, false, false, $info);
|
||||
}
|
||||
else {
|
||||
db_pandora_audit("Networkmap management", "Fail to update networkmap #$id", false, false, $info);
|
||||
}
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
}
|
||||
else if ($add_networkmap) {
|
||||
|
||||
$info = ' Name: ' . $name . ' Description: ' . $description . ' ID group: ' . $id_group . ' Type: ' . $type;
|
||||
|
||||
if ($id) {
|
||||
db_pandora_audit("Networkmap management", "Update networkmap #" . $id, false, false, $info);
|
||||
}
|
||||
else {
|
||||
db_pandora_audit("Networkmap management", "Fail to update networkmap #$id", false, false, $info);
|
||||
}
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
|
||||
?>
|
||||
|
|
|
@ -66,24 +66,22 @@ $duplicate_networkmap = (bool)get_parameter('duplicate_networkmap', 0);
|
|||
|
||||
if ($delete_networkmap) {
|
||||
$result_delete = networkmap_delete_networkmap($id);
|
||||
|
||||
|
||||
if ($result_delete)
|
||||
db_pandora_audit( "Networkmap management",
|
||||
"Delete networkmap #$id");
|
||||
else
|
||||
db_pandora_audit( "Networkmap management",
|
||||
"Fail try to delete networkmap #$id");
|
||||
|
||||
|
||||
ui_print_result_message ($result_delete,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
}
|
||||
|
||||
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'),
|
||||
__('Could not be 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)) {
|
||||
|
@ -146,18 +143,18 @@ if (empty($networkmaps)) {
|
|||
else {
|
||||
foreach ($networkmaps as $networkmap) {
|
||||
$data = array();
|
||||
|
||||
|
||||
$data['name'] = $networkmap['name'];
|
||||
|
||||
|
||||
$data['name'] = '<a href="index.php?' .
|
||||
'sec=maps&' .
|
||||
'sec2=operation/maps/networkmap_editor&' .
|
||||
'id_networkmap=' . $networkmap['id'] .'">' .
|
||||
$networkmap['name'] . '</a>';
|
||||
|
||||
|
||||
$data['type'] = maps_get_subtype_string($networkmap['subtype']);
|
||||
|
||||
|
||||
|
||||
|
||||
if (enterprise_installed()) {
|
||||
if ($networkmap['generated']) {
|
||||
$data['nodes'] = maps_get_count_nodes($networkmap['id']);
|
||||
|
@ -166,7 +163,7 @@ else {
|
|||
$data['nodes'] = __('Pending to generate');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($networkmap['id_user'])) {
|
||||
$data['group'] = __('Private for (%s)', $networkmap['id_user']);
|
||||
}
|
||||
|
@ -174,26 +171,26 @@ else {
|
|||
$data['groups'] =
|
||||
ui_print_group_icon($networkmap['id_group'], true);
|
||||
}
|
||||
|
||||
|
||||
$data['copy'] = '<a href="index.php?' .
|
||||
'sec=maps&;' .
|
||||
'sec2=operation/maps/networkmap_list&' .
|
||||
'duplicate_networkmap=1&id_networkmap=' . $networkmap['id'] . '" alt="' . __('Copy') . '">' .
|
||||
html_print_image("images/copy.png", true) . '</a>';
|
||||
|
||||
|
||||
$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?' .
|
||||
'sec=maps&;' .
|
||||
'sec2=operation/maps/networkmap_list&' .
|
||||
'delete_networkmap=1&id_networkmap=' . $networkmap['id'] . '" alt="' . __('Delete') .
|
||||
'" onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' .
|
||||
html_print_image('images/cross.png', true) . '</a>';
|
||||
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
html_print_table($table);
|
||||
|
|
Loading…
Reference in New Issue