/[drupal]/contributions/modules/mapapi/mapapi.install
ViewVC logotype

Contents of /contributions/modules/mapapi/mapapi.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Mon Apr 30 03:41:38 2007 UTC (2 years, 6 months ago) by dmitrig01
Branch: MAIN
CVS Tags: DRUPAL-5--1-0-RC1, DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5
File MIME type: text/x-php
Initial commit of mapapi module.  This module is made for loading, saving, creating, and deleting maps, tiles on maps, and content on the tiles.  This module is authored by litwol and mitrig01.  It is simply an api, and will do nothing on it's own.  It is meant to be used in RPG-type games.  See http://groups.drupal.org/games-and-game-apis/
1 <?php
2 //added module name prefix to all tables
3 function mapapi_install(){
4 switch ($GLOBALS['db_type']){
5 case 'mysql':
6 case 'mysqli':
7 if(!db_query("CREATE TABLE `{mapapi_map_definition}` (
8 `mid` int(10) unsigned NOT NULL auto_increment,
9 `name` varchar(255) NOT NULL,
10 `limit_x` int(11) NOT NULL,
11 `limit_y` int(11) NOT NULL,
12 PRIMARY KEY (`mid`)
13 ) ENGINE=MyISAM")){
14 drupal_set_message("mapapi_map_definition did not install!", 'error');
15 }
16
17 if(!db_query("CREATE TABLE `{mapapi_tile_definition}` (
18 `tid` int(10) unsigned NOT NULL auto_increment,
19 `mid` int(10) unsigned NOT NULL,
20 `coord_x` int(10) unsigned NOT NULL,
21 `coord_y` int(10) unsigned NOT NULL,
22 `description` text,
23 PRIMARY KEY (`coord_x`,`coord_y`),
24 KEY `mid` (`mid`),
25 KEY `tid` (`tid`)
26 ) ENGINE=MyISAM")){
27 drupal_set_message("mapapi_tile_definition did not install!", 'error');
28 }
29
30 if(!db_query("CREATE TABLE `mapapi_tile_content` (
31 `tid` int(10) unsigned NOT NULL,
32 `mid` int(10) unsigned zerofill NOT NULL,
33 `content` text collate utf8_unicode_ci NOT NULL,
34 PRIMARY KEY (`tid`,`mid`)
35 ) ENGINE=MyISAM")){
36 drupal_set_message("mapapi_tile_content did not install!", 'error');
37 }
38 break;
39 }
40 drupal_set_message("MapAPI installed successfuly");
41 }
42
43 function mapapi_uninstall(){
44 if(!db_query("DROP TABLE `{mapapi_map_definition}`") ||
45 !db_query("DROP TABLE `{mapapi_tile_definition}`") ||
46 !db_query("DROP TABLE `{mapapi_tile_content}`") ||
47 !db_query("DELETE FROM `{sequences}` WHERE name like 'mapapi_%'")){
48
49 drupal_set_message("MapAPI did NOT uninstall successfuly", "error");
50 }
51 drupal_set_message("MapAPI uninstalled successfuly");
52 }

  ViewVC Help
Powered by ViewVC 1.1.2