function tokenauth_enable in Token authentication 6
Same name and namespace in other branches
- 6.2 tokenauth.install \tokenauth_enable()
- 7 tokenauth.install \tokenauth_enable()
Implementation of hook_enable().
File
- ./
tokenauth.install, line 48 - Install, update, and uninstall functions for tokenauth.
Code
function tokenauth_enable() {
// Assign tokens for each user.
$result = 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");
while ($row = db_fetch_object($result)) {
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)");
}