You are here

function system_settings_deploy_form_submit in Deploy - Content Staging 6

Same name and namespace in other branches
  1. 5 system_settings_deploy/system_settings_deploy.module \system_settings_deploy_form_submit()

Submit handler for systems settings forms that have deployment enabled.

1 string reference to 'system_settings_deploy_form_submit'
system_settings_deploy_form_alter in modules/system_settings_deploy/system_settings_deploy.module
Implementation of hook_form_alter().

File

modules/system_settings_deploy/system_settings_deploy.module, line 49
Deployment API which enables modules to deploy items between servers.

Code

function system_settings_deploy_form_submit($form, &$form_state) {
  $pid = $form_state['values']['deploy_plan'];

  // Remove the "deploy_plan" key from form_values before
  // we save the array, since it is stupid on the other side.
  if (array_key_exists("deploy_plan", $form_state['values'])) {
    unset($form_state['values']["deploy_plan"]);
  }

  // Serialize and save $form_values.
  $data = serialize($form_state['values']);
  $form_id = $form['form_id']['#value'];

  // if a deployment plan is submitted, and the settings don't already exist in that plan, then add these settings
  if ($pid != '0') {
    $result = db_query("SELECT iid FROM {deploy_plan_items} WHERE pid = %d AND description = '%s'", $pid, 'Settings: ' . $form_id);
    if (!db_result($result)) {
      deploy_add_to_plan($pid, 'system_settings', 'Settings: ' . $form['form_id']['#value'], $data, 0, DEPLOY_SYSTEM_SETTINGS_GROUP_WEIGHT);
    }
  }

  // if these settings already exist in existing plans,
  // then we need to update them. note that this the only thing in deployment that updates
  // on the fly as changes occur due to the difficulty of retrieving system setting
  // information on the fly at deploy_time. yes, if a new set of settings has just been added
  // above, this will rewrite the same data again. no harm, no foul.
  $result = db_query("SELECT iid FROM {deploy_plan_items} WHERE description = '%s'", 'Settings: ' . $form_id);
  while ($row = db_fetch_array($result)) {
    deploy_update_item($row['iid'], $data);
  }
}