function userpoints_admin_access in User Points 7
Same name and namespace in other branches
- 7.2 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.
7 calls to userpoints_admin_access()
- userpoints_access_my_points in ./
userpoints.module - Checks if user can access their points - used via hook_menu().
- 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.
- userpoints_get_list_row in ./
userpoints.module - userpoints_get_points_list in ./
userpoints.module - Returns a render array that displays the points and action links.
2 string references to 'userpoints_admin_access'
- userpoints_menu in ./
userpoints.module - Implements hook_menu().
- userpoints_service_services_resources in ./
userpoints_service.module - Implementation of hook_services_resources().
File
- ./
userpoints.module, line 101
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;
}