You are here

function front_page_admin_arrange_form_submit in Front Page 6.2

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

Submit hook for front_page_admin_arrange_form.

File

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

Code

function front_page_admin_arrange_form_submit($form, &$form_state) {
  $front_page_data = front_page_get_all();
  foreach ($form_state['values']['roles'] as $rid => $role) {
    $count = db_result(db_query("SELECT COUNT(*) FROM {front_page} WHERE rid = %d", $rid));
    if (!isset($front_page_data[$rid])) {
      db_query("INSERT INTO {front_page} (rid, mode, data, filter_format, weight) VALUES (%d, '', '', '', %d)", $rid, $role['weight']);
    }
    elseif (isset($role['enabled']) && !$role['enabled']) {
      db_query("UPDATE {front_page} SET mode = '', data = '', filter_format = '', weight = %d WHERE rid = %d", $role['weight'], $rid);
    }
    else {
      db_query("UPDATE {front_page} SET weight = %d WHERE rid = %d", $role['weight'], $rid);
    }
  }
}