You are here

function groupmenu_uninstall in Group Menu 7

Implements hook_uninstall().

File

./groupmenu.install, line 46
Install, update and uninstall functions for the groupmenu module.

Code

function groupmenu_uninstall() {

  // List custom vars.
  $vars = array(
    'groupmenu_block_links',
    'groupmenu_max_menus_per_group',
    'groupmenu_show_nodetype',
    'groupmenu_create_by_default',
  );

  // List all group_menu related node type settings vars.
  $node_types = node_type_get_types();
  foreach ($node_types as $type) {
    $vars[] = 'groupmenu_enable_' . $type->type;
  }

  // Finally, delete all the vars we listed.
  foreach ($vars as $var) {
    variable_del($var);
  }

  // Delete custom menus.
  $result = db_select('group_menu', 'm')
    ->fields('m', array(
    'menu_name',
  ))
    ->execute();
  while ($record = $result
    ->fetchAssoc()) {
    if ($menu = menu_load($record['menu_name'])) {
      menu_delete($menu);
    }
  }
}