public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
Made the drop tables function in the installer actually do something
Display the config file in a textarea if config.php can't be written (so 
they can upload it themselves)

Signed-off-by: Ted Kulp <ted@cmsmadesimple.org>


git-svn-id: http://svn.cmsmadesimple.org/svn/cmsmadesimple/trunk@4332 
3d254a34-79dc-0310-9e5f-be208747d8a0
tedkulp (author)
Sun Feb 03 20:08:14 -0800 2008
commit  f404033d7a45c19b2d906d0316276432b4e3aa2f
tree    baf22e6348034c0ac7ccd8af1092b650c8dbfd6d
parent  953a075f9720eba2de0ea039d32922c5bffe033f
...
177
178
179
 
 
180
181
 
182
183
184
185
186
 
187
188
189
190
 
191
192
193
...
177
178
179
180
181
182
 
183
184
185
186
187
 
188
189
190
191
192
193
194
195
196
0
@@ -177,17 +177,20 @@ function display_page($smarty, $action = '')
0
       $admin_account = $_SESSION['admin_account'];
0
       
0
       $user_created = false;
0
+ $config_created = false;
0
+ $config_file_contents = '';
0
       
0
- $installed = CmsInstallOperations::install_schema($connection['driver'], $connection['hostname'], $connection['username'], $connection['password'], $connection['dbname'], $connection['table_prefix']);
0
+ $installed = CmsInstallOperations::install_schema($connection['driver'], $connection['hostname'], $connection['username'], $connection['password'], $connection['dbname'], $connection['table_prefix'], $connection['drop_tables']);
0
       if ($installed)
0
       {
0
         $basic_loaded = CmsInstallOperations::load_basic_schema($connection['driver'], $connection['hostname'], $connection['username'], $connection['password'], $connection['dbname'], $connection['table_prefix']);
0
         $user_created = CmsInstallOperations::install_account($connection['driver'], $connection['hostname'], $connection['username'], $connection['password'], $connection['dbname'], $connection['table_prefix'], $admin_account['username'], $admin_account['password']);
0
- $config_created = CmsInstallOperations::install_config($connection,$_SESSION['config']);
0
+ $config_created = CmsInstallOperations::install_config($connection,$_SESSION['config'], $config_file_contents);
0
       }  
0
       $smarty->assign('installed', $installed);
0
       $smarty->assign('user_created', $user_created);
0
       $smarty->assign('config_created', $config_created);
0
+ $smarty->assign('config_file_contents', $config_file_contents);
0
       $smarty->assign('include_file', 'create_schema.tpl');
0
       $smarty->display('body.tpl');
0
     
...
42
43
44
 
 
 
 
 
 
 
 
45
46
47
...
201
202
203
204
 
205
206
207
...
225
226
227
228
 
229
230
 
231
232
233
 
234
235
236
...
242
243
244
 
 
 
 
245
246
247
...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
...
209
210
211
 
212
213
214
215
...
233
234
235
 
236
237
 
238
239
240
 
241
242
243
244
...
250
251
252
253
254
255
256
257
258
259
0
@@ -42,6 +42,14 @@ class CmsInstallOperations extends CmsObject
0
     $dbdict->ExecuteSQLArray($sqlarray);
0
   }
0
   
0
+ static function drop_table($db, $table)
0
+ {
0
+ $dbdict = NewDataDictionary($db);
0
+
0
+ $sqlarray = $dbdict->DropTableSQL(CmsDatabase::get_prefix().$table);
0
+ $dbdict->ExecuteSQLArray($sqlarray);
0
+ }
0
+
0
   static function get_action()
0
   {
0
     $value = CmsRequest::get('action');
0
@@ -201,7 +209,7 @@ class CmsInstallOperations extends CmsObject
0
     return false;
0
   }
0
   
0
- static function install_config($conn,$url)
0
+ static function install_config($conn,$url,&$file_data)
0
   {
0
     //Get an instance of CMSConfig(we need a list of all the variables plus defaults)
0
     $config = CmsConfig::get_instance();
0
@@ -225,12 +233,12 @@ class CmsInstallOperations extends CmsObject
0
     //Generate the file
0
     $file_data = "<?php\n";
0
     $file_data .= $config->config_text($config_data);
0
- $file_data .= "?>";
0
+ $file_data .= "\n?>";
0
     //Write the file
0
- return file_put_contents(CONFIG_FILE_LOCATION,$file_data) > 0;
0
+ return @file_put_contents(CONFIG_FILE_LOCATION,$file_data) > 0;
0
   }
0
   
0
- static function install_schema($driver = '', $hostname = '', $username = '', $password = '', $dbname = '', $prefix = '')
0
+ static function install_schema($driver = '', $hostname = '', $username = '', $password = '', $dbname = '', $prefix = '', $drop_tables = false)
0
   {
0
     $drivers = self::get_loaded_database_modules();
0
     $driver = $drivers[$driver];
0
@@ -242,6 +250,10 @@ class CmsInstallOperations extends CmsObject
0
       {
0
         try
0
         {
0
+ if ($drop_tables)
0
+ {
0
+ include_once(cms_join_path(dirname(dirname(__FILE__)), 'schemas', 'droptables.php'));
0
+ }
0
           include_once(cms_join_path(dirname(dirname(__FILE__)), 'schemas', 'schema.php'));
0
           return true;
0
         }
...
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
3
4
...
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -1,4 +1,22 @@
0
-<?php
0
+<?php // -*- mode:php; tab-width:4; indent-tabs-mode:t; c-basic-offset:4; -*-
0
+#CMS - CMS Made Simple
0
+#(c)2004-2008 by Ted Kulp (ted@cmsmadesimple.org)
0
+#This project's homepage is: http://cmsmadesimple.org
0
+#
0
+#This program is free software; you can redistribute it and/or modify
0
+#it under the terms of the GNU General Public License as published by
0
+#the Free Software Foundation; either version 2 of the License, or
0
+#(at your option) any later version.
0
+#
0
+#This program is distributed in the hope that it will be useful,
0
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
0
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0
+#GNU General Public License for more details.
0
+#You should have received a copy of the GNU General Public License
0
+#along with this program; if not, write to the Free Software
0
+#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0
+#
0
+#$Id$
0
 
0
 CmsInstallOperations::create_table($db, 'additional_users', "
0
   id I KEY AUTO,
...
6
7
8
 
9
10
11
...
6
7
8
9
10
11
12
0
@@ -6,6 +6,7 @@
0
     <p>{tr}The config file was created.{/tr}</p>
0
   {else}
0
     <p>{tr}The config file could not be created{/tr}</p>
0
+ <textarea rows="25" cols="80">{$config_file_contents}</textarea>
0
   {/if}
0
   {else}
0
     <p>{tr}The user account could not be created.{/tr}</p>

Comments

    No one has commented yet.