2017-04-05 14:15:22 +00:00
package main
2017-05-07 08:31:41 +00:00
import (
2017-09-03 04:50:31 +00:00
"encoding/json"
2017-05-07 08:31:41 +00:00
"errors"
2017-09-03 04:50:31 +00:00
"fmt"
2017-05-07 08:31:41 +00:00
"html"
"html/template"
2017-09-23 19:57:13 +00:00
"io/ioutil"
2017-09-03 04:50:31 +00:00
"log"
"net/http"
2017-09-23 19:57:13 +00:00
"os"
"path/filepath"
2017-09-03 04:50:31 +00:00
"strconv"
"strings"
2017-05-07 08:31:41 +00:00
2017-07-17 10:23:42 +00:00
"github.com/Azareal/gopsutil/mem"
2017-06-28 12:05:26 +00:00
)
2017-04-05 14:15:22 +00:00
2017-10-30 09:57:08 +00:00
func routePanel ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-07-17 10:23:42 +00:00
// We won't calculate this on the spot anymore, as the system doesn't seem to like it if we do multiple fetches simultaneously. Should we constantly calculate this on a background thread? Perhaps, the watchdog to scale back heavy features under load? One plus side is that we'd get immediate CPU percentages here instead of waiting it to kick in with WebSockets
2017-09-03 04:50:31 +00:00
var cpustr = "Unknown"
2017-07-17 10:23:42 +00:00
var cpuColour string
2017-05-07 08:31:41 +00:00
var ramstr , ramColour string
memres , err := mem . VirtualMemory ( )
if err != nil {
ramstr = "Unknown"
} else {
2017-09-03 04:50:31 +00:00
totalCount , totalUnit := convertByteUnit ( float64 ( memres . Total ) )
usedCount := convertByteInUnit ( float64 ( memres . Total - memres . Available ) , totalUnit )
2017-05-29 14:52:37 +00:00
2017-05-07 08:31:41 +00:00
// Round totals with .9s up, it's how most people see it anyway. Floats are notoriously imprecise, so do it off 0.85
2017-08-13 11:22:34 +00:00
//log.Print("pre used_count",used_count)
2017-05-07 08:31:41 +00:00
var totstr string
2017-09-03 04:50:31 +00:00
if ( totalCount - float64 ( int ( totalCount ) ) ) > 0.85 {
usedCount += 1.0 - ( totalCount - float64 ( int ( totalCount ) ) )
totstr = strconv . Itoa ( int ( totalCount ) + 1 )
2017-05-07 08:31:41 +00:00
} else {
2017-09-03 04:50:31 +00:00
totstr = fmt . Sprintf ( "%.1f" , totalCount )
2017-05-07 08:31:41 +00:00
}
2017-08-13 11:22:34 +00:00
//log.Print("post used_count",used_count)
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if usedCount > totalCount {
usedCount = totalCount
2017-05-07 08:31:41 +00:00
}
2017-09-03 04:50:31 +00:00
ramstr = fmt . Sprintf ( "%.1f" , usedCount ) + " / " + totstr + totalUnit
2017-05-29 14:52:37 +00:00
2017-05-07 08:31:41 +00:00
ramperc := ( ( memres . Total - memres . Available ) * 100 ) / memres . Total
2017-08-13 11:22:34 +00:00
//log.Print("ramperc",ramperc)
2017-05-07 08:31:41 +00:00
if ramperc < 50 {
ramColour = "stat_green"
} else if ramperc < 75 {
ramColour = "stat_orange"
} else {
ramColour = "stat_red"
}
}
2017-05-29 14:52:37 +00:00
2017-05-07 08:31:41 +00:00
var postCount int
2017-11-05 09:55:34 +00:00
err = stmts . todaysPostCount . QueryRow ( ) . Scan ( & postCount )
2017-06-28 12:05:26 +00:00
if err != nil && err != ErrNoRows {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-05-07 08:31:41 +00:00
}
2017-09-03 04:50:31 +00:00
var postInterval = "day"
2017-05-29 14:52:37 +00:00
2017-05-07 08:31:41 +00:00
var postColour string
2017-05-11 13:04:43 +00:00
if postCount > 25 {
2017-05-07 08:31:41 +00:00
postColour = "stat_green"
2017-05-11 13:04:43 +00:00
} else if postCount > 5 {
2017-05-07 08:31:41 +00:00
postColour = "stat_orange"
} else {
postColour = "stat_red"
}
2017-05-29 14:52:37 +00:00
2017-05-07 08:31:41 +00:00
var topicCount int
2017-11-05 09:55:34 +00:00
err = stmts . todaysTopicCount . QueryRow ( ) . Scan ( & topicCount )
2017-06-28 12:05:26 +00:00
if err != nil && err != ErrNoRows {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-05-07 08:31:41 +00:00
}
2017-09-03 04:50:31 +00:00
var topicInterval = "day"
2017-05-29 14:52:37 +00:00
2017-05-07 08:31:41 +00:00
var topicColour string
2017-05-11 13:04:43 +00:00
if topicCount > 8 {
2017-05-07 08:31:41 +00:00
topicColour = "stat_green"
} else if topicCount > 0 {
topicColour = "stat_orange"
} else {
topicColour = "stat_red"
}
2017-05-29 14:52:37 +00:00
2017-05-07 08:31:41 +00:00
var reportCount int
2017-11-05 09:55:34 +00:00
err = stmts . todaysReportCount . QueryRow ( ) . Scan ( & reportCount )
2017-06-28 12:05:26 +00:00
if err != nil && err != ErrNoRows {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-05-07 08:31:41 +00:00
}
2017-09-03 04:50:31 +00:00
var reportInterval = "week"
2017-05-29 14:52:37 +00:00
2017-05-07 08:31:41 +00:00
var newUserCount int
2017-11-05 09:55:34 +00:00
err = stmts . todaysNewUserCount . QueryRow ( ) . Scan ( & newUserCount )
2017-06-28 12:05:26 +00:00
if err != nil && err != ErrNoRows {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-05-07 08:31:41 +00:00
}
2017-09-03 04:50:31 +00:00
var newUserInterval = "week"
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
var gridElements = [ ] GridElement {
GridElement { "dash-version" , "v" + version . String ( ) , 0 , "grid_istat stat_green" , "" , "" , "Gosora is up-to-date :)" } ,
GridElement { "dash-cpu" , "CPU: " + cpustr , 1 , "grid_istat " + cpuColour , "" , "" , "The global CPU usage of this server" } ,
GridElement { "dash-ram" , "RAM: " + ramstr , 2 , "grid_istat " + ramColour , "" , "" , "The global RAM usage of this server" } ,
2017-05-11 13:04:43 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if enableWebsockets {
uonline := wsHub . userCount ( )
gonline := wsHub . guestCount ( )
2017-05-11 13:04:43 +00:00
totonline := uonline + gonline
2017-05-29 14:52:37 +00:00
2017-05-11 13:04:43 +00:00
var onlineColour string
if totonline > 10 {
onlineColour = "stat_green"
} else if totonline > 3 {
onlineColour = "stat_orange"
} else {
onlineColour = "stat_red"
}
2017-05-29 14:52:37 +00:00
2017-05-11 13:04:43 +00:00
var onlineGuestsColour string
if gonline > 10 {
onlineGuestsColour = "stat_green"
} else if gonline > 1 {
onlineGuestsColour = "stat_orange"
} else {
onlineGuestsColour = "stat_red"
}
2017-05-29 14:52:37 +00:00
2017-05-11 13:04:43 +00:00
var onlineUsersColour string
if uonline > 5 {
onlineUsersColour = "stat_green"
} else if uonline > 1 {
onlineUsersColour = "stat_orange"
} else {
onlineUsersColour = "stat_red"
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
totonline , totunit := convertFriendlyUnit ( totonline )
uonline , uunit := convertFriendlyUnit ( uonline )
gonline , gunit := convertFriendlyUnit ( gonline )
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
gridElements = append ( gridElements , GridElement { "dash-totonline" , strconv . Itoa ( totonline ) + totunit + " online" , 3 , "grid_stat " + onlineColour , "" , "" , "The number of people who are currently online" } )
gridElements = append ( gridElements , GridElement { "dash-gonline" , strconv . Itoa ( gonline ) + gunit + " guests online" , 4 , "grid_stat " + onlineGuestsColour , "" , "" , "The number of guests who are currently online" } )
gridElements = append ( gridElements , GridElement { "dash-uonline" , strconv . Itoa ( uonline ) + uunit + " users online" , 5 , "grid_stat " + onlineUsersColour , "" , "" , "The number of logged-in users who are currently online" } )
2017-05-07 08:31:41 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
gridElements = append ( gridElements , GridElement { "dash-postsperday" , strconv . Itoa ( postCount ) + " posts / " + postInterval , 6 , "grid_stat " + postColour , "" , "" , "The number of new posts over the last 24 hours" } )
gridElements = append ( gridElements , GridElement { "dash-topicsperday" , strconv . Itoa ( topicCount ) + " topics / " + topicInterval , 7 , "grid_stat " + topicColour , "" , "" , "The number of new topics over the last 24 hours" } )
gridElements = append ( gridElements , GridElement { "dash-totonlineperday" , "20 online / day" , 8 , "grid_stat stat_disabled" , "" , "" , "Coming Soon!" /*"The people online over the last 24 hours"*/ } )
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
gridElements = append ( gridElements , GridElement { "dash-searches" , "8 searches / week" , 9 , "grid_stat stat_disabled" , "" , "" , "Coming Soon!" /*"The number of searches over the last 7 days"*/ } )
gridElements = append ( gridElements , GridElement { "dash-newusers" , strconv . Itoa ( newUserCount ) + " new users / " + newUserInterval , 10 , "grid_stat" , "" , "" , "The number of new users over the last 7 days" } )
gridElements = append ( gridElements , GridElement { "dash-reports" , strconv . Itoa ( reportCount ) + " reports / " + reportInterval , 11 , "grid_stat" , "" , "" , "The number of reports over the last 7 days" } )
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
gridElements = append ( gridElements , GridElement { "dash-minperuser" , "2 minutes / user / week" , 12 , "grid_stat stat_disabled" , "" , "" , "Coming Soon!" /*"The average number of number of minutes spent by each active user over the last 7 days"*/ } )
gridElements = append ( gridElements , GridElement { "dash-visitorsperweek" , "2 visitors / week" , 13 , "grid_stat stat_disabled" , "" , "" , "Coming Soon!" /*"The number of unique visitors we've had over the last 7 days"*/ } )
gridElements = append ( gridElements , GridElement { "dash-postsperuser" , "5 posts / user / week" , 14 , "grid_stat stat_disabled" , "" , "" , "Coming Soon!" /*"The average number of posts made by each active user over the past week"*/ } )
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
pi := PanelDashboardPage { "Control Panel Dashboard" , user , headerVars , stats , gridElements }
if preRenderHooks [ "pre_render_panel_dashboard" ] != nil {
if runPreRenderHook ( "pre_render_panel_dashboard" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "panel-dashboard.html" , pi )
2017-07-17 10:23:42 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-07-17 10:23:42 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelForums ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManageForums {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-23 19:57:13 +00:00
// TODO: Paginate this?
2017-04-05 14:15:22 +00:00
var forumList [ ] interface { }
2017-06-28 12:05:26 +00:00
forums , err := fstore . GetAll ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-06-28 12:05:26 +00:00
}
2017-09-23 19:57:13 +00:00
// ? - Should we generate something similar to the forumView? It might be a little overkill for a page which is rarely loaded in comparison to /forums/
2017-04-05 14:15:22 +00:00
for _ , forum := range forums {
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 forum . Name != "" && forum . ParentID == 0 {
2017-09-03 04:50:31 +00:00
fadmin := ForumAdmin { forum . ID , forum . Name , forum . Desc , forum . Active , forum . Preset , forum . TopicCount , presetToLang ( forum . Preset ) }
2017-05-29 14:52:37 +00:00
if fadmin . Preset == "" {
fadmin . Preset = "custom"
}
2017-09-03 04:50:31 +00:00
forumList = append ( forumList , fadmin )
2017-04-05 14:15:22 +00:00
}
}
2017-09-03 04:50:31 +00:00
pi := PanelPage { "Forum Manager" , user , headerVars , stats , forumList , nil }
if preRenderHooks [ "pre_render_panel_forums" ] != nil {
if runPreRenderHook ( "pre_render_panel_forums" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "panel-forums.html" , pi )
2017-05-29 14:52:37 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-05-29 14:52:37 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelForumsCreateSubmit ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManageForums {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
err := r . ParseForm ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "Bad Form" , w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
fname := r . PostFormValue ( "forum-name" )
2017-06-05 11:57:27 +00:00
fdesc := r . PostFormValue ( "forum-desc" )
2017-09-03 04:50:31 +00:00
fpreset := stripInvalidPreset ( r . PostFormValue ( "forum-preset" ) )
2017-04-05 14:15:22 +00:00
factive := r . PostFormValue ( "forum-name" )
2017-09-03 04:50:31 +00:00
active := ( factive == "on" || factive == "1" )
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
_ , err = fstore . Create ( fname , fdesc , active , fpreset )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/forums/" , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-09-10 16:57:22 +00:00
// TODO: Revamp this
2017-10-30 09:57:08 +00:00
func routePanelForumsDelete ( w http . ResponseWriter , r * http . Request , user User , sfid string ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManageForums {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-13 10:55:51 +00:00
fid , err := strconv . Atoi ( sfid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "The provided Forum ID is not a valid number." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
forum , err := fstore . Get ( fid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalError ( "The forum you're trying to delete doesn't exist." , w , r , user )
2017-06-28 12:05:26 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-10 16:57:22 +00:00
confirmMsg := "Are you sure you want to delete the '" + forum . Name + "' forum?"
yousure := AreYouSure { "/panel/forums/delete/submit/" + strconv . Itoa ( fid ) , confirmMsg }
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
pi := PanelPage { "Delete Forum" , user , headerVars , stats , tList , yousure }
if preRenderHooks [ "pre_render_panel_delete_forum" ] != nil {
if runPreRenderHook ( "pre_render_panel_delete_forum" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "areyousure.html" , pi )
2017-08-13 11:22:34 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-08-13 11:22:34 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelForumsDeleteSubmit ( w http . ResponseWriter , r * http . Request , user User , sfid string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManageForums {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-13 10:55:51 +00:00
fid , err := strconv . Atoi ( sfid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "The provided Forum ID is not a valid number." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
err = fstore . Delete ( fid )
2017-07-12 11:05:18 +00:00
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalError ( "The forum you're trying to delete doesn't exist." , w , r , user )
2017-07-12 11:05:18 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-07-17 10:23:42 +00:00
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/forums/" , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelForumsEdit ( w http . ResponseWriter , r * http . Request , user User , sfid string ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManageForums {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-13 10:55:51 +00:00
fid , err := strconv . Atoi ( sfid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "The provided Forum ID is not a valid number." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-06-28 12:05:26 +00:00
2017-09-15 22:20:01 +00:00
forum , err := fstore . Get ( fid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalError ( "The forum you're trying to edit doesn't exist." , w , r , user )
2017-06-28 12:05:26 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-06-05 11:57:27 +00:00
if forum . Preset == "" {
forum . Preset = "custom"
}
2017-09-15 22:20:01 +00:00
glist , err := gstore . GetAll ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-09-15 22:20:01 +00:00
}
2017-06-05 11:57:27 +00:00
var gplist [ ] GroupForumPermPreset
for gid , group := range glist {
if gid == 0 {
continue
}
2017-09-03 04:50:31 +00:00
gplist = append ( gplist , GroupForumPermPreset { group , forumPermsToGroupForumPreset ( group . Forums [ fid ] ) } )
2017-06-05 11:57:27 +00:00
}
2017-09-03 04:50:31 +00:00
pi := PanelEditForumPage { "Forum Editor" , user , headerVars , stats , forum . ID , forum . Name , forum . Desc , forum . Active , forum . Preset , gplist }
if preRenderHooks [ "pre_render_panel_edit_forum" ] != nil {
if runPreRenderHook ( "pre_render_panel_edit_forum" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "panel-forum-edit.html" , pi )
2017-06-05 11:57:27 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-06-05 11:57:27 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelForumsEditSubmit ( w http . ResponseWriter , r * http . Request , user User , sfid string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManageForums {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
err := r . ParseForm ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "Bad Form" , w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
isJs := ( r . PostFormValue ( "js" ) == "1" )
2017-05-29 14:52:37 +00:00
2017-04-13 10:55:51 +00:00
fid , err := strconv . Atoi ( sfid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalErrorJSQ ( "The provided Forum ID is not a valid number." , w , r , user , isJs )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
forum , err := fstore . Get ( fid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalErrorJSQ ( "The forum you're trying to edit doesn't exist." , w , r , user , isJs )
2017-06-28 12:05:26 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalErrorJSQ ( err , w , r , isJs )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-25 00:48:35 +00:00
forumName := r . PostFormValue ( "forum_name" )
forumDesc := r . PostFormValue ( "forum_desc" )
forumPreset := stripInvalidPreset ( r . PostFormValue ( "forum_preset" ) )
forumActive := r . PostFormValue ( "forum_active" )
2017-05-29 14:52:37 +00:00
2017-09-25 00:48:35 +00:00
var active = false
2017-09-10 16:57:22 +00:00
if forumActive == "" {
2017-06-28 12:05:26 +00:00
active = forum . Active
2017-09-10 16:57:22 +00:00
} else if forumActive == "1" || forumActive == "Show" {
2017-04-05 14:15:22 +00:00
active = true
}
2017-05-29 14:52:37 +00:00
2017-09-25 00:48:35 +00:00
err = forum . Update ( forumName , forumDesc , active , forumPreset )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalErrorJSQ ( err , w , r , isJs )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if ! isJs {
http . Redirect ( w , r , "/panel/forums/" , http . StatusSeeOther )
2017-04-05 14:15:22 +00:00
} else {
2017-09-03 04:50:31 +00:00
w . Write ( successJSONBytes )
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelForumsEditPermsSubmit ( w http . ResponseWriter , r * http . Request , user User , sfid string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-06-05 11:57:27 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManageForums {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-06-05 11:57:27 +00:00
}
err := r . ParseForm ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "Bad Form" , w , r , user )
2017-06-05 11:57:27 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-06-05 11:57:27 +00:00
}
2017-09-03 04:50:31 +00:00
isJs := ( r . PostFormValue ( "js" ) == "1" )
2017-06-05 11:57:27 +00:00
fid , err := strconv . Atoi ( sfid )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalErrorJSQ ( "The provided Forum ID is not a valid number." , w , r , user , isJs )
2017-06-05 11:57:27 +00:00
}
2017-06-06 08:47:33 +00:00
gid , err := strconv . Atoi ( r . PostFormValue ( "gid" ) )
2017-06-05 11:57:27 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalErrorJSQ ( "Invalid Group ID" , w , r , user , isJs )
2017-06-05 11:57:27 +00:00
}
2017-09-10 16:57:22 +00:00
permPreset := stripInvalidGroupForumPreset ( r . PostFormValue ( "perm_preset" ) )
fperms , changed := groupForumPresetToForumPerms ( permPreset )
2017-06-28 12:05:26 +00:00
2017-09-15 22:20:01 +00:00
forum , err := fstore . Get ( fid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalErrorJSQ ( "This forum doesn't exist" , w , r , user , isJs )
2017-06-28 12:05:26 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalErrorJSQ ( err , w , r , isJs )
2017-06-28 12:05:26 +00:00
}
2017-11-05 01:04:57 +00:00
// ! IMPORTANT
// TODO: Refactor this
2017-09-03 04:50:31 +00:00
forumUpdateMutex . Lock ( )
defer forumUpdateMutex . Unlock ( )
2017-06-05 11:57:27 +00:00
if changed {
2017-09-03 04:50:31 +00:00
permUpdateMutex . Lock ( )
2017-09-15 22:20:01 +00:00
defer permUpdateMutex . Unlock ( )
group , err := gstore . Get ( gid )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "The group whose permissions you're updating doesn't exist." , w , r , user )
2017-09-15 22:20:01 +00:00
}
group . Forums [ fid ] = fperms
2017-06-05 11:57:27 +00:00
2017-10-21 00:27:47 +00:00
err = replaceForumPermsForGroup ( gid , map [ int ] string { fid : permPreset } , map [ int ] ForumPerms { fid : fperms } )
2017-06-05 11:57:27 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalErrorJSQ ( err , w , r , isJs )
2017-06-05 11:57:27 +00:00
}
2017-10-21 00:27:47 +00:00
// TODO: Add this and replaceForumPermsForGroup into a transaction?
2017-11-05 09:55:34 +00:00
_ , err = stmts . updateForum . Exec ( forum . Name , forum . Desc , forum . Active , "" , fid )
2017-06-05 11:57:27 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalErrorJSQ ( err , w , r , isJs )
2017-06-05 11:57:27 +00:00
}
2017-10-21 00:27:47 +00:00
err = fstore . Reload ( fid )
2017-06-06 08:47:33 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalErrorJSQ ( "Unable to reload forum" , w , r , user , isJs )
2017-06-06 08:47:33 +00:00
}
2017-06-05 11:57:27 +00:00
}
2017-09-03 04:50:31 +00:00
if ! isJs {
http . Redirect ( w , r , "/panel/forums/edit/" + strconv . Itoa ( fid ) , http . StatusSeeOther )
2017-06-05 11:57:27 +00:00
} else {
2017-09-03 04:50:31 +00:00
w . Write ( successJSONBytes )
2017-06-05 11:57:27 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-06-05 11:57:27 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelSettings ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . EditSettings {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-08-20 09:39:02 +00:00
//log.Print("headerVars.Settings",headerVars.Settings)
2017-09-10 16:57:22 +00:00
var settingList = make ( map [ string ] interface { } )
2017-11-05 09:55:34 +00:00
rows , err := stmts . getSettings . Query ( )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
defer rows . Close ( )
2017-05-29 14:52:37 +00:00
2017-09-10 16:57:22 +00:00
// nolint need the type so people viewing this file understand what it returns without visiting setting.go
2017-09-03 04:50:31 +00:00
var settingLabels map [ string ] string = GetAllSettingLabels ( )
2017-04-13 15:01:30 +00:00
var sname , scontent , stype string
2017-04-05 14:15:22 +00:00
for rows . Next ( ) {
2017-09-03 04:50:31 +00:00
err := rows . Scan ( & sname , & scontent , & stype )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
if stype == "list" {
llist := settingLabels [ sname ]
2017-09-03 04:50:31 +00:00
labels := strings . Split ( llist , "," )
2017-04-05 14:15:22 +00:00
conv , err := strconv . Atoi ( scontent )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "The setting '" + sname + "' can't be converted to an integer" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
scontent = labels [ conv - 1 ]
2017-04-05 14:15:22 +00:00
} else if stype == "bool" {
if scontent == "1" {
scontent = "Yes"
} else {
scontent = "No"
}
}
settingList [ sname ] = scontent
}
err = rows . Err ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
pi := PanelPage { "Setting Manager" , user , headerVars , stats , tList , settingList }
if preRenderHooks [ "pre_render_panel_settings" ] != nil {
if runPreRenderHook ( "pre_render_panel_settings" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "panel-settings.html" , pi )
2017-08-13 11:22:34 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-08-13 11:22:34 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelSetting ( w http . ResponseWriter , r * http . Request , user User , sname string ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . EditSettings {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
setting := Setting { sname , "" , "" , "" }
2017-05-29 14:52:37 +00:00
2017-11-05 09:55:34 +00:00
err := stmts . getSetting . QueryRow ( setting . Name ) . Scan ( & setting . Content , & setting . Type )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalError ( "The setting you want to edit doesn't exist." , w , r , user )
2017-04-05 14:15:22 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
var itemList [ ] interface { }
if setting . Type == "list" {
2017-09-03 04:50:31 +00:00
llist := GetSettingLabel ( setting . Name )
2017-04-05 14:15:22 +00:00
conv , err := strconv . Atoi ( setting . Content )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "The value of this setting couldn't be converted to an integer" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
labels := strings . Split ( llist , "," )
2017-04-05 14:15:22 +00:00
for index , label := range labels {
itemList = append ( itemList , OptionLabel {
2017-09-03 04:50:31 +00:00
Label : label ,
Value : index + 1 ,
2017-04-05 14:15:22 +00:00
Selected : conv == ( index + 1 ) ,
} )
}
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
pi := PanelPage { "Edit Setting" , user , headerVars , stats , itemList , setting }
if preRenderHooks [ "pre_render_panel_setting" ] != nil {
if runPreRenderHook ( "pre_render_panel_setting" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "panel-setting.html" , pi )
2017-08-13 11:22:34 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-08-13 11:22:34 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelSettingEdit ( w http . ResponseWriter , r * http . Request , user User , sname string ) RouteError {
headerLite , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . EditSettings {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
err := r . ParseForm ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "Bad Form" , w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-06-06 08:47:33 +00:00
var stype , sconstraints string
2017-04-05 14:15:22 +00:00
scontent := r . PostFormValue ( "setting-value" )
2017-05-29 14:52:37 +00:00
2017-11-05 09:55:34 +00:00
err = stmts . getFullSetting . QueryRow ( sname ) . Scan ( & sname , & stype , & sconstraints )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalError ( "The setting you want to edit doesn't exist." , w , r , user )
2017-04-05 14:15:22 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
if stype == "bool" {
if scontent == "on" || scontent == "1" {
scontent = "1"
} else {
scontent = "0"
}
}
2017-05-29 14:52:37 +00:00
2017-09-18 17:03:52 +00:00
// TODO: Make this a method or function?
2017-11-05 09:55:34 +00:00
_ , err = stmts . updateSetting . Exec ( scontent , sname )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-08-20 09:39:02 +00:00
errmsg := headerLite . Settings . ParseSetting ( sname , scontent , stype , sconstraints )
2017-04-05 14:15:22 +00:00
if errmsg != "" {
2017-10-30 09:57:08 +00:00
return LocalError ( errmsg , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-08-20 09:39:02 +00:00
settingBox . Store ( headerLite . Settings )
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/settings/" , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelWordFilters ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return nil
2017-08-27 09:33:45 +00:00
}
if ! user . Perms . EditSettings {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-08-27 09:33:45 +00:00
}
2017-09-10 16:57:22 +00:00
var filterList = wordFilterBox . Load ( ) . ( WordFilterBox )
2017-09-03 04:50:31 +00:00
pi := PanelPage { "Word Filter Manager" , user , headerVars , stats , tList , filterList }
if preRenderHooks [ "pre_render_panel_word_filters" ] != nil {
if runPreRenderHook ( "pre_render_panel_word_filters" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
2017-08-27 09:33:45 +00:00
}
}
2017-09-03 04:50:31 +00:00
err := templates . ExecuteTemplate ( w , "panel-word-filters.html" , pi )
2017-08-27 09:33:45 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-08-27 09:33:45 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-08-27 09:33:45 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelWordFiltersCreate ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-08-27 09:33:45 +00:00
}
if ! user . Perms . EditSettings {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-08-27 09:33:45 +00:00
}
err := r . ParseForm ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return PreError ( "Bad Form" , w , r )
2017-08-27 09:33:45 +00:00
}
2017-09-03 04:50:31 +00:00
isJs := ( r . PostFormValue ( "js" ) == "1" )
2017-08-27 09:33:45 +00:00
find := strings . TrimSpace ( r . PostFormValue ( "find" ) )
if find == "" {
2017-10-30 09:57:08 +00:00
return LocalErrorJSQ ( "You need to specify what word you want to match" , w , r , user , isJs )
2017-08-27 09:33:45 +00:00
}
// Unlike with find, it's okay if we leave this blank, as this means that the admin wants to remove the word entirely with no replacement
replacement := strings . TrimSpace ( r . PostFormValue ( "replacement" ) )
2017-11-05 09:55:34 +00:00
res , err := stmts . createWordFilter . Exec ( find , replacement )
2017-08-27 09:33:45 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalErrorJSQ ( err , w , r , isJs )
2017-08-27 09:33:45 +00:00
}
2017-09-10 16:57:22 +00:00
lastID , err := res . LastInsertId ( )
2017-08-27 09:33:45 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalErrorJSQ ( err , w , r , isJs )
2017-08-27 09:33:45 +00:00
}
2017-09-10 16:57:22 +00:00
addWordFilter ( int ( lastID ) , find , replacement )
2017-10-30 09:57:08 +00:00
if ! isJs {
http . Redirect ( w , r , "/panel/settings/word-filters/" , http . StatusSeeOther )
} else {
w . Write ( successJSONBytes )
}
return nil
2017-08-27 09:33:45 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelWordFiltersEdit ( w http . ResponseWriter , r * http . Request , user User , wfid string ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-08-27 09:33:45 +00:00
}
if ! user . Perms . EditSettings {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-08-27 09:33:45 +00:00
}
_ = wfid
2017-09-03 04:50:31 +00:00
pi := PanelPage { "Edit Word Filter" , user , headerVars , stats , tList , nil }
if preRenderHooks [ "pre_render_panel_word_filters_edit" ] != nil {
if runPreRenderHook ( "pre_render_panel_word_filters_edit" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
2017-08-27 09:33:45 +00:00
}
}
2017-09-03 04:50:31 +00:00
err := templates . ExecuteTemplate ( w , "panel-word-filters-edit.html" , pi )
2017-08-27 09:33:45 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-08-27 09:33:45 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-08-27 09:33:45 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelWordFiltersEditSubmit ( w http . ResponseWriter , r * http . Request , user User , wfid string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-08-27 09:33:45 +00:00
}
err := r . ParseForm ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return PreError ( "Bad Form" , w , r )
2017-08-27 09:33:45 +00:00
}
2017-09-10 16:57:22 +00:00
// TODO: Either call it isJs or js rather than flip-flopping back and forth across the routes x.x
2017-09-03 04:50:31 +00:00
isJs := ( r . PostFormValue ( "isJs" ) == "1" )
2017-08-27 09:33:45 +00:00
if ! user . Perms . EditSettings {
2017-10-30 09:57:08 +00:00
return NoPermissionsJSQ ( w , r , user , isJs )
2017-08-27 09:33:45 +00:00
}
id , err := strconv . Atoi ( wfid )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalErrorJSQ ( "The word filter ID must be an integer." , w , r , user , isJs )
2017-08-27 09:33:45 +00:00
}
find := strings . TrimSpace ( r . PostFormValue ( "find" ) )
if find == "" {
2017-10-30 09:57:08 +00:00
return LocalErrorJSQ ( "You need to specify what word you want to match" , w , r , user , isJs )
2017-08-27 09:33:45 +00:00
}
// Unlike with find, it's okay if we leave this blank, as this means that the admin wants to remove the word entirely with no replacement
replacement := strings . TrimSpace ( r . PostFormValue ( "replacement" ) )
2017-11-05 09:55:34 +00:00
_ , err = stmts . updateWordFilter . Exec ( find , replacement , id )
2017-08-27 09:33:45 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalErrorJSQ ( err , w , r , isJs )
2017-08-27 09:33:45 +00:00
}
wordFilters := wordFilterBox . Load ( ) . ( WordFilterBox )
2017-09-03 04:50:31 +00:00
wordFilters [ id ] = WordFilter { ID : id , Find : find , Replacement : replacement }
2017-08-27 09:33:45 +00:00
wordFilterBox . Store ( wordFilters )
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/settings/word-filters/" , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-08-27 09:33:45 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelWordFiltersDeleteSubmit ( w http . ResponseWriter , r * http . Request , user User , wfid string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-08-27 09:33:45 +00:00
}
err := r . ParseForm ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return PreError ( "Bad Form" , w , r )
2017-08-27 09:33:45 +00:00
}
2017-09-03 04:50:31 +00:00
isJs := ( r . PostFormValue ( "isJs" ) == "1" )
2017-08-27 09:33:45 +00:00
if ! user . Perms . EditSettings {
2017-10-30 09:57:08 +00:00
return NoPermissionsJSQ ( w , r , user , isJs )
2017-08-27 09:33:45 +00:00
}
id , err := strconv . Atoi ( wfid )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalErrorJSQ ( "The word filter ID must be an integer." , w , r , user , isJs )
2017-08-27 09:33:45 +00:00
}
2017-11-05 09:55:34 +00:00
_ , err = stmts . deleteWordFilter . Exec ( id )
2017-08-27 09:33:45 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalErrorJSQ ( err , w , r , isJs )
2017-08-27 09:33:45 +00:00
}
wordFilters := wordFilterBox . Load ( ) . ( WordFilterBox )
2017-09-03 04:50:31 +00:00
delete ( wordFilters , id )
2017-08-27 09:33:45 +00:00
wordFilterBox . Store ( wordFilters )
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/settings/word-filters/" , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-08-27 09:33:45 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelPlugins ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManagePlugins {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
var pluginList [ ] interface { }
for _ , plugin := range plugins {
2017-09-03 04:50:31 +00:00
pluginList = append ( pluginList , plugin )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
pi := PanelPage { "Plugin Manager" , user , headerVars , stats , pluginList , nil }
if preRenderHooks [ "pre_render_panel_plugins" ] != nil {
if runPreRenderHook ( "pre_render_panel_plugins" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err := templates . ExecuteTemplate ( w , "panel-plugins.html" , pi )
2017-08-13 11:22:34 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-08-13 11:22:34 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelPluginsActivate ( w http . ResponseWriter , r * http . Request , user User , uname string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManagePlugins {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-08-13 11:22:34 +00:00
//log.Print("uname","'"+uname+"'")
2017-04-05 14:15:22 +00:00
plugin , ok := plugins [ uname ]
if ! ok {
2017-10-30 09:57:08 +00:00
return LocalError ( "The plugin isn't registered in the system" , w , r , user )
2017-04-05 14:15:22 +00:00
}
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
if plugin . Installable && ! plugin . Installed {
2017-10-30 09:57:08 +00:00
return LocalError ( "You can't activate this plugin without installing it first" , w , r , user )
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-04-05 14:15:22 +00:00
var active bool
2017-11-05 09:55:34 +00:00
err := stmts . isPluginActive . QueryRow ( uname ) . Scan ( & active )
2017-06-28 12:05:26 +00:00
if err != nil && err != ErrNoRows {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-09-10 16:57:22 +00:00
var hasPlugin = ( err == nil )
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
if plugins [ uname ] . Activate != nil {
err = plugins [ uname ] . Activate ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( err . Error ( ) , w , r , user )
2017-04-05 14:15:22 +00:00
}
}
2017-05-29 14:52:37 +00:00
2017-10-30 09:57:08 +00:00
//log.Print("err", err)
//log.Print("active", active)
2017-09-10 16:57:22 +00:00
if hasPlugin {
2017-04-05 14:15:22 +00:00
if active {
2017-10-30 09:57:08 +00:00
return LocalError ( "The plugin is already active" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-18 17:03:52 +00:00
//log.Print("updatePlugin")
2017-11-05 09:55:34 +00:00
_ , err = stmts . updatePlugin . Exec ( 1 , uname )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
} else {
2017-09-18 17:03:52 +00:00
//log.Print("addPlugin")
2017-11-05 09:55:34 +00:00
_ , err := stmts . addPlugin . Exec ( uname , 1 , 0 )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
log . Print ( "Activating plugin '" + plugin . Name + "'" )
plugin . Active = true
plugins [ uname ] = plugin
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
err = plugins [ uname ] . Init ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( err . Error ( ) , w , r , user )
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/plugins/" , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelPluginsDeactivate ( w http . ResponseWriter , r * http . Request , user User , uname string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManagePlugins {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
plugin , ok := plugins [ uname ]
if ! ok {
2017-10-30 09:57:08 +00:00
return LocalError ( "The plugin isn't registered in the system" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
var active bool
2017-11-05 09:55:34 +00:00
err := stmts . isPluginActive . QueryRow ( uname ) . Scan ( & active )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalError ( "The plugin you're trying to deactivate isn't active" , w , r , user )
2017-04-05 14:15:22 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
if ! active {
2017-10-30 09:57:08 +00:00
return LocalError ( "The plugin you're trying to deactivate isn't active" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-11-05 09:55:34 +00:00
_ , err = stmts . updatePlugin . Exec ( 0 , uname )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
plugin . Active = false
plugins [ uname ] = plugin
plugins [ uname ] . Deactivate ( )
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/plugins/" , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelPluginsInstall ( w http . ResponseWriter , r * http . Request , user User , uname string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
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 ! user . Perms . ManagePlugins {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
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 r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
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
}
plugin , ok := plugins [ uname ]
if ! ok {
2017-10-30 09:57:08 +00:00
return LocalError ( "The plugin isn't registered in the system" , w , r , user )
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 ! plugin . Installable {
2017-10-30 09:57:08 +00:00
return LocalError ( "This plugin is not installable" , w , r , user )
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 plugin . Installed {
2017-10-30 09:57:08 +00:00
return LocalError ( "This plugin has already been installed" , w , r , user )
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
}
var active bool
2017-11-05 09:55:34 +00:00
err := stmts . isPluginActive . QueryRow ( uname ) . Scan ( & active )
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 err != nil && err != ErrNoRows {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
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
var hasPlugin = ( err == 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
if plugins [ uname ] . Install != nil {
err = plugins [ uname ] . Install ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( err . Error ( ) , w , r , user )
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 plugins [ uname ] . Activate != nil {
err = plugins [ uname ] . Activate ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( err . Error ( ) , w , r , user )
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
if hasPlugin {
2017-11-05 09:55:34 +00:00
_ , err = stmts . updatePluginInstall . Exec ( 1 , uname )
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 err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
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-05 09:55:34 +00:00
_ , err = stmts . updatePlugin . Exec ( 1 , uname )
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 err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
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
}
} else {
2017-11-05 09:55:34 +00:00
_ , err := stmts . addPlugin . Exec ( uname , 1 , 1 )
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 err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
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
}
}
log . Print ( "Installing plugin '" + plugin . Name + "'" )
plugin . Active = true
plugin . Installed = true
plugins [ uname ] = plugin
err = plugins [ uname ] . Init ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( err . Error ( ) , w , r , user )
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/plugins/" , http . StatusSeeOther )
2017-10-30 09:57:08 +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-10-30 09:57:08 +00:00
func routePanelUsers ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-08-17 11:13:49 +00:00
page , _ := strconv . Atoi ( r . FormValue ( "page" ) )
perPage := 10
2017-09-03 04:50:31 +00:00
offset , page , lastPage := pageOffset ( stats . Users , page , perPage )
2017-08-17 11:13:49 +00:00
var userList [ ] User
2017-10-31 07:26:44 +00:00
// TODO: Move this into the UserStore
2017-11-05 09:55:34 +00:00
rows , err := stmts . getUsersOffset . Query ( offset , perPage )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
defer rows . Close ( )
2017-05-29 14:52:37 +00:00
2017-09-10 16:57:22 +00:00
// TODO: Add a UserStore method for iterating over global users and global user offsets
2017-04-05 14:15:22 +00:00
for rows . Next ( ) {
2017-09-22 02:21:17 +00:00
puser := & User { ID : 0 }
2017-09-03 04:50:31 +00:00
err := rows . Scan ( & puser . ID , & puser . Name , & puser . Group , & puser . Active , & puser . IsSuperAdmin , & puser . Avatar )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-22 02:21:17 +00:00
puser . initPerms ( )
2017-04-05 14:15:22 +00:00
if puser . Avatar != "" {
if puser . Avatar [ 0 ] == '.' {
puser . Avatar = "/uploads/avatar_" + strconv . Itoa ( puser . ID ) + puser . Avatar
}
} else {
2017-09-03 04:50:31 +00:00
puser . Avatar = strings . Replace ( config . Noavatar , "{id}" , strconv . Itoa ( puser . ID ) , 1 )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
if gstore . DirtyGet ( puser . Group ) . Tag != "" {
puser . Tag = gstore . DirtyGet ( puser . Group ) . Tag
2017-04-05 14:15:22 +00:00
} else {
puser . Tag = ""
}
2017-09-22 02:21:17 +00:00
userList = append ( userList , * puser )
2017-04-05 14:15:22 +00:00
}
err = rows . Err ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-08-17 11:13:49 +00:00
pageList := paginate ( stats . Users , perPage , 5 )
2017-09-03 04:50:31 +00:00
pi := PanelUserPage { "User Manager" , user , headerVars , stats , userList , pageList , page , lastPage }
if preRenderHooks [ "pre_render_panel_users" ] != nil {
if runPreRenderHook ( "pre_render_panel_users" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "panel-users.html" , pi )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelUsersEdit ( w http . ResponseWriter , r * http . Request , user User , suid string ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-06-16 10:41:30 +00:00
if ! user . Perms . EditUser {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-13 15:01:30 +00:00
uid , err := strconv . Atoi ( suid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "The provided User ID is not a valid number." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
targetUser , err := users . Get ( uid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalError ( "The user you're trying to edit doesn't exist." , w , r , user )
2017-04-05 14:15:22 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if targetUser . IsAdmin && ! user . IsAdmin {
2017-10-30 09:57:08 +00:00
return LocalError ( "Only administrators can edit the account of an administrator." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-10-30 09:57:08 +00:00
// ? - Should we stop admins from deleting all the groups? Maybe, protect the group they're currently using?
2017-09-15 22:20:01 +00:00
groups , err := gstore . GetRange ( 1 , 0 ) // ? - 0 = Go to the end
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-09-15 22:20:01 +00:00
}
2017-04-05 14:15:22 +00:00
var groupList [ ] interface { }
for _ , group := range groups [ 1 : ] {
2017-09-03 04:50:31 +00:00
if ! user . Perms . EditUserGroupAdmin && group . IsAdmin {
2017-04-05 14:15:22 +00:00
continue
}
2017-09-03 04:50:31 +00:00
if ! user . Perms . EditUserGroupSuperMod && group . IsMod {
2017-04-05 14:15:22 +00:00
continue
}
2017-09-03 04:50:31 +00:00
groupList = append ( groupList , group )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
pi := PanelPage { "User Editor" , user , headerVars , stats , groupList , targetUser }
if preRenderHooks [ "pre_render_panel_edit_user" ] != nil {
if runPreRenderHook ( "pre_render_panel_edit_user" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "panel-user-edit.html" , pi )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelUsersEditSubmit ( w http . ResponseWriter , r * http . Request , user User , suid string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . EditUser {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-13 15:01:30 +00:00
uid , err := strconv . Atoi ( suid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "The provided User ID is not a valid number." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
targetUser , err := users . Get ( uid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalError ( "The user you're trying to edit doesn't exist." , w , r , user )
2017-04-05 14:15:22 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if targetUser . IsAdmin && ! user . IsAdmin {
2017-10-30 09:57:08 +00:00
return LocalError ( "Only administrators can edit the account of other administrators." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
newname := html . EscapeString ( r . PostFormValue ( "user-name" ) )
if newname == "" {
2017-10-30 09:57:08 +00:00
return LocalError ( "You didn't put in a username." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
newemail := html . EscapeString ( r . PostFormValue ( "user-email" ) )
if newemail == "" {
2017-10-30 09:57:08 +00:00
return LocalError ( "You didn't put in an email address." , w , r , user )
2017-04-05 14:15:22 +00:00
}
if ( newemail != targetUser . Email ) && ! user . Perms . EditUserEmail {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditUserEmail permission to edit the email address of a user." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
newpassword := r . PostFormValue ( "user-password" )
if newpassword != "" && ! user . Perms . EditUserPassword {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditUserPassword permission to edit the password of a user." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
newgroup , err := strconv . Atoi ( r . PostFormValue ( "user-group" ) )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need to provide a whole number for the group ID" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
group , err := gstore . Get ( newgroup )
if err == ErrNoRows {
2017-10-30 09:57:08 +00:00
return LocalError ( "The group you're trying to place this user in doesn't exist." , w , r , user )
2017-09-15 22:20:01 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
if ! user . Perms . EditUserGroupAdmin && group . IsAdmin {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditUserGroupAdmin permission to assign someone to an administrator group." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-15 22:20:01 +00:00
if ! user . Perms . EditUserGroupSuperMod && group . IsMod {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditUserGroupSuperMod permission to assign someone to a super mod group." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-05 09:55:34 +00:00
_ , err = stmts . updateUser . Exec ( newname , newemail , newgroup , targetUser . ID )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
if newpassword != "" {
2017-09-03 04:50:31 +00:00
SetPassword ( targetUser . ID , newpassword )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-22 02:21:17 +00:00
ucache , ok := users . ( UserCache )
if ok {
ucache . CacheRemove ( targetUser . ID )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/users/edit/" + strconv . Itoa ( targetUser . ID ) , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelGroups ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-08-15 13:47:56 +00:00
page , _ := strconv . Atoi ( r . FormValue ( "page" ) )
perPage := 9
2017-09-03 04:50:31 +00:00
offset , page , lastPage := pageOffset ( stats . Groups , page , perPage )
2017-08-15 13:47:56 +00:00
2017-10-21 00:27:47 +00:00
// Skip the 'Unknown' group
2017-08-15 13:47:56 +00:00
offset ++
var count int
var groupList [ ] GroupAdmin
2017-09-15 22:20:01 +00:00
groups , _ := gstore . GetRange ( offset , 0 )
for _ , group := range groups {
2017-08-15 13:47:56 +00:00
if count == perPage {
break
}
2017-04-05 14:15:22 +00:00
var rank string
2017-09-03 04:50:31 +00:00
var rankClass string
var canEdit bool
var canDelete = false
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if group . IsAdmin {
2017-04-05 14:15:22 +00:00
rank = "Admin"
2017-09-03 04:50:31 +00:00
rankClass = "admin"
} else if group . IsMod {
2017-04-05 14:15:22 +00:00
rank = "Mod"
2017-09-03 04:50:31 +00:00
rankClass = "mod"
} else if group . IsBanned {
2017-04-05 14:15:22 +00:00
rank = "Banned"
2017-09-03 04:50:31 +00:00
rankClass = "banned"
2017-04-05 14:15:22 +00:00
} else if group . ID == 6 {
rank = "Guest"
2017-09-03 04:50:31 +00:00
rankClass = "guest"
2017-04-05 14:15:22 +00:00
} else {
rank = "Member"
2017-09-03 04:50:31 +00:00
rankClass = "member"
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
canEdit = user . Perms . EditGroup && ( ! group . IsAdmin || user . Perms . EditGroupAdmin ) && ( ! group . IsMod || user . Perms . EditGroupSuperMod )
groupList = append ( groupList , GroupAdmin { group . ID , group . Name , rank , rankClass , canEdit , canDelete } )
2017-08-15 13:47:56 +00:00
count ++
2017-04-05 14:15:22 +00:00
}
2017-08-13 11:22:34 +00:00
//log.Printf("groupList: %+v\n", groupList)
2017-05-29 14:52:37 +00:00
2017-08-15 13:47:56 +00:00
pageList := paginate ( stats . Groups , perPage , 5 )
2017-09-03 04:50:31 +00:00
pi := PanelGroupPage { "Group Manager" , user , headerVars , stats , groupList , pageList , page , lastPage }
if preRenderHooks [ "pre_render_panel_groups" ] != nil {
if runPreRenderHook ( "pre_render_panel_groups" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +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-08-13 11:22:34 +00:00
2017-09-03 04:50:31 +00:00
err := templates . ExecuteTemplate ( w , "panel-groups.html" , pi )
2017-08-13 11:22:34 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-08-13 11:22:34 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelGroupsEdit ( w http . ResponseWriter , r * http . Request , user User , sgid string ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . EditGroup {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-13 15:01:30 +00:00
gid , err := strconv . Atoi ( sgid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need to provide a whole number for the group ID" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
group , err := gstore . Get ( gid )
if err == ErrNoRows {
2017-08-13 11:22:34 +00:00
//log.Print("aaaaa monsters")
2017-10-30 09:57:08 +00:00
return NotFound ( w , r )
2017-09-15 22:20:01 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if group . IsAdmin && ! user . Perms . EditGroupAdmin {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupAdmin permission to edit an admin group." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
if group . IsMod && ! user . Perms . EditGroupSuperMod {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupSuperMod permission to edit a super-mod group." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
var rank string
2017-10-21 00:27:47 +00:00
switch {
case group . IsAdmin :
2017-04-05 14:15:22 +00:00
rank = "Admin"
2017-10-21 00:27:47 +00:00
case group . IsMod :
2017-04-05 14:15:22 +00:00
rank = "Mod"
2017-10-21 00:27:47 +00:00
case group . IsBanned :
2017-04-05 14:15:22 +00:00
rank = "Banned"
2017-10-21 00:27:47 +00:00
case group . ID == 6 :
2017-04-05 14:15:22 +00:00
rank = "Guest"
2017-10-21 00:27:47 +00:00
default :
2017-04-05 14:15:22 +00:00
rank = "Member"
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
disableRank := ! user . Perms . EditGroupGlobalPerms || ( group . ID == 6 )
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
pi := PanelEditGroupPage { "Group Editor" , user , headerVars , stats , group . ID , group . Name , group . Tag , rank , disableRank }
if preRenderHooks [ "pre_render_panel_edit_group" ] != nil {
if runPreRenderHook ( "pre_render_panel_edit_group" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "panel-group-edit.html" , pi )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelGroupsEditPerms ( w http . ResponseWriter , r * http . Request , user User , sgid string ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . EditGroup {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-13 15:01:30 +00:00
gid , err := strconv . Atoi ( sgid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "The Group ID is not a valid integer." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
group , err := gstore . Get ( gid )
if err == ErrNoRows {
2017-08-13 11:22:34 +00:00
//log.Print("aaaaa monsters")
2017-10-30 09:57:08 +00:00
return NotFound ( w , r )
2017-09-15 22:20:01 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if group . IsAdmin && ! user . Perms . EditGroupAdmin {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupAdmin permission to edit an admin group." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
if group . IsMod && ! user . Perms . EditGroupSuperMod {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupSuperMod permission to edit a super-mod group." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-10 16:57:22 +00:00
// TODO: Load the phrases in bulk for efficiency?
2017-04-05 14:15:22 +00:00
var localPerms [ ] NameLangToggle
2017-09-03 04:50:31 +00:00
localPerms = append ( localPerms , NameLangToggle { "ViewTopic" , GetLocalPermPhrase ( "ViewTopic" ) , group . Perms . ViewTopic } )
localPerms = append ( localPerms , NameLangToggle { "LikeItem" , GetLocalPermPhrase ( "LikeItem" ) , group . Perms . LikeItem } )
localPerms = append ( localPerms , NameLangToggle { "CreateTopic" , GetLocalPermPhrase ( "CreateTopic" ) , group . Perms . CreateTopic } )
2017-04-05 14:15:22 +00:00
//<--
2017-09-03 04:50:31 +00:00
localPerms = append ( localPerms , NameLangToggle { "EditTopic" , GetLocalPermPhrase ( "EditTopic" ) , group . Perms . EditTopic } )
localPerms = append ( localPerms , NameLangToggle { "DeleteTopic" , GetLocalPermPhrase ( "DeleteTopic" ) , group . Perms . DeleteTopic } )
localPerms = append ( localPerms , NameLangToggle { "CreateReply" , GetLocalPermPhrase ( "CreateReply" ) , group . Perms . CreateReply } )
localPerms = append ( localPerms , NameLangToggle { "EditReply" , GetLocalPermPhrase ( "EditReply" ) , group . Perms . EditReply } )
localPerms = append ( localPerms , NameLangToggle { "DeleteReply" , GetLocalPermPhrase ( "DeleteReply" ) , group . Perms . DeleteReply } )
localPerms = append ( localPerms , NameLangToggle { "PinTopic" , GetLocalPermPhrase ( "PinTopic" ) , group . Perms . PinTopic } )
localPerms = append ( localPerms , NameLangToggle { "CloseTopic" , GetLocalPermPhrase ( "CloseTopic" ) , group . Perms . CloseTopic } )
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
var globalPerms [ ] NameLangToggle
2017-09-03 04:50:31 +00:00
globalPerms = append ( globalPerms , NameLangToggle { "BanUsers" , GetGlobalPermPhrase ( "BanUsers" ) , group . Perms . BanUsers } )
globalPerms = append ( globalPerms , NameLangToggle { "ActivateUsers" , GetGlobalPermPhrase ( "ActivateUsers" ) , group . Perms . ActivateUsers } )
globalPerms = append ( globalPerms , NameLangToggle { "EditUser" , GetGlobalPermPhrase ( "EditUser" ) , group . Perms . EditUser } )
globalPerms = append ( globalPerms , NameLangToggle { "EditUserEmail" , GetGlobalPermPhrase ( "EditUserEmail" ) , group . Perms . EditUserEmail } )
globalPerms = append ( globalPerms , NameLangToggle { "EditUserPassword" , GetGlobalPermPhrase ( "EditUserPassword" ) , group . Perms . EditUserPassword } )
globalPerms = append ( globalPerms , NameLangToggle { "EditUserGroup" , GetGlobalPermPhrase ( "EditUserGroup" ) , group . Perms . EditUserGroup } )
globalPerms = append ( globalPerms , NameLangToggle { "EditUserGroupSuperMod" , GetGlobalPermPhrase ( "EditUserGroupSuperMod" ) , group . Perms . EditUserGroupSuperMod } )
globalPerms = append ( globalPerms , NameLangToggle { "EditUserGroupAdmin" , GetGlobalPermPhrase ( "EditUserGroupAdmin" ) , group . Perms . EditUserGroupAdmin } )
globalPerms = append ( globalPerms , NameLangToggle { "EditGroup" , GetGlobalPermPhrase ( "EditGroup" ) , group . Perms . EditGroup } )
globalPerms = append ( globalPerms , NameLangToggle { "EditGroupLocalPerms" , GetGlobalPermPhrase ( "EditGroupLocalPerms" ) , group . Perms . EditGroupLocalPerms } )
globalPerms = append ( globalPerms , NameLangToggle { "EditGroupGlobalPerms" , GetGlobalPermPhrase ( "EditGroupGlobalPerms" ) , group . Perms . EditGroupGlobalPerms } )
globalPerms = append ( globalPerms , NameLangToggle { "EditGroupSuperMod" , GetGlobalPermPhrase ( "EditGroupSuperMod" ) , group . Perms . EditGroupSuperMod } )
globalPerms = append ( globalPerms , NameLangToggle { "EditGroupAdmin" , GetGlobalPermPhrase ( "EditGroupAdmin" ) , group . Perms . EditGroupAdmin } )
globalPerms = append ( globalPerms , NameLangToggle { "ManageForums" , GetGlobalPermPhrase ( "ManageForums" ) , group . Perms . ManageForums } )
globalPerms = append ( globalPerms , NameLangToggle { "EditSettings" , GetGlobalPermPhrase ( "EditSettings" ) , group . Perms . EditSettings } )
globalPerms = append ( globalPerms , NameLangToggle { "ManageThemes" , GetGlobalPermPhrase ( "ManageThemes" ) , group . Perms . ManageThemes } )
globalPerms = append ( globalPerms , NameLangToggle { "ManagePlugins" , GetGlobalPermPhrase ( "ManagePlugins" ) , group . Perms . ManagePlugins } )
globalPerms = append ( globalPerms , NameLangToggle { "ViewAdminLogs" , GetGlobalPermPhrase ( "ViewAdminLogs" ) , group . Perms . ViewAdminLogs } )
globalPerms = append ( globalPerms , NameLangToggle { "ViewIPs" , GetGlobalPermPhrase ( "ViewIPs" ) , group . Perms . 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
globalPerms = append ( globalPerms , NameLangToggle { "UploadFiles" , GetGlobalPermPhrase ( "UploadFiles" ) , group . Perms . UploadFiles } )
2017-09-03 04:50:31 +00:00
pi := PanelEditGroupPermsPage { "Group Editor" , user , headerVars , stats , group . ID , group . Name , localPerms , globalPerms }
if preRenderHooks [ "pre_render_panel_edit_group_perms" ] != nil {
if runPreRenderHook ( "pre_render_panel_edit_group_perms" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "panel-group-edit-perms.html" , pi )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelGroupsEditSubmit ( w http . ResponseWriter , r * http . Request , user User , sgid string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . EditGroup {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-13 15:01:30 +00:00
gid , err := strconv . Atoi ( sgid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need to provide a whole number for the group ID" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
group , err := gstore . Get ( gid )
if err == ErrNoRows {
2017-08-13 11:22:34 +00:00
//log.Print("aaaaa monsters")
2017-10-30 09:57:08 +00:00
return NotFound ( w , r )
2017-09-15 22:20:01 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if group . IsAdmin && ! user . Perms . EditGroupAdmin {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupAdmin permission to edit an admin group." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
if group . IsMod && ! user . Perms . EditGroupSuperMod {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupSuperMod permission to edit a super-mod group." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
gname := r . FormValue ( "group-name" )
if gname == "" {
2017-10-30 09:57:08 +00:00
return LocalError ( "The group name can't be left blank." , w , r , user )
2017-04-05 14:15:22 +00:00
}
gtag := r . FormValue ( "group-tag" )
rank := r . FormValue ( "group-type" )
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
var originalRank string
if group . IsAdmin {
originalRank = "Admin"
} else if group . IsMod {
originalRank = "Mod"
} else if group . IsBanned {
originalRank = "Banned"
2017-04-05 14:15:22 +00:00
} else if group . ID == 6 {
2017-09-03 04:50:31 +00:00
originalRank = "Guest"
2017-04-05 14:15:22 +00:00
} else {
2017-09-03 04:50:31 +00:00
originalRank = "Member"
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if rank != originalRank {
2017-04-05 14:15:22 +00:00
if ! user . Perms . EditGroupGlobalPerms {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupGlobalPerms permission to change the group type." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
switch rank {
case "Admin" :
if ! user . Perms . EditGroupAdmin {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupAdmin permission to designate this group as an admin group." , w , r , user )
2017-09-03 04:50:31 +00:00
}
2017-10-21 00:27:47 +00:00
err = group . ChangeRank ( true , true , false )
2017-09-03 04:50:31 +00:00
case "Mod" :
if ! user . Perms . EditGroupSuperMod {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupSuperMod permission to designate this group as a super-mod group." , w , r , user )
2017-09-03 04:50:31 +00:00
}
2017-10-21 00:27:47 +00:00
err = group . ChangeRank ( false , true , false )
2017-09-03 04:50:31 +00:00
case "Banned" :
2017-10-21 00:27:47 +00:00
err = group . ChangeRank ( false , false , true )
2017-09-03 04:50:31 +00:00
case "Guest" :
2017-10-30 09:57:08 +00:00
return LocalError ( "You can't designate a group as a guest group." , w , r , user )
2017-09-03 04:50:31 +00:00
case "Member" :
2017-10-21 00:27:47 +00:00
err = group . ChangeRank ( false , false , false )
2017-09-03 04:50:31 +00:00
default :
2017-10-30 09:57:08 +00:00
return LocalError ( "Invalid group type." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-10-21 00:27:47 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-10-21 00:27:47 +00:00
}
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-02 13:35:19 +00:00
// TODO: Move this to *Group
2017-11-05 09:55:34 +00:00
_ , err = stmts . updateGroup . Exec ( gname , gtag , gid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-11-02 13:35:19 +00:00
gstore . Reload ( gid )
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/groups/edit/" + strconv . Itoa ( gid ) , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelGroupsEditPermsSubmit ( w http . ResponseWriter , r * http . Request , user User , sgid string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . EditGroup {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-13 15:01:30 +00:00
gid , err := strconv . Atoi ( sgid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "The Group ID is not a valid integer." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
group , err := gstore . Get ( gid )
if err == ErrNoRows {
2017-08-13 11:22:34 +00:00
//log.Print("aaaaa monsters o.o")
2017-10-30 09:57:08 +00:00
return NotFound ( w , r )
2017-09-15 22:20:01 +00:00
} else if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
if group . IsAdmin && ! user . Perms . EditGroupAdmin {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupAdmin permission to edit an admin group." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
if group . IsMod && ! user . Perms . EditGroupSuperMod {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupSuperMod permission to edit a super-mod group." , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-11 10:24:03 +00:00
////var lpmap map[string]bool = make(map[string]bool)
2017-09-03 04:50:31 +00:00
var pmap = make ( map [ string ] bool )
2017-04-05 14:15:22 +00:00
if user . Perms . EditGroupLocalPerms {
pplist := LocalPermList
for _ , perm := range pplist {
pvalue := r . PostFormValue ( "group-perm-" + perm )
2017-04-13 15:01:30 +00:00
pmap [ perm ] = ( pvalue == "1" )
2017-04-05 14:15:22 +00:00
}
}
2017-05-29 14:52:37 +00:00
2017-09-11 10:24:03 +00:00
////var gpmap map[string]bool = make(map[string]bool)
2017-04-05 14:15:22 +00:00
if user . Perms . EditGroupGlobalPerms {
gplist := GlobalPermList
for _ , perm := range gplist {
pvalue := r . PostFormValue ( "group-perm-" + perm )
2017-04-13 15:01:30 +00:00
pmap [ perm ] = ( pvalue == "1" )
2017-04-05 14:15:22 +00:00
}
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
pjson , err := json . Marshal ( pmap )
if err != nil {
2017-10-30 09:57:08 +00:00
return LocalError ( "Unable to marshal the data" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-11-05 09:55:34 +00:00
_ , err = stmts . updateGroupPerms . Exec ( pjson , gid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
err = rebuildGroupPermissions ( gid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/groups/edit/perms/" + strconv . Itoa ( gid ) , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelGroupsCreateSubmit ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . EditGroup {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
groupName := r . PostFormValue ( "group-name" )
if groupName == "" {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need a name for this group!" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
groupTag := r . PostFormValue ( "group-tag" )
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
var isAdmin , isMod , isBanned bool
2017-04-05 14:15:22 +00:00
if user . Perms . EditGroupGlobalPerms {
2017-09-03 04:50:31 +00:00
groupType := r . PostFormValue ( "group-type" )
if groupType == "Admin" {
2017-04-05 14:15:22 +00:00
if ! user . Perms . EditGroupAdmin {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupAdmin permission to create admin groups" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
isAdmin = true
isMod = true
} else if groupType == "Mod" {
2017-04-05 14:15:22 +00:00
if ! user . Perms . EditGroupSuperMod {
2017-10-30 09:57:08 +00:00
return LocalError ( "You need the EditGroupSuperMod permission to create admin groups" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
isMod = true
} else if groupType == "Banned" {
isBanned = true
2017-04-05 14:15:22 +00:00
}
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
gid , err := gstore . Create ( groupName , groupTag , isAdmin , isMod , isBanned )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/groups/edit/" + strconv . Itoa ( gid ) , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelThemes ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManageThemes {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-13 15:01:30 +00:00
var pThemeList , vThemeList [ ] Theme
2017-04-05 14:15:22 +00:00
for _ , theme := range themes {
if theme . HideFromThemes {
continue
}
if theme . ForkOf == "" {
2017-09-03 04:50:31 +00:00
pThemeList = append ( pThemeList , theme )
2017-04-05 14:15:22 +00:00
} else {
2017-09-03 04:50:31 +00:00
vThemeList = append ( vThemeList , theme )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
pi := PanelThemesPage { "Theme Manager" , user , headerVars , stats , pThemeList , vThemeList }
if preRenderHooks [ "pre_render_panel_themes" ] != nil {
if runPreRenderHook ( "pre_render_panel_themes" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err := templates . ExecuteTemplate ( w , "panel-themes.html" , pi )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelThemesSetDefault ( w http . ResponseWriter , r * http . Request , user User , uname string ) RouteError {
_ , ferr := SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-05 14:15:22 +00:00
}
2017-06-16 10:41:30 +00:00
if ! user . Perms . ManageThemes {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
if r . FormValue ( "session" ) != user . Session {
2017-10-30 09:57:08 +00:00
return SecurityError ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
theme , ok := themes [ uname ]
if ! ok {
2017-10-30 09:57:08 +00:00
return LocalError ( "The theme isn't registered in the system" , w , r , user )
2017-04-05 14:15:22 +00:00
}
if theme . Disabled {
2017-10-30 09:57:08 +00:00
return LocalError ( "You must not enable this theme" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
var isDefault bool
2017-10-30 09:57:08 +00:00
log . Print ( "uname" , uname ) // TODO: Do we need to log this?
2017-11-05 09:55:34 +00:00
err := stmts . isThemeDefault . QueryRow ( uname ) . Scan ( & isDefault )
2017-06-28 12:05:26 +00:00
if err != nil && err != ErrNoRows {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
hasTheme := err != ErrNoRows
if hasTheme {
2017-10-30 09:57:08 +00:00
log . Print ( "isDefault" , isDefault ) // TODO: Do we need to log this?
2017-04-05 14:15:22 +00:00
if isDefault {
2017-10-30 09:57:08 +00:00
return LocalError ( "The theme is already active" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-11-05 09:55:34 +00:00
_ , err = stmts . updateTheme . Exec ( 1 , uname )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
} else {
2017-11-05 09:55:34 +00:00
_ , err := stmts . addTheme . Exec ( uname , 1 )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
}
2017-05-29 14:52:37 +00:00
2017-09-10 16:57:22 +00:00
// TODO: Make this less racey
changeDefaultThemeMutex . Lock ( )
defaultTheme := defaultThemeBox . Load ( ) . ( string )
2017-11-05 09:55:34 +00:00
_ , err = stmts . updateTheme . Exec ( 0 , defaultTheme )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
log . Print ( "Setting theme '" + theme . Name + "' as the default theme" )
theme . Active = true
themes [ uname ] = theme
2017-05-29 14:52:37 +00:00
2017-04-05 14:15:22 +00:00
dTheme , ok := themes [ defaultTheme ]
if ! ok {
2017-10-30 09:57:08 +00:00
return InternalError ( errors . New ( "The default theme is missing" ) , w , r )
2017-04-05 14:15:22 +00:00
}
dTheme . Active = false
themes [ defaultTheme ] = dTheme
2017-05-29 14:52:37 +00:00
2017-09-10 16:57:22 +00:00
defaultThemeBox . Store ( uname )
2017-09-03 04:50:31 +00:00
resetTemplateOverrides ( )
mapThemeTemplates ( theme )
2017-09-10 16:57:22 +00:00
changeDefaultThemeMutex . Unlock ( )
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
http . Redirect ( w , r , "/panel/themes/" , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-04-06 17:37:32 +00:00
2017-10-30 09:57:08 +00:00
func routePanelBackups ( w http . ResponseWriter , r * http . Request , user User , backupURL string ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-09-23 19:57:13 +00:00
}
if ! user . IsSuperAdmin {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-09-23 19:57:13 +00:00
}
if backupURL != "" {
// We don't want them trying to break out of this directory, it shouldn't hurt since it's a super admin, but it's always good to practice good security hygiene, especially if this is one of many instances on a managed server not controlled by the superadmin/s
backupURL = Stripslashes ( backupURL )
var ext = filepath . Ext ( "./backups/" + backupURL )
if ext == ".sql" {
info , err := os . Stat ( "./backups/" + backupURL )
if err != nil {
2017-10-30 09:57:08 +00:00
return NotFound ( w , r )
2017-09-23 19:57:13 +00:00
}
// TODO: Change the served filename to gosora_backup_%timestamp%.sql, the time the file was generated, not when it was modified aka what the name of it should be
w . Header ( ) . Set ( "Content-Disposition" , "attachment; filename=gosora_backup.sql" )
w . Header ( ) . Set ( "Content-Length" , strconv . FormatInt ( info . Size ( ) , 10 ) )
// TODO: Fix the problem where non-existent files aren't greeted with custom 404s on ServeFile()'s side
http . ServeFile ( w , r , "./backups/" + backupURL )
2017-10-30 09:57:08 +00:00
return nil
2017-09-23 19:57:13 +00:00
}
2017-10-30 09:57:08 +00:00
return NotFound ( w , r )
2017-09-23 19:57:13 +00:00
}
var backupList [ ] backupItem
backupFiles , err := ioutil . ReadDir ( "./backups" )
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-09-23 19:57:13 +00:00
}
for _ , backupFile := range backupFiles {
var ext = filepath . Ext ( backupFile . Name ( ) )
if ext != ".sql" {
continue
}
backupList = append ( backupList , backupItem { backupFile . Name ( ) , backupFile . ModTime ( ) } )
}
pi := PanelBackupPage { "Backups" , user , headerVars , stats , backupList }
err = templates . ExecuteTemplate ( w , "panel-backups.html" , pi )
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-09-23 19:57:13 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-09-23 19:57:13 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelLogsMod ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-04-06 17:37:32 +00:00
}
2017-05-29 14:52:37 +00:00
2017-08-17 11:13:49 +00:00
var logCount int
2017-11-05 09:55:34 +00:00
err := stmts . modlogCount . QueryRow ( ) . Scan ( & logCount )
2017-08-17 11:13:49 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-08-17 11:13:49 +00:00
}
page , _ := strconv . Atoi ( r . FormValue ( "page" ) )
perPage := 10
2017-09-03 04:50:31 +00:00
offset , page , lastPage := pageOffset ( logCount , page , perPage )
2017-08-17 11:13:49 +00:00
2017-11-05 09:55:34 +00:00
rows , err := stmts . getModlogsOffset . Query ( offset , perPage )
2017-04-06 17:37:32 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-06 17:37:32 +00:00
}
defer rows . Close ( )
2017-05-29 14:52:37 +00:00
2017-09-23 19:57:13 +00:00
var logs [ ] logItem
2017-04-06 17:37:32 +00:00
var action , elementType , ipaddress , doneAt string
var elementID , actorID int
for rows . Next ( ) {
2017-09-03 04:50:31 +00:00
err := rows . Scan ( & action , & elementID , & elementType , & ipaddress , & actorID , & doneAt )
2017-04-06 17:37:32 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-06 17:37:32 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-15 22:20:01 +00:00
actor , err := users . Get ( actorID )
2017-04-06 17:37:32 +00:00
if err != nil {
2017-09-03 04:50:31 +00:00
actor = & User { Name : "Unknown" , Link : buildProfileURL ( "unknown" , 0 ) }
2017-04-06 17:37:32 +00:00
}
2017-05-29 14:52:37 +00:00
2017-09-03 04:50:31 +00:00
switch action {
case "lock" :
2017-09-15 22:20:01 +00:00
topic , err := topics . Get ( elementID )
2017-09-03 04:50:31 +00:00
if err != nil {
topic = & Topic { Title : "Unknown" , Link : buildProfileURL ( "unknown" , 0 ) }
}
action = "<a href='" + topic . Link + "'>" + topic . Title + "</a> was locked by <a href='" + actor . Link + "'>" + actor . Name + "</a>"
case "unlock" :
2017-09-15 22:20:01 +00:00
topic , err := topics . Get ( elementID )
2017-09-03 04:50:31 +00:00
if err != nil {
topic = & Topic { Title : "Unknown" , Link : buildProfileURL ( "unknown" , 0 ) }
}
action = "<a href='" + topic . Link + "'>" + topic . Title + "</a> was reopened by <a href='" + actor . Link + "'>" + actor . Name + "</a>"
case "stick" :
2017-09-15 22:20:01 +00:00
topic , err := topics . Get ( elementID )
2017-09-03 04:50:31 +00:00
if err != nil {
topic = & Topic { Title : "Unknown" , Link : buildProfileURL ( "unknown" , 0 ) }
}
action = "<a href='" + topic . Link + "'>" + topic . Title + "</a> was pinned by <a href='" + actor . Link + "'>" + actor . Name + "</a>"
case "unstick" :
2017-09-15 22:20:01 +00:00
topic , err := topics . Get ( elementID )
2017-09-03 04:50:31 +00:00
if err != nil {
topic = & Topic { Title : "Unknown" , Link : buildProfileURL ( "unknown" , 0 ) }
}
action = "<a href='" + topic . Link + "'>" + topic . Title + "</a> was unpinned by <a href='" + actor . Link + "'>" + actor . Name + "</a>"
case "delete" :
if elementType == "topic" {
action = "Topic #" + strconv . Itoa ( elementID ) + " was deleted by <a href='" + actor . Link + "'>" + actor . Name + "</a>"
} else {
topic , err := getTopicByReply ( elementID )
2017-04-06 17:37:32 +00:00
if err != nil {
2017-09-03 04:50:31 +00:00
topic = & Topic { Title : "Unknown" , Link : buildProfileURL ( "unknown" , 0 ) }
2017-04-06 17:37:32 +00:00
}
2017-09-03 04:50:31 +00:00
action = "A reply in <a href='" + topic . Link + "'>" + topic . Title + "</a> was deleted by <a href='" + actor . Link + "'>" + actor . Name + "</a>"
}
case "ban" :
2017-09-15 22:20:01 +00:00
targetUser , err := users . Get ( elementID )
2017-09-03 04:50:31 +00:00
if err != nil {
targetUser = & User { Name : "Unknown" , Link : buildProfileURL ( "unknown" , 0 ) }
}
action = "<a href='" + targetUser . Link + "'>" + targetUser . Name + "</a> was banned by <a href='" + actor . Link + "'>" + actor . Name + "</a>"
case "unban" :
2017-09-15 22:20:01 +00:00
targetUser , err := users . Get ( elementID )
2017-09-03 04:50:31 +00:00
if err != nil {
targetUser = & User { Name : "Unknown" , Link : buildProfileURL ( "unknown" , 0 ) }
}
action = "<a href='" + targetUser . Link + "'>" + targetUser . Name + "</a> was unbanned by <a href='" + actor . Link + "'>" + actor . Name + "</a>"
case "activate" :
2017-09-15 22:20:01 +00:00
targetUser , err := users . Get ( elementID )
2017-09-03 04:50:31 +00:00
if err != nil {
targetUser = & User { Name : "Unknown" , Link : buildProfileURL ( "unknown" , 0 ) }
}
action = "<a href='" + targetUser . Link + "'>" + targetUser . Name + "</a> was activated by <a href='" + actor . Link + "'>" + actor . Name + "</a>"
default :
action = "Unknown action '" + action + "' by <a href='" + actor . Link + "'>" + actor . Name + "</a>"
2017-04-06 17:37:32 +00:00
}
2017-09-23 19:57:13 +00:00
logs = append ( logs , logItem { Action : template . HTML ( action ) , IPAddress : ipaddress , DoneAt : doneAt } )
2017-04-06 17:37:32 +00:00
}
err = rows . Err ( )
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-06 17:37:32 +00:00
}
2017-05-29 14:52:37 +00:00
2017-08-17 11:13:49 +00:00
pageList := paginate ( logCount , perPage , 5 )
2017-09-03 04:50:31 +00:00
pi := PanelLogsPage { "Moderation Logs" , user , headerVars , stats , logs , pageList , page , lastPage }
if preRenderHooks [ "pre_render_panel_mod_log" ] != nil {
if runPreRenderHook ( "pre_render_panel_mod_log" , w , r , & user , & pi ) {
2017-10-30 09:57:08 +00:00
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
}
2017-09-03 04:50:31 +00:00
err = templates . ExecuteTemplate ( w , "panel-modlogs.html" , pi )
2017-04-06 17:37:32 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-08-15 13:47:56 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-08-15 13:47:56 +00:00
}
2017-10-30 09:57:08 +00:00
func routePanelDebug ( w http . ResponseWriter , r * http . Request , user User ) RouteError {
headerVars , stats , ferr := PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
2017-08-15 13:47:56 +00:00
}
2017-09-03 04:50:31 +00:00
if ! user . IsAdmin {
2017-10-30 09:57:08 +00:00
return NoPermissions ( w , r , user )
2017-08-15 13:47:56 +00:00
}
uptime := "..."
2017-09-03 04:50:31 +00:00
dbStats := db . Stats ( )
openConnCount := dbStats . OpenConnections
2017-08-15 13:47:56 +00:00
// Disk I/O?
2017-09-03 04:50:31 +00:00
pi := PanelDebugPage { "Debug" , user , headerVars , stats , uptime , openConnCount , dbAdapter }
err := templates . ExecuteTemplate ( w , "panel-debug.html" , pi )
2017-08-15 13:47:56 +00:00
if err != nil {
2017-10-30 09:57:08 +00:00
return InternalError ( err , w , r )
2017-04-06 17:37:32 +00:00
}
2017-10-30 09:57:08 +00:00
return nil
2017-04-06 17:37:32 +00:00
}