You are here

function autoassignrole_get_path_roles in Auto Assign Role 6.2

Same name and namespace in other branches
  1. 6 autoassignrole.module \autoassignrole_get_path_roles()

Get all path assignable roles

Parameters

$path: array Optional array of paths to restrict selection to when using an $op of path

Return value

array An array of roles

2 calls to autoassignrole_get_path_roles()
autoassignrole_get_active_path_roles in ./autoassignrole.module
Get all roles that will be assigned based on the active path
autoassignrole_get_roles in ./autoassignrole.module
An API like call to return the roles a user has available or will be assigned

File

./autoassignrole.module, line 575
The main autoassignrole.module file

Code

function autoassignrole_get_path_roles($path = array()) {
  $aar_roles = array();

  // Select path based roles
  if (count($path) == 0) {
    $sql = "SELECT rid FROM {autoassignrole_page}";
    $result = db_query($sql);
  }
  else {
    foreach ($path as $key => $value) {
      $path[$key] = "'{$value}'";
    }
    $sql = "SELECT rid FROM {autoassignrole_page} WHERE path IN(" . implode(',', $path) . ")";
    $result = db_query($sql);
  }
  while ($row = db_fetch_object($result)) {
    $aar_roles[$row->rid] = $row->rid;
  }
  return _autoassignrole_clean_roles($aar_roles);
}