function test() { if (!$this->table_exists($this->bmp_table)) { $obj = new RTDBUpdate(false, RTMEDIA_PATH . 'index.php', RTMEDIA_PATH . 'app/schema/', true); $obj->install_db_version = '0'; $obj->do_upgrade(true); } global $rtmedia_error; if (isset($rtmedia_error) && true === $rtmedia_error) { ?> <div class="error"><p> Please Resolve create database error before migration.</p></div> <?php } $prog = new rtProgress(); $total = $this->get_total_count(); $done = $this->get_done_count(); if ($done >= $total) { $done = $total; } else { ?> <div class="error"> <p><?php _e('Please Backup your <strong>DATABASE</strong> and <strong>UPLOAD</strong> folder before Migration.', 'buddypress-media'); ?> </p> </div> <?php } ?> <div class="wrap"> <h2><?php _e('rtMedia Migration', 'buddypress-media'); ?> </h2> <h3><?php _e('It will migrate following things', 'buddypress-media'); ?> </h3> User Albums : <?php echo $_SESSION['migration_user_album']; ?> <br/> <?php if (isset($_SESSION['migration_group_album'])) { ?> Groups Albums : <?php echo $_SESSION['migration_group_album']; ?> <br/> <?php } ?> Media : <?php echo $_SESSION['migration_media']; ?> <br/> <?php if (isset($_SESSION['migration_activity'])) { ?> Comments : <?php echo $_SESSION['migration_activity']; ?> <br/> <?php } ?> <hr/> <?php echo '<span class="pending">' . $this->formatSeconds($total - $done) . '</span><br />'; echo '<span class="finished">' . $done . '</span>/<span class="total">' . $total . '</span>'; echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />'; $temp = $prog->progress($done, $total); $prog->progress_ui($temp, true); ?> <script type="text/javascript"> jQuery( document ).ready( function ( e ) { jQuery( "#toplevel_page_rtmedia-settings" ).addClass( "wp-has-current-submenu" ) jQuery( "#toplevel_page_rtmedia-settings" ).removeClass( "wp-not-current-submenu" ) jQuery( "#toplevel_page_rtmedia-settings" ).addClass( "wp-menu-open" ) jQuery( "#toplevel_page_rtmedia-settings>a" ).addClass( "wp-menu-open" ) jQuery( "#toplevel_page_rtmedia-settings>a" ).addClass( "wp-has-current-submenu" ) if ( db_total < 1 ) jQuery( "#submit" ).attr( 'disabled', "disabled" ); } ) function db_start_migration( db_done, db_total ) { if ( db_done < db_total ) { jQuery( "#rtMediaSyncing" ).show(); jQuery.ajax( { url: rtmedia_admin_ajax, type: 'post', data: { "action": "bp_media_rt_db_migration", "done": db_done }, success: function ( sdata ) { try { data = JSON.parse( sdata ); } catch ( e ) { jQuery( "#submit" ).attr( 'disabled', "" ); } if ( data.status ) { done = parseInt( data.done ); total = parseInt( data.total ); var progw = Math.ceil( (done / total) * 100 ); if ( progw > 100 ) { progw = 100; } ; jQuery( '#rtprogressbar>div' ).css( 'width', progw + '%' ); jQuery( 'span.finished' ).html( done ); jQuery( 'span.total' ).html( total ); jQuery( 'span.pending' ).html( data.pending ); db_start_migration( done, total ); } else { alert( "Migration completed." ); jQuery( "#rtMediaSyncing" ).hide(); } }, error: function () { alert( "<?php _e('Error During Migration, Please Refresh Page then try again', 'buddypress-media'); ?> " ); jQuery( "#submit" ).removeAttr( 'disabled' ); } } ); } else { alert( "Migration completed." ); jQuery( "#rtMediaSyncing" ).hide(); } } var db_done = <?php echo $done; ?> ; var db_total = <?php echo $total; ?> ; jQuery( document ).on( 'click', '#submit', function ( e ) { e.preventDefault(); db_start_migration( db_done, db_total ); jQuery( this ).attr( 'disabled', 'disabled' ); } ); </script> <hr/> <?php if (!(isset($rtmedia_error) && true === $rtmedia_error)) { ?> <input type="button" id="submit" value="<?php esc_attr_e('Start', 'buddypress-media'); ?> " class="button button-primary"/> <?php } ?> </div> <?php }
function update_db() { $update = new RTDBUpdate(false, RTMEDIA_PATH . 'index.php', RTMEDIA_PATH . 'app/schema/', true); /* Current Version. */ if (!defined('RTMEDIA_VERSION')) { define('RTMEDIA_VERSION', $update->db_version); } if ($update->check_upgrade()) { $update->do_upgrade(); } if (!$update->table_exists($update->genrate_table_name('rtm_media'))) { delete_site_option($update->get_db_version_option_name()); $update->install_db_version = '0'; $update->do_upgrade(); } }