2017-04-05 14:15:22 +00:00
package main
2017-05-07 08:31:41 +00:00
import (
2017-12-30 05:47:46 +00:00
"database/sql"
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-11-11 04:06:16 +00:00
"./common"
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-11-11 04:06:16 +00:00
func routePanel ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-23 05:37:08 +00:00
lessThanSwitch := func ( number int , lowerBound int , midBound int ) string {
switch {
case number < lowerBound :
return "stat_green"
case number < midBound :
return "stat_orange"
}
return "stat_red"
}
2017-05-07 08:31:41 +00:00
var ramstr , ramColour string
memres , err := mem . VirtualMemory ( )
if err != nil {
ramstr = "Unknown"
} else {
2017-11-11 04:06:16 +00:00
totalCount , totalUnit := common . ConvertByteUnit ( float64 ( memres . Total ) )
usedCount := common . 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
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-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-11-23 05:37:08 +00:00
ramColour = lessThanSwitch ( int ( ramperc ) , 50 , 75 )
}
greaterThanSwitch := func ( number int , lowerBound int , midBound int ) string {
switch {
case number > midBound :
return "stat_green"
case number > lowerBound :
return "stat_orange"
2017-05-07 08:31:41 +00:00
}
2017-11-23 05:37:08 +00:00
return "stat_red"
2017-05-07 08:31:41 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-23 05:37:08 +00:00
// TODO: Add a stat store for this?
2017-12-30 05:47:46 +00:00
var intErr error
var extractStat = func ( stmt * sql . Stmt ) ( stat int ) {
err := stmt . QueryRow ( ) . Scan ( & stat )
if err != nil && err != ErrNoRows {
intErr = err
}
return stat
2017-05-07 08:31:41 +00:00
}
2017-12-30 05:47:46 +00:00
var postCount = extractStat ( stmts . todaysPostCount )
2017-09-03 04:50:31 +00:00
var postInterval = "day"
2017-11-23 05:37:08 +00:00
var postColour = greaterThanSwitch ( postCount , 5 , 25 )
2017-05-29 14:52:37 +00:00
2017-12-30 05:47:46 +00:00
var topicCount = extractStat ( stmts . todaysTopicCount )
2017-09-03 04:50:31 +00:00
var topicInterval = "day"
2017-11-23 05:37:08 +00:00
var topicColour = greaterThanSwitch ( topicCount , 0 , 8 )
2017-05-29 14:52:37 +00:00
2017-12-30 05:47:46 +00:00
var reportCount = extractStat ( stmts . todaysReportCount )
2017-09-03 04:50:31 +00:00
var reportInterval = "week"
2017-05-29 14:52:37 +00:00
2017-12-30 05:47:46 +00:00
var newUserCount = extractStat ( stmts . todaysNewUserCount )
2017-09-03 04:50:31 +00:00
var newUserInterval = "week"
2017-05-29 14:52:37 +00:00
2017-12-30 05:47:46 +00:00
// Did any of the extractStats fail?
if intErr != nil {
return common . InternalError ( intErr , w , r )
}
2017-11-11 04:06:16 +00:00
var gridElements = [ ] common . GridElement {
common . GridElement { "dash-version" , "v" + version . String ( ) , 0 , "grid_istat stat_green" , "" , "" , "Gosora is up-to-date :)" } ,
common . GridElement { "dash-cpu" , "CPU: " + cpustr , 1 , "grid_istat " + cpuColour , "" , "" , "The global CPU usage of this server" } ,
common . 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-12-30 05:47:46 +00:00
reqCount := 0
2017-05-29 14:52:37 +00:00
2017-11-23 05:37:08 +00:00
var onlineColour = greaterThanSwitch ( totonline , 3 , 10 )
var onlineGuestsColour = greaterThanSwitch ( gonline , 1 , 10 )
var onlineUsersColour = greaterThanSwitch ( uonline , 1 , 5 )
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
totonline , totunit := common . ConvertFriendlyUnit ( totonline )
uonline , uunit := common . ConvertFriendlyUnit ( uonline )
gonline , gunit := common . ConvertFriendlyUnit ( gonline )
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
gridElements = append ( gridElements , common . GridElement { "dash-totonline" , strconv . Itoa ( totonline ) + totunit + " online" , 3 , "grid_stat " + onlineColour , "" , "" , "The number of people who are currently online" } )
gridElements = append ( gridElements , common . GridElement { "dash-gonline" , strconv . Itoa ( gonline ) + gunit + " guests online" , 4 , "grid_stat " + onlineGuestsColour , "" , "" , "The number of guests who are currently online" } )
gridElements = append ( gridElements , common . GridElement { "dash-uonline" , strconv . Itoa ( uonline ) + uunit + " users online" , 5 , "grid_stat " + onlineUsersColour , "" , "" , "The number of logged-in users who are currently online" } )
2017-12-30 05:47:46 +00:00
gridElements = append ( gridElements , common . GridElement { "dash-reqs" , strconv . Itoa ( reqCount ) + " reqs / second" , 7 , "grid_stat grid_end_group " + topicColour , "" , "" , "The number of requests over the last 24 hours" } )
2017-05-07 08:31:41 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
gridElements = append ( gridElements , common . 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 , common . GridElement { "dash-topicsperday" , strconv . Itoa ( topicCount ) + " topics / " + topicInterval , 7 , "grid_stat " + topicColour , "" , "" , "The number of new topics over the last 24 hours" } )
2017-12-30 05:47:46 +00:00
gridElements = append ( gridElements , common . 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-11-11 04:06:16 +00:00
gridElements = append ( gridElements , common . 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 , common . 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 , common . 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-12-30 05:47:46 +00:00
if false {
gridElements = append ( gridElements , common . 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 , common . 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 , common . 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-12-27 23:38:37 +00:00
pi := common . PanelDashboardPage { common . GetTitlePhrase ( "panel-dashboard" ) , user , headerVars , stats , "dashboard" , gridElements }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_dashboard" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-dashboard.html" , pi )
2017-07-17 10:23:42 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelForums ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
forums , err := common . Forums . GetAll ( )
2017-06-28 12:05:26 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
fadmin := common . ForumAdmin { forum . ID , forum . Name , forum . Desc , forum . Active , forum . Preset , forum . TopicCount , common . 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-12-27 23:38:37 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel-forums" ) , user , headerVars , stats , "forums" , forumList , nil }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_forums" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-forums.html" , pi )
2017-05-29 14:52:37 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-05-29 14:52:37 +00:00
}
2017-11-23 05:37:08 +00:00
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-11-11 04:06:16 +00:00
func routePanelForumsCreateSubmit ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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
fname := r . PostFormValue ( "forum-name" )
2017-06-05 11:57:27 +00:00
fdesc := r . PostFormValue ( "forum-desc" )
2017-11-11 04:06:16 +00:00
fpreset := common . 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-11-23 05:37:08 +00:00
_ , err := common . Forums . Create ( fname , fdesc , active , fpreset )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelForumsDelete ( w http . ResponseWriter , r * http . Request , user common . User , sfid string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
forum , err := common . Forums . Get ( fid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-23 05:37:08 +00:00
// TODO: Make this a phrase
2017-09-10 16:57:22 +00:00
confirmMsg := "Are you sure you want to delete the '" + forum . Name + "' forum?"
2017-11-11 04:06:16 +00:00
yousure := common . AreYouSure { "/panel/forums/delete/submit/" + strconv . Itoa ( fid ) , confirmMsg }
2017-05-29 14:52:37 +00:00
2017-12-27 23:38:37 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel-delete-forum" ) , user , headerVars , stats , "forums" , tList , yousure }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_delete_forum" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "areyousure.html" , pi )
2017-08-13 11:22:34 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelForumsDeleteSubmit ( w http . ResponseWriter , r * http . Request , user common . User , sfid string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
err = common . Forums . Delete ( fid )
2017-07-12 11:05:18 +00:00
if err == ErrNoRows {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelForumsEdit ( w http . ResponseWriter , r * http . Request , user common . User , sfid string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
forum , err := common . Forums . Get ( fid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
glist , err := common . Groups . GetAll ( )
2017-09-15 22:20:01 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-09-15 22:20:01 +00:00
}
2017-11-11 04:06:16 +00:00
var gplist [ ] common . GroupForumPermPreset
2017-06-05 11:57:27 +00:00
for gid , group := range glist {
if gid == 0 {
continue
}
2017-11-11 04:06:16 +00:00
gplist = append ( gplist , common . GroupForumPermPreset { group , common . ForumPermsToGroupForumPreset ( group . Forums [ fid ] ) } )
2017-06-05 11:57:27 +00:00
}
2017-12-27 23:38:37 +00:00
pi := common . PanelEditForumPage { common . GetTitlePhrase ( "panel-edit-forum" ) , user , headerVars , stats , "forums" , forum . ID , forum . Name , forum . Desc , forum . Active , forum . Preset , gplist }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_edit_forum" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-forum-edit.html" , pi )
2017-06-05 11:57:27 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-06-05 11:57:27 +00:00
}
2017-11-23 05:37:08 +00:00
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-11-11 04:06:16 +00:00
func routePanelForumsEditSubmit ( w http . ResponseWriter , r * http . Request , user common . User , sfid string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . NoPermissions ( 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
forum , err := common . Forums . Get ( fid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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" )
2017-11-11 04:06:16 +00:00
forumPreset := common . StripInvalidPreset ( r . PostFormValue ( "forum_preset" ) )
2017-09-25 00:48:35 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelForumsEditPermsSubmit ( w http . ResponseWriter , r * http . Request , user common . User , sfid string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . NoPermissions ( 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . LocalErrorJSQ ( "Invalid Group ID" , w , r , user , isJs )
2017-06-05 11:57:27 +00:00
}
2017-11-23 05:37:08 +00:00
forum , err := common . Forums . Get ( fid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-11-11 04:06:16 +00:00
return common . LocalErrorJSQ ( "This forum doesn't exist" , w , r , user , isJs )
2017-06-28 12:05:26 +00:00
} else if err != nil {
2017-11-11 04:06:16 +00:00
return common . InternalErrorJSQ ( err , w , r , isJs )
2017-06-28 12:05:26 +00:00
}
2017-11-13 05:22:37 +00:00
permPreset := common . StripInvalidGroupForumPreset ( r . PostFormValue ( "perm_preset" ) )
err = forum . SetPreset ( permPreset , gid )
if err != nil {
return common . LocalErrorJSQ ( err . Error ( ) , w , r , user , isJs )
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-12-30 05:47:46 +00:00
func routePanelAnalyticsViews ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
pi := common . PanelPage { common . GetTitlePhrase ( "panel-analytics" ) , user , headerVars , stats , "analytics" , tList , nil }
if common . PreRenderHooks [ "pre_render_panel_analytics" ] != nil {
if common . RunPreRenderHook ( "pre_render_panel_analytics" , w , r , & user , & pi ) {
return nil
}
}
err := common . Templates . ExecuteTemplate ( w , "panel-analytics-views.html" , pi )
if err != nil {
return common . InternalError ( err , w , r )
}
return nil
}
2017-11-11 04:06:16 +00:00
func routePanelSettings ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-09-10 16:57:22 +00:00
var settingList = make ( map [ string ] interface { } )
2017-11-23 05:37:08 +00:00
settings , err := headerVars . Settings . BypassGetAll ( )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-23 05:37:08 +00:00
// nolint need the type so people viewing this file understand what it returns without visiting phrases.go
2017-11-11 04:06:16 +00:00
var settingLabels map [ string ] string = common . GetAllSettingLabels ( )
2017-11-23 05:37:08 +00:00
for _ , setting := range settings {
if setting . Type == "list" {
llist := settingLabels [ setting . Name ]
2017-09-03 04:50:31 +00:00
labels := strings . Split ( llist , "," )
2017-11-23 05:37:08 +00:00
conv , err := strconv . Atoi ( setting . Content )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-23 05:37:08 +00:00
return common . LocalError ( "The setting '" + setting . Name + "' can't be converted to an integer" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-11-23 05:37:08 +00:00
setting . Content = labels [ conv - 1 ]
} else if setting . Type == "bool" {
if setting . Content == "1" {
setting . Content = "Yes"
2017-04-05 14:15:22 +00:00
} else {
2017-11-23 05:37:08 +00:00
setting . Content = "No"
2017-04-05 14:15:22 +00:00
}
}
2017-11-23 05:37:08 +00:00
settingList [ setting . Name ] = setting . Content
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-12-27 23:38:37 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel-settings" ) , user , headerVars , stats , "settings" , tList , settingList }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_settings" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-settings.html" , pi )
2017-08-13 11:22:34 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
func routePanelSettingEdit ( w http . ResponseWriter , r * http . Request , user common . User , sname string ) common . RouteError {
2017-11-11 04:06:16 +00:00
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-13 09:23:43 +00:00
setting , err := headerVars . Settings . BypassGet ( sname )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
llist := common . GetSettingLabel ( setting . Name )
2017-04-05 14:15:22 +00:00
conv , err := strconv . Atoi ( setting . Content )
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-13 09:23:43 +00:00
for index , label := range strings . Split ( llist , "," ) {
2017-11-11 04:06:16 +00:00
itemList = append ( itemList , common . 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-12-27 23:38:37 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel-edit-setting" ) , user , headerVars , stats , "settings" , itemList , setting }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_setting" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-setting.html" , pi )
2017-08-13 11:22:34 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
func routePanelSettingEditSubmit ( w http . ResponseWriter , r * http . Request , user common . User , sname string ) common . RouteError {
2017-11-11 04:06:16 +00:00
headerLite , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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
scontent := r . PostFormValue ( "setting-value" )
2017-11-23 05:37:08 +00:00
err := headerLite . Settings . Update ( sname , scontent )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-23 05:37:08 +00:00
if common . SafeSettingError ( err ) {
return common . LocalError ( err . Error ( ) , w , r , user )
}
2017-11-11 04:06:16 +00:00
return common . 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/settings/" , http . StatusSeeOther )
2017-10-30 09:57:08 +00:00
return nil
2017-04-05 14:15:22 +00:00
}
2017-11-11 04:06:16 +00:00
func routePanelWordFilters ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
if ferr != nil {
2017-11-11 23:34:27 +00:00
return ferr
2017-08-27 09:33:45 +00:00
}
if ! user . Perms . EditSettings {
2017-11-11 04:06:16 +00:00
return common . NoPermissions ( w , r , user )
2017-08-27 09:33:45 +00:00
}
2017-11-11 04:06:16 +00:00
var filterList = common . WordFilterBox . Load ( ) . ( common . WordFilterMap )
2017-12-27 23:38:37 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel-word-filters" ) , user , headerVars , stats , "word-filters" , tList , filterList }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_word_filters" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err := common . Templates . ExecuteTemplate ( w , "panel-word-filters.html" , pi )
2017-08-27 09:33:45 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelWordFiltersCreate ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
if ferr != nil {
return ferr
2017-08-27 09:33:45 +00:00
}
if ! user . Perms . EditSettings {
2017-11-11 04:06:16 +00:00
return common . NoPermissions ( w , r , user )
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . InternalErrorJSQ ( err , w , r , isJs )
2017-08-27 09:33:45 +00:00
}
2017-11-11 04:06:16 +00:00
common . AddWordFilter ( int ( lastID ) , find , replacement )
2017-11-13 09:23:43 +00:00
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-11-11 04:06:16 +00:00
func routePanelWordFiltersEdit ( w http . ResponseWriter , r * http . Request , user common . User , wfid string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
if ferr != nil {
return ferr
2017-08-27 09:33:45 +00:00
}
if ! user . Perms . EditSettings {
2017-11-11 04:06:16 +00:00
return common . NoPermissions ( w , r , user )
2017-08-27 09:33:45 +00:00
}
_ = wfid
2017-12-27 23:38:37 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel-edit-word-filter" ) , user , headerVars , stats , "word-filters" , tList , nil }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_word_filters_edit" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err := common . Templates . ExecuteTemplate ( w , "panel-word-filters-edit.html" , pi )
2017-08-27 09:33:45 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelWordFiltersEditSubmit ( w http . ResponseWriter , r * http . Request , user common . User , wfid string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
if ferr != nil {
return ferr
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-11-11 04:06:16 +00:00
return common . NoPermissionsJSQ ( w , r , user , isJs )
2017-08-27 09:33:45 +00:00
}
id , err := strconv . Atoi ( wfid )
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . InternalErrorJSQ ( err , w , r , isJs )
2017-08-27 09:33:45 +00:00
}
2017-11-11 04:06:16 +00:00
wordFilters := common . WordFilterBox . Load ( ) . ( common . WordFilterMap )
wordFilters [ id ] = common . WordFilter { ID : id , Find : find , Replacement : replacement }
common . WordFilterBox . Store ( wordFilters )
2017-08-27 09:33:45 +00:00
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-11-11 04:06:16 +00:00
func routePanelWordFiltersDeleteSubmit ( w http . ResponseWriter , r * http . Request , user common . User , wfid string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
if ferr != nil {
return ferr
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-11-11 04:06:16 +00:00
return common . NoPermissionsJSQ ( w , r , user , isJs )
2017-08-27 09:33:45 +00:00
}
id , err := strconv . Atoi ( wfid )
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . InternalErrorJSQ ( err , w , r , isJs )
2017-08-27 09:33:45 +00:00
}
2017-11-11 04:06:16 +00:00
wordFilters := common . WordFilterBox . Load ( ) . ( common . WordFilterMap )
2017-09-03 04:50:31 +00:00
delete ( wordFilters , id )
2017-11-11 04:06:16 +00:00
common . WordFilterBox . Store ( wordFilters )
2017-08-27 09:33:45 +00:00
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-11-11 04:06:16 +00:00
func routePanelPlugins ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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 { }
2017-11-11 04:06:16 +00:00
for _ , plugin := range common . 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-12-27 23:38:37 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel-plugins" ) , user , headerVars , stats , "plugins" , pluginList , nil }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_plugins" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err := common . Templates . ExecuteTemplate ( w , "panel-plugins.html" , pi )
2017-08-13 11:22:34 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelPluginsActivate ( w http . ResponseWriter , r * http . Request , user common . User , uname string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
plugin , ok := common . Plugins [ uname ]
2017-04-05 14:15:22 +00:00
if ! ok {
2017-11-11 04:06:16 +00:00
return common . LocalError ( "The plugin isn't registered in the system" , w , r , user )
2017-04-05 14:15:22 +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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
if common . Plugins [ uname ] . Activate != nil {
err = common . Plugins [ uname ] . Activate ( )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . LocalError ( err . Error ( ) , 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
if hasPlugin {
2017-04-05 14:15:22 +00:00
if active {
2017-11-11 04:06:16 +00:00
return common . LocalError ( "The plugin is already active" , w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-11-05 09:55:34 +00:00
_ , err = stmts . updatePlugin . Exec ( 1 , uname )
2017-04-05 14:15:22 +00:00
} else {
2017-11-11 23:34:27 +00:00
_ , err = stmts . addPlugin . Exec ( uname , 1 , 0 )
}
if err != nil {
return common . InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-11 23:34:27 +00:00
log . Printf ( "Activating plugin '%s'" , plugin . Name )
2017-04-05 14:15:22 +00:00
plugin . Active = true
2017-11-11 04:06:16 +00:00
common . Plugins [ uname ] = plugin
err = common . Plugins [ uname ] . Init ( )
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelPluginsDeactivate ( w http . ResponseWriter , r * http . Request , user common . User , uname string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
plugin , ok := common . Plugins [ uname ]
2017-04-05 14:15:22 +00:00
if ! ok {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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
2017-11-11 04:06:16 +00:00
common . Plugins [ uname ] = plugin
common . 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-11-11 04:06:16 +00:00
func routePanelPluginsInstall ( w http . ResponseWriter , r * http . Request , user common . User , uname string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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
}
2017-11-11 04:06:16 +00:00
plugin , ok := common . Plugins [ 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 ! ok {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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
2017-11-11 04:06:16 +00:00
if common . Plugins [ uname ] . Install != nil {
err = common . Plugins [ uname ] . Install ( )
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
if common . Plugins [ uname ] . Activate != nil {
err = common . Plugins [ uname ] . Activate ( )
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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
} else {
2017-11-11 04:06:16 +00:00
_ , err = stmts . addPlugin . Exec ( uname , 1 , 1 )
}
if err != nil {
return common . 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-11 04:06:16 +00:00
log . Printf ( "Installing plugin '%s'" , plugin . Name )
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
plugin . Active = true
plugin . Installed = true
2017-11-11 04:06:16 +00:00
common . Plugins [ uname ] = plugin
err = common . Plugins [ uname ] . Init ( )
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelUsers ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
offset , page , lastPage := common . PageOffset ( stats . Users , page , perPage )
2017-08-17 11:13:49 +00:00
2017-11-11 04:06:16 +00:00
var userList [ ] common . User
// TODO: Move this into the common.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-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
defer rows . Close ( )
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
// TODO: Add a common.UserStore method for iterating over global users and global user offsets
2017-04-05 14:15:22 +00:00
for rows . Next ( ) {
2017-11-11 04:06:16 +00:00
puser := & common . 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-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +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-11-11 04:06:16 +00:00
puser . Avatar = strings . Replace ( common . 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-11-23 05:37:08 +00:00
if common . Groups . DirtyGet ( puser . Group ) . Tag != "" {
puser . Tag = common . Groups . 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-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
pageList := common . Paginate ( stats . Users , perPage , 5 )
2017-12-27 23:38:37 +00:00
pi := common . PanelUserPage { common . GetTitlePhrase ( "panel-users" ) , user , headerVars , stats , "users" , userList , pageList , page , lastPage }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_users" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-users.html" , pi )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelUsersEdit ( w http . ResponseWriter , r * http . Request , user common . User , suid string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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-12-25 02:41:10 +00:00
return common . LocalError ( "The provided UserID 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-11-11 04:06:16 +00:00
targetUser , err := common . Users . Get ( uid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
groups , err := common . Groups . GetRange ( 1 , 0 ) // ? - 0 = Go to the end
2017-09-15 22:20:01 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-12-27 23:38:37 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel-edit-user" ) , user , headerVars , stats , "users" , groupList , targetUser }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_edit_user" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-user-edit.html" , pi )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelUsersEditSubmit ( w http . ResponseWriter , r * http . Request , user common . User , suid string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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-12-25 02:41:10 +00:00
return common . LocalError ( "The provided UserID 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-11-11 04:06:16 +00:00
targetUser , err := common . Users . Get ( uid )
2017-06-28 12:05:26 +00:00
if err == ErrNoRows {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
group , err := common . Groups . Get ( newgroup )
2017-09-15 22:20:01 +00:00
if err == ErrNoRows {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-23 05:37:08 +00:00
// TODO: Move this query into common
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
common . SetPassword ( targetUser . ID , newpassword )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
targetUser . CacheRemove ( )
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-11-11 04:06:16 +00:00
func routePanelGroups ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
offset , page , lastPage := common . 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
2017-11-11 04:06:16 +00:00
var groupList [ ] common . GroupAdmin
2017-11-23 05:37:08 +00:00
groups , _ := common . Groups . GetRange ( offset , 0 )
2017-09-15 22:20:01 +00:00
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-11-23 05:37:08 +00:00
// TODO: Use a switch for this
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 )
2017-11-11 04:06:16 +00:00
groupList = append ( groupList , common . 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-11-11 04:06:16 +00:00
pageList := common . Paginate ( stats . Groups , perPage , 5 )
2017-12-27 23:38:37 +00:00
pi := common . PanelGroupPage { common . GetTitlePhrase ( "panel-groups" ) , user , headerVars , stats , "groups" , groupList , pageList , page , lastPage }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_groups" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err := common . Templates . ExecuteTemplate ( w , "panel-groups.html" , pi )
2017-08-13 11:22:34 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelGroupsEdit ( w http . ResponseWriter , r * http . Request , user common . User , sgid string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
group , err := common . Groups . Get ( gid )
2017-09-15 22:20:01 +00:00
if err == ErrNoRows {
2017-08-13 11:22:34 +00:00
//log.Print("aaaaa monsters")
2017-11-11 04:06:16 +00:00
return common . NotFound ( w , r )
2017-09-15 22:20:01 +00:00
} else if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-12-27 23:38:37 +00:00
pi := common . PanelEditGroupPage { common . GetTitlePhrase ( "panel-edit-group" ) , user , headerVars , stats , "groups" , group . ID , group . Name , group . Tag , rank , disableRank }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_edit_group" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-group-edit.html" , pi )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelGroupsEditPerms ( w http . ResponseWriter , r * http . Request , user common . User , sgid string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
group , err := common . Groups . Get ( gid )
2017-09-15 22:20:01 +00:00
if err == ErrNoRows {
2017-08-13 11:22:34 +00:00
//log.Print("aaaaa monsters")
2017-11-11 04:06:16 +00:00
return common . NotFound ( w , r )
2017-09-15 22:20:01 +00:00
} else if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
var localPerms [ ] common . NameLangToggle
localPerms = append ( localPerms , common . NameLangToggle { "ViewTopic" , common . GetLocalPermPhrase ( "ViewTopic" ) , group . Perms . ViewTopic } )
localPerms = append ( localPerms , common . NameLangToggle { "LikeItem" , common . GetLocalPermPhrase ( "LikeItem" ) , group . Perms . LikeItem } )
localPerms = append ( localPerms , common . NameLangToggle { "CreateTopic" , common . GetLocalPermPhrase ( "CreateTopic" ) , group . Perms . CreateTopic } )
2017-04-05 14:15:22 +00:00
//<--
2017-11-11 04:06:16 +00:00
localPerms = append ( localPerms , common . NameLangToggle { "EditTopic" , common . GetLocalPermPhrase ( "EditTopic" ) , group . Perms . EditTopic } )
localPerms = append ( localPerms , common . NameLangToggle { "DeleteTopic" , common . GetLocalPermPhrase ( "DeleteTopic" ) , group . Perms . DeleteTopic } )
localPerms = append ( localPerms , common . NameLangToggle { "CreateReply" , common . GetLocalPermPhrase ( "CreateReply" ) , group . Perms . CreateReply } )
localPerms = append ( localPerms , common . NameLangToggle { "EditReply" , common . GetLocalPermPhrase ( "EditReply" ) , group . Perms . EditReply } )
localPerms = append ( localPerms , common . NameLangToggle { "DeleteReply" , common . GetLocalPermPhrase ( "DeleteReply" ) , group . Perms . DeleteReply } )
localPerms = append ( localPerms , common . NameLangToggle { "PinTopic" , common . GetLocalPermPhrase ( "PinTopic" ) , group . Perms . PinTopic } )
localPerms = append ( localPerms , common . NameLangToggle { "CloseTopic" , common . GetLocalPermPhrase ( "CloseTopic" ) , group . Perms . CloseTopic } )
var globalPerms [ ] common . NameLangToggle
globalPerms = append ( globalPerms , common . NameLangToggle { "BanUsers" , common . GetGlobalPermPhrase ( "BanUsers" ) , group . Perms . BanUsers } )
globalPerms = append ( globalPerms , common . NameLangToggle { "ActivateUsers" , common . GetGlobalPermPhrase ( "ActivateUsers" ) , group . Perms . ActivateUsers } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditUser" , common . GetGlobalPermPhrase ( "EditUser" ) , group . Perms . EditUser } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditUserEmail" , common . GetGlobalPermPhrase ( "EditUserEmail" ) , group . Perms . EditUserEmail } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditUserPassword" , common . GetGlobalPermPhrase ( "EditUserPassword" ) , group . Perms . EditUserPassword } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditUserGroup" , common . GetGlobalPermPhrase ( "EditUserGroup" ) , group . Perms . EditUserGroup } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditUserGroupSuperMod" , common . GetGlobalPermPhrase ( "EditUserGroupSuperMod" ) , group . Perms . EditUserGroupSuperMod } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditUserGroupAdmin" , common . GetGlobalPermPhrase ( "EditUserGroupAdmin" ) , group . Perms . EditUserGroupAdmin } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditGroup" , common . GetGlobalPermPhrase ( "EditGroup" ) , group . Perms . EditGroup } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditGroupLocalPerms" , common . GetGlobalPermPhrase ( "EditGroupLocalPerms" ) , group . Perms . EditGroupLocalPerms } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditGroupGlobalPerms" , common . GetGlobalPermPhrase ( "EditGroupGlobalPerms" ) , group . Perms . EditGroupGlobalPerms } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditGroupSuperMod" , common . GetGlobalPermPhrase ( "EditGroupSuperMod" ) , group . Perms . EditGroupSuperMod } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditGroupAdmin" , common . GetGlobalPermPhrase ( "EditGroupAdmin" ) , group . Perms . EditGroupAdmin } )
globalPerms = append ( globalPerms , common . NameLangToggle { "ManageForums" , common . GetGlobalPermPhrase ( "ManageForums" ) , group . Perms . ManageForums } )
globalPerms = append ( globalPerms , common . NameLangToggle { "EditSettings" , common . GetGlobalPermPhrase ( "EditSettings" ) , group . Perms . EditSettings } )
globalPerms = append ( globalPerms , common . NameLangToggle { "ManageThemes" , common . GetGlobalPermPhrase ( "ManageThemes" ) , group . Perms . ManageThemes } )
globalPerms = append ( globalPerms , common . NameLangToggle { "ManagePlugins" , common . GetGlobalPermPhrase ( "ManagePlugins" ) , group . Perms . ManagePlugins } )
globalPerms = append ( globalPerms , common . NameLangToggle { "ViewAdminLogs" , common . GetGlobalPermPhrase ( "ViewAdminLogs" ) , group . Perms . ViewAdminLogs } )
globalPerms = append ( globalPerms , common . NameLangToggle { "ViewIPs" , common . GetGlobalPermPhrase ( "ViewIPs" ) , group . Perms . ViewIPs } )
globalPerms = append ( globalPerms , common . NameLangToggle { "UploadFiles" , common . GetGlobalPermPhrase ( "UploadFiles" ) , group . Perms . UploadFiles } )
2017-12-27 23:38:37 +00:00
pi := common . PanelEditGroupPermsPage { common . GetTitlePhrase ( "panel-edit-group" ) , user , headerVars , stats , "groups" , group . ID , group . Name , localPerms , globalPerms }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_edit_group_perms" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-group-edit-perms.html" , pi )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelGroupsEditSubmit ( w http . ResponseWriter , r * http . Request , user common . User , sgid string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
group , err := common . Groups . Get ( gid )
2017-09-15 22:20:01 +00:00
if err == ErrNoRows {
2017-08-13 11:22:34 +00:00
//log.Print("aaaaa monsters")
2017-11-11 04:06:16 +00:00
return common . NotFound ( w , r )
2017-09-15 22:20:01 +00:00
} else if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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
2017-11-23 05:37:08 +00:00
// TODO: Use a switch for this
2017-09-03 04:50:31 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-11-23 05:37:08 +00:00
common . Groups . 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-11-11 04:06:16 +00:00
func routePanelGroupsEditPermsSubmit ( w http . ResponseWriter , r * http . Request , user common . User , sgid string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
group , err := common . Groups . Get ( gid )
2017-09-15 22:20:01 +00:00
if err == ErrNoRows {
2017-08-13 11:22:34 +00:00
//log.Print("aaaaa monsters o.o")
2017-11-11 04:06:16 +00:00
return common . NotFound ( w , r )
2017-09-15 22:20:01 +00:00
} else if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-03 04:50:31 +00:00
var pmap = make ( map [ string ] bool )
2017-04-05 14:15:22 +00:00
if user . Perms . EditGroupLocalPerms {
2017-11-11 04:06:16 +00:00
for _ , perm := range common . LocalPermList {
2017-04-05 14:15:22 +00:00
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
if user . Perms . EditGroupGlobalPerms {
2017-11-11 04:06:16 +00:00
for _ , perm := range common . GlobalPermList {
2017-04-05 14:15:22 +00:00
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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-11-11 04:06:16 +00:00
err = common . RebuildGroupPermissions ( gid )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelGroupsCreateSubmit ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . NoPermissions ( 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . 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-11-23 05:37:08 +00:00
gid , err := common . Groups . Create ( groupName , groupTag , isAdmin , isMod , isBanned )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelThemes ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-12-01 02:04:29 +00:00
var pThemeList , vThemeList [ ] * common . Theme
2017-11-11 04:06:16 +00:00
for _ , theme := range common . Themes {
2017-04-05 14:15:22 +00:00
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-12-27 23:38:37 +00:00
pi := common . PanelThemesPage { common . GetTitlePhrase ( "panel-themes" ) , user , headerVars , stats , "themes" , pThemeList , vThemeList }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_themes" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err := common . Templates . ExecuteTemplate ( w , "panel-themes.html" , pi )
2017-04-05 14:15:22 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelThemesSetDefault ( w http . ResponseWriter , r * http . Request , user common . User , uname string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
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-11-11 04:06:16 +00:00
return common . NoPermissions ( w , r , user )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
theme , ok := common . Themes [ uname ]
2017-04-05 14:15:22 +00:00
if ! ok {
2017-11-11 04:06:16 +00:00
return common . LocalError ( "The theme isn't registered in the system" , w , r , user )
2017-04-05 14:15:22 +00:00
}
if theme . Disabled {
2017-11-11 04:06:16 +00:00
return common . 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-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-11-11 04:06:16 +00:00
return common . 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-04-05 14:15:22 +00:00
if isDefault {
2017-11-11 04:06:16 +00:00
return common . 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
} else {
2017-11-11 23:34:27 +00:00
_ , err = stmts . addTheme . Exec ( uname , 1 )
}
if err != nil {
return common . 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
2017-11-11 04:06:16 +00:00
// TODO: Move this to common
common . ChangeDefaultThemeMutex . Lock ( )
defaultTheme := common . 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-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-05 14:15:22 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
log . Printf ( "Setting theme '%s' as the default theme" , theme . Name )
2017-04-05 14:15:22 +00:00
theme . Active = true
2017-11-11 04:06:16 +00:00
common . Themes [ uname ] = theme
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
dTheme , ok := common . Themes [ defaultTheme ]
2017-04-05 14:15:22 +00:00
if ! ok {
2017-11-11 04:06:16 +00:00
return common . InternalError ( errors . New ( "The default theme is missing" ) , w , r )
2017-04-05 14:15:22 +00:00
}
dTheme . Active = false
2017-11-11 04:06:16 +00:00
common . Themes [ defaultTheme ] = dTheme
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
common . DefaultThemeBox . Store ( uname )
common . ResetTemplateOverrides ( )
2017-12-01 02:04:29 +00:00
theme . MapTemplates ( )
2017-11-11 04:06:16 +00:00
common . 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-11-11 04:06:16 +00:00
func routePanelBackups ( w http . ResponseWriter , r * http . Request , user common . User , backupURL string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
if ferr != nil {
return ferr
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
2017-11-11 04:06:16 +00:00
backupURL = common . Stripslashes ( backupURL )
2017-09-23 19:57:13 +00:00
var ext = filepath . Ext ( "./backups/" + backupURL )
if ext == ".sql" {
info , err := os . Stat ( "./backups/" + backupURL )
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
return common . NotFound ( w , r )
2017-09-23 19:57:13 +00:00
}
2017-11-11 04:06:16 +00:00
var backupList [ ] common . BackupItem
2017-09-23 19:57:13 +00:00
backupFiles , err := ioutil . ReadDir ( "./backups" )
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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
}
2017-11-11 04:06:16 +00:00
backupList = append ( backupList , common . BackupItem { backupFile . Name ( ) , backupFile . ModTime ( ) } )
2017-09-23 19:57:13 +00:00
}
2017-12-27 23:38:37 +00:00
pi := common . PanelBackupPage { common . GetTitlePhrase ( "panel-backups" ) , user , headerVars , stats , "backups" , backupList }
2017-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-backups.html" , pi )
2017-09-23 19:57:13 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-29 02:34:02 +00:00
// TODO: Log errors when something really screwy is going on?
func handleUnknownUser ( user * common . User , err error ) * common . User {
if err != nil {
return & common . User { Name : "Unknown" , Link : common . BuildProfileURL ( "unknown" , 0 ) }
}
return user
}
func handleUnknownTopic ( topic * common . Topic , err error ) * common . Topic {
if err != nil {
return & common . Topic { Title : "Unknown" , Link : common . BuildProfileURL ( "unknown" , 0 ) }
}
return topic
}
func modlogsElementType ( action string , elementType string , elementID int , actor * common . User ) ( out string ) {
switch elementType {
case "topic" :
topic := handleUnknownTopic ( common . Topics . Get ( elementID ) )
switch action {
case "lock" :
out = "<a href='%s'>%s</a> was locked by <a href='%s'>%s</a>"
case "unlock" :
out = "<a href='%s'>%s</a> was reopened by <a href='%s'>%s</a>"
case "stick" :
out = "<a href='%s'>%s</a> was pinned by <a href='%s'>%s</a>"
case "unstick" :
out = "<a href='%s'>%s</a> was unpinned by <a href='%s'>%s</a>"
case "delete" :
return fmt . Sprintf ( "Topic #%d was deleted by <a href='%s'>%s</a>" , elementID , actor . Link , actor . Name )
}
out = fmt . Sprintf ( out , topic . Link , topic . Title , actor . Link , actor . Name )
case "user" :
targetUser := handleUnknownUser ( common . Users . Get ( elementID ) )
switch action {
case "ban" :
out = "<a href='%s'>%s</a> was banned by <a href='%s'>%s</a>"
case "unban" :
out = "<a href='%s'>%s</a> was unbanned by <a href='%s'>%s</a>"
case "activate" :
out = "<a href='%s'>%s</a> was activated by <a href='%s'>%s</a>"
}
out = fmt . Sprintf ( out , targetUser . Link , targetUser . Name , actor . Link , actor . Name )
case "reply" :
if action == "delete" {
topic := handleUnknownTopic ( common . BlankReply ( elementID ) . Topic ( ) )
out = fmt . Sprintf ( "A reply in <a href='%s'>%s</a> was deleted by <a href='%s'>%s</a>" , topic . Link , topic . Title , actor . Link , actor . Name )
}
}
if out == "" {
out = fmt . Sprintf ( "Unknown action '%s' on elementType '%s' by <a href='%s'>%s</a>" , action , elementType , actor . Link , actor . Name )
}
return out
}
2017-11-11 04:06:16 +00:00
func routePanelLogsMod ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
if ferr != nil {
return ferr
2017-04-06 17:37:32 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-23 05:37:08 +00:00
logCount := common . ModLogs . GlobalCount ( )
2017-08-17 11:13:49 +00:00
page , _ := strconv . Atoi ( r . FormValue ( "page" ) )
perPage := 10
2017-11-11 04:06:16 +00:00
offset , page , lastPage := common . 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-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-06 17:37:32 +00:00
}
defer rows . Close ( )
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
var logs [ ] common . 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-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-06 17:37:32 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-23 05:37:08 +00:00
actor := handleUnknownUser ( common . Users . Get ( actorID ) )
2017-11-29 02:34:02 +00:00
action = modlogsElementType ( action , elementType , elementID , actor )
2017-11-11 04:06:16 +00:00
logs = append ( logs , common . LogItem { Action : template . HTML ( action ) , IPAddress : ipaddress , DoneAt : doneAt } )
2017-04-06 17:37:32 +00:00
}
err = rows . Err ( )
if err != nil {
2017-11-11 04:06:16 +00:00
return common . InternalError ( err , w , r )
2017-04-06 17:37:32 +00:00
}
2017-05-29 14:52:37 +00:00
2017-11-11 04:06:16 +00:00
pageList := common . Paginate ( logCount , perPage , 5 )
2017-12-27 23:38:37 +00:00
pi := common . PanelLogsPage { common . GetTitlePhrase ( "panel-mod-logs" ) , user , headerVars , stats , "logs" , logs , pageList , page , lastPage }
2017-11-11 04:06:16 +00:00
if common . PreRenderHooks [ "pre_render_panel_mod_log" ] != nil {
if common . 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-11-11 04:06:16 +00:00
err = common . Templates . ExecuteTemplate ( w , "panel-modlogs.html" , pi )
2017-04-06 17:37:32 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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-11-11 04:06:16 +00:00
func routePanelDebug ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
2017-10-30 09:57:08 +00:00
if ferr != nil {
return ferr
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-12-27 23:38:37 +00:00
pi := common . PanelDebugPage { common . GetTitlePhrase ( "panel-debug" ) , user , headerVars , stats , "debug" , uptime , openConnCount , dbAdapter }
2017-11-11 04:06:16 +00:00
err := common . Templates . ExecuteTemplate ( w , "panel-debug.html" , pi )
2017-08-15 13:47:56 +00:00
if err != nil {
2017-11-11 04:06:16 +00:00
return common . 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
}