-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.php
111 lines (100 loc) · 3.2 KB
/
setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php /* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
/*
* Name: Documentation
* Directory: documentation
* Version: 0.2
* Class: CDocumentation
* UI Name: Documentation
* UI Icon:
*/
// MODULE CONFIGURATION DEFINITION
$config = array();
$config['mod_name'] = 'Documentation';
$config['mod_version'] = '0.2';
$config['mod_directory'] = 'documentation';
$config['mod_setup_class'] = 'CSetupDocumentation';
$config['mod_type'] = 'user';
$config['mod_ui_name'] = 'Documentation';
$config['mod_ui_icon'] = 'documentation.png';
$config['mod_description'] = $AppUI->_('A module for documentation of project');
$config['permissions_item_table'] = 'wikipages';
$config['permissions_item_field'] = 'wikipage_id';
$config['permissions_item_label'] = 'wikipage_name';
$config['mod_main_class'] = 'CDocumentation';
$config['mod_config'] = true;
if ($a == 'setup') {
echo w2PshowModuleConfig($config);
}
class CSetupDocumentation {
/*
* Install routine
*/
public function install() {
global $AppUI;
$q = new w2p_Database_Query();
$q->createTable('wikipages');
$q->createDefinition('(
wikipage_id int(10) unsigned NOT NULL auto_increment,
wikipage_date datetime NOT NULL default \'0000-00-00 00:00:00\',
wikipage_user int(10) NOT NULL default \'0\',
wikipage_start tinyint(1) NOT NULL default \'0\',
wikipage_locked tinyint(1) NOT NULL default \'0\',
wikipage_parser varchar(10),
wikipage_namespace varchar(50) NOT NULL DEFAULT \'\',
wikipage_name varchar(255),
wikipage_lang varchar(5) NOT NULL default \'en\',
wikipage_title varchar(255),
wikipage_content text,
wikipage_categorylinks text,
PRIMARY KEY (wikipage_id),
UNIQUE KEY wikipage_name_key (wikipage_namespace, wikipage_name),
INDEX (wikipage_namespace, wikipage_start)
) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci
');
$q->exec();
$q->clear();
if (db_error()) return false;
$perms = $AppUI->acl();
return $perms->registerModule('Documentation', 'documentation');
}
/*
* Removal routine
*/
public function remove() {
global $AppUI;
$q = new w2p_Database_Query;
$q->dropTable('wikipages');
$q->exec();
$q->clear();
if (db_error()) return false;
$perms = $AppUI->acl();
return $perms->unregisterModule('documentation');
}
/*
* Upgrade routine
*/
public function upgrade()
{
switch ($old_version) {
case '0.1':
$q = new w2p_Database_Query();
$q->alterTable('wikipages');
$q->createDefinition('wikipage_categorylinks text after wikipage_content');
$q->exec();
return true;
default:
}
return false;
}
/*
* configure routine
*/
public function configure() {
global $AppUI;
$AppUI->redirect('m=documentation&a=configure');
return true;
}
}