You are here

function legal_administration_submit in Legal 7

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

File

./legal.admin.inc, line 363
Administration UI 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['triggering_element']['#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 (isset($values['link_target'])) {
    variable_set('legal_link_target', $values['link_target']);
    drupal_set_message(t('Link target 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_insert('legal_conditions')
      ->fields(array(
      'version' => $version['version'],
      'revision' => $version['revision'],
      'language' => $values['language'],
      'conditions' => $values['conditions']['value'],
      'date' => time(),
      'extras' => serialize($values['extras']),
      'changes' => $values['changes'],
      'format' => $values['conditions']['format'],
    ))
      ->execute();
    drupal_set_message(t('Terms & Conditions have been saved.'));
  }

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