You are here

function userpoints_user in User Points 6

Same name and namespace in other branches
  1. 5.3 userpoints.module \userpoints_user()
  2. 5 userpoints.module \userpoints_user()
  3. 5.2 userpoints.module \userpoints_user()

File

./userpoints.module, line 898

Code

function userpoints_user($op, &$edit, &$account, $category = '') {
  global $user;
  switch ($op) {
    case 'delete':

      // The user is being deleted, delete all traces in userpoints and txn tables
      db_query('DELETE FROM {userpoints} WHERE uid = %d', $account->uid);
      db_query('DELETE FROM {userpoints_txn} WHERE uid = %d', $account->uid);
      break;
    case 'view':
      if (userpoints_access_my_points($account)) {
        $details = array();
        $details[] = l(t('View'), 'myuserpoints/' . $account->uid, array(
          'attributes' => array(
            'title' => t('View detailed transactions'),
          ),
        ));
        if (user_access(USERPOINTS_PERM_ADMIN)) {
          $details[] = l(t('Adjust'), 'admin/user/userpoints/add/' . $account->uid, array(
            'attributes' => array(
              'title' => t('Add/substract !points from this user', userpoints_translation()),
            ),
          ));
        }
        $details = implode(', ', $details);

        //Which points are we display?
        $points = userpoints_get_current_points($account->uid, variable_get(USERPOINTS_CATEGORY_PROFILE_DISPLAY_TID, 0));
        $account->content['userpoints'] = array(
          '#type' => 'user_profile_category',
          '#title' => t('User !points', userpoints_translation()),
        );
        $account->content['userpoints']['points'] = array(
          '#type' => 'user_profile_item',
          '#title' => t('!Points', userpoints_translation()),
          '#value' => $details ? $points . ' - ' . $details : $points,
        );
      }
      break;
  }
}