You are here

function commons_reputation_set_auth_badge in Drupal Commons 6.2

Set the default badge for authenticated users

1 call to commons_reputation_set_auth_badge()
commons_reputation_install in modules/features/commons_reputation/commons_reputation.install
Implementation of hook_install()

File

modules/features/commons_reputation/commons_reputation.install, line 38

Code

function commons_reputation_set_auth_badge($badges) {

  // Fetch the badge
  $badge = db_fetch_object(db_query("SELECT * FROM {user_badges_badges} WHERE name = '%s' AND image = '%s'", $badges['user']->name, $badges['user']->image));

  // Set badge for authenticated role
  if ($badge->bid) {
    $sql = "INSERT INTO {user_badges_roles} (bid, rid) VALUES (%d, %d)";

    // drupal_write_record() is not working here
    db_query($sql, $badge->bid, 2);
  }
}