function _user_resource_definition in Services 7.3
Same name and namespace in other branches
- 6.3 resources/user_resource.inc \_user_resource_definition()
1 call to _user_resource_definition()
- _services_core_resources in includes/
services.resource_build.inc - Supplies the resource definitions for Drupal core data
File
- resources/
user_resource.inc, line 3
Code
function _user_resource_definition() {
$definition = array(
'user' => array(
'operations' => array(
'retrieve' => array(
'help' => 'Retrieve a user',
'callback' => '_user_resource_retrieve',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
'access callback' => '_user_resource_access',
'access arguments' => array(
'view',
),
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'uid',
'type' => 'int',
'description' => 'The uid of the user to retrieve.',
'source' => array(
'path' => 0,
),
'optional' => FALSE,
),
),
),
'create' => array(
'help' => 'Create a user',
'callback' => '_user_resource_create',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
'access callback' => '_user_resource_access',
'access arguments' => array(
'create',
),
'access arguments append' => FALSE,
'args' => array(
array(
'name' => 'account',
'type' => 'array',
'description' => 'The user object',
'source' => 'data',
'optional' => FALSE,
),
),
),
'update' => array(
'help' => 'Update a user',
'callback' => '_user_resource_update',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
'access callback' => '_user_resource_access',
'access arguments' => array(
'update',
),
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'uid',
'type' => 'int',
'description' => 'Unique identifier for this user',
'source' => array(
'path' => 0,
),
'optional' => FALSE,
),
array(
'name' => 'data',
'type' => 'array',
'description' => 'The user object with updated information',
'source' => 'data',
'optional' => FALSE,
),
),
),
'delete' => array(
'help' => 'Delete a user',
'callback' => '_user_resource_delete',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
'access callback' => '_user_resource_access',
'access arguments' => array(
'delete',
),
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'uid',
'type' => 'int',
'description' => 'The id of the user to delete',
'source' => array(
'path' => 0,
),
'optional' => FALSE,
),
),
),
'index' => array(
'help' => 'List all users',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
'callback' => '_user_resource_index',
'args' => array(
array(
'name' => 'page',
'optional' => TRUE,
'type' => 'int',
'description' => 'The zero-based index of the page to get, defaults to 0.',
'default value' => 0,
'source' => array(
'param' => 'page',
),
),
array(
'name' => 'fields',
'optional' => TRUE,
'type' => 'string',
'description' => 'The fields to get.',
'default value' => '*',
'source' => array(
'param' => 'fields',
),
),
array(
'name' => 'parameters',
'optional' => TRUE,
'type' => 'array',
'description' => 'Parameters',
'default value' => array(),
'source' => array(
'param' => 'parameters',
),
),
array(
'name' => 'pagesize',
'optional' => TRUE,
'type' => 'int',
'description' => 'Number of records to get per page.',
'default value' => variable_get('services_user_index_page_size', 20),
'source' => array(
'param' => 'pagesize',
),
),
array(
'name' => 'options',
'optional' => TRUE,
'type' => 'array',
'description' => 'Additional query options.',
'default value' => array(
'orderby' => array(
'created' => 'DESC',
),
),
'source' => array(
'param' => 'options',
),
),
),
'access arguments' => array(
'access user profiles',
),
'access arguments append' => FALSE,
),
),
'actions' => array(
'login' => array(
'help' => 'Login a user for a new session',
'callback' => '_user_resource_login',
'args' => array(
array(
'name' => 'username',
'type' => 'string',
'description' => 'A valid username',
'source' => array(
'data' => 'username',
),
'optional' => FALSE,
),
array(
'name' => 'password',
'type' => 'string',
'description' => 'A valid password',
'source' => array(
'data' => 'password',
),
'optional' => FALSE,
),
),
'access callback' => 'services_access_menu',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
),
'logout' => array(
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
'help' => 'Logout a user session',
'callback' => '_user_resource_logout',
'access callback' => 'services_access_menu',
),
'token' => array(
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
'callback' => '_user_resource_get_token',
'access callback' => 'services_access_menu',
'help' => t('Returns the CSRF token.'),
),
'request_new_password' => array(
'help' => 'Request a new password, given a user name or e-mail address',
'callback' => '_user_resource_request_new_password',
'args' => array(
array(
'name' => 'name',
'type' => 'string',
'description' => 'A valid user name or e-mail address',
'source' => array(
'data' => 'name',
),
'optional' => FALSE,
),
),
'access callback' => 'services_access_menu',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
),
'user_pass_reset' => array(
'help' => 'Process one time login link and return the pass_reset_{uid} token to be used on user update operation',
'callback' => '_user_resource_user_pass_reset_login',
'args' => array(
array(
'name' => 'uid',
'optional' => FALSE,
'type' => 'int',
'description' => 'The uid of the user in the operation.',
'source' => array(
'data' => 'uid',
),
),
array(
'name' => 'timestamp',
'optional' => FALSE,
'type' => 'int',
'description' => 'The timestamp value from the reset password link.',
'source' => array(
'data' => 'timestamp',
),
),
array(
'name' => 'hashed_pass',
'optional' => FALSE,
'type' => 'string',
'description' => 'The hashed pass value from the reset password link.',
'source' => array(
'data' => 'hashed_pass',
),
),
),
'access callback' => 'services_access_menu',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
),
),
'targeted_actions' => array(
'cancel' => array(
'help' => 'Cancel a user',
'callback' => '_user_resource_cancel',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/user_resource',
),
'access callback' => '_user_resource_access',
'access arguments' => array(
'cancel',
),
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'uid',
'optional' => FALSE,
'source' => array(
'path' => 0,
),
'type' => 'int',
'description' => 'The id of the user to cancel.',
),
),
),
'password_reset' => array(
'access callback' => '_user_resource_access',
'access arguments' => array(
'password_reset',
),
'access arguments append' => TRUE,
'callback' => '_user_resource_password_reset',
'args' => array(
array(
'name' => 'uid',
'optional' => FALSE,
'source' => array(
'path' => 0,
),
'type' => 'int',
'description' => 'The id of the user whose password to reset.',
),
),
),
'resend_welcome_email' => array(
'access callback' => '_user_resource_access',
'access arguments' => array(
'resend_welcome_email',
),
'access arguments append' => TRUE,
'callback' => '_user_resource_resend_welcome_email',
'args' => array(
array(
'name' => 'uid',
'optional' => FALSE,
'source' => array(
'path' => 0,
),
'type' => 'int',
'description' => 'The id of the user whose welcome email to resend.',
),
),
),
),
),
);
$definition['user']['actions']['register'] = array_merge($definition['user']['operations']['create'], array(
'help' => 'Register a user',
));
return $definition;
}