Changeset 1979254
- Timestamp:
- 11/23/2018 07:54:13 AM (7 years ago)
- Location:
- dwqa-migration
- Files:
-
- 19 added
- 5 edited
-
tags/1.0.1 (added)
-
tags/1.0.1/Includes (added)
-
tags/1.0.1/Includes/Main.php (added)
-
tags/1.0.1/Libraries (added)
-
tags/1.0.1/Libraries/cdwqa-db.php (added)
-
tags/1.0.1/Migrations (added)
-
tags/1.0.1/Migrations/BBpress (added)
-
tags/1.0.1/Migrations/BBpress/BBpress.php (added)
-
tags/1.0.1/Migrations/SabaiDiscuss (added)
-
tags/1.0.1/Migrations/SabaiDiscuss/SabaiDiscuss.php (added)
-
tags/1.0.1/assets (added)
-
tags/1.0.1/assets/css (added)
-
tags/1.0.1/assets/css/admin-style.css (added)
-
tags/1.0.1/assets/js (added)
-
tags/1.0.1/assets/js/admin-script.js (added)
-
tags/1.0.1/converter.php (added)
-
tags/1.0.1/index.php (added)
-
tags/1.0.1/readme.txt (added)
-
trunk/Includes/Main.php (modified) (14 diffs)
-
trunk/Migrations/BBpress/BBpress.php (modified) (14 diffs)
-
trunk/Migrations/SabaiDiscuss/SabaiDiscuss.php (added)
-
trunk/assets/js/admin-script.js (modified) (2 diffs)
-
trunk/converter.php (modified) (1 diff)
-
trunk/readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dwqa-migration/trunk/Includes/Main.php
r1964869 r1979254 5 5 require_once CDWQA_DIR.'/Libraries/cdwqa-db.php'; 6 6 require_once CDWQA_DIR.'/Migrations/BBpress/BBpress.php'; 7 require_once CDWQA_DIR.'/Migrations/SabaiDiscuss/SabaiDiscuss.php'; 7 8 8 9 use CDWQA\Migrations\BBpress; 10 use CDWQA\Migrations\SabaiDiscuss; 9 11 10 12 … … 47 49 public function migration(){ 48 50 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'){ 51 54 // require_once CDWQA_ROOT_FILE.'/Migrations/BBpress/BBpress.php'; 52 55 53 56 switch ($_POST['migration_action']) { 54 57 case 'connect': 55 $db_info = $this->getDBInfo();58 56 59 $db = new \CDWQA_DB($db_info['db_host'], $db_info['db_user'], $db_info['db_password'], $db_info['db_name']); 57 60 if($db->checkConnect()){ … … 62 65 break; 63 66 case 'reset': 64 $db_info = $this->getDBInfo();65 67 $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']); 66 68 … … 75 77 break; 76 78 case 're-run': 77 $db_info = $this->getDBInfo();78 79 $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']); 79 80 … … 88 89 break; 89 90 case 'run': 90 $db_info = $this->getDBInfo();91 92 93 91 $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']); 94 92 … … 125 123 } 126 124 } 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 } 127 199 wp_die(); 128 200 } … … 134 206 global $wpdb; 135 207 208 $migration_from = isset($_POST['migration_from'])?$_POST['migration_from']:''; 136 209 $migration_type = isset($_POST['migration_type'])?$_POST['migration_type']:''; 137 210 $db_name = isset($_POST['db_name'])?$_POST['db_name']:''; … … 145 218 146 219 $db_info = array( 220 'migration_from' => $migration_from, 147 221 'migration_type' => $migration_type, 148 222 'db_name' => $db_name, … … 179 253 } 180 254 181 public function get BBpressProcessed(){182 $processed = get_option('cdwqa_ bbpress_processed', false);255 public function getProcessed(){ 256 $processed = get_option('cdwqa_processed', false); 183 257 return $processed?json_decode($processed, true):$processed; 184 258 } 185 259 186 public function get BBpressOffset(){187 $offset = get_option('cdwqa_ bbpress_remote_offset', false);260 public function getOffset(){ 261 $offset = get_option('cdwqa_remote_offset', false); 188 262 return $offset?json_decode($offset, true):$offset; 189 263 } 190 264 191 public function get BBpressCurrentAction(){192 $action = get_option('cdwqa_ bbpress_current_action', false);265 public function getCurrentAction(){ 266 $action = get_option('cdwqa_current_action', false); 193 267 return $action?json_decode($action, true):$action; 194 268 } 195 269 196 public function get BBpressTotal(){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 get BBpressCountText(){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; 203 277 } 204 278 … … 209 283 $db_info = $this->getDBInfo(); 210 284 211 $ bbpress_total = $this->getBBpressTotal();212 $ bbpress_count_text = $this->getBBpressCountText();213 $current_action = $this->get BBpressCurrentAction();214 $offset = $this->get BBpressOffset();215 $processed = $this->get BBpressProcessed();285 $total = $this->getTotal(); 286 $text = $this->getCountText(); 287 $current_action = $this->getCurrentAction(); 288 $offset = $this->getOffset(); 289 $processed = $this->getProcessed(); 216 290 217 291 $config = false; 218 if(isset($db_info[' db_name']) && $db_info['db_name']){292 if(isset($db_info['migration_type']) && $db_info['migration_type']){ 219 293 $config = true; 220 294 } … … 223 297 <div class="wrap"> 224 298 <div class="page-title"> 225 <h1> bbPress toDesignwall 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> 227 301 </div> 228 302 <div class="page-content"> … … 240 314 <table> 241 315 <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> 243 332 <td> 244 333 <label> … … 311 400 <div id="action-migration"> 312 401 <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 ): 315 404 ?> 316 405 <div class="process"> 317 406 <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> 319 408 <div class="per-wrap"> 320 409 <div class="per"> … … 357 446 <div>DW Q&A Migration Tool supports 2 migration database source types:</div> 358 447 <ul> 359 <li><span class="btn-style">Local</span> Migrate bbPress database to DW Q&A on entire database.</li>360 <li><span class="btn-style">Remote</span> Migrate bbPress database to DW Q&A from remote database.</li>448 <li><span class="btn-style">Local</span> Migrate bbPress or Sabai Discuss database to DW Q&A on entire database.</li> 449 <li><span class="btn-style">Remote</span> Migrate bbPress or Sabai Discussdatabase to DW Q&A from remote database.</li> 361 450 </ul> 362 451 </div> -
dwqa-migration/trunk/Migrations/BBpress/BBpress.php
r1964869 r1979254 80 80 $this->remote_total = 0; 81 81 $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); 87 87 } 88 88 … … 164 164 public function prepareData(){ 165 165 $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); 170 170 } 171 171 … … 190 190 if(is_array($this->processed)){ 191 191 $this->processed[] = $this->current_action; 192 $this->updateOption('cdwqa_ bbpress_processed', $this->processed);192 $this->updateOption('cdwqa_processed', $this->processed); 193 193 }else{ 194 194 $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); 201 201 202 202 return true; … … 230 230 'update_category' => 'Update Category', //update category data 231 231 'update_category_parent' => 'Update Category Tree', //update category tree 232 'update_tag' => 'Update Category Tree', //update tag data232 'update_tag' => 'Update Tag', //update tag data 233 233 'update_question_answer' => 'Update Question', //update question answer data 234 234 'update_attachment_file' => 'Update Attachment', //update attachment tree … … 243 243 private function increaseOffset(){ 244 244 $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 ); 246 246 } 247 247 248 248 public function runCountTotal(){ 249 249 $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()); 252 252 253 253 $this->nextAction(); … … 309 309 //init 310 310 $this->remote_total = $this->countTagsQuestion(); 311 $this->updateOption( 'cdwqa_ bbpress_remote_total', $this->remote_total );311 $this->updateOption( 'cdwqa_remote_total', $this->remote_total ); 312 312 } 313 313 if($this->remote_total < $this->remote_offset){ … … 432 432 //init 433 433 $this->remote_total = $this->countDWQAQuestions(); 434 $this->updateOption( 'cdwqa_ bbpress_remote_total', $this->remote_total );434 $this->updateOption( 'cdwqa_remote_total', $this->remote_total ); 435 435 } 436 436 if($this->remote_total < $this->remote_offset){ … … 535 535 536 536 $this->remote_total = $this->countDWQAChilds(); 537 $this->updateOption( 'cdwqa_ bbpress_remote_total', $this->remote_total );537 $this->updateOption( 'cdwqa_remote_total', $this->remote_total ); 538 538 } 539 539 if($this->remote_total < $this->remote_offset){ … … 627 627 628 628 $this->remote_total = $this->countDWQAParentAttachment(); 629 $this->updateOption( 'cdwqa_ bbpress_remote_total', $this->remote_total );629 $this->updateOption( 'cdwqa_remote_total', $this->remote_total ); 630 630 } 631 631 if($this->remote_total < $this->remote_offset){ … … 719 719 //init 720 720 $this->remote_total = $this->countBBpressTopicReply(); 721 $this->updateOption( 'cdwqa_ bbpress_remote_total', $this->remote_total );721 $this->updateOption( 'cdwqa_remote_total', $this->remote_total ); 722 722 } 723 723 if($this->remote_total < $this->remote_offset){ … … 1040 1040 //init 1041 1041 $this->remote_total = $this->countBBpressTag();; 1042 $this->updateOption( 'cdwqa_ bbpress_remote_total', $this->remote_total );1042 $this->updateOption( 'cdwqa_remote_total', $this->remote_total ); 1043 1043 } 1044 1044 if($this->remote_total < $this->remote_offset){ … … 1188 1188 //init 1189 1189 $this->remote_total = $this->countBBpressCategoryParent(); 1190 $this->updateOption( 'cdwqa_ bbpress_remote_total', $this->remote_total );1190 $this->updateOption( 'cdwqa_remote_total', $this->remote_total ); 1191 1191 } 1192 1192 if($this->remote_total < $this->remote_offset){ … … 1266 1266 //init 1267 1267 $this->remote_total = $this->countBBpressForums(); 1268 $this->updateOption( 'cdwqa_ bbpress_remote_total', $this->remote_total );1268 $this->updateOption( 'cdwqa_remote_total', $this->remote_total ); 1269 1269 } 1270 1270 … … 1456 1456 //init 1457 1457 $this->remote_total = $this->countBBpressUsers(); 1458 $this->updateOption( 'cdwqa_ bbpress_remote_total', $this->remote_total );1458 $this->updateOption( 'cdwqa_remote_total', $this->remote_total ); 1459 1459 } 1460 1460 -
dwqa-migration/trunk/assets/js/admin-script.js
r1964869 r1979254 143 143 144 144 $('#cdwqa_save').on('click', function(){ 145 var migration_from = $('#remote-migration input[name="migration_from"]:checked').val(); 145 146 var migration_type = $('#remote-migration input[name="migration_type"]:checked').val(); 146 147 var db_name = $('#db_name').val(); … … 160 161 action: 'cdwqa_save_db_info', 161 162 nonce: cdwqa.ajax_nonce, 163 migration_from: migration_from, 162 164 migration_type: migration_type, 163 165 db_name: db_name, -
dwqa-migration/trunk/converter.php
r1964869 r1979254 6 6 * Author URI: # 7 7 * Author Email: # 8 * Version: 1.0. 08 * Version: 1.0.1 9 9 * Text Domain: cdwqa 10 10 */ -
dwqa-migration/trunk/readme.txt
r1964869 r1979254 4 4 Requires at least: 3.0.1 5 5 Tested up to: 4.9.8 6 Stable tag: 1.0. 06 Stable tag: 1.0.1 7 7 License: GPLv3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 12 12 DW Q&A Migration is a free tool to migrate database of comunity/forum plugins to DW Question & Answer plugin like bbPress. 13 13 14 Note: The preview version supports bbPress only, more plugins: Sabai Discuss,Question2Answer will be supported in upcoming versions.14 Note: The preview version supports bbPress and Sabai Discuss, more plugins: Question2Answer will be supported in upcoming versions. 15 15 16 16 = Benefits & Features = … … 25 25 26 26 * BBPress 27 * Sabai Discuss 27 28 28 29 = Next Integration Plugins = 29 30 30 * Sabai Discuss31 31 * Question2Answer 32 32 … … 45 45 Migrate bbPress Attachments 46 46 47 48 Migrate Sabai Discuss Users to DWQA Users 49 Migrate Sabai Discuss Categories to DWQA Categories 50 Migrate Sabai Discuss Questions to DWQA Questions 51 Migrate Sabai Discuss Answers to DWQA Answers 52 47 53 == Installation == 48 54 … … 56 62 == Changelog == 57 63 58 = 1.0 = 64 = 1.0.1 = 65 66 * Migrate Sabai Discuss 67 68 = 1.0.0 = 59 69 60 70 * The first version of DWQA Migration
Note: See TracChangeset
for help on using the changeset viewer.