web: provision an entry in the logger_users table when a first device is added

This commit is contained in:
Bart Van Der Meerssche 2010-03-09 12:55:25 +00:00
parent e6743f610c
commit 517efafed3
1 changed files with 4 additions and 0 deletions

View File

@ -67,6 +67,10 @@ function _logger_account_devices_submit($form, &$form_state) {
db_query("UPDATE {logger_devices} SET uid = %d WHERE serial = %d", $user->uid, $serial);
db_query("UPDATE {logger_meters} SET uid = %d WHERE device = '%s'", $user->uid, $device);
if (db_result(db_query("SELECT COUNT(*) FROM {logger_users} WHERE uid = %d", $user->uid)) == 0) {
db_query("INSERT INTO {logger_users} (uid, private) VALUES (%d, %d)", $user->uid, 0);
}
drupal_set_message(t("The device is now associated with your account."));
}