diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f7220e4a43..eb23ce7fba 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2012-01-03 Sergio Martin + + * include/functions_users.php + include/auth/mysql.php + pandoradb.sql + pandoradb.postgreSQL.sql + pandoradb.oracle.sql + extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql + extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql + extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql + godmode/users/user_list.php: Added to users the + disable/enable feature + 2012-01-03 Juan Manuel Ramon * pandoradb.data.postgreSQL.sql diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql index 99139007f3..340756c0ed 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql @@ -60,3 +60,9 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report_content` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +-- ----------------------------------------------------- +-- Table `tusuario` +-- ----------------------------------------------------- + +ALTER TABLE `tusuario` ADD COLUMN `disabled` int(4) NOT NULL DEFAULT 0; + diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql new file mode 100644 index 0000000000..cb742037a2 --- /dev/null +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql @@ -0,0 +1,5 @@ +-- ----------------------------------------------------- +-- Table `tusuario` +-- ----------------------------------------------------- + +alter table tusuario add (disabled NUMBER(10,0) default 0 NOT NULL); diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql new file mode 100644 index 0000000000..1151d73575 --- /dev/null +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql @@ -0,0 +1,5 @@ +-- ----------------------------------------------------- +-- Table `tusuario` +-- ----------------------------------------------------- + +ALTER TABLE "tusuario" ADD COLUMN "disabled" INTEGER NOT NULL DEFAULT 0; diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index e3b082a573..c08d321248 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -105,6 +105,8 @@ $buttons[$tab]['active'] = true; // Header ui_print_page_header (__('User management').' » '.__('Users defined in Pandora'), "images/god3.png", false, "", true, $buttons); +$disable_user = get_parameter ("disable_user", false); + if (isset ($_GET["user_del"])) { //delete user $id_user = get_parameter ("delete_user", 0); // Only allow delete user if is not the actual user @@ -129,6 +131,27 @@ elseif (isset ($_GET["profile_del"])) { //delete profile __('Successfully deleted'), __('There was a problem deleting the profile')); } +elseif ($disable_user !== false) { //disable_user + $id_user = get_parameter ("id", 0); + + if($id_user !== 0) { + $result = users_disable ($id_user, $disable_user); + } + else { + $result = false; + } + + if($disable_user == 1) { + ui_print_result_message ($result, + __('Successfully disabled'), + __('There was a problem disabling user')); + } + else { + ui_print_result_message ($result, + __('Successfully enabled'), + __('There was a problem enabling user')); + } +} $table->cellpadding = 4; $table->cellspacing = 4; @@ -155,7 +178,7 @@ $table->head[5] = '' . __('Op.') . ''; $table->align[2] = "center"; $table->align[3] = "center"; $table->align[5] = "left"; -$table->size[5] = '45px'; +$table->size[5] = '65px'; $info1 = array (); @@ -227,8 +250,14 @@ foreach ($info as $user_id => $user_info) { $data[3] .= ""; $data[4] = ui_print_string_substr ($user_info["comments"], 24, true); - - $data[5] = ''.html_print_image('images/config.png', true, array('title' => __('Edit'))).''; + + if($user_info['disabled'] == 0) { + $data[5] = ''.html_print_image('images/lightbulb.png', true, array('title' => __('Disable'))).''; + } + else { + $data[5] = ''.html_print_image('images/lightbulb_off.png', true, array('title' => __('Enable'))).''; + } + $data[5] .= ''.html_print_image('images/config.png', true, array('title' => __('Edit'))).''; if ($config["admin_can_delete_user"] && $user_info['id_user'] != $config['id_user']) { $data[5] .= "  ".html_print_image('images/cross.png', true, array ('title' => __('Delete'), 'onclick' => "if (! confirm ('" .__('Deleting User'). " ". $user_info['id_user'] . ". " . __('Are you sure?') ."')) return false")).""; } else { diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index fedbeb6019..023b4f223e 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -80,13 +80,13 @@ function process_user_login ($login, $pass) { // Connect to Database switch ($config["dbtype"]) { case "mysql": - $sql = sprintf ("SELECT `id_user`, `password` FROM `tusuario` WHERE `id_user` = '%s'", $login); + $sql = sprintf ("SELECT `id_user`, `password` FROM `tusuario` WHERE `id_user` = '%s' AND `disabled` = 0", $login); break; case "postgresql": - $sql = sprintf ('SELECT "id_user", "password" FROM "tusuario" WHERE "id_user" = \'%s\'', $login); + $sql = sprintf ('SELECT "id_user", "password" FROM "tusuario" WHERE "id_user" = \'%s\' AND "disabled" = 0', $login); break; case "oracle": - $sql = sprintf ('SELECT id_user, password FROM tusuario WHERE id_user = \'%s\'', $login); + $sql = sprintf ('SELECT id_user, password FROM tusuario WHERE id_user = \'%s\' AND disabled = 0', $login); break; } $row = db_get_row_sql ($sql); diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index 02c0061f4d..9bba4d31c8 100644 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -38,6 +38,18 @@ function users_get_info ($order = "fullname", $info = "fullname") { return $ret; } +/** + * Enable/Disable a user + * + * @param int user id + * @param int new disabled value (0 when enable, 1 when disable) + * + * @return int sucess return + */ +function users_disable ($user_id, $new_disabled_value) { + return db_process_sql_update('tusuario', array('disabled' => $new_disabled_value), array('id_user' => $user_id)); +} + /** * Get all the Model groups a user has reading privileges. * diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index f59364dadc..9c9ba2cc76 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -840,7 +840,8 @@ CREATE TABLE tusuario ( timezone VARCHAR2(50) default '', block_size NUMBER(10, 0) default 20 NOT NULL, flash_chart NUMBER(10, 0) default 1 NOT NULL, - id_skin NUMBER(10, 0) DEFAULT 0 NOT NULL + id_skin NUMBER(10, 0) DEFAULT 0 NOT NULL, + disabled NUMBER(10, 0) default 0 NOT NULL ); CREATE TABLE tusuario_perfil ( diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index 512467a760..aa7dac206c 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -674,7 +674,8 @@ CREATE TABLE "tusuario" ( "timezone" varchar(50) default '', "block_size" INTEGER NOT NULL default 20, "flash_chart" INTEGER NOT NULL default 1, - "id_skin" INTEGER NOT NULL DEFAULT 0 + "id_skin" INTEGER NOT NULL DEFAULT 0, + "disabled" INTEGER NOT NULL default 1 ); CREATE TABLE "tusuario_perfil" ( diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f40147f234..96e79fe3a1 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -750,6 +750,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` ( `block_size` int(4) NOT NULL DEFAULT 20, `flash_chart` int(4) NOT NULL DEFAULT 1, `id_skin` int(10) unsigned NOT NULL, + `disabled` int(4) NOT NULL DEFAULT 0, UNIQUE KEY `id_user` (`id_user`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;