You are here

function flag_update_6001 in Flag 6

Same name and namespace in other branches
  1. 6.2 flag.install \flag_update_6001()

Move flag messages and link titles into the options array.

File

./flag.install, line 373
Flag module install/schema/update hooks.

Code

function flag_update_6001() {
  $ret = array();
  if (_flag_column_exists('flags', 'flag_short')) {
    $result = db_query("SELECT * FROM {flags}");
    while ($flag = db_fetch_object($result)) {
      $options = unserialize($flag->options);
      $options['flag_short'] = $flag->flag_short;
      $options['flag_long'] = $flag->flag_long;
      $options['flag_message'] = $flag->flag_message;
      $options['unflag_short'] = $flag->unflag_short;
      $options['unflag_long'] = $flag->unflag_long;
      $options['unflag_message'] = $flag->unflag_message;
      db_query("UPDATE {flags} SET options = '%s' WHERE fid = %d", serialize($options), $flag->fid);
    }
    db_drop_field($ret, 'flags', 'flag_short');
    db_drop_field($ret, 'flags', 'flag_long');
    db_drop_field($ret, 'flags', 'flag_message');
    db_drop_field($ret, 'flags', 'unflag_short');
    db_drop_field($ret, 'flags', 'unflag_long');
    db_drop_field($ret, 'flags', 'unflag_message');
  }
  return $ret;
}