| 1 |
<?php
|
| 2 |
// $Id: arcade.install,v 1.2 2009/04/09 02:49:44 matt2000 Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install().
|
| 6 |
*/
|
| 7 |
function arcade_install() {
|
| 8 |
drupal_install_schema('arcade');
|
| 9 |
}
|
| 10 |
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Implementation of hook_uninstall
|
| 14 |
*/
|
| 15 |
function arcade_uninstall() {
|
| 16 |
drupal_uninstall_schema('arcade');
|
| 17 |
db_query("DELETE FROM {blocks} WHERE module = 'arcade'");
|
| 18 |
db_query("DELETE FROM {variable} WHERE name LIKE 'arcade%'");
|
| 19 |
}
|
| 20 |
|
| 21 |
|
| 22 |
/**
|
| 23 |
* Schema definition for Flashgames
|
| 24 |
*/
|
| 25 |
function arcade_schema() {
|
| 26 |
$schema['arcade_data'] = array(
|
| 27 |
'description' => t('Stores user highscores for flash games.'),
|
| 28 |
'fields' => array(
|
| 29 |
'nid' => array(
|
| 30 |
'description' => t('{node}.nid for the game node.'),
|
| 31 |
'type' => 'int',
|
| 32 |
'unsigned' => TRUE,
|
| 33 |
'not null' => TRUE,
|
| 34 |
),
|
| 35 |
'uid' => array(
|
| 36 |
'description' => t('UID of player achieving this score.'),
|
| 37 |
'type' => 'int',
|
| 38 |
'unsigned' => TRUE,
|
| 39 |
'not null' => TRUE,
|
| 40 |
),
|
| 41 |
'score' => array(
|
| 42 |
'description' => t('Player\'s score for this game.'),
|
| 43 |
'type' => 'varchar',
|
| 44 |
'length' => 31,
|
| 45 |
'not null' => FALSE,
|
| 46 |
),
|
| 47 |
'gamedata' => array(
|
| 48 |
'description' => t('Saved Game Data.'),
|
| 49 |
'type' => 'text',
|
| 50 |
'size' => 'big',
|
| 51 |
'not null' => FALSE,
|
| 52 |
),
|
| 53 |
'date' => array(
|
| 54 |
'description' => t('Time score achieved'),
|
| 55 |
'type' => 'datetime',
|
| 56 |
'not null' => TRUE,
|
| 57 |
),
|
| 58 |
),
|
| 59 |
'primary key' => array('nid', 'uid'),
|
| 60 |
);
|
| 61 |
|
| 62 |
$schema['arcade_games'] = array(
|
| 63 |
'description' => t('Store settings for game nodes.'),
|
| 64 |
'fields' => array(
|
| 65 |
'nid' => array(
|
| 66 |
'description' => t('{node}.nid for the game node.'),
|
| 67 |
'type' => 'int',
|
| 68 |
'unsigned' => TRUE,
|
| 69 |
'not null' => TRUE,
|
| 70 |
),
|
| 71 |
'game_type' => array(
|
| 72 |
'description' => t('1: high score wins, 2: low score wins, 3: high time wins, 4: low time wins'),
|
| 73 |
'type' => 'int',
|
| 74 |
'length' => 1,
|
| 75 |
'unsigned' => TRUE,
|
| 76 |
'not null' => TRUE,
|
| 77 |
),
|
| 78 |
'game_path' => array(
|
| 79 |
'description' => t('Path to game files.'),
|
| 80 |
'type' => 'varchar',
|
| 81 |
'length' => '255',
|
| 82 |
'not null' => FALSE,
|
| 83 |
),
|
| 84 |
'secure' => array(
|
| 85 |
'description' => t('Use secure mode?'),
|
| 86 |
'type' => 'int',
|
| 87 |
'length' => 1,
|
| 88 |
'unsigned' => TRUE,
|
| 89 |
'not null' => FALSE,
|
| 90 |
),
|
| 91 |
),
|
| 92 |
'primary key' => array('nid'),
|
| 93 |
);
|
| 94 |
|
| 95 |
$schema['arcade_keys'] = array(
|
| 96 |
'description' => t('Store security keys to curb cheating.'),
|
| 97 |
'fields' => array(
|
| 98 |
'nid' => array(
|
| 99 |
'description' => t('{node}.nid for the game node.'),
|
| 100 |
'type' => 'int',
|
| 101 |
'unsigned' => TRUE,
|
| 102 |
'not null' => TRUE,
|
| 103 |
),
|
| 104 |
'uid' => array(
|
| 105 |
'description' => t('{user}.uid for the player'),
|
| 106 |
'type' => 'int',
|
| 107 |
'unsigned' => TRUE,
|
| 108 |
'not null' => TRUE,
|
| 109 |
),
|
| 110 |
'token' => array(
|
| 111 |
'description' => t('a security token'),
|
| 112 |
'type' => 'varchar',
|
| 113 |
'length' => '32',
|
| 114 |
'not null' => TRUE,
|
| 115 |
),
|
| 116 |
'key' => array(
|
| 117 |
'description' => t('salted MD5 hash for game instance'),
|
| 118 |
'type' => 'varchar',
|
| 119 |
'length' => '32',
|
| 120 |
'not null' => TRUE,
|
| 121 |
),
|
| 122 |
'timestamp' => array(
|
| 123 |
'description' => t('timestamp for game instance'),
|
| 124 |
'type' => 'int',
|
| 125 |
'unsigned' => TRUE,
|
| 126 |
'not null' => TRUE,
|
| 127 |
),
|
| 128 |
),
|
| 129 |
'primary key' => array('nid'),
|
| 130 |
'unique keys' => array(
|
| 131 |
'nid_uid' => array('nid','uid'),
|
| 132 |
),
|
| 133 |
);
|
| 134 |
return $schema;
|
| 135 |
}
|
| 136 |
|
| 137 |
// add 'secure' column to DB
|
| 138 |
function arcade_update_6100() {
|
| 139 |
$ret = array();
|
| 140 |
db_add_field($ret, 'arcade_games', 'secure', array('type' => 'int', 'length' => 1, 'unsigned' => TRUE, 'not null' => FALSE));
|
| 141 |
$schema = arcade_schema();
|
| 142 |
$new_table = $schema['arcade_keys'];
|
| 143 |
db_create_table($ret, 'arcade_keys', $new_table);
|
| 144 |
return $ret;
|
| 145 |
}
|