name; $items[t('!Points', userpoints_translation())] = array( 'value' => l(t('Give !points to ' .$account->name, userpoints_translation()), $url), 'class' => 'member', ); return array(t('!Points', userpoints_translation()) => $items); } //added by darxtar } } function user2userpoints_perm() { return array(USER2USERPOINTS_PERM_SEND); } /* Create the links to givepoints */ function user2userpoints_menu($may_cache) { $items = array(); if (!$may_cache) { $items[] = array( 'path' => 'user2userpoints', 'title' => t('Give !points', userpoints_translation()), 'callback' => 'drupal_get_form', 'callback arguments' => array('user2userpoints_form'), 'access' => array(USER2USERPOINTS_PERM_SEND), ); } return $items; } function user2userpoints_form($name = '') { $form = array(); /* START Modified by Darxtar */ $form['to'] = array( '#type' => 'textfield', '#title' => t('To'), '#default_value' => $name, '#autocomplete_path' => 'user/autocomplete', '#size' => 50, '#maxlength' => 64, '#required' => TRUE ); /* END Modified by Darxtar */ $form['amount'] = array( '#type' => 'textfield', '#title' => t('Amount'), '#default_value' => '1', '#size' => 50, '#required' => TRUE ); $form[] = array( '#type' => 'submit', '#value' => t('Give !Points', userpoints_translation()) ); return $form; } //Modified by darxtar //WAS: function user2userpoints_validate($form_id, $form_values) { function user2userpoints_form_validate($form_id, $form_values) { global $user; /* Check the name to be valid. */ if (!empty($form_values['to'])) { $to= user_load(array('name' => $form_values['to'])); if (!$to->uid) { form_set_error('to', t("That is not a valid user.")); } elseif ($to->uid == $user->uid) { form_set_error('to', t("You can't give !points to yourself.", userpoints_translation())); } } /* Check the value to be valid. */ if (!empty($form_values['amount'])) { if ($form_values['amount'] < 1) { form_set_error('amount', t("You can't give less than one !point.", userpoints_translation())); } if ($form_values['amount'] > userpoints_get_current_points($user->uid)) { form_set_error('amount', t("You don't have enough !points for that.", userpoints_translation())); } } } //Modified by darxtar //WAS: function user2userpoints_submit($form_id, $form_values) { function user2userpoints_form_submit($form_id, $form_values) { global $user; $points = $form_values['amount']; $to = user_load(array('name' => $form_values['to'])); userpoints_userpointsapi('points', $points, $to->uid, 'From: ' . $user->name); userpoints_userpointsapi('points', -$points, $user->uid, 'To: ' . $to->name); }