-- Schema
-- REMINDER: Create order IS important, dependencies first !!
-DROP TABLE IF EXISTS galette_paymenttypes;
+DROP TABLE IF EXISTS galette_paymenttypes CASCADE;
CREATE TABLE galette_paymenttypes (
type_id integer DEFAULT nextval('galette_paymenttypes_id_seq'::text) NOT NULL,
type_name character varying(50) NOT NULL,
PRIMARY KEY (trans_id)
);
-DROP TABLE IF EXISTS galette_cotisations;
+DROP TABLE IF EXISTS galette_cotisations CASCADE;
CREATE TABLE galette_cotisations (
id_cotis integer DEFAULT nextval('galette_cotisations_id_seq'::text) NOT NULL,
id_adh integer REFERENCES galette_adherents (id_adh) ON DELETE RESTRICT ON UPDATE CASCADE,
PRIMARY KEY (id_cotis)
);
-DROP TABLE IF EXISTS galette_preferences;
+DROP TABLE IF EXISTS galette_preferences CASCADE;
CREATE TABLE galette_preferences (
id_pref integer DEFAULT nextval('galette_preferences_id_seq'::text) NOT NULL,
nom_pref character varying(100) DEFAULT '' NOT NULL,
-- add index, nom_pref is used as foreign key elsewhere
CREATE UNIQUE INDEX galette_preferences_nom_pref_idx ON galette_preferences (nom_pref);
-DROP TABLE IF EXISTS galette_logs;
+DROP TABLE IF EXISTS galette_logs CASCADE;
CREATE TABLE galette_logs (
id_log integer DEFAULT nextval('galette_logs_id_seq'::text) NOT NULL,
date_log timestamp NOT NULL,
CREATE INDEX galette_field_types_field_form_idx ON galette_field_types (field_form);
-- Table for dynamic fields data;
-DROP TABLE IF EXISTS galette_dynamic_fields;
+DROP TABLE IF EXISTS galette_dynamic_fields CASCADE;
CREATE TABLE galette_dynamic_fields (
item_id integer DEFAULT '0' NOT NULL, -- could be id_adh, trans_id, id_cotis
field_id integer REFERENCES galette_field_types (field_id) ON DELETE RESTRICT ON UPDATE CASCADE,
PRIMARY KEY (item_id, field_id, field_form, val_index)
);
-DROP TABLE IF EXISTS galette_pictures;
+DROP TABLE IF EXISTS galette_pictures CASCADE;
CREATE TABLE galette_pictures (
id_adh integer DEFAULT '0' NOT NULL,
picture bytea NOT NULL,
);
-- Table for dynamic translation of strings;
-DROP TABLE IF EXISTS galette_l10n;
+DROP TABLE IF EXISTS galette_l10n CASCADE;
CREATE TABLE galette_l10n (
text_orig character varying(255) NOT NULL,
text_locale character varying(15) NOT NULL,
);
-- new table for temporary passwords 2006-02-18;
-DROP TABLE IF EXISTS galette_tmppasswds;
+DROP TABLE IF EXISTS galette_tmppasswds CASCADE;
CREATE TABLE galette_tmppasswds (
id_adh integer REFERENCES galette_adherents (id_adh) ON DELETE CASCADE ON UPDATE CASCADE,
tmp_passwd character varying(250) NOT NULL,
);
-- Table for automatic mails and their translations 2007-10-22;
-DROP TABLE IF EXISTS galette_texts;
+DROP TABLE IF EXISTS galette_texts CASCADE;
CREATE TABLE galette_texts (
tid integer DEFAULT nextval('galette_texts_id_seq'::text) NOT NULL,
tref character varying(20) NOT NULL,
PRIMARY KEY (id_field_category)
);
-DROP TABLE IF EXISTS galette_fields_config;
+DROP TABLE IF EXISTS galette_fields_config CASCADE;
CREATE TABLE galette_fields_config (
table_name character varying(30) NOT NULL,
field_id character varying(30) NOT NULL,
);
-- Table for mailing history storage
-DROP TABLE IF EXISTS galette_mailing_history;
+DROP TABLE IF EXISTS galette_mailing_history CASCADE;
CREATE TABLE galette_mailing_history (
mailing_id integer DEFAULT nextval('galette_mailing_history_id_seq'::text) NOT NULL,
mailing_sender integer REFERENCES galette_adherents (id_adh) ON DELETE RESTRICT ON UPDATE CASCADE,
);
-- Table for reminders
-DROP TABLE IF EXISTS galette_reminders;
+DROP TABLE IF EXISTS galette_reminders CASCADE;
CREATE TABLE galette_reminders (
reminder_id integer DEFAULT nextval('galette_reminders_id_seq'::text) NOT NULL,
reminder_type integer NOT NULL,
);
-- Table for import models
-DROP TABLE IF EXISTS galette_import_model;
+DROP TABLE IF EXISTS galette_import_model CASCADE;
CREATE TABLE galette_import_model (
model_id integer DEFAULT nextval('galette_import_model_id_seq'::text) NOT NULL,
model_fields text,
);
-- Table for saved searches
-DROP TABLE IF EXISTS galette_searches;
+DROP TABLE IF EXISTS galette_searches CASCADE;
CREATE TABLE galette_searches (
search_id integer DEFAULT nextval('galette_searches_id_seq'::text) NOT NULL,
name character varying(100) DEFAULT NULL,
);
-- new table for temporary links
-DROP TABLE IF EXISTS galette_tmplinks;
+DROP TABLE IF EXISTS galette_tmplinks CASCADE;
CREATE TABLE galette_tmplinks (
hash character varying(250) NOT NULL,
target smallint NOT NULL,
);
-- table for social networks
-DROP TABLE IF EXISTS galette_socials;
+DROP TABLE IF EXISTS galette_socials CASCADE;
CREATE TABLE galette_socials (
id_social integer DEFAULT nextval('galette_socials_id_seq'::text) NOT NULL,
id_adh integer REFERENCES galette_adherents (id_adh) ON DELETE CASCADE ON UPDATE CASCADE,
CREATE INDEX galette_socials_idx ON galette_socials (type);
-- table for database version
-DROP TABLE IF EXISTS galette_database;
+DROP TABLE IF EXISTS galette_database CASCADE;
CREATE TABLE galette_database (
version decimal NOT NULL
);
--- /dev/null
+<?php
+
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Galette installation, telemetry
+ *
+ * PHP version 5
+ *
+ * Copyright © 2023 The Galette Team
+ *
+ * This file is part of Galette (http://galette.tuxfamily.org).
+ *
+ * Galette 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, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Galette 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 Galette. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Core
+ * @package Galette
+ *
+ * @author Johan Cwiklinski <johan@x-tnd.be>
+ * @copyright 2023 The Galette Team
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
+ * @link http://galette.tuxfamily.org
+ * @since 2023-10-27
+ */
+
+use Galette\Core\Plugins;
+use Galette\Core\Preferences;
+
+$preferences = new Preferences($zdb);
+$plugins = new Plugins();
+$telemetry = new \Galette\Util\Telemetry(
+ $zdb,
+ $preferences,
+ $plugins
+);
+?>
+ <form action="installer.php" method="POST" class="ui form">
+ <div class="ui segment">
+ <div class="content field">
+ <div class="ui text container">
+ <div class="ui toggle checkbox tooltip" title="<?php echo _T("Send anonymous and imprecise data about your Galette instance"); ?>">
+ <input type="checkbox" name="send_telemetry" tabindex="0" class="hidden" checked="checked"/>
+ <label><?php echo _T("Send telemetry information"); ?></label>
+ </div>
+<?php
+if (!$telemetry->isRegistered()) {
+?>
+ <a class="ui button right floated" href="<?php echo GALETTE_TELEMETRY_URI; ?>reference?showmodal&uuid=<?php echo $telemetry->getRegistrationUuid(); ?>" title="<?php echo _T("Register your organization as a Galette user"); ?>" target="_blank">
+ <i class="id card icon"></i>
+ <?php echo _T("Register"); ?>
+ </a>
+<?php
+}
+?>
+ <div class="ui message scrolling content">
+ <p><?php echo _T("Telemetry data are <strong>anonymous</strong>; nothing about your organization or its members will be sent."); ?></p>
+ <p>
+ <?php echo _T("Also note tha all data is sent over a <strong>HTTPS secured connection</strong>."); ?>
+ </p>
+ <div class="tdata">
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="ui mobile tablet computer reversed equal width grid">
+ <div class="right aligned column">
+ <button type="submit" class="ui right labeled icon button"><i class="angle double right icon"></i> <?php echo _T("Next step"); ?></button>
+ <input type="hidden" name="install_telemetry_ok" value="1"/>
+ </div>
+ </div>
+ </form>
+
public const STEP_DB_UPGRADE = 5;
public const STEP_DB_INSTALL = 6;
public const STEP_ADMIN = 7;
- public const STEP_GALETTE_INIT = 8;
- public const STEP_END = 9;
+ public const STEP_TELEMETRY = 8;
+ public const STEP_GALETTE_INIT = 9;
+ public const STEP_END = 10;
public const INSTALL = 'i';
public const UPDATE = 'u';
case self::STEP_ADMIN:
$step_title = _T("Admin parameters");
break;
+ case self::STEP_TELEMETRY:
+ $step_title = _T("Telemetry");
+ break;
case self::STEP_GALETTE_INIT:
$step_title = _T("Galette initialization");
break;
*/
public function postCheckDb()
{
- return $this->_step > self::STEP_DB_CHECKS;
+ return $this->_step >= self::STEP_DB_CHECKS;
}
/**
return $this->_admin_pass;
}
+ /**
+ * Set step to telemetry
+ *
+ * @return void
+ */
+ public function atTelemetryStep()
+ {
+ $this->_step = self::STEP_TELEMETRY;
+ }
+
+ /**
+ * Are we at telemetry step?
+ *
+ * @return boolean
+ */
+ public function isTelemetryStep()
+ {
+ return $this->_step === self::STEP_TELEMETRY;
+ }
+
/**
* Set step to Galette initialization
*
use Analog\Analog;
use Analog\Handler;
use Analog\Handler\LevelName;
+use Galette\Core\Plugins;
+use Galette\Core\Preferences;
+use Galette\Util\Telemetry;
//set a flag saying we work from installer
//that way, in galette.inc.php, we'll only include relevant parts
Analog::handler($galette_run_log);
}
+if (!$install->isEndStep()
+ && ($install->postCheckDb())
+) {
+ //if we have passed database configuration, define required constants
+ initDbConstants($install);
+
+ if ($install->postCheckDb()) {
+ try {
+ $zdb = new GaletteDb();
+ } catch (Throwable $e) {
+ if (!$install->isDbCheckStep()) {
+ throw $e;
+ }
+ }
+
+ }
+}
+
if (isset($_POST['stepback_btn'])) {
$install->atPreviousStep();
} elseif (isset($_POST['install_permsok']) && $_POST['install_permsok'] == 1) {
$_POST['install_dbprefix']
);
$install->atDbCheckStep();
+ initDbConstants($install);
}
} elseif (isset($_POST['install_dbperms_ok'])) {
if ($install->isInstall()) {
} elseif (isset($_POST['install_dbwrite_ok']) && $install->isInstall()) {
$install->atAdminStep();
} elseif (isset($_POST['install_dbwrite_ok']) && $install->isUpgrade()) {
- $install->atGaletteInitStep();
+ $install->atTelemetryStep();
} elseif (isset($_POST['install_adminlogin'])
&& isset($_POST['install_adminpass'])
&& $install->isInstall()
if ($_POST['install_adminlogin'] == '') {
$error_detected[] = _T("No user name");
}
- if (strpos($_POST['install_adminlogin'], '@') != false) {
+ if (strpos($_POST['install_adminlogin'], '@')) {
$error_detected[] = _T("The username cannot contain the @ character");
}
if ($_POST['install_adminpass'] == '') {
$_POST['install_adminlogin'],
$_POST['install_adminpass']
);
- $install->atGaletteInitStep();
+ $install->atTelemetryStep();
+ }
+} elseif (isset($_POST['install_telemetry_ok'])) {
+ if (isset($_POST['send_telemetry'])) {
+ $preferences = new Preferences($zdb);
+ $plugins = new Plugins();
+ $telemetry = new Telemetry(
+ $zdb,
+ $preferences,
+ $plugins
+ );
+ try {
+ $telemetry->send();
+ } catch (Throwable $e) {
+ Analog::log($e->getMessage(), Analog::ERROR);
+ }
}
+ $install->atGaletteInitStep();
} elseif (isset($_POST['install_prefs_ok'])) {
$install->atEndStep();
}
-if (!$install->isEndStep()
- && ($install->postCheckDb() || $install->isDbCheckStep())
-) {
- //if we have passed database configuration, define required constants
- initDbConstants($install);
-
- if ($install->postCheckDb()) {
- //while before check db, connection is not checked
- $zdb = new GaletteDb();
- }
-}
-
header('Content-Type: text/html; charset=UTF-8');
?>
<!DOCTYPE html>
include_once __DIR__ . '/../install/steps/db_install.php';
} elseif ($install->isAdminStep()) {
include_once __DIR__ . '/../install/steps/admin.php';
+} elseif ($install->isTelemetryStep()) {
+ include_once __DIR__ . '/../install/steps/telemetry.php';
} elseif ($install->isGaletteInitStep()) {
include_once __DIR__ . '/../install/steps/galette.php';
} elseif ($install->isEndStep()) {
include_once __DIR__ . '/../install/steps/end.php';
}
?>
- <div class="ui tablet stackable mini eight steps">
- <div class="step<?php if ($install->isCheckStep()) echo ' active'; ?>">
- <i class="tasks icon"></i>
- <div class="content">
- <div class="title"><?php echo _T("Checks"); ?></div>
- </div>
+ <div class="ui tablet stackable mini nine steps fluid">
+ <div class="step<?php if ($install->isCheckStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("Checks"), ENT_QUOTES); ?>">
+ <i class="tasks icon<?php if($install->isStepPassed(GaletteInstall::STEP_CHECK)) { echo ' green'; } ?>"></i>
+ <span class="displaynone"><?php echo _T("Checks"); ?></span>
</div>
- <div class="step<?php if ($install->isTypeStep()) echo ' active'; ?>">
- <i class="question icon"></i>
- <div class="content">
- <div class="title"><?php echo _T("Installation mode"); ?></div>
- </div>
+ <div class="step<?php if ($install->isTypeStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("Installation mode"), ENT_QUOTES); ?>">
+ <i class="question icon<?php if($install->isStepPassed(GaletteInstall::STEP_TYPE)) { echo ' green'; } ?>"></i>
+ <span class="displaynone"><?php echo _T("Installation mode"); ?></span>
</div>
- <div class="step<?php if ($install->isDbStep()) echo ' active'; ?>">
+ <div class="step<?php if ($install->isDbStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("Database"), ENT_QUOTES); ?>">
<i class="database icon"></i>
- <div class="content">
- <div class="title"><?php echo _T("Database"); ?></div>
- </div>
+ <span class="displaynone"><?php echo _T("Database"); ?></span>
</div>
- <div class="step<?php if ($install->isDbCheckStep()) echo ' active'; ?>">
+ <div class="step<?php if ($install->isDbCheckStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("Database access/permissions"), ENT_QUOTES); ?>">
<i class="key icon"></i>
- <div class="content">
- <div class="title"><?php echo _T("Database access/permissions"); ?></div>
- </div>
+ <span class="displaynone"><?php echo _T("Database access/permissions"); ?></span>
</div>
<?php
if ($install->isUpgrade()) {
?>
- <div class="step<?php if ($install->isVersionSelectionStep()) echo ' active'; ?>">
+ <div class="step<?php if ($install->isVersionSelectionStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("Version selection"), ENT_QUOTES); ?>">
<i class="tag icon"></i>
- <div class="content">
- <div class="title"><?php echo _T("Version selection"); ?></div>
- </div>
+ <span class="displaynone"><?php echo _T("Version selection"); ?></span>
</div>
- <div class="step<?php if ($install->isDbUpgradeStep()) echo ' active'; ?>">
+ <div class="step<?php if ($install->isDbUpgradeStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("Database upgrade", ENT_QUOTES)); ?>">
<i class="sync alt icon"></i>
- <div class="content">
- <div class="title"><?php echo _T("Database upgrade"); ?></div>
- </div>
+ <span class="displaynone"><?php echo _T("Database upgrade"); ?></span>
</div>
<?php
} else {
?>
- <div class="step<?php if ($install->isDbinstallStep()) echo ' active'; ?>">
+ <div class="step<?php if ($install->isDbinstallStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("Database installation"), ENT_QUOTES); ?>">
<i class="spinner icon"></i>
- <div class="content">
- <div class="title"><?php echo _T("Database installation"); ?></div>
- </div>
+ <span class="displaynone"><?php echo _T("Database installation"); ?></span>
</div>
<?php
}
if (!$install->isUpgrade()) {
?>
- <div class="step<?php if ($install->isAdminStep()) echo ' active'; ?>">
+ <div class="step<?php if ($install->isAdminStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("Admin parameters"), ENT_QUOTES); ?>">
<i class="user icon"></i>
- <div class="content">
- <div class="title"><?php echo _T("Admin parameters"); ?></div>
- </div>
+ <span class="displaynone"><?php echo _T("Admin parameters"); ?></span>
</div>
<?php
}
?>
- <div class="step<?php if ($install->isGaletteInitStep()) echo ' active'; ?>">
+ <div class="step<?php if ($install->isTelemetryStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("Telemetry"), ENT_QUOTES); ?>">
+ <i class="chart bar icon"></i>
+ <span class="displaynone"><?php echo _T("Telemetry"); ?></span>
+ </div>
+ <div class="step<?php if ($install->isGaletteInitStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("Galette initialisation"), ENT_QUOTES); ?>">
<i class="cogs icon"></i>
- <div class="content">
- <div class="title"><?php echo _T("Galette initialisation"); ?></div>
- </div>
+ <span class="displaynone"><?php echo _T("Galette initialisation"); ?></span>
</div>
- <div class="step<?php if ($install->isEndStep()) echo ' active'; ?>">
+ <div class="step<?php if ($install->isEndStep()) echo ' active'; ?> tooltip" title="<?php echo htmlentities(_T("End!"), ENT_QUOTES); ?>">
<i class="flag checkered icon"></i>
- <div class="content">
- <div class="title"><?php echo _T("End!"); ?></div>
- </div>
+ <span class="displaynone"><?php echo _T("End!"); ?></span>
</div>
</div>
</div>
$this->assertSame(PWD_DB, $pass);
$post_check = $this->install->postCheckDb();
- $this->assertFalse($post_check);
+ $this->assertTrue($post_check);
$this->install->atPreviousStep();
$step = $this->install->isDbStep();