You are here

function spaces_features_labels_submit in Spaces 5

Submit handler for the menu customization form.

File

./spaces_admin.inc, line 291

Code

function spaces_features_labels_submit($form_id, $form_values) {
  if ($form_values['op'] == t('Save')) {
    $labels = array();
    $weights = array();
    foreach (spaces_features($form_values['nid']) as $feature => $dummy) {
      if (is_array($form_values[$feature])) {
        foreach ($form_values[$feature] as $path => $item) {
          if ($label = $item['label']) {

            // check for empty strings
            $label = trim($label);
            if (!empty($label)) {
              $labels[$path] = $label;
            }
          }
          if ($weight = $item['weight']) {
            $weights[$path] = $weight;
          }
        }
      }
    }
    db_query("REPLACE INTO {spaces_features_custom} VALUES(%d, '%s', '%s')", $form_values['nid'], serialize($labels), serialize($weights));
    drupal_set_message(t('Feature lables have been saved.'));
  }
  else {
    if ($form_values['op'] == t('Reset')) {
      db_query("DELETE FROM {spaces_features_custom} WHERE gid = %d", $form_values['nid']);
      drupal_set_message(t("This group's labels and weights have been reset to their default values."));
    }
  }
}