You are here

function simple_access_save_group in Simple Access 6.2

Same name and namespace in other branches
  1. 5.2 simple_access.module \simple_access_save_group()
  2. 5 simple_access.module \simple_access_save_group()
  3. 7.2 simple_access.module \simple_access_save_group()

Save group of roles into the database $roles is an associative array of roles where the keys are role ids $name is the name of the group $gid is the group id

1 call to simple_access_save_group()
simple_access_group_form_submit in ./simple_access.admin.inc

File

./simple_access.module, line 609
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_save_group($edit) {
  if (empty($edit['gid'])) {
    drupal_write_record('simple_access_groups', $edit);
  }
  else {
    drupal_write_record('simple_access_groups', $edit, array(
      'gid',
    ));
  }
  db_query('DELETE FROM {simple_access_roles} WHERE gid = %d', $edit['gid']);
  if (is_array($edit['roles'])) {
    foreach ($edit['roles'] as $key => $value) {
      if ($value) {
        $record = array(
          'rid' => $key,
          'gid' => $edit['gid'],
        );
        $s = drupal_write_record('simple_access_roles', $record);
        $success = $success && $s;
      }
    }
  }
  return $success;
}