function userpoints_admin_approve in User Points 5
Same name and namespace in other branches
- 5.3 userpoints.module \userpoints_admin_approve()
- 5.2 userpoints.module \userpoints_admin_approve()
- 6 userpoints.module \userpoints_admin_approve()
1 string reference to 'userpoints_admin_approve'
- userpoints_menu in ./
userpoints.module - Implementation of hook_menu().
File
- ./
userpoints.module, line 416
Code
function userpoints_admin_approve() {
global $user;
$op = arg(3);
$txn_id = (int) arg(4);
if ($txn_id) {
switch ($op) {
case 'approve':
$result = db_query("SELECT uid, event, points, description, reference\n FROM {userpoints_txn}\n WHERE status = %d AND txn_id = %d", USERPOINTS_TXN_STATUS_PENDING, $txn_id);
$data = db_fetch_object($result);
drupal_set_message(t('Transaction approved'));
// This transaction has not been credited to the user's account, so credit it first
userpoints_userpointsapi('txn approve', $data->points, $data->uid, $data->event, $data->description, $data->reference);
// Set it to approved
db_query("UPDATE {userpoints_txn}\n SET status = %d, approver_uid = %d WHERE txn_id = %d", USERPOINTS_TXN_STATUS_APPROVED, $user->uid, $txn_id);
break;
case 'decline':
db_query("UPDATE {userpoints_txn}\n SET status = %d, approver_uid = %d WHERE txn_id = %d", USERPOINTS_TXN_STATUS_DECLINED, $user->uid, $txn_id);
drupal_set_message(t('Transaction declined'));
break;
}
}
drupal_goto('admin/user/userpoints');
}