| 1 |
<?php
|
| 2 |
// $Id:
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Some rules integration for the user points module
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Rules hook implementation.
|
| 11 |
*/
|
| 12 |
function userpoints_rules_action_info() {
|
| 13 |
$actions = array();
|
| 14 |
$actions['userpoints_action_grant_points'] = array(
|
| 15 |
'label' => t('Grant points to a user'),
|
| 16 |
'arguments' => array(
|
| 17 |
'user' => array('type' => 'user','label' => t('User') )
|
| 18 |
),
|
| 19 |
'module' => 'Userpoints',
|
| 20 |
'eval input' => array('points')
|
| 21 |
);
|
| 22 |
return $actions;
|
| 23 |
}
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Rules action - grant points to a user
|
| 27 |
*/
|
| 28 |
function userpoints_action_grant_points($user,$settings){
|
| 29 |
userpoints_userpointsapi(array('uid' => $user->uid, 'points' => $settings['points']));
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Rules form configuration - allow number of points to be set by the rule
|
| 34 |
*/
|
| 35 |
function userpoints_action_grant_points_form($settings = array(), &$form) {
|
| 36 |
|
| 37 |
$form['settings']['points'] = array(
|
| 38 |
'#type' => 'textfield',
|
| 39 |
'#title' => t('Number of points'),
|
| 40 |
'#default_value' => isset($settings['points']) ? $settings['points'] : '',
|
| 41 |
'#description' => t('The number of points to award')
|
| 42 |
);
|
| 43 |
}
|