You are here

function legal_administration_submit in Legal 6.8

Same name and namespace in other branches
  1. 5 legal.module \legal_administration_submit()
  2. 6.7 legal.module \legal_administration_submit()
  3. 7.2 legal.admin.inc \legal_administration_submit()
  4. 7 legal.admin.inc \legal_administration_submit()

File

./legal.admin.inc, line 197
Administration functions for the Legal module.

Code

function legal_administration_submit($form, &$form_state) {
  $values = $form_state['values'];

  // Preview request, don't save anything.
  if ($form_state['clicked_button']['#value'] == t('Preview')) {
    return;
  }
  if (variable_get('legal_display', '0') != $values['display']) {
    variable_set('legal_display', $values['display']);
    drupal_set_message(t('Display setting has been saved.'));
  }

  // If new conditions are different from current permisions, enter in database.
  if (legal_conditions_updated($values)) {
    $version = legal_version($values['version_handling'], $values['language']);
    db_query("INSERT INTO {legal_conditions} (version, revision, language, conditions, date, extras, changes) VALUES (%d, %d, '%s', '%s', %d, '%s', '%s')", $version['version'], $version['revision'], $values['language'], $values['conditions'], time(), serialize($values['extras']), $values['changes']);
    drupal_set_message(t('Terms & Conditions have been saved.'));
  }

  // Empty all cache.
  // @todo: is this necessary?
  cache_clear_all();
}