![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: setup.php 40 2008-02-11 12:11:44Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/resources/setup.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 $config = array('mod_name' => 'Resources', 'mod_version' => '1.0.1', 'mod_directory' => 'resources', 'mod_setup_class' => 'SResource', 'mod_type' => 'user', 'mod_ui_name' => 'Resources', 'mod_ui_icon' => 'resources.png', 'mod_description' => '', 'permissions_item_table' => 'resources', 'permissions_item_field' => 'resource_id', 'permissions_item_label' => 'resource_name', 'mod_main_class' => 'CResource'); 7 8 if ($a == 'setup') { 9 echo w2PshowModuleConfig($config); 10 } 11 12 class SResource { 13 function install() { 14 $ok = true; 15 $q = new DBQuery; 16 $sql = '( 17 resource_id integer not null auto_increment, 18 resource_name varchar(255) not null default "", 19 resource_key varchar(64) not null default "", 20 resource_type integer not null default 0, 21 resource_note text not null default "", 22 resource_max_allocation integer not null default 100, 23 primary key (resource_id), 24 key (resource_name), 25 key (resource_type) 26 )'; 27 $q->createTable('resources', $sql); 28 $ok = $ok && $q->exec(); 29 $q->clear(); 30 31 $sql = '( 32 resource_type_id integer not null auto_increment, 33 resource_type_name varchar(255) not null default "", 34 resource_type_note text, 35 primary key (resource_type_id) 36 )'; 37 $q->createTable('resource_types', $sql); 38 $ok = $ok && $q->exec(); 39 $q->clear(); 40 41 $sql = '( 42 resource_id integer not null default 0, 43 task_id integer not null default 0, 44 percent_allocated integer not null default 100, 45 key (resource_id), 46 key (task_id, resource_id) 47 )'; 48 $q->createTable('resource_tasks', $sql); 49 $ok = $ok && $q->exec(); 50 $q->clear(); 51 $q->addTable('resource_types'); 52 $q->addInsert('resource_type_name', 'Equipment'); 53 $q->exec(); 54 $q->addInsert('resource_type_name', 'Tool'); 55 $q->exec(); 56 $q->addInsert('resource_type_name', 'Venue'); 57 $ok = $ok && $q->exec(); 58 59 if (!$ok) { 60 return false; 61 } 62 return null; 63 } 64 65 function remove() { 66 $q = new DBQuery; 67 $q->dropTable('resources'); 68 $q->exec(); 69 $q->clear(); 70 $q->dropTable('resource_tasks'); 71 $q->exec(); 72 $q->clear(); 73 $q->dropTable('resource_types'); 74 $q->exec(); 75 76 return null; 77 } 78 79 function upgrade($old_version) { 80 switch ($old_version) { 81 case '1.0': 82 $q = new DBQuery; 83 $q->addTable('resources'); 84 $q->addField('resource_key', 'varchar(64) not null default ""'); 85 $q->exec(); 86 if (db_error()) { 87 return false; 88 } 89 // FALLTHROUGH 90 case '1.0.1': 91 break; 92 } 93 return true; 94 } 95 } 96 97 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jan 8 03:00:03 2009 | Cross-referenced by PHPXref 0.7 |