| 1 |
<?php |
<?php |
| 2 |
// $Id: drupalvb.admin-pages.inc,v 1.1.2.10.2.1 2009/05/29 10:22:50 sun Exp $ |
// $Id: drupalvb.admin-pages.inc,v 1.1.2.10.2.2 2009/06/05 15:03:20 sun Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 294 |
$form['action']['action'] = array( |
$form['action']['action'] = array( |
| 295 |
'#type' => 'value', |
'#type' => 'value', |
| 296 |
); |
); |
|
$forum_exportable = (module_exists('forum') && module_exists('batch')); |
|
| 297 |
$form['action']['forum'] = array( |
$form['action']['forum'] = array( |
| 298 |
'#type' => 'radio', |
'#type' => 'radio', |
| 299 |
'#name' => 'action', |
'#name' => 'action', |
| 300 |
'#return_value' => 'forum', |
'#return_value' => 'forum', |
| 301 |
'#title' => t('Export Drupal forum to vBulletin'), |
'#title' => t('Export Drupal forum to vBulletin'), |
| 302 |
'#disabled' => !$forum_exportable, |
'#disabled' => !module_exists('forum'), |
| 303 |
'#description' => t('Exports the complete Drupal forum to vBulletin. Unlike the user export below, it will copy only users which have posted in the past. To make all users available in vBulletin simply run the user export before or afterwards.'), |
'#description' => t('Exports the complete Drupal forum to vBulletin. Unlike the user export below, it will copy only users which have posted in the past. To make all users available in vBulletin simply run the user export before or afterwards.'), |
| 304 |
); |
); |
|
if (!$forum_exportable && module_exists('forum')) { |
|
|
$form['action']['forum']['#description'] .= '<br />' . t('<a href="@batchapi-url">Batch API</a> module is required for exporting data.', array('@batchapi' => url('http://drupal.org/project/batchapi'))); |
|
|
} |
|
| 305 |
$form['action']['users'] = array( |
$form['action']['users'] = array( |
| 306 |
'#type' => 'radio', |
'#type' => 'radio', |
| 307 |
'#name' => 'action', |
'#name' => 'action', |
| 309 |
'#title' => t('Export Drupal users to vBulletin'), |
'#title' => t('Export Drupal users to vBulletin'), |
| 310 |
'#description' => t('Exports the complete Drupal user base to vBulletin.<br /><strong>Warning:</strong> This export relies on usernames. If identical usernames exist in both systems, the user vBulletin account will be overwritten with data from Drupal.'), |
'#description' => t('Exports the complete Drupal user base to vBulletin.<br /><strong>Warning:</strong> This export relies on usernames. If identical usernames exist in both systems, the user vBulletin account will be overwritten with data from Drupal.'), |
| 311 |
); |
); |
| 312 |
|
$form['action']['privatemsg'] = array( |
| 313 |
|
'#type' => 'radio', |
| 314 |
|
'#name' => 'action', |
| 315 |
|
'#return_value' => 'privatemsg', |
| 316 |
|
'#title' => t('Export Drupal privatemsg counts to vBulletin'), |
| 317 |
|
'#disabled' => !module_exists('privatemsg'), |
| 318 |
|
'#description' => t('Updates vBulletin user private message statistics with counts from privatemsg module.'), |
| 319 |
|
); |
| 320 |
|
if (!module_exists('batch')) { |
| 321 |
|
$form['action']['#description'] = t('<a href="@batchapi-url">Batch API</a> module is required for exporting data.', array('@batchapi' => url('http://drupal.org/project/batchapi'))); |
| 322 |
|
foreach (element_children($form['action']) as $element) { |
| 323 |
|
$form['action'][$element]['#disabled'] = TRUE; |
| 324 |
|
} |
| 325 |
|
} |
| 326 |
|
|
| 327 |
$form[] = array( |
$form[] = array( |
| 328 |
'#type' => 'item', |
'#type' => 'item', |
| 329 |
'#title' => t('Advanced options'), |
'#title' => t('Advanced options'), |
| 344 |
* Form submit handler for export actions form. |
* Form submit handler for export actions form. |
| 345 |
*/ |
*/ |
| 346 |
function drupalvb_settings_export_submit($form_id, $form_values) { |
function drupalvb_settings_export_submit($form_id, $form_values) { |
| 347 |
if ($form_values['action']) { |
if (!$form_values['action']) { |
| 348 |
drupal_goto('admin/settings/drupalvb/export/confirm/' . $form_values['action'] . '/' . $form_values['clean']); |
drupal_set_message(t('Please select an export option.'), 'error'); |
| 349 |
|
return; |
| 350 |
} |
} |
| 351 |
drupal_set_message(t('Please select an export option.'), 'error'); |
return 'admin/settings/drupalvb/export/confirm/' . $form_values['action'] . '/' . $form_values['clean']; |
| 352 |
} |
} |
| 353 |
|
|
| 354 |
/** |
/** |
| 444 |
); |
); |
| 445 |
$result = db_query("SELECT u.uid |
$result = db_query("SELECT u.uid |
| 446 |
FROM {users} u |
FROM {users} u |
| 447 |
LEFT JOIN {drupalvb_users} d ON u.uid = d.drupal_id |
LEFT JOIN {drupalvb_map} m ON m.type = 'users' AND u.uid = m.drupal_id |
| 448 |
WHERE u.uid > 0 AND d.vb_id IS NULL |
WHERE u.uid > 0 AND m.vb_id IS NULL |
| 449 |
ORDER BY u.uid ASC"); |
ORDER BY u.uid ASC"); |
| 450 |
while ($user = db_fetch_array($result)) { |
while ($user = db_fetch_array($result)) { |
| 451 |
$batch['operations'][] = array('drupalvb_export_user', array($user['uid'])); |
$batch['operations'][] = array('drupalvb_export_user', array($user['uid'])); |
| 452 |
} |
} |
| 453 |
batch_set($batch); |
batch_set($batch); |
| 454 |
break; |
break; |
| 455 |
|
|
| 456 |
|
case 'privatemsg': |
| 457 |
|
// Initialize batch. |
| 458 |
|
$batch = array( |
| 459 |
|
'title' => t('Exporting privatemsg counts'), |
| 460 |
|
'operations' => array(), |
| 461 |
|
'finished' => 'drupalvb_export_finished', |
| 462 |
|
'file' => $path . '/drupalvb.batch.inc', |
| 463 |
|
); |
| 464 |
|
batch_set($batch); |
| 465 |
|
|
| 466 |
|
// Reset pm counters. |
| 467 |
|
drupalvb_db_query("UPDATE {user} SET pmtotal = 0, pmunread = 0"); |
| 468 |
|
|
| 469 |
|
// Export privatemsg counts (progressive). |
| 470 |
|
$batch = array( |
| 471 |
|
'title' => t('Exporting privatemsg counts'), |
| 472 |
|
'operations' => array(), |
| 473 |
|
'file' => $path . '/drupalvb.batch.inc', |
| 474 |
|
); |
| 475 |
|
$result = db_query("SELECT recipient, COUNT(*) AS pmtotal, SUM(IF(newmsg = 1, 1, 0)) AS pmunread FROM {privatemsg} WHERE recipient_del = 0 GROUP BY recipient"); |
| 476 |
|
while ($user = db_fetch_array($result)) { |
| 477 |
|
$batch['operations'][] = array('drupalvb_export_privatemsg', array($user['recipient'], $user['pmtotal'], $user['pmunread'])); |
| 478 |
|
} |
| 479 |
|
batch_set($batch); |
| 480 |
|
break; |
| 481 |
} |
} |
| 482 |
|
|
| 483 |
batch_process('admin/settings/drupalvb/export'); |
batch_process('admin/settings/drupalvb/export'); |