You are here

function securepages_roles in Secure Pages 7

Same name and namespace in other branches
  1. 6.2 securepages.module \securepages_roles()

Checks if the user is in a role that is always forced onto HTTPS.

Parameters

$account: A valid user object.

Return value

The number of roles set on the user that require HTTPS enforcing.

3 calls to securepages_roles()
securepages_drupal_goto_alter in ./securepages.module
Implements hook_drupal_goto_alter().
securepages_form_alter in ./securepages.module
Implements hook_form_alter().
securepages_redirect in ./securepages.module
Checks the current page and see if we need to redirect to the secure or insecure version of the page.
3 string references to 'securepages_roles'
SecurePagesTestCase::_testRoles in ./securepages.test
Test role-based switching.
securepages_settings in ./securepages.admin.inc
Builds the securepages settings form.
securepages_uninstall in ./securepages.install
Implements hook_uninstall().

File

./securepages.module, line 276
Allows certain pages to be viewable only via HTTPS.

Code

function securepages_roles($account) {

  // All rids are in the settings, so first we need to filter out the ones
  // that aren't enabled. Otherwise this would match positive against all
  // roles a user has set.
  $roles = array_filter(variable_get('securepages_roles', array()));
  $matches = array_intersect_key($account->roles, $roles);
  return count($matches);
}