You are here

function userpoints_admin_access in User Points 7.2

Same name and namespace in other branches
  1. 7 userpoints.module \userpoints_admin_access()

Checks access for administrative functionality.

Provides simplified access checks for the administrative permissions:

  • administer userpoints
  • add userpoints
  • edit userpoints
  • moderate userpoints

Parameters

$type: The access type to check. The administer permission has access to all of them. Supported strings:

  • list: Access to the userpoints list, default local task. All administrative permissions have access to this.
  • add: Permission to add new userpoints transactions.
  • edit: Permission to edit existing userpoints transactions.
  • moderate: Permission to approve/decline pending transactions.
  • administer: Unlimited userpoints permissions, used for settings page.

Return value

TRUE if the current user has access, FALSE if not.

8 calls to userpoints_admin_access()
UserpointsTransaction::getActions in ./userpoints.transaction.inc
Returns a list of operations as links.
userpoints_access_my_points in ./userpoints.module
Checks if user can access their points - used via hook_menu().
userpoints_access_transactions in ./userpoints.module
Checks if a user has access to own or other users transactions history.
userpoints_admin_access_transaction_pending in ./userpoints.module
Access callback for approve and decline local tasks.
userpoints_admin_txn in ./userpoints.admin.inc
Form builder for add/edit userpoints transaction form.

... See full list

4 string references to 'userpoints_admin_access'
userpoints_entity_info in ./userpoints.module
Implements hook_entity_info().
userpoints_entity_info_alter in ./userpoints.module
Implements hook_entity_info_alter().
userpoints_menu in ./userpoints.module
Implements hook_menu().
userpoints_service_services_resources in userpoints_service/userpoints_service.module
Implementation of hook_services_resources().

File

./userpoints.module, line 96

Code

function userpoints_admin_access($type = 'list') {

  // Administer userpoints permission has full access.
  if (user_access('administer userpoints')) {
    return TRUE;
  }
  switch ($type) {

    // All admin permissions have access to the list page.
    case 'list':
      return user_access('add userpoints') || user_access('edit userpoints') || user_access('moderate userpoints');
      break;
    case 'add':
      return user_access('add userpoints');
      break;
    case 'edit':
      return user_access('edit userpoints');
      break;
    case 'moderate':
      return user_access('moderate userpoints');
      break;
    case 'administer':

      // administer permission was already checked, this exists for
      // documentation purposes only.
      break;
  }
  return FALSE;
}