ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilWikiDBCreator.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
34 {
35 
36  static function createTables()
37  {
38  global $ilDB, $ilSetting;
39 
40  $wiki_db = $ilSetting->get("wiki_db");
41 
42  if ($wiki_db <= 0)
43  {
44  // wiki data
45  $q = "DROP TABLE IF EXISTS il_wiki_data";
46  $ilDB->query($q);
47 
48  $q = "CREATE TABLE il_wiki_data (
49  id int NOT NULL PRIMARY KEY,
50  startpage varchar(200) NOT NULL DEFAULT '',
51  short varchar(20) NOT NULL DEFAULT '',
52  online TINYINT DEFAULT 0
53  )";
54  $ilDB->query($q);
55 
56  $q = "DROP TABLE IF EXISTS il_wiki_page";
57  $ilDB->query($q);
58 
59  $q = "CREATE TABLE il_wiki_page (
60  id int AUTO_INCREMENT NOT NULL PRIMARY KEY,
61  title varchar(200) NOT NULL DEFAULT '',
62  wiki_id int NOT NULL
63  )";
64  $ilDB->query($q);
65 
66  $ilSetting->set("wiki_db", 1);
67  }
68 
69  //
70  if ($wiki_db == 1)
71  {
72  $q = "DROP TABLE IF EXISTS page_history";
73  $ilDB->query($q);
74  $q = "CREATE TABLE page_history (
75  page_id int NOT NULL DEFAULT 0,
76  parent_type varchar(4) NOT NULL DEFAULT '',
77  hdate datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
78  parent_id int,
79  content mediumtext,
80  PRIMARY KEY (page_id, parent_type, hdate)
81  )";
82  $ilDB->query($q);
83 
84  $ilSetting->set("wiki_db", 2);
85  }
86 
87  if ($wiki_db == 2)
88  {
89  $q = "ALTER TABLE page_object ADD COLUMN user int DEFAULT 0";
90  $ilDB->query($q);
91  $q = "ALTER TABLE page_history ADD COLUMN user int DEFAULT 0";
92  $ilDB->query($q);
93 
94  $ilSetting->set("wiki_db", 3);
95  }
96 
97  if ($wiki_db == 3)
98  {
99  $q = "DROP TABLE IF EXISTS page_history";
100  $ilDB->query($q);
101  $q = "CREATE TABLE page_history (
102  page_id int NOT NULL DEFAULT 0,
103  parent_type varchar(4) NOT NULL DEFAULT '',
104  hdate datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
105  parent_id int,
106  nr int,
107  user int,
108  content mediumtext,
109  PRIMARY KEY (page_id, parent_type, hdate)
110  )";
111  $ilDB->query($q);
112 
113  $ilSetting->set("wiki_db", 4);
114  }
115 
116  if ($wiki_db == 4)
117  {
118  $q = "ALTER TABLE page_object ADD COLUMN view_cnt int DEFAULT 0";
119  $ilDB->query($q);
120 
121  $ilSetting->set("wiki_db", 5);
122  }
123 
124  if ($wiki_db == 5)
125  {
126  $q = "ALTER TABLE page_object ADD COLUMN last_change TIMESTAMP";
127  $ilDB->query($q);
128  $q = "ALTER TABLE page_object ADD COLUMN created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'";
129  $ilDB->query($q);
130 
131  $ilSetting->set("wiki_db", 6);
132  }
133  }
134 }