diff --git a/common/extend.go b/common/extend.go index ce0b0d35..52995712 100644 --- a/common/extend.go +++ b/common/extend.go @@ -83,10 +83,12 @@ var hookTable = &HookTable{ "simple_forum_check_pre_perms": nil, "forum_check_pre_perms": nil, - "action_end_create_topic": nil, - "action_end_create_reply": nil, - "action_end_edit_reply": nil, - "action_end_delete_reply": nil, + "action_end_create_topic": nil, + "action_end_create_reply": nil, + "action_end_edit_reply": nil, + "action_end_delete_reply": nil, + "action_end_add_attach_to_reply": nil, + "action_end_remove_attach_from_reply": nil, "router_after_filters": nil, "router_pre_route": nil, diff --git a/public/global.js b/public/global.js index 608dcdb5..505b69d7 100644 --- a/public/global.js +++ b/public/global.js @@ -1076,9 +1076,7 @@ function mainInit(){ $("#mod_topic_mover .pane_row").click(function(){ modTopicMover.find(".pane_row").removeClass("pane_selected"); let fid = this.getAttribute("data-fid"); - if (fid == null) { - return; - } + if (fid == null) return; this.classList.add("pane_selected"); console.log("fid: " + fid); forumToMoveTo = fid; diff --git a/routes/reply.go b/routes/reply.go index 2c3e99ca..009fc596 100644 --- a/routes/reply.go +++ b/routes/reply.go @@ -368,7 +368,7 @@ func AddAttachToReplySubmit(w http.ResponseWriter, r *http.Request, user common. return common.NotFoundJS(w, r) } - _, ferr := common.SimpleForumUserCheck(w, r, &user, topic.ParentID) + lite, ferr := common.SimpleForumUserCheck(w, r, &user, topic.ParentID) if ferr != nil { return ferr } @@ -389,6 +389,11 @@ func AddAttachToReplySubmit(w http.ResponseWriter, r *http.Request, user common. return common.InternalErrorJS(errors.New("no paths for attachment add"), w, r) } + skip, rerr := lite.Hooks.VhookSkippable("action_end_add_attach_to_reply", reply.ID) + if skip || rerr != nil { + return rerr + } + var elemStr string for path, aids := range pathMap { elemStr += "\"" + path + "\":\"" + aids + "\"," @@ -420,7 +425,7 @@ func RemoveAttachFromReplySubmit(w http.ResponseWriter, r *http.Request, user co return common.NotFoundJS(w, r) } - _, ferr := common.SimpleForumUserCheck(w, r, &user, topic.ParentID) + lite, ferr := common.SimpleForumUserCheck(w, r, &user, topic.ParentID) if ferr != nil { return ferr } @@ -443,6 +448,11 @@ func RemoveAttachFromReplySubmit(w http.ResponseWriter, r *http.Request, user co } } + skip, rerr := lite.Hooks.VhookSkippable("action_end_remove_attach_from_reply", reply.ID) + if skip || rerr != nil { + return rerr + } + w.Write(successJSONBytes) return nil } diff --git a/templates/topic_alt.html b/templates/topic_alt.html index cc613434..d4158194 100644 --- a/templates/topic_alt.html +++ b/templates/topic_alt.html @@ -68,7 +68,7 @@ {{if .CurrentUser.Loggedin}} {{if .CurrentUser.Perms.EditTopic}} - {{if .Topic.Attachments}}