function tokenauth_enable in Token authentication 7
Same name and namespace in other branches
- 6.2 tokenauth.install \tokenauth_enable()
- 6 tokenauth.install \tokenauth_enable()
Implements hook_enable().
File
- ./
tokenauth.install, line 46 - Installation routines for the Token Authentication module.
Code
function tokenauth_enable() {
// Assign tokens for each user.
$results = db_query("SELECT u.uid FROM {users} u LEFT JOIN {tokenauth_tokens} tt ON u.uid = tt.uid WHERE tt.token IS NULL AND u.uid > 0");
foreach ($results as $row) {
tokenauth_insert($row->uid);
}
// Clean up orphaned tokens from users removed while module disabled
db_query("DELETE tt.* FROM {tokenauth_tokens} tt WHERE NOT EXISTS (SELECT * FROM {users} u WHERE u.uid=tt.uid)");
}