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"
2018-04-22 12:33:56 +00:00
"runtime"
2017-09-03 04:50:31 +00:00
"strconv"
"strings"
2018-01-03 07:46:18 +00:00
"time"
2017-05-07 08:31:41 +00:00
2017-11-11 04:06:16 +00:00
"./common"
2018-01-03 07:46:18 +00:00
"./query_gen/lib"
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
2018-01-10 03:32:48 +00:00
// We're trying to reduce the amount of boilerplate in here, so I added these two functions, they might wind up circulating outside this file in the future
func panelSuccessRedirect ( dest string , w http . ResponseWriter , r * http . Request , isJs bool ) common . RouteError {
if ! isJs {
http . Redirect ( w , r , dest , http . StatusSeeOther )
} else {
w . Write ( successJSONBytes )
}
return nil
}
2018-01-11 08:03:17 +00:00
func panelRenderTemplate ( tmplName string , w http . ResponseWriter , r * http . Request , user common . User , pi interface { } ) common . RouteError {
2018-02-19 04:26:01 +00:00
if common . RunPreRenderHook ( "pre_render_" + tmplName , w , r , & user , pi ) {
return nil
2018-01-10 03:32:48 +00:00
}
2018-01-11 08:03:17 +00:00
err := common . Templates . ExecuteTemplate ( w , tmplName + ".html" , pi )
2018-01-10 03:32:48 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
return nil
2018-01-11 08:03:17 +00:00
}
2018-01-10 03:32:48 +00:00
2018-01-22 08:15:45 +00:00
func routePanelDashboard ( w http . ResponseWriter , r * http . Request , user common . User ) 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
}
2018-05-11 05:41:51 +00:00
headerVars . Title = common . GetTitlePhrase ( "panel_dashboard" )
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
2018-03-08 03:59:47 +00:00
if common . EnableWebsockets {
uonline := common . WsHub . UserCount ( )
gonline := common . 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
2018-05-11 05:41:51 +00:00
pi := common . PanelDashboardPage { headerVars , stats , "dashboard" , gridElements }
2018-01-11 08:03:17 +00:00
return panelRenderTemplate ( "panel_dashboard" , w , r , user , & pi )
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
}
}
2018-03-11 09:33:49 +00:00
if r . FormValue ( "created" ) == "1" {
2018-03-21 05:56:33 +00:00
headerVars . NoticeList = append ( headerVars . NoticeList , common . GetNoticePhrase ( "panel_forum_created" ) )
2018-03-11 09:33:49 +00:00
} else if r . FormValue ( "deleted" ) == "1" {
2018-03-21 05:56:33 +00:00
headerVars . NoticeList = append ( headerVars . NoticeList , common . GetNoticePhrase ( "panel_forum_deleted" ) )
2018-03-11 09:33:49 +00:00
} else if r . FormValue ( "updated" ) == "1" {
2018-03-21 05:56:33 +00:00
headerVars . NoticeList = append ( headerVars . NoticeList , common . GetNoticePhrase ( "panel_forum_updated" ) )
2018-03-11 09:33:49 +00:00
}
2018-01-11 08:03:17 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel_forums" ) , user , headerVars , stats , "forums" , forumList , nil }
return panelRenderTemplate ( "panel_forums" , w , r , user , & pi )
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" ) )
2018-04-23 21:08:31 +00:00
factive := r . PostFormValue ( "forum-active" )
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
2018-03-11 09:33:49 +00:00
http . Redirect ( w , r , "/panel/forums/?created=1" , 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
2018-01-11 08:03:17 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel_delete_forum" ) , user , headerVars , stats , "forums" , tList , yousure }
2018-02-19 04:26:01 +00:00
if common . RunPreRenderHook ( "pre_render_panel_delete_forum" , w , r , & user , & pi ) {
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
}
2018-01-10 03:32:48 +00:00
err = common . Templates . ExecuteTemplate ( w , "are_you_sure.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
2018-03-11 09:33:49 +00:00
http . Redirect ( w , r , "/panel/forums/?deleted=1" , 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
}
2018-04-23 21:08:31 +00:00
forumPerms , err := common . FPStore . Get ( fid , group . ID )
2018-04-24 03:47:39 +00:00
if err == ErrNoRows {
forumPerms = common . BlankForumPerms ( )
} else if err != nil {
2018-04-23 21:08:31 +00:00
return common . InternalError ( err , w , r )
}
gplist = append ( gplist , common . GroupForumPermPreset { group , common . ForumPermsToGroupForumPreset ( forumPerms ) } )
2017-06-05 11:57:27 +00:00
}
2018-03-11 09:33:49 +00:00
if r . FormValue ( "updated" ) == "1" {
2018-03-21 05:56:33 +00:00
headerVars . NoticeList = append ( headerVars . NoticeList , common . GetNoticePhrase ( "panel_forum_updated" ) )
2018-03-11 09:33:49 +00:00
}
2018-01-11 08:03:17 +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 }
2018-02-19 04:26:01 +00:00
if common . RunPreRenderHook ( "pre_render_panel_edit_forum" , w , r , & user , & pi ) {
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
}
2018-03-11 09:33:49 +00:00
// ? Should we redirect to the forum editor instead?
2018-01-10 03:32:48 +00:00
return panelSuccessRedirect ( "/panel/forums/" , w , r , isJs )
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
}
2018-03-11 09:33:49 +00:00
return panelSuccessRedirect ( "/panel/forums/edit/" + strconv . Itoa ( fid ) + "?updated=1" , w , r , isJs )
2018-01-10 03:32:48 +00:00
}
// A helper function for the Advanced portion of the Forum Perms Editor
func panelForumPermsExtractDash ( paramList string ) ( fid int , gid int , err error ) {
params := strings . Split ( paramList , "-" )
if len ( params ) != 2 {
return fid , gid , errors . New ( "Parameter count mismatch" )
2017-06-05 11:57:27 +00:00
}
2018-01-10 03:32:48 +00:00
fid , err = strconv . Atoi ( params [ 0 ] )
if err != nil {
return fid , gid , errors . New ( "The provided Forum ID is not a valid number." )
}
gid , err = strconv . Atoi ( params [ 1 ] )
if err != nil {
err = errors . New ( "The provided Group ID is not a valid number." )
}
return fid , gid , err
2017-06-05 11:57:27 +00:00
}
2018-01-10 03:32:48 +00:00
func routePanelForumsEditPermsAdvance ( w http . ResponseWriter , r * http . Request , user common . User , paramList string ) common . RouteError {
2018-01-08 08:53:51 +00:00
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
if ! user . Perms . ManageForums {
return common . NoPermissions ( w , r , user )
}
2018-01-10 03:32:48 +00:00
fid , gid , err := panelForumPermsExtractDash ( paramList )
2018-01-08 08:53:51 +00:00
if err != nil {
2018-01-10 03:32:48 +00:00
return common . LocalError ( err . Error ( ) , w , r , user )
2018-01-08 08:53:51 +00:00
}
forum , err := common . Forums . Get ( fid )
if err == ErrNoRows {
return common . LocalError ( "The forum you're trying to edit doesn't exist." , w , r , user )
} else if err != nil {
return common . InternalError ( err , w , r )
}
if forum . Preset == "" {
forum . Preset = "custom"
}
2018-01-10 03:32:48 +00:00
forumPerms , err := common . FPStore . Get ( fid , gid )
if err == ErrNoRows {
2018-04-24 03:47:39 +00:00
forumPerms = common . BlankForumPerms ( )
2018-01-10 03:32:48 +00:00
} else if err != nil {
2018-01-08 08:53:51 +00:00
return common . InternalError ( err , w , r )
}
2018-01-10 03:32:48 +00:00
var formattedPermList [ ] common . NameLangToggle
2018-01-08 08:53:51 +00:00
2018-01-10 03:32:48 +00:00
// TODO: Load the phrases in bulk for efficiency?
// TODO: Reduce the amount of code duplication between this and the group editor. Also, can we grind this down into one line or use a code generator to stay current more easily?
var addNameLangToggle = func ( permStr string , perm bool ) {
formattedPermList = append ( formattedPermList , common . NameLangToggle { permStr , common . GetLocalPermPhrase ( permStr ) , perm } )
}
addNameLangToggle ( "ViewTopic" , forumPerms . ViewTopic )
addNameLangToggle ( "LikeItem" , forumPerms . LikeItem )
addNameLangToggle ( "CreateTopic" , forumPerms . CreateTopic )
//<--
addNameLangToggle ( "EditTopic" , forumPerms . EditTopic )
addNameLangToggle ( "DeleteTopic" , forumPerms . DeleteTopic )
addNameLangToggle ( "CreateReply" , forumPerms . CreateReply )
addNameLangToggle ( "EditReply" , forumPerms . EditReply )
addNameLangToggle ( "DeleteReply" , forumPerms . DeleteReply )
addNameLangToggle ( "PinTopic" , forumPerms . PinTopic )
addNameLangToggle ( "CloseTopic" , forumPerms . CloseTopic )
2018-01-15 08:24:18 +00:00
addNameLangToggle ( "MoveTopic" , forumPerms . MoveTopic )
2018-01-10 03:32:48 +00:00
2018-03-11 09:33:49 +00:00
if r . FormValue ( "updated" ) == "1" {
2018-03-21 05:56:33 +00:00
headerVars . NoticeList = append ( headerVars . NoticeList , common . GetNoticePhrase ( "panel_forums_perms_updated" ) )
2018-03-11 09:33:49 +00:00
}
2018-01-11 08:03:17 +00:00
pi := common . PanelEditForumGroupPage { common . GetTitlePhrase ( "panel_edit_forum" ) , user , headerVars , stats , "forums" , forum . ID , gid , forum . Name , forum . Desc , forum . Active , forum . Preset , formattedPermList }
2018-02-19 04:26:01 +00:00
if common . RunPreRenderHook ( "pre_render_panel_edit_forum" , w , r , & user , & pi ) {
return nil
2018-01-08 08:53:51 +00:00
}
err = common . Templates . ExecuteTemplate ( w , "panel-forum-edit-perms.html" , pi )
if err != nil {
return common . InternalError ( err , w , r )
}
return nil
}
2018-01-10 03:32:48 +00:00
func routePanelForumsEditPermsAdvanceSubmit ( w http . ResponseWriter , r * http . Request , user common . User , paramList string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
if ! user . Perms . ManageForums {
return common . NoPermissions ( w , r , user )
}
isJs := ( r . PostFormValue ( "js" ) == "1" )
fid , gid , err := panelForumPermsExtractDash ( paramList )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
forum , err := common . Forums . Get ( fid )
if err == ErrNoRows {
return common . LocalError ( "The forum you're trying to edit doesn't exist." , w , r , user )
} else if err != nil {
return common . InternalError ( err , w , r )
}
forumPerms , err := common . FPStore . GetCopy ( fid , gid )
if err == ErrNoRows {
2018-04-24 03:47:39 +00:00
forumPerms = * common . BlankForumPerms ( )
2018-01-10 03:32:48 +00:00
} else if err != nil {
return common . InternalError ( err , w , r )
}
var extractPerm = func ( name string ) bool {
pvalue := r . PostFormValue ( "forum-perm-" + name )
return ( pvalue == "1" )
}
// TODO: Generate this code?
forumPerms . ViewTopic = extractPerm ( "ViewTopic" )
forumPerms . LikeItem = extractPerm ( "LikeItem" )
forumPerms . CreateTopic = extractPerm ( "CreateTopic" )
forumPerms . EditTopic = extractPerm ( "EditTopic" )
forumPerms . DeleteTopic = extractPerm ( "DeleteTopic" )
forumPerms . CreateReply = extractPerm ( "CreateReply" )
forumPerms . EditReply = extractPerm ( "EditReply" )
forumPerms . DeleteReply = extractPerm ( "DeleteReply" )
forumPerms . PinTopic = extractPerm ( "PinTopic" )
forumPerms . CloseTopic = extractPerm ( "CloseTopic" )
2018-01-15 08:24:18 +00:00
forumPerms . MoveTopic = extractPerm ( "MoveTopic" )
2018-01-10 03:32:48 +00:00
err = forum . SetPerms ( & forumPerms , "custom" , gid )
if err != nil {
return common . LocalErrorJSQ ( err . Error ( ) , w , r , user , isJs )
}
2018-03-11 09:33:49 +00:00
return panelSuccessRedirect ( "/panel/forums/edit/perms/" + strconv . Itoa ( fid ) + "-" + strconv . Itoa ( gid ) + "?updated=1" , w , r , isJs )
2018-01-10 03:32:48 +00:00
}
2018-01-14 12:03:20 +00:00
type AnalyticsTimeRange struct {
Quantity int
Unit string
Slices int
SliceWidth int
Range string
}
2017-12-30 05:47:46 +00:00
2018-01-14 12:03:20 +00:00
func panelAnalyticsTimeRange ( rawTimeRange string ) ( timeRange AnalyticsTimeRange , err error ) {
timeRange . Quantity = 6
timeRange . Unit = "hour"
timeRange . Slices = 12
timeRange . SliceWidth = 60 * 30
timeRange . Range = "six-hours"
2018-01-08 08:53:51 +00:00
2018-01-14 12:03:20 +00:00
switch rawTimeRange {
2018-01-12 10:22:28 +00:00
case "one-month" :
2018-01-14 12:03:20 +00:00
timeRange . Quantity = 30
timeRange . Unit = "day"
timeRange . Slices = 30
timeRange . SliceWidth = 60 * 60 * 24
timeRange . Range = "one-month"
2018-02-22 02:27:17 +00:00
case "one-week" :
timeRange . Quantity = 7
timeRange . Unit = "day"
timeRange . Slices = 14
timeRange . SliceWidth = 60 * 60 * 12
timeRange . Range = "one-week"
2018-01-11 08:03:17 +00:00
case "two-days" : // Two days is experimental
2018-01-14 12:03:20 +00:00
timeRange . Quantity = 2
timeRange . Unit = "day"
timeRange . Slices = 24
timeRange . SliceWidth = 60 * 60 * 2
timeRange . Range = "two-days"
2018-01-08 08:53:51 +00:00
case "one-day" :
2018-01-14 12:03:20 +00:00
timeRange . Quantity = 1
timeRange . Unit = "day"
timeRange . Slices = 24
timeRange . SliceWidth = 60 * 60
timeRange . Range = "one-day"
2018-01-08 08:53:51 +00:00
case "twelve-hours" :
2018-01-14 12:03:20 +00:00
timeRange . Quantity = 12
timeRange . Slices = 24
timeRange . Range = "twelve-hours"
2018-01-08 08:53:51 +00:00
case "six-hours" , "" :
2018-01-14 12:03:20 +00:00
timeRange . Range = "six-hours"
2018-01-08 08:53:51 +00:00
default :
2018-01-14 12:03:20 +00:00
return timeRange , errors . New ( "Unknown time range" )
}
return timeRange , nil
}
2018-02-22 02:27:17 +00:00
func panelAnalyticsTimeRangeToLabelList ( timeRange AnalyticsTimeRange ) ( revLabelList [ ] int64 , labelList [ ] int64 , viewMap map [ int64 ] int64 ) {
viewMap = make ( map [ int64 ] int64 )
var currentTime = time . Now ( ) . Unix ( )
for i := 1 ; i <= timeRange . Slices ; i ++ {
var label = currentTime - int64 ( i * timeRange . SliceWidth )
revLabelList = append ( revLabelList , label )
viewMap [ label ] = 0
}
for _ , value := range revLabelList {
labelList = append ( labelList , value )
}
return revLabelList , labelList , viewMap
}
2018-02-26 09:07:00 +00:00
func panelAnalyticsRowsToViewMap ( rows * sql . Rows , labelList [ ] int64 , viewMap map [ int64 ] int64 ) ( map [ int64 ] int64 , error ) {
defer rows . Close ( )
for rows . Next ( ) {
var count int64
var createdAt time . Time
err := rows . Scan ( & count , & createdAt )
if err != nil {
return viewMap , err
}
var unixCreatedAt = createdAt . Unix ( )
// TODO: Bulk log this
if common . Dev . SuperDebug {
log . Print ( "count: " , count )
log . Print ( "createdAt: " , createdAt )
log . Print ( "unixCreatedAt: " , unixCreatedAt )
}
for _ , value := range labelList {
if unixCreatedAt > value {
viewMap [ value ] += count
break
}
}
}
return viewMap , rows . Err ( )
}
2018-01-14 12:03:20 +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
}
2018-04-04 04:49:13 +00:00
headerVars . AddSheet ( "chartist/chartist.min.css" )
headerVars . AddScript ( "chartist/chartist.min.js" )
headerVars . AddScript ( "analytics.js" )
2018-01-14 12:03:20 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
2018-01-08 08:53:51 +00:00
}
2018-02-22 02:27:17 +00:00
revLabelList , labelList , viewMap := panelAnalyticsTimeRangeToLabelList ( timeRange )
2018-01-03 07:46:18 +00:00
2018-02-22 02:27:17 +00:00
common . DebugLog ( "in routePanelAnalyticsViews" )
2018-01-03 07:46:18 +00:00
acc := qgen . Builder . Accumulator ( )
2018-01-14 12:03:20 +00:00
rows , err := acc . Select ( "viewchunks" ) . Columns ( "count, createdAt" ) . Where ( "route = ''" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( )
2018-01-03 07:46:18 +00:00
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
viewMap , err = panelAnalyticsRowsToViewMap ( rows , labelList , viewMap )
2018-01-03 07:46:18 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
var viewList [ ] int64
2018-01-08 08:53:51 +00:00
var viewItems [ ] common . PanelAnalyticsItem
2018-01-03 07:46:18 +00:00
for _ , value := range revLabelList {
viewList = append ( viewList , viewMap [ value ] )
2018-01-08 08:53:51 +00:00
viewItems = append ( viewItems , common . PanelAnalyticsItem { Time : value , Count : viewMap [ value ] } )
2018-01-03 07:46:18 +00:00
}
graph := common . PanelTimeGraph { Series : viewList , Labels : labelList }
2018-02-26 09:07:00 +00:00
common . DebugLogf ( "graph: %+v\n" , graph )
2018-01-03 07:46:18 +00:00
2018-01-14 12:03:20 +00:00
pi := common . PanelAnalyticsPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , graph , viewItems , timeRange . Range }
return panelRenderTemplate ( "panel_analytics_views" , w , r , user , & pi )
2017-12-30 05:47:46 +00:00
}
2018-01-05 22:47:13 +00:00
func routePanelAnalyticsRouteViews ( w http . ResponseWriter , r * http . Request , user common . User , route string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
2018-04-04 04:49:13 +00:00
headerVars . AddSheet ( "chartist/chartist.min.css" )
headerVars . AddScript ( "chartist/chartist.min.js" )
headerVars . AddScript ( "analytics.js" )
2018-01-05 22:47:13 +00:00
2018-01-14 12:03:20 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
2018-01-08 08:53:51 +00:00
}
2018-02-22 02:27:17 +00:00
revLabelList , labelList , viewMap := panelAnalyticsTimeRangeToLabelList ( timeRange )
2018-01-05 22:47:13 +00:00
2018-02-22 02:27:17 +00:00
common . DebugLog ( "in routePanelAnalyticsRouteViews" )
2018-01-05 22:47:13 +00:00
acc := qgen . Builder . Accumulator ( )
2018-01-10 03:32:48 +00:00
// TODO: Validate the route is valid
2018-01-14 12:03:20 +00:00
rows , err := acc . Select ( "viewchunks" ) . Columns ( "count, createdAt" ) . Where ( "route = ?" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( route )
2018-01-05 22:47:13 +00:00
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
viewMap , err = panelAnalyticsRowsToViewMap ( rows , labelList , viewMap )
2018-01-05 22:47:13 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
var viewList [ ] int64
2018-01-14 12:03:20 +00:00
var viewItems [ ] common . PanelAnalyticsItem
2018-01-05 22:47:13 +00:00
for _ , value := range revLabelList {
viewList = append ( viewList , viewMap [ value ] )
2018-01-14 12:03:20 +00:00
viewItems = append ( viewItems , common . PanelAnalyticsItem { Time : value , Count : viewMap [ value ] } )
2018-01-05 22:47:13 +00:00
}
graph := common . PanelTimeGraph { Series : viewList , Labels : labelList }
2018-02-26 09:07:00 +00:00
common . DebugLogf ( "graph: %+v\n" , graph )
2018-01-05 22:47:13 +00:00
2018-01-14 12:03:20 +00:00
pi := common . PanelAnalyticsRoutePage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , html . EscapeString ( route ) , graph , viewItems , timeRange . Range }
2018-01-11 08:03:17 +00:00
return panelRenderTemplate ( "panel_analytics_route_views" , w , r , user , & pi )
2018-01-05 22:47:13 +00:00
}
2018-01-10 03:32:48 +00:00
func routePanelAnalyticsAgentViews ( w http . ResponseWriter , r * http . Request , user common . User , agent string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
2018-04-04 04:49:13 +00:00
headerVars . AddSheet ( "chartist/chartist.min.css" )
headerVars . AddScript ( "chartist/chartist.min.js" )
headerVars . AddScript ( "analytics.js" )
2018-01-10 03:32:48 +00:00
2018-01-14 12:03:20 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
2018-02-22 02:27:17 +00:00
revLabelList , labelList , viewMap := panelAnalyticsTimeRangeToLabelList ( timeRange )
2018-01-14 12:03:20 +00:00
2018-03-08 03:59:47 +00:00
// ? Only allow valid agents? The problem with this is that agents wind up getting renamed and it would take a migration to get them all up to snuff
agent = html . EscapeString ( agent )
2018-02-22 02:27:17 +00:00
common . DebugLog ( "in routePanelAnalyticsAgentViews" )
2018-01-14 12:03:20 +00:00
acc := qgen . Builder . Accumulator ( )
// TODO: Verify the agent is valid
rows , err := acc . Select ( "viewchunks_agents" ) . Columns ( "count, createdAt" ) . Where ( "browser = ?" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( agent )
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
viewMap , err = panelAnalyticsRowsToViewMap ( rows , labelList , viewMap )
2018-01-14 12:03:20 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
var viewList [ ] int64
2018-01-14 12:03:20 +00:00
for _ , value := range revLabelList {
viewList = append ( viewList , viewMap [ value ] )
}
graph := common . PanelTimeGraph { Series : viewList , Labels : labelList }
2018-02-26 09:07:00 +00:00
common . DebugLogf ( "graph: %+v\n" , graph )
2018-01-14 12:03:20 +00:00
2018-02-04 08:15:20 +00:00
friendlyAgent , ok := common . GetUserAgentPhrase ( agent )
if ! ok {
friendlyAgent = agent
}
pi := common . PanelAnalyticsAgentPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , agent , friendlyAgent , graph , timeRange . Range }
2018-01-14 12:03:20 +00:00
return panelRenderTemplate ( "panel_analytics_agent_views" , w , r , user , & pi )
}
2018-02-22 02:27:17 +00:00
func routePanelAnalyticsForumViews ( w http . ResponseWriter , r * http . Request , user common . User , sfid string ) common . RouteError {
2018-02-04 08:15:20 +00:00
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
2018-04-04 04:49:13 +00:00
headerVars . AddSheet ( "chartist/chartist.min.css" )
headerVars . AddScript ( "chartist/chartist.min.js" )
headerVars . AddScript ( "analytics.js" )
2018-02-04 08:15:20 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
2018-02-22 02:27:17 +00:00
revLabelList , labelList , viewMap := panelAnalyticsTimeRangeToLabelList ( timeRange )
2018-02-04 08:15:20 +00:00
2018-03-08 03:59:47 +00:00
fid , err := strconv . Atoi ( sfid )
if err != nil {
return common . LocalError ( "Invalid integer" , w , r , user )
}
2018-02-22 02:27:17 +00:00
common . DebugLog ( "in routePanelAnalyticsForumViews" )
acc := qgen . Builder . Accumulator ( )
// TODO: Verify the agent is valid
2018-03-08 03:59:47 +00:00
rows , err := acc . Select ( "viewchunks_forums" ) . Columns ( "count, createdAt" ) . Where ( "forum = ?" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( fid )
2018-02-22 02:27:17 +00:00
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
2018-02-04 08:15:20 +00:00
}
2018-02-22 02:27:17 +00:00
2018-02-26 09:07:00 +00:00
viewMap , err = panelAnalyticsRowsToViewMap ( rows , labelList , viewMap )
2018-02-22 02:27:17 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
var viewList [ ] int64
2018-02-04 08:15:20 +00:00
for _ , value := range revLabelList {
2018-02-22 02:27:17 +00:00
viewList = append ( viewList , viewMap [ value ] )
}
graph := common . PanelTimeGraph { Series : viewList , Labels : labelList }
2018-02-26 09:07:00 +00:00
common . DebugLogf ( "graph: %+v\n" , graph )
2018-02-22 02:27:17 +00:00
forum , err := common . Forums . Get ( fid )
if err != nil {
return common . InternalError ( err , w , r )
}
pi := common . PanelAnalyticsAgentPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , sfid , forum . Name , graph , timeRange . Range }
return panelRenderTemplate ( "panel_analytics_forum_views" , w , r , user , & pi )
}
func routePanelAnalyticsSystemViews ( w http . ResponseWriter , r * http . Request , user common . User , system string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
2018-04-04 04:49:13 +00:00
headerVars . AddSheet ( "chartist/chartist.min.css" )
headerVars . AddScript ( "chartist/chartist.min.js" )
headerVars . AddScript ( "analytics.js" )
2018-02-22 02:27:17 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
2018-02-04 08:15:20 +00:00
}
2018-02-22 02:27:17 +00:00
revLabelList , labelList , viewMap := panelAnalyticsTimeRangeToLabelList ( timeRange )
2018-03-08 03:59:47 +00:00
system = html . EscapeString ( system )
2018-02-04 08:15:20 +00:00
2018-02-22 02:27:17 +00:00
common . DebugLog ( "in routePanelAnalyticsSystemViews" )
2018-02-04 08:15:20 +00:00
acc := qgen . Builder . Accumulator ( )
2018-03-08 03:59:47 +00:00
// TODO: Verify the OS name is valid
2018-02-04 08:15:20 +00:00
rows , err := acc . Select ( "viewchunks_systems" ) . Columns ( "count, createdAt" ) . Where ( "system = ?" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( system )
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
viewMap , err = panelAnalyticsRowsToViewMap ( rows , labelList , viewMap )
2018-02-04 08:15:20 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
var viewList [ ] int64
2018-02-04 08:15:20 +00:00
for _ , value := range revLabelList {
viewList = append ( viewList , viewMap [ value ] )
}
graph := common . PanelTimeGraph { Series : viewList , Labels : labelList }
2018-02-26 09:07:00 +00:00
common . DebugLogf ( "graph: %+v\n" , graph )
2018-02-04 08:15:20 +00:00
friendlySystem , ok := common . GetOSPhrase ( system )
if ! ok {
friendlySystem = system
}
pi := common . PanelAnalyticsAgentPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , system , friendlySystem , graph , timeRange . Range }
return panelRenderTemplate ( "panel_analytics_system_views" , w , r , user , & pi )
}
2018-03-08 03:59:47 +00:00
func routePanelAnalyticsLanguageViews ( w http . ResponseWriter , r * http . Request , user common . User , lang string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
2018-04-04 04:49:13 +00:00
headerVars . AddSheet ( "chartist/chartist.min.css" )
headerVars . AddScript ( "chartist/chartist.min.js" )
headerVars . AddScript ( "analytics.js" )
2018-03-08 03:59:47 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
revLabelList , labelList , viewMap := panelAnalyticsTimeRangeToLabelList ( timeRange )
lang = html . EscapeString ( lang )
common . DebugLog ( "in routePanelAnalyticsLanguageViews" )
acc := qgen . Builder . Accumulator ( )
// TODO: Verify the language code is valid
rows , err := acc . Select ( "viewchunks_langs" ) . Columns ( "count, createdAt" ) . Where ( "lang = ?" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( lang )
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
viewMap , err = panelAnalyticsRowsToViewMap ( rows , labelList , viewMap )
if err != nil {
return common . InternalError ( err , w , r )
}
var viewList [ ] int64
for _ , value := range revLabelList {
viewList = append ( viewList , viewMap [ value ] )
}
graph := common . PanelTimeGraph { Series : viewList , Labels : labelList }
common . DebugLogf ( "graph: %+v\n" , graph )
friendlyLang , ok := common . GetHumanLangPhrase ( lang )
if ! ok {
friendlyLang = lang
}
pi := common . PanelAnalyticsAgentPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , lang , friendlyLang , graph , timeRange . Range }
return panelRenderTemplate ( "panel_analytics_lang_views" , w , r , user , & pi )
}
2018-02-05 10:29:13 +00:00
func routePanelAnalyticsReferrerViews ( w http . ResponseWriter , r * http . Request , user common . User , domain string ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
2018-04-04 04:49:13 +00:00
headerVars . AddSheet ( "chartist/chartist.min.css" )
headerVars . AddScript ( "chartist/chartist.min.js" )
headerVars . AddScript ( "analytics.js" )
2018-02-05 10:29:13 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
2018-02-22 02:27:17 +00:00
revLabelList , labelList , viewMap := panelAnalyticsTimeRangeToLabelList ( timeRange )
2018-02-05 10:29:13 +00:00
2018-02-22 02:27:17 +00:00
common . DebugLog ( "in routePanelAnalyticsReferrerViews" )
2018-02-05 10:29:13 +00:00
acc := qgen . Builder . Accumulator ( )
// TODO: Verify the agent is valid
rows , err := acc . Select ( "viewchunks_referrers" ) . Columns ( "count, createdAt" ) . Where ( "domain = ?" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( domain )
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
viewMap , err = panelAnalyticsRowsToViewMap ( rows , labelList , viewMap )
2018-02-05 10:29:13 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
var viewList [ ] int64
2018-02-05 10:29:13 +00:00
for _ , value := range revLabelList {
viewList = append ( viewList , viewMap [ value ] )
}
graph := common . PanelTimeGraph { Series : viewList , Labels : labelList }
2018-02-26 09:07:00 +00:00
common . DebugLogf ( "graph: %+v\n" , graph )
2018-02-05 10:29:13 +00:00
pi := common . PanelAnalyticsAgentPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , html . EscapeString ( domain ) , "" , graph , timeRange . Range }
return panelRenderTemplate ( "panel_analytics_referrer_views" , w , r , user , & pi )
}
2018-01-18 12:31:25 +00:00
func routePanelAnalyticsTopics ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
2018-04-04 04:49:13 +00:00
headerVars . AddSheet ( "chartist/chartist.min.css" )
headerVars . AddScript ( "chartist/chartist.min.js" )
headerVars . AddScript ( "analytics.js" )
2018-01-18 12:31:25 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
2018-02-22 02:27:17 +00:00
revLabelList , labelList , viewMap := panelAnalyticsTimeRangeToLabelList ( timeRange )
2018-01-18 12:31:25 +00:00
2018-02-22 02:27:17 +00:00
common . DebugLog ( "in routePanelAnalyticsTopics" )
2018-01-18 12:31:25 +00:00
acc := qgen . Builder . Accumulator ( )
rows , err := acc . Select ( "topicchunks" ) . Columns ( "count, createdAt" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( )
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-04 08:15:20 +00:00
2018-02-26 09:07:00 +00:00
viewMap , err = panelAnalyticsRowsToViewMap ( rows , labelList , viewMap )
2018-01-18 12:31:25 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
var viewList [ ] int64
2018-01-18 12:31:25 +00:00
var viewItems [ ] common . PanelAnalyticsItem
for _ , value := range revLabelList {
viewList = append ( viewList , viewMap [ value ] )
viewItems = append ( viewItems , common . PanelAnalyticsItem { Time : value , Count : viewMap [ value ] } )
}
graph := common . PanelTimeGraph { Series : viewList , Labels : labelList }
2018-02-26 09:07:00 +00:00
common . DebugLogf ( "graph: %+v\n" , graph )
2018-01-18 12:31:25 +00:00
pi := common . PanelAnalyticsPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , graph , viewItems , timeRange . Range }
return panelRenderTemplate ( "panel_analytics_topics" , w , r , user , & pi )
}
2018-01-14 12:03:20 +00:00
func routePanelAnalyticsPosts ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
2018-04-04 04:49:13 +00:00
headerVars . AddSheet ( "chartist/chartist.min.css" )
headerVars . AddScript ( "chartist/chartist.min.js" )
headerVars . AddScript ( "analytics.js" )
2018-01-14 12:03:20 +00:00
2018-01-17 11:13:08 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
2018-01-10 03:32:48 +00:00
}
2018-02-22 02:27:17 +00:00
revLabelList , labelList , viewMap := panelAnalyticsTimeRangeToLabelList ( timeRange )
2018-01-10 03:32:48 +00:00
2018-02-22 02:27:17 +00:00
common . DebugLog ( "in routePanelAnalyticsPosts" )
2018-01-10 03:32:48 +00:00
acc := qgen . Builder . Accumulator ( )
2018-01-17 11:13:08 +00:00
rows , err := acc . Select ( "postchunks" ) . Columns ( "count, createdAt" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( )
2018-01-10 03:32:48 +00:00
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-04 08:15:20 +00:00
2018-02-26 09:07:00 +00:00
viewMap , err = panelAnalyticsRowsToViewMap ( rows , labelList , viewMap )
2018-01-10 03:32:48 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
var viewList [ ] int64
2018-01-14 12:03:20 +00:00
var viewItems [ ] common . PanelAnalyticsItem
2018-01-10 03:32:48 +00:00
for _ , value := range revLabelList {
viewList = append ( viewList , viewMap [ value ] )
2018-01-14 12:03:20 +00:00
viewItems = append ( viewItems , common . PanelAnalyticsItem { Time : value , Count : viewMap [ value ] } )
2018-01-10 03:32:48 +00:00
}
graph := common . PanelTimeGraph { Series : viewList , Labels : labelList }
2018-02-26 09:07:00 +00:00
common . DebugLogf ( "graph: %+v\n" , graph )
2018-01-10 03:32:48 +00:00
2018-01-17 11:13:08 +00:00
pi := common . PanelAnalyticsPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , graph , viewItems , timeRange . Range }
2018-01-14 12:03:20 +00:00
return panelRenderTemplate ( "panel_analytics_posts" , w , r , user , & pi )
2018-01-10 03:32:48 +00:00
}
2018-02-26 09:07:00 +00:00
func panelAnalyticsRowsToNameMap ( rows * sql . Rows ) ( map [ string ] int , error ) {
nameMap := make ( map [ string ] int )
defer rows . Close ( )
for rows . Next ( ) {
var count int
var name string
err := rows . Scan ( & count , & name )
if err != nil {
return nameMap , err
}
// TODO: Bulk log this
if common . Dev . SuperDebug {
log . Print ( "count: " , count )
log . Print ( "name: " , name )
}
nameMap [ name ] += count
}
return nameMap , rows . Err ( )
}
2018-02-22 02:27:17 +00:00
func routePanelAnalyticsForums ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
acc := qgen . Builder . Accumulator ( )
rows , err := acc . Select ( "viewchunks_forums" ) . Columns ( "count, forum" ) . Where ( "forum != ''" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( )
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
forumMap , err := panelAnalyticsRowsToNameMap ( rows )
2018-02-22 02:27:17 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
// TODO: Sort this slice
var forumItems [ ] common . PanelAnalyticsAgentsItem
for sfid , count := range forumMap {
fid , err := strconv . Atoi ( sfid )
if err != nil {
return common . InternalError ( err , w , r )
}
forum , err := common . Forums . Get ( fid )
if err != nil {
return common . InternalError ( err , w , r )
}
forumItems = append ( forumItems , common . PanelAnalyticsAgentsItem {
Agent : sfid ,
FriendlyAgent : forum . Name ,
Count : count ,
} )
}
pi := common . PanelAnalyticsAgentsPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , forumItems , timeRange . Range }
return panelRenderTemplate ( "panel_analytics_forums" , w , r , user , & pi )
}
2018-01-09 07:39:29 +00:00
func routePanelAnalyticsRoutes ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
2018-01-17 11:13:08 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
2018-01-09 07:39:29 +00:00
acc := qgen . Builder . Accumulator ( )
2018-01-17 11:13:08 +00:00
rows , err := acc . Select ( "viewchunks" ) . Columns ( "count, route" ) . Where ( "route != ''" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( )
2018-01-09 07:39:29 +00:00
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
routeMap , err := panelAnalyticsRowsToNameMap ( rows )
2018-01-09 07:39:29 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
// TODO: Sort this slice
var routeItems [ ] common . PanelAnalyticsRoutesItem
for route , count := range routeMap {
routeItems = append ( routeItems , common . PanelAnalyticsRoutesItem {
Route : route ,
Count : count ,
} )
}
2018-01-17 11:13:08 +00:00
pi := common . PanelAnalyticsRoutesPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , routeItems , timeRange . Range }
2018-01-11 08:03:17 +00:00
return panelRenderTemplate ( "panel_analytics_routes" , w , r , user , & pi )
2018-01-09 07:39:29 +00:00
}
func routePanelAnalyticsAgents ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
2018-01-17 11:13:08 +00:00
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
2018-01-09 07:39:29 +00:00
acc := qgen . Builder . Accumulator ( )
2018-01-17 11:13:08 +00:00
rows , err := acc . Select ( "viewchunks_agents" ) . Columns ( "count, browser" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( )
2018-01-09 07:39:29 +00:00
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
agentMap , err := panelAnalyticsRowsToNameMap ( rows )
2018-01-09 07:39:29 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
// TODO: Sort this slice
var agentItems [ ] common . PanelAnalyticsAgentsItem
for agent , count := range agentMap {
2018-02-04 08:15:20 +00:00
aAgent , ok := common . GetUserAgentPhrase ( agent )
if ! ok {
aAgent = agent
}
2018-01-09 07:39:29 +00:00
agentItems = append ( agentItems , common . PanelAnalyticsAgentsItem {
2018-02-04 08:15:20 +00:00
Agent : agent ,
FriendlyAgent : aAgent ,
Count : count ,
2018-01-09 07:39:29 +00:00
} )
}
2018-01-17 11:13:08 +00:00
pi := common . PanelAnalyticsAgentsPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , agentItems , timeRange . Range }
2018-01-11 08:03:17 +00:00
return panelRenderTemplate ( "panel_analytics_agents" , w , r , user , & pi )
2018-01-09 07:39:29 +00:00
}
2018-02-04 08:15:20 +00:00
func routePanelAnalyticsSystems ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
acc := qgen . Builder . Accumulator ( )
rows , err := acc . Select ( "viewchunks_systems" ) . Columns ( "count, system" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( )
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
osMap , err := panelAnalyticsRowsToNameMap ( rows )
2018-02-04 08:15:20 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
// TODO: Sort this slice
var systemItems [ ] common . PanelAnalyticsAgentsItem
for system , count := range osMap {
sSystem , ok := common . GetOSPhrase ( system )
if ! ok {
sSystem = system
}
systemItems = append ( systemItems , common . PanelAnalyticsAgentsItem {
Agent : system ,
FriendlyAgent : sSystem ,
Count : count ,
} )
}
pi := common . PanelAnalyticsAgentsPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , systemItems , timeRange . Range }
return panelRenderTemplate ( "panel_analytics_systems" , w , r , user , & pi )
}
2018-03-08 03:59:47 +00:00
func routePanelAnalyticsLanguages ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
acc := qgen . Builder . Accumulator ( )
rows , err := acc . Select ( "viewchunks_langs" ) . Columns ( "count, lang" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( )
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
langMap , err := panelAnalyticsRowsToNameMap ( rows )
if err != nil {
return common . InternalError ( err , w , r )
}
// TODO: Can we de-duplicate these analytics functions further?
// TODO: Sort this slice
var langItems [ ] common . PanelAnalyticsAgentsItem
for lang , count := range langMap {
lLang , ok := common . GetHumanLangPhrase ( lang )
if ! ok {
lLang = lang
}
langItems = append ( langItems , common . PanelAnalyticsAgentsItem {
Agent : lang ,
FriendlyAgent : lLang ,
Count : count ,
} )
}
pi := common . PanelAnalyticsAgentsPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , langItems , timeRange . Range }
return panelRenderTemplate ( "panel_analytics_langs" , w , r , user , & pi )
}
2018-02-05 10:29:13 +00:00
func routePanelAnalyticsReferrers ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
timeRange , err := panelAnalyticsTimeRange ( r . FormValue ( "timeRange" ) )
if err != nil {
return common . LocalError ( err . Error ( ) , w , r , user )
}
acc := qgen . Builder . Accumulator ( )
rows , err := acc . Select ( "viewchunks_referrers" ) . Columns ( "count, domain" ) . DateCutoff ( "createdAt" , timeRange . Quantity , timeRange . Unit ) . Query ( )
if err != nil && err != ErrNoRows {
return common . InternalError ( err , w , r )
}
2018-02-26 09:07:00 +00:00
refMap , err := panelAnalyticsRowsToNameMap ( rows )
2018-02-05 10:29:13 +00:00
if err != nil {
return common . InternalError ( err , w , r )
}
// TODO: Sort this slice
var refItems [ ] common . PanelAnalyticsAgentsItem
for domain , count := range refMap {
refItems = append ( refItems , common . PanelAnalyticsAgentsItem {
Agent : html . EscapeString ( domain ) ,
Count : count ,
} )
}
pi := common . PanelAnalyticsAgentsPage { common . GetTitlePhrase ( "panel_analytics" ) , user , headerVars , stats , "analytics" , refItems , timeRange . Range }
return panelRenderTemplate ( "panel_analytics_referrers" , w , r , user , & pi )
}
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
2018-01-11 08:03:17 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel_settings" ) , user , headerVars , stats , "settings" , tList , settingList }
return panelRenderTemplate ( "panel_settings" , w , r , user , & pi )
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
2018-01-11 08:03:17 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel_edit_setting" ) , user , headerVars , stats , "settings" , itemList , setting }
return panelRenderTemplate ( "panel_setting" , w , r , user , & pi )
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 )
2018-01-11 08:03:17 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel_word_filters" ) , user , headerVars , stats , "word-filters" , tList , filterList }
return panelRenderTemplate ( "panel_word_filters" , w , r , user , & pi )
2017-08-27 09:33:45 +00:00
}
2018-01-18 12:31:25 +00:00
func routePanelWordFiltersCreateSubmit ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
2017-11-11 04:06:16 +00:00
_ , 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 )
2018-01-10 03:32:48 +00:00
return panelSuccessRedirect ( "/panel/settings/word-filters/" , w , r , isJs )
2017-08-27 09:33:45 +00:00
}
2018-01-11 08:03:17 +00:00
// TODO: Implement this as a non-JS fallback
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
2018-01-11 08:03:17 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel_edit_word_filter" ) , user , headerVars , stats , "word-filters" , tList , nil }
return panelRenderTemplate ( "panel_word_filters_edit" , w , r , user , & pi )
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
2018-01-11 08:03:17 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel_plugins" ) , user , headerVars , stats , "plugins" , pluginList , nil }
return panelRenderTemplate ( "panel_plugins" , w , r , user , & pi )
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 ( )
2018-02-03 05:47:14 +00:00
puser . Avatar = common . BuildAvatar ( puser . ID , puser . Avatar )
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 )
2018-04-22 12:33:56 +00:00
pi := common . PanelUserPage { common . GetTitlePhrase ( "panel_users" ) , user , headerVars , stats , "users" , userList , common . Paginator { pageList , page , lastPage } }
2018-01-11 08:03:17 +00:00
return panelRenderTemplate ( "panel_users" , w , r , user , & pi )
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 { }
2018-01-17 11:13:08 +00:00
for _ , group := range groups {
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
2018-03-08 03:59:47 +00:00
if r . FormValue ( "updated" ) == "1" {
2018-03-21 05:56:33 +00:00
headerVars . NoticeList = append ( headerVars . NoticeList , common . GetNoticePhrase ( "panel_user_updated" ) )
2018-03-08 03:59:47 +00:00
}
2018-01-11 08:03:17 +00:00
pi := common . PanelPage { common . GetTitlePhrase ( "panel_edit_user" ) , user , headerVars , stats , "users" , groupList , targetUser }
2018-02-19 04:26:01 +00:00
if common . RunPreRenderHook ( "pre_render_panel_edit_user" , w , r , & user , & pi ) {
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-12-31 07:01:44 +00:00
newname := html . EscapeString ( strings . Replace ( r . PostFormValue ( "user-name" ) , "\n" , "" , - 1 ) )
2017-04-05 14:15:22 +00:00
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-12-31 07:01:44 +00:00
// TODO: How should activation factor into admin set emails?
// TODO: How should we handle secondary emails? Do we even have secondary emails implemented?
newemail := html . EscapeString ( strings . Replace ( r . PostFormValue ( "user-email" ) , "\n" , "" , - 1 ) )
2017-04-05 14:15:22 +00:00
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 )
2018-01-17 11:13:08 +00:00
// Log the user out as a safety precaution
common . Auth . ForceLogout ( targetUser . ID )
2017-04-05 14:15:22 +00:00
}
2017-11-11 04:06:16 +00:00
targetUser . CacheRemove ( )
2018-05-11 06:18:49 +00:00
// If we're changing our own password, redirect to the index rather than to a noperms error due to the force logout
if targetUser . ID == user . ID {
http . Redirect ( w , r , "/" , http . StatusSeeOther )
} else {
http . Redirect ( w , r , "/panel/users/edit/" + strconv . Itoa ( targetUser . ID ) + "?updated=1" , 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 )
2018-04-22 12:33:56 +00:00
pi := common . PanelGroupPage { common . GetTitlePhrase ( "panel_groups" ) , user , headerVars , stats , "groups" , groupList , common . Paginator { pageList , page , lastPage } }
2018-01-11 08:03:17 +00:00
return panelRenderTemplate ( "panel_groups" , w , r , user , & pi )
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")
2018-02-19 04:26:01 +00:00
return common . NotFound ( w , r , headerVars )
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
2018-01-11 08:03:17 +00:00
pi := common . PanelEditGroupPage { common . GetTitlePhrase ( "panel_edit_group" ) , user , headerVars , stats , "groups" , group . ID , group . Name , group . Tag , rank , disableRank }
2018-02-19 04:26:01 +00:00
if common . RunPreRenderHook ( "pre_render_panel_edit_group" , w , r , & user , & pi ) {
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")
2018-02-19 04:26:01 +00:00
return common . NotFound ( w , r , headerVars )
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
2018-01-10 03:32:48 +00:00
var addLocalPerm = func ( permStr string , perm bool ) {
localPerms = append ( localPerms , common . NameLangToggle { permStr , common . GetLocalPermPhrase ( permStr ) , perm } )
}
addLocalPerm ( "ViewTopic" , group . Perms . ViewTopic )
addLocalPerm ( "LikeItem" , group . Perms . LikeItem )
addLocalPerm ( "CreateTopic" , group . Perms . CreateTopic )
2017-04-05 14:15:22 +00:00
//<--
2018-01-10 03:32:48 +00:00
addLocalPerm ( "EditTopic" , group . Perms . EditTopic )
addLocalPerm ( "DeleteTopic" , group . Perms . DeleteTopic )
addLocalPerm ( "CreateReply" , group . Perms . CreateReply )
addLocalPerm ( "EditReply" , group . Perms . EditReply )
addLocalPerm ( "DeleteReply" , group . Perms . DeleteReply )
addLocalPerm ( "PinTopic" , group . Perms . PinTopic )
addLocalPerm ( "CloseTopic" , group . Perms . CloseTopic )
2018-01-15 08:24:18 +00:00
addLocalPerm ( "MoveTopic" , group . Perms . MoveTopic )
2017-11-11 04:06:16 +00:00
var globalPerms [ ] common . NameLangToggle
2018-01-10 03:32:48 +00:00
var addGlobalPerm = func ( permStr string , perm bool ) {
globalPerms = append ( globalPerms , common . NameLangToggle { permStr , common . GetGlobalPermPhrase ( permStr ) , perm } )
}
addGlobalPerm ( "BanUsers" , group . Perms . BanUsers )
addGlobalPerm ( "ActivateUsers" , group . Perms . ActivateUsers )
addGlobalPerm ( "EditUser" , group . Perms . EditUser )
addGlobalPerm ( "EditUserEmail" , group . Perms . EditUserEmail )
addGlobalPerm ( "EditUserPassword" , group . Perms . EditUserPassword )
addGlobalPerm ( "EditUserGroup" , group . Perms . EditUserGroup )
addGlobalPerm ( "EditUserGroupSuperMod" , group . Perms . EditUserGroupSuperMod )
addGlobalPerm ( "EditUserGroupAdmin" , group . Perms . EditUserGroupAdmin )
addGlobalPerm ( "EditGroup" , group . Perms . EditGroup )
addGlobalPerm ( "EditGroupLocalPerms" , group . Perms . EditGroupLocalPerms )
addGlobalPerm ( "EditGroupGlobalPerms" , group . Perms . EditGroupGlobalPerms )
addGlobalPerm ( "EditGroupSuperMod" , group . Perms . EditGroupSuperMod )
addGlobalPerm ( "EditGroupAdmin" , group . Perms . EditGroupAdmin )
addGlobalPerm ( "ManageForums" , group . Perms . ManageForums )
addGlobalPerm ( "EditSettings" , group . Perms . EditSettings )
addGlobalPerm ( "ManageThemes" , group . Perms . ManageThemes )
addGlobalPerm ( "ManagePlugins" , group . Perms . ManagePlugins )
addGlobalPerm ( "ViewAdminLogs" , group . Perms . ViewAdminLogs )
addGlobalPerm ( "ViewIPs" , group . Perms . ViewIPs )
addGlobalPerm ( "UploadFiles" , group . Perms . UploadFiles )
2017-11-11 04:06:16 +00:00
2018-01-11 08:03:17 +00:00
pi := common . PanelEditGroupPermsPage { common . GetTitlePhrase ( "panel_edit_group" ) , user , headerVars , stats , "groups" , group . ID , group . Name , localPerms , globalPerms }
2018-02-19 04:26:01 +00:00
if common . RunPreRenderHook ( "pre_render_panel_edit_group_perms" , w , r , & user , & pi ) {
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")
2018-02-19 04:26:01 +00:00
return common . NotFound ( w , r , nil )
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")
2018-02-19 04:26:01 +00:00
return common . NotFound ( w , r , nil )
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
2018-01-10 03:32:48 +00:00
// TODO: Abstract this
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 {
2018-05-11 05:41:51 +00:00
header , 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
}
2018-05-11 05:41:51 +00:00
header . Title = common . GetTitlePhrase ( "panel_themes" )
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
2018-05-11 05:41:51 +00:00
pi := common . PanelThemesPage { header , stats , "themes" , pThemeList , vThemeList }
2018-01-11 08:03:17 +00:00
return panelRenderTemplate ( "panel_themes" , w , r , user , & pi )
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
2018-05-11 05:41:51 +00:00
func routePanelThemesMenus ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
header , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
if ! user . Perms . ManageThemes {
return common . NoPermissions ( w , r , user )
}
header . Title = common . GetTitlePhrase ( "panel_themes_menus" )
var menuList [ ] common . PanelMenuListItem
for mid , list := range common . Menus . GetAllMap ( ) {
menuList = append ( menuList , common . PanelMenuListItem {
ID : mid ,
ItemCount : len ( list . List ) ,
} )
}
pi := common . PanelMenuListPage { header , stats , "themes" , menuList }
return panelRenderTemplate ( "panel_themes_menus" , w , r , user , & pi )
}
func routePanelThemesMenusEdit ( w http . ResponseWriter , r * http . Request , user common . User , smid string ) common . RouteError {
header , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
if ! user . Perms . ManageThemes {
return common . NoPermissions ( w , r , user )
}
// TODO: Something like Menu #1 for the title?
header . Title = common . GetTitlePhrase ( "panel_themes_menus_edit" )
2018-05-13 06:56:59 +00:00
header . AddScript ( "Sortable-1.4.0/Sortable.min.js" )
2018-05-11 05:41:51 +00:00
mid , err := strconv . Atoi ( smid )
if err != nil {
return common . LocalError ( "Invalid integer" , w , r , user )
}
menuHold , err := common . Menus . Get ( mid )
if err == ErrNoRows {
return common . NotFound ( w , r , header )
} else if err != nil {
return common . InternalError ( err , w , r )
}
var menuList [ ] common . MenuItem
for _ , item := range menuHold . List {
var menuTmpls = map [ string ] common . MenuTmpl {
item . TmplName : menuHold . Parse ( item . Name , [ ] byte ( "{{.Name}}" ) ) ,
}
var renderBuffer [ ] [ ] byte
var variableIndices [ ] int
renderBuffer , _ = menuHold . ScanItem ( menuTmpls , item , renderBuffer , variableIndices )
var out string
for _ , renderItem := range renderBuffer {
out += string ( renderItem )
}
item . Name = out
if item . Name == "" {
item . Name = "???"
}
menuList = append ( menuList , item )
}
pi := common . PanelMenuPage { header , stats , "themes" , mid , menuList }
return panelRenderTemplate ( "panel_themes_menus_items" , w , r , user , & pi )
}
func routePanelThemesMenuItemEdit ( w http . ResponseWriter , r * http . Request , user common . User , sitemID string ) common . RouteError {
header , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
if ! user . Perms . ManageThemes {
return common . NoPermissions ( w , r , user )
}
// TODO: Something like Menu #1 for the title?
header . Title = common . GetTitlePhrase ( "panel_themes_menus_edit" )
itemID , err := strconv . Atoi ( sitemID )
if err != nil {
return common . LocalError ( "Invalid integer" , w , r , user )
}
menuItem , err := common . Menus . ItemStore ( ) . Get ( itemID )
if err == ErrNoRows {
return common . NotFound ( w , r , header )
} else if err != nil {
return common . InternalError ( err , w , r )
}
pi := common . PanelMenuItemPage { header , stats , "themes" , menuItem }
return panelRenderTemplate ( "panel_themes_menus_item_edit" , w , r , user , & pi )
}
2018-05-13 06:56:59 +00:00
func routePanelThemesMenuItemSetters ( r * http . Request , menuItem common . MenuItem ) common . MenuItem {
2018-05-11 05:41:51 +00:00
var getItem = func ( name string ) string {
return html . EscapeString ( strings . Replace ( r . PostFormValue ( "item-" + name ) , "\n" , "" , - 1 ) )
}
menuItem . Name = getItem ( "name" )
menuItem . HTMLID = getItem ( "htmlid" )
menuItem . CSSClass = getItem ( "cssclass" )
menuItem . Position = getItem ( "position" )
if menuItem . Position != "left" && menuItem . Position != "right" {
menuItem . Position = "left"
}
menuItem . Path = getItem ( "path" )
menuItem . Aria = getItem ( "aria" )
menuItem . Tooltip = getItem ( "tooltip" )
menuItem . TmplName = getItem ( "tmplname" )
2018-05-13 06:56:59 +00:00
switch getItem ( "permissions" ) {
2018-05-11 05:41:51 +00:00
case "everyone" :
menuItem . GuestOnly = false
menuItem . MemberOnly = false
menuItem . SuperModOnly = false
menuItem . AdminOnly = false
case "guest-only" :
menuItem . GuestOnly = true
menuItem . MemberOnly = false
menuItem . SuperModOnly = false
menuItem . AdminOnly = false
case "member-only" :
menuItem . GuestOnly = false
menuItem . MemberOnly = true
menuItem . SuperModOnly = false
menuItem . AdminOnly = false
case "supermod-only" :
menuItem . GuestOnly = false
menuItem . MemberOnly = true
menuItem . SuperModOnly = true
menuItem . AdminOnly = false
case "admin-only" :
menuItem . GuestOnly = false
menuItem . MemberOnly = true
menuItem . SuperModOnly = true
menuItem . AdminOnly = true
}
2018-05-13 06:56:59 +00:00
return menuItem
}
func routePanelThemesMenuItemEditSubmit ( w http . ResponseWriter , r * http . Request , user common . User , sitemID string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
isJs := ( r . PostFormValue ( "js" ) == "1" )
if ! user . Perms . ManageThemes {
return common . NoPermissionsJSQ ( w , r , user , isJs )
}
itemID , err := strconv . Atoi ( sitemID )
if err != nil {
return common . LocalErrorJSQ ( "Invalid integer" , w , r , user , isJs )
}
menuItem , err := common . Menus . ItemStore ( ) . Get ( itemID )
if err == ErrNoRows {
return common . LocalErrorJSQ ( "This item doesn't exist." , w , r , user , isJs )
} else if err != nil {
return common . InternalErrorJSQ ( err , w , r , isJs )
}
//menuItem = menuItem.Copy() // If we switch this for a pointer, we might need this as a scratchpad
menuItem = routePanelThemesMenuItemSetters ( r , menuItem )
2018-05-11 05:41:51 +00:00
err = menuItem . Commit ( )
if err != nil {
return common . InternalErrorJSQ ( err , w , r , isJs )
}
return panelSuccessRedirect ( "/panel/themes/menus/item/edit/" + strconv . Itoa ( itemID ) , w , r , isJs )
}
2018-05-13 06:56:59 +00:00
func routePanelThemesMenuItemCreateSubmit ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
isJs := ( r . PostFormValue ( "js" ) == "1" )
if ! user . Perms . ManageThemes {
return common . NoPermissionsJSQ ( w , r , user , isJs )
}
smenuID := r . PostFormValue ( "mid" )
if smenuID == "" {
return common . LocalErrorJSQ ( "No menuID provided" , w , r , user , isJs )
}
menuID , err := strconv . Atoi ( smenuID )
if err != nil {
return common . LocalErrorJSQ ( "Invalid integer" , w , r , user , isJs )
}
menuItem := common . MenuItem { MenuID : menuID }
menuItem = routePanelThemesMenuItemSetters ( r , menuItem )
itemID , err := menuItem . Create ( )
if err != nil {
return common . InternalErrorJSQ ( err , w , r , isJs )
}
return panelSuccessRedirect ( "/panel/themes/menus/item/edit/" + strconv . Itoa ( itemID ) , w , r , isJs )
}
func routePanelThemesMenuItemDeleteSubmit ( w http . ResponseWriter , r * http . Request , user common . User , sitemID string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
isJs := ( r . PostFormValue ( "js" ) == "1" )
if ! user . Perms . ManageThemes {
return common . NoPermissionsJSQ ( w , r , user , isJs )
}
itemID , err := strconv . Atoi ( sitemID )
if err != nil {
return common . LocalErrorJSQ ( "Invalid integer" , w , r , user , isJs )
}
menuItem , err := common . Menus . ItemStore ( ) . Get ( itemID )
if err == ErrNoRows {
return common . LocalErrorJSQ ( "This item doesn't exist." , w , r , user , isJs )
} else if err != nil {
return common . InternalErrorJSQ ( err , w , r , isJs )
}
//menuItem = menuItem.Copy() // If we switch this for a pointer, we might need this as a scratchpad
err = menuItem . Delete ( )
if err != nil {
return common . InternalErrorJSQ ( err , w , r , isJs )
}
return panelSuccessRedirect ( "/panel/themes/menus/" , w , r , isJs )
}
func routePanelThemesMenuItemOrderSubmit ( w http . ResponseWriter , r * http . Request , user common . User , smid string ) common . RouteError {
_ , ferr := common . SimplePanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
isJs := ( r . PostFormValue ( "js" ) == "1" )
if ! user . Perms . ManageThemes {
return common . NoPermissionsJSQ ( w , r , user , isJs )
}
mid , err := strconv . Atoi ( smid )
if err != nil {
return common . LocalErrorJSQ ( "Invalid integer" , w , r , user , isJs )
}
menuHold , err := common . Menus . Get ( mid )
if err == ErrNoRows {
return common . LocalErrorJSQ ( "Can't find menu" , w , r , user , isJs )
} else if err != nil {
return common . InternalErrorJSQ ( err , w , r , isJs )
}
sitems := strings . TrimSuffix ( strings . TrimPrefix ( r . PostFormValue ( "items" ) , "{" ) , "}" )
fmt . Printf ( "sitems: %+v\n" , sitems )
var updateMap = make ( map [ int ] int )
for index , smiid := range strings . Split ( sitems , "," ) {
miid , err := strconv . Atoi ( smiid )
if err != nil {
return common . LocalErrorJSQ ( "Invalid integer in menu item list" , w , r , user , isJs )
}
updateMap [ miid ] = index
}
menuHold . UpdateOrder ( updateMap )
return panelSuccessRedirect ( "/panel/themes/menus/edit/" + strconv . Itoa ( mid ) , w , r , isJs )
}
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 {
2018-02-19 04:26:01 +00:00
return common . NotFound ( w , r , headerVars )
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
}
2018-02-19 04:26:01 +00:00
return common . NotFound ( w , r , headerVars )
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
}
2018-01-11 08:03:17 +00:00
pi := common . PanelBackupPage { common . GetTitlePhrase ( "panel_backups" ) , user , headerVars , stats , "backups" , backupList }
return panelRenderTemplate ( "panel_backups" , w , r , user , & pi )
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
}
2018-02-19 04:26:01 +00:00
// TODO: Move the log building logic into /common/ and it's own abstraction
func topicElementTypeAction ( action string , elementType string , elementID int , actor * common . User , topic * common . Topic ) ( out string ) {
if action == "delete" {
return fmt . Sprintf ( "Topic #%d was deleted by <a href='%s'>%s</a>" , elementID , actor . Link , actor . Name )
}
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 "move" :
out = "<a href='%s'>%s</a> was moved by <a href='%s'>%s</a>" // TODO: Add where it was moved to, we'll have to change the source data for that, most likely? Investigate that and try to work this in
default :
return fmt . Sprintf ( "Unknown action '%s' on elementType '%s' by <a href='%s'>%s</a>" , action , elementType , actor . Link , actor . Name )
}
return fmt . Sprintf ( out , topic . Link , topic . Title , actor . Link , actor . Name )
}
2017-11-29 02:34:02 +00:00
func modlogsElementType ( action string , elementType string , elementID int , actor * common . User ) ( out string ) {
switch elementType {
case "topic" :
topic := handleUnknownTopic ( common . Topics . Get ( elementID ) )
2018-02-19 04:26:01 +00:00
out = topicElementTypeAction ( action , elementType , elementID , actor , topic )
2017-11-29 02:34:02 +00:00
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" {
2018-01-20 06:50:29 +00:00
topic := handleUnknownTopic ( common . TopicByReplyID ( elementID ) )
2017-11-29 02:34:02 +00:00
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 )
}
}
2018-02-19 04:26:01 +00:00
2017-11-29 02:34:02 +00:00
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 )
2018-04-22 12:33:56 +00:00
pi := common . PanelLogsPage { common . GetTitlePhrase ( "panel_mod_logs" ) , user , headerVars , stats , "logs" , logs , common . Paginator { pageList , page , lastPage } }
2018-01-11 08:03:17 +00:00
return panelRenderTemplate ( "panel_modlogs" , w , r , user , & pi )
}
func routePanelLogsAdmin ( w http . ResponseWriter , r * http . Request , user common . User ) common . RouteError {
headerVars , stats , ferr := common . PanelUserCheck ( w , r , & user )
if ferr != nil {
return ferr
}
logCount := common . ModLogs . GlobalCount ( )
page , _ := strconv . Atoi ( r . FormValue ( "page" ) )
perPage := 10
offset , page , lastPage := common . PageOffset ( logCount , page , perPage )
rows , err := stmts . getAdminlogsOffset . Query ( offset , perPage )
if err != nil {
return common . InternalError ( err , w , r )
}
defer rows . Close ( )
var logs [ ] common . LogItem
var action , elementType , ipaddress , doneAt string
var elementID , actorID int
for rows . Next ( ) {
err := rows . Scan ( & action , & elementID , & elementType , & ipaddress , & actorID , & doneAt )
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
}
2018-01-11 08:03:17 +00:00
actor := handleUnknownUser ( common . Users . Get ( actorID ) )
action = modlogsElementType ( action , elementType , elementID , actor )
logs = append ( logs , common . LogItem { Action : template . HTML ( action ) , IPAddress : ipaddress , DoneAt : doneAt } )
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
}
2018-01-11 08:03:17 +00:00
err = rows . Err ( )
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
}
2018-01-11 08:03:17 +00:00
pageList := common . Paginate ( logCount , perPage , 5 )
2018-04-22 12:33:56 +00:00
pi := common . PanelLogsPage { common . GetTitlePhrase ( "panel_admin_logs" ) , user , headerVars , stats , "logs" , logs , common . Paginator { pageList , page , lastPage } }
2018-01-11 08:03:17 +00:00
return panelRenderTemplate ( "panel_adminlogs" , w , r , user , & pi )
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
}
2018-04-22 12:33:56 +00:00
goVersion := runtime . Version ( )
dbVersion := qgen . Builder . DbVersion ( )
2018-04-03 04:34:07 +00:00
var uptime string
upDuration := time . Since ( startTime )
hours := int ( upDuration . Hours ( ) )
minutes := int ( upDuration . Minutes ( ) )
if hours > 24 {
days := hours / 24
hours -= days * 24
uptime += strconv . Itoa ( days ) + "d"
uptime += strconv . Itoa ( hours ) + "h"
} else if hours >= 1 {
uptime += strconv . Itoa ( hours ) + "h"
}
uptime += strconv . Itoa ( minutes ) + "m"
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?
2018-04-03 04:34:07 +00:00
// TODO: Fetch the adapter from Builder rather than getting it from a global?
2017-08-15 13:47:56 +00:00
2018-04-22 12:33:56 +00:00
pi := common . PanelDebugPage { common . GetTitlePhrase ( "panel_debug" ) , user , headerVars , stats , "debug" , goVersion , dbVersion , uptime , openConnCount , dbAdapter }
2018-01-11 08:03:17 +00:00
return panelRenderTemplate ( "panel_debug" , w , r , user , & pi )
2017-04-06 17:37:32 +00:00
}