Plugin Directory

Changeset 1979254


Ignore:
Timestamp:
11/23/2018 07:54:13 AM (7 years ago)
Author:
designwall
Message:

release New Version 1.0.1

Location:
dwqa-migration
Files:
19 added
5 edited

Legend:

Unmodified
Added
Removed
  • dwqa-migration/trunk/Includes/Main.php

    r1964869 r1979254  
    55require_once CDWQA_DIR.'/Libraries/cdwqa-db.php';
    66require_once CDWQA_DIR.'/Migrations/BBpress/BBpress.php';
     7require_once CDWQA_DIR.'/Migrations/SabaiDiscuss/SabaiDiscuss.php';
    78
    89use CDWQA\Migrations\BBpress;
     10use CDWQA\Migrations\SabaiDiscuss;
    911
    1012
     
    4749    public function migration(){
    4850        check_ajax_referer('dwqa-migration-ajax', 'nonce');
    49 
    50         if(isset($_POST['migration']) && $_POST['migration']=='bbpress'){
     51        $db_info = $this->getDBInfo();
     52
     53        if(isset($db_info['migration_from']) && $db_info['migration_from']=='bbpress'){
    5154            // require_once CDWQA_ROOT_FILE.'/Migrations/BBpress/BBpress.php';
    5255
    5356            switch ($_POST['migration_action']) {
    5457                case 'connect':
    55                     $db_info = $this->getDBInfo();
     58                   
    5659                    $db = new \CDWQA_DB($db_info['db_host'], $db_info['db_user'], $db_info['db_password'], $db_info['db_name']);
    5760                    if($db->checkConnect()){
     
    6265                    break;
    6366                case 'reset':
    64                     $db_info = $this->getDBInfo();
    6567                    $current_db = new \CDWQA_DB($db_info['current_db_host'], $db_info['current_db_user'], $db_info['current_db_password'], $db_info['current_db_name'], $db_info['current_db_prefix'], $db_info['current_db_blog_id']);
    6668
     
    7577                    break;
    7678                case 're-run':
    77                     $db_info = $this->getDBInfo();
    7879                    $current_db = new \CDWQA_DB($db_info['current_db_host'], $db_info['current_db_user'], $db_info['current_db_password'], $db_info['current_db_name'], $db_info['current_db_prefix'], $db_info['current_db_blog_id']);
    7980
     
    8889                    break;
    8990                case 'run':
    90                     $db_info = $this->getDBInfo();
    91                    
    92 
    9391                    $current_db = new \CDWQA_DB($db_info['current_db_host'], $db_info['current_db_user'], $db_info['current_db_password'], $db_info['current_db_name'], $db_info['current_db_prefix'], $db_info['current_db_blog_id'], '', $db_info['current_upload_dir']);
    9492
     
    125123            }
    126124        }
     125
     126        if(isset($db_info['migration_from']) && $db_info['migration_from']=='sabai-discuss'){
     127            // require_once CDWQA_ROOT_FILE.'/Migrations/BBpress/BBpress.php';
     128
     129            switch ($_POST['migration_action']) {
     130                case 'connect':
     131                   
     132                    $db = new \CDWQA_DB($db_info['db_host'], $db_info['db_user'], $db_info['db_password'], $db_info['db_name']);
     133                    if($db->checkConnect()){
     134                        wp_send_json_success();
     135                    }else{
     136                        wp_send_json_error();
     137                    }
     138                    break;
     139                case 'reset':
     140                    $current_db = new \CDWQA_DB($db_info['current_db_host'], $db_info['current_db_user'], $db_info['current_db_password'], $db_info['current_db_name'], $db_info['current_db_prefix'], $db_info['current_db_blog_id']);
     141
     142                    $sabai = new SabaiDiscuss\CDWQA_Sabai_Discuss_Migration();
     143
     144                    $sabai->setCurrentDB($current_db);
     145                    $sabai->init();
     146                    $sabai->resetDefault();
     147
     148                    $result = $sabai->returnStatus();
     149                    wp_send_json_success($result);
     150                    break;
     151                case 're-run':
     152                    $current_db = new \CDWQA_DB($db_info['current_db_host'], $db_info['current_db_user'], $db_info['current_db_password'], $db_info['current_db_name'], $db_info['current_db_prefix'], $db_info['current_db_blog_id']);
     153
     154                    $sabai = new SabaiDiscuss\CDWQA_Sabai_Discuss_Migration();
     155
     156                    $sabai->setCurrentDB($current_db);
     157                    $sabai->init();
     158                    $sabai->resetDefault();
     159
     160                    $result = $sabai->returnStatus();
     161                    wp_send_json_success($result);
     162                    break;
     163                case 'run':
     164                   
     165                    $current_db = new \CDWQA_DB($db_info['current_db_host'], $db_info['current_db_user'], $db_info['current_db_password'], $db_info['current_db_name'], $db_info['current_db_prefix'], $db_info['current_db_blog_id'], '', $db_info['current_upload_dir']);
     166
     167
     168                    $sabai = new SabaiDiscuss\CDWQA_Sabai_Discuss_Migration();
     169
     170                    $sabai->setCurrentDB($current_db);
     171
     172                    if($db_info['migration_type']=='local'){
     173                        $sabai->setLocal(true);
     174                        $sabai->setRemoteDB($current_db);
     175                    }else{
     176                        $remote_db = new \CDWQA_DB($db_info['db_host'], $db_info['db_user'], $db_info['db_password'], $db_info['db_name'], $db_info['db_prefix'], $db_info['db_blog_id'], '', $db_info['upload_dir'] );
     177                        if(!$remote_db->checkConnect()){
     178                            wp_send_json_error();
     179                        }
     180                       
     181                        $sabai->setRemoteDB($remote_db);
     182
     183                    }
     184
     185                    $sabai->setLimit($db_info['db_limit']);
     186                    $sabai->init();
     187                   
     188                    $sabai->run();
     189
     190                    $result = $sabai->returnStatus();
     191                    wp_send_json_success($result);
     192                    break;
     193               
     194                default:
     195                    # code...
     196                    break;
     197            }
     198        }
    127199        wp_die();
    128200    }
     
    134206        global $wpdb;
    135207
     208        $migration_from = isset($_POST['migration_from'])?$_POST['migration_from']:'';
    136209        $migration_type = isset($_POST['migration_type'])?$_POST['migration_type']:'';
    137210        $db_name = isset($_POST['db_name'])?$_POST['db_name']:'';
     
    145218
    146219        $db_info = array(
     220            'migration_from' => $migration_from,
    147221            'migration_type' => $migration_type,
    148222            'db_name' => $db_name,
     
    179253    }
    180254
    181     public function getBBpressProcessed(){
    182         $processed =  get_option('cdwqa_bbpress_processed', false);
     255    public function getProcessed(){
     256        $processed =  get_option('cdwqa_processed', false);
    183257        return $processed?json_decode($processed, true):$processed;
    184258    }
    185259
    186     public function getBBpressOffset(){
    187         $offset =  get_option('cdwqa_bbpress_remote_offset', false);
     260    public function getOffset(){
     261        $offset =  get_option('cdwqa_remote_offset', false);
    188262        return $offset?json_decode($offset, true):$offset;
    189263    }
    190264
    191     public function getBBpressCurrentAction(){
    192         $action =  get_option('cdwqa_bbpress_current_action', false);
     265    public function getCurrentAction(){
     266        $action =  get_option('cdwqa_current_action', false);
    193267        return $action?json_decode($action, true):$action;
    194268    }
    195269
    196     public function getBBpressTotal(){
    197         $bbpress_total = get_option('cdwqa_bbpress_count_total', false);
    198         return $bbpress_total?json_decode($bbpress_total, true):$bbpress_total;
    199     }
    200     public function getBBpressCountText(){
    201         $bbpress_text = get_option('cdwqa_bbpress_count_text', false);
    202         return $bbpress_text?json_decode($bbpress_text, true):$bbpress_text;
     270    public function getTotal(){
     271        $total = get_option('cdwqa_count_total', false);
     272        return $total?json_decode($total, true):$total;
     273    }
     274    public function getCountText(){
     275        $text = get_option('cdwqa_count_text', false);
     276        return $text?json_decode($text, true):$text;
    203277    }
    204278
     
    209283        $db_info = $this->getDBInfo();
    210284
    211         $bbpress_total = $this->getBBpressTotal();
    212         $bbpress_count_text = $this->getBBpressCountText();
    213         $current_action = $this->getBBpressCurrentAction();
    214         $offset = $this->getBBpressOffset();
    215         $processed = $this->getBBpressProcessed();
     285        $total = $this->getTotal();
     286        $text = $this->getCountText();
     287        $current_action = $this->getCurrentAction();
     288        $offset = $this->getOffset();
     289        $processed = $this->getProcessed();
    216290
    217291        $config = false;
    218         if(isset($db_info['db_name']) && $db_info['db_name']){
     292        if(isset($db_info['migration_type']) && $db_info['migration_type']){
    219293            $config = true;
    220294        }
     
    223297        <div class="wrap">
    224298            <div class="page-title">
    225                 <h1>bbPress to Designwall Question and Answer Migration Tool:</h1>
    226                 <p class="description">DW Q&A Migration is a Free tool to migrate <strong>bbPress</strong> database to <strong>Designwall Question and Answer</strong> (DW Q&A).</p>
     299                <h1>Designwall Question and Answer Migration Tool:</h1>
     300                <p class="description">DW Q&A Migration is a Free tool to migrate <strong>bbPress</strong> or <strong>Sabai Discuss</strong> database to <strong>Designwall Question and Answer</strong> (DW Q&A).</p>
    227301            </div>
    228302            <div class="page-content">
     
    240314                                        <table>
    241315                                            <tr>
    242                                                 <th>Data From:</th>
     316                                                <th>Migrate From:</th>
     317                                                <td>
     318                                                    <label>
     319                                                        <input type="radio" name="migration_from" value="bbpress" <?php echo isset($db_info['migration_from']) && $db_info['migration_from']=='bbpress'?'checked':'';?>>
     320                                                        bbPress
     321                                                    </label>
     322                                                    <label>
     323                                                        <input type="radio" name="migration_from" value="sabai-discuss" <?php echo isset($db_info['migration_from']) && $db_info['migration_from']=='sabai-discuss'?'checked':'';?>>
     324                                                        Sabai Discuss
     325                                                    </label>
     326                                                   
     327                                                   
     328                                                </td>
     329                                            </tr>
     330                                            <tr>
     331                                                <th>Database Source:</th>
    243332                                                <td>
    244333                                                    <label>
     
    311400                                <div id="action-migration">
    312401                                    <div class="process-wrap">
    313                                         <?php if($bbpress_total):
    314                                             foreach($bbpress_total as $key => $value ):
     402                                        <?php if($total):
     403                                            foreach($total as $key => $value ):
    315404                                                ?>
    316405                                            <div class="process">
    317406                                                <div class="processed">
    318                                                     <div class="text"><?php echo $bbpress_count_text[$value['action']];?>   </div>
     407                                                    <div class="text"><?php echo $text[$value['action']];?> </div>
    319408                                                    <div class="per-wrap">
    320409                                                        <div class="per">
     
    357446                            <div>DW Q&A Migration Tool supports 2 migration database source types:</div>
    358447                            <ul>
    359                                 <li><span class="btn-style">Local</span> Migrate bbPress database to DW Q&amp;A on entire database.</li>
    360                                 <li><span class="btn-style">Remote</span> Migrate bbPress database to DW Q&amp;A from remote database.</li>
     448                                <li><span class="btn-style">Local</span> Migrate bbPress or Sabai Discuss database to DW Q&amp;A on entire database.</li>
     449                                <li><span class="btn-style">Remote</span> Migrate bbPress or Sabai Discussdatabase to DW Q&amp;A from remote database.</li>
    361450                            </ul>
    362451                        </div>
  • dwqa-migration/trunk/Migrations/BBpress/BBpress.php

    r1964869 r1979254  
    8080        $this->remote_total = 0;
    8181        $this->current_action = reset($this->action_queue);
    82         $this->updateOption('cdwqa_bbpress_remote_offset', $this->remote_offset);
    83         $this->updateOption('cdwqa_bbpress_remote_total', $this->remote_total);
    84         $this->updateOption('cdwqa_bbpress_current_action', $this->current_action);
    85         $this->updateOption('cdwqa_bbpress_processed', false);
    86         $this->updateOption('cdwqa_bbpress_count_total', false);
     82        $this->updateOption('cdwqa_remote_offset', $this->remote_offset);
     83        $this->updateOption('cdwqa_remote_total', $this->remote_total);
     84        $this->updateOption('cdwqa_current_action', $this->current_action);
     85        $this->updateOption('cdwqa_processed', false);
     86        $this->updateOption('cdwqa_count_total', false);
    8787    }
    8888
     
    164164    public function prepareData(){
    165165        $this->action_queue = $this->getActionQueue();
    166         $this->remote_offset = $this->getOption('cdwqa_bbpress_remote_offset', 0);
    167         $this->remote_total = $this->getOption('cdwqa_bbpress_remote_total', 0);
    168         $this->current_action = $this->getOption('cdwqa_bbpress_current_action', reset($this->action_queue));
    169         $this->processed = $this->getOption('cdwqa_bbpress_processed', false);
     166        $this->remote_offset = $this->getOption('cdwqa_remote_offset', 0);
     167        $this->remote_total = $this->getOption('cdwqa_remote_total', 0);
     168        $this->current_action = $this->getOption('cdwqa_current_action', reset($this->action_queue));
     169        $this->processed = $this->getOption('cdwqa_processed', false);
    170170    }
    171171
     
    190190        if(is_array($this->processed)){
    191191            $this->processed[] = $this->current_action;
    192             $this->updateOption('cdwqa_bbpress_processed', $this->processed);
     192            $this->updateOption('cdwqa_processed', $this->processed);
    193193        }else{
    194194            $this->processed = array($this->current_action);
    195             $this->updateOption('cdwqa_bbpress_processed', $this->processed);
    196         }
    197 
    198         $this->updateOption('cdwqa_bbpress_remote_offset', 0);
    199         $this->updateOption('cdwqa_bbpress_remote_total', 0);
    200         $this->updateOption('cdwqa_bbpress_current_action', $next_action);
     195            $this->updateOption('cdwqa_processed', $this->processed);
     196        }
     197
     198        $this->updateOption('cdwqa_remote_offset', 0);
     199        $this->updateOption('cdwqa_remote_total', 0);
     200        $this->updateOption('cdwqa_current_action', $next_action);
    201201       
    202202        return true;
     
    230230            'update_category' => 'Update Category', //update category data
    231231            'update_category_parent' => 'Update Category Tree', //update category tree
    232             'update_tag' => 'Update Category Tree', //update tag data
     232            'update_tag' => 'Update Tag',   //update tag data
    233233            'update_question_answer' => 'Update Question',  //update question answer data
    234234            'update_attachment_file' => 'Update Attachment',    //update attachment tree
     
    243243    private function increaseOffset(){
    244244        $this->remote_offset =  $this->remote_offset + $this->limit;
    245         $this->updateOption( 'cdwqa_bbpress_remote_offset', $this->remote_offset );
     245        $this->updateOption( 'cdwqa_remote_offset', $this->remote_offset );
    246246    }
    247247
    248248    public function runCountTotal(){
    249249        $this->count = $this->countTotal();
    250         $this->updateOption('cdwqa_bbpress_count_total', $this->count);
    251         $this->updateOption('cdwqa_bbpress_count_text', $this->countText());
     250        $this->updateOption('cdwqa_count_total', $this->count);
     251        $this->updateOption('cdwqa_count_text', $this->countText());
    252252       
    253253        $this->nextAction();
     
    309309            //init
    310310            $this->remote_total = $this->countTagsQuestion();
    311             $this->updateOption( 'cdwqa_bbpress_remote_total', $this->remote_total );
     311            $this->updateOption( 'cdwqa_remote_total', $this->remote_total );
    312312        }
    313313        if($this->remote_total < $this->remote_offset){
     
    432432            //init
    433433            $this->remote_total = $this->countDWQAQuestions();
    434             $this->updateOption( 'cdwqa_bbpress_remote_total', $this->remote_total );
     434            $this->updateOption( 'cdwqa_remote_total', $this->remote_total );
    435435        }
    436436        if($this->remote_total < $this->remote_offset){
     
    535535           
    536536            $this->remote_total = $this->countDWQAChilds();
    537             $this->updateOption( 'cdwqa_bbpress_remote_total', $this->remote_total );
     537            $this->updateOption( 'cdwqa_remote_total', $this->remote_total );
    538538        }
    539539        if($this->remote_total < $this->remote_offset){
     
    627627           
    628628            $this->remote_total = $this->countDWQAParentAttachment();
    629             $this->updateOption( 'cdwqa_bbpress_remote_total', $this->remote_total );
     629            $this->updateOption( 'cdwqa_remote_total', $this->remote_total );
    630630        }
    631631        if($this->remote_total < $this->remote_offset){
     
    719719            //init
    720720            $this->remote_total = $this->countBBpressTopicReply();
    721             $this->updateOption( 'cdwqa_bbpress_remote_total', $this->remote_total );
     721            $this->updateOption( 'cdwqa_remote_total', $this->remote_total );
    722722        }
    723723        if($this->remote_total < $this->remote_offset){
     
    10401040            //init
    10411041            $this->remote_total = $this->countBBpressTag();;
    1042             $this->updateOption( 'cdwqa_bbpress_remote_total', $this->remote_total );
     1042            $this->updateOption( 'cdwqa_remote_total', $this->remote_total );
    10431043        }
    10441044        if($this->remote_total < $this->remote_offset){
     
    11881188            //init
    11891189            $this->remote_total = $this->countBBpressCategoryParent();
    1190             $this->updateOption( 'cdwqa_bbpress_remote_total', $this->remote_total );
     1190            $this->updateOption( 'cdwqa_remote_total', $this->remote_total );
    11911191        }
    11921192        if($this->remote_total < $this->remote_offset){
     
    12661266            //init
    12671267            $this->remote_total = $this->countBBpressForums();
    1268             $this->updateOption( 'cdwqa_bbpress_remote_total', $this->remote_total );
     1268            $this->updateOption( 'cdwqa_remote_total', $this->remote_total );
    12691269        }
    12701270
     
    14561456            //init
    14571457            $this->remote_total = $this->countBBpressUsers();
    1458             $this->updateOption( 'cdwqa_bbpress_remote_total', $this->remote_total );
     1458            $this->updateOption( 'cdwqa_remote_total', $this->remote_total );
    14591459        }
    14601460
  • dwqa-migration/trunk/assets/js/admin-script.js

    r1964869 r1979254  
    143143
    144144    $('#cdwqa_save').on('click', function(){
     145        var migration_from = $('#remote-migration input[name="migration_from"]:checked').val();
    145146        var migration_type = $('#remote-migration input[name="migration_type"]:checked').val();
    146147        var db_name = $('#db_name').val();
     
    160161                    action: 'cdwqa_save_db_info',
    161162                    nonce: cdwqa.ajax_nonce,
     163                    migration_from: migration_from,
    162164                    migration_type: migration_type,
    163165                    db_name: db_name,
  • dwqa-migration/trunk/converter.php

    r1964869 r1979254  
    66 *  Author URI: #
    77 *  Author Email: #
    8  *  Version: 1.0.0
     8 *  Version: 1.0.1
    99 *  Text Domain: cdwqa
    1010 */
  • dwqa-migration/trunk/readme.txt

    r1964869 r1979254  
    44Requires at least: 3.0.1
    55Tested up to: 4.9.8
    6 Stable tag: 1.0.0
     6Stable tag: 1.0.1
    77License: GPLv3
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    1212DW Q&A Migration is a free tool to migrate database of comunity/forum plugins to DW Question & Answer plugin like bbPress.
    1313
    14 Note: The preview version supports bbPress only, more plugins: Sabai Discuss, Question2Answer will be supported in upcoming versions.
     14Note: The preview version supports bbPress and Sabai Discuss, more plugins: Question2Answer will be supported in upcoming versions.
    1515
    1616= Benefits & Features =
     
    2525
    2626* BBPress
     27* Sabai Discuss
    2728
    2829= Next Integration Plugins =
    2930
    30 * Sabai Discuss
    3131* Question2Answer
    3232
     
    4545Migrate bbPress Attachments
    4646
     47
     48Migrate Sabai Discuss Users to DWQA Users
     49Migrate Sabai Discuss Categories to DWQA Categories
     50Migrate Sabai Discuss Questions to DWQA Questions
     51Migrate Sabai Discuss Answers to DWQA Answers
     52
    4753== Installation ==
    4854
     
    5662== Changelog ==
    5763
    58 = 1.0 =
     64= 1.0.1 =
     65
     66* Migrate Sabai Discuss
     67
     68= 1.0.0 =
    5969
    6070* The first version of DWQA Migration
Note: See TracChangeset for help on using the changeset viewer.