landed Community Admin - Set Community Category

This commit is contained in:
2026-02-22 17:56:04 -07:00
parent ac22181a19
commit 59c1db1f27
8 changed files with 170 additions and 11 deletions
+2 -5
View File
@@ -143,11 +143,8 @@ func AmGetCategoryHierarchy(ctx context.Context, catid int32) ([]*Category, erro
p = c.Parent
}
// reverse the array for return
rc := make([]*Category, 0, len(ia))
for i := range ia {
rc = append(rc, ia[len(ia)-(i+1)])
}
return rc, nil
slices.Reverse(ia)
return ia, nil
}
/* AmGetSubCategories returns a list of all subcategories of the given category ID.
+14
View File
@@ -461,6 +461,20 @@ func (c *Community) SaveFlags(ctx context.Context, f *util.OptionSet) error {
return err
}
// SetCategory sets the community's category ID.
func (c *Community) SetCategory(ctx context.Context, catId int32, u *User, ipaddr string) error {
c.Mutex.Lock()
defer c.Mutex.Unlock()
_, err := amdb.ExecContext(ctx, "UPDATE communities SET catid = ? WHERE commid = ?", catId, c.Id)
if err == nil {
if catId != c.CategoryId {
AmStoreAudit(AmNewCommAudit(AuditCommunityCategory, u.Uid, c.Id, ipaddr, fmt.Sprintf("catid=%d", catId)))
}
c.CategoryId = catId
}
return err
}
// SetProfileData sets all the "settable" profile data
func (c *Community) SetProfileData(ctx context.Context, name string, alias string, synopsis *string, rules *string, language *string,
joinkey *string, membersonly bool, hideDirectory bool, hideSearch bool, read_lvl uint16, write_lvl uint16,