You are here

userpoints_workflow_ng.module in User Points 5.3

Some workflow-ng integration for the user points module

File

userpoints_workflow_ng.module
View source
<?php

/**
 * @file
 * Some workflow-ng integration for the user points module
 */

/**
 * Implementation of hook_action_info().
 */
function userpoints_action_info() {
  return array(
    'userpoints_action_grant_points' => array(
      '#label' => t('Grant points to a user'),
      '#arguments' => array(
        'user' => array(
          '#entity' => 'user',
          '#label' => t('User'),
        ),
      ),
      '#module' => t('Userpoints'),
    ),
  );
}
function userpoints_event_info() {
  return array(
    'userpoints_points_awarded' => array(
      '#label' => t('User was awarded points'),
      '#module' => t('User Points'),
      '#arguments' => array(
        'user' => array(
          '#entity' => 'user',
          '#label' => t('Current User'),
        ),
        'points' => array(
          '#entity' => 'points',
          '#label' => t('Points Awarded'),
        ),
      ),
    ),
  );
}

// End Function

/**
 * Implementation of a workflow-ng action:  grant points to a user
 */
function userpoints_action_grant_points($user, $settings, &$arguments, &$log) {
  extract(workflow_ng_token_replace_all(array(
    'number',
  ), $settings, $arguments, $log));
  userpoints_userpointsapi(array(
    'uid' => $user->uid,
    'points' => $number,
  ));
}

/**
 * Implementation of a workflow-ng action: disables revision moderation.
 */
function userpoints_action_grant_points_form($settings = array(), $argument_info) {
  $form = array();
  $form['number'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of points'),
    '#default_value' => isset($settings['number']) ? $settings['number'] : '',
  );
  workflow_ng_token_replacement_help($form, $argument_info);
  return $form;
}
function userpoints_action_grant_points_submit($form_id, $form_values) {
  return workflow_ng_token_get_settings(array(
    'number',
  ), $form_values);
}
function userpoints_workflow_ng_userpoints($op, $points = 0, $uid = 0, $event = '') {
  switch ($op) {
    case 'points after':
      workflow_ng_invoke_event('userpoints_points_awarded', $uid, $points);
      break;
  }
}

Functions

Namesort descending Description
userpoints_action_grant_points Implementation of a workflow-ng action: grant points to a user
userpoints_action_grant_points_form Implementation of a workflow-ng action: disables revision moderation.
userpoints_action_grant_points_submit
userpoints_action_info Implementation of hook_action_info().
userpoints_event_info
userpoints_workflow_ng_userpoints