Renamed plugin_socialgroups to plugin_guilds 1/3

This commit is contained in:
Azareal 2017-11-02 04:12:51 +00:00
parent 6f45c62815
commit f20a9966da
13 changed files with 198 additions and 198 deletions

View File

@ -10,7 +10,7 @@ func NewForumPermsStore() *ForumPermsStore {
} }
func (fps *ForumPermsStore) Get(fid int, gid int) (fperms ForumPerms, err error) { func (fps *ForumPermsStore) Get(fid int, gid int) (fperms ForumPerms, err error) {
// TODO: Add a hook here and have plugin_socialgroups use it // TODO: Add a hook here and have plugin_guilds use it
group, err := gstore.Get(gid) group, err := gstore.Get(gid)
if err != nil { if err != nil {
return fperms, ErrNoRows return fperms, ErrNoRows

View File

@ -145,7 +145,7 @@ func (mfs *MemoryForumStore) LoadForums() error {
} }
// TODO: Hide social groups too // TODO: Hide social groups too
// ? - Will this be hit a lot by plugin_socialgroups? // ? - Will this be hit a lot by plugin_guilds?
func (mfs *MemoryForumStore) rebuildView() { func (mfs *MemoryForumStore) rebuildView() {
var forumView []*Forum var forumView []*Forum
mfs.forums.Range(func(_ interface{}, value interface{}) bool { mfs.forums.Range(func(_ interface{}, value interface{}) bool {
@ -313,7 +313,7 @@ func (mfs *MemoryForumStore) CacheDelete(id int) {
mfs.rebuildView() mfs.rebuildView()
} }
// TODO: Add a hook to allow plugin_socialgroups to detect when one of it's forums has just been deleted? // TODO: Add a hook to allow plugin_guilds to detect when one of it's forums has just been deleted?
func (mfs *MemoryForumStore) Delete(id int) error { func (mfs *MemoryForumStore) Delete(id int) error {
if id == 1 { if id == 1 {
return errors.New("You cannot delete the Reports forum") return errors.New("You cannot delete the Reports forum")

View File

@ -50,7 +50,7 @@ func routeTopicCreate(w http.ResponseWriter, r *http.Request, user User, sfid st
runVhook("topic_create_pre_loop", w, r, fid, &headerVars, &user, &strictmode) runVhook("topic_create_pre_loop", w, r, fid, &headerVars, &user, &strictmode)
} }
// TODO: Re-add support for plugin_socialgroups // TODO: Re-add support for plugin_guilds
var forumList []Forum var forumList []Forum
var canSee []int var canSee []int
if user.IsSuperAdmin { if user.IsSuperAdmin {
@ -71,7 +71,7 @@ func routeTopicCreate(w http.ResponseWriter, r *http.Request, user User, sfid st
// TODO: plugin_superadmin needs to be able to override this loop. Skip flag on topic_create_pre_loop? // TODO: plugin_superadmin needs to be able to override this loop. Skip flag on topic_create_pre_loop?
for _, ffid := range canSee { for _, ffid := range canSee {
// TODO: Surely, there's a better way of doing this. I've added it in for now to support plugin_socialgroups, but we really need to clean this up // TODO: Surely, there's a better way of doing this. I've added it in for now to support plugin_guilds, but we really need to clean this up
if strictmode && ffid != fid { if strictmode && ffid != fid {
continue continue
} }

View File

@ -13,7 +13,7 @@ import (
) )
// TODO: Update the stats after edits so that we don't under or over decrement stats during deletes // TODO: Update the stats after edits so that we don't under or over decrement stats during deletes
// TODO: Disable stat updates in posts handled by plugin_socialgroups // TODO: Disable stat updates in posts handled by plugin_guilds
func routeEditTopic(w http.ResponseWriter, r *http.Request, user User) RouteError { func routeEditTopic(w http.ResponseWriter, r *http.Request, user User) RouteError {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
@ -63,7 +63,7 @@ func routeEditTopic(w http.ResponseWriter, r *http.Request, user User) RouteErro
} }
// TODO: Add support for soft-deletion and add a permission for hard delete in addition to the usual // TODO: Add support for soft-deletion and add a permission for hard delete in addition to the usual
// TODO: Disable stat updates in posts handled by plugin_socialgroups // TODO: Disable stat updates in posts handled by plugin_guilds
func routeDeleteTopic(w http.ResponseWriter, r *http.Request, user User) RouteError { func routeDeleteTopic(w http.ResponseWriter, r *http.Request, user User) RouteError {
// TODO: Move this to some sort of middleware // TODO: Move this to some sort of middleware
var tids []int var tids []int
@ -334,7 +334,7 @@ func routeUnlockTopic(w http.ResponseWriter, r *http.Request, user User) RouteEr
return nil return nil
} }
// TODO: Disable stat updates in posts handled by plugin_socialgroups // TODO: Disable stat updates in posts handled by plugin_guilds
// TODO: Update the stats after edits so that we don't under or over decrement stats during deletes // TODO: Update the stats after edits so that we don't under or over decrement stats during deletes
func routeReplyEditSubmit(w http.ResponseWriter, r *http.Request, user User) RouteError { func routeReplyEditSubmit(w http.ResponseWriter, r *http.Request, user User) RouteError {
err := r.ParseForm() err := r.ParseForm()
@ -387,7 +387,7 @@ func routeReplyEditSubmit(w http.ResponseWriter, r *http.Request, user User) Rou
} }
// TODO: Refactor this // TODO: Refactor this
// TODO: Disable stat updates in posts handled by plugin_socialgroups // TODO: Disable stat updates in posts handled by plugin_guilds
func routeReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user User) RouteError { func routeReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user User) RouteError {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {

View File

@ -15,20 +15,20 @@ import (
"./query_gen/lib" "./query_gen/lib"
) )
var socialgroupsListStmt *sql.Stmt var guildsListStmt *sql.Stmt
var socialgroupsMemberListStmt *sql.Stmt var guildsMemberListStmt *sql.Stmt
var socialgroupsMemberListJoinStmt *sql.Stmt var guildsMemberListJoinStmt *sql.Stmt
var socialgroupsGetMemberStmt *sql.Stmt var guildsGetMemberStmt *sql.Stmt
var socialgroupsGetGroupStmt *sql.Stmt var guildsGetGuildStmt *sql.Stmt
var socialgroupsCreateGroupStmt *sql.Stmt var guildsCreateGuildStmt *sql.Stmt
var socialgroupsAttachForumStmt *sql.Stmt var guildsAttachForumStmt *sql.Stmt
var socialgroupsUnattachForumStmt *sql.Stmt var guildsUnattachForumStmt *sql.Stmt
var socialgroupsAddMemberStmt *sql.Stmt var guildsAddMemberStmt *sql.Stmt
// TODO: Add a better way of splitting up giant plugins like this // TODO: Add a better way of splitting up giant plugins like this
// SocialGroup is a struct representing a social group // Guild is a struct representing a guild
type SocialGroup struct { type Guild struct {
ID int ID int
Link string Link string
Name string Name string
@ -51,37 +51,37 @@ type SocialGroup struct {
ExtData ExtData ExtData ExtData
} }
type SocialGroupPage struct { type GuildPage struct {
Title string Title string
CurrentUser User CurrentUser User
Header *HeaderVars Header *HeaderVars
ItemList []*TopicsRow ItemList []*TopicsRow
Forum *Forum Forum *Forum
SocialGroup *SocialGroup Guild *Guild
Page int Page int
LastPage int LastPage int
} }
// SocialGroupListPage is a page struct for constructing a list of every social group // GuildListPage is a page struct for constructing a list of every guild
type SocialGroupListPage struct { type GuildListPage struct {
Title string Title string
CurrentUser User CurrentUser User
Header *HeaderVars Header *HeaderVars
GroupList []*SocialGroup GroupList []*Guild
} }
type SocialGroupMemberListPage struct { type GuildMemberListPage struct {
Title string Title string
CurrentUser User CurrentUser User
Header *HeaderVars Header *HeaderVars
ItemList []SocialGroupMember ItemList []GuildMember
SocialGroup *SocialGroup Guild *Guild
Page int Page int
LastPage int LastPage int
} }
// SocialGroupMember is a struct representing a specific member of a group, not to be confused with the global User struct. // GuildMember is a struct representing a specific member of a guild, not to be confused with the global User struct.
type SocialGroupMember struct { type GuildMember struct {
Link string Link string
Rank int /* 0: Member. 1: Mod. 2: Admin. */ Rank int /* 0: Member. 1: Mod. 2: Admin. */
RankString string /* Member, Mod, Admin, Owner */ RankString string /* Member, Mod, Admin, Owner */
@ -94,57 +94,57 @@ type SocialGroupMember struct {
// TODO: Add a plugin interface instead of having a bunch of argument to AddPlugin? // TODO: Add a plugin interface instead of having a bunch of argument to AddPlugin?
func init() { func init() {
plugins["socialgroups"] = NewPlugin("socialgroups", "Social Groups", "Azareal", "http://github.com/Azareal", "", "", "", initSocialgroups, nil, deactivateSocialgroups, installSocialgroups, nil) plugins["guilds"] = NewPlugin("guilds", "Guilds", "Azareal", "http://github.com/Azareal", "", "", "", initGuilds, nil, deactivateGuilds, installGuilds, nil)
} }
func initSocialgroups() (err error) { func initGuilds() (err error) {
plugins["socialgroups"].AddHook("intercept_build_widgets", socialgroupsWidgets) plugins["guilds"].AddHook("intercept_build_widgets", guildsWidgets)
plugins["socialgroups"].AddHook("trow_assign", socialgroupsTrowAssign) plugins["guilds"].AddHook("trow_assign", guildsTrowAssign)
plugins["socialgroups"].AddHook("topic_create_pre_loop", socialgroupsTopicCreatePreLoop) plugins["guilds"].AddHook("topic_create_pre_loop", guildsTopicCreatePreLoop)
plugins["socialgroups"].AddHook("pre_render_view_forum", socialgroupsPreRenderViewForum) plugins["guilds"].AddHook("pre_render_view_forum", guildsPreRenderViewForum)
plugins["socialgroups"].AddHook("simple_forum_check_pre_perms", socialgroupsForumCheck) plugins["guilds"].AddHook("simple_forum_check_pre_perms", guildsForumCheck)
plugins["socialgroups"].AddHook("forum_check_pre_perms", socialgroupsForumCheck) plugins["guilds"].AddHook("forum_check_pre_perms", guildsForumCheck)
// TODO: Auto-grant this perm to admins upon installation? // TODO: Auto-grant this perm to admins upon installation?
registerPluginPerm("CreateSocialGroup") registerPluginPerm("CreateGuild")
router.HandleFunc("/groups/", socialgroupsGroupList) router.HandleFunc("/guilds/", guildsGuildList)
router.HandleFunc("/group/", socialgroupsViewGroup) router.HandleFunc("/guild/", guildsViewGuild)
router.HandleFunc("/group/create/", socialgroupsCreateGroup) router.HandleFunc("/guild/create/", guildsCreateGuild)
router.HandleFunc("/group/create/submit/", socialgroupsCreateGroupSubmit) router.HandleFunc("/guild/create/submit/", guildsCreateGuildSubmit)
router.HandleFunc("/group/members/", socialgroupsMemberList) router.HandleFunc("/guild/members/", guildsMemberList)
socialgroupsListStmt, err = qgen.Builder.SimpleSelect("socialgroups", "sgid, name, desc, active, privacy, joinable, owner, memberCount, createdAt, lastUpdateTime", "", "", "") guildsListStmt, err = qgen.Builder.SimpleSelect("guilds", "guildID, name, desc, active, privacy, joinable, owner, memberCount, createdAt, lastUpdateTime", "", "", "")
if err != nil { if err != nil {
return err return err
} }
socialgroupsGetGroupStmt, err = qgen.Builder.SimpleSelect("socialgroups", "name, desc, active, privacy, joinable, owner, memberCount, mainForum, backdrop, createdAt, lastUpdateTime", "sgid = ?", "", "") guildsGetGuildStmt, err = qgen.Builder.SimpleSelect("guilds", "name, desc, active, privacy, joinable, owner, memberCount, mainForum, backdrop, createdAt, lastUpdateTime", "guildID = ?", "", "")
if err != nil { if err != nil {
return err return err
} }
socialgroupsMemberListStmt, err = qgen.Builder.SimpleSelect("socialgroups_members", "sgid, uid, rank, posts, joinedAt", "", "", "") guildsMemberListStmt, err = qgen.Builder.SimpleSelect("guilds_members", "guildID, uid, rank, posts, joinedAt", "", "", "")
if err != nil { if err != nil {
return err return err
} }
socialgroupsMemberListJoinStmt, err = qgen.Builder.SimpleLeftJoin("socialgroups_members", "users", "users.uid, socialgroups_members.rank, socialgroups_members.posts, socialgroups_members.joinedAt, users.name, users.avatar", "socialgroups_members.uid = users.uid", "socialgroups_members.sgid = ?", "socialgroups_members.rank DESC, socialgroups_members.joinedat ASC", "") guildsMemberListJoinStmt, err = qgen.Builder.SimpleLeftJoin("guilds_members", "users", "users.uid, guilds_members.rank, guilds_members.posts, guilds_members.joinedAt, users.name, users.avatar", "guilds_members.uid = users.uid", "guilds_members.guildID = ?", "guilds_members.rank DESC, guilds_members.joinedat ASC", "")
if err != nil { if err != nil {
return err return err
} }
socialgroupsGetMemberStmt, err = qgen.Builder.SimpleSelect("socialgroups_members", "rank, posts, joinedAt", "sgid = ? AND uid = ?", "", "") guildsGetMemberStmt, err = qgen.Builder.SimpleSelect("guilds_members", "rank, posts, joinedAt", "guildID = ? AND uid = ?", "", "")
if err != nil { if err != nil {
return err return err
} }
socialgroupsCreateGroupStmt, err = qgen.Builder.SimpleInsert("socialgroups", "name, desc, active, privacy, joinable, owner, memberCount, mainForum, backdrop, createdAt, lastUpdateTime", "?,?,?,?,1,?,1,?,'',UTC_TIMESTAMP(),UTC_TIMESTAMP()") guildsCreateGuildStmt, err = qgen.Builder.SimpleInsert("guilds", "name, desc, active, privacy, joinable, owner, memberCount, mainForum, backdrop, createdAt, lastUpdateTime", "?,?,?,?,1,?,1,?,'',UTC_TIMESTAMP(),UTC_TIMESTAMP()")
if err != nil { if err != nil {
return err return err
} }
socialgroupsAttachForumStmt, err = qgen.Builder.SimpleUpdate("forums", "parentID = ?, parentType = 'socialgroup'", "fid = ?") guildsAttachForumStmt, err = qgen.Builder.SimpleUpdate("forums", "parentID = ?, parentType = 'guild'", "fid = ?")
if err != nil { if err != nil {
return err return err
} }
socialgroupsUnattachForumStmt, err = qgen.Builder.SimpleUpdate("forums", "parentID = 0, parentType = ''", "fid = ?") guildsUnattachForumStmt, err = qgen.Builder.SimpleUpdate("forums", "parentID = 0, parentType = ''", "fid = ?")
if err != nil { if err != nil {
return err return err
} }
socialgroupsAddMemberStmt, err = qgen.Builder.SimpleInsert("socialgroups_members", "sgid, uid, rank, posts, joinedAt", "?,?,?,0,UTC_TIMESTAMP()") guildsAddMemberStmt, err = qgen.Builder.SimpleInsert("guilds_members", "guildID, uid, rank, posts, joinedAt", "?,?,?,0,UTC_TIMESTAMP()")
if err != nil { if err != nil {
return err return err
} }
@ -152,34 +152,34 @@ func initSocialgroups() (err error) {
return nil return nil
} }
func deactivateSocialgroups() { func deactivateGuilds() {
plugins["socialgroups"].RemoveHook("intercept_build_widgets", socialgroupsWidgets) plugins["guilds"].RemoveHook("intercept_build_widgets", guildsWidgets)
plugins["socialgroups"].RemoveHook("trow_assign", socialgroupsTrowAssign) plugins["guilds"].RemoveHook("trow_assign", guildsTrowAssign)
plugins["socialgroups"].RemoveHook("topic_create_pre_loop", socialgroupsTopicCreatePreLoop) plugins["guilds"].RemoveHook("topic_create_pre_loop", guildsTopicCreatePreLoop)
plugins["socialgroups"].RemoveHook("pre_render_view_forum", socialgroupsPreRenderViewForum) plugins["guilds"].RemoveHook("pre_render_view_forum", guildsPreRenderViewForum)
plugins["socialgroups"].RemoveHook("simple_forum_check_pre_perms", socialgroupsForumCheck) plugins["guilds"].RemoveHook("simple_forum_check_pre_perms", guildsForumCheck)
plugins["socialgroups"].RemoveHook("forum_check_pre_perms", socialgroupsForumCheck) plugins["guilds"].RemoveHook("forum_check_pre_perms", guildsForumCheck)
deregisterPluginPerm("CreateSocialGroup") deregisterPluginPerm("CreateGuild")
_ = router.RemoveFunc("/groups/") _ = router.RemoveFunc("/guilds/")
_ = router.RemoveFunc("/group/") _ = router.RemoveFunc("/guild/")
_ = router.RemoveFunc("/group/create/") _ = router.RemoveFunc("/guild/create/")
_ = router.RemoveFunc("/group/create/submit/") _ = router.RemoveFunc("/guild/create/submit/")
_ = socialgroupsListStmt.Close() _ = guildsListStmt.Close()
_ = socialgroupsMemberListStmt.Close() _ = guildsMemberListStmt.Close()
_ = socialgroupsMemberListJoinStmt.Close() _ = guildsMemberListJoinStmt.Close()
_ = socialgroupsGetMemberStmt.Close() _ = guildsGetMemberStmt.Close()
_ = socialgroupsGetGroupStmt.Close() _ = guildsGetGuildStmt.Close()
_ = socialgroupsCreateGroupStmt.Close() _ = guildsCreateGuildStmt.Close()
_ = socialgroupsAttachForumStmt.Close() _ = guildsAttachForumStmt.Close()
_ = socialgroupsUnattachForumStmt.Close() _ = guildsUnattachForumStmt.Close()
_ = socialgroupsAddMemberStmt.Close() _ = guildsAddMemberStmt.Close()
} }
// TODO: Stop accessing the query builder directly and add a feature in Gosora which is more easily reversed, if an error comes up during the installation process // TODO: Stop accessing the query builder directly and add a feature in Gosora which is more easily reversed, if an error comes up during the installation process
func installSocialgroups() error { func installGuilds() error {
sgTableStmt, err := qgen.Builder.CreateTable("socialgroups", "utf8mb4", "utf8mb4_general_ci", guildTableStmt, err := qgen.Builder.CreateTable("guilds", "utf8mb4", "utf8mb4_general_ci",
[]qgen.DB_Table_Column{ []qgen.DB_Table_Column{
qgen.DB_Table_Column{"sgid", "int", 0, false, true, ""}, qgen.DB_Table_Column{"guildID", "int", 0, false, true, ""},
qgen.DB_Table_Column{"name", "varchar", 100, false, false, ""}, qgen.DB_Table_Column{"name", "varchar", 100, false, false, ""},
qgen.DB_Table_Column{"desc", "varchar", 200, false, false, ""}, qgen.DB_Table_Column{"desc", "varchar", 200, false, false, ""},
qgen.DB_Table_Column{"active", "boolean", 1, false, false, ""}, qgen.DB_Table_Column{"active", "boolean", 1, false, false, ""},
@ -194,21 +194,21 @@ func installSocialgroups() error {
qgen.DB_Table_Column{"lastUpdateTime", "datetime", 0, false, false, ""}, qgen.DB_Table_Column{"lastUpdateTime", "datetime", 0, false, false, ""},
}, },
[]qgen.DB_Table_Key{ []qgen.DB_Table_Key{
qgen.DB_Table_Key{"sgid", "primary"}, qgen.DB_Table_Key{"guildID", "primary"},
}, },
) )
if err != nil { if err != nil {
return err return err
} }
_, err = sgTableStmt.Exec() _, err = guildTableStmt.Exec()
if err != nil { if err != nil {
return err return err
} }
sgMembersTableStmt, err := qgen.Builder.CreateTable("socialgroups_members", "", "", guildMembersTableStmt, err := qgen.Builder.CreateTable("guilds_members", "", "",
[]qgen.DB_Table_Column{ []qgen.DB_Table_Column{
qgen.DB_Table_Column{"sgid", "int", 0, false, false, ""}, qgen.DB_Table_Column{"guildID", "int", 0, false, false, ""},
qgen.DB_Table_Column{"uid", "int", 0, false, false, ""}, qgen.DB_Table_Column{"uid", "int", 0, false, false, ""},
qgen.DB_Table_Column{"rank", "int", 0, false, false, "0"}, /* 0: Member. 1: Mod. 2: Admin. */ qgen.DB_Table_Column{"rank", "int", 0, false, false, "0"}, /* 0: Member. 1: Mod. 2: Admin. */
qgen.DB_Table_Column{"posts", "int", 0, false, false, "0"}, /* Per-Group post count. Should we do some sort of score system? */ qgen.DB_Table_Column{"posts", "int", 0, false, false, "0"}, /* Per-Group post count. Should we do some sort of score system? */
@ -220,21 +220,21 @@ func installSocialgroups() error {
return err return err
} }
_, err = sgMembersTableStmt.Exec() _, err = guildMembersTableStmt.Exec()
return err return err
} }
// TO-DO; Implement an uninstallation system into Gosora. And a better installation system. // TO-DO; Implement an uninstallation system into Gosora. And a better installation system.
func uninstallSocialgroups() error { func uninstallGuilds() error {
return nil return nil
} }
// TODO: Do this properly via the widget system // TODO: Do this properly via the widget system
func socialgroupsCommonAreaWidgets(headerVars *HeaderVars) { func guildsCommonAreaWidgets(headerVars *HeaderVars) {
// TODO: Hot Groups? Featured Groups? Official Groups? // TODO: Hot Groups? Featured Groups? Official Groups?
var b bytes.Buffer var b bytes.Buffer
var menu = WidgetMenu{"Social Groups", []WidgetMenuItem{ var menu = WidgetMenu{"Guilds", []WidgetMenuItem{
WidgetMenuItem{"Create Group", "/group/create/", false}, WidgetMenuItem{"Create Guild", "/guild/create/", false},
}} }}
err := templates.ExecuteTemplate(&b, "widget_menu.html", menu) err := templates.ExecuteTemplate(&b, "widget_menu.html", menu)
@ -252,13 +252,13 @@ func socialgroupsCommonAreaWidgets(headerVars *HeaderVars) {
// TODO: Do this properly via the widget system // TODO: Do this properly via the widget system
// TODO: Make a better more customisable group widget system // TODO: Make a better more customisable group widget system
func socialgroupsGroupWidgets(headerVars *HeaderVars, sgItem *SocialGroup) (success bool) { func guildsGuildWidgets(headerVars *HeaderVars, guildItem *Guild) (success bool) {
return false // Disabled until the next commit return false // Disabled until the next commit
/*var b bytes.Buffer /*var b bytes.Buffer
var menu WidgetMenu = WidgetMenu{"Group Options", []WidgetMenuItem{ var menu WidgetMenu = WidgetMenu{"Guild Options", []WidgetMenuItem{
WidgetMenuItem{"Join", "/group/join/" + strconv.Itoa(sgItem.ID), false}, WidgetMenuItem{"Join", "/guild/join/" + strconv.Itoa(guildItem.ID), false},
WidgetMenuItem{"Members", "/group/members/" + strconv.Itoa(sgItem.ID), false}, WidgetMenuItem{"Members", "/guild/members/" + strconv.Itoa(guildItem.ID), false},
}} }}
err := templates.ExecuteTemplate(&b, "widget_menu.html", menu) err := templates.ExecuteTemplate(&b, "widget_menu.html", menu)
@ -281,27 +281,27 @@ func socialgroupsGroupWidgets(headerVars *HeaderVars, sgItem *SocialGroup) (succ
Custom Pages Custom Pages
*/ */
func socialgroupsGroupList(w http.ResponseWriter, r *http.Request, user User) RouteError { func guildsGuildList(w http.ResponseWriter, r *http.Request, user User) RouteError {
headerVars, ferr := UserCheck(w, r, &user) headerVars, ferr := UserCheck(w, r, &user)
if ferr != nil { if ferr != nil {
return ferr return ferr
} }
socialgroupsCommonAreaWidgets(headerVars) guildsCommonAreaWidgets(headerVars)
rows, err := socialgroupsListStmt.Query() rows, err := guildsListStmt.Query()
if err != nil && err != ErrNoRows { if err != nil && err != ErrNoRows {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
var sgList []*SocialGroup var guildList []*Guild
for rows.Next() { for rows.Next() {
sgItem := &SocialGroup{ID: 0} guildItem := &Guild{ID: 0}
err := rows.Scan(&sgItem.ID, &sgItem.Name, &sgItem.Desc, &sgItem.Active, &sgItem.Privacy, &sgItem.Joinable, &sgItem.Owner, &sgItem.MemberCount, &sgItem.CreatedAt, &sgItem.LastUpdateTime) err := rows.Scan(&guildItem.ID, &guildItem.Name, &guildItem.Desc, &guildItem.Active, &guildItem.Privacy, &guildItem.Joinable, &guildItem.Owner, &guildItem.MemberCount, &guildItem.CreatedAt, &guildItem.LastUpdateTime)
if err != nil { if err != nil {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
sgItem.Link = socialgroupsBuildGroupURL(nameToSlug(sgItem.Name), sgItem.ID) guildItem.Link = guildsBuildGuildURL(nameToSlug(guildItem.Name), guildItem.ID)
sgList = append(sgList, sgItem) guildList = append(guildList, guildItem)
} }
err = rows.Err() err = rows.Err()
if err != nil { if err != nil {
@ -309,93 +309,93 @@ func socialgroupsGroupList(w http.ResponseWriter, r *http.Request, user User) Ro
} }
rows.Close() rows.Close()
pi := SocialGroupListPage{"Group List", user, headerVars, sgList} pi := GuildListPage{"Guild List", user, headerVars, guildList}
err = templates.ExecuteTemplate(w, "socialgroups_group_list.html", pi) err = templates.ExecuteTemplate(w, "guilds_guild_list.html", pi)
if err != nil { if err != nil {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
return nil return nil
} }
func socialgroupsGetGroup(sgid int) (sgItem *SocialGroup, err error) { func guildsGetGuild(guildID int) (guildItem *Guild, err error) {
sgItem = &SocialGroup{ID: sgid} guildItem = &Guild{ID: guildID}
err = socialgroupsGetGroupStmt.QueryRow(sgid).Scan(&sgItem.Name, &sgItem.Desc, &sgItem.Active, &sgItem.Privacy, &sgItem.Joinable, &sgItem.Owner, &sgItem.MemberCount, &sgItem.MainForumID, &sgItem.Backdrop, &sgItem.CreatedAt, &sgItem.LastUpdateTime) err = guildsGetGuildStmt.QueryRow(guildID).Scan(&guildItem.Name, &guildItem.Desc, &guildItem.Active, &guildItem.Privacy, &guildItem.Joinable, &guildItem.Owner, &guildItem.MemberCount, &guildItem.MainForumID, &guildItem.Backdrop, &guildItem.CreatedAt, &guildItem.LastUpdateTime)
return sgItem, err return guildItem, err
} }
func socialgroupsViewGroup(w http.ResponseWriter, r *http.Request, user User) RouteError { func guildsViewGuild(w http.ResponseWriter, r *http.Request, user User) RouteError {
// SEO URLs... // SEO URLs...
halves := strings.Split(r.URL.Path[len("/group/"):], ".") halves := strings.Split(r.URL.Path[len("/guild/"):], ".")
if len(halves) < 2 { if len(halves) < 2 {
halves = append(halves, halves[0]) halves = append(halves, halves[0])
} }
sgid, err := strconv.Atoi(halves[1]) guildID, err := strconv.Atoi(halves[1])
if err != nil { if err != nil {
return PreError("Not a valid group ID", w, r) return PreError("Not a valid guild ID", w, r)
} }
sgItem, err := socialgroupsGetGroup(sgid) guildItem, err := guildsGetGuild(guildID)
if err != nil { if err != nil {
return LocalError("Bad group", w, r, user) return LocalError("Bad guild", w, r, user)
} }
if !sgItem.Active { if !guildItem.Active {
return NotFound(w, r) return NotFound(w, r)
} }
// Re-route the request to routeForums // Re-route the request to routeForums
var ctx = context.WithValue(r.Context(), "socialgroups_current_group", sgItem) var ctx = context.WithValue(r.Context(), "guilds_current_guild", guildItem)
return routeForum(w, r.WithContext(ctx), user, strconv.Itoa(sgItem.MainForumID)) return routeForum(w, r.WithContext(ctx), user, strconv.Itoa(guildItem.MainForumID))
} }
func socialgroupsCreateGroup(w http.ResponseWriter, r *http.Request, user User) RouteError { func guildsCreateGuild(w http.ResponseWriter, r *http.Request, user User) RouteError {
headerVars, ferr := UserCheck(w, r, &user) headerVars, ferr := UserCheck(w, r, &user)
if ferr != nil { if ferr != nil {
return ferr return ferr
} }
// TODO: Add an approval queue mode for group creation // TODO: Add an approval queue mode for group creation
if !user.Loggedin || !user.PluginPerms["CreateSocialGroup"] { if !user.Loggedin || !user.PluginPerms["CreateGuild"] {
return NoPermissions(w, r, user) return NoPermissions(w, r, user)
} }
socialgroupsCommonAreaWidgets(headerVars) guildsCommonAreaWidgets(headerVars)
pi := Page{"Create Group", user, headerVars, tList, nil} pi := Page{"Create Guild", user, headerVars, tList, nil}
err := templates.ExecuteTemplate(w, "socialgroups_create_group.html", pi) err := templates.ExecuteTemplate(w, "guilds_create_guild.html", pi)
if err != nil { if err != nil {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
return nil return nil
} }
func socialgroupsCreateGroupSubmit(w http.ResponseWriter, r *http.Request, user User) RouteError { func guildsCreateGuildSubmit(w http.ResponseWriter, r *http.Request, user User) RouteError {
// TODO: Add an approval queue mode for group creation // TODO: Add an approval queue mode for group creation
if !user.Loggedin || !user.PluginPerms["CreateSocialGroup"] { if !user.Loggedin || !user.PluginPerms["CreateGuild"] {
return NoPermissions(w, r, user) return NoPermissions(w, r, user)
} }
var groupActive = true var guildActive = true
var groupName = html.EscapeString(r.PostFormValue("group_name")) var guildName = html.EscapeString(r.PostFormValue("group_name"))
var groupDesc = html.EscapeString(r.PostFormValue("group_desc")) var guildDesc = html.EscapeString(r.PostFormValue("group_desc"))
var gprivacy = r.PostFormValue("group_privacy") var gprivacy = r.PostFormValue("group_privacy")
var groupPrivacy int var guildPrivacy int
switch gprivacy { switch gprivacy {
case "0": case "0":
groupPrivacy = 0 // Public guildPrivacy = 0 // Public
case "1": case "1":
groupPrivacy = 1 // Protected guildPrivacy = 1 // Protected
case "2": case "2":
groupPrivacy = 2 // private guildPrivacy = 2 // private
default: default:
groupPrivacy = 0 guildPrivacy = 0
} }
// Create the backing forum // Create the backing forum
fid, err := fstore.Create(groupName, "", true, "") fid, err := fstore.Create(guildName, "", true, "")
if err != nil { if err != nil {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
res, err := socialgroupsCreateGroupStmt.Exec(groupName, groupDesc, groupActive, groupPrivacy, user.ID, fid) res, err := guildsCreateGuildStmt.Exec(guildName, guildDesc, guildActive, guildPrivacy, user.ID, fid)
if err != nil { if err != nil {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
@ -405,80 +405,80 @@ func socialgroupsCreateGroupSubmit(w http.ResponseWriter, r *http.Request, user
} }
// Add the main backing forum to the forum list // Add the main backing forum to the forum list
err = socialgroupsAttachForum(int(lastID), fid) err = guildsAttachForum(int(lastID), fid)
if err != nil { if err != nil {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
_, err = socialgroupsAddMemberStmt.Exec(lastID, user.ID, 2) _, err = guildsAddMemberStmt.Exec(lastID, user.ID, 2)
if err != nil { if err != nil {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
http.Redirect(w, r, socialgroupsBuildGroupURL(nameToSlug(groupName), int(lastID)), http.StatusSeeOther) http.Redirect(w, r, guildsBuildGuildURL(nameToSlug(guildName), int(lastID)), http.StatusSeeOther)
return nil return nil
} }
func socialgroupsMemberList(w http.ResponseWriter, r *http.Request, user User) RouteError { func guildsMemberList(w http.ResponseWriter, r *http.Request, user User) RouteError {
headerVars, ferr := UserCheck(w, r, &user) headerVars, ferr := UserCheck(w, r, &user)
if ferr != nil { if ferr != nil {
return ferr return ferr
} }
// SEO URLs... // SEO URLs...
halves := strings.Split(r.URL.Path[len("/group/members/"):], ".") halves := strings.Split(r.URL.Path[len("/guild/members/"):], ".")
if len(halves) < 2 { if len(halves) < 2 {
halves = append(halves, halves[0]) halves = append(halves, halves[0])
} }
sgid, err := strconv.Atoi(halves[1]) guildID, err := strconv.Atoi(halves[1])
if err != nil { if err != nil {
return PreError("Not a valid group ID", w, r) return PreError("Not a valid group ID", w, r)
} }
var sgItem = &SocialGroup{ID: sgid} var guildItem = &Guild{ID: guildID}
var mainForum int // Unused var mainForum int // Unused
err = socialgroupsGetGroupStmt.QueryRow(sgid).Scan(&sgItem.Name, &sgItem.Desc, &sgItem.Active, &sgItem.Privacy, &sgItem.Joinable, &sgItem.Owner, &sgItem.MemberCount, &mainForum, &sgItem.Backdrop, &sgItem.CreatedAt, &sgItem.LastUpdateTime) err = guildsGetGuildStmt.QueryRow(guildID).Scan(&guildItem.Name, &guildItem.Desc, &guildItem.Active, &guildItem.Privacy, &guildItem.Joinable, &guildItem.Owner, &guildItem.MemberCount, &mainForum, &guildItem.Backdrop, &guildItem.CreatedAt, &guildItem.LastUpdateTime)
if err != nil { if err != nil {
return LocalError("Bad group", w, r, user) return LocalError("Bad group", w, r, user)
} }
sgItem.Link = socialgroupsBuildGroupURL(nameToSlug(sgItem.Name), sgItem.ID) guildItem.Link = guildsBuildGuildURL(nameToSlug(guildItem.Name), guildItem.ID)
socialgroupsGroupWidgets(headerVars, sgItem) guildsGuildWidgets(headerVars, guildItem)
rows, err := socialgroupsMemberListJoinStmt.Query(sgid) rows, err := guildsMemberListJoinStmt.Query(guildID)
if err != nil && err != ErrNoRows { if err != nil && err != ErrNoRows {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
var sgMembers []SocialGroupMember var guildMembers []GuildMember
for rows.Next() { for rows.Next() {
sgMember := SocialGroupMember{PostCount: 0} guildMember := GuildMember{PostCount: 0}
err := rows.Scan(&sgMember.User.ID, &sgMember.Rank, &sgMember.PostCount, &sgMember.JoinedAt, &sgMember.User.Name, &sgMember.User.Avatar) err := rows.Scan(&guildMember.User.ID, &guildMember.Rank, &guildMember.PostCount, &guildMember.JoinedAt, &guildMember.User.Name, &guildMember.User.Avatar)
if err != nil { if err != nil {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
sgMember.Link = buildProfileURL(nameToSlug(sgMember.User.Name), sgMember.User.ID) guildMember.Link = buildProfileURL(nameToSlug(guildMember.User.Name), guildMember.User.ID)
if sgMember.User.Avatar != "" { if guildMember.User.Avatar != "" {
if sgMember.User.Avatar[0] == '.' { if guildMember.User.Avatar[0] == '.' {
sgMember.User.Avatar = "/uploads/avatar_" + strconv.Itoa(sgMember.User.ID) + sgMember.User.Avatar guildMember.User.Avatar = "/uploads/avatar_" + strconv.Itoa(guildMember.User.ID) + guildMember.User.Avatar
} }
} else { } else {
sgMember.User.Avatar = strings.Replace(config.Noavatar, "{id}", strconv.Itoa(sgMember.User.ID), 1) guildMember.User.Avatar = strings.Replace(config.Noavatar, "{id}", strconv.Itoa(guildMember.User.ID), 1)
} }
sgMember.JoinedAt, _ = relativeTimeFromString(sgMember.JoinedAt) guildMember.JoinedAt, _ = relativeTimeFromString(guildMember.JoinedAt)
if sgItem.Owner == sgMember.User.ID { if guildItem.Owner == guildMember.User.ID {
sgMember.RankString = "Owner" guildMember.RankString = "Owner"
} else { } else {
switch sgMember.Rank { switch guildMember.Rank {
case 0: case 0:
sgMember.RankString = "Member" guildMember.RankString = "Member"
case 1: case 1:
sgMember.RankString = "Mod" guildMember.RankString = "Mod"
case 2: case 2:
sgMember.RankString = "Admin" guildMember.RankString = "Admin"
} }
} }
sgMembers = append(sgMembers, sgMember) guildMembers = append(guildMembers, guildMember)
} }
err = rows.Err() err = rows.Err()
if err != nil { if err != nil {
@ -486,49 +486,49 @@ func socialgroupsMemberList(w http.ResponseWriter, r *http.Request, user User) R
} }
rows.Close() rows.Close()
pi := SocialGroupMemberListPage{"Group Member List", user, headerVars, sgMembers, sgItem, 0, 0} pi := GuildMemberListPage{"Guild Member List", user, headerVars, guildMembers, guildItem, 0, 0}
// A plugin with plugins. Pluginception! // A plugin with plugins. Pluginception!
if preRenderHooks["pre_render_socialgroups_member_list"] != nil { if preRenderHooks["pre_render_guilds_member_list"] != nil {
if runPreRenderHook("pre_render_socialgroups_member_list", w, r, &user, &pi) { if runPreRenderHook("pre_render_guilds_member_list", w, r, &user, &pi) {
return nil return nil
} }
} }
err = templates.ExecuteTemplate(w, "socialgroups_member_list.html", pi) err = templates.ExecuteTemplate(w, "guilds_member_list.html", pi)
if err != nil { if err != nil {
return InternalError(err, w, r) return InternalError(err, w, r)
} }
return nil return nil
} }
func socialgroupsAttachForum(sgid int, fid int) error { func guildsAttachForum(guildID int, fid int) error {
_, err := socialgroupsAttachForumStmt.Exec(sgid, fid) _, err := guildsAttachForumStmt.Exec(guildID, fid)
return err return err
} }
func socialgroupsUnattachForum(fid int) error { func guildsUnattachForum(fid int) error {
_, err := socialgroupsAttachForumStmt.Exec(fid) _, err := guildsAttachForumStmt.Exec(fid)
return err return err
} }
func socialgroupsBuildGroupURL(slug string, id int) string { func guildsBuildGuildURL(slug string, id int) string {
if slug == "" { if slug == "" {
return "/group/" + slug + "." + strconv.Itoa(id) return "/guild/" + slug + "." + strconv.Itoa(id)
} }
return "/group/" + strconv.Itoa(id) return "/guild/" + strconv.Itoa(id)
} }
/* /*
Hooks Hooks
*/ */
func socialgroupsPreRenderViewForum(w http.ResponseWriter, r *http.Request, user *User, data interface{}) (halt bool) { func guildsPreRenderViewForum(w http.ResponseWriter, r *http.Request, user *User, data interface{}) (halt bool) {
pi := data.(*ForumPage) pi := data.(*ForumPage)
if pi.Header.ExtData.items != nil { if pi.Header.ExtData.items != nil {
if sgData, ok := pi.Header.ExtData.items["socialgroups_current_group"]; ok { if guildData, ok := pi.Header.ExtData.items["guilds_current_group"]; ok {
sgItem := sgData.(*SocialGroup) guildItem := guildData.(*Guild)
sgpi := SocialGroupPage{pi.Title, pi.CurrentUser, pi.Header, pi.ItemList, pi.Forum, sgItem, pi.Page, pi.LastPage} guildpi := GuildPage{pi.Title, pi.CurrentUser, pi.Header, pi.ItemList, pi.Forum, guildItem, pi.Page, pi.LastPage}
err := templates.ExecuteTemplate(w, "socialgroups_view_group.html", sgpi) err := templates.ExecuteTemplate(w, "guilds_view_guild.html", guildpi)
if err != nil { if err != nil {
LogError(err) LogError(err)
return false return false
@ -539,19 +539,19 @@ func socialgroupsPreRenderViewForum(w http.ResponseWriter, r *http.Request, user
return false return false
} }
func socialgroupsTrowAssign(args ...interface{}) interface{} { func guildsTrowAssign(args ...interface{}) interface{} {
var forum = args[1].(*Forum) var forum = args[1].(*Forum)
if forum.ParentType == "socialgroup" { if forum.ParentType == "guild" {
var topicItem = args[0].(*TopicsRow) var topicItem = args[0].(*TopicsRow)
topicItem.ForumLink = "/group/" + strings.TrimPrefix(topicItem.ForumLink, getForumURLPrefix()) topicItem.ForumLink = "/guild/" + strings.TrimPrefix(topicItem.ForumLink, getForumURLPrefix())
} }
return nil return nil
} }
// TODO: It would be nice, if you could select one of the boards in the group from that drop-down rather than just the one you got linked from // TODO: It would be nice, if you could select one of the boards in the group from that drop-down rather than just the one you got linked from
func socialgroupsTopicCreatePreLoop(args ...interface{}) interface{} { func guildsTopicCreatePreLoop(args ...interface{}) interface{} {
var fid = args[2].(int) var fid = args[2].(int)
if fstore.DirtyGet(fid).ParentType == "socialgroup" { if fstore.DirtyGet(fid).ParentType == "guild" {
var strictmode = args[5].(*bool) var strictmode = args[5].(*bool)
*strictmode = true *strictmode = true
} }
@ -561,24 +561,24 @@ func socialgroupsTopicCreatePreLoop(args ...interface{}) interface{} {
// TODO: Add privacy options // TODO: Add privacy options
// TODO: Add support for multiple boards and add per-board simplified permissions // TODO: Add support for multiple boards and add per-board simplified permissions
// TODO: Take isJs into account for routes which expect JSON responses // TODO: Take isJs into account for routes which expect JSON responses
func socialgroupsForumCheck(args ...interface{}) (skip bool, rerr RouteError) { func guildsForumCheck(args ...interface{}) (skip bool, rerr RouteError) {
var r = args[1].(*http.Request) var r = args[1].(*http.Request)
var fid = args[3].(*int) var fid = args[3].(*int)
var forum = fstore.DirtyGet(*fid) var forum = fstore.DirtyGet(*fid)
if forum.ParentType == "socialgroup" { if forum.ParentType == "guild" {
var err error var err error
var w = args[0].(http.ResponseWriter) var w = args[0].(http.ResponseWriter)
sgItem, ok := r.Context().Value("socialgroups_current_group").(*SocialGroup) guildItem, ok := r.Context().Value("guilds_current_group").(*Guild)
if !ok { if !ok {
sgItem, err = socialgroupsGetGroup(forum.ParentID) guildItem, err = guildsGetGuild(forum.ParentID)
if err != nil { if err != nil {
return true, InternalError(errors.New("Unable to find the parent group for a forum"), w, r) return true, InternalError(errors.New("Unable to find the parent group for a forum"), w, r)
} }
if !sgItem.Active { if !guildItem.Active {
return true, NotFound(w, r) return true, NotFound(w, r)
} }
r = r.WithContext(context.WithValue(r.Context(), "socialgroups_current_group", sgItem)) r = r.WithContext(context.WithValue(r.Context(), "guilds_current_group", guildItem))
} }
var user = args[2].(*User) var user = args[2].(*User)
@ -593,7 +593,7 @@ func socialgroupsForumCheck(args ...interface{}) (skip bool, rerr RouteError) {
overrideForumPerms(&user.Perms, false) overrideForumPerms(&user.Perms, false)
user.Perms.ViewTopic = true user.Perms.ViewTopic = true
err = socialgroupsGetMemberStmt.QueryRow(sgItem.ID, user.ID).Scan(&rank, &posts, &joinedAt) err = guildsGetMemberStmt.QueryRow(guildItem.ID, user.ID).Scan(&rank, &posts, &joinedAt)
if err != nil && err != ErrNoRows { if err != nil && err != ErrNoRows {
return true, InternalError(err, w, r) return true, InternalError(err, w, r)
} else if err != nil { } else if err != nil {
@ -608,7 +608,7 @@ func socialgroupsForumCheck(args ...interface{}) (skip bool, rerr RouteError) {
} }
// Basic permissions for members, more complicated permissions coming in the next commit! // Basic permissions for members, more complicated permissions coming in the next commit!
if sgItem.Owner == user.ID { if guildItem.Owner == user.ID {
overrideForumPerms(&user.Perms, true) overrideForumPerms(&user.Perms, true)
} else if rank == 0 { } else if rank == 0 {
user.Perms.LikeItem = true user.Perms.LikeItem = true
@ -625,7 +625,7 @@ func socialgroupsForumCheck(args ...interface{}) (skip bool, rerr RouteError) {
// TODO: Override redirects? I don't think this is needed quite yet // TODO: Override redirects? I don't think this is needed quite yet
func socialgroupsWidgets(args ...interface{}) interface{} { func guildsWidgets(args ...interface{}) interface{} {
var zone = args[0].(string) var zone = args[0].(string)
var headerVars = args[2].(*HeaderVars) var headerVars = args[2].(*HeaderVars)
var request = args[3].(*http.Request) var request = args[3].(*http.Request)
@ -635,9 +635,9 @@ func socialgroupsWidgets(args ...interface{}) interface{} {
} }
var forum = args[1].(*Forum) var forum = args[1].(*Forum)
if forum.ParentType == "socialgroup" { if forum.ParentType == "guild" {
// This is why I hate using contexts, all the daisy chains and interface casts x.x // This is why I hate using contexts, all the daisy chains and interface casts x.x
sgItem, ok := request.Context().Value("socialgroups_current_group").(*SocialGroup) guildItem, ok := request.Context().Value("guilds_current_group").(*Guild)
if !ok { if !ok {
LogError(errors.New("Unable to find a parent group in the context data")) LogError(errors.New("Unable to find a parent group in the context data"))
return false return false
@ -646,9 +646,9 @@ func socialgroupsWidgets(args ...interface{}) interface{} {
if headerVars.ExtData.items == nil { if headerVars.ExtData.items == nil {
headerVars.ExtData.items = make(map[string]interface{}) headerVars.ExtData.items = make(map[string]interface{})
} }
headerVars.ExtData.items["socialgroups_current_group"] = sgItem headerVars.ExtData.items["guilds_current_group"] = guildItem
return socialgroupsGroupWidgets(headerVars, sgItem) return guildsGuildWidgets(headerVars, guildItem)
} }
return false return false
} }

View File

@ -57,7 +57,7 @@ func createTables(adapter qgen.DB_Adapter) error {
// Should we add IP Penalties? No, that's a stupid idea, just implement IP Bans properly. What about shadowbans? // Should we add IP Penalties? No, that's a stupid idea, just implement IP Bans properly. What about shadowbans?
// TODO: Perm overrides // TODO: Perm overrides
// TODO: Add a mod-queue and other basic auto-mod features. This is needed for awaiting activation and the mod_queue penalty flag // TODO: Add a mod-queue and other basic auto-mod features. This is needed for awaiting activation and the mod_queue penalty flag
// TODO: Add a penalty type where a user is stopped from creating plugin_socialgroups social groups // TODO: Add a penalty type where a user is stopped from creating plugin_guilds social groups
// TODO: Shadow bans. We will probably have a CanShadowBan permission for this, as we *really* don't want people using this lightly. // TODO: Shadow bans. We will probably have a CanShadowBan permission for this, as we *really* don't want people using this lightly.
/*qgen.Install.CreateTable("users_penalties","","", /*qgen.Install.CreateTable("users_penalties","","",
[]qgen.DB_Table_Column{ []qgen.DB_Table_Column{

View File

@ -85,7 +85,7 @@ func routeStatic(w http.ResponseWriter, r *http.Request) {
// TODO: Make this a static file somehow? Is it possible for us to put this file somewhere else? // TODO: Make this a static file somehow? Is it possible for us to put this file somewhere else?
// TODO: Add a sitemap // TODO: Add a sitemap
// TODO: Add an API so that plugins can register disallowed areas. E.g. /groups/join for plugin_socialgroups // TODO: Add an API so that plugins can register disallowed areas. E.g. /guilds/join for plugin_guilds
func routeRobotsTxt(w http.ResponseWriter, r *http.Request) RouteError { func routeRobotsTxt(w http.ResponseWriter, r *http.Request) RouteError {
_, _ = w.Write([]byte(`User-agent: * _, _ = w.Write([]byte(`User-agent: *
Disallow: /panel/ Disallow: /panel/
@ -180,11 +180,11 @@ func routeTopics(w http.ResponseWriter, r *http.Request, user User) RouteError {
// Optimise Quick Topic away for guests // Optimise Quick Topic away for guests
if user.Loggedin { if user.Loggedin {
fcopy := forum.Copy() fcopy := forum.Copy()
// TODO: Add a hook here for plugin_socialgroups // TODO: Add a hook here for plugin_guilds
forumList = append(forumList, fcopy) forumList = append(forumList, fcopy)
} }
} }
// ? - Should we be showing plugin_socialgroups posts on /topics/? // ? - Should we be showing plugin_guilds posts on /topics/?
// ? - Would it be useful, if we could post in social groups from /topics/? // ? - Would it be useful, if we could post in social groups from /topics/?
argList = append(argList, strconv.Itoa(fid)) argList = append(argList, strconv.Itoa(fid))
qlist += "?," qlist += "?,"

View File

@ -29,7 +29,7 @@ func getDefaultHeaderVar() *HeaderVars {
} }
// TODO: Support for left sidebars and sidebars on both sides // TODO: Support for left sidebars and sidebars on both sides
// http.Request is for context.Context middleware. Mostly for plugin_socialgroups right now // http.Request is for context.Context middleware. Mostly for plugin_guilds right now
func BuildWidgets(zone string, data interface{}, headerVars *HeaderVars, r *http.Request) { func BuildWidgets(zone string, data interface{}, headerVars *HeaderVars, r *http.Request) {
if vhooks["intercept_build_widgets"] != nil { if vhooks["intercept_build_widgets"] != nil {
if runVhook("intercept_build_widgets", zone, data, headerVars, r).(bool) { if runVhook("intercept_build_widgets", zone, data, headerVars, r).(bool) {
@ -62,7 +62,7 @@ func simpleForumUserCheck(w http.ResponseWriter, r *http.Request, user *User, fi
if vhookSkippable["simple_forum_check_pre_perms"] != nil { if vhookSkippable["simple_forum_check_pre_perms"] != nil {
var skip bool var skip bool
skip, rerr = runVhookSkippable("simple_forum_check_pre_perms", w, r, user, &fid, &headerLite) skip, rerr = runVhookSkippable("simple_forum_check_pre_perms", w, r, user, &fid, &headerLite)
if skip { if skip || rerr != nil {
return headerLite, rerr return headerLite, rerr
} }
} }
@ -89,7 +89,7 @@ func forumUserCheck(w http.ResponseWriter, r *http.Request, user *User, fid int)
if vhookSkippable["forum_check_pre_perms"] != nil { if vhookSkippable["forum_check_pre_perms"] != nil {
var skip bool var skip bool
skip, rerr = runVhookSkippable("forum_check_pre_perms", w, r, user, &fid, &headerVars) skip, rerr = runVhookSkippable("forum_check_pre_perms", w, r, user, &fid, &headerVars)
if skip { if skip || rerr != nil {
return headerVars, rerr return headerVars, rerr
} }
} }