mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-09-11 11:46:24 -07:00
Add action to delete wordfilter
This commit is contained in:
parent
20fce2ab88
commit
ee0910da78
3 changed files with 25 additions and 7 deletions
|
@ -654,6 +654,23 @@ var actions = []Action{
|
|||
Callback: func(writer http.ResponseWriter, request *http.Request, wantsJSON bool) (output interface{}, err error) {
|
||||
managePageBuffer := bytes.NewBufferString("")
|
||||
editIDstr := request.FormValue("edit")
|
||||
deleteIDstr := request.FormValue("delete")
|
||||
var staff *gcsql.Staff
|
||||
if staff, err = getCurrentFullStaff(request); err != nil {
|
||||
return err, err
|
||||
}
|
||||
if deleteIDstr != "" {
|
||||
var result sql.Result
|
||||
if result, err = gcsql.ExecSQL(`DELETE FROM DBPREFIXwordfilters WHERE id = ?`, deleteIDstr); err != nil {
|
||||
return err, err
|
||||
}
|
||||
if numRows, _ := result.RowsAffected(); numRows < 1 {
|
||||
err = invalidWordfilterID(deleteIDstr)
|
||||
gclog.Println(gclog.LErrorLog|gclog.LStaffLog, err.Error())
|
||||
return err, err
|
||||
}
|
||||
gclog.Printf(gclog.LStaffLog, "%s deleted wordfilter with id #%s", staff.Username, deleteIDstr)
|
||||
}
|
||||
|
||||
submitBtn := request.FormValue("dowordfilter")
|
||||
switch submitBtn {
|
||||
|
@ -678,10 +695,6 @@ var actions = []Action{
|
|||
request.FormValue("replace"),
|
||||
editIDstr)
|
||||
case "Create new wordfilter":
|
||||
staff, err2 := getCurrentFullStaff(request)
|
||||
if err2 != nil {
|
||||
return err2, err2
|
||||
}
|
||||
_, err = gcsql.CreateWordFilter(
|
||||
request.FormValue("find"),
|
||||
request.FormValue("replace"),
|
||||
|
|
|
@ -2,6 +2,7 @@ package manage
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -190,3 +191,7 @@ func boardsRequestType(request *http.Request) (string, int, error) {
|
|||
}
|
||||
return requestType, boardID, err
|
||||
}
|
||||
|
||||
func invalidWordfilterID(id interface{}) error {
|
||||
return fmt.Errorf("wordfilter with id %q does not exist", id)
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
<hr/>
|
||||
<h2>Wordfilters</h2>
|
||||
<table width="100%" border="1">
|
||||
<colgroup><col width="5%"><col width="10%"><col width="10%"><col width="5%"><col width="15%"><col width="10%"></colgroup>
|
||||
<tr><th></th><th>Search</th><th>Replace with</th><th>Is regex</th><th>Dirs</th><th>Created by</th><th>Staff note</th></tr>
|
||||
<colgroup><col width="10%"><col width="10%"><col width="10%"><col width="5%"><col width="15%"><col width="10%"></colgroup>
|
||||
<tr><th>Actions</th><th>Search</th><th>Replace with</th><th>Is regex</th><th>Dirs</th><th>Created by</th><th>Staff note</th></tr>
|
||||
{{- range $f,$filter := .wordfilters}}
|
||||
<tr>
|
||||
<td><a href="{{$.webroot}}manage?action=wordfilters&edit={{$filter.ID}}">Edit</a></td>
|
||||
<td><a href="{{$.webroot}}manage?action=wordfilters&edit={{$filter.ID}}">Edit</a> | <a href="{{$.webroot}}manage?action=wordfilters&delete={{$filter.ID}}" onclick="return confirm('Are you sure you want to delete this wordfilter?')">Delete</a> </td>
|
||||
<td>{{$filter.Search}}</td>
|
||||
<td>{{$filter.ChangeTo}}</td>
|
||||
<td>{{if $filter.IsRegex}}yes{{else}}no{{end}}</td>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue