function userpoints_admin_txn_submit in User Points 7
Same name and namespace in other branches
- 5.3 userpoints.module \userpoints_admin_txn_submit()
- 5 userpoints.module \userpoints_admin_txn_submit()
- 5.2 userpoints.module \userpoints_admin_txn_submit()
- 6 userpoints.module \userpoints_admin_txn_submit()
- 7.2 userpoints.admin.inc \userpoints_admin_txn_submit()
Submit function for userpoints transaction form.
File
- ./
userpoints.admin.inc, line 312 - Admin menu callbacks for userpoints.module.
Code
function userpoints_admin_txn_submit($form, &$form_state) {
global $user;
if ($form_state['values']['mode'] == 'add') {
$params = array(
'points' => $form_state['values']['points'],
'uid' => $form_state['values']['txn_user']->uid,
'operation' => $form_state['values']['operation'],
'description' => $form_state['values']['description'],
'reference' => $form_state['values']['reference'],
'tid' => $form_state['values']['tid'],
'time_stamp' => strtotime($form_state['values']['time_stamp']),
'moderate' => (bool) $form_state['values']['moderate'],
'approver_uid' => $user->uid,
);
if ($form_state['values']['expirydate']) {
// Check for the existence of an expirydate.
$params['expirydate'] = strtotime($form_state['values']['expirydate']);
}
if (!empty($form_state['values']['entity_id']) && !empty($form_state['values']['entity_type'])) {
$params['entity_type'] = $form_state['values']['entity_type'];
$params['entity_id'] = (int) $form_state['values']['entity_id'];
}
}
else {
$expirydate = 0;
if (!empty($form_state['values']['expirydate'])) {
$expirydate = strtotime($form_state['values']['expirydate']);
}
// If status changed, the current user is the new approver, when not
// changed, then the current approver is kept.
if ($form_state['values']['txn']->status == $form_state['values']['status']) {
$approver_uid = $form_state['values']['txn']->approver_uid;
}
else {
$approver_uid = $user->uid;
}
$params = array(
'uid' => $form_state['values']['txn']->uid,
'approver_uid' => $approver_uid,
'points' => $form_state['values']['points'],
'tid' => $form_state['values']['tid'],
'time_stamp' => strtotime($form_state['values']['time_stamp']),
'operation' => $form_state['values']['operation'],
'description' => $form_state['values']['description'],
'reference' => $form_state['values']['reference'],
'status' => $form_state['values']['status'],
'expirydate' => $expirydate,
'txn_id' => $form_state['values']['txn']->txn_id,
'display' => FALSE,
);
if (!empty($form_state['values']['entity_id']) && !empty($form_state['values']['entity_type'])) {
$params['entity_type'] = $form_state['values']['entity_type'];
$params['entity_id'] = (int) $form_state['values']['entity_id'];
}
drupal_set_message(t('Changes to the !points transaction have been saved.', userpoints_translation()));
}
userpoints_userpointsapi($params);
$form_state['redirect'] = 'admin/config/people/userpoints';
}