r1413: Fixing the installer to allow settings to actually be inserted into the database
authorRobert Sesek <rsesek@bluestatic.org>
Fri, 16 Feb 2007 06:52:29 +0000 (06:52 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Fri, 16 Feb 2007 06:52:29 +0000 (06:52 +0000)
docs/datatools.php
install/install.php
install/settings.php [new file with mode: 0644]

index 3a893051d57616500531398f0897d979bf1193b0..4fe972ad430c85c2e4e4ddf733a0f5712aae73cf 100644 (file)
@@ -48,7 +48,7 @@ $THELIST = array(
 
 Here you can either export or import the standard data tables for Bugdar. These include things such as usergroups, priorities, etc.
 
-<h3>[<strong><a href="datatools.php?do=export">Export</a></strong>] [<strong><a href="datatools.php?do=import">Import</a></strong>] [<strong><a href="datatools.php?do=view">View</a></strong>]</h3>
+<h3>[<strong><a href="datatools.php?do=export">Export</a></strong>] [<strong><a href="datatools.php?do=import">Import</a></strong>] [<strong><a href="datatools.php?do=view">View</a></strong>] [<strong><a href="datatools.php?do=settings">Dump Settings</a></strong>]</h3>
 
 <hr />
 
@@ -165,4 +165,59 @@ if ($_REQUEST['do'] == 'view')
        echo '<textarea style="height: 500px; width: 100%">' . htmlspecialchars($build) . '</textarea>';
 }
 
+// ###################################################################
+
+if ($_REQUEST['do'] == 'settings')
+{
+       $fout = <<<FILE
+<?php
+/*=====================================================================*
+|| ###################################################################
+|| # Bugdar [#]version[#]
+|| # Copyright ©2002-[#]year[#] Blue Static
+|| #
+|| # This program is free software; you can redistribute it and/or modify
+|| # it under the terms of the GNU General Public License as published by
+|| # the Free Software Foundation; version [#]gpl[#] of the License.
+|| #
+|| # This program is distributed in the hope that it will be useful, but
+|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+|| # more details.
+|| #
+|| # You should have received a copy of the GNU General Public License along
+|| # with this program; if not, write to the Free Software Foundation, Inc.,
+|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+|| ###################################################################
+\*=====================================================================*/
+
+// this stores all the settings for a new installation
+
+\$settings = array(
+FILE;
+       
+       $settings = $db->query("SELECT * FROM " . TABLE_PREFIX . "setting");
+       while ($setting = $db->fetch_array($settings))
+       {
+               $fout .= "\n\t'$setting[varname]' => '" . str_replace("'", "\'", $setting['value']) . "',";
+       }
+       
+       $fout .= <<<FILE
+
+);
+
+/*=====================================================================*
+|| ###################################################################
+|| # \$HeadURL: \$
+|| # \$Id: \$
+|| ###################################################################
+\*=====================================================================*/
+?>
+FILE;
+       
+       file_put_contents('install/settings.php', $fout);
+       
+       echo 'Dumping current settings into install/settings.php';
+}
+
 ?>
\ No newline at end of file
index 6583ba84ec58ffcf92c607f8267ba4290456edf2..3a2e6cdd20631b00432eeb8ce0debe9ea35752b6 100644 (file)
@@ -106,19 +106,11 @@ if ($bugsys->in['mark'] == 3)
 
 <?php
        
-       // TODO - fix the way we insert default settings
-       require_once('./includes/settings.php');
+       require_once('./install/settings.php');
        
-       foreach ($settings AS $group => $sgroup)
+       foreach ($settings AS $key => $value)
        {
-               foreach ($sgroup AS $varname => $setting)
-               {
-                       if (!is_array($setting))
-                       {
-                               continue;
-                       }
-                       $db->query("INSERT INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('" . $varname . "', '" . addslashes($setting[1]) . "')");
-               }
+               $db->query("INSERT INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('" . $key . "', '" . $db->escape_string($value) . "')");
        }
        
        echo 'Settings loaded...';
diff --git a/install/settings.php b/install/settings.php
new file mode 100644 (file)
index 0000000..0e6d2d2
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+/*=====================================================================*
+|| ###################################################################
+|| # Bugdar [#]version[#]
+|| # Copyright ©2002-[#]year[#] Blue Static
+|| #
+|| # This program is free software; you can redistribute it and/or modify
+|| # it under the terms of the GNU General Public License as published by
+|| # the Free Software Foundation; version [#]gpl[#] of the License.
+|| #
+|| # This program is distributed in the hope that it will be useful, but
+|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+|| # more details.
+|| #
+|| # You should have received a copy of the GNU General Public License along
+|| # with this program; if not, write to the Free Software Foundation, Inc.,
+|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+|| ###################################################################
+\*=====================================================================*/
+
+// this stores all the settings for a new installation
+
+$settings = array(
+       'allownewreg' => '1',
+       'verifyemail' => '1',
+       'moderatenewusers' => '0',
+       'webmasteremail' => 'noreply@bluestatic.org',
+       'trackertitle' => 'Avalon Development Tracker',
+       'trackerversion' => '[#]version[#]',
+       'defaultcomment' => '',
+       'sendwelcomemail' => '1',
+       'allowhtml' => '0',
+       'allowrawhtml' => '0',
+       'allowsafehtml' => '1',
+       'defaultseverity' => '2',
+       'defaultpriority' => '3',
+       'defaultstatus' => '1',
+       'defaultresolve' => '1',
+       'defaultassign' => '0',
+       'dateformat' => 'F j, Y h:i:s A',
+       'defaultpp' => '20',
+       'maxpp' => '100',
+       'pagelinks' => '2',
+       'trackerurl' => 'http://localhost/bugtrack',
+       'defaultlanguage' => '1',
+       'syndicateditems' => '10',
+       'hidestatuses' => '0',
+       'defaultsortkey' => 'lastpost',
+       'defaultsortas' => 'desc',
+       'defaulttimezone' => '0',
+       'columnoptions' => 'a:12:{s:5:"bugid";s:1:"1";s:7:"summary";s:1:"2";s:6:"userid";s:1:"2";s:7:"product";s:1:"3";s:9:"component";s:1:"0";s:7:"version";s:1:"3";s:6:"status";s:1:"4";s:10:"resolution";s:1:"4";s:8:"priority";s:1:"5";s:8:"severity";s:1:"5";s:8:"lastpost";s:1:"6";s:5:"votes";s:1:"0";}',
+       'redirectheaders' => '0',
+);
+
+/*=====================================================================*
+|| ###################################################################
+|| # $HeadURL$
+|| # $Id$
+|| ###################################################################
+\*=====================================================================*/
+?>
\ No newline at end of file