From dcbe39e1aef3947492d44ad9ffaf7d79fe5fbade Mon Sep 17 00:00:00 2001 From: Bart Van Der Meerssche Date: Mon, 7 Dec 2009 09:21:28 +0000 Subject: [PATCH] web: add entry in {logger_users} when creating device --- web/drupal/modules/logger/logger.drush.inc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/drupal/modules/logger/logger.drush.inc b/web/drupal/modules/logger/logger.drush.inc index 72259dd..d8cf678 100644 --- a/web/drupal/modules/logger/logger.drush.inc +++ b/web/drupal/modules/logger/logger.drush.inc @@ -48,6 +48,10 @@ function _logger_create($serial, $country ="", $uid = 0) { drush_set_error('LOGGER_CREATE_SERIAL_DUPLICATE', dt('The S/N: @serial already exists.', array('@serial' => $serial))); } else { + if ($uid > 0) { + $result = db_query("INSERT INTO {logger_users} (uid, private) VALUES (%d, %d)", $uid, 0); + if (!$result) drush_set_error('LOGGER_CREATE_USERS_ENTRY', dt('Error creating a user entry for @uid.', array('@uid' => $uid))); + } // create an entry in the {logger_devices} table $device = md5(uniqid(rand(), TRUE)); @@ -122,6 +126,9 @@ function _logger_assign($serial, $country, $uid) { else { db_query("UPDATE {logger_devices} SET uid = %d, country = '%s' WHERE serial = %d", $uid, $country, $serial); db_query("UPDATE {logger_meters} SET uid = %d WHERE device = '%s'", $uid, $device); + + $result = db_query("INSERT INTO {logger_users} (uid, private) VALUES (%d, %d)", $uid, 0); + if (!$result) drush_log(dt('uid: @uid already exists in the {logger_users} table', array('@uid' => $uid)), 'notice'); } if (!drush_get_error()) drush_log(dt('Successfully assigned uid: @uid to S/N: @serial', array('@uid' => $uid, '@serial' => $serial)), 'ok');