You are here

function shoutbox_points_shoutbox in Shoutbox 6.2

Same name and namespace in other branches
  1. 7.2 shoutbox_points/shoutbox_points.module \shoutbox_points_shoutbox()
  2. 7 shoutbox_points/shoutbox_points.module \shoutbox_points_shoutbox()

Implementation of hook_shoutbox()

File

shoutbox_points/shoutbox_points.module, line 37

Code

function shoutbox_points_shoutbox($op, &$shout, &$a1 = NULL, $form_state = NULL) {

  // If this shout was anonymous, points can't be handled
  if (!$shout->uid) {
    return;
  }
  switch ($op) {
    case 'insert':
      if ($points = variable_get('shoutbox_points_amount', '0')) {
        $params = array(
          'points' => $points,
          'uid' => $shout->uid,
          'operation' => t('shouted'),
          'entity_id' => $shout->shout_id,
          'entity_type' => t('shout'),
          'display' => FALSE,
        );
        userpoints_userpointsapi($params);
      }
      break;
    case 'delete':
      if (variable_get('shoutbox_points_delete_points', 1)) {
        if ($points = variable_get('shoutbox_points_amount', '0')) {
          $params = array(
            'points' => $points * -1,
            'uid' => $shout->uid,
            'operation' => t('shout removed'),
            'entity_id' => $shout->shout_id,
            'entity_type' => t('shout'),
            'display' => FALSE,
          );
          userpoints_userpointsapi($params);
        }
      }
      break;
  }
}