migrate_ui.install 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @file
  4. * Install/update function for migrate_ui.
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function migrate_ui_install() {
  10. migrate_ui_set_weight();
  11. }
  12. /**
  13. * Implements hook_uninstall().
  14. */
  15. function migrate_ui_uninstall() {
  16. variable_del('migrate_import_method');
  17. variable_del('migrate_drush_path');
  18. variable_del('migrate_drush_mail');
  19. variable_del('migrate_drush_mail_subject');
  20. variable_del('migrate_drush_mail_body');
  21. }
  22. /**
  23. * Make sure we have a higher weight than node.
  24. */
  25. function migrate_ui_update_7201() {
  26. migrate_ui_set_weight();
  27. }
  28. /**
  29. * Sets the weight of migrate_ui higher than node, so Import links come after
  30. * "Add content" at admin/content.
  31. */
  32. function migrate_ui_set_weight() {
  33. $node_weight = db_select('system', 's')
  34. ->fields('s', array('weight'))
  35. ->condition('name', 'node')
  36. ->execute()
  37. ->fetchField();
  38. db_update('system')
  39. ->fields(array('weight' => $node_weight + 1))
  40. ->condition('name', 'migrate_ui')
  41. ->execute();
  42. }
  43. /**
  44. * If WordPress Migrate has background imports via drush enabled, copy the
  45. * configuration to the new general Migrate support.
  46. */
  47. function migrate_ui_update_7202() {
  48. $drush_command = variable_get('wordpress_migrate_drush', '');
  49. if ($drush_command) {
  50. variable_set('migrate_drush_path', $drush_command);
  51. // Consolidate these two variables into import method - 0 means immediate
  52. // only, 1 means drush only, 2 means offer both options.
  53. $import_method = variable_get('wordpress_migrate_import_method', 0);
  54. $force_drush = variable_get('wordpress_migrate_force_drush', FALSE);
  55. if (!$force_drush) {
  56. $import_method = 2;
  57. }
  58. variable_set('migrate_import_method', $import_method);
  59. variable_set('migrate_drush_mail',
  60. variable_get('wordpress_migrate_notification', 0));
  61. variable_set('migrate_drush_mail_subject',
  62. variable_get('wordpress_migrate_notification_subject', ''));
  63. variable_set('migrate_drush_mail_body',
  64. variable_get('wordpress_migrate_notification_body', ''));
  65. }
  66. }