]> git.agnieray.net Git - galette.git/commitdiff
Add SQLite database; fixes #482
authorbohwaz <bohwaz@bohwaz.net>
Thu, 10 Jan 2013 15:52:34 +0000 (02:52 +1100)
committerJohan Cwiklinski <johan@x-tnd.be>
Fri, 11 Jan 2013 13:50:45 +0000 (14:50 +0100)
galette/config/config.inc.php.dist
galette/config/paths.inc.php
galette/docs/INSTALL
galette/install/index.php
galette/install/sql/sqlite.sql [new file with mode: 0644]
galette/lib/Galette/Common/ClassLoader.php
galette/lib/Galette/Core/CheckModules.php
galette/lib/Galette/Core/Db.php

index d618c911390bc008798630471f33da327921af32..3f9f3f2da07456e26dba0932ddd42b0863e03815 100644 (file)
@@ -7,7 +7,7 @@ You can then copy the file in GALETTE_CONFIG_PATH/config.inc.php
 $Id$
 */
 
-/* choose your database engine, values : pgsql|mysql */
+/* choose your database engine, values : pgsql|mysql|sqlite */
 define("TYPE_DB", "pgsql"); 
 /* hostname for the database */
 define("HOST_DB", "localhost"); 
index 2a7013b6b7d50b452426ffc700c1b64f13b8ddc6..f7e15ecb9c08a9963e3153551db1466a8cd9bb7d 100644 (file)
@@ -88,3 +88,9 @@ if ( !defined('GALETTE_PHOTOS_PATH') ) {
 if ( !defined('GALETTE_TEMPIMAGES_PATH') ) {
     define('GALETTE_TEMPIMAGES_PATH', GALETTE_ROOT . 'tempimages/');
 }
+if ( !defined('GALETTE_DATA_PATH') ) {
+    define('GALETTE_DATA_PATH', GALETTE_ROOT . 'data/');
+}
+if ( !defined('GALETTE_SQLITE_PATH') ) {
+    define('GALETTE_SQLITE_PATH', GALETTE_DATA_PATH . 'database.sqlite');
+}
index 6da2154a359e806ca04988ca097cada4d66c18b0..f0039d684e3365f123acfaab67ad212f9d4246cb 100644 (file)
@@ -4,7 +4,7 @@ Dependencies
 - Apache 2 Webserver,
 - PHP 5.3 minimum (also tested on php 5.4);,
 - MySQL 5 or Postgresl (tested on Mysql 5.5.20 and postgresql 9.2.1),
-  and its php driver,
+  and its php driver or SQLite 3.x php driver,
 - php gd extension,
 - php curl extension,
 - SSL supported enabled,
index 54084bc8140ebb8e68d22eb414c57b9d51e1d545..d9d87024b0522ac1200608bd75a3785e5c70b1f3 100644 (file)
@@ -80,42 +80,44 @@ if ( $error_detected == '' && isset($_POST['install_permsok']) ) {
 
 if ( $error_detected == ''
     && isset($_POST['install_dbtype'])
-    && isset($_POST['install_dbhost'])
-    && isset($_POST['install_dbport'])
-    && isset($_POST['install_dbuser'])
-    && isset($_POST['install_dbpass'])
-    && isset($_POST['install_dbname'])
-    && isset($_POST['install_dbprefix'])
 ) {
     if ( $_POST['install_dbtype'] != 'mysql'
         && $_POST['install_dbtype'] != 'pgsql'
+        && $_POST['install_dbtype'] != 'sqlite'
     ) {
             $error_detected .= '<li>' . _T("Database type unknown") . '</li>';
     }
-    if ( $_POST['install_dbhost'] == '' ) {
-        $error_detected .= '<li>' . _T("No host") . '</li>';
-    }
-    if ( $_POST['install_dbport'] == '' ) {
-        $error_detected .= '<li>' . _T("No port") . '</li>';
-    }
-    if ( $_POST['install_dbuser'] == '' ) {
-        $error_detected .= '<li>' . _T("No user name") . '</li>';
-    }
-    if ( $_POST['install_dbpass'] == '' ) {
-        $error_detected .= '<li>' . _T("No password") . '</li>';
-    }
-    if ( $_POST['install_dbname'] == '' ) {
-            $error_detected .= '<li>' . _T("No database name") . '</li>';
+
+    if ($_POST['install_dbtype'] != 'sqlite') {
+        if ( empty($_POST['install_dbhost']) ) {
+            $error_detected .= '<li>' . _T("No host") . '</li>';
+        }
+        if ( empty($_POST['install_dbport']) ) {
+            $error_detected .= '<li>' . _T("No port") . '</li>';
+        }
+        if ( empty($_POST['install_dbuser']) ) {
+            $error_detected .= '<li>' . _T("No user name") . '</li>';
+        }
+        if ( empty($_POST['install_dbpass']) ) {
+            $error_detected .= '<li>' . _T("No password") . '</li>';
+        }
+        if ( empty($_POST['install_dbname']) ) {
+                $error_detected .= '<li>' . _T("No database name") . '</li>';
+        }
     }
+
     if ($error_detected == '') {
         if ( isset($_POST['install_dbconn_ok']) ) {
 
             define('TYPE_DB', $_POST['install_dbtype']);
-            define('USER_DB', $_POST['install_dbuser']);
-            define('PWD_DB', $_POST['install_dbpass']);
-            define('HOST_DB', $_POST['install_dbhost']);
-            define('PORT_DB', $_POST['install_dbport']);
-            define('NAME_DB', $_POST['install_dbname']);
+
+            if (TYPE_DB != 'sqlite') {
+                define('USER_DB', $_POST['install_dbuser']);
+                define('PWD_DB', $_POST['install_dbpass']);
+                define('HOST_DB', $_POST['install_dbhost']);
+                define('PORT_DB', $_POST['install_dbport']);
+                define('NAME_DB', $_POST['install_dbname']);
+            }
 
             $zdb = new Galette\Core\Db();
 
@@ -596,39 +598,42 @@ case 'u4':
                         <select name="install_dbtype" id="install_dbtype">
                             <option value="mysql"<?php if ( isset($_POST['install_dbtype']) && $_POST['install_dbtype'] == 'mysql' ) {echo ' selected="selected"';} ?>>Mysql</option>
                             <option value="pgsql"<?php if ( isset($_POST['install_dbtype']) && $_POST['install_dbtype'] == 'pgsql' ) {echo ' selected="selected"';} ?>>Postgresql</option>
+                            <option value="sqlite"<?php if ( isset($_POST['install_dbtype']) && $_POST['install_dbtype'] == 'sqlite' ) {echo ' selected="selected"';} ?>>SQLite</option>
                         </select>
                     </p>
-                    <p>
-                        <label class="bline" for="install_dbhost"><?php echo _T("Host:"); ?></label>
-                        <input type="text" name="install_dbhost" id="install_dbhost" value="<?php echo (isset($_POST['install_dbhost']))?$_POST['install_dbhost']:'localhost'; ?>" required/>
-                    </p>
-                    <p>
-                        <label class="bline" for="install_dbport"><?php echo _T("Port:"); ?></label>
-                        <input type="text" name="install_dbport" id="install_dbport" value="<?php echo (isset($_POST['install_dbport']))?$_POST['install_dbport']:$default_dbport; ?>" required/>
-                    </p>
-                    <p>
-                        <label class="bline" for="install_dbuser"><?php echo _T("User:"); ?></label>
-                        <input type="text" name="install_dbuser" id="install_dbuser" value="<?php if(isset($_POST['install_dbuser'])) echo $_POST['install_dbuser']; ?>" required/>
-                    </p>
-                    <p>
-                        <label class="bline" for="install_dbpass"><?php echo _T("Password:"); ?></label>
-                        <input type="password" name="install_dbpass" id="install_dbpass" value="<?php if(isset($_POST['install_dbpass'])) echo $_POST['install_dbpass']; ?>" required/>
-                    </p>
-                    <p>
-                        <label class="bline" for="install_dbname"><?php echo _T("Database:"); ?></label>
-                        <input type="text" name="install_dbname" id="install_dbname" value="<?php if(isset($_POST['install_dbname'])) echo $_POST['install_dbname']; ?>" required/>
-                    </p>
-                    <p>
-    <?php
-    if ( substr($_POST['install_type'], 0, 8) == 'upgrade-' ) {
-        echo '<span class="required">' .
-            _T("(Indicate the CURRENT prefix of your Galette tables)") .
-            '</span><br/>';
-    }
-    ?>
-                        <label class="bline" for="install_dbprefix"><?php echo _T("Table prefix:"); ?></label>
-                        <input type="text" name="install_dbprefix" id="install_dbprefix" value="<?php echo (isset($_POST['install_dbprefix']))?$_POST['install_dbprefix']:'galette_'; ?>" required/>
-                    </p>
+                    <div id="install_dbconfig">
+                        <p>
+                            <label class="bline" for="install_dbhost"><?php echo _T("Host:"); ?></label>
+                            <input type="text" name="install_dbhost" id="install_dbhost" value="<?php echo (isset($_POST['install_dbhost']))?$_POST['install_dbhost']:'localhost'; ?>" required/>
+                        </p>
+                        <p>
+                            <label class="bline" for="install_dbport"><?php echo _T("Port:"); ?></label>
+                            <input type="text" name="install_dbport" id="install_dbport" value="<?php echo (isset($_POST['install_dbport']))?$_POST['install_dbport']:$default_dbport; ?>" required/>
+                        </p>
+                        <p>
+                            <label class="bline" for="install_dbuser"><?php echo _T("User:"); ?></label>
+                            <input type="text" name="install_dbuser" id="install_dbuser" value="<?php if(isset($_POST['install_dbuser'])) echo $_POST['install_dbuser']; ?>" required/>
+                        </p>
+                        <p>
+                            <label class="bline" for="install_dbpass"><?php echo _T("Password:"); ?></label>
+                            <input type="password" name="install_dbpass" id="install_dbpass" value="<?php if(isset($_POST['install_dbpass'])) echo $_POST['install_dbpass']; ?>" required/>
+                        </p>
+                        <p>
+                            <label class="bline" for="install_dbname"><?php echo _T("Database:"); ?></label>
+                            <input type="text" name="install_dbname" id="install_dbname" value="<?php if(isset($_POST['install_dbname'])) echo $_POST['install_dbname']; ?>" required/>
+                        </p>
+                        <p>
+        <?php
+        if ( substr($_POST['install_type'], 0, 8) == 'upgrade-' ) {
+            echo '<span class="required">' .
+                _T("(Indicate the CURRENT prefix of your Galette tables)") .
+                '</span><br/>';
+        }
+        ?>
+                            <label class="bline" for="install_dbprefix"><?php echo _T("Table prefix:"); ?></label>
+                            <input type="text" name="install_dbprefix" id="install_dbprefix" value="<?php echo (isset($_POST['install_dbprefix']))?$_POST['install_dbprefix']:'galette_'; ?>" required/>
+                        </p>
+                    </div>
                 </fieldset>
                 <p id="btn_box">
                     <input id="next_btn" type="submit" value="<?php echo _T("Next step"); ?>"/>
@@ -638,6 +643,21 @@ case 'u4':
             </form>
             <script type="text/javascript">
                 $(function(){
+                    function changeDbType(type)
+                    {
+                        if (type == 'sqlite') {
+                            $('#install_dbconfig').css('display', 'none');
+                            $('#install_dbconfig input').each(function () {
+                                $(this).removeAttr('required');
+                            })
+                        } else {
+                            $('#install_dbconfig').css('display', 'block');
+                            $('#install_dbconfig input').each(function () {
+                                $(this).attr('required', 'required');
+                            })
+                        }
+                    }
+
                     $('#install_dbtype').change(function(){
                         var _db = $(this).val();
                         var _port = null;
@@ -647,7 +667,11 @@ case 'u4':
                             _port = <?php echo Galette\Core\Db::MYSQL_DEFAULT_PORT; ?>;
                         }
                         $('#install_dbport').val(_port);
+                        changeDbType($(this).val());
                     });
+
+                    changeDbType($('#install_dbtype').val());
+
                 });
             </script>
     <?php
@@ -660,14 +684,20 @@ case 'u5':
     <?php
     $permsdb_ok = true;
 
-    $test = Galette\Core\Db::testConnectivity(
-        $_POST['install_dbtype'],
-        $_POST['install_dbuser'],
-        $_POST['install_dbpass'],
-        $_POST['install_dbhost'],
-        $_POST['install_dbport'],
-        $_POST['install_dbname']
-    );
+    if ($_POST['install_dbtype'] == 'sqlite') {
+        $test = Galette\Core\Db::testConnectivity(
+            $_POST['install_dbtype']
+        );
+    } else {
+        $test = Galette\Core\Db::testConnectivity(
+            $_POST['install_dbtype'],
+            $_POST['install_dbuser'],
+            $_POST['install_dbpass'],
+            $_POST['install_dbhost'],
+            $_POST['install_dbport'],
+            $_POST['install_dbname']
+        );
+    }
 
     if ( $test === true ) {
         echo '<p id="infobox">' . _T("Connection to database successfull") . '</p>';
@@ -919,6 +949,9 @@ case 'u7':
 
     $sql_query = split_sql_file($sql_query, ';');
 
+    $db = $zdb->db->getConnection();
+    $db->beginTransaction();
+
     for ( $i = 0; $i < sizeof($sql_query); $i++ ) {
         $query = trim($sql_query[$i]);
         if ( $query != '' && $query[0] != '-' ) {
@@ -928,14 +961,14 @@ case 'u7':
                 $extra = '...';
             }
             try {
-                $result = $zdb->db->getConnection()->exec($query);
+                $result = $db->exec($query);
                 echo '<li class="install-ok">' . $w1 . ' ' . $w2 . ' ' . $w3 .
                     ' ' . $extra . '</li>';
             } catch (Exception $e) {
-                Analog::log(
+                \Analog\Analog::log(
                     'Error executing query | ' . $e->getMessage() .
                     ' | Query was: ' . $query,
-                    Galette\Common\Analog::WARNING
+                    \Analog\Analog::WARNING
                 );
                 echo '<li class="install-bad debuginfos">' . $w1 . ' ' . $w2 .
                     ' ' . $w3 . ' ' . $extra . '<span>' . $e->getMessage() .
@@ -951,6 +984,15 @@ case 'u7':
         }
     }
 
+    if (!empty($error))
+    {
+        $db->rollBack();
+    }
+    else
+    {
+        $db->commit();
+    }
+
     echo "</ul>\n";
     /**
     * FIXME: is this code util ?
diff --git a/galette/install/sql/sqlite.sql b/galette/install/sql/sqlite.sql
new file mode 100644 (file)
index 0000000..25fbcb2
--- /dev/null
@@ -0,0 +1,257 @@
+-- CREATE DATABASE `galette` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
+-- $Id$
+
+DROP TABLE IF EXISTS galette_adherents;
+CREATE TABLE galette_adherents (
+  id_adh INTEGER NOT NULL PRIMARY KEY, -- auto increment
+  id_statut INTEGER NOT NULL default '4',
+  nom_adh TEXT NOT NULL default '',
+  prenom_adh TEXT NOT NULL default '',
+  pseudo_adh TEXT NOT NULL default '',
+  societe_adh TEXT default NULL,
+  titre_adh INTEGER unsigned NOT NULL default '0',
+  ddn_adh TEXT default '1901-01-01',
+  adresse_adh TEXT NOT NULL default '',
+  adresse2_adh TEXT default NULL,
+  cp_adh TEXT NOT NULL default '',
+  ville_adh TEXT NOT NULL default '',
+  pays_adh TEXT default NULL,
+  tel_adh TEXT default NULL,
+  gsm_adh TEXT default NULL,
+  email_adh TEXT default NULL,
+  url_adh TEXT default NULL,
+  icq_adh TEXT default NULL,
+  msn_adh TEXT default NULL,
+  jabber_adh TEXT default NULL,
+  info_adh text,
+  info_public_adh text,
+  prof_adh TEXT default NULL,
+  login_adh TEXT NOT NULL default '',
+  mdp_adh TEXT NOT NULL default '',
+  date_crea_adh TEXT NOT NULL default '1901-01-01',
+  date_modif_adh TEXT NOT NULL default '1901-01-01',
+  activite_adh INTEGER NOT NULL default 0,
+  bool_admin_adh INTEGER NOT NULL default 0,
+  bool_exempt_adh INTEGER NOT NULL default 0,
+  bool_display_info INTEGER NOT NULL default 0,
+  date_echeance TEXT default NULL,
+  pref_lang TEXT default 'fr_FR',
+  lieu_naissance text default '',
+  gpgid TEXT DEFAULT NULL,
+  fingerprint TEXT DEFAULT NULL,
+  UNIQUE (login_adh),
+  FOREIGN KEY (id_statut) REFERENCES galette_statuts (id_statut)
+);
+
+DROP TABLE IF EXISTS galette_cotisations;
+CREATE TABLE galette_cotisations (
+  id_cotis INTEGER NOT NULL PRIMARY KEY,
+  id_adh INTEGER NOT NULL default '0',
+  id_type_cotis INTEGER NOT NULL default '0',
+  montant_cotis REAL unsigned default '0',
+  type_paiement_cotis INTEGER unsigned NOT NULL default '0',
+  info_cotis text,
+  date_enreg TEXT NOT NULL default '1901-01-01',
+  date_debut_cotis TEXT NOT NULL default '1901-01-01',
+  date_fin_cotis TEXT NOT NULL default '1901-01-01',
+  trans_id INTEGER default NULL,
+  FOREIGN KEY (id_type_cotis) REFERENCES galette_types_cotisation (id_type_cotis),
+  FOREIGN KEY (id_adh) REFERENCES galette_adherents (id_adh)
+);
+
+DROP TABLE IF EXISTS galette_transactions;
+CREATE TABLE galette_transactions (
+  trans_id INTEGER NOT NULL PRIMARY KEY,
+  trans_date TEXT NOT NULL default '1901-01-01',
+  trans_amount REAL default '0',
+  trans_desc TEXT NOT NULL default '',
+  id_adh INTEGER default NULL,
+  FOREIGN KEY (id_adh) REFERENCES galette_adherents (id_adh)
+);
+
+DROP TABLE IF EXISTS galette_statuts;
+CREATE TABLE galette_statuts (
+  id_statut INTEGER NOT NULL PRIMARY KEY,
+  libelle_statut TEXT NOT NULL default '',
+  priorite_statut INTEGER NOT NULL default '0'
+);
+
+DROP TABLE IF EXISTS galette_types_cotisation;
+CREATE TABLE galette_types_cotisation (
+  id_type_cotis INTEGER NOT NULL PRIMARY KEY,
+  libelle_type_cotis TEXT NOT NULL default '',
+  cotis_extension INTEGER NOT NULL default 0
+);
+
+DROP TABLE IF EXISTS galette_preferences;
+CREATE TABLE galette_preferences (
+  id_pref INTEGER NOT NULL PRIMARY KEY,
+  nom_pref TEXT NOT NULL default '',
+  val_pref TEXT NOT NULL default '',
+  UNIQUE (nom_pref)
+);
+
+DROP TABLE IF EXISTS galette_logs;
+CREATE TABLE galette_logs (
+  id_log INTEGER NOT NULL PRIMARY KEY,
+  date_log TEXT NOT NULL,
+  ip_log TEXT NOT NULL default '',
+  adh_log TEXT NOT NULL default '',
+  text_log text,
+  action_log text,
+  sql_log text
+);
+
+-- Table for dynamic fields description;
+DROP TABLE IF EXISTS galette_field_types;
+CREATE TABLE galette_field_types (
+    field_id INTEGER NOT NULL PRIMARY KEY,
+    field_form TEXT NOT NULL,
+    field_index INTEGER NOT NULL default '0',
+    field_name TEXT NOT NULL default '',
+    field_perm INTEGER NOT NULL default '0',
+    field_type INTEGER NOT NULL default '0',
+    field_required INTEGER NOT NULL default 0,
+    field_pos INTEGER NOT NULL default '0',
+    field_width INTEGER default NULL,
+    field_height INTEGER default NULL,
+    field_size INTEGER default NULL,
+    field_repeat INTEGER default NULL,
+    field_layout INTEGER default NULL
+);
+
+CREATE INDEX galette_field_types_field_form ON galette_field_types (field_form);
+
+-- Table for dynamic fields data;
+DROP TABLE IF EXISTS galette_dynamic_fields;
+CREATE TABLE galette_dynamic_fields (
+    item_id INTEGER NOT NULL default '0',
+    field_id INTEGER NOT NULL default '0',
+    field_form TEXT NOT NULL,
+    val_index INTEGER NOT NULL default '0',
+    field_val text DEFAULT '',
+    PRIMARY KEY (item_id, field_id, field_form, val_index),
+    FOREIGN KEY (field_id) REFERENCES galette_field_types (field_id)
+);
+
+DROP TABLE IF EXISTS galette_pictures;
+CREATE TABLE galette_pictures (
+    id_adh INTEGER NOT NULL default '0',
+    picture BLOB NOT NULL,
+    format TEXT NOT NULL default '',
+    PRIMARY KEY  (id_adh)
+);
+
+-- Table for dynamic translation of strings;
+DROP TABLE IF EXISTS galette_l10n;
+CREATE TABLE galette_l10n (
+    text_orig TEXT NOT NULL,
+    text_locale TEXT NOT NULL,
+    text_nref INTEGER NOT NULL default '1',
+    text_trans TEXT NOT NULL default '',
+    PRIMARY KEY (text_orig, text_locale)
+);
+
+-- new table for temporary passwords  2006-02-18;
+DROP TABLE IF EXISTS galette_tmppasswds;
+CREATE TABLE galette_tmppasswds (
+    id_adh INTEGER NOT NULL,
+    tmp_passwd TEXT NOT NULL,
+    date_crea_tmp_passwd TEXT NOT NULL,
+    PRIMARY KEY (id_adh),
+    FOREIGN KEY (id_adh) REFERENCES galette_adherents (id_adh)
+);
+
+-- Table for dynamic required fields 2007-07-10;
+DROP TABLE IF EXISTS galette_required;
+CREATE TABLE galette_required (
+       field_id TEXT NOT NULL,
+       required INTEGER NOT NULL,
+       PRIMARY KEY  (field_id)
+);
+
+-- Add new table for automatic mails and their translations;
+DROP TABLE IF EXISTS galette_texts;
+CREATE TABLE galette_texts (
+  tid INTEGER NOT NULL PRIMARY KEY,
+  tref TEXT NOT NULL,
+  tsubject TEXT NOT NULL,
+  tbody text NOT NULL,
+  tlang TEXT NOT NULL,
+  tcomment TEXT NOT NULL
+);
+
+DROP TABLE IF EXISTS galette_fields_categories;
+CREATE TABLE galette_fields_categories (
+  id_field_category INTEGER NOT NULL PRIMARY KEY,
+  table_name TEXT NOT NULL,
+  category TEXT NOT NULL,
+  position INTEGER NOT NULL
+);
+
+
+DROP TABLE IF EXISTS galette_fields_config;
+CREATE TABLE galette_fields_config (
+  table_name TEXT NOT NULL,
+  field_id TEXT NOT NULL,
+  required INTEGER NOT NULL,
+  visible INTEGER NOT NULL,
+  position INTEGER NOT NULL,
+  id_field_category INTEGER NOT NULL,
+  PRIMARY KEY (table_name, field_id),
+  FOREIGN KEY (id_field_category) REFERENCES galette_fields_categories (id_field_category)
+);
+
+-- Table for mailing history storage;
+DROP TABLE IF EXISTS galette_mailing_history;
+CREATE TABLE galette_mailing_history (
+  mailing_id INTEGER NOT NULL PRIMARY KEY,
+  mailing_sender INTEGER,
+  mailing_subject TEXT NOT NULL,
+  mailing_body text NOT NULL,
+  mailing_date TEXT NOT NULL,
+  mailing_recipients text NOT NULL,
+  mailing_sent INTEGER NOT NULL,
+  FOREIGN KEY (mailing_sender) REFERENCES galette_adherents (id_adh)
+);
+
+-- table for groups
+DROP TABLE IF EXISTS galette_groups;
+CREATE TABLE galette_groups (
+  id_group INTEGER NOT NULL PRIMARY KEY,
+  group_name TEXT NOT NULL,
+  creation_date TEXT NOT NULL,
+  parent_group INTEGER DEFAULT NULL,
+  FOREIGN KEY (parent_group) REFERENCES galette_groups (id_group)
+);
+
+CREATE UNIQUE INDEX galette_groups_name ON galette_groups (group_name);
+
+-- table for groups managers
+DROP TABLE IF EXISTS galette_groups_managers;
+CREATE TABLE galette_groups_managers (
+  id_group INTEGER NOT NULL,
+  id_adh INTEGER NOT NULL,
+  PRIMARY KEY (id_group,id_adh),
+  FOREIGN KEY (id_adh) REFERENCES galette_adherents (id_adh),
+  FOREIGN KEY (id_group) REFERENCES galette_groups (id_group)
+);
+
+-- table for groups member
+DROP TABLE IF EXISTS galette_groups_members;
+CREATE TABLE galette_groups_members (
+  id_group INTEGER NOT NULL,
+  id_adh INTEGER NOT NULL,
+  PRIMARY KEY (id_group,id_adh),
+  FOREIGN KEY (id_adh) REFERENCES galette_adherents (id_adh),
+  FOREIGN KEY (id_group) REFERENCES galette_groups (id_group)
+);
+
+-- table for database version
+DROP TABLE IF EXISTS galette_database;
+CREATE TABLE galette_database (
+  version REAL NOT NULL
+);
+INSERT INTO galette_database(version) VALUES(0.701);
+
+PRAGMA foreign_keys = ON;
index eba93b4e6af9ec81dcf491a23cd97be519668e5d..66eebdea6a123ca5c6a031c306977bdf464a4fea 100644 (file)
@@ -66,6 +66,11 @@ class ClassLoader
      */
     public function __construct($ns = null, $includePath = null)
     {
+        if (!file_exists($includePath))
+        {
+            throw new \RuntimeException('Include path "'.$includePath.'" doesn\'t exists');
+        }
+
         $this->namespace = $ns;
         $this->includePath = $includePath;
     }
index 2c10b5530db806229af665d2a0b31f886aea95c8..7dd055c06500cca9f0539c73bbc174c07621c7cd 100644 (file)
@@ -84,10 +84,10 @@ class CheckModules
         }
 
         //one of mysql or pgsql driver must be present
-        if ( !extension_loaded('pdo_mysql') && !extension_loaded('pdo_pgsql') ) {
-            $this->_missing[] = _T("either 'mysql' or 'pgsql' PDO driver");
+        if ( !extension_loaded('pdo_mysql') && !extension_loaded('pdo_pgsql') && !extension_loaded('pdo_sqlite') ) {
+            $this->_missing[] = _T("either 'mysql', 'pgsql' or 'sqlite' PDO driver");
         } else {
-            $this->_good['pdo_driver'] = _T("either 'mysql' or 'pgsql' PDO driver");
+            $this->_good['pdo_driver'] = _T("either 'mysql', 'pgsql' or 'sqlite' PDO driver");
         }
 
         //curl module is optionnal
index eea7c136a12ee4756abcd8fc7d4808467b9e53e9..1f91f3c96c866bd23a968f4e5c02a5465596be17 100644 (file)
@@ -73,20 +73,30 @@ class Db extends \Zend_Db
                 $_type = 'Pdo_Mysql';
             } else if ( TYPE_DB === 'pgsql' ) {
                 $_type = 'Pdo_Pgsql';
+            } else if ( TYPE_DB == 'sqlite' ) {
+                $_type = 'Pdo_Sqlite';
             } else {
                 throw new \Exception;
             }
 
+            if (TYPE_DB != 'sqlite') {
+                $_options = array(
+                        'host'     => HOST_DB,
+                        'port'     => PORT_DB,
+                        'username' => USER_DB,
+                        'password' => PWD_DB,
+                        'dbname'   => NAME_DB
+                    );
+            } else {
+                $_options = array(
+                        'dbname'   => GALETTE_SQLITE_PATH,
+                    );
+            }
+
             $this->_db = \Zend_Db::factory(
                 $_type,
-                array(
-                    'host'     => HOST_DB,
-                    'port'     => PORT_DB,
-                    'username' => USER_DB,
-                    'password' => PWD_DB,
-                    'dbname'   => NAME_DB
-                )
-            );
+                $_options
+                );
             $this->_db->getConnection();
             $this->_db->setFetchMode(\Zend_Db::FETCH_OBJ);
             Analog::log(
@@ -138,6 +148,8 @@ class Db extends \Zend_Db
             $res = $select->query()->fetch();
             return $res->version === GALETTE_DB_VERSION;
         } catch ( \Exception $e ) {
+            var_dump($e->getMessage());
+            exit;
             Analog::log(
                 'Cannot check database version: ' . $e->getMessage(),
                 Analog::ERROR
@@ -205,7 +217,7 @@ class Db extends \Zend_Db
     *
     * @return true|array true if connection was successfull, an array with some infos otherwise
     */
-    public static function testConnectivity($type, $user, $pass, $host, $port, $db)
+    public static function testConnectivity($type, $user = null, $pass = null, $host = null, $port = null, $db = null)
     {
         $_type = null;
         try {
@@ -213,20 +225,30 @@ class Db extends \Zend_Db
                 $_type = 'Pdo_Mysql';
             } else if ( $type === 'pgsql' ) {
                 $_type = 'Pdo_Pgsql';
+            } else if ( $type == 'sqlite' ) {
+                $_type = 'Pdo_Sqlite';
             } else {
                 throw new \Exception;
             }
 
+            if ($type != 'sqlite') {
+                $_options = array(
+                        'host'     => $host,
+                        'port'     => $port,
+                        'username' => $user,
+                        'password' => $pass,
+                        'dbname'   => $db
+                    );
+            } else {
+                $_options = array(
+                        'dbname'   => GALETTE_SQLITE_PATH,
+                    );
+            }
+
             $_db = \Zend_Db::factory(
                 $_type,
-                array(
-                    'host'     => $host,
-                    'port'     => $port,
-                    'username' => $user,
-                    'password' => $pass,
-                    'dbname'   => $db
-                )
-            );
+                $_options
+                );
             $_db->getConnection();
             $_db->setFetchMode(\Zend_Db::FETCH_OBJ);
             $_db->closeConnection();