You are here

function biblio_coins_generate in Bibliography Module 7.2

Same name and namespace in other branches
  1. 5 biblio.module \biblio_coins_generate()
  2. 6.2 includes/biblio.util.inc \biblio_coins_generate()
  3. 6 biblio.module \biblio_coins_generate()
  4. 7 includes/biblio.util.inc \biblio_coins_generate()

File

includes/biblio.util.inc, line 192

Code

function biblio_coins_generate(&$biblio) {
  if (!isset($biblio->vid)) {
    $biblio->biblio_coins = biblio_coins($biblio);
    return;
  }
  if ($biblio) {
    $biblio->biblio_coins = biblio_coins($biblio);

    // @todo: check if this is needed
    db_update('biblio')
      ->fields(array(
      'biblio_coins' => $biblio->biblio_coins,
    ))
      ->condition('vid', $biblio->vid)
      ->execute();
  }
  else {
    $result = db_query("SELECT nr.*, b.*\n                        FROM {biblio} AS n\n                        LEFT JOIN {biblio_revision}  AS nr ON n.vid = nr.vid LEFT JOIN {biblio} AS b ON n.vid = b.vid\n                        WHERE n.type = 'biblio'  ");
    foreach ($result as $biblio) {
      $biblio->biblio_coins = biblio_coins($biblio);
      db_update('biblio')
        ->fields(array(
        'biblio_coins' => $biblio->biblio_coins,
      ))
        ->condition('vid', $biblio->vid)
        ->execute();
    }
    drupal_goto('');
  }
}