diff --git a/common/parser.go b/common/parser.go index 40e47b7a..896b2401 100644 --- a/common/parser.go +++ b/common/parser.go @@ -610,14 +610,14 @@ func ParseMessage(msg string, sectionID int, sectionType string /*, user User*/) // TODO: Reduce the amount of code duplication if media.Type == "attach" { - addImage(media.URL + "?sectionID=" + strconv.Itoa(sectionID) + "§ionType=" + sectionType) + addImage(media.URL + "?sid=" + strconv.Itoa(sectionID) + "&stype=" + sectionType) continue } else if media.Type == "image" { addImage(media.URL) continue } else if media.Type == "aother" { sb.Write(attachOpen) - sb.WriteString(media.URL + "?sectionID=" + strconv.Itoa(sectionID) + "§ionType=" + sectionType) + sb.WriteString(media.URL + "?sid=" + strconv.Itoa(sectionID) + "&stype=" + sectionType) sb.Write(attachClose) i += urlLen lastItem = i diff --git a/common/topic_store.go b/common/topic_store.go index 5d2301cc..0c7e5079 100644 --- a/common/topic_store.go +++ b/common/topic_store.go @@ -137,9 +137,9 @@ func (s *DefaultTopicStore) BulkGetMap(ids []int) (list map[int]*Topic, err erro // TODO: Add a function for the qlist stuff var qlist string - var idList []interface{} - for _, id := range ids { - idList = append(idList, strconv.Itoa(id)) + idList := make([]interface{},len(ids)) + for i, id := range ids { + idList[i] = strconv.Itoa(id) qlist += "?," } qlist = qlist[0 : len(qlist)-1] diff --git a/common/user_store.go b/common/user_store.go index 7a15620e..d2eb9ade 100644 --- a/common/user_store.go +++ b/common/user_store.go @@ -141,7 +141,7 @@ func (store *DefaultUserStore) GetOffset(offset int, perPage int) (users []*User // TODO: Optimise the query to avoid preparing it on the spot? Maybe, use knowledge of the most common IN() parameter counts? // TODO: ID of 0 should always error? -func (mus *DefaultUserStore) BulkGetMap(ids []int) (list map[int]*User, err error) { +func (s *DefaultUserStore) BulkGetMap(ids []int) (list map[int]*User, err error) { var idCount = len(ids) list = make(map[int]*User) if idCount == 0 { @@ -149,7 +149,7 @@ func (mus *DefaultUserStore) BulkGetMap(ids []int) (list map[int]*User, err erro } var stillHere []int - sliceList := mus.cache.BulkGet(ids) + sliceList := s.cache.BulkGet(ids) if len(sliceList) > 0 { for i, sliceItem := range sliceList { if sliceItem != nil { @@ -165,19 +165,19 @@ func (mus *DefaultUserStore) BulkGetMap(ids []int) (list map[int]*User, err erro if len(ids) == 0 { return list, nil } else if len(ids) == 1 { - topic, err := mus.Get(ids[0]) + user, err := s.Get(ids[0]) if err != nil { return list, err } - list[topic.ID] = topic + list[user.ID] = user return list, nil } // TODO: Add a function for the qlist stuff var qlist string - var idList []interface{} - for _, id := range ids { - idList = append(idList, strconv.Itoa(id)) + idList := make([]interface{},len(ids)) + for i, id := range ids { + idList[i] = strconv.Itoa(id) qlist += "?," } qlist = qlist[0 : len(qlist)-1] @@ -189,14 +189,14 @@ func (mus *DefaultUserStore) BulkGetMap(ids []int) (list map[int]*User, err erro defer rows.Close() for rows.Next() { - user := &User{Loggedin: true} - err := rows.Scan(&user.ID, &user.Name, &user.Group, &user.Active, &user.IsSuperAdmin, &user.Session, &user.Email, &user.RawAvatar, &user.Message, &user.URLPrefix, &user.URLName, &user.Level, &user.Score, &user.Liked, &user.LastIP, &user.TempGroup) + u := &User{Loggedin: true} + err := rows.Scan(&u.ID, &u.Name, &u.Group, &u.Active, &u.IsSuperAdmin, &u.Session, &u.Email, &u.RawAvatar, &u.Message, &u.URLPrefix, &u.URLName, &u.Level, &u.Score, &u.Liked, &u.LastIP, &u.TempGroup) if err != nil { return list, err } - user.Init() - mus.cache.Set(user) - list[user.ID] = user + u.Init() + s.cache.Set(u) + list[u.ID] = u } err = rows.Err() if err != nil { diff --git a/query_gen/mssql.go b/query_gen/mssql.go index 9d07dc99..a86c75a4 100644 --- a/query_gen/mssql.go +++ b/query_gen/mssql.go @@ -1093,8 +1093,7 @@ func (adapter *MssqlAdapter) SimpleCount(name string, table string, where string if table == "" { return "", errors.New("You need a name for this table") } - - var querystr = "SELECT COUNT(*) AS [count] FROM [" + table + "]" + var querystr = "SELECT COUNT(*) FROM [" + table + "]" // TODO: Add support for BETWEEN x.x if len(where) != 0 { diff --git a/routes/attachments.go b/routes/attachments.go index e9fdb983..fdc812d5 100644 --- a/routes/attachments.go +++ b/routes/attachments.go @@ -35,11 +35,11 @@ func ShowAttachment(w http.ResponseWriter, r *http.Request, user c.User, filenam return c.LocalError("Bad extension", w, r, user) } - sectionID, err := strconv.Atoi(r.FormValue("sectionID")) + sectionID, err := strconv.Atoi(r.FormValue("sid")) if err != nil { return c.LocalError("The sectionID is not an integer", w, r, user) } - var sectionTable = r.FormValue("sectionType") + sectionTable := r.FormValue("stype") var originTable string var originID, uploadedBy int diff --git a/templates/topic_alt.html b/templates/topic_alt.html index e9fb89c7..0439f16e 100644 --- a/templates/topic_alt.html +++ b/templates/topic_alt.html @@ -67,7 +67,7 @@