From 60df8a029dda0fa7f7672be08745951101d210e6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 1 Feb 2011 00:17:25 +0000 Subject: [PATCH] Added confirm for deleting a module --- root/includes/acp/acp_portal.php | 48 ++++++++++++++++------- root/language/de/mods/info_acp_portal.php | 1 + root/language/en/mods/info_acp_portal.php | 1 + 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/root/includes/acp/acp_portal.php b/root/includes/acp/acp_portal.php index a6cf77e4..b2ab5185 100644 --- a/root/includes/acp/acp_portal.php +++ b/root/includes/acp/acp_portal.php @@ -598,23 +598,41 @@ class acp_portal { trigger_error('CLASS_NOT_FOUND', E_USER_ERROR); } - - $c_class = new $class(); - $c_class->uninstall($module_data['module_id']); - - $sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE . ' - WHERE module_id = ' . $module_id; - $db->sql_query($sql); - - $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' - SET module_order = module_order - 1 - WHERE module_column = ' . $module_data['module_column'] . ' - AND module_order > ' . $module_data['module_order']; - $db->sql_query($sql); - $cache->purge(); // make sure we don't get errors after re-adding a module + if (confirm_box(true)) + { + $c_class = new $class(); + $c_class->uninstall($module_data['module_id']); - trigger_error($user->lang['SUCCESS_DELETE'] . adm_back_link($this->u_action)); + $sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE . ' + WHERE module_id = ' . $module_id; + $db->sql_query($sql); + + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_order = module_order - 1 + WHERE module_column = ' . $module_data['module_column'] . ' + AND module_order > ' . $module_data['module_order']; + $db->sql_query($sql); + + $cache->purge(); // make sure we don't get errors after re-adding a module + + trigger_error($user->lang['SUCCESS_DELETE'] . adm_back_link($this->u_action)); + } + else + { + $c_class = new $class(); + if ($c_class->language) + { + $user->add_lang('mods/portal/' . $c_class->language); + } + $confirm_text = (isset($user->lang[$module_data['module_name']])) ? sprintf($user->lang['DELETE_MODULE_CONFIRM'], $user->lang[$module_data['module_name']]) : sprintf($user->lang['DELETE_MODULE_CONFIRM'], utf8_normalize_nfc($module_data['module_name'])); + confirm_box(false, $confirm_text, build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + 'module_id' => $module_id, + ))); + } } } diff --git a/root/language/de/mods/info_acp_portal.php b/root/language/de/mods/info_acp_portal.php index 5c09c662..daf1c3f8 100644 --- a/root/language/de/mods/info_acp_portal.php +++ b/root/language/de/mods/info_acp_portal.php @@ -54,6 +54,7 @@ $lang = array_merge($lang, array( 'MOVE_LEFT' => 'Nach links', 'B3P_FILE_NOT_FOUND' => 'Die angegebene Datei konnte nicht gefunden werden', 'UNABLE_TO_MOVE' => 'Es ist nicht möglich den Block in die gewählte Spalte zu verschieben.', + 'DELETE_MODULE_CONFIRM' => 'Bist du sicher, dass du das Module "%1$s" löschen möchtest?', 'MODULE_OPTIONS' => 'Modul Optionen', 'MODULE_NAME' => 'Modul Name', diff --git a/root/language/en/mods/info_acp_portal.php b/root/language/en/mods/info_acp_portal.php index 155d3117..ec493397 100644 --- a/root/language/en/mods/info_acp_portal.php +++ b/root/language/en/mods/info_acp_portal.php @@ -53,6 +53,7 @@ $lang = array_merge($lang, array( 'MOVE_LEFT' => 'Move left', 'B3P_FILE_NOT_FOUND' => 'The requested file could not be found', 'UNABLE_TO_MOVE' => 'It is not possible to move the block to the selected column.', + 'DELETE_MODULE_CONFIRM' => 'Are you sure you wish to delete the module "%1$s"?', 'MODULE_OPTIONS' => 'Module options', 'MODULE_NAME' => 'Module name',