You are here

function defaultcontent_remove_default_content in Default Content 7.2

Same name and namespace in other branches
  1. 7 defaultcontent.module \defaultcontent_remove_default_content()
1 call to defaultcontent_remove_default_content()
defaultcontent_modules_disabled in ./defaultcontent.module
Implements hook_modules_disabled().

File

./defaultcontent.module, line 572
Module file for the Default content module which allow export and import of default content in a Drupal site.

Code

function defaultcontent_remove_default_content($module_name) {
  module_load_include('inc', $module_name, $module_name . '.features.content');
  $components = module_invoke($module_name, 'content_defaults');
  if (!empty($components)) {
    usort($components, 'defaultcontent_import_sort');
    foreach (array_reverse($components) as $component) {
      if ($nid = defaultcontent_get_default($component->machine_name)) {
        $node = node_load($nid, NULL, TRUE);
        $node = defaultcontent_export_node_process($node);

        //check if the node has change before we blow it away

        //and reimport

        //For the moment we are going to remove it regardless of its overriden status
        if (TRUE || $node == $component) {

          //we have to reset this cache or the node goes not get found by node_delete
          entity_get_controller('node')
            ->resetCache();
          node_delete($nid);
          defaultcontent_set_default($component->machine_name, FALSE);
        }
      }
    }
  }
  return TRUE;
}