You are here

function advpoll_update_2 in Advanced Poll 5

Same name and namespace in other branches
  1. 6 advpoll.install \advpoll_update_2()
  2. 6.2 advpoll.install \advpoll_update_2()

Migrate old global settings to new per-content-type settings.

File

./advpoll.install, line 136

Code

function advpoll_update_2() {
  $ret = array();
  $variables = array();
  $variables[] = array(
    'name' => 'advpoll_electoral_list',
    'old_name' => 'advpoll_default_electoral_list',
  );
  $variables[] = array(
    'name' => 'advpoll_view_results',
    'old_name' => 'advpoll_view_results',
  );
  $types = node_get_types();
  foreach ($variables as $variable) {
    if (!is_null($value = variable_get($variable['old_name'], NULL))) {
      foreach ($types as $type) {
        if ($type->module == 'advpoll') {
          variable_set($variable['name'] . '_' . $type->type, $value);
        }
      }
    }
    variable_del($variable['old_name']);
  }
  return $ret;
}