2017-02-04 06:19:55 +00:00
|
|
|
package main
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
import "log"
|
|
|
|
import "sync"
|
|
|
|
import "strconv"
|
|
|
|
import "encoding/json"
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
var permUpdateMutex sync.Mutex
|
2017-02-04 06:19:55 +00:00
|
|
|
var BlankPerms Perms
|
|
|
|
var BlankForumPerms ForumPerms
|
|
|
|
var GuestPerms Perms
|
|
|
|
var ReadForumPerms ForumPerms
|
|
|
|
var ReadReplyForumPerms ForumPerms
|
|
|
|
var ReadWriteForumPerms ForumPerms
|
|
|
|
var AllPerms Perms
|
|
|
|
var AllForumPerms ForumPerms
|
2017-09-03 04:50:31 +00:00
|
|
|
var AllPluginPerms = make(map[string]bool)
|
2017-02-04 06:19:55 +00:00
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
var LocalPermList = []string{
|
2017-03-23 12:13:50 +00:00
|
|
|
"ViewTopic",
|
|
|
|
"LikeItem",
|
|
|
|
"CreateTopic",
|
|
|
|
"EditTopic",
|
|
|
|
"DeleteTopic",
|
|
|
|
"CreateReply",
|
|
|
|
"EditReply",
|
|
|
|
"DeleteReply",
|
|
|
|
"PinTopic",
|
|
|
|
"CloseTopic",
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
var GlobalPermList = []string{
|
2017-03-23 12:13:50 +00:00
|
|
|
"BanUsers",
|
|
|
|
"ActivateUsers",
|
|
|
|
"EditUser",
|
|
|
|
"EditUserEmail",
|
|
|
|
"EditUserPassword",
|
|
|
|
"EditUserGroup",
|
|
|
|
"EditUserGroupSuperMod",
|
|
|
|
"EditUserGroupAdmin",
|
|
|
|
"EditGroup",
|
|
|
|
"EditGroupLocalPerms",
|
|
|
|
"EditGroupGlobalPerms",
|
|
|
|
"EditGroupSuperMod",
|
|
|
|
"EditGroupAdmin",
|
|
|
|
"ManageForums",
|
|
|
|
"EditSettings",
|
|
|
|
"ManageThemes",
|
|
|
|
"ManagePlugins",
|
2017-04-12 10:10:36 +00:00
|
|
|
"ViewAdminLogs",
|
2017-03-23 12:13:50 +00:00
|
|
|
"ViewIPs",
|
|
|
|
}
|
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
// Permission Structure: ActionComponent[Subcomponent]Flag
|
2017-09-03 04:50:31 +00:00
|
|
|
type Perms struct {
|
2017-02-04 06:19:55 +00:00
|
|
|
// Global Permissions
|
2017-09-03 04:50:31 +00:00
|
|
|
BanUsers bool
|
|
|
|
ActivateUsers bool
|
|
|
|
EditUser bool
|
|
|
|
EditUserEmail bool
|
|
|
|
EditUserPassword bool
|
|
|
|
EditUserGroup bool
|
2017-02-04 06:19:55 +00:00
|
|
|
EditUserGroupSuperMod bool
|
2017-09-03 04:50:31 +00:00
|
|
|
EditUserGroupAdmin bool
|
|
|
|
EditGroup bool
|
|
|
|
EditGroupLocalPerms bool
|
|
|
|
EditGroupGlobalPerms bool
|
|
|
|
EditGroupSuperMod bool
|
|
|
|
EditGroupAdmin bool
|
|
|
|
ManageForums bool // This could be local, albeit limited for per-forum managers?
|
|
|
|
EditSettings bool
|
|
|
|
ManageThemes bool
|
|
|
|
ManagePlugins bool
|
|
|
|
ViewAdminLogs bool
|
|
|
|
ViewIPs bool
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
// Forum permissions
|
2017-09-03 04:50:31 +00:00
|
|
|
ViewTopic bool
|
|
|
|
LikeItem bool
|
2017-02-04 06:19:55 +00:00
|
|
|
CreateTopic bool
|
2017-09-03 04:50:31 +00:00
|
|
|
EditTopic bool
|
2017-02-04 06:19:55 +00:00
|
|
|
DeleteTopic bool
|
|
|
|
CreateReply bool
|
|
|
|
//CreateReplyToOwn bool
|
|
|
|
EditReply bool
|
|
|
|
//EditOwnReply bool
|
|
|
|
DeleteReply bool
|
2017-09-03 04:50:31 +00:00
|
|
|
PinTopic bool
|
|
|
|
CloseTopic bool
|
2017-02-04 06:19:55 +00:00
|
|
|
//CloseOwnTopic bool
|
2017-05-29 14:52:37 +00:00
|
|
|
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
//ExtData map[string]bool
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Inherit from group permissions for ones we don't have */
|
2017-09-03 04:50:31 +00:00
|
|
|
type ForumPerms struct {
|
|
|
|
ViewTopic bool
|
|
|
|
LikeItem bool
|
2017-02-04 06:19:55 +00:00
|
|
|
CreateTopic bool
|
2017-09-03 04:50:31 +00:00
|
|
|
EditTopic bool
|
2017-02-04 06:19:55 +00:00
|
|
|
DeleteTopic bool
|
|
|
|
CreateReply bool
|
|
|
|
//CreateReplyToOwn bool
|
|
|
|
EditReply bool
|
|
|
|
//EditOwnReply bool
|
|
|
|
DeleteReply bool
|
2017-09-03 04:50:31 +00:00
|
|
|
PinTopic bool
|
|
|
|
CloseTopic bool
|
2017-02-04 06:19:55 +00:00
|
|
|
//CloseOwnTopic bool
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
Overrides bool
|
2017-09-03 04:50:31 +00:00
|
|
|
ExtData map[string]bool
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
BlankPerms = Perms{
|
2017-09-03 04:50:31 +00:00
|
|
|
//ExtData: make(map[string]bool),
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
BlankForumPerms = ForumPerms{
|
|
|
|
ExtData: make(map[string]bool),
|
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
GuestPerms = Perms{
|
|
|
|
ViewTopic: true,
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
//ExtData: make(map[string]bool),
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
AllPerms = Perms{
|
2017-09-03 04:50:31 +00:00
|
|
|
BanUsers: true,
|
|
|
|
ActivateUsers: true,
|
|
|
|
EditUser: true,
|
|
|
|
EditUserEmail: true,
|
|
|
|
EditUserPassword: true,
|
|
|
|
EditUserGroup: true,
|
2017-02-04 06:19:55 +00:00
|
|
|
EditUserGroupSuperMod: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
EditUserGroupAdmin: true,
|
|
|
|
EditGroup: true,
|
|
|
|
EditGroupLocalPerms: true,
|
|
|
|
EditGroupGlobalPerms: true,
|
|
|
|
EditGroupSuperMod: true,
|
|
|
|
EditGroupAdmin: true,
|
|
|
|
ManageForums: true,
|
|
|
|
EditSettings: true,
|
|
|
|
ManageThemes: true,
|
|
|
|
ManagePlugins: true,
|
|
|
|
ViewAdminLogs: true,
|
|
|
|
ViewIPs: true,
|
|
|
|
|
|
|
|
ViewTopic: true,
|
|
|
|
LikeItem: true,
|
2017-02-04 06:19:55 +00:00
|
|
|
CreateTopic: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
EditTopic: true,
|
2017-02-04 06:19:55 +00:00
|
|
|
DeleteTopic: true,
|
|
|
|
CreateReply: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
EditReply: true,
|
2017-02-04 06:19:55 +00:00
|
|
|
DeleteReply: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
PinTopic: true,
|
|
|
|
CloseTopic: true,
|
2017-05-29 14:52:37 +00:00
|
|
|
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
//ExtData: make(map[string]bool),
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
AllForumPerms = ForumPerms{
|
2017-09-03 04:50:31 +00:00
|
|
|
ViewTopic: true,
|
|
|
|
LikeItem: true,
|
2017-02-04 06:19:55 +00:00
|
|
|
CreateTopic: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
EditTopic: true,
|
2017-02-04 06:19:55 +00:00
|
|
|
DeleteTopic: true,
|
|
|
|
CreateReply: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
EditReply: true,
|
2017-02-04 06:19:55 +00:00
|
|
|
DeleteReply: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
PinTopic: true,
|
|
|
|
CloseTopic: true,
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
Overrides: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
ExtData: make(map[string]bool),
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
ReadWriteForumPerms = ForumPerms{
|
2017-09-03 04:50:31 +00:00
|
|
|
ViewTopic: true,
|
|
|
|
LikeItem: true,
|
2017-02-04 06:19:55 +00:00
|
|
|
CreateTopic: true,
|
|
|
|
CreateReply: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
Overrides: true,
|
|
|
|
ExtData: make(map[string]bool),
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
ReadReplyForumPerms = ForumPerms{
|
2017-09-03 04:50:31 +00:00
|
|
|
ViewTopic: true,
|
|
|
|
LikeItem: true,
|
2017-02-04 06:19:55 +00:00
|
|
|
CreateReply: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
Overrides: true,
|
|
|
|
ExtData: make(map[string]bool),
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
ReadForumPerms = ForumPerms{
|
|
|
|
ViewTopic: true,
|
|
|
|
Overrides: true,
|
2017-09-03 04:50:31 +00:00
|
|
|
ExtData: make(map[string]bool),
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
guestUser.Perms = GuestPerms
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.DebugMode {
|
2017-08-13 11:22:34 +00:00
|
|
|
log.Printf("Guest Perms: %+v\n", GuestPerms)
|
|
|
|
log.Printf("All Perms: %+v\n", AllPerms)
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func presetToPermmap(preset string) (out map[string]ForumPerms) {
|
2017-02-04 06:19:55 +00:00
|
|
|
out = make(map[string]ForumPerms)
|
2017-09-03 04:50:31 +00:00
|
|
|
switch preset {
|
|
|
|
case "all":
|
|
|
|
out["guests"] = ReadForumPerms
|
|
|
|
out["members"] = ReadWriteForumPerms
|
|
|
|
out["staff"] = AllForumPerms
|
|
|
|
out["admins"] = AllForumPerms
|
|
|
|
case "announce":
|
|
|
|
out["guests"] = ReadForumPerms
|
|
|
|
out["members"] = ReadReplyForumPerms
|
|
|
|
out["staff"] = AllForumPerms
|
|
|
|
out["admins"] = AllForumPerms
|
|
|
|
case "members":
|
|
|
|
out["guests"] = BlankForumPerms
|
|
|
|
out["members"] = ReadWriteForumPerms
|
|
|
|
out["staff"] = AllForumPerms
|
|
|
|
out["admins"] = AllForumPerms
|
|
|
|
case "staff":
|
|
|
|
out["guests"] = BlankForumPerms
|
|
|
|
out["members"] = BlankForumPerms
|
|
|
|
out["staff"] = ReadWriteForumPerms
|
|
|
|
out["admins"] = AllForumPerms
|
|
|
|
case "admins":
|
|
|
|
out["guests"] = BlankForumPerms
|
|
|
|
out["members"] = BlankForumPerms
|
|
|
|
out["staff"] = BlankForumPerms
|
|
|
|
out["admins"] = AllForumPerms
|
|
|
|
case "archive":
|
|
|
|
out["guests"] = ReadForumPerms
|
|
|
|
out["members"] = ReadForumPerms
|
|
|
|
out["staff"] = ReadForumPerms
|
|
|
|
out["admins"] = ReadForumPerms //CurateForumPerms. Delete / Edit but no create?
|
|
|
|
default:
|
|
|
|
out["guests"] = BlankForumPerms
|
|
|
|
out["members"] = BlankForumPerms
|
|
|
|
out["staff"] = BlankForumPerms
|
|
|
|
out["admins"] = BlankForumPerms
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func permmapToQuery(permmap map[string]ForumPerms, fid int) error {
|
|
|
|
permUpdateMutex.Lock()
|
|
|
|
defer permUpdateMutex.Unlock()
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
_, err := deleteForumPermsByForumStmt.Exec(fid)
|
2017-02-04 06:19:55 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
perms, err := json.Marshal(permmap["admins"])
|
2017-03-27 07:09:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-18 17:03:52 +00:00
|
|
|
_, err = addForumPermsToForumAdminsStmt.Exec(fid, "", perms)
|
2017-02-04 06:19:55 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
perms, err = json.Marshal(permmap["staff"])
|
2017-03-27 07:09:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-18 17:03:52 +00:00
|
|
|
_, err = addForumPermsToForumStaffStmt.Exec(fid, "", perms)
|
2017-02-04 06:19:55 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
perms, err = json.Marshal(permmap["members"])
|
2017-03-27 07:09:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-18 17:03:52 +00:00
|
|
|
_, err = addForumPermsToForumMembersStmt.Exec(fid, "", perms)
|
2017-02-04 06:19:55 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
perms, err = json.Marshal(permmap["guests"])
|
2017-03-27 07:09:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-18 17:03:52 +00:00
|
|
|
_, err = addForumPermsToGroupStmt.Exec(6, fid, "", perms)
|
2017-02-04 06:19:55 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
return rebuildForumPermissions(fid)
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
|
|
|
|
2017-09-15 22:20:01 +00:00
|
|
|
// TODO: Need a more thread-safe way of doing this. Possibly with sync.Map?
|
2017-09-03 04:50:31 +00:00
|
|
|
func rebuildForumPermissions(fid int) error {
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.DebugMode {
|
2017-06-14 09:55:47 +00:00
|
|
|
log.Print("Loading the forum permissions")
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
forums, err := fstore.GetAll()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
rows, err := db.Query("select gid, permissions from forums_permissions where fid = ? order by gid asc", fid)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.DebugMode {
|
2017-06-14 09:55:47 +00:00
|
|
|
log.Print("Updating the forum permissions")
|
|
|
|
}
|
2017-02-04 06:19:55 +00:00
|
|
|
for rows.Next() {
|
|
|
|
var gid int
|
|
|
|
var perms []byte
|
|
|
|
var pperms ForumPerms
|
|
|
|
err := rows.Scan(&gid, &perms)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = json.Unmarshal(perms, &pperms)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
pperms.ExtData = make(map[string]bool)
|
|
|
|
pperms.Overrides = true
|
2017-09-03 04:50:31 +00:00
|
|
|
_, ok := forumPerms[gid]
|
2017-02-04 06:19:55 +00:00
|
|
|
if !ok {
|
2017-09-03 04:50:31 +00:00
|
|
|
forumPerms[gid] = make(map[int]ForumPerms)
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
forumPerms[gid][fid] = pperms
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-09-15 22:20:01 +00:00
|
|
|
|
|
|
|
groups, err := gstore.GetAll()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, group := range groups {
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.DebugMode {
|
2017-09-15 22:20:01 +00:00
|
|
|
log.Print("Updating the forum permissions for Group #" + strconv.Itoa(group.ID))
|
2017-06-14 09:55:47 +00:00
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
var blankList []ForumPerms
|
|
|
|
var blankIntList []int
|
2017-09-15 22:20:01 +00:00
|
|
|
group.Forums = blankList
|
|
|
|
group.CanSee = blankIntList
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
for ffid := range forums {
|
2017-09-15 22:20:01 +00:00
|
|
|
forumPerm, ok := forumPerms[group.ID][ffid]
|
2017-02-04 06:19:55 +00:00
|
|
|
if ok {
|
|
|
|
//log.Print("Overriding permissions for forum #" + strconv.Itoa(fid))
|
2017-09-15 22:20:01 +00:00
|
|
|
group.Forums = append(group.Forums, forumPerm)
|
2017-02-04 06:19:55 +00:00
|
|
|
} else {
|
|
|
|
//log.Print("Inheriting from default for forum #" + strconv.Itoa(fid))
|
2017-09-03 04:50:31 +00:00
|
|
|
forumPerm = BlankForumPerms
|
2017-09-15 22:20:01 +00:00
|
|
|
group.Forums = append(group.Forums, forumPerm)
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
if forumPerm.Overrides {
|
|
|
|
if forumPerm.ViewTopic {
|
2017-09-15 22:20:01 +00:00
|
|
|
group.CanSee = append(group.CanSee, ffid)
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
2017-09-15 22:20:01 +00:00
|
|
|
} else if group.Perms.ViewTopic {
|
|
|
|
group.CanSee = append(group.CanSee, ffid)
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.SuperDebug {
|
2017-09-15 22:20:01 +00:00
|
|
|
log.Printf("group.CanSee %+v\n", group.CanSee)
|
|
|
|
log.Printf("group.Forums %+v\n", group.Forums)
|
|
|
|
log.Print("len(group.Forums)", len(group.Forums))
|
2017-06-14 09:55:47 +00:00
|
|
|
}
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
// ? - We could have buildForumPermissions and rebuildForumPermissions call a third function containing common logic?
|
2017-09-03 04:50:31 +00:00
|
|
|
func buildForumPermissions() error {
|
2017-06-28 12:05:26 +00:00
|
|
|
forums, err := fstore.GetAll()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
rows, err := getForumsPermissionsStmt.Query()
|
2017-06-14 09:55:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.DebugMode {
|
2017-06-14 09:55:47 +00:00
|
|
|
log.Print("Adding the forum permissions")
|
|
|
|
}
|
|
|
|
// Temporarily store the forum perms in a map before transferring it to a much faster and thread-safe slice
|
2017-09-03 04:50:31 +00:00
|
|
|
forumPerms = make(map[int]map[int]ForumPerms)
|
2017-06-14 09:55:47 +00:00
|
|
|
for rows.Next() {
|
|
|
|
var gid, fid int
|
|
|
|
var perms []byte
|
|
|
|
var pperms ForumPerms
|
|
|
|
err = rows.Scan(&gid, &fid, &perms)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = json.Unmarshal(perms, &pperms)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
pperms.ExtData = make(map[string]bool)
|
|
|
|
pperms.Overrides = true
|
2017-09-03 04:50:31 +00:00
|
|
|
_, ok := forumPerms[gid]
|
2017-06-14 09:55:47 +00:00
|
|
|
if !ok {
|
2017-09-03 04:50:31 +00:00
|
|
|
forumPerms[gid] = make(map[int]ForumPerms)
|
2017-06-14 09:55:47 +00:00
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
forumPerms[gid][fid] = pperms
|
2017-06-14 09:55:47 +00:00
|
|
|
}
|
2017-09-15 22:20:01 +00:00
|
|
|
|
|
|
|
groups, err := gstore.GetAll()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
for _, group := range groups {
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.DebugMode {
|
2017-09-15 22:20:01 +00:00
|
|
|
log.Print("Adding the forum permissions for Group #" + strconv.Itoa(group.ID) + " - " + group.Name)
|
2017-06-14 09:55:47 +00:00
|
|
|
}
|
|
|
|
//groups[gid].Forums = append(groups[gid].Forums,BlankForumPerms) // GID 0. No longer needed now that Uncategorised occupies that slot
|
2017-09-03 04:50:31 +00:00
|
|
|
for fid := range forums {
|
2017-09-15 22:20:01 +00:00
|
|
|
forumPerm, ok := forumPerms[group.ID][fid]
|
2017-06-14 09:55:47 +00:00
|
|
|
if ok {
|
|
|
|
// Override group perms
|
|
|
|
//log.Print("Overriding permissions for forum #" + strconv.Itoa(fid))
|
2017-09-15 22:20:01 +00:00
|
|
|
group.Forums = append(group.Forums, forumPerm)
|
2017-06-14 09:55:47 +00:00
|
|
|
} else {
|
|
|
|
// Inherit from Group
|
|
|
|
//log.Print("Inheriting from default for forum #" + strconv.Itoa(fid))
|
2017-09-03 04:50:31 +00:00
|
|
|
forumPerm = BlankForumPerms
|
2017-09-15 22:20:01 +00:00
|
|
|
group.Forums = append(group.Forums, forumPerm)
|
2017-06-14 09:55:47 +00:00
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
if forumPerm.Overrides {
|
|
|
|
if forumPerm.ViewTopic {
|
2017-09-15 22:20:01 +00:00
|
|
|
group.CanSee = append(group.CanSee, fid)
|
2017-06-14 09:55:47 +00:00
|
|
|
}
|
2017-09-15 22:20:01 +00:00
|
|
|
} else if group.Perms.ViewTopic {
|
|
|
|
group.CanSee = append(group.CanSee, fid)
|
2017-06-14 09:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.SuperDebug {
|
2017-08-13 11:22:34 +00:00
|
|
|
//log.Printf("groups[gid].CanSee %+v\n", groups[gid].CanSee)
|
|
|
|
//log.Printf("groups[gid].Forums %+v\n", groups[gid].Forums)
|
|
|
|
//log.Print("len(groups[gid].CanSee)",len(groups[gid].CanSee))
|
|
|
|
//log.Print("len(groups[gid].Forums)",len(groups[gid].Forums))
|
2017-06-14 09:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-04 06:19:55 +00:00
|
|
|
return nil
|
|
|
|
}
|
2017-02-04 15:49:24 +00:00
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func forumPermsToGroupForumPreset(fperms ForumPerms) string {
|
2017-06-05 11:57:27 +00:00
|
|
|
if !fperms.Overrides {
|
|
|
|
return "default"
|
|
|
|
}
|
|
|
|
if !fperms.ViewTopic {
|
|
|
|
return "no_access"
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
var canPost = (fperms.LikeItem && fperms.CreateTopic && fperms.CreateReply)
|
|
|
|
var canModerate = (canPost && fperms.EditTopic && fperms.DeleteTopic && fperms.EditReply && fperms.DeleteReply && fperms.PinTopic && fperms.CloseTopic)
|
|
|
|
if canModerate {
|
2017-06-05 11:57:27 +00:00
|
|
|
return "can_moderate"
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
if fperms.EditTopic || fperms.DeleteTopic || fperms.EditReply || fperms.DeleteReply || fperms.PinTopic || fperms.CloseTopic {
|
|
|
|
if !canPost {
|
2017-06-05 11:57:27 +00:00
|
|
|
return "custom"
|
|
|
|
}
|
|
|
|
return "quasi_mod"
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
if canPost {
|
2017-06-05 11:57:27 +00:00
|
|
|
return "can_post"
|
|
|
|
}
|
|
|
|
if fperms.ViewTopic && !fperms.LikeItem && !fperms.CreateTopic && !fperms.CreateReply {
|
|
|
|
return "read_only"
|
|
|
|
}
|
|
|
|
return "custom"
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func groupForumPresetToForumPerms(preset string) (fperms ForumPerms, changed bool) {
|
|
|
|
switch preset {
|
|
|
|
case "read_only":
|
|
|
|
return ReadForumPerms, true
|
|
|
|
case "can_post":
|
|
|
|
return ReadWriteForumPerms, true
|
|
|
|
case "can_moderate":
|
|
|
|
return AllForumPerms, true
|
|
|
|
case "no_access":
|
|
|
|
return ForumPerms{Overrides: true, ExtData: make(map[string]bool)}, true
|
|
|
|
case "default":
|
|
|
|
return BlankForumPerms, true
|
2017-06-05 11:57:27 +00:00
|
|
|
//case "custom": return fperms, false
|
|
|
|
}
|
|
|
|
return fperms, false
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func stripInvalidGroupForumPreset(preset string) string {
|
|
|
|
switch preset {
|
|
|
|
case "read_only", "can_post", "can_moderate", "no_access", "default", "custom":
|
|
|
|
return preset
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func stripInvalidPreset(preset string) string {
|
|
|
|
switch preset {
|
|
|
|
case "all", "announce", "members", "staff", "admins", "archive", "custom":
|
|
|
|
return preset
|
|
|
|
default:
|
|
|
|
return ""
|
2017-02-04 15:49:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Move this into the phrase system?
|
2017-09-03 04:50:31 +00:00
|
|
|
func presetToLang(preset string) string {
|
|
|
|
switch preset {
|
|
|
|
case "all":
|
|
|
|
return "Public"
|
|
|
|
case "announce":
|
|
|
|
return "Announcements"
|
|
|
|
case "members":
|
|
|
|
return "Member Only"
|
|
|
|
case "staff":
|
|
|
|
return "Staff Only"
|
|
|
|
case "admins":
|
|
|
|
return "Admin Only"
|
|
|
|
case "archive":
|
|
|
|
return "Archive"
|
|
|
|
case "custom":
|
|
|
|
return "Custom"
|
|
|
|
default:
|
|
|
|
return ""
|
2017-02-04 15:49:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Is this racey?
|
2017-09-03 04:50:31 +00:00
|
|
|
func rebuildGroupPermissions(gid int) error {
|
2017-03-23 12:13:50 +00:00
|
|
|
var permstr []byte
|
|
|
|
log.Print("Reloading a group")
|
2017-09-03 04:50:31 +00:00
|
|
|
err := db.QueryRow("select permissions from users_groups where gid = ?", gid).Scan(&permstr)
|
2017-03-23 12:13:50 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
tmpPerms := Perms{
|
2017-09-03 04:50:31 +00:00
|
|
|
//ExtData: make(map[string]bool),
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
}
|
2017-09-10 16:57:22 +00:00
|
|
|
err = json.Unmarshal(permstr, &tmpPerms)
|
2017-03-23 12:13:50 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-09-15 22:20:01 +00:00
|
|
|
group, err := gstore.Get(gid)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
group.Perms = tmpPerms
|
2017-03-23 12:13:50 +00:00
|
|
|
return nil
|
|
|
|
}
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func overridePerms(perms *Perms, status bool) {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
if status {
|
|
|
|
*perms = AllPerms
|
|
|
|
} else {
|
|
|
|
*perms = BlankPerms
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: We need a better way of overriding forum perms rather than setting them one by one
|
2017-09-03 04:50:31 +00:00
|
|
|
func overrideForumPerms(perms *Perms, status bool) {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
perms.ViewTopic = status
|
|
|
|
perms.LikeItem = status
|
|
|
|
perms.CreateTopic = status
|
|
|
|
perms.EditTopic = status
|
|
|
|
perms.DeleteTopic = status
|
|
|
|
perms.CreateReply = status
|
|
|
|
perms.EditReply = status
|
|
|
|
perms.DeleteReply = status
|
|
|
|
perms.PinTopic = status
|
|
|
|
perms.CloseTopic = status
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func registerPluginPerm(name string) {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
AllPluginPerms[name] = true
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func deregisterPluginPerm(name string) {
|
|
|
|
delete(AllPluginPerms, name)
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
}
|