You are here

function views_bulk_operations_update_3 in Views Bulk Operations (VBO) 5

File

./views_bulk_operations.install, line 46

Code

function views_bulk_operations_update_3() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $entries = db_query("SELECT * FROM {vbo_settings}");
      $count = 0;
      while ($entry = db_fetch_object($entries)) {
        $new_ops = array();
        $old_ops = unserialize($entry->value);
        foreach ($old_ops as $op) {
          $key = md5($op['callback'] . $op['label']);
          $new_ops[$key] = $op;
        }
        db_query("UPDATE {vbo_settings} SET value = '%s' WHERE name = '%s'", serialize($new_ops), $entry->name);
        $count++;
      }
      break;
  }
  $ret[] = array(
    'success' => true,
    'query' => "Converted {$count} VBO settings.",
  );
  return $ret;
}