Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

This works for version 5.x and 6.x modules.

Code Block
borderStylesolid
titlemodulename.installborderStylesolid
<?php

function modulename_uninstall() {
  // remove module system variables
  $module_name = 'modulename';

  $vars = db_query("select * from {variable} where name like '" . $module_name . "%'");
  while ($var = db_fetch_object($vars)) {
    variable_del($var->name);
  }
}

Renaming system variables when changing module name

Code Block
borderStylesolid
titlemodulename.installborderStylesolid
<?php

function newmodulename_install() {
  // rename module system variables
  $oldname = 'modulename';
  $newname = 'newmodulename';
  
  $vars = db_query("select * from {variable} where name like '" . $oldname . "%'");
  while ($var = db_fetch_object($vars)) {
    $newvar = str_replace($oldname,$newname,$var->name);

    variable_set($newvar, variable_get($var->name, NULL));
    variable_del($var->name);
  }
}