2017-06-05 11:57:27 +00:00
/* WIP Under Construction */
package main
import "log"
2017-06-13 07:12:58 +00:00
import "./lib"
2017-06-05 11:57:27 +00:00
func main ( ) {
log . Println ( "Running the query generator" )
2017-06-13 07:12:58 +00:00
for _ , adapter := range qgen . DB_Registry {
log . Println ( "Building the queries for the " + adapter . GetName ( ) + " adapter" )
2017-07-12 11:05:18 +00:00
qgen . Install . SetAdapterInstance ( adapter )
2017-06-05 11:57:27 +00:00
write_statements ( adapter )
2017-07-12 11:05:18 +00:00
qgen . Install . Write ( )
2017-06-13 07:12:58 +00:00
adapter . Write ( )
2017-06-05 11:57:27 +00:00
}
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-13 07:12:58 +00:00
func write_statements ( adapter qgen . DB_Adapter ) error {
2017-07-12 11:05:18 +00:00
err := create_tables ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-07-12 11:05:18 +00:00
err = seed_tables ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-07-12 11:05:18 +00:00
err = write_selects ( adapter )
2017-06-10 07:58:15 +00:00
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-12 09:03:14 +00:00
err = write_left_joins ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-12 09:03:14 +00:00
err = write_inner_joins ( adapter )
2017-06-10 07:58:15 +00:00
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-10 07:58:15 +00:00
err = write_inserts ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-10 07:58:15 +00:00
err = write_replaces ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-10 07:58:15 +00:00
err = write_updates ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-12 09:03:14 +00:00
err = write_deletes ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-14 07:09:44 +00:00
err = write_simple_counts ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-19 08:06:54 +00:00
err = write_insert_selects ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-19 08:06:54 +00:00
err = write_insert_left_joins ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-19 08:06:54 +00:00
err = write_insert_inner_joins ( adapter )
if err != nil {
return err
}
2017-09-10 16:57:22 +00:00
2017-06-10 07:58:15 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-07-12 11:05:18 +00:00
func create_tables ( adapter qgen . DB_Adapter ) error {
2017-09-10 16:57:22 +00:00
qgen . Install . CreateTable ( "users" , "utf8mb4" , "utf8mb4_general_ci" ,
2017-07-12 11:05:18 +00:00
[ ] qgen . DB_Table_Column {
2017-09-10 16:57:22 +00:00
qgen . DB_Table_Column { "uid" , "int" , 0 , false , true , "" } ,
qgen . DB_Table_Column { "name" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "password" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "salt" , "varchar" , 80 , false , false , "''" } ,
qgen . DB_Table_Column { "group" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "active" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "is_super_admin" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "createdAt" , "createdAt" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "lastActiveAt" , "datetime" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "session" , "varchar" , 200 , false , false , "''" } ,
qgen . DB_Table_Column { "last_ip" , "varchar" , 200 , false , false , "0.0.0.0.0" } ,
qgen . DB_Table_Column { "email" , "varchar" , 200 , false , false , "''" } ,
qgen . DB_Table_Column { "avatar" , "varchar" , 100 , false , false , "''" } ,
qgen . DB_Table_Column { "message" , "text" , 0 , false , false , "''" } ,
qgen . DB_Table_Column { "url_prefix" , "varchar" , 20 , false , false , "''" } ,
qgen . DB_Table_Column { "url_name" , "varchar" , 100 , false , false , "''" } ,
qgen . DB_Table_Column { "level" , "smallint" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "score" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "posts" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "bigposts" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "megaposts" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "topics" , "int" , 0 , false , false , "0" } ,
2017-07-17 10:23:42 +00:00
//qgen.DB_Table_Column{"penalty_count","int",0,false,false,"0"},
2017-09-10 16:57:22 +00:00
qgen . DB_Table_Column { "temp_group" , "int" , 0 , false , false , "0" } , // For temporary groups, set this to zero when a temporary group isn't in effect
2017-07-12 11:05:18 +00:00
} ,
[ ] qgen . DB_Table_Key {
2017-09-10 16:57:22 +00:00
qgen . DB_Table_Key { "uid" , "primary" } ,
qgen . DB_Table_Key { "name" , "unique" } ,
2017-07-12 11:05:18 +00:00
} ,
)
2017-09-10 16:57:22 +00:00
2017-10-14 07:39:22 +00:00
qgen . Install . CreateTable ( "users_groups" , "utf8mb4" , "utf8mb4_general_ci" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "gid" , "int" , 0 , false , true , "" } ,
qgen . DB_Table_Column { "name" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "permissions" , "text" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "plugin_perms" , "text" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "is_mod" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "is_admin" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "is_banned" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "tag" , "varchar" , 50 , false , false , "''" } ,
} ,
[ ] qgen . DB_Table_Key {
qgen . DB_Table_Key { "gid" , "primary" } ,
} ,
)
2017-07-17 10:23:42 +00:00
// What should we do about global penalties? Put them on the users table for speed? Or keep them here?
2017-08-27 09:33:45 +00:00
// Should we add IP Penalties? No, that's a stupid idea, just implement IP Bans properly. What about shadowbans?
2017-09-10 16:57:22 +00:00
// TODO: Perm overrides
// TODO: Add a mod-queue and other basic auto-mod features. This is needed for awaiting activation and the mod_queue penalty flag
// TODO: Add a penalty type where a user is stopped from creating plugin_socialgroups social groups
// TODO: Shadow bans. We will probably have a CanShadowBan permission for this, as we *really* don't want people using this lightly.
2017-08-13 11:22:34 +00:00
/ * qgen . Install . CreateTable ( "users_penalties" , "" , "" ,
2017-07-17 10:23:42 +00:00
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "uid" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "element_id" , "int" , 0 , false , false , "" } ,
2017-08-27 09:33:45 +00:00
qgen . DB_Table_Column { "element_type" , "varchar" , 50 , false , false , "" } , //forum, profile?, and social_group. Leave blank for global.
qgen . DB_Table_Column { "overrides" , "text" , 0 , false , false , "{}" } ,
2017-09-10 16:57:22 +00:00
2017-08-27 09:33:45 +00:00
qgen . DB_Table_Column { "mod_queue" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "shadow_ban" , "boolean" , 0 , false , false , "0" } ,
2017-07-17 10:23:42 +00:00
qgen . DB_Table_Column { "no_avatar" , "boolean" , 0 , false , false , "0" } , // Coming Soon. Should this be a perm override instead?
2017-09-10 16:57:22 +00:00
2017-08-27 09:33:45 +00:00
// Do we *really* need rate-limit penalty types? Are we going to be allowing bots or something?
//qgen.DB_Table_Column{"posts_per_hour","int",0,false,false,"0"},
//qgen.DB_Table_Column{"topics_per_hour","int",0,false,false,"0"},
//qgen.DB_Table_Column{"posts_count","int",0,false,false,"0"},
//qgen.DB_Table_Column{"topic_count","int",0,false,false,"0"},
2017-07-17 10:23:42 +00:00
//qgen.DB_Table_Column{"last_hour","int",0,false,false,"0"}, // UNIX Time, as we don't need to do anything too fancy here. When an hour has elapsed since that time, reset the hourly penalty counters.
2017-09-10 16:57:22 +00:00
2017-07-17 10:23:42 +00:00
qgen . DB_Table_Column { "issued_by" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "issued_at" , "createdAt" , 0 , false , false , "" } ,
2017-08-27 09:33:45 +00:00
qgen . DB_Table_Column { "expires_at" , "datetime" , 0 , false , false , "" } ,
2017-07-17 10:23:42 +00:00
} ,
[ ] qgen . DB_Table_Key { } ,
2017-08-13 11:22:34 +00:00
) * /
2017-09-10 16:57:22 +00:00
qgen . Install . CreateTable ( "users_groups_scheduler" , "" , "" ,
2017-08-27 09:33:45 +00:00
[ ] qgen . DB_Table_Column {
2017-09-10 16:57:22 +00:00
qgen . DB_Table_Column { "uid" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "set_group" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "issued_by" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "issued_at" , "createdAt" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "revert_at" , "datetime" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "temporary" , "boolean" , 0 , false , false , "" } , // special case for permanent bans to do the necessary bookkeeping, might be removed in the future
2017-08-27 09:33:45 +00:00
} ,
[ ] qgen . DB_Table_Key {
2017-09-10 16:57:22 +00:00
qgen . DB_Table_Key { "uid" , "primary" } ,
2017-08-27 09:33:45 +00:00
} ,
)
2017-09-10 16:57:22 +00:00
2017-10-14 07:39:22 +00:00
qgen . Install . CreateTable ( "emails" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "email" , "varchar" , 200 , false , false , "" } ,
qgen . DB_Table_Column { "uid" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "validated" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "token" , "varchar" , 200 , false , false , "''" } ,
} ,
[ ] qgen . DB_Table_Key { } ,
)
qgen . Install . CreateTable ( "forums" , "utf8mb4" , "utf8mb4_general_ci" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "fid" , "int" , 0 , false , true , "" } ,
qgen . DB_Table_Column { "name" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "desc" , "varchar" , 200 , false , false , "" } ,
qgen . DB_Table_Column { "active" , "boolean" , 0 , false , false , "1" } ,
qgen . DB_Table_Column { "topicCount" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "preset" , "varchar" , 100 , false , false , "''" } ,
qgen . DB_Table_Column { "parentID" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "parentType" , "varchar" , 50 , false , false , "''" } ,
qgen . DB_Table_Column { "lastTopicID" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "lastReplyerID" , "int" , 0 , false , false , "0" } ,
} ,
[ ] qgen . DB_Table_Key {
qgen . DB_Table_Key { "fid" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "forums_permissions" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "fid" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "gid" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "preset" , "varchar" , 100 , false , false , "''" } ,
qgen . DB_Table_Column { "permissions" , "text" , 0 , false , false , "" } ,
} ,
[ ] qgen . DB_Table_Key {
// TODO: Test to see that the compound primary key works
qgen . DB_Table_Key { "fid,gid" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "topics" , "utf8mb4" , "utf8mb4_general_ci" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "tid" , "int" , 0 , false , true , "" } ,
qgen . DB_Table_Column { "title" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "content" , "text" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "parsed_content" , "text" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "createdAt" , "createdAt" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "lastReplyAt" , "datetime" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "lastReplyBy" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "createdBy" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "is_closed" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "sticky" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "parentID" , "int" , 0 , false , false , "2" } ,
qgen . DB_Table_Column { "ipaddress" , "varchar" , 200 , false , false , "0.0.0.0.0" } ,
qgen . DB_Table_Column { "postCount" , "int" , 0 , false , false , "1" } ,
qgen . DB_Table_Column { "likeCount" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "words" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "css_class" , "varchar" , 100 , false , false , "''" } ,
qgen . DB_Table_Column { "data" , "varchar" , 200 , false , false , "''" } ,
} ,
[ ] qgen . DB_Table_Key {
qgen . DB_Table_Key { "tid" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "replies" , "utf8mb4" , "utf8mb4_general_ci" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "rid" , "int" , 0 , false , true , "" } ,
qgen . DB_Table_Column { "tid" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "content" , "text" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "parsed_content" , "text" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "createdAt" , "createdAt" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "createdBy" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "lastEdit" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "lastEditBy" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "lastUpdated" , "datetime" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "ipaddress" , "varchar" , 200 , false , false , "0.0.0.0.0" } ,
qgen . DB_Table_Column { "likeCount" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "words" , "int" , 0 , false , false , "1" } , // ? - replies has a default of 1 and topics has 0? why?
qgen . DB_Table_Column { "actionType" , "varchar" , 20 , false , false , "''" } ,
} ,
[ ] qgen . DB_Table_Key {
qgen . DB_Table_Key { "rid" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "attachments" , "utf8mb4" , "utf8mb4_general_ci" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "attachID" , "int" , 0 , false , true , "" } ,
qgen . DB_Table_Column { "sectionID" , "int" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "sectionTable" , "varchar" , 200 , false , false , "forums" } ,
qgen . DB_Table_Column { "originID" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "originTable" , "varchar" , 200 , false , false , "replies" } ,
qgen . DB_Table_Column { "uploadedBy" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "path" , "varchar" , 200 , false , false , "" } ,
} ,
[ ] qgen . DB_Table_Key {
qgen . DB_Table_Key { "attachID" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "revisions" , "utf8mb4" , "utf8mb4_general_ci" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "index" , "int" , 0 , false , false , "" } , // TODO: Replace this with a proper revision ID x.x
qgen . DB_Table_Column { "content" , "text" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "contentID" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "contentType" , "varchar" , 100 , false , false , "replies" } ,
} ,
[ ] qgen . DB_Table_Key { } ,
)
qgen . Install . CreateTable ( "users_replies" , "utf8mb4" , "utf8mb4_general_ci" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "rid" , "int" , 0 , false , true , "" } ,
qgen . DB_Table_Column { "uid" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "content" , "text" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "parsed_content" , "text" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "createdAt" , "createdAt" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "createdBy" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "lastEdit" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "lastEditBy" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "ipaddress" , "varchar" , 200 , false , false , "0.0.0.0.0" } ,
} ,
[ ] qgen . DB_Table_Key {
qgen . DB_Table_Key { "rid" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "likes" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "weight" , "tinyint" , 0 , false , false , "1" } ,
qgen . DB_Table_Column { "targetItem" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "targetType" , "varchar" , 50 , false , false , "replies" } ,
qgen . DB_Table_Column { "sentBy" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "recalc" , "tinyint" , 0 , false , false , "0" } ,
} ,
[ ] qgen . DB_Table_Key { } ,
)
qgen . Install . CreateTable ( "activity_stream_matches" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "watcher" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "asid" , "int" , 0 , false , false , "" } ,
} ,
[ ] qgen . DB_Table_Key { } ,
)
qgen . Install . CreateTable ( "activity_stream" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "asid" , "int" , 0 , false , true , "" } ,
qgen . DB_Table_Column { "actor" , "int" , 0 , false , false , "" } , /* the one doing the act */
qgen . DB_Table_Column { "targetUser" , "int" , 0 , false , false , "" } , /* the user who created the item the actor is acting on, some items like forums may lack a targetUser field */
qgen . DB_Table_Column { "event" , "varchar" , 50 , false , false , "" } , /* mention, like, reply (as in the act of replying to an item, not the reply item type, you can "reply" to a forum by making a topic in it), friend_invite */
qgen . DB_Table_Column { "elementType" , "varchar" , 50 , false , false , "" } , /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */
qgen . DB_Table_Column { "elementID" , "int" , 0 , false , false , "" } , /* the ID of the element being acted upon */
} ,
[ ] qgen . DB_Table_Key {
qgen . DB_Table_Key { "asid" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "activity_subscriptions" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "user" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "targetID" , "int" , 0 , false , false , "" } , /* the ID of the element being acted upon */
qgen . DB_Table_Column { "targetType" , "varchar" , 50 , false , false , "" } , /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */
qgen . DB_Table_Column { "level" , "int" , 0 , false , false , "0" } , /* 0: Mentions (aka the global default for any post), 1: Replies To You, 2: All Replies*/
} ,
[ ] qgen . DB_Table_Key { } ,
)
/* Due to MySQL's design, we have to drop the unique keys for table settings, plugins, and themes down from 200 to 180 or it will error */
qgen . Install . CreateTable ( "settings" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "name" , "varchar" , 180 , false , false , "" } ,
qgen . DB_Table_Column { "content" , "varchar" , 250 , false , false , "" } ,
qgen . DB_Table_Column { "type" , "varchar" , 50 , false , false , "" } ,
qgen . DB_Table_Column { "constraints" , "varchar" , 200 , false , false , "''" } ,
} ,
[ ] qgen . DB_Table_Key {
qgen . DB_Table_Key { "name" , "unique" } ,
} ,
)
2017-09-10 16:57:22 +00:00
qgen . Install . CreateTable ( "word_filters" , "" , "" ,
2017-08-27 09:33:45 +00:00
[ ] qgen . DB_Table_Column {
2017-09-10 16:57:22 +00:00
qgen . DB_Table_Column { "wfid" , "int" , 0 , false , true , "" } ,
qgen . DB_Table_Column { "find" , "varchar" , 200 , false , false , "" } ,
qgen . DB_Table_Column { "replacement" , "varchar" , 200 , false , false , "" } ,
2017-08-27 09:33:45 +00:00
} ,
[ ] qgen . DB_Table_Key {
2017-09-10 16:57:22 +00:00
qgen . DB_Table_Key { "wfid" , "primary" } ,
2017-08-27 09:33:45 +00:00
} ,
)
2017-09-10 16:57:22 +00:00
2017-10-14 07:39:22 +00:00
qgen . Install . CreateTable ( "plugins" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "uname" , "varchar" , 180 , false , false , "" } ,
qgen . DB_Table_Column { "active" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "installed" , "boolean" , 0 , false , false , "0" } ,
} ,
[ ] qgen . DB_Table_Key {
qgen . DB_Table_Key { "uname" , "unique" } ,
} ,
)
qgen . Install . CreateTable ( "themes" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "uname" , "varchar" , 180 , false , false , "" } ,
qgen . DB_Table_Column { "default" , "boolean" , 0 , false , false , "0" } ,
} ,
[ ] qgen . DB_Table_Key {
qgen . DB_Table_Key { "uname" , "unique" } ,
} ,
)
qgen . Install . CreateTable ( "widgets" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "position" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "side" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "type" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "active" , "boolean" , 0 , false , false , "0" } ,
qgen . DB_Table_Column { "location" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "data" , "text" , 0 , false , false , "''" } ,
} ,
[ ] qgen . DB_Table_Key { } ,
)
qgen . Install . CreateTable ( "moderation_logs" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "action" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "elementID" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "elementType" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "ipaddress" , "varchar" , 200 , false , false , "" } ,
qgen . DB_Table_Column { "actorID" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "doneAt" , "datetime" , 0 , false , false , "" } ,
} ,
[ ] qgen . DB_Table_Key { } ,
)
qgen . Install . CreateTable ( "administration_logs" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "action" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "elementID" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "elementType" , "varchar" , 100 , false , false , "" } ,
qgen . DB_Table_Column { "ipaddress" , "varchar" , 200 , false , false , "" } ,
qgen . DB_Table_Column { "actorID" , "int" , 0 , false , false , "" } ,
qgen . DB_Table_Column { "doneAt" , "datetime" , 0 , false , false , "" } ,
} ,
[ ] qgen . DB_Table_Key { } ,
)
2017-09-10 16:57:22 +00:00
qgen . Install . CreateTable ( "sync" , "" , "" ,
[ ] qgen . DB_Table_Column {
qgen . DB_Table_Column { "last_update" , "datetime" , 0 , false , false , "" } ,
} ,
[ ] qgen . DB_Table_Key { } ,
)
2017-07-12 11:05:18 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-07-12 11:05:18 +00:00
func seed_tables ( adapter qgen . DB_Adapter ) error {
2017-10-14 07:39:22 +00:00
qgen . Install . SimpleInsert ( "sync" , "last_update" , "UTC_TIMESTAMP()" )
qgen . Install . SimpleInsert ( "settings" , "name, content, type" , "'url_tags','1','bool'" )
qgen . Install . SimpleInsert ( "settings" , "name, content, type, constraints" , "'activation_type','1','list','1-3'" )
qgen . Install . SimpleInsert ( "settings" , "name, content, type" , "'bigpost_min_words','250','int'" )
qgen . Install . SimpleInsert ( "settings" , "name, content, type" , "'megapost_min_words','1000','int'" )
qgen . Install . SimpleInsert ( "themes" , "uname, default" , "'tempra-simple',1" )
qgen . Install . SimpleInsert ( "emails" , "email, uid, validated" , "'admin@localhost',1,1" ) // ? - Use a different default email or let the admin input it during installation?
/ *
The Permissions :
Global Permissions :
BanUsers
ActivateUsers
EditUser
EditUserEmail
EditUserPassword
EditUserGroup
EditUserGroupSuperMod
EditUserGroupAdmin
EditGroup
EditGroupLocalPerms
EditGroupGlobalPerms
EditGroupSuperMod
EditGroupAdmin
ManageForums
EditSettings
ManageThemes
ManagePlugins
ViewAdminLogs
ViewIPs
Non - staff Global Permissions :
UploadFiles
Forum Permissions :
ViewTopic
LikeItem
CreateTopic
EditTopic
DeleteTopic
CreateReply
EditReply
DeleteReply
PinTopic
CloseTopic
* /
qgen . Install . SimpleInsert ( "users_groups" , "name, permissions, plugin_perms, is_mod, is_admin, tag" , ` 'Administrator',' { "BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditUserGroupAdmin":false,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"EditGroupAdmin":false,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}',' { }',1,1,"Admin" ` )
qgen . Install . SimpleInsert ( "users_groups" , "name, permissions, plugin_perms, is_mod, tag" , ` 'Moderator',' { "BanUsers":true,"ActivateUsers":false,"EditUser":true,"EditUserEmail":false,"EditUserGroup":true,"ViewIPs":true,"UploadFiles":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}',' { }',1,"Mod" ` )
qgen . Install . SimpleInsert ( "users_groups" , "name, permissions, plugin_perms" , ` 'Member',' { "UploadFiles":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"CreateReply":true}',' { }' ` )
qgen . Install . SimpleInsert ( "users_groups" , "name, permissions, plugin_perms, is_banned" , ` 'Banned',' { "ViewTopic":true}',' { }',1 ` )
qgen . Install . SimpleInsert ( "users_groups" , "name, permissions, plugin_perms" , ` 'Awaiting Activation',' { "ViewTopic":true}',' { }' ` )
qgen . Install . SimpleInsert ( "users_groups" , "name, permissions, plugin_perms, tag" , ` 'Not Loggedin',' { "ViewTopic":true}',' { }','Guest' ` )
//
// TODO: Stop processFields() from stripping the spaces in the descriptions in the next commit
qgen . Install . SimpleInsert ( "forums" , "name, active, desc" , "'Reports',0,'All the reports go here'" )
qgen . Install . SimpleInsert ( "forums" , "name, lastTopicID, lastReplyerID, desc" , "'General',1,1,'A place for general discussions which don't fit elsewhere'" )
//
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , ` 1,1,' { "ViewTopic":true,"CreateReply":true,"CreateTopic":true,"PinTopic":true,"CloseTopic":true}' ` )
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , ` 2,1,' { "ViewTopic":true,"CreateReply":true,"CloseTopic":true}' ` )
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , "3,1,'{}'" )
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , "4,1,'{}'" )
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , "5,1,'{}'" )
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , "6,1,'{}'" )
//
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , ` 1,2,' { "ViewTopic":true,"CreateReply":true,"CreateTopic":true,"LikeItem":true,"EditTopic":true,"DeleteTopic":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}' ` )
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , ` 2,2,' { "ViewTopic":true,"CreateReply":true,"CreateTopic":true,"LikeItem":true,"EditTopic":true,"DeleteTopic":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}' ` )
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , ` 3,2,' { "ViewTopic":true,"CreateReply":true,"CreateTopic":true,"LikeItem":true}' ` )
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , ` 4,2,' { "ViewTopic":true}' ` )
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , ` 5,2,' { "ViewTopic":true}' ` )
qgen . Install . SimpleInsert ( "forums_permissions" , "gid, fid, permissions" , ` 6,2,' { "ViewTopic":true}' ` )
//
qgen . Install . SimpleInsert ( "topics" , "title, content, parsed_content, createdAt, lastReplyAt, lastReplyBy, createdBy, parentID" , "'Test Topic','A topic automatically generated by the software.','A topic automatically generated by the software.',UTC_TIMESTAMP(),UTC_TIMESTAMP(),1,1,2" )
qgen . Install . SimpleInsert ( "replies" , "tid, content, parsed_content, createdAt, createdBy, lastUpdated, lastEdit, lastEditBy" , "1,'A reply!','A reply!',UTC_TIMESTAMP(),1,UTC_TIMESTAMP(),0,0" )
2017-07-12 11:05:18 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-13 07:12:58 +00:00
func write_selects ( adapter qgen . DB_Adapter ) error {
2017-06-05 11:57:27 +00:00
// url_prefix and url_name will be removed from this query in a later commit
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getUser" , "users" , "name, group, is_super_admin, avatar, message, url_prefix, url_name, level" , "uid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
// Looking for getTopic? Your statement is in another castle
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getReply" , "replies" , "tid, content, createdBy, createdAt, lastEdit, lastEditBy, ipaddress, likeCount" , "rid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getUserReply" , "users_replies" , "uid, content, createdBy, createdAt, lastEdit, lastEditBy, ipaddress" , "rid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getPassword" , "users" , "password,salt" , "uid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getSettings" , "settings" , "name, content, type" , "" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getSetting" , "settings" , "content, type" , "name = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getFullSetting" , "settings" , "name, type, constraints" , "name = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getFullSettings" , "settings" , "name, content, type, constraints" , "" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getGroups" , "users_groups" , "gid, name, permissions, plugin_perms, is_mod, is_admin, is_banned, tag" , "" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-28 22:16:34 +00:00
adapter . SimpleSelect ( "getForums" , "forums" , "fid, name, desc, active, preset, parentID, parentType, topicCount, lastTopicID, lastReplyerID" , "" , "fid ASC" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getForumsPermissions" , "forums_permissions" , "gid, fid, permissions" , "" , "gid ASC, fid ASC" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getPlugins" , "plugins" , "uname, active, installed" , "" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getThemes" , "themes" , "uname, default" , "" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getWidgets" , "widgets" , "position, side, type, active, location, data" , "" , "position ASC" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "isPluginActive" , "plugins" , "active" , "uname = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
//adapter.SimpleSelect("isPluginInstalled","plugins","installed","uname = ?","","")
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getUsers" , "users" , "uid, name, group, active, is_super_admin, avatar" , "" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getUsersOffset" , "users" , "uid, name, group, active, is_super_admin, avatar" , "" , "" , "?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getWordFilters" , "word_filters" , "wfid, find, replacement" , "" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "isThemeDefault" , "themes" , "default" , "uname = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getModlogs" , "moderation_logs" , "action, elementID, elementType, ipaddress, actorID, doneAt" , "" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getModlogsOffset" , "moderation_logs" , "action, elementID, elementType, ipaddress, actorID, doneAt" , "" , "" , "?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getReplyTID" , "replies" , "tid" , "rid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getTopicFID" , "topics" , "parentID" , "tid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getUserReplyUID" , "users_replies" , "uid" , "rid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "hasLikedTopic" , "likes" , "targetItem" , "sentBy = ? and targetItem = ? and targetType = 'topics'" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "hasLikedReply" , "likes" , "targetItem" , "sentBy = ? and targetItem = ? and targetType = 'replies'" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getUserName" , "users" , "name" , "uid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getEmailsByUser" , "emails" , "email, validated, token" , "uid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getTopicBasic" , "topics" , "title, content" , "tid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getActivityEntry" , "activity_stream" , "actor, targetUser, event, elementType, elementID" , "asid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "forumEntryExists" , "forums" , "fid" , "name = ''" , "fid ASC" , "0,1" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "groupEntryExists" , "users_groups" , "gid" , "name = ''" , "gid ASC" , "0,1" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getForumTopicsOffset" , "topics" , "tid, title, content, createdBy, is_closed, sticky, createdAt, lastReplyAt, lastReplyBy, parentID, postCount, likeCount" , "parentID = ?" , "sticky DESC, lastReplyAt DESC, createdBy DESC" , "?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getExpiredScheduledGroups" , "users_groups_scheduler" , "uid" , "UTC_TIMESTAMP() > revert_at AND temporary = 1" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleSelect ( "getSync" , "sync" , "last_update" , "" , "" , "" )
2017-09-10 16:57:22 +00:00
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
adapter . SimpleSelect ( "getAttachment" , "attachments" , "sectionID, sectionTable, originID, originTable, uploadedBy, path" , "path = ? AND sectionID = ? AND sectionTable = ?" , "" , "" )
2017-06-10 07:58:15 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-13 07:12:58 +00:00
func write_left_joins ( adapter qgen . DB_Adapter ) error {
2017-10-14 07:39:22 +00:00
adapter . SimpleLeftJoin ( "getTopicRepliesOffset" , "replies" , "users" , "replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name, users.group, users.url_prefix, users.url_name, users.level, replies.ipaddress, replies.likeCount, replies.actionType" , "replies.createdBy = users.uid" , "replies.tid = ?" , "" , "?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleLeftJoin ( "getTopicList" , "topics" , "users" , "topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.parentID, users.name, users.avatar" , "topics.createdBy = users.uid" , "" , "topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy DESC" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleLeftJoin ( "getTopicUser" , "topics" , "users" , "topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, users.name, users.avatar, users.group, users.url_prefix, users.url_name, users.level" , "topics.createdBy = users.uid" , "tid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleLeftJoin ( "getTopicByReply" , "replies" , "topics" , "topics.tid, topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, topics.data" , "replies.tid = topics.tid" , "rid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleLeftJoin ( "getTopicReplies" , "replies" , "users" , "replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name, users.group, users.url_prefix, users.url_name, users.level, replies.ipaddress" , "replies.createdBy = users.uid" , "tid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleLeftJoin ( "getForumTopics" , "topics" , "users" , "topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, users.name, users.avatar" , "topics.createdBy = users.uid" , "topics.parentID = ?" , "topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy desc" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleLeftJoin ( "getProfileReplies" , "users_replies" , "users" , "users_replies.rid, users_replies.content, users_replies.createdBy, users_replies.createdAt, users_replies.lastEdit, users_replies.lastEditBy, users.avatar, users.name, users.group" , "users_replies.createdBy = users.uid" , "users_replies.uid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-06-12 09:03:14 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-13 07:12:58 +00:00
func write_inner_joins ( adapter qgen . DB_Adapter ) error {
2017-09-18 17:03:52 +00:00
adapter . SimpleInnerJoin ( "getWatchers" , "activity_stream" , "activity_subscriptions" , "activity_subscriptions.user" , "activity_subscriptions.targetType = activity_stream.elementType AND activity_subscriptions.targetID = activity_stream.elementID AND activity_subscriptions.user != activity_stream.actor" , "asid = ?" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-06-10 07:58:15 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-13 07:12:58 +00:00
func write_inserts ( adapter qgen . DB_Adapter ) error {
2017-10-14 07:39:22 +00:00
adapter . SimpleInsert ( "createTopic" , "topics" , "parentID, title, content, parsed_content, createdAt, lastReplyAt, lastReplyBy, ipaddress, words, createdBy" , "?,?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,?,?" )
2017-09-10 16:57:22 +00:00
2017-10-14 07:39:22 +00:00
adapter . SimpleInsert ( "createReport" , "topics" , "title, content, parsed_content, createdAt, lastReplyAt, createdBy, data, parentID, css_class" , "?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,1,'report'" )
2017-09-10 16:57:22 +00:00
2017-10-14 07:39:22 +00:00
adapter . SimpleInsert ( "createReply" , "replies" , "tid, content, parsed_content, createdAt, ipaddress, words, createdBy" , "?,?,?,UTC_TIMESTAMP(),?,?,?" )
2017-09-10 16:57:22 +00:00
2017-10-14 07:39:22 +00:00
adapter . SimpleInsert ( "createActionReply" , "replies" , "tid, actionType, ipaddress, createdBy" , "?,?,?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsert ( "createLike" , "likes" , "weight, targetItem, targetType, sentBy" , "?,?,?,?" )
2017-09-10 16:57:22 +00:00
2017-10-14 07:39:22 +00:00
adapter . SimpleInsert ( "addActivity" , "activity_stream" , "actor, targetUser, event, elementType, elementID" , "?,?,?,?,?" )
2017-09-10 16:57:22 +00:00
2017-10-14 07:39:22 +00:00
adapter . SimpleInsert ( "notifyOne" , "activity_stream_matches" , "watcher, asid" , "?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsert ( "addEmail" , "emails" , "email, uid, validated, token" , "?,?,?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsert ( "createProfileReply" , "users_replies" , "uid, content, parsed_content, createdAt, createdBy, ipaddress" , "?,?,?,UTC_TIMESTAMP(),?,?" )
2017-09-10 16:57:22 +00:00
2017-10-14 07:39:22 +00:00
adapter . SimpleInsert ( "addSubscription" , "activity_subscriptions" , "user, targetID, targetType, level" , "?,?,?,2" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsert ( "createForum" , "forums" , "name, desc, active, preset" , "?,?,?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsert ( "addForumPermsToForum" , "forums_permissions" , "gid,fid,preset,permissions" , "?,?,?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsert ( "addPlugin" , "plugins" , "uname, active, installed" , "?,?,?" )
2017-09-10 16:57:22 +00:00
2017-10-14 07:39:22 +00:00
adapter . SimpleInsert ( "addTheme" , "themes" , "uname, default" , "?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsert ( "createGroup" , "users_groups" , "name, tag, is_admin, is_mod, is_banned, permissions" , "?,?,?,?,?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsert ( "addModlogEntry" , "moderation_logs" , "action, elementID, elementType, ipaddress, actorID, doneAt" , "?,?,?,?,?,UTC_TIMESTAMP()" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsert ( "addAdminlogEntry" , "administration_logs" , "action, elementID, elementType, ipaddress, actorID, doneAt" , "?,?,?,?,?,UTC_TIMESTAMP()" )
2017-09-10 16:57:22 +00:00
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
adapter . SimpleInsert ( "addAttachment" , "attachments" , "sectionID, sectionTable, originID, originTable, uploadedBy, path" , "?,?,?,?,?,?" )
2017-09-18 17:03:52 +00:00
adapter . SimpleInsert ( "createWordFilter" , "word_filters" , "find, replacement" , "?,?" )
2017-09-10 16:57:22 +00:00
2017-06-10 07:58:15 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-13 07:12:58 +00:00
func write_replaces ( adapter qgen . DB_Adapter ) error {
2017-10-14 07:39:22 +00:00
adapter . SimpleReplace ( "addForumPermsToGroup" , "forums_permissions" , "gid, fid, preset, permissions" , "?,?,?,?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleReplace ( "replaceScheduleGroup" , "users_groups_scheduler" , "uid, set_group, issued_by, issued_at, revert_at, temporary" , "?,?,?,UTC_TIMESTAMP(),?,?" )
2017-09-10 16:57:22 +00:00
2017-06-10 07:58:15 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-13 07:12:58 +00:00
func write_updates ( adapter qgen . DB_Adapter ) error {
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "addRepliesToTopic" , "topics" , "postCount = postCount + ?, lastReplyBy = ?, lastReplyAt = UTC_TIMESTAMP()" , "tid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "removeRepliesFromTopic" , "topics" , "postCount = postCount - ?" , "tid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "addTopicsToForum" , "forums" , "topicCount = topicCount + ?" , "fid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "removeTopicsFromForum" , "forums" , "topicCount = topicCount - ?" , "fid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-28 22:16:34 +00:00
adapter . SimpleUpdate ( "updateForumCache" , "forums" , "lastTopicID = ?, lastReplyerID = ?" , "fid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "addLikesToTopic" , "topics" , "likeCount = likeCount + ?" , "tid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "addLikesToReply" , "replies" , "likeCount = likeCount + ?" , "rid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-22 02:21:17 +00:00
adapter . SimpleUpdate ( "editTopic" , "topics" , "title = ?, content = ?, parsed_content = ?" , "tid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "editReply" , "replies" , "content = ?, parsed_content = ?" , "rid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "stickTopic" , "topics" , "sticky = 1" , "tid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "unstickTopic" , "topics" , "sticky = 0" , "tid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-22 02:21:17 +00:00
adapter . SimpleUpdate ( "lockTopic" , "topics" , "is_closed = 1" , "tid = ?" )
adapter . SimpleUpdate ( "unlockTopic" , "topics" , "is_closed = 0" , "tid = ?" )
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateLastIP" , "users" , "last_ip = ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateSession" , "users" , "session = ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "setPassword" , "users" , "password = ?, salt = ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "setAvatar" , "users" , "avatar = ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "setUsername" , "users" , "name = ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "changeGroup" , "users" , "group = ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "activateUser" , "users" , "active = 1" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateUserLevel" , "users" , "level = ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "incrementUserScore" , "users" , "score = score + ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "incrementUserPosts" , "users" , "posts = posts + ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "incrementUserBigposts" , "users" , "posts = posts + ?, bigposts = bigposts + ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "incrementUserMegaposts" , "users" , "posts = posts + ?, bigposts = bigposts + ?, megaposts = megaposts + ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "incrementUserTopics" , "users" , "topics = topics + ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "editProfileReply" , "users_replies" , "content = ?, parsed_content = ?" , "rid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateForum" , "forums" , "name = ?, desc = ?, active = ?, preset = ?" , "fid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateSetting" , "settings" , "content = ?" , "name = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updatePlugin" , "plugins" , "active = ?" , "uname = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updatePluginInstall" , "plugins" , "installed = ?" , "uname = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateTheme" , "themes" , "default = ?" , "uname = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateUser" , "users" , "name = ?, email = ?, group = ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateGroupPerms" , "users_groups" , "permissions = ?" , "gid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateGroupRank" , "users_groups" , "is_admin = ?, is_mod = ?, is_banned = ?" , "gid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateGroup" , "users_groups" , "name = ?, tag = ?" , "gid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateEmail" , "emails" , "email = ?, uid = ?, validated = ?, token = ?" , "email = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "verifyEmail" , "emails" , "validated = 1, token = ''" , "email = ?" ) // Need to fix this: Empty string isn't working, it gets set to 1 instead x.x -- Has this been fixed?
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "setTempGroup" , "users" , "temp_group = ?" , "uid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "updateWordFilter" , "word_filters" , "find = ?, replacement = ?" , "wfid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleUpdate ( "bumpSync" , "sync" , "last_update = UTC_TIMESTAMP()" , "" )
2017-09-10 16:57:22 +00:00
2017-06-05 11:57:27 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-13 07:12:58 +00:00
func write_deletes ( adapter qgen . DB_Adapter ) error {
2017-09-18 17:03:52 +00:00
adapter . SimpleDelete ( "deleteReply" , "replies" , "rid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleDelete ( "deleteProfileReply" , "users_replies" , "rid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleDelete ( "deleteForumPermsByForum" , "forums_permissions" , "fid = ?" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleDelete ( "deleteActivityStreamMatch" , "activity_stream_matches" , "watcher = ? AND asid = ?" )
2017-08-18 12:16:56 +00:00
//adapter.SimpleDelete("delete_activity_stream_matches_by_watcher","activity_stream_matches","watcher = ?")
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleDelete ( "deleteWordFilter" , "word_filters" , "wfid = ?" )
2017-09-10 16:57:22 +00:00
2017-06-12 09:03:14 +00:00
return nil
2017-06-14 07:09:44 +00:00
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-14 07:09:44 +00:00
func write_simple_counts ( adapter qgen . DB_Adapter ) error {
2017-09-18 17:03:52 +00:00
adapter . SimpleCount ( "reportExists" , "topics" , "data = ? AND data != '' AND parentID = 1" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleCount ( "groupCount" , "users_groups" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleCount ( "modlogCount" , "moderation_logs" , "" , "" )
2017-09-10 16:57:22 +00:00
2017-06-19 08:06:54 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-19 08:06:54 +00:00
func write_insert_selects ( adapter qgen . DB_Adapter ) error {
2017-09-18 17:03:52 +00:00
adapter . SimpleInsertSelect ( "addForumPermsToForumAdmins" ,
2017-10-14 07:39:22 +00:00
qgen . DB_Insert { "forums_permissions" , "gid, fid, preset, permissions" , "" } ,
2017-09-10 16:57:22 +00:00
qgen . DB_Select { "users_groups" , "gid, ? AS fid, ? AS preset, ? AS permissions" , "is_admin = 1" , "" , "" } ,
2017-06-19 08:06:54 +00:00
)
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsertSelect ( "addForumPermsToForumStaff" ,
2017-10-14 07:39:22 +00:00
qgen . DB_Insert { "forums_permissions" , "gid, fid, preset, permissions" , "" } ,
2017-09-10 16:57:22 +00:00
qgen . DB_Select { "users_groups" , "gid, ? AS fid, ? AS preset, ? AS permissions" , "is_admin = 0 AND is_mod = 1" , "" , "" } ,
2017-06-25 09:56:39 +00:00
)
2017-09-10 16:57:22 +00:00
2017-09-18 17:03:52 +00:00
adapter . SimpleInsertSelect ( "addForumPermsToForumMembers" ,
2017-10-14 07:39:22 +00:00
qgen . DB_Insert { "forums_permissions" , "gid, fid, preset, permissions" , "" } ,
2017-09-10 16:57:22 +00:00
qgen . DB_Select { "users_groups" , "gid, ? AS fid, ? AS preset, ? AS permissions" , "is_admin = 0 AND is_mod = 0 AND is_banned = 0" , "" , "" } ,
2017-06-25 09:56:39 +00:00
)
2017-09-10 16:57:22 +00:00
2017-06-19 08:06:54 +00:00
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-19 08:06:54 +00:00
func write_insert_left_joins ( adapter qgen . DB_Adapter ) error {
return nil
}
2017-09-10 16:57:22 +00:00
// nolint
2017-06-19 08:06:54 +00:00
func write_insert_inner_joins ( adapter qgen . DB_Adapter ) error {
2017-09-18 17:03:52 +00:00
adapter . SimpleInsertInnerJoin ( "notifyWatchers" ,
2017-09-10 16:57:22 +00:00
qgen . DB_Insert { "activity_stream_matches" , "watcher, asid" , "" } ,
qgen . DB_Join { "activity_stream" , "activity_subscriptions" , "activity_subscriptions.user, activity_stream.asid" , "activity_subscriptions.targetType = activity_stream.elementType AND activity_subscriptions.targetID = activity_stream.elementID AND activity_subscriptions.user != activity_stream.actor" , "asid = ?" , "" , "" } ,
2017-06-19 08:06:54 +00:00
)
2017-09-10 16:57:22 +00:00
2017-06-14 07:09:44 +00:00
return nil
}