From 757685ead6ad684a376db1e03d863686d743d295 Mon Sep 17 00:00:00 2001 From: jsatoh Date: Tue, 2 Apr 2013 06:29:38 +0000 Subject: [PATCH] 2013-04-02 Junichi Satoh * extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql, godmode/alerts/alert_special_days.php, godmode/alerts/configure_alert_special_days.php: Added group ACL to 'Special days list'. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7908 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 +++++++ .../pandoradb_migrate_4.0.x_to_5.0.mysql.sql | 1 + .../pandoradb_migrate_4.0.x_to_5.0.oracle.sql | 1 + ...doradb_migrate_4.0.x_to_5.0.postgreSQL.sql | 1 + .../godmode/alerts/alert_special_days.php | 29 +++++++++++++------ .../alerts/configure_alert_special_days.php | 25 +++++++++++----- pandora_console/pandoradb.oracle.sql | 1 + pandora_console/pandoradb.postgreSQL.sql | 1 + pandora_console/pandoradb.sql | 1 + 9 files changed, 53 insertions(+), 17 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 6d3d16df51..2315525122 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2013-04-02 Junichi Satoh + + * extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, + pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql, + godmode/alerts/alert_special_days.php, + godmode/alerts/configure_alert_special_days.php: Added group ACL to + 'Special days list'. + 2013-04-01 Miguel de Dios * mobile/operation/events.php, mobile/include/ui.class.php, diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql index 32b8480a47..6e7761141f 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql @@ -73,6 +73,7 @@ ALTER TABLE `tagente` ADD COLUMN `update_alert_count` tinyint(1) NOT NULL DEFAUL -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_special_days` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_group` INT(10) NOT NULL DEFAULT 0, `date` date NOT NULL DEFAULT '0000-00-00', `same_day` enum('monday','tuesday','wednesday','thursday','friday','saturday','sunday') NOT NULL DEFAULT 'sunday', `description` text, diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql index 5b3a09c7ab..1a458a6bcd 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql @@ -94,6 +94,7 @@ ALTER TABLE tagente ADD (update_alert_count NUMBER(5, 0) default 0 NOT NULL); -- ----------------------------------------------------- CREATE TABLE talert_special_days ( id NUMBER(10,0) NOT NULL PRIMARY KEY, + id_group NUMBER(10, 0) default 0 NOT NULL, date DATE default '0000-00-00' NOT NULL, same_day VARCHAR2(20) default 'sunday', description CLOB, diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql index d5406184df..122339b183 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql @@ -90,6 +90,7 @@ ALTER TABLE "tagente" ADD COLUMN "update_alert_count" SMALLINT NOT NULL default CREATE TYPE type_talert_special_days_same_day AS ENUM ('monday','tuesday','wednesday','thursday','friday','saturday','sunday'); CREATE TABLE "talert_special_days" ( "id" SERIAL NOT NULL PRIMARY KEY, + "id_group" INTEGER NOT NULL default 0, "date" DATE NOT NULL default '0001-01-01', "same_day" type_talert_special_days_same_day NOT NULL default 'sunday', "description" TEXT diff --git a/pandora_console/godmode/alerts/alert_special_days.php b/pandora_console/godmode/alerts/alert_special_days.php index 8282085870..78803eb594 100644 --- a/pandora_console/godmode/alerts/alert_special_days.php +++ b/pandora_console/godmode/alerts/alert_special_days.php @@ -3,7 +3,7 @@ // Pandora FMS - http://pandorafms.com // ================================================== // Copyright (c) 2005-2010 Artica Soluciones Tecnologicas -// Copyright (c) 2012 Junichi Satoh +// Copyright (c) 2012-2013 Junichi Satoh // Please see http://pandorafms.org for full contribution list // This program is free software; you can redistribute it and/or @@ -49,7 +49,9 @@ $delete_special_day = (bool) get_parameter ('delete_special_day'); if ($create_special_day) { $date = (string) get_parameter ('date'); $same_day = (string) get_parameter ('same_day'); - $description = (string) get_parameter ('description'); + $values = array(); + $values['id_group'] = (string) get_parameter ('id_group'); + $values['description'] = (string) get_parameter ('description'); list($year, $month, $day) = explode("-", $date); if ($year == '*') { @@ -68,8 +70,8 @@ if ($create_special_day) { $result = ''; } else { - $result = alerts_create_alert_special_day ($date, $same_day, array ('description' => $description)); - $info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $description; + $result = alerts_create_alert_special_day ($date, $same_day, $values); + $info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $values['description']; } } @@ -91,6 +93,7 @@ if ($update_special_day) { $date = (string) get_parameter ('date'); $same_day = (string) get_parameter ('same_day'); $description = (string) get_parameter ('description'); + $id_group = (string) get_parameter ('id_group'); list($year, $month, $day) = explode("-", $date); if ($year == '*') { @@ -101,6 +104,7 @@ if ($update_special_day) { $values = array (); $values['date'] = $date; + $values['id_group'] = $id_group; $values['same_day'] = $same_day; $values['description'] = $description; @@ -147,18 +151,25 @@ $table->head = array (); $table->head[0] = __('Date'); $table->head[1] = __('Same day of the week'); $table->head[2] = __('Description'); -$table->head[3] = __('Delete'); +$table->head[3] = __('Group'); +$table->head[4] = __('Delete'); $table->style = array (); $table->style[0] = 'font-weight: bold'; $table->size = array (); $table->size[0] = '20%'; $table->size[1] = '15%'; -$table->size[2] = '60%'; +$table->size[2] = '55%'; $table->size[3] = '5%'; +$table->size[4] = '5%'; $table->align = array (); $table->align[3] = 'center'; +$table->align[4] = 'center'; -$special_days = db_get_all_rows_in_table ('talert_special_days', 'date'); +$filter = array(); +if (!is_user_admin($config['id_user'])) + $filter['id_group'] = array_keys(users_get_groups(false, "LM")); + +$special_days = db_get_all_rows_filter ('talert_special_days', $filter); if ($special_days === false) $special_days = array (); @@ -194,8 +205,8 @@ foreach ($special_days as $special_day) { break; } $data[2] = $special_day['description']; - $data[3] = ''; - $data[3] = ''. html_print_image("images/cross.png", true) . ''; diff --git a/pandora_console/godmode/alerts/configure_alert_special_days.php b/pandora_console/godmode/alerts/configure_alert_special_days.php index 02e2a85aa4..f0ff05672f 100644 --- a/pandora_console/godmode/alerts/configure_alert_special_days.php +++ b/pandora_console/godmode/alerts/configure_alert_special_days.php @@ -3,7 +3,7 @@ // Pandora FMS - http://pandorafms.com // ================================================== // Copyright (c) 2005-2010 Artica Soluciones Tecnologicas -// Copyright (c) 2012 Junichi Satoh +// Copyright (c) 2012-2013 Junichi Satoh // Please see http://pandorafms.org for full contribution list // This program is free software; you can redistribute it and/or @@ -36,6 +36,7 @@ $command = ''; $description = ''; $date = ''; $same_day = ''; +$id_group = 0; if ($id) { $special_day = alerts_get_alert_special_day ($id); $date = str_replace('0001', '*', $special_day['date']); @@ -59,7 +60,17 @@ $table->data = array (); $table->data[0][0] = __('Date'); $table->data[0][1] = html_print_input_text ('date', $date, '', 10, 10, true); $table->data[0][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-date'),this);")); -$table->data[1][0] = __('Same day of the week'); +$table->data[1][0] = __('Group'); +$groups = users_get_groups (); +$own_info = get_user_info ($config['id_user']); +// Only display group "All" if user is administrator or has "PM" privileges +if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) + $display_all_group = true; +else + $display_all_group = false; +$table->data[1][1] = html_print_select_groups(false, "LW", $display_all_group, 'id_group', $id_group, '', '', 0, true); + +$table->data[2][0] = __('Same day of the week'); $days = array (); $days["monday"] = __('Monday'); $days["tuesday"] = __('Tuesday'); @@ -68,12 +79,10 @@ $days["thursday"] = __('Thursday'); $days["friday"] = __('Friday'); $days["saturday"] = __('Saturday'); $days["sunday"] = __('Sunday'); -$table->data[1][1] = html_print_select ($days, "same_day", $same_day, '', '', 0, true, false, false); +$table->data[2][1] = html_print_select ($days, "same_day", $same_day, '', '', 0, true, false, false); -#$table->data[1][1] = html_print_input_text ('same_day', $same_day, '', 80, 255, true); - -$table->data[2][0] = __('Description'); -$table->data[2][1] = html_print_textarea ('description', 10, 30, $description, '', true); +$table->data[3][0] = __('Description'); +$table->data[3][1] = html_print_textarea ('description', 10, 30, $description, '', true); echo '
'; html_print_table ($table); @@ -90,4 +99,4 @@ else { } echo ''; echo '
'; -?> \ No newline at end of file +?> diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index 880f94557f..779a31c31c 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -453,6 +453,7 @@ CREATE OR REPLACE TRIGGER talert_template_mod_ac_update1 AFTER UPDATE OF ID ON t CREATE TABLE talert_special_days ( id NUMBER(10,0) NOT NULL PRIMARY KEY, + id_group NUMBER(10, 0) default 0 NOT NULL, date DATE default '0000-00-00' NOT NULL, same_day VARCHAR2(20) default 'sunday', description CLOB, diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index fc84667311..ed2f99a720 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -392,6 +392,7 @@ CREATE TABLE "talert_template_module_actions" ( CREATE TYPE type_talert_special_days_same_day AS ENUM ('monday','tuesday','wednesday','thursday','friday','saturday','sunday'); CREATE TABLE "talert_special_days" ( "id" SERIAL NOT NULL PRIMARY KEY, + "id_group" INTEGER NOT NULL default 0, "date" DATE NOT NULL default '0001-01-01', "same_day" type_talert_special_days_same_day NOT NULL default 'sunday', "description" TEXT diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f72f0cb6a2..4f7c1b644a 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -436,6 +436,7 @@ CREATE TABLE IF NOT EXISTS `talert_template_module_actions` ( -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_special_days` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_group` INT(10) NOT NULL DEFAULT 0, `date` date NOT NULL DEFAULT '0000-00-00', `same_day` enum('monday','tuesday','wednesday','thursday','friday','saturday','sunday') NOT NULL DEFAULT 'sunday', `description` text,