You are here

function faq_weight_settings_form_submit in Frequently Asked Questions 5.2

Same name and namespace in other branches
  1. 5 faq.module \faq_weight_settings_form_submit()

Save the options set by the user in the FAQ Settings - Weight tab.

Parameters

$form_id: The id of the form.

&$form_values: Array reference containing the form values submitted.

File

./faq.module, line 739
The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.

Code

function faq_weight_settings_form_submit($form_id, $form_values) {
  if ($form_values['op'] == t('Save order')) {
    $order = explode(",", $form_values['faq_node_order']);
    switch ($GLOBALS['db_type']) {
      case 'mysql':
      case 'mysqli':
        foreach ($order as $index => $nid) {
          $result = db_query("REPLACE INTO {faq_weights} (tid, nid, weight) VALUES(%d, %d, %d)", $form_values['faq_category'], $nid, $index);
        }
        break;
      case 'pgsql':
        foreach ($order as $index => $nid) {
          $result = db_query("DELETE FROM {faq_weights} WHERE tid = %d AND nid = %d", $form_values['faq_category'], $nid);
          $result = db_query("INSERT INTO {faq_weights} (tid, nid, weight) VALUES(%d, %d, %d)", $form_values['faq_category'], $nid, $index);
        }
        break;
    }
    drupal_set_message(t('Configuration has been updated.'));
  }
  else {
  }
}