You are here

function simple_access_profile_form_submit in Simple Access 5.2

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

File

./simple_access.module, line 685
This module allows administrators to make nodes viewable by specific 'access groups'. Each access group can contain any number of roles. If a node is not assigned to any access groups, it will remain viewable by all users.

Code

function simple_access_profile_form_submit($form_id, $form_values) {
  if (!empty($form_values['pid'])) {
    db_query("UPDATE {simple_access_profiles} SET name = '%s' WHERE pid = %d", $form['pid'], $form['name']);
  }
  else {
    $form_values['pid'] = db_next_id('{simple_access_profiles}_pid');
    db_query("INSERT INTO {simple_access_profiles} (pid, name) VALUES (%d, '%s')", $form_values['pid'], $form_values['name']);
  }
  db_query('DELETE FROM {simple_access_profiles_access} WHERE pid = %d', $form_values['pid']);
  if (isset($form_values['access'])) {
    foreach ($form_values['access'] as $gid => $access) {
      if ($access['sa_view'] || $access['sa_update'] || $access['sa_delete']) {
        db_query("INSERT INTO {simple_access_profiles_access} (pid, gid, sa_view, sa_update, sa_delete) VALUES (%d, %d, %d, %d, %d)", $form_values['pid'], $gid, $access['sa_view'], $access['sa_update'], $access['sa_delete']);
      }
    }
  }
  return 'admin/user/sa_profiles';
}