VBO add userpoint action

Error message

  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; GeSHi has a deprecated constructor in require_once() (line 818 of /home/xenyomed/public_html/sites/all/modules/libraries/libraries.module).
  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context has a deprecated constructor in require_once() (line 127 of /home/xenyomed/public_html/sites/all/modules/ctools/ctools.module).
  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_required has a deprecated constructor in require_once() (line 127 of /home/xenyomed/public_html/sites/all/modules/ctools/ctools.module).
  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_optional has a deprecated constructor in require_once() (line 127 of /home/xenyomed/public_html/sites/all/modules/ctools/ctools.module).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 579 of /home/xenyomed/public_html/includes/menu.inc).

WE HAVE MOVED!

Please visit our new Drupal Website at https://www.xenyo.com.

function modulename_action_info() {
  return array(
    'modulename_adduserpoint_action' => array(
      'type' => 'user',
      'label' => t('userpoint operations'),
      'configurable' => TRUE,
      'triggers' => array('user_update'),
    ),
  );
}
 
function modulename_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) {
  if ($form_state['step'] == 'views_bulk_operations_confirm_form' && $form_state['operation']->operationId == 'action::modulename_adduserpoint_action') {
    $form['desc'] = array (
      '#markup' => 'Action : Add userpoints ' . $form_state['operation']->formOptions['add_userpoint'] ,
    );
  }
}
 
function modulename_adduserpoint_action_form ($context) {
  $options = array();
  $options = array (
    'add' => 'Add userpoint',
    'substract' => 'Substract userpoint',
    'modifiy' => 'Fixed value'
  );
  $form['userpoint_operations'] = array (
    '#type' => 'select',
    '#required' => true,
    '#options' => $options,
  );
  $form['modulename_adduserpoint'] = array (
    '#type' => 'textfield',
    '#required' => true,
    '#title' => 'Userpoints value',
  );
  return $form;
}
 
function modulename_adduserpoint_action_submit ($form, $form_state) {
  return array (
    'add_userpoint' => check_plain($form_state['values']['modulename_adduserpoint'])
  );
}
 
function modulename_adduserpoint_action(&$user, $context = array()) {
  if (is_numeric ($user->uid)) {
    userpoints_userpointsapi(
      array(
        'uid' => $user->uid,
        'points' => $context['add_userpoint'],
        'moderate' => variable_get('userpoints_votingapi_moderation', 0),
        'event' => 'coupon',
        'entity_id' => $user->uid, 
        'entity_type' => 'user',
        'operation' => t('Add userpoint'),    
        'tid' => variable_get('userpoints_votingapi_tid', 0),  
        'description' => t('Add userpoint: !entity_type !entity_id.', array('!entity_type' => 'user', '!entity_id' => $user->uid)),    
      )
    );
  }
}
Help Share this Article