View source
<?php
function tokenauth_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {tokenauth_tokens} (\n uid int(11) NOT NULL,\n token varchar(50) NOT NULL,\n PRIMARY KEY (token),\n UNIQUE KEY (uid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
}
$sql = 'SELECT uid FROM {users}';
$result = db_query($sql);
while ($row = db_fetch_object($result)) {
$sql = "INSERT INTO {tokenauth_tokens} (uid, token) VALUES (%d, '%s')";
db_query($sql, $row->uid, user_password());
}
}
function tokenauth_uninstall() {
db_query('DROP TABLE {tokenauth_tokens}');
variable_del('tokenauth_length');
variable_del('tokenauth_pages');
variable_del('tokenauth_reset');
}