add_field.inc

  1. cis7 sites/all/modules/ulmus/og/og_ui/includes/migrate/7000/add_field.inc
  2. cle7 sites/all/modules/ulmus/og/og_ui/includes/migrate/7000/add_field.inc
  3. ecd7 sites/all/modules/ulmus/og/og_ui/includes/migrate/7000/add_field.inc
  4. elmsmedia7 sites/all/modules/ulmus/og/og_ui/includes/migrate/7000/add_field.inc
  5. harmony7 sites/all/modules/ulmus/og/og_ui/includes/migrate/7000/add_field.inc
  6. icor7 sites/all/modules/ulmus/og/og_ui/includes/migrate/7000/add_field.inc
  7. meedjum_blog7 sites/all/modules/ulmus/og/og_ui/includes/migrate/7000/add_field.inc
  8. mooc7 sites/all/modules/ulmus/og/og_ui/includes/migrate/7000/add_field.inc

Add OG UI related fields to group node-types.

Classes

File

sites/all/modules/ulmus/og/og_ui/includes/migrate/7000/add_field.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Add OG UI related fields to group node-types.
  5. */
  6. class OgUiMigrateAddField extends MigrationBase {
  7. public function __construct() {
  8. parent::__construct();
  9. $this->description = t('Add OG UI related fields to group node-types.');
  10. $this->enabled = !$this->isComplete();
  11. foreach (node_type_get_names() as $bundle => $value) {
  12. // Dependent on a dynamic migration.
  13. $machine_name = 'OgMigrateGroup' . ucfirst($bundle);
  14. if (MigrationBase::getInstance($machine_name, 'OgMigrateGroup', array('bundle' => $bundle))) {
  15. $this->dependencies[] = $machine_name;
  16. }
  17. }
  18. }
  19. public function isComplete() {
  20. return !variable_get('og_ui_7000_add_field', FALSE);
  21. }
  22. /**
  23. * Add OG_DEFAULT_ACCESS_FIELD to group.
  24. */
  25. public function import() {
  26. $bundles = og_get_all_group_bundle();
  27. if (!empty($bundles['node'])) {
  28. foreach (array_keys($bundles['node']) as $bundle) {
  29. // Add the "Group roles and permissions" field to the bundle.
  30. og_create_field(OG_DEFAULT_ACCESS_FIELD, 'node', $bundle);
  31. }
  32. }
  33. // Delete the field that indicates we still need to add fields.
  34. variable_del('og_ui_7000_add_field');
  35. return MigrationBase::RESULT_COMPLETED;
  36. }
  37. }