From a0070c64ddcec789e268f1baaf0ded7c7c37ab23 Mon Sep 17 00:00:00 2001 From: Yufeng Du Date: Fri, 10 Jan 2020 17:15:21 -0500 Subject: [PATCH] give admins option to force migrate rooms --- admin/class-bigbluebutton-admin.php | 19 +++++++++++++++--- admin/css/bigbluebutton-admin.css | 6 ++++++ .../bigbluebutton-settings-display.php | 7 +++++++ includes/class-bigbluebutton-migration.php | 14 ++++++++++--- includes/class-bigbluebutton.php | 5 ++++- languages/bigbluebutton-en_CA.mo | Bin 6047 -> 6223 bytes languages/bigbluebutton-en_CA.po | 8 +++++++- languages/bigbluebutton-en_US.mo | Bin 6047 -> 6223 bytes languages/bigbluebutton-en_US.po | 8 +++++++- languages/bigbluebutton.pot | 6 ++++++ 10 files changed, 64 insertions(+), 9 deletions(-) diff --git a/admin/class-bigbluebutton-admin.php b/admin/class-bigbluebutton-admin.php index 90dd709..648ca78 100644 --- a/admin/class-bigbluebutton-admin.php +++ b/admin/class-bigbluebutton-admin.php @@ -210,9 +210,10 @@ public function bbb_room_custom_columns( $column, $post_id ) { * @since 3.0.0 */ public function display_room_server_settings() { - $change_success = $this->room_server_settings_change(); - $bbb_settings = $this->fetch_room_server_settings(); - $meta_nonce = wp_create_nonce( 'bbb_edit_server_settings_meta_nonce' ); + $change_success = $this->room_server_settings_change(); + $bbb_settings = $this->fetch_room_server_settings(); + $meta_nonce = wp_create_nonce( 'bbb_edit_server_settings_meta_nonce' ); + $old_rooms_exist = $this->check_old_room_tables(); require_once 'partials/bigbluebutton-settings-display.php'; } @@ -253,6 +254,18 @@ public function bigbluebutton_show_upgrade_notification( $current_plugin_metadat } } + /** + * Check if old rooms table exists. + * + * @since 3.0.0 + */ + private function check_old_room_tables() { + global $wpdb; + $old_rooms_table = $wpdb->prefix . 'bigbluebutton'; + $old_rooms_query = $wpdb->prepare( 'SHOW TABLES LIKE %s;', $wpdb->esc_like( $old_rooms_table ) ); + return $wpdb->get_var( $old_rooms_query ) === $old_rooms_table; + } + /** * Get information about the newest plugin version. * diff --git a/admin/css/bigbluebutton-admin.css b/admin/css/bigbluebutton-admin.css index 69a1357..47e45ae 100644 --- a/admin/css/bigbluebutton-admin.css +++ b/admin/css/bigbluebutton-admin.css @@ -55,3 +55,9 @@ margin-top: 2em; margin-bottom: 2em; } + +.bbb-warning { + font-weight: 700; + color: red; + font-size: 1.2em; +} \ No newline at end of file diff --git a/admin/partials/bigbluebutton-settings-display.php b/admin/partials/bigbluebutton-settings-display.php index d5f5d1b..3dd6e7b 100644 --- a/admin/partials/bigbluebutton-settings-display.php +++ b/admin/partials/bigbluebutton-settings-display.php @@ -1,4 +1,11 @@
+ +
+ +

+ +
+

diff --git a/includes/class-bigbluebutton-migration.php b/includes/class-bigbluebutton-migration.php index 41b4e8d..1897f09 100644 --- a/includes/class-bigbluebutton-migration.php +++ b/includes/class-bigbluebutton-migration.php @@ -85,10 +85,10 @@ public function migrate() { * * @since 3.0.0 */ - private function import_rooms() { + public function import_rooms() { global $wpdb; - $old_rooms_table = 'wp_bigbluebutton'; - $old_room_logs_table = 'wp_bigbluebutton_logs'; + $old_rooms_table = $wpdb->prefix . 'bigbluebutton'; + $old_room_logs_table = $wpdb->prefix . 'bigbluebutton_logs'; // Import old rooms to new rooms. $old_rooms_query = $wpdb->prepare( 'SHOW TABLES LIKE %s;', $wpdb->esc_like( $old_rooms_table ) ); @@ -151,6 +151,14 @@ private function import_rooms() { $wpdb->query( 'DROP TABLE IF EXISTS ' . $old_room_logs_table ); } } + + // Redirect to rooms page after forced migration. + if (isset($_POST['action']) && "bbb_force_migration" == $_POST['action']) { + $args = array( + 'post_type' => 'bbb-room' + ); + wp_redirect( add_query_arg( $args, admin_url( 'edit.php') ) ); + } return true; } diff --git a/includes/class-bigbluebutton.php b/includes/class-bigbluebutton.php index 9426093..64f006c 100644 --- a/includes/class-bigbluebutton.php +++ b/includes/class-bigbluebutton.php @@ -236,10 +236,10 @@ private function set_locale() { * @access private */ private function define_admin_hooks() { - $plugin_admin = new Bigbluebutton_Admin( $this->get_plugin_name(), $this->get_version() ); $plugin_admin_api = new Bigbluebutton_Admin_Api(); $plugin_admin_register_custom_types = new Bigbluebutton_Register_Custom_Types(); + $migrator = new Bigbluebutton_Migration( "1.4.6", $this->get_version() ); // Suggest not disabling heartbeat. $this->loader->add_action( 'admin_notices', $plugin_admin, 'check_for_heartbeat_script' ); @@ -274,6 +274,9 @@ private function define_admin_hooks() { $this->loader->add_action( 'manage_posts_custom_column', $plugin_admin, 'bbb_room_custom_columns', 10, 2 ); $this->loader->add_filter( 'manage_bbb-room_posts_columns', $plugin_admin, 'add_custom_room_column_to_list' ); + // Force old rooms migration. + $this->loader->add_action( 'admin_post_bbb_force_migration', $migrator, 'import_rooms' ); + } /** diff --git a/languages/bigbluebutton-en_CA.mo b/languages/bigbluebutton-en_CA.mo index 0c29fbd3d9f8235f505bf0c5a4410a362578a14a..3d4bf9f905900e9f9e18f02dc044a7778ef342a5 100644 GIT binary patch delta 1771 zcmb`{-%rhP9LMobb&f*6^DBvODL*2elTHzl^h^#Di4|CfJ1`CV(1W)z2ggwN&EVlUOh&yY zokNN-A(O?)Vg}Yu515^pMBj(W*o{qi7PY2v``7@t5B;t3}1Wpd>C*pj}#7*eI zQtZYO9Kd+yH%EMb20gp*Ym!_{0YKs~q%^`*_I1+*c5<~WCPJdN7w2dI?&Kp*ZSUu8Iq7EWO? zF5#teH!3w3Fy!Xs4krybf!u3~nN2IKK&`wHS)i$OZs+9SVsZ4tk`>z-GFi?kQP(}0%M{pdq(lCXf`(7d0G2^HgeME}Ld_~oe zlaBg19C*|eBbQ7ys)qKU7Iqi4vqLHDzg{%VfO7g6HNi`}{}xq5pHW2=%jc?ys!>IB z3iTyJs0BVm?a+wbAGQ1MkWDaOY^PB3#fSJ@6;TGNh>B1bw%hJSP0)tg+GD5*PM}hB z9$WAlmZM`1za*?eJ=cT!(sQTe#~ZdDxO~3 zd#KcWM>l4$O$}I&%5^{TsJV?=_Yx(xrA0q!(=+qF|1e+Au6|fumS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SP0)tg+GD5*PM}hB z9$WAlmZM`1za*?eJ=cT!(sQTe#~ZdDxO~3 zd#KcWM>l4$O$}I&%5^{TsJV?=_Yx(xrA0q!(=+qF|1e+Au6|fumSH3mjLL!q`M^q84Ba#v=N=2l$ znXm}`r&KEbW-Bfs zR4=RSF{LDz(AK&LrD6>cO{i&Sm4-@nXsd}lVi}?It=zytZ40rI(9cHALu3&JL^@Fx z{^hKRN~#V75BRP6w$`AxyDiWeewths(em4r4uzS%098qLf7( zY{yO7nBd_MS!9<@KWd^Ys2UkW)y$}Uev14vlU!6Y zUr-6f7_1%Lje5TgbySB?^Bxbe|LQnRhl-{TRWvtHMKg)YJiuowpb+N}FMN+m z;4|v|?-<89RLwN3UZ|Nf*v<14s%G3eRyoDZc~sGSv<696N0C4Wd$AKoQD^%T8EXEZ z5)ZL`+MzsD0>!9t6-e%;5mhrCsPVUvBXZ3hZm606O<$o_x`1~K)!b`4%WdBx`VXs- z*h@qREu>vp+H}rZFrO$S>WMuBdGi6Be}bD5LQPwu!dh%K+@uo41Uu=qR_jvq#W6xf zR$zZnLGp#(E~u-4P;G4@bYyCA{ryM1TdEX`2sXrQwS9HCfzZ}&BdUlBB85<+J`G1{ zTJ%6GBeoDaIvraRp|*?IOz;QhwOX$0i9jV6Rp|C)(XxHMWFi#v-5L+yPhJmP_GdXw bl}=5iQyXy_o1JK~C@VkJ8<89j52gJBy8wMj diff --git a/languages/bigbluebutton-en_US.po b/languages/bigbluebutton-en_US.po index fe7af01..796cc04 100644 --- a/languages/bigbluebutton-en_US.po +++ b/languages/bigbluebutton-en_US.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2019-09-13 10:54-0400\n" -"PO-Revision-Date: 2019-12-13 18:15-0500\n" +"PO-Revision-Date: 2020-01-10 16:42-0500\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -56,6 +56,12 @@ msgstr "" "Error: The server cannot be reached. Are you sure the server is running and your settings " "are correct?" +msgid "Force Migration" +msgstr "Force Migration" + +msgid "Please backup your database before migrating old rooms." +msgstr "Please backup your database before migrating old rooms." + # Admin Room settings msgid "Add New" msgstr "Add New" diff --git a/languages/bigbluebutton.pot b/languages/bigbluebutton.pot index e757c01..f999057 100644 --- a/languages/bigbluebutton.pot +++ b/languages/bigbluebutton.pot @@ -50,6 +50,12 @@ msgstr "" msgid "Save server settings bad server settings error message." msgstr "" +msgid "Force Migration" +msgstr "" + +msgid "Please backup your database before migrating old rooms." +msgstr "" + # Admin Room settings msgid "Add New" msgstr ""