You are here

function shib_auth_update_6402 in Shibboleth Authentication 6.4

File

./shib_auth.install, line 166
This is the install file of the Shibboleth authentication module for Drupal system

Code

function shib_auth_update_6402() {

  // This update is useful for those, who already linked existing accounts to shibboleth with versions prior to RC4, but link didn't create authmap entry
  $ret = array();

  //copy the elements of shib_authmap to authmap, which isn't there already
  $entries = db_query("SELECT uid, name FROM {users} WHERE (uid) IN\n  (SELECT DISTINCT uid\nFROM {shib_authmap}\nWHERE (uid) NOT IN\n  (SELECT uid FROM {authmap})\n)");
  while ($entry = db_fetch_array($entries)) {
    if ($entry['uid'] > 1) {
      $ret[] = update_sql("INSERT INTO {authmap} (uid, authname, module) VALUES  ('" . $entry['uid'] . "',\n      '" . $entry['name'] . "',\n      'shib_auth')");
    }
  }
  return $ret;
}