You are here

function farm_access_roles_create in farmOS 7

Create farm roles.

4 calls to farm_access_roles_create()
farm_access_flush_caches in modules/farm/farm_access/farm_access.module
Implements hook_flush_caches().
farm_access_install in modules/farm/farm_access/farm_access.install
Implements hook_install().
farm_access_modules_enabled in modules/farm/farm_access/farm_access.module
Implements hook_modules_enabled().
farm_access_permissions_form_submit in modules/farm/farm_access/farm_access.module
Submit function for the core permissions form.

File

modules/farm/farm_access/farm_access.module, line 228
Farm Access module.

Code

function farm_access_roles_create() {

  // Get a list of farm roles.
  $roles = farm_access_roles();

  // Iterate through the roles.
  foreach ($roles as $key => $info) {

    // If the name is blank, skip.
    if (empty($info['name'])) {
      continue;
    }

    // Load the role by name.
    $role = user_role_load_by_name($info['name']);

    // If the role doesn't exist, create it.
    if (empty($role)) {
      $role = new stdClass();
      $role->name = $info['name'];
      user_role_save($role);
    }
  }
}