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-06-05 11:57:27 +00:00
write_statements ( adapter )
2017-06-13 07:12:58 +00:00
adapter . Write ( )
2017-06-05 11:57:27 +00:00
}
}
2017-06-13 07:12:58 +00:00
func write_statements ( adapter qgen . DB_Adapter ) error {
2017-06-10 07:58:15 +00:00
err := write_selects ( adapter )
if err != nil {
return err
}
2017-06-19 08:06:54 +00:00
2017-06-12 09:03:14 +00:00
err = write_left_joins ( adapter )
if err != nil {
return err
}
2017-06-19 08:06:54 +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-06-19 08:06:54 +00:00
2017-06-10 07:58:15 +00:00
err = write_inserts ( adapter )
if err != nil {
return err
}
2017-06-19 08:06:54 +00:00
2017-06-10 07:58:15 +00:00
err = write_replaces ( adapter )
if err != nil {
return err
}
2017-06-19 08:06:54 +00:00
2017-06-10 07:58:15 +00:00
err = write_updates ( adapter )
if err != nil {
return err
}
2017-06-19 08:06:54 +00:00
2017-06-12 09:03:14 +00:00
err = write_deletes ( adapter )
if err != nil {
return err
}
2017-06-19 08:06:54 +00:00
2017-06-14 07:09:44 +00:00
err = write_simple_counts ( adapter )
if err != nil {
return err
}
2017-06-19 08:06:54 +00:00
err = write_insert_selects ( adapter )
if err != nil {
return err
}
err = write_insert_left_joins ( adapter )
if err != nil {
return err
}
err = write_insert_inner_joins ( adapter )
if err != nil {
return err
}
2017-06-10 07:58:15 +00:00
return nil
}
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-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_user" , "users" , "name, group, is_super_admin, avatar, message, url_prefix, url_name, level" , "uid = ?" , "" , "" )
2017-06-05 11:57:27 +00:00
2017-06-13 08:56:48 +00:00
// Looking for get_topic? Your statement is in another castle
2017-06-05 11:57:27 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_reply" , "replies" , "tid, content, createdBy, createdAt, lastEdit, lastEditBy, ipaddress, likeCount" , "rid = ?" , "" , "" )
2017-06-14 07:09:44 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_user_reply" , "users_replies" , "uid, content, createdBy, createdAt, lastEdit, lastEditBy, ipaddress" , "rid = ?" , "" , "" )
2017-06-06 08:47:33 +00:00
2017-06-25 09:56:39 +00:00
adapter . SimpleSelect ( "get_password" , "users" , "password,salt" , "uid = ?" , "" , "" )
2017-06-06 08:47:33 +00:00
2017-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_settings" , "settings" , "name, content, type" , "" , "" , "" )
2017-06-05 11:57:27 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_setting" , "settings" , "content, type" , "name = ?" , "" , "" )
2017-06-06 08:47:33 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_full_setting" , "settings" , "name, type, constraints" , "name = ?" , "" , "" )
2017-06-06 08:47:33 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_full_settings" , "settings" , "name, content, type, constraints" , "" , "" , "" )
2017-06-14 07:09:44 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_groups" , "users_groups" , "gid, name, permissions, is_mod, is_admin, is_banned, tag" , "" , "" , "" )
2017-06-14 07:09:44 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_forums" , "forums" , "fid, name, desc, active, preset, topicCount, lastTopic, lastTopicID, lastReplyer, lastReplyerID, lastTopicTime" , "" , "fid ASC" , "" )
2017-06-14 07:09:44 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_forums_permissions" , "forums_permissions" , "gid, fid, permissions" , "" , "gid ASC, fid ASC" , "" )
2017-06-14 07:09:44 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_plugins" , "plugins" , "uname, active" , "" , "" , "" )
2017-06-14 07:09:44 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_themes" , "themes" , "uname, default" , "" , "" , "" )
2017-06-14 07:09:44 +00:00
2017-06-19 08:06:54 +00:00
adapter . SimpleSelect ( "get_widgets" , "widgets" , "position, side, type, active, location, data" , "" , "position ASC" , "" )
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "is_plugin_active" , "plugins" , "active" , "uname = ?" , "" , "" )
2017-06-06 08:47:33 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_users" , "users" , "uid, name, group, active, is_super_admin, avatar" , "" , "" , "" )
2017-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "is_theme_default" , "themes" , "default" , "uname = ?" , "" , "" )
2017-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_modlogs" , "moderation_logs" , "action, elementID, elementType, ipaddress, actorID, doneAt" , "" , "" , "" )
2017-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_reply_tid" , "replies" , "tid" , "rid = ?" , "" , "" )
2017-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_topic_fid" , "topics" , "parentID" , "tid = ?" , "" , "" )
2017-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_user_reply_uid" , "users_replies" , "uid" , "rid = ?" , "" , "" )
2017-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "has_liked_topic" , "likes" , "targetItem" , "sentBy = ? and targetItem = ? and targetType = 'topics'" , "" , "" )
2017-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "has_liked_reply" , "likes" , "targetItem" , "sentBy = ? and targetItem = ? and targetType = 'replies'" , "" , "" )
2017-06-07 10:07:40 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_user_name" , "users" , "name" , "uid = ?" , "" , "" )
2017-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_user_rank" , "users" , "group, is_super_admin" , "uid = ?" , "" , "" )
2017-06-12 09:03:14 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_user_active" , "users" , "active" , "uid = ?" , "" , "" )
2017-06-12 09:03:14 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_user_group" , "users" , "group" , "uid = ?" , "" , "" )
2017-06-12 09:03:14 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_emails_by_user" , "emails" , "email, validated, token" , "uid = ?" , "" , "" )
2017-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_topic_basic" , "topics" , "title, content" , "tid = ?" , "" , "" )
2017-06-12 09:03:14 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleSelect ( "get_activity_entry" , "activity_stream" , "actor, targetUser, event, elementType, elementID" , "asid = ?" , "" , "" )
2017-06-16 10:41:30 +00:00
adapter . SimpleSelect ( "forum_entry_exists" , "forums" , "fid" , "name = ''" , "fid ASC" , "0,1" )
2017-06-15 11:40:35 +00:00
2017-06-16 10:41:30 +00:00
adapter . SimpleSelect ( "group_entry_exists" , "users_groups" , "gid" , "name = ''" , "gid ASC" , "0,1" )
2017-06-12 09:03:14 +00:00
2017-06-10 07:58:15 +00:00
return nil
}
2017-06-13 07:12:58 +00:00
func write_left_joins ( adapter qgen . DB_Adapter ) error {
2017-06-15 11:40:35 +00:00
adapter . SimpleLeftJoin ( "get_topic_replies_offset" , "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" , "tid = ?" , "" , "?,?" )
adapter . SimpleLeftJoin ( "get_forum_topics_offset" , "topics" , "users" , "topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, topics.postCount, topics.likeCount, users.name, users.avatar" , "topics.createdBy = users.uid" , "topics.parentID = ?" , "topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy DESC" , "?,?" )
adapter . SimpleLeftJoin ( "get_topic_list" , "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-06-05 11:57:27 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleLeftJoin ( "get_topic_user" , "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-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleLeftJoin ( "get_topic_by_reply" , "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-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleLeftJoin ( "get_topic_replies" , "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-06-05 11:57:27 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleLeftJoin ( "get_forum_topics" , "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-06-06 14:41:06 +00:00
2017-06-15 11:40:35 +00:00
adapter . SimpleLeftJoin ( "get_profile_replies" , "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-06-12 09:03:14 +00:00
return nil
}
2017-06-13 07:12:58 +00:00
func write_inner_joins ( adapter qgen . DB_Adapter ) error {
2017-06-15 11:40:35 +00:00
adapter . SimpleInnerJoin ( "get_watchers" , "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-06-12 09:03:14 +00:00
2017-06-10 07:58:15 +00:00
return nil
}
2017-06-13 07:12:58 +00:00
func write_inserts ( adapter qgen . DB_Adapter ) error {
adapter . SimpleInsert ( "create_topic" , "topics" , "parentID,title,content,parsed_content,createdAt,lastReplyAt,ipaddress,words,createdBy" , "?,?,?,?,NOW(),NOW(),?,?,?" )
2017-06-05 11:57:27 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "create_report" , "topics" , "title,content,parsed_content,createdAt,lastReplyAt,createdBy,data,parentID,css_class" , "?,?,?,NOW(),NOW(),?,?,1,'report'" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "create_reply" , "replies" , "tid,content,parsed_content,createdAt,ipaddress,words,createdBy" , "?,?,?,NOW(),?,?,?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "create_action_reply" , "replies" , "tid,actionType,ipaddress,createdBy" , "?,?,?,?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "create_like" , "likes" , "weight, targetItem, targetType, sentBy" , "?,?,?,?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "add_activity" , "activity_stream" , "actor,targetUser,event,elementType,elementID" , "?,?,?,?,?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "notify_one" , "activity_stream_matches" , "watcher,asid" , "?,?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "add_email" , "emails" , "email, uid, validated, token" , "?,?,?,?" )
2017-06-12 09:03:14 +00:00
2017-06-14 07:09:44 +00:00
adapter . SimpleInsert ( "create_profile_reply" , "users_replies" , "uid, content, parsed_content, createdAt, createdBy, ipaddress" , "?,?,?,NOW(),?,?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "add_subscription" , "activity_subscriptions" , "user,targetID,targetType,level" , "?,?,?,2" )
2017-06-12 09:03:14 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "create_forum" , "forums" , "name, desc, active, preset" , "?,?,?,?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "add_forum_perms_to_forum" , "forums_permissions" , "gid,fid,preset,permissions" , "?,?,?,?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "add_plugin" , "plugins" , "uname,active" , "?,?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "add_theme" , "themes" , "uname,default" , "?,?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "create_group" , "users_groups" , "name, tag, is_admin, is_mod, is_banned, permissions" , "?,?,?,?,?,?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "add_modlog_entry" , "moderation_logs" , "action, elementID, elementType, ipaddress, actorID, doneAt" , "?,?,?,?,?,NOW()" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleInsert ( "add_adminlog_entry" , "administration_logs" , "action, elementID, elementType, ipaddress, actorID, doneAt" , "?,?,?,?,?,NOW()" )
2017-06-10 07:58:15 +00:00
return nil
}
2017-06-13 07:12:58 +00:00
func write_replaces ( adapter qgen . DB_Adapter ) error {
adapter . SimpleReplace ( "add_forum_perms_to_group" , "forums_permissions" , "gid,fid,preset,permissions" , "?,?,?,?" )
2017-06-10 07:58:15 +00:00
return nil
}
2017-06-13 07:12:58 +00:00
func write_updates ( adapter qgen . DB_Adapter ) error {
adapter . SimpleUpdate ( "add_replies_to_topic" , "topics" , "postCount = postCount + ?, lastReplyAt = NOW()" , "tid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "remove_replies_from_topic" , "topics" , "postCount = postCount - ?" , "tid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "add_topics_to_forum" , "forums" , "topicCount = topicCount + ?" , "fid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "remove_topics_from_forum" , "forums" , "topicCount = topicCount - ?" , "fid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_forum_cache" , "forums" , "lastTopic = ?, lastTopicID = ?, lastReplyer = ?, lastReplyerID = ?, lastTopicTime = NOW()" , "fid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "add_likes_to_topic" , "topics" , "likeCount = likeCount + ?" , "tid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "add_likes_to_reply" , "replies" , "likeCount = likeCount + ?" , "rid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "edit_topic" , "topics" , "title = ?, content = ?, parsed_content = ?, is_closed = ?" , "tid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "edit_reply" , "replies" , "content = ?, parsed_content = ?" , "rid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "stick_topic" , "topics" , "sticky = 1" , "tid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "unstick_topic" , "topics" , "sticky = 0" , "tid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_last_ip" , "users" , "last_ip = ?" , "uid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_session" , "users" , "session = ?" , "uid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "set_password" , "users" , "password = ?, salt = ?" , "uid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "set_avatar" , "users" , "avatar = ?" , "uid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "set_username" , "users" , "name = ?" , "uid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "change_group" , "users" , "group = ?" , "uid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "activate_user" , "users" , "active = 1" , "uid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_user_level" , "users" , "level = ?" , "uid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "increment_user_score" , "users" , "score = score + ?" , "uid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "increment_user_posts" , "users" , "posts = posts + ?" , "uid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "increment_user_bigposts" , "users" , "posts = posts + ?, bigposts = bigposts + ?" , "uid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "increment_user_megaposts" , "users" , "posts = posts + ?, bigposts = bigposts + ?, megaposts = megaposts + ?" , "uid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "increment_user_topics" , "users" , "topics = topics + ?" , "uid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "edit_profile_reply" , "users_replies" , "content = ?, parsed_content = ?" , "rid = ?" )
2017-06-10 07:58:15 +00:00
//delete_forum_stmt, err = db.Prepare("delete from forums where fid = ?")
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "delete_forum" , "forums" , "name= '', active = 0" , "fid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_forum" , "forums" , "name = ?, desc = ?, active = ?, preset = ?" , "fid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_setting" , "settings" , "content = ?" , "name = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_plugin" , "plugins" , "active = ?" , "uname = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_theme" , "themes" , "default = ?" , "uname = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_user" , "users" , "name = ?, email = ?, group = ?" , "uid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_group_perms" , "users_groups" , "permissions = ?" , "gid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_group_rank" , "users_groups" , "is_admin = ?, is_mod = ?, is_banned = ?" , "gid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleUpdate ( "update_group" , "users_groups" , "name = ?, tag = ?" , "gid = ?" )
2017-06-10 07:58:15 +00:00
2017-06-14 07:09:44 +00:00
adapter . SimpleUpdate ( "update_email" , "emails" , "email = ?, uid = ?, validated = ?, token = ?" , "email = ?" )
adapter . SimpleUpdate ( "verify_email" , "emails" , "validated = 1, token = ''" , "email = ?" ) // Need to fix this: Empty string isn't working, it gets set to 1 instead x.x
2017-06-05 11:57:27 +00:00
return nil
}
2017-06-13 07:12:58 +00:00
func write_deletes ( adapter qgen . DB_Adapter ) error {
adapter . SimpleDelete ( "delete_reply" , "replies" , "rid = ?" )
2017-06-07 10:07:40 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleDelete ( "delete_topic" , "topics" , "tid = ?" )
2017-06-12 09:03:14 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleDelete ( "delete_profile_reply" , "users_replies" , "rid = ?" )
2017-06-12 09:03:14 +00:00
2017-06-13 07:12:58 +00:00
adapter . SimpleDelete ( "delete_forum_perms_by_forum" , "forums_permissions" , "fid = ?" )
2017-06-12 09:03:14 +00:00
return nil
2017-06-14 07:09:44 +00:00
}
func write_simple_counts ( adapter qgen . DB_Adapter ) error {
2017-06-19 08:06:54 +00:00
adapter . SimpleCount ( "report_exists" , "topics" , "data = ? AND data != '' AND parentID = 1" , "" )
return nil
}
func write_insert_selects ( adapter qgen . DB_Adapter ) error {
adapter . SimpleInsertSelect ( "add_forum_perms_to_forum_admins" ,
qgen . DB_Insert { "forums_permissions" , "gid,fid,preset,permissions" , "" } ,
qgen . DB_Select { "users_groups" , "gid, ? AS fid, ? AS preset, ? AS permissions" , "is_admin = 1" , "" , "" } ,
)
2017-06-25 09:56:39 +00:00
adapter . SimpleInsertSelect ( "add_forum_perms_to_forum_staff" ,
qgen . DB_Insert { "forums_permissions" , "gid,fid,preset,permissions" , "" } ,
qgen . DB_Select { "users_groups" , "gid, ? AS fid, ? AS preset, ? AS permissions" , "is_admin = 0 AND is_mod = 1" , "" , "" } ,
)
adapter . SimpleInsertSelect ( "add_forum_perms_to_forum_members" ,
qgen . DB_Insert { "forums_permissions" , "gid,fid,preset,permissions" , "" } ,
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-19 08:06:54 +00:00
return nil
}
func write_insert_left_joins ( adapter qgen . DB_Adapter ) error {
return nil
}
func write_insert_inner_joins ( adapter qgen . DB_Adapter ) error {
adapter . SimpleInsertInnerJoin ( "notify_watchers" ,
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-14 07:09:44 +00:00
return nil
}