diff --git a/app/assets/javascripts/admin/controllers/admin-agree-flag.js.es6 b/app/assets/javascripts/admin/controllers/admin-agree-flag.js.es6
index 73e1238de..ac7fb9c63 100644
--- a/app/assets/javascripts/admin/controllers/admin-agree-flag.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-agree-flag.js.es6
@@ -2,37 +2,25 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality';
import ObjectController from 'discourse/controllers/object';
export default ObjectController.extend(ModalFunctionality, {
-
needs: ["adminFlags"],
+ _agreeFlag: function (actionOnPost) {
+ var adminFlagController = this.get("controllers.adminFlags");
+ var post = this.get("content");
+ var self = this;
+
+ return post.agreeFlags(actionOnPost).then(function () {
+ adminFlagController.removeObject(post);
+ self.send("closeModal");
+ }, function () {
+ bootbox.alert(I18n.t("admin.flags.error"));
+ });
+ },
+
actions: {
-
- agreeFlagHidePost: function () {
- var adminFlagController = this.get("controllers.adminFlags");
- var post = this.get("content");
- var self = this;
-
- return post.agreeFlags("hide").then(function () {
- adminFlagController.removeObject(post);
- self.send("closeModal");
- }, function () {
- bootbox.alert(I18n.t("admin.flags.error"));
- });
- },
-
- agreeFlagKeepPost: function () {
- var adminFlagController = this.get("controllers.adminFlags");
- var post = this.get("content");
- var self = this;
-
- return post.agreeFlags("keep").then(function () {
- adminFlagController.removeObject(post);
- self.send("closeModal");
- }, function () {
- bootbox.alert(I18n.t("admin.flags.error"));
- });
- }
-
+ agreeFlagHidePost: function () { return this._agreeFlag("hide"); },
+ agreeFlagKeepPost: function () { return this._agreeFlag("keep"); },
+ agreeFlagRestorePost: function () { return this._agreeFlag("restore"); }
}
});
diff --git a/app/assets/javascripts/admin/templates/modal/admin_agree_flag.js.handlebars b/app/assets/javascripts/admin/templates/modal/admin_agree_flag.js.handlebars
index 953155145..f06384a22 100644
--- a/app/assets/javascripts/admin/templates/modal/admin_agree_flag.js.handlebars
+++ b/app/assets/javascripts/admin/templates/modal/admin_agree_flag.js.handlebars
@@ -1,6 +1,10 @@
-{{#unless postHidden}}
-
-{{/unless}}
+{{#if user_deleted}}
+
+{{else}}
+ {{#unless postHidden}}
+
+ {{/unless}}
+{{/if}}
{{#if canDeleteAsSpammer}}
diff --git a/app/controllers/admin/flags_controller.rb b/app/controllers/admin/flags_controller.rb
index 976b070d8..1385f958d 100644
--- a/app/controllers/admin/flags_controller.rb
+++ b/app/controllers/admin/flags_controller.rb
@@ -26,11 +26,14 @@ class Admin::FlagsController < Admin::AdminController
keep_post = params[:action_on_post] == "keep"
delete_post = params[:action_on_post] == "delete"
+ restore_post = params[:action_on_post] == "restore"
PostAction.agree_flags!(post, current_user, delete_post)
if delete_post
PostDestroyer.new(current_user, post).destroy
+ elsif restore_post
+ PostDestroyer.new(current_user, post).recover
elsif !keep_post
PostAction.hide_post!(post, post_action_type)
end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 3d743eace..baaad0038 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1498,6 +1498,8 @@ en:
agree_flag_modal_title: "Agree and..."
agree_flag_hide_post: "Agree (hide post + send PM)"
agree_flag_hide_post_title: "Hide this post and automatically send the user a private message urging them to edit it"
+ agree_flag_restore_post: "Agree (restore post)"
+ agree_flag_restore_post_title: "Restore this post"
agree_flag: "Agree with flag"
agree_flag_title: "Agree with flag and keep the post unchanged"
defer_flag: "Defer"
diff --git a/lib/flag_query.rb b/lib/flag_query.rb
index d9f61e7fc..11c016eb2 100644
--- a/lib/flag_query.rb
+++ b/lib/flag_query.rb
@@ -26,6 +26,7 @@ module FlagQuery
p.post_number,
p.hidden,
p.deleted_at,
+ p.user_deleted,
(SELECT created_at FROM post_revisions WHERE post_id = p.id AND user_id = p.user_id ORDER BY created_at DESC LIMIT 1) AS last_revised_at,
(SELECT COUNT(*) FROM post_actions WHERE (disagreed_at IS NOT NULL OR agreed_at IS NOT NULL OR deferred_at IS NOT NULL) AND post_id = p.id)::int AS previous_flags_count
FROM posts p