2017-06-05 11:57:27 +00:00
|
|
|
/* WIP Under Construction */
|
2017-06-13 07:12:58 +00:00
|
|
|
package qgen
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-06-06 08:47:33 +00:00
|
|
|
//import "fmt"
|
2017-06-05 11:57:27 +00:00
|
|
|
import "strings"
|
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
|
|
|
import "strconv"
|
2017-06-05 11:57:27 +00:00
|
|
|
import "errors"
|
|
|
|
|
|
|
|
func init() {
|
2017-06-13 07:12:58 +00:00
|
|
|
DB_Registry = append(DB_Registry,
|
2017-07-12 11:05:18 +00:00
|
|
|
&Mysql_Adapter{Name:"mysql",Buffer:make(map[string]DB_Stmt)},
|
2017-06-13 07:12:58 +00:00
|
|
|
)
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Mysql_Adapter struct
|
|
|
|
{
|
|
|
|
Name string
|
2017-07-12 11:05:18 +00:00
|
|
|
Buffer map[string]DB_Stmt
|
2017-06-13 07:12:58 +00:00
|
|
|
BufferOrder []string // Map iteration order is random, so we need this to track the order, so we don't get huge diffs every commit
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 07:12:58 +00:00
|
|
|
func (adapter *Mysql_Adapter) GetName() string {
|
2017-06-05 11:57:27 +00:00
|
|
|
return adapter.Name
|
|
|
|
}
|
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Mysql_Adapter) GetStmt(name string) DB_Stmt {
|
2017-06-13 07:12:58 +00:00
|
|
|
return adapter.Buffer[name]
|
|
|
|
}
|
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Mysql_Adapter) GetStmts() map[string]DB_Stmt {
|
2017-06-13 07:12:58 +00:00
|
|
|
return adapter.Buffer
|
|
|
|
}
|
|
|
|
|
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
|
|
|
func (adapter *Mysql_Adapter) CreateTable(name string, table string, charset string, collation string, columns []DB_Table_Column, keys []DB_Table_Key) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table == "" {
|
|
|
|
return "", errors.New("You need a name for this table")
|
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
|
|
|
return "", errors.New("You can't have a table with no columns")
|
|
|
|
}
|
|
|
|
|
|
|
|
var querystr string = "CREATE TABLE `" + table + "` ("
|
|
|
|
for _, column := range columns {
|
|
|
|
// Make it easier to support Cassandra in the future
|
|
|
|
if column.Type == "createdAt" {
|
|
|
|
column.Type = "datetime"
|
|
|
|
}
|
|
|
|
|
|
|
|
var size string
|
|
|
|
if column.Size > 0 {
|
|
|
|
size = "(" + strconv.Itoa(column.Size) + ")"
|
|
|
|
}
|
|
|
|
|
|
|
|
var end string
|
2017-07-12 11:05:18 +00:00
|
|
|
// TO-DO: Exclude the other variants of text like mediumtext and longtext too
|
|
|
|
if column.Default != "" && column.Type != "text" {
|
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
|
|
|
end = " DEFAULT "
|
2017-07-12 11:05:18 +00:00
|
|
|
if adapter.stringy_type(column.Type) && column.Default != "''" {
|
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
|
|
|
end += "'" + column.Default + "'"
|
|
|
|
} else {
|
|
|
|
end += column.Default
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if column.Null {
|
|
|
|
end += " null"
|
|
|
|
} else {
|
|
|
|
end += " not null"
|
|
|
|
}
|
|
|
|
|
|
|
|
if column.Auto_Increment {
|
|
|
|
end += " AUTO_INCREMENT"
|
|
|
|
}
|
|
|
|
|
|
|
|
querystr += "\n\t`"+column.Name+"` " + column.Type + size + end + ","
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(keys) > 0 {
|
|
|
|
for _, key := range keys {
|
2017-07-12 11:05:18 +00:00
|
|
|
querystr += "\n\t" + key.Type
|
|
|
|
if key.Type != "unique" {
|
|
|
|
querystr += " key"
|
|
|
|
}
|
|
|
|
querystr += "("
|
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
|
|
|
for _, column := range strings.Split(key.Columns,",") {
|
|
|
|
querystr += "`" + column + "`,"
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1] + "),"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
querystr = querystr[0:len(querystr) - 1] + "\n)"
|
|
|
|
if charset != "" {
|
|
|
|
querystr += " CHARSET=" + charset
|
|
|
|
}
|
|
|
|
if collation != "" {
|
|
|
|
querystr += " COLLATE " + collation
|
|
|
|
}
|
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"create-table",querystr + ";")
|
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
|
|
|
return querystr + ";", nil
|
|
|
|
}
|
|
|
|
|
2017-06-13 08:56:48 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleInsert(name string, table string, columns string, fields string) (string, error) {
|
2017-06-05 11:57:27 +00:00
|
|
|
if name == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this statement")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
if table == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this table")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("No columns found for SimpleInsert")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
if len(fields) == 0 {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("No input data found for SimpleInsert")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
2017-06-07 10:07:40 +00:00
|
|
|
var querystr string = "INSERT INTO `" + table + "`("
|
2017-06-05 11:57:27 +00:00
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
2017-06-06 14:41:06 +00:00
|
|
|
for _, column := range _process_columns(columns) {
|
|
|
|
if column.Type == "function" {
|
|
|
|
querystr += column.Left + ","
|
|
|
|
} else {
|
|
|
|
querystr += "`" + column.Left + "`,"
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove the trailing comma
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
|
|
|
querystr += ") VALUES ("
|
2017-06-06 14:41:06 +00:00
|
|
|
for _, field := range _process_fields(fields) {
|
|
|
|
querystr += field.Name + ","
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"insert",querystr + ")")
|
2017-06-13 08:56:48 +00:00
|
|
|
return querystr + ")", nil
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 08:56:48 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleReplace(name string, table string, columns string, fields string) (string, error) {
|
2017-06-10 07:58:15 +00:00
|
|
|
if name == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this statement")
|
2017-06-10 07:58:15 +00:00
|
|
|
}
|
|
|
|
if table == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this table")
|
2017-06-10 07:58:15 +00:00
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("No columns found for SimpleInsert")
|
2017-06-10 07:58:15 +00:00
|
|
|
}
|
|
|
|
if len(fields) == 0 {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("No input data found for SimpleInsert")
|
2017-06-10 07:58:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var querystr string = "REPLACE INTO `" + table + "`("
|
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
|
|
|
for _, column := range _process_columns(columns) {
|
|
|
|
if column.Type == "function" {
|
|
|
|
querystr += column.Left + ","
|
|
|
|
} else {
|
|
|
|
querystr += "`" + column.Left + "`,"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Remove the trailing comma
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
|
|
|
querystr += ") VALUES ("
|
|
|
|
for _, field := range _process_fields(fields) {
|
|
|
|
querystr += field.Name + ","
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"replace",querystr + ")")
|
2017-06-13 08:56:48 +00:00
|
|
|
return querystr + ")", nil
|
2017-06-10 07:58:15 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 08:56:48 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleUpdate(name string, table string, set string, where string) (string, error) {
|
2017-06-07 10:07:40 +00:00
|
|
|
if name == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this statement")
|
2017-06-07 10:07:40 +00:00
|
|
|
}
|
|
|
|
if table == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this table")
|
2017-06-07 10:07:40 +00:00
|
|
|
}
|
|
|
|
if set == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need to set data in this update statement")
|
2017-06-07 10:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var querystr string = "UPDATE `" + table + "` SET "
|
|
|
|
for _, item := range _process_set(set) {
|
|
|
|
querystr += "`" + item.Column + "` ="
|
|
|
|
for _, token := range item.Expr {
|
|
|
|
switch(token.Type) {
|
|
|
|
case "function","operator","number","substitute":
|
|
|
|
querystr += " " + token.Contents + ""
|
|
|
|
case "column":
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
querystr += ","
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove the trailing comma
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
2017-06-19 08:06:54 +00:00
|
|
|
// Add support for BETWEEN x.x
|
2017-06-07 10:07:40 +00:00
|
|
|
if len(where) != 0 {
|
|
|
|
querystr += " WHERE"
|
|
|
|
for _, loc := range _process_where(where) {
|
2017-06-19 08:06:54 +00:00
|
|
|
for _, token := range loc.Expr {
|
|
|
|
switch(token.Type) {
|
|
|
|
case "function","operator","number","substitute":
|
|
|
|
querystr += " " + token.Contents + ""
|
|
|
|
case "column":
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
default:
|
|
|
|
panic("This token doesn't exist o_o")
|
|
|
|
}
|
2017-06-07 10:07:40 +00:00
|
|
|
}
|
2017-06-19 08:06:54 +00:00
|
|
|
querystr += " AND"
|
2017-06-07 10:07:40 +00:00
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
|
|
|
}
|
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"update",querystr)
|
2017-06-13 08:56:48 +00:00
|
|
|
return querystr, nil
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 08:56:48 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleDelete(name string, table string, where string) (string, error) {
|
2017-06-12 09:03:14 +00:00
|
|
|
if name == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this statement")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
if table == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this table")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
if where == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need to specify what data you want to delete")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var querystr string = "DELETE FROM `" + table + "` WHERE"
|
2017-06-19 08:06:54 +00:00
|
|
|
|
|
|
|
// Add support for BETWEEN x.x
|
2017-06-12 09:03:14 +00:00
|
|
|
for _, loc := range _process_where(where) {
|
2017-06-19 08:06:54 +00:00
|
|
|
for _, token := range loc.Expr {
|
|
|
|
switch(token.Type) {
|
|
|
|
case "function","operator","number","substitute":
|
|
|
|
querystr += " " + token.Contents + ""
|
|
|
|
case "column":
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
default:
|
|
|
|
panic("This token doesn't exist o_o")
|
|
|
|
}
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
2017-06-19 08:06:54 +00:00
|
|
|
querystr += " AND"
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 08:56:48 +00:00
|
|
|
querystr = strings.TrimSpace(querystr[0:len(querystr) - 4])
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"delete",querystr)
|
2017-06-13 08:56:48 +00:00
|
|
|
return querystr, nil
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// We don't want to accidentally wipe tables, so we'll have a seperate method for purging tables instead
|
2017-06-13 08:56:48 +00:00
|
|
|
func (adapter *Mysql_Adapter) Purge(name string, table string) (string, error) {
|
2017-06-12 09:03:14 +00:00
|
|
|
if name == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this statement")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
if table == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this table")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"purge","DELETE FROM `" + table + "`")
|
2017-06-13 08:56:48 +00:00
|
|
|
return "DELETE FROM `" + table + "`", nil
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 11:40:35 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleSelect(name string, table string, columns string, where string, orderby string, limit string) (string, error) {
|
2017-06-05 11:57:27 +00:00
|
|
|
if name == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this statement")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
if table == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this table")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("No columns found for SimpleSelect")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Slice up the user friendly strings into something easier to process
|
|
|
|
var colslice []string = strings.Split(strings.TrimSpace(columns),",")
|
|
|
|
|
|
|
|
var querystr string = "SELECT "
|
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
|
|
|
for _, column := range colslice {
|
|
|
|
querystr += "`" + strings.TrimSpace(column) + "`,"
|
|
|
|
}
|
|
|
|
// Remove the trailing comma
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
2017-06-07 10:07:40 +00:00
|
|
|
querystr += " FROM `" + table + "`"
|
2017-06-19 08:06:54 +00:00
|
|
|
|
|
|
|
// Add support for BETWEEN x.x
|
2017-06-05 11:57:27 +00:00
|
|
|
if len(where) != 0 {
|
2017-06-07 10:07:40 +00:00
|
|
|
querystr += " WHERE"
|
2017-06-05 11:57:27 +00:00
|
|
|
for _, loc := range _process_where(where) {
|
2017-06-19 08:06:54 +00:00
|
|
|
for _, token := range loc.Expr {
|
|
|
|
switch(token.Type) {
|
|
|
|
case "function","operator","number","substitute":
|
|
|
|
querystr += " " + token.Contents + ""
|
|
|
|
case "column":
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
default:
|
|
|
|
panic("This token doesn't exist o_o")
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
2017-06-19 08:06:54 +00:00
|
|
|
querystr += " AND"
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
2017-06-06 08:47:33 +00:00
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(orderby) != 0 {
|
|
|
|
querystr += " ORDER BY "
|
2017-06-06 08:47:33 +00:00
|
|
|
for _, column := range _process_orderby(orderby) {
|
|
|
|
querystr += column.Column + " " + strings.ToUpper(column.Order) + ","
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
2017-06-06 08:47:33 +00:00
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 11:40:35 +00:00
|
|
|
if limit != "" {
|
|
|
|
querystr += " LIMIT " + limit
|
|
|
|
}
|
|
|
|
|
2017-06-13 08:56:48 +00:00
|
|
|
querystr = strings.TrimSpace(querystr)
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"select",querystr)
|
2017-06-13 08:56:48 +00:00
|
|
|
return querystr, nil
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 11:40:35 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleLeftJoin(name string, table1 string, table2 string, columns string, joiners string, where string, orderby string, limit string) (string, error) {
|
2017-06-05 11:57:27 +00:00
|
|
|
if name == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this statement")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
if table1 == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for the left table")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
if table2 == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for the right table")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("No columns found for SimpleLeftJoin")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
if len(joiners) == 0 {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("No joiners found for SimpleLeftJoin")
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var querystr string = "SELECT "
|
|
|
|
|
2017-06-06 08:47:33 +00:00
|
|
|
for _, column := range _process_columns(columns) {
|
|
|
|
var source, alias string
|
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
|
|
|
if column.Table != "" {
|
|
|
|
source = "`" + column.Table + "`.`" + column.Left + "`"
|
|
|
|
} else if column.Type == "function" {
|
|
|
|
source = column.Left
|
|
|
|
} else {
|
|
|
|
source = "`" + column.Left + "`"
|
|
|
|
}
|
|
|
|
|
|
|
|
if column.Alias != "" {
|
|
|
|
alias = " AS `" + column.Alias + "`"
|
|
|
|
}
|
|
|
|
querystr += source + alias + ","
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove the trailing comma
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
2017-06-07 10:07:40 +00:00
|
|
|
querystr += " FROM `" + table1 + "` LEFT JOIN `" + table2 + "` ON "
|
2017-06-06 08:47:33 +00:00
|
|
|
for _, joiner := range _process_joiner(joiners) {
|
2017-06-12 09:03:14 +00:00
|
|
|
querystr += "`" + joiner.LeftTable + "`.`" + joiner.LeftColumn + "` " + joiner.Operator + " `" + joiner.RightTable + "`.`" + joiner.RightColumn + "` AND "
|
|
|
|
}
|
|
|
|
// Remove the trailing AND
|
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
|
|
|
|
2017-06-19 08:06:54 +00:00
|
|
|
// Add support for BETWEEN x.x
|
2017-06-12 09:03:14 +00:00
|
|
|
if len(where) != 0 {
|
|
|
|
querystr += " WHERE"
|
|
|
|
for _, loc := range _process_where(where) {
|
2017-06-19 08:06:54 +00:00
|
|
|
for _, token := range loc.Expr {
|
|
|
|
switch(token.Type) {
|
|
|
|
case "function","operator","number","substitute":
|
|
|
|
querystr += " " + token.Contents + ""
|
|
|
|
case "column":
|
|
|
|
halves := strings.Split(token.Contents,".")
|
|
|
|
if len(halves) == 2 {
|
|
|
|
querystr += " `" + halves[0] + "`.`" + halves[1] + "`"
|
|
|
|
} else {
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
}
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
default:
|
|
|
|
panic("This token doesn't exist o_o")
|
|
|
|
}
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
2017-06-19 08:06:54 +00:00
|
|
|
querystr += " AND"
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(orderby) != 0 {
|
|
|
|
querystr += " ORDER BY "
|
|
|
|
for _, column := range _process_orderby(orderby) {
|
|
|
|
querystr += column.Column + " " + strings.ToUpper(column.Order) + ","
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
}
|
|
|
|
|
2017-06-15 11:40:35 +00:00
|
|
|
if limit != "" {
|
|
|
|
querystr += " LIMIT " + limit
|
|
|
|
}
|
|
|
|
|
2017-06-13 08:56:48 +00:00
|
|
|
querystr = strings.TrimSpace(querystr)
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"select",querystr)
|
2017-06-13 08:56:48 +00:00
|
|
|
return querystr, nil
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 11:40:35 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleInnerJoin(name string, table1 string, table2 string, columns string, joiners string, where string, orderby string, limit string) (string, error) {
|
2017-06-12 09:03:14 +00:00
|
|
|
if name == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for this statement")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
if table1 == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for the left table")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
if table2 == "" {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("You need a name for the right table")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("No columns found for SimpleInnerJoin")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
if len(joiners) == 0 {
|
2017-06-13 08:56:48 +00:00
|
|
|
return "", errors.New("No joiners found for SimpleInnerJoin")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var querystr string = "SELECT "
|
|
|
|
|
|
|
|
for _, column := range _process_columns(columns) {
|
|
|
|
var source, alias string
|
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
|
|
|
if column.Table != "" {
|
|
|
|
source = "`" + column.Table + "`.`" + column.Left + "`"
|
|
|
|
} else if column.Type == "function" {
|
|
|
|
source = column.Left
|
|
|
|
} else {
|
|
|
|
source = "`" + column.Left + "`"
|
|
|
|
}
|
|
|
|
|
|
|
|
if column.Alias != "" {
|
|
|
|
alias = " AS `" + column.Alias + "`"
|
|
|
|
}
|
|
|
|
querystr += source + alias + ","
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove the trailing comma
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
|
|
|
querystr += " FROM `" + table1 + "` INNER JOIN `" + table2 + "` ON "
|
|
|
|
for _, joiner := range _process_joiner(joiners) {
|
|
|
|
querystr += "`" + joiner.LeftTable + "`.`" + joiner.LeftColumn + "` " + joiner.Operator + " `" + joiner.RightTable + "`.`" + joiner.RightColumn + "` AND "
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
// Remove the trailing AND
|
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
|
|
|
|
2017-06-19 08:06:54 +00:00
|
|
|
// Add support for BETWEEN x.x
|
2017-06-05 11:57:27 +00:00
|
|
|
if len(where) != 0 {
|
2017-06-07 10:07:40 +00:00
|
|
|
querystr += " WHERE"
|
2017-06-05 11:57:27 +00:00
|
|
|
for _, loc := range _process_where(where) {
|
2017-06-19 08:06:54 +00:00
|
|
|
for _, token := range loc.Expr {
|
|
|
|
switch(token.Type) {
|
|
|
|
case "function","operator","number","substitute":
|
|
|
|
querystr += " " + token.Contents + ""
|
|
|
|
case "column":
|
|
|
|
halves := strings.Split(token.Contents,".")
|
|
|
|
if len(halves) == 2 {
|
|
|
|
querystr += " `" + halves[0] + "`.`" + halves[1] + "`"
|
|
|
|
} else {
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
}
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
default:
|
|
|
|
panic("This token doesn't exist o_o")
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
2017-06-19 08:06:54 +00:00
|
|
|
querystr += " AND"
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
2017-06-06 14:41:06 +00:00
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(orderby) != 0 {
|
|
|
|
querystr += " ORDER BY "
|
2017-06-06 08:47:33 +00:00
|
|
|
for _, column := range _process_orderby(orderby) {
|
|
|
|
querystr += column.Column + " " + strings.ToUpper(column.Order) + ","
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
2017-06-06 08:47:33 +00:00
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 11:40:35 +00:00
|
|
|
if limit != "" {
|
|
|
|
querystr += " LIMIT " + limit
|
|
|
|
}
|
|
|
|
|
2017-06-13 08:56:48 +00:00
|
|
|
querystr = strings.TrimSpace(querystr)
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"select",querystr)
|
2017-06-14 07:09:44 +00:00
|
|
|
return querystr, nil
|
|
|
|
}
|
|
|
|
|
2017-06-19 08:06:54 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleInsertSelect(name string, ins DB_Insert, sel DB_Select) (string, error) {
|
|
|
|
/* Insert Portion */
|
2017-06-25 09:56:39 +00:00
|
|
|
|
2017-06-19 08:06:54 +00:00
|
|
|
var querystr string = "INSERT INTO `" + ins.Table + "`("
|
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
|
|
|
for _, column := range _process_columns(ins.Columns) {
|
|
|
|
if column.Type == "function" {
|
|
|
|
querystr += column.Left + ","
|
|
|
|
} else {
|
|
|
|
querystr += "`" + column.Left + "`,"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1] + ") SELECT"
|
|
|
|
|
|
|
|
/* Select Portion */
|
|
|
|
|
|
|
|
for _, column := range _process_columns(sel.Columns) {
|
|
|
|
var source, alias string
|
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
|
|
|
if column.Type == "function" || column.Type == "substitute" {
|
|
|
|
source = column.Left
|
|
|
|
} else {
|
|
|
|
source = "`" + column.Left + "`"
|
|
|
|
}
|
|
|
|
|
|
|
|
if column.Alias != "" {
|
|
|
|
alias = " AS `" + column.Alias + "`"
|
|
|
|
}
|
|
|
|
querystr += " " + source + alias + ","
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
|
|
|
querystr += " FROM `" + sel.Table + "`"
|
|
|
|
|
|
|
|
// Add support for BETWEEN x.x
|
|
|
|
if len(sel.Where) != 0 {
|
|
|
|
querystr += " WHERE"
|
|
|
|
for _, loc := range _process_where(sel.Where) {
|
|
|
|
for _, token := range loc.Expr {
|
|
|
|
switch(token.Type) {
|
|
|
|
case "function","operator","number","substitute":
|
|
|
|
querystr += " " + token.Contents + ""
|
|
|
|
case "column":
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
default:
|
|
|
|
panic("This token doesn't exist o_o")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
querystr += " AND"
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(sel.Orderby) != 0 {
|
|
|
|
querystr += " ORDER BY "
|
|
|
|
for _, column := range _process_orderby(sel.Orderby) {
|
|
|
|
querystr += column.Column + " " + strings.ToUpper(column.Order) + ","
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
}
|
|
|
|
|
|
|
|
if sel.Limit != "" {
|
|
|
|
querystr += " LIMIT " + sel.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
querystr = strings.TrimSpace(querystr)
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"insert",querystr)
|
2017-06-19 08:06:54 +00:00
|
|
|
return querystr, nil
|
|
|
|
}
|
|
|
|
|
2017-06-25 09:56:39 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleInsertLeftJoin(name string, ins DB_Insert, sel DB_Join) (string, error) {
|
|
|
|
/* Insert Portion */
|
|
|
|
|
|
|
|
var querystr string = "INSERT INTO `" + ins.Table + "`("
|
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
|
|
|
for _, column := range _process_columns(ins.Columns) {
|
|
|
|
if column.Type == "function" {
|
|
|
|
querystr += column.Left + ","
|
|
|
|
} else {
|
|
|
|
querystr += "`" + column.Left + "`,"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1] + ") SELECT"
|
|
|
|
|
|
|
|
/* Select Portion */
|
|
|
|
|
|
|
|
for _, column := range _process_columns(sel.Columns) {
|
|
|
|
var source, alias string
|
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
|
|
|
if column.Table != "" {
|
|
|
|
source = "`" + column.Table + "`.`" + column.Left + "`"
|
|
|
|
} else if column.Type == "function" {
|
|
|
|
source = column.Left
|
|
|
|
} else {
|
|
|
|
source = "`" + column.Left + "`"
|
|
|
|
}
|
|
|
|
|
|
|
|
if column.Alias != "" {
|
|
|
|
alias = " AS `" + column.Alias + "`"
|
|
|
|
}
|
|
|
|
querystr += " " + source + alias + ","
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
|
|
|
querystr += " FROM `" + sel.Table1 + "` LEFT JOIN `" + sel.Table2 + "` ON "
|
|
|
|
for _, joiner := range _process_joiner(sel.Joiners) {
|
|
|
|
querystr += "`" + joiner.LeftTable + "`.`" + joiner.LeftColumn + "` " + joiner.Operator + " `" + joiner.RightTable + "`.`" + joiner.RightColumn + "` AND "
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
|
|
|
|
|
|
|
// Add support for BETWEEN x.x
|
|
|
|
if len(sel.Where) != 0 {
|
|
|
|
querystr += " WHERE"
|
|
|
|
for _, loc := range _process_where(sel.Where) {
|
|
|
|
for _, token := range loc.Expr {
|
|
|
|
switch(token.Type) {
|
|
|
|
case "function","operator","number","substitute":
|
|
|
|
querystr += " " + token.Contents + ""
|
|
|
|
case "column":
|
|
|
|
halves := strings.Split(token.Contents,".")
|
|
|
|
if len(halves) == 2 {
|
|
|
|
querystr += " `" + halves[0] + "`.`" + halves[1] + "`"
|
|
|
|
} else {
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
}
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
default:
|
|
|
|
panic("This token doesn't exist o_o")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
querystr += " AND"
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(sel.Orderby) != 0 {
|
|
|
|
querystr += " ORDER BY "
|
|
|
|
for _, column := range _process_orderby(sel.Orderby) {
|
|
|
|
querystr += column.Column + " " + strings.ToUpper(column.Order) + ","
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
}
|
|
|
|
|
|
|
|
if sel.Limit != "" {
|
|
|
|
querystr += " LIMIT " + sel.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
querystr = strings.TrimSpace(querystr)
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"insert",querystr)
|
2017-06-25 09:56:39 +00:00
|
|
|
return querystr, nil
|
|
|
|
}
|
|
|
|
|
2017-06-19 08:06:54 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleInsertInnerJoin(name string, ins DB_Insert, sel DB_Join) (string, error) {
|
|
|
|
/* Insert Portion */
|
2017-06-25 09:56:39 +00:00
|
|
|
|
2017-06-19 08:06:54 +00:00
|
|
|
var querystr string = "INSERT INTO `" + ins.Table + "`("
|
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
|
|
|
for _, column := range _process_columns(ins.Columns) {
|
|
|
|
if column.Type == "function" {
|
|
|
|
querystr += column.Left + ","
|
|
|
|
} else {
|
|
|
|
querystr += "`" + column.Left + "`,"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1] + ") SELECT"
|
|
|
|
|
|
|
|
/* Select Portion */
|
|
|
|
|
|
|
|
for _, column := range _process_columns(sel.Columns) {
|
|
|
|
var source, alias string
|
|
|
|
|
|
|
|
// Escape the column names, just in case we've used a reserved keyword
|
|
|
|
if column.Table != "" {
|
|
|
|
source = "`" + column.Table + "`.`" + column.Left + "`"
|
|
|
|
} else if column.Type == "function" {
|
|
|
|
source = column.Left
|
|
|
|
} else {
|
|
|
|
source = "`" + column.Left + "`"
|
|
|
|
}
|
|
|
|
|
|
|
|
if column.Alias != "" {
|
|
|
|
alias = " AS `" + column.Alias + "`"
|
|
|
|
}
|
|
|
|
querystr += " " + source + alias + ","
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
|
|
|
|
querystr += " FROM `" + sel.Table1 + "` INNER JOIN `" + sel.Table2 + "` ON "
|
|
|
|
for _, joiner := range _process_joiner(sel.Joiners) {
|
|
|
|
querystr += "`" + joiner.LeftTable + "`.`" + joiner.LeftColumn + "` " + joiner.Operator + " `" + joiner.RightTable + "`.`" + joiner.RightColumn + "` AND "
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
|
|
|
|
|
|
|
// Add support for BETWEEN x.x
|
|
|
|
if len(sel.Where) != 0 {
|
|
|
|
querystr += " WHERE"
|
|
|
|
for _, loc := range _process_where(sel.Where) {
|
|
|
|
for _, token := range loc.Expr {
|
|
|
|
switch(token.Type) {
|
|
|
|
case "function","operator","number","substitute":
|
|
|
|
querystr += " " + token.Contents + ""
|
|
|
|
case "column":
|
|
|
|
halves := strings.Split(token.Contents,".")
|
|
|
|
if len(halves) == 2 {
|
|
|
|
querystr += " `" + halves[0] + "`.`" + halves[1] + "`"
|
|
|
|
} else {
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
}
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
default:
|
|
|
|
panic("This token doesn't exist o_o")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
querystr += " AND"
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(sel.Orderby) != 0 {
|
|
|
|
querystr += " ORDER BY "
|
|
|
|
for _, column := range _process_orderby(sel.Orderby) {
|
|
|
|
querystr += column.Column + " " + strings.ToUpper(column.Order) + ","
|
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 1]
|
|
|
|
}
|
|
|
|
|
|
|
|
if sel.Limit != "" {
|
|
|
|
querystr += " LIMIT " + sel.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
querystr = strings.TrimSpace(querystr)
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"insert",querystr)
|
2017-06-19 08:06:54 +00:00
|
|
|
return querystr, nil
|
|
|
|
}
|
|
|
|
|
2017-06-15 11:40:35 +00:00
|
|
|
func (adapter *Mysql_Adapter) SimpleCount(name string, table string, where string, limit string) (string, error) {
|
2017-06-14 07:09:44 +00:00
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table == "" {
|
|
|
|
return "", errors.New("You need a name for this table")
|
|
|
|
}
|
|
|
|
|
|
|
|
var querystr string = "SELECT COUNT(*) AS `count` FROM `" + table + "`"
|
2017-06-19 08:06:54 +00:00
|
|
|
|
|
|
|
// Add support for BETWEEN x.x
|
2017-06-14 07:09:44 +00:00
|
|
|
if len(where) != 0 {
|
|
|
|
querystr += " WHERE"
|
2017-06-19 08:06:54 +00:00
|
|
|
//fmt.Println("SimpleCount:",name)
|
|
|
|
//fmt.Println("where:",where)
|
|
|
|
//fmt.Println("_process_where:",_process_where(where))
|
2017-06-14 07:09:44 +00:00
|
|
|
for _, loc := range _process_where(where) {
|
2017-06-19 08:06:54 +00:00
|
|
|
for _, token := range loc.Expr {
|
|
|
|
switch(token.Type) {
|
|
|
|
case "function","operator","number","substitute":
|
|
|
|
querystr += " " + token.Contents + ""
|
|
|
|
case "column":
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
default:
|
|
|
|
panic("This token doesn't exist o_o")
|
|
|
|
}
|
2017-06-14 07:09:44 +00:00
|
|
|
}
|
2017-06-19 08:06:54 +00:00
|
|
|
querystr += " AND"
|
2017-06-14 07:09:44 +00:00
|
|
|
}
|
|
|
|
querystr = querystr[0:len(querystr) - 4]
|
|
|
|
}
|
|
|
|
|
2017-06-15 11:40:35 +00:00
|
|
|
if limit != "" {
|
|
|
|
querystr += " LIMIT " + limit
|
|
|
|
}
|
|
|
|
|
2017-06-14 07:09:44 +00:00
|
|
|
querystr = strings.TrimSpace(querystr)
|
2017-07-12 11:05:18 +00:00
|
|
|
adapter.push_statement(name,"select",querystr)
|
2017-06-13 08:56:48 +00:00
|
|
|
return querystr, nil
|
2017-06-05 11:57:27 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 07:12:58 +00:00
|
|
|
func (adapter *Mysql_Adapter) Write() error {
|
|
|
|
var stmts, body string
|
|
|
|
for _, name := range adapter.BufferOrder {
|
2017-07-12 11:05:18 +00:00
|
|
|
stmt := adapter.Buffer[name]
|
|
|
|
// TO-DO: Add support for create-table? Table creation might be a little complex for Go to do outside a SQL file :(
|
|
|
|
if stmt.Type != "create-table" {
|
|
|
|
stmts += "var " + name + "_stmt *sql.Stmt\n"
|
|
|
|
body += `
|
2017-06-13 07:12:58 +00:00
|
|
|
log.Print("Preparing ` + name + ` statement.")
|
2017-07-12 11:05:18 +00:00
|
|
|
` + name + `_stmt, err = db.Prepare("` + stmt.Contents + `")
|
2017-06-13 07:12:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
`
|
2017-07-12 11:05:18 +00:00
|
|
|
}
|
2017-06-13 07:12:58 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
out := `// +build !pgsql !sqlite !mssql
|
|
|
|
|
2017-06-14 09:55:47 +00:00
|
|
|
/* This file was generated by Gosora's Query Generator. Please try to avoid modifying this file, as it might change at any time. */
|
2017-07-12 11:05:18 +00:00
|
|
|
|
2017-06-05 11:57:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
import "database/sql"
|
|
|
|
|
2017-06-13 07:12:58 +00:00
|
|
|
` + stmts + `
|
2017-07-12 11:05:18 +00:00
|
|
|
func _gen_mysql() (err error) {
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.DebugMode {
|
2017-06-05 11:57:27 +00:00
|
|
|
log.Print("Building the generated statements")
|
|
|
|
}
|
2017-06-13 07:12:58 +00:00
|
|
|
` + body + `
|
2017-06-05 11:57:27 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
`
|
|
|
|
return write_file("./gen_mysql.go", out)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// Internal methods, not exposed in the interface
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Mysql_Adapter) push_statement(name string, stype string, querystr string) {
|
|
|
|
adapter.Buffer[name] = DB_Stmt{querystr,stype}
|
2017-06-13 07:12:58 +00:00
|
|
|
adapter.BufferOrder = append(adapter.BufferOrder,name)
|
2017-06-05 11:57:27 +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
|
|
|
|
|
|
|
func (adapter *Mysql_Adapter) stringy_type(ctype string) bool {
|
|
|
|
ctype = strings.ToLower(ctype)
|
|
|
|
return ctype == "varchar" || ctype == "tinytext" || ctype == "text" || ctype == "mediumtext" || ctype == "longtext" || ctype == "char" || ctype == "datetime" || ctype == "timestamp" || ctype == "time" || ctype == "date"
|
|
|
|
}
|