You are here

function workflow_update_5200 in Workflow 6

Same name and namespace in other branches
  1. 5.2 workflow.install \workflow_update_5200()
  2. 6.2 workflow.install \workflow_update_5200()

File

./workflow.install, line 274

Code

function workflow_update_5200() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
    case 'pgsql':

      // Move workflow action assignments to the actions_assignments table.
      if (module_exists('actions')) {
        $result = db_query("SELECT * FROM {workflow_actions}");
        if ($result) {
          $success = FALSE;
          while ($data = db_fetch_object($result)) {
            $success = db_query("INSERT INTO {actions_assignments} (hook, op, aid, weight) VALUES ('%s', '%s', '%s', %d)", 'workflow', 'workflow-' . $data->tid, $data->aid, $data->weight);
          }
        }
        else {

          // workflow_actions had no records; it can be safely dropped.
          $success = TRUE;
        }

        // The workflow_actions table is no longer needed.
        if ($success) {
          $ret[] = update_sql("DROP TABLE {workflow_actions}");
        }
      }
  }
  return $ret;
}