You are here

function simple_access_profile_form_submit in Simple Access 6.2

Same name and namespace in other branches
  1. 5.2 simple_access.module \simple_access_profile_form_submit()
  2. 7.2 simple_access.admin.inc \simple_access_profile_form_submit()

File

./simple_access.admin.inc, line 206
House all the admin functions in inc to make the foot print a lot smaller.

Code

function simple_access_profile_form_submit($form, &$form_state) {
  if (!empty($form_state['values']['pid'])) {
    drupal_write_record('simple_access_profiles', $form_state['values'], array(
      'pid',
    ));
  }
  else {
    drupal_write_record('simple_access_profiles', $form_state['values']);
  }
  db_query('DELETE FROM {simple_access_profiles_access} WHERE pid = %d', $form_state['values']['pid']);
  if (isset($form_state['values']['access'])) {
    foreach ($form_state['values']['access'] as $gid => $access) {
      if ($access['sa_view'] || $access['sa_update'] || $access['sa_delete']) {
        $access['pid'] = $form_state['values']['pid'];
        $access['gid'] = $gid;
        drupal_write_record('simple_access_profiles_access', $access);
      }
    }
  }
  $form_state['redirect'] = 'admin/user/sa_profiles';
}