You are here

function spaces_ui_feature_form_submit in Spaces 5.2

Submit handler for spaces context_ui form alterations.

File

./spaces_ui.module, line 194

Code

function spaces_ui_feature_form_submit($form_id, $form_values) {
  $feature = $form_values['value'];
  $settings = array();
  $settings['label'] = $form_values['feature']['label'];
  $settings['description'] = $form_values['feature']['description'];

  // Types
  if ($form_values['feature']['types'] == 0) {
    $settings['types'] = array();
  }
  else {
    $settings['types'] = array(
      $form_values['feature']['types'],
    );
  }

  // Menu
  $settings['menu'] = array();
  foreach ($form_values['feature']['menu'] as $item) {
    if (!empty($item['title']) && !empty($item['path'])) {
      $settings['menu'][$item['path']] = array(
        'title' => $item['title'],
      );
    }
  }
  ksort($settings['menu']);
  db_query('DELETE FROM {spaces_features_ui} WHERE feature = "%s"', $feature);
  db_query('INSERT INTO {spaces_features_ui} (feature, value) VALUES ("%s", "%s")', $feature, serialize($settings));
}