CVS update: /cowiki/htdocs/setup/class/task/

[email protected] 29 Apr 2005 22:45:19 -0000
Newsgroups gmane.comp.php.cowiki.cvs
Message-ID <[email protected]>
User: dgorski 
Date: 2005/04/29 15:45:19

Modified:
   cowiki/htdocs/setup/class/task/class.TaskFinish.php

Log:
 Store data to the core.conf file and "seal" the installation

File Changes:

Directory: /cowiki/htdocs/setup/class/task/
===========================================

File [changed]: class.TaskFinish.php
Url: http://cowiki.tigris.org/source/browse/cowiki/htdocs/setup/class/task/class.TaskFinish.php?r1=1.1&r2=1.2
Delta lines:  +175 -27
----------------------
--- class.TaskFinish.php	21 Apr 2005 00:17:14 -0000	1.1
+++ class.TaskFinish.php	29 Apr 2005 22:45:17 -0000	1.2
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.TaskFinish.php,v 1.1 2005/04/21 00:17:14 dgorski Exp $
+ * $Id: class.TaskFinish.php,v 1.2 2005/04/29 22:45:17 dgorski Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -17,7 +17,7 @@
  * @author      Daniel T. Gorski, <[email protected]>
  * @copyright   (C) Daniel T. Gorski, {@link http://www.develnet.org}
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.1 $
+ * @version     $Revision: 1.2 $
  *
  */
 
@@ -39,6 +39,7 @@
     public function __construct($Tpl) {
         parent::__construct($Tpl);
         parent::checkValidUser();
+        parent::loadClassLoader();
     }
 
     // --------------------------------------------------------------------
@@ -64,17 +65,23 @@
         $sHtDocs = $this->State->getHtdocsPath();
         $sIncludes = $this->State->getIncludesPath();
     
-        $sStr = '<b>Congratulation, the '.COWIKI_FULL_IDENT.' installation
-                 setup has been cleanly finished. Everything seems to be
-                 updated and seems to work properly.</b>
+        // Store the data we gathered to the configuration file
+        try {
+            $this->storeConfigSettings();
+            $this->sealInstallation();
+
+            $sStr = '<b>Congratulation, the '.COWIKI_FULL_IDENT.'
+                     installation setup has been cleanly finished.
+                     Everything seems to be updated and seems to work
+                     properly.</b>
                  <br/><br/>
 
                  All setting has been saved in the configuration file
                  (<tt>core.conf</tt>) that is located in
-                 <tt>'.$sIncludes.'/</tt> and your installation has been
-                 sealed. Please <i>do not remove</i> the
-                 control <tt>install.seal</tt> file that has been created
-                 in the <tt>'.$sHtDocs.'/</tt> directory!
+                     <tt>'.$sIncludes.'/</tt> and your installation has
+                     been sealed. Please <i>do not remove</i> the
+                     control <tt>install.seal</tt> file that has been
+                     created in the <tt>'.$sHtDocs.'/</tt> directory!
                  <br/><br/>
 
                  Thank you for the interest in this sofware. If you
@@ -87,8 +94,13 @@
                  <center>
                     <input type="submit" class="submit" name="submit"
                     value="'.self::STRING_FINISH_AND_LAUNCH.'">
-                 </center>
-        ';
+                     </center>';
+
+        } catch (IOException $ioe) {
+            $sStr = '<b class="warn">';
+            $sStr .=  'Error: '.$ioe->getMessage();
+            $sStr .= '</b>';   
+        }
 
         $sStr .=  '<br/><br/>';
 
@@ -99,6 +111,142 @@
         $this->Tpl->assign('MESSAGE', $this->getMsgQueueFormatted());
 
         echo $this->Tpl->parse(SETUP_PATH.'/tpl/window.default.tpl');
+    }
+
+    // --------------------------------------------------------------------
+
+    private function storeConfigSettings() {
+        $Conf = $this->getConfig();
+
+        // [ABOUT] section
+        $Conf->setSectionKeyValue(
+            'ABOUT', 'TITLE', $this->State->getAboutTitle()
+        );
+        $Conf->setSectionKeyValue(
+            'ABOUT', 'DESCRIPTION', $this->State->getAboutDescription()
+        );
+
+        // ----------------------------------------------------------------
+
+        // [SOFTWARE] section
+        $Conf->setSectionKeyValue(
+            'SOFTWARE', 'DEBUG_LEVEL', $this->State->getDebugLevelString()
+        );
+
+        // ----------------------------------------------------------------
+
+        // [MAIL] section
+        $Conf->setSectionKeyValue(
+            'MAIL', 'FULL_NAME', $this->State->getMailFullName()
+        );
+        $Conf->setSectionKeyValue(
+            'MAIL', 'RETURN_PATH', $this->State->getMailReturnPath()
+        );
+        $Conf->setSectionKeyValue(
+            'MAIL', 'ABUSE_PATH', $this->State->getMailAbusePath()
+        );
+
+        // ----------------------------------------------------------------
+
+        // [.DOCUMENT] section
+        $Conf->setSectionKeyValue(
+            '.DOCUMENT', 'RESOURCE', $this->getDsnResource('.DOCUMENT')
+        );
+
+        // ----------------------------------------------------------------
+
+        // [.AUTH] section
+        // FIX: This is not supported yet, we take over the values of the
+        // [.DOCUMENT] RESOURCE
+        $Conf->setSectionKeyValue(
+            '.AUTH', 'RESOURCE',
+            $Conf->getSectionKeyValue('.DOCUMENT', 'RESOURCE')
+        );
+        $Conf->setSectionKeyValue('.AUTH', 'ENCRYPTION', 'CRYPT');
+        $Conf->setSectionKeyValue(
+            '.AUTH', 'ROOT_PASSWD',
+            crypt($this->State->getRootUserPassword())
+        );
+
+        // ----------------------------------------------------------------
+
+        // [.USER] section
+        // FIX: This is not supported yet, we take over the values of the
+        // [.DOCUMENT] RESOURCE
+        $Conf->setSectionKeyValue(
+            '.USER', 'RESOURCE',
+            $Conf->getSectionKeyValue('.DOCUMENT', 'RESOURCE')
+        );
+
+        // ----------------------------------------------------------------
+
+        // [RUNTIME] section
+        $Conf->setSectionKeyValue(
+            'RUNTIME', 'LANGUAGE_LOCALE', $this->State->getLanguageLocale()
+        );
+        $Conf->setSectionKeyValue(
+            'RUNTIME', 'TEMPLATE_ACTIVE', $this->State->getTemplateActive()
+        );
+
+        $Conf->setSectionKeyValueBoolean(
+            'RUNTIME', 'EMAIL_OBFUSCATE', $this->State->hasEmailObfuscation()
+        );
+
+        $sConfigFile = $this->State->getIncludesPath() . '/core.conf';
+        $Conf->store($sConfigFile);
+    }
+
+    // --------------------------------------------------------------------
+
+    private function sealInstallation() {
+
+        $sSealName = $this->State->getHtdocsPath() . '/install.seal';
+        $sPendName = $this->State->getHtdocsPath() . '/install.pending';
+
+        $sContent =   'DO NOT delete or modify this file manually!' . "\n";
+        $sContent .=  'Sealed: '. date('Ymd') . "\n";
+        
+        try {
+            $Out = new FileOutputStream($sSealName);
+            $Out->write($sContent);
+            $Out->close();
+
+            @unlink($sPendName);
+
+        } catch (IOException $ioe) {
+            throw new ConfigNotWritableException(
+                'Could not write configuration file '.basename($sSealName)
+            );
+        }
+
+    }
+
+    // --------------------------------------------------------------------
+
+    // Assemble DSN path
+    private function getDsnResource($sType = null) {
+        if ($sType == null) {
+            throw new ConfigSyntaxException('Unknown DSN resource.');
+        }
+
+        $sStr = 'illegal';
+
+        if ($sType == '.DOCUMENT') {
+        
+            $sStr = $this->State->getDocStorageScheme() . '://';
+            $sStr .=  $this->State->getDocStorageConnectorUser();
+            $sStr .=  ':';
+            $sStr .=  $this->State->getDocStorageConnectorPassword();
+            $sStr .=  '@';
+            $sStr .=  $this->State->getDocHost();
+            if ($this->State->getDocHostPort() != '') {
+                $sStr .= ':' . $this->State->getDocHostPort();
+            }
+            $sStr .=  '/';
+            $sStr .=  $this->State->getDocDatabaseName();        
+        }
+
+        return $sStr;
     }
 
 } // of class