Shorten some bits and pieces.
Stop users from making blank profile comments. Normalise the forum edit URL ID error.
This commit is contained in:
parent
e9e527e76a
commit
7134dfdda5
@ -32,7 +32,7 @@ func ViewForum(w http.ResponseWriter, r *http.Request, user c.User, header *c.He
|
|||||||
page, _ := strconv.Atoi(r.FormValue("page"))
|
page, _ := strconv.Atoi(r.FormValue("page"))
|
||||||
_, fid, err := ParseSEOURL(sfid)
|
_, fid, err := ParseSEOURL(sfid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.PreError(phrases.GetErrorPhrase("url_id_must_be_integer"), w, r)
|
return c.SimpleError(phrases.GetErrorPhrase("url_id_must_be_integer"),w,r,header)
|
||||||
}
|
}
|
||||||
|
|
||||||
ferr := c.ForumUserCheck(header, w, r, &user, fid)
|
ferr := c.ForumUserCheck(header, w, r, &user, fid)
|
||||||
|
@ -165,12 +165,12 @@ func ForumsEdit(w http.ResponseWriter, r *http.Request, user c.User, sfid string
|
|||||||
if !user.Perms.ManageForums {
|
if !user.Perms.ManageForums {
|
||||||
return c.NoPermissions(w, r, user)
|
return c.NoPermissions(w, r, user)
|
||||||
}
|
}
|
||||||
basePage.Header.AddScriptAsync("panel_forum_edit.js")
|
|
||||||
|
|
||||||
fid, err := strconv.Atoi(sfid)
|
fid, err := strconv.Atoi(sfid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError("The provided Forum ID is not a valid number.", w, r, user)
|
return c.SimpleError(phrases.GetErrorPhrase("url_id_must_be_integer"),w,r,basePage.Header)
|
||||||
}
|
}
|
||||||
|
basePage.Header.AddScriptAsync("panel_forum_edit.js")
|
||||||
|
|
||||||
forum, err := c.Forums.Get(fid)
|
forum, err := c.Forums.Get(fid)
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
|
@ -64,7 +64,7 @@ func CreateReplySubmit(w http.ResponseWriter, r *http.Request, user c.User) c.Ro
|
|||||||
return c.NoPermissionsJSQ(w, r, user, js)
|
return c.NoPermissionsJSQ(w, r, user, js)
|
||||||
}
|
}
|
||||||
|
|
||||||
content := c.PreparseMessage(r.PostFormValue("reply-content"))
|
content := c.PreparseMessage(r.PostFormValue("content"))
|
||||||
// TODO: Fully parse the post and put that in the parsed column
|
// TODO: Fully parse the post and put that in the parsed column
|
||||||
rid, err := c.Rstore.Create(topic, content, user.LastIP, user.ID)
|
rid, err := c.Rstore.Create(topic, content, user.LastIP, user.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -86,8 +86,8 @@ func CreateReplySubmit(w http.ResponseWriter, r *http.Request, user c.User) c.Ro
|
|||||||
}
|
}
|
||||||
|
|
||||||
if r.PostFormValue("has_poll") == "1" {
|
if r.PostFormValue("has_poll") == "1" {
|
||||||
var maxPollOptions = 10
|
maxPollOptions := 10
|
||||||
var pollInputItems = make(map[int]string)
|
pollInputItems := make(map[int]string)
|
||||||
for key, values := range r.Form {
|
for key, values := range r.Form {
|
||||||
//c.DebugDetail("key: ", key)
|
//c.DebugDetail("key: ", key)
|
||||||
//c.DebugDetailf("values: %+v\n", values)
|
//c.DebugDetailf("values: %+v\n", values)
|
||||||
@ -466,7 +466,6 @@ func ProfileReplyCreateSubmit(w http.ResponseWriter, r *http.Request, user c.Use
|
|||||||
if !user.Perms.ViewTopic || !user.Perms.CreateReply {
|
if !user.Perms.ViewTopic || !user.Perms.CreateReply {
|
||||||
return c.NoPermissions(w, r, user)
|
return c.NoPermissions(w, r, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
uid, err := strconv.Atoi(r.PostFormValue("uid"))
|
uid, err := strconv.Atoi(r.PostFormValue("uid"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError("Invalid UID", w, r, user)
|
return c.LocalError("Invalid UID", w, r, user)
|
||||||
@ -479,7 +478,10 @@ func ProfileReplyCreateSubmit(w http.ResponseWriter, r *http.Request, user c.Use
|
|||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
content := c.PreparseMessage(r.PostFormValue("reply-content"))
|
content := c.PreparseMessage(r.PostFormValue("content"))
|
||||||
|
if len(content) == 0 {
|
||||||
|
return c.LocalError("You can't make a blank post", w, r, user)
|
||||||
|
}
|
||||||
// TODO: Fully parse the post and store it in the parsed column
|
// TODO: Fully parse the post and store it in the parsed column
|
||||||
_, err = c.Prstore.Create(profileOwner.ID, content, user.ID, user.LastIP)
|
_, err = c.Prstore.Create(profileOwner.ID, content, user.ID, user.LastIP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -500,7 +502,6 @@ func ProfileReplyCreateSubmit(w http.ResponseWriter, r *http.Request, user c.Use
|
|||||||
|
|
||||||
func ProfileReplyEditSubmit(w http.ResponseWriter, r *http.Request, user c.User, srid string) c.RouteError {
|
func ProfileReplyEditSubmit(w http.ResponseWriter, r *http.Request, user c.User, srid string) c.RouteError {
|
||||||
isJs := (r.PostFormValue("js") == "1")
|
isJs := (r.PostFormValue("js") == "1")
|
||||||
|
|
||||||
rid, err := strconv.Atoi(srid)
|
rid, err := strconv.Atoi(srid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalErrorJSQ("The provided Reply ID is not a valid number.", w, r, user, isJs)
|
return c.LocalErrorJSQ("The provided Reply ID is not a valid number.", w, r, user, isJs)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
{{template "header.html" . }}
|
{{template "header.html" . }}
|
||||||
|
|
||||||
<div id="profile_container" class="colstack">
|
<div id="profile_container" class="colstack">
|
||||||
|
|
||||||
<div id="profile_left_lane" class="colstack_left">
|
<div id="profile_left_lane" class="colstack_left">
|
||||||
@ -18,7 +17,7 @@
|
|||||||
<div class="levelBit">
|
<div class="levelBit">
|
||||||
<a>{{level .ProfileOwner.Level}}</a>
|
<a>{{level .ProfileOwner.Level}}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="progressWrap"{{if ne .CurrentScore 0}} style="width: 40%"{{end}}>
|
<div class="progressWrap"{{if ne .CurrentScore 0}} style="width:40%"{{end}}>
|
||||||
<div>{{.CurrentScore}} / {{.NextScore}}</div>
|
<div>{{.CurrentScore}} / {{.NextScore}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -28,6 +27,9 @@
|
|||||||
{{if not .CurrentUser.Loggedin}}<div class="rowitem passive">
|
{{if not .CurrentUser.Loggedin}}<div class="rowitem passive">
|
||||||
<a class="profile_menu_item">{{lang "profile_login_for_options"}}</a>
|
<a class="profile_menu_item">{{lang "profile_login_for_options"}}</a>
|
||||||
</div>{{else}}
|
</div>{{else}}
|
||||||
|
<!--<div class="rowitem passive">
|
||||||
|
<a href="/user/convos/create/" class="profile_menu_item">{{lang "profile_send_message"}}</a>
|
||||||
|
</div>-->
|
||||||
<!--<div class="rowitem passive">
|
<!--<div class="rowitem passive">
|
||||||
<a class="profile_menu_item">{{lang "profile_add_friend"}}</a>
|
<a class="profile_menu_item">{{lang "profile_add_friend"}}</a>
|
||||||
</div>-->
|
</div>-->
|
||||||
@ -95,9 +97,9 @@
|
|||||||
{{if not .CurrentUser.IsBanned}}
|
{{if not .CurrentUser.IsBanned}}
|
||||||
<form id="profile_comments_form" class="hash_hide" action="/profile/reply/create/?session={{.CurrentUser.Session}}" method="post">
|
<form id="profile_comments_form" class="hash_hide" action="/profile/reply/create/?session={{.CurrentUser.Session}}" method="post">
|
||||||
<input name="uid" value='{{.ProfileOwner.ID}}' type="hidden" />
|
<input name="uid" value='{{.ProfileOwner.ID}}' type="hidden" />
|
||||||
<div class="colstack_item topic_reply_form" style="border-top: none;">
|
<div class="colstack_item topic_reply_form" style="border-top:none;">
|
||||||
<div class="formrow">
|
<div class="formrow">
|
||||||
<div class="formitem"><textarea class="input_content" name="reply-content" placeholder="{{lang "profile_comments_form_content"}}"></textarea></div>
|
<div class="formitem"><textarea class="input_content" name="content" placeholder="{{lang "profile_comments_form_content"}}"></textarea></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="formrow quick_button_row">
|
<div class="formrow quick_button_row">
|
||||||
<div class="formitem"><button name="reply-button" class="formbutton">{{lang "profile_comments_form_button"}}</button></div>
|
<div class="formitem"><button name="reply-button" class="formbutton">{{lang "profile_comments_form_button"}}</button></div>
|
||||||
@ -106,12 +108,11 @@
|
|||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="colstack_item" style="border-top: none;">
|
<div class="colstack_item" style="border-top:none;">
|
||||||
<div class="rowitem passive">{{lang "profile_comments_form_guest"}}</div>
|
<div class="rowitem passive">{{lang "profile_comments_form_guest"}}</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{template "footer.html" . }}
|
{{template "footer.html" . }}
|
@ -74,10 +74,10 @@
|
|||||||
<div class="rowblock topic_reply_form quick_create_form" aria-label="{{lang "topic.reply_aria"}}">
|
<div class="rowblock topic_reply_form quick_create_form" aria-label="{{lang "topic.reply_aria"}}">
|
||||||
<form id="quick_post_form" enctype="multipart/form-data" action="/reply/create/?s={{.CurrentUser.Session}}" method="post"></form>
|
<form id="quick_post_form" enctype="multipart/form-data" action="/reply/create/?s={{.CurrentUser.Session}}" method="post"></form>
|
||||||
<input form="quick_post_form" name="tid" value='{{.Topic.ID}}' type="hidden" />
|
<input form="quick_post_form" name="tid" value='{{.Topic.ID}}' type="hidden" />
|
||||||
<input form="quick_post_form" id="has_poll_input" name="has_poll" value="0" type="hidden" />
|
<input form="quick_post_form" id="has_poll_input" name="has_poll" value=0 type="hidden" />
|
||||||
<div class="formrow real_first_child">
|
<div class="formrow real_first_child">
|
||||||
<div class="formitem">
|
<div class="formitem">
|
||||||
<textarea id="input_content" form="quick_post_form" name="reply-content" placeholder="{{lang "topic.reply_content"}}" required></textarea>
|
<textarea id="input_content" form="quick_post_form" name="content" placeholder="{{lang "topic.reply_content"}}" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="formrow poll_content_row auto_hide">
|
<div class="formrow poll_content_row auto_hide">
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<input form="quick_post_form" id="has_poll_input" name="has_poll" value=0 type="hidden" />
|
<input form="quick_post_form" id="has_poll_input" name="has_poll" value=0 type="hidden" />
|
||||||
<div class="formrow real_first_child">
|
<div class="formrow real_first_child">
|
||||||
<div class="formitem">
|
<div class="formitem">
|
||||||
<textarea id="input_content" form="quick_post_form" name="reply-content" placeholder="{{lang "topic.reply_content_alt"}}" required></textarea>
|
<textarea id="input_content" form="quick_post_form" name="content" placeholder="{{lang "topic.reply_content_alt"}}" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="formrow poll_content_row auto_hide">
|
<div class="formrow poll_content_row auto_hide">
|
||||||
|
Loading…
Reference in New Issue
Block a user