2017-11-10 03:33:11 +00:00
|
|
|
package common
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-10-21 00:27:47 +00:00
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"encoding/json"
|
|
|
|
"log"
|
|
|
|
"sync"
|
2017-11-11 04:06:16 +00:00
|
|
|
|
|
|
|
"../query_gen/lib"
|
2017-10-21 00:27:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// TODO: Refactor the perms system
|
2017-02-04 06:19:55 +00:00
|
|
|
|
2017-11-11 04:06:16 +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
|
2017-11-11 04:06:16 +00:00
|
|
|
|
|
|
|
// AllPerms is a set of global permissions with everything set to true
|
2017-02-04 06:19:55 +00:00
|
|
|
var AllPerms Perms
|
2017-11-11 04:06:16 +00:00
|
|
|
|
|
|
|
// AllForumPerms is a set of forum local permissions with everything set to true
|
2017-02-04 06:19:55 +00:00
|
|
|
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
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
// ? - Can we avoid duplicating the items in this list in a bunch of places?
|
|
|
|
|
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",
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
// ? - Can we avoid duplicating the items in this list in a bunch of places?
|
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",
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
"UploadFiles",
|
2017-03-23 12:13:50 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
// Global non-staff permissions
|
|
|
|
UploadFiles bool
|
|
|
|
// TODO: Add a permission for enabling avatars
|
|
|
|
|
2017-02-04 06:19:55 +00:00
|
|
|
// Forum permissions
|
2017-11-10 00:16:15 +00:00
|
|
|
ViewTopic bool
|
|
|
|
//ViewOwnTopic bool
|
2017-09-03 04:50:31 +00:00
|
|
|
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 {
|
2017-11-10 00:16:15 +00:00
|
|
|
ViewTopic bool
|
|
|
|
//ViewOwnTopic bool
|
2017-09-03 04:50:31 +00:00
|
|
|
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,
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
UploadFiles: true,
|
|
|
|
|
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
|
|
|
|
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-11-11 04:06:16 +00:00
|
|
|
GuestUser.Perms = GuestPerms
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-11-11 04:06:16 +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-11-11 04:06:16 +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-11-11 04:06:16 +00:00
|
|
|
func PermmapToQuery(permmap map[string]ForumPerms, fid int) error {
|
|
|
|
tx, err := qgen.Builder.Begin()
|
2017-10-21 00:27:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer tx.Rollback()
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-10-21 00:27:47 +00:00
|
|
|
deleteForumPermsByForumTx, err := qgen.Builder.SimpleDeleteTx(tx, "forums_permissions", "fid = ?")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = deleteForumPermsByForumTx.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-10-21 00:27:47 +00:00
|
|
|
|
|
|
|
addForumPermsToForumAdminsTx, err := qgen.Builder.SimpleInsertSelectTx(tx,
|
2017-11-12 05:25:04 +00:00
|
|
|
qgen.DBInsert{"forums_permissions", "gid, fid, preset, permissions", ""},
|
|
|
|
qgen.DBSelect{"users_groups", "gid, ? AS fid, ? AS preset, ? AS permissions", "is_admin = 1", "", ""},
|
2017-10-21 00:27:47 +00:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = addForumPermsToForumAdminsTx.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-10-21 00:27:47 +00:00
|
|
|
|
|
|
|
addForumPermsToForumStaffTx, err := qgen.Builder.SimpleInsertSelectTx(tx,
|
2017-11-12 05:25:04 +00:00
|
|
|
qgen.DBInsert{"forums_permissions", "gid, fid, preset, permissions", ""},
|
|
|
|
qgen.DBSelect{"users_groups", "gid, ? AS fid, ? AS preset, ? AS permissions", "is_admin = 0 AND is_mod = 1", "", ""},
|
2017-10-21 00:27:47 +00:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err = addForumPermsToForumStaffTx.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-10-21 00:27:47 +00:00
|
|
|
|
|
|
|
addForumPermsToForumMembersTx, err := qgen.Builder.SimpleInsertSelectTx(tx,
|
2017-11-12 05:25:04 +00:00
|
|
|
qgen.DBInsert{"forums_permissions", "gid, fid, preset, permissions", ""},
|
|
|
|
qgen.DBSelect{"users_groups", "gid, ? AS fid, ? AS preset, ? AS permissions", "is_admin = 0 AND is_mod = 0 AND is_banned = 0", "", ""},
|
2017-10-21 00:27:47 +00:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err = addForumPermsToForumMembersTx.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-10-21 00:27:47 +00:00
|
|
|
// 6 is the ID of the Not Loggedin Group
|
|
|
|
// TODO: Use a shared variable rather than a literal for the group ID
|
2017-11-11 04:06:16 +00:00
|
|
|
err = ReplaceForumPermsForGroupTx(tx, 6, map[int]string{fid: ""}, map[int]ForumPerms{fid: permmap["guests"]})
|
2017-03-27 07:09:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-10-21 00:27:47 +00:00
|
|
|
|
|
|
|
err = tx.Commit()
|
2017-02-04 06:19:55 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-29 14:52:37 +00:00
|
|
|
|
2017-11-11 04:06:16 +00:00
|
|
|
PermUpdateMutex.Lock()
|
|
|
|
defer PermUpdateMutex.Unlock()
|
|
|
|
return Fpstore.Reload(fid)
|
2017-02-04 06:19:55 +00:00
|
|
|
}
|
|
|
|
|
2017-11-11 04:06:16 +00:00
|
|
|
func ReplaceForumPermsForGroup(gid int, presetSet map[int]string, permSets map[int]ForumPerms) error {
|
|
|
|
tx, err := qgen.Builder.Begin()
|
2017-10-21 00:27:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer tx.Rollback()
|
2017-11-11 04:06:16 +00:00
|
|
|
err = ReplaceForumPermsForGroupTx(tx, gid, presetSet, permSets)
|
2017-10-21 00:27:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return tx.Commit()
|
|
|
|
}
|
|
|
|
|
2017-11-11 04:06:16 +00:00
|
|
|
func ReplaceForumPermsForGroupTx(tx *sql.Tx, gid int, presetSets map[int]string, permSets map[int]ForumPerms) error {
|
2017-10-21 00:27:47 +00:00
|
|
|
deleteForumPermsForGroupTx, err := qgen.Builder.SimpleDeleteTx(tx, "forums_permissions", "gid = ? AND fid = ?")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
addForumPermsToGroupTx, err := qgen.Builder.SimpleInsertTx(tx, "forums_permissions", "gid, fid, preset, permissions", "?,?,?,?")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for fid, permSet := range permSets {
|
|
|
|
permstr, err := json.Marshal(permSet)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err = deleteForumPermsForGroupTx.Exec(gid, fid)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err = addForumPermsToGroupTx.Exec(gid, fid, presetSets[fid], string(permstr))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-11-05 01:04:57 +00:00
|
|
|
// TODO: Refactor this and write tests for it
|
2017-11-11 04:06:16 +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-11-11 04:06:16 +00:00
|
|
|
func GroupForumPresetToForumPerms(preset string) (fperms ForumPerms, changed bool) {
|
2017-09-03 04:50:31 +00:00
|
|
|
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-11-11 04:06:16 +00:00
|
|
|
func StripInvalidGroupForumPreset(preset string) string {
|
2017-09-03 04:50:31 +00:00
|
|
|
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-11-11 04:06:16 +00:00
|
|
|
func StripInvalidPreset(preset string) string {
|
2017-09-03 04:50:31 +00:00
|
|
|
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-11-11 04:06:16 +00:00
|
|
|
func PresetToLang(preset string) string {
|
2017-11-05 01:04:57 +00:00
|
|
|
phrases := GetAllPermPresets()
|
|
|
|
phrase, ok := phrases[preset]
|
|
|
|
if !ok {
|
|
|
|
phrase = phrases["unknown"]
|
2017-02-04 15:49:24 +00:00
|
|
|
}
|
2017-11-05 01:04:57 +00:00
|
|
|
return phrase
|
2017-02-04 15:49:24 +00:00
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Is this racey?
|
2017-11-11 04:06:16 +00:00
|
|
|
// TODO: Test this along with the rest of the perms system
|
|
|
|
func RebuildGroupPermissions(gid int) error {
|
2017-03-23 12:13:50 +00:00
|
|
|
var permstr []byte
|
|
|
|
log.Print("Reloading a group")
|
2017-11-11 04:06:16 +00:00
|
|
|
|
|
|
|
// TODO: Avoid re-initting this all the time
|
|
|
|
getGroupPerms, err := qgen.Builder.SimpleSelect("users_groups", "permissions", "gid = ?", "", "")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-11-11 23:34:27 +00:00
|
|
|
defer getGroupPerms.Close()
|
2017-11-11 04:06:16 +00:00
|
|
|
|
|
|
|
err = getGroupPerms.QueryRow(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-11-11 04:06:16 +00:00
|
|
|
group, err := Gstore.Get(gid)
|
2017-09-15 22:20:01 +00:00
|
|
|
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-11-11 04:06:16 +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-11-11 04:06:16 +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-11-11 04:06:16 +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-11-11 04:06:16 +00:00
|
|
|
func DeregisterPluginPerm(name string) {
|
2017-09-03 04:50:31 +00:00
|
|
|
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
|
|
|
}
|