You are here

user_service.module in Services 6

@author Services Dev Team

Link general user functionalities to services module.

File

services/user_service/user_service.module
View source
<?php

/**
 * @author Services Dev Team
 * @file
 *  Link general user functionalities to services module.
 */

/**
 * Implementation of hook_help().
 */
function user_service_help($path, $arg) {
  switch ($path) {
    case 'admin/help#services_user':
      return '<p>' . t('Provides user methods to services applications. Requires services.module.') . '</p>';
    case 'admin/modules#description':
      return t('Provides user methods to services applications. Requires services.module.');
  }
}

/**
 * Implementation of hook_perm().
 */
function user_service_perm() {
  return array(
    'get any user data',
    'get own user data',
    'update any user data',
    'update own user data',
    'create new users',
    'delete any user',
    'delete own user',
  );
}

/**
 * Implementation of hook_service().
 */
function user_service_service() {
  return array(
    // user.delete
    array(
      '#method' => 'user.delete',
      '#callback' => 'user_service_delete',
      '#access callback' => 'user_service_delete_access',
      '#file' => array(
        'file' => 'inc',
        'module' => 'user_service',
      ),
      '#args' => array(
        array(
          '#name' => 'uid',
          '#type' => 'int',
          '#description' => t('User ID.'),
        ),
      ),
      '#return' => 'struct',
      '#help' => t('Delete an user.'),
    ),
    // user.get
    array(
      '#method' => 'user.get',
      '#callback' => 'user_service_get',
      '#access callback' => 'user_service_get_access',
      '#file' => array(
        'file' => 'inc',
        'module' => 'user_service',
      ),
      '#args' => array(
        array(
          '#name' => 'uid',
          '#type' => 'int',
          '#description' => t('User ID.'),
        ),
      ),
      '#return' => 'struct',
      '#help' => t('Get all user details.'),
    ),
    // user.login
    array(
      '#method' => 'user.login',
      '#callback' => 'user_service_login',
      '#file' => array(
        'file' => 'inc',
        'module' => 'user_service',
      ),
      '#args' => array(
        array(
          '#name' => 'username',
          '#type' => 'string',
          '#description' => t('A valid username.'),
        ),
        array(
          '#name' => 'password',
          '#type' => 'string',
          '#description' => t('A valid password.'),
        ),
      ),
      '#return' => 'struct',
      '#help' => t('Logs in a user.'),
    ),
    // user.logout
    array(
      '#method' => 'user.logout',
      '#callback' => 'user_service_logout',
      '#file' => array(
        'file' => 'inc',
        'module' => 'user_service',
      ),
      '#args' => array(),
      '#return' => 'struct',
      '#help' => t('Logs out a user.'),
    ),
    // user.save
    array(
      '#method' => 'user.save',
      '#callback' => 'user_service_save',
      '#access callback' => 'user_service_save_access',
      '#file' => array(
        'file' => 'inc',
        'module' => 'user_service',
      ),
      '#args' => array(
        array(
          '#name' => 'uid',
          '#type' => 'int',
          '#description' => t('User ID.'),
        ),
      ),
      '#return' => 'struct',
      '#help' => t('Save user details.'),
    ),
  );
}

Functions

Namesort descending Description
user_service_help Implementation of hook_help().
user_service_perm Implementation of hook_perm().
user_service_service Implementation of hook_service().