1 | <?php |
---|
2 | |
---|
3 | function plugin_install() |
---|
4 | { |
---|
5 | global $prefixeTable, $conf; |
---|
6 | |
---|
7 | $query = 'SHOW TABLES LIKE "' . $prefixeTable . 'additionalpages"'; |
---|
8 | $result = pwg_query($query); |
---|
9 | if (!mysql_fetch_row($result)) |
---|
10 | { |
---|
11 | $query = 'CREATE TABLE ' . $prefixeTable . 'additionalpages ( |
---|
12 | id SMALLINT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT, |
---|
13 | pos SMALLINT( 5 ) NULL default NULL , |
---|
14 | lang VARCHAR( 255 ) NULL default NULL , |
---|
15 | title VARCHAR( 255 ) NOT NULL , |
---|
16 | content LONGTEXT NOT NULL , |
---|
17 | users VARCHAR( 255 ) NULL DEFAULT NULL , |
---|
18 | groups VARCHAR( 255 ) NULL DEFAULT NULL , |
---|
19 | level TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT "0" , |
---|
20 | permalink VARCHAR( 64 ) NULL DEFAULT NULL , |
---|
21 | standalone ENUM( "true", "false" ) NOT NULL DEFAULT "false" , |
---|
22 | PRIMARY KEY (id) , |
---|
23 | INDEX (pos) , |
---|
24 | INDEX (lang)) |
---|
25 | DEFAULT CHARACTER SET utf8'; |
---|
26 | if ('mysql' == $conf['dblayer']) |
---|
27 | { |
---|
28 | $query .= ' ENGINE=MYISAM'; |
---|
29 | } |
---|
30 | pwg_query($query.';'); |
---|
31 | } |
---|
32 | |
---|
33 | if (!isset($conf['additional_pages'])) |
---|
34 | { |
---|
35 | $config = array( |
---|
36 | 'languages' => array('default' => 'Additional Pages'), |
---|
37 | 'show_home' => true, |
---|
38 | 'level_perm' => false, |
---|
39 | 'group_perm' => false, |
---|
40 | 'user_perm' => false, |
---|
41 | 'language_perm' => false, |
---|
42 | 'homepage' => null, |
---|
43 | ); |
---|
44 | |
---|
45 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
46 | VALUES ("additional_pages" , "'.pwg_db_real_escape_string(serialize($config)).'" , "Additional Pages configuration");'; |
---|
47 | pwg_query($query); |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | function plugin_activate() |
---|
52 | { |
---|
53 | global $prefixeTable; |
---|
54 | |
---|
55 | $q = pwg_query('SHOW COLUMNS FROM ' . HISTORY_TABLE . ' LIKE "section"'); |
---|
56 | $section = mysql_fetch_array($q); |
---|
57 | $type = $section['Type']; |
---|
58 | |
---|
59 | // Add additional page section into history table |
---|
60 | if (strpos($type, 'additional_page') === false) |
---|
61 | { |
---|
62 | $type = strtr($type , array(')' => ',\'additional_page\')')); |
---|
63 | pwg_query('ALTER TABLE ' . HISTORY_TABLE . ' CHANGE section section ' . $type . ' DEFAULT NULL'); |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | function plugin_uninstall() |
---|
68 | { |
---|
69 | global $prefixeTable, $conf; |
---|
70 | |
---|
71 | $q = 'DROP TABLE ' . $prefixeTable . 'additionalpages;'; |
---|
72 | pwg_query($q); |
---|
73 | |
---|
74 | $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="additional_pages" LIMIT 1;'; |
---|
75 | pwg_query($q); |
---|
76 | unset($conf['additional_pages']); |
---|
77 | } |
---|
78 | |
---|
79 | ?> |
---|