You are here

function front_page_admin_submit in Front Page 6.2

Same name and namespace in other branches
  1. 7.2 front_page.admin.inc \front_page_admin_submit()

Submit hook for front_page_admin.

File

./front_page.admin.inc, line 132
Admin page callbacks for the front page module.

Code

function front_page_admin_submit($form, &$form_state) {
  variable_set('front_page_enable', $form_state['values']['front_page_enable']);
  $front_page_data = front_page_get_all();
  db_query("DELETE FROM {front_page}");
  if (is_array($form_state['values']['roles'])) {
    foreach ($form_state['values']['roles'] as $rid => $role) {
      if (!isset($front_page_data[$rid]['weight'])) {
        $front_page_data[$rid]['weight'] = 0;
      }
      switch ($role['mode']) {
        case 'themed':
        case 'full':
          db_query("INSERT INTO {front_page} (rid, mode, data, filter_format, weight) VALUES (%d, '%s', '%s', '%s', %d)", $rid, $role['mode'], $role['data'], $role['filter_format'], $front_page_data[$rid]['weight']);
          break;
        case 'redirect':
        case 'alias':
          db_query("INSERT INTO {front_page} (rid, mode, data, filter_format, weight) VALUES (%d, '%s', '%s', '', %d)", $rid, $role['mode'], $role['path'], $front_page_data[$rid]['weight']);
          break;
        default:
          db_query("INSERT INTO {front_page} (rid, mode, data, filter_format, weight) VALUES (%d, '', '', '', %d)", $rid, $front_page_data[$rid]['weight']);
      }
    }
  }
  drupal_set_message(t('Your settings have been saved.'));
}