Overview
Comment: | Gestion à l'upgrade/install |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
911be190ea4e88727a71140d3dbc33ff |
User & Date: | bohwaz on 2012-12-23 13:10:06 |
Other Links: | manifest | tags |
Context
2012-12-29
| ||
02:37 | Catégorie de recette "subventions" check-in: 768605f340 user: bohwaz tags: trunk | |
2012-12-23
| ||
13:10 | Gestion à l'upgrade/install check-in: 911be190ea user: bohwaz tags: trunk | |
12:51 | Début des champs modifiables et personnalisables check-in: b8cd499be0 user: bohwaz tags: trunk | |
Changes
Modified include/class.champs_membres.php from [9192892681] to [a1455f1902].
︙ | ︙ | |||
27 28 29 30 31 32 33 | return json_encode($this->champs); } static public function import() { $json = file_get_contents(GARRADIN_ROOT . '/include/data/champs_membres.json'); $json = preg_replace('!/[*].*?[*]/!s', '', $json); | | < < < < | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | return json_encode($this->champs); } static public function import() { $json = file_get_contents(GARRADIN_ROOT . '/include/data/champs_membres.json'); $json = preg_replace('!/[*].*?[*]/!s', '', $json); return new Champs_Membres($json); } public function __construct($champs) { if ($champs instanceOf Champs_Membres) { $this->champs = $champs->getAll(); |
︙ | ︙ | |||
60 61 62 63 64 65 66 67 68 69 70 71 72 73 | return $this->champs[$key]; } public function getAll() { return $this->champs; } public function setAll($champs) { if (!array_key_exists('email', $champs)) { throw new UserException('Le champ E-Mail ne peut être supprimé des fiches membres.'); } | > > > > > > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | return $this->champs[$key]; } public function getAll() { return $this->champs; } public function set($champ, $key, $value) { $this->champs[$champs][$key] = $value; return true; } public function setAll($champs) { if (!array_key_exists('email', $champs)) { throw new UserException('Le champ E-Mail ne peut être supprimé des fiches membres.'); } |
︙ | ︙ | |||
95 96 97 98 99 100 101 | public function diff() { $db = DB::getInstance(); //$config } | | | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | public function diff() { $db = DB::getInstance(); //$config } public function save($copy = true) { $db = DB::getInstance(); $config = Config::getInstance(); // Champs à créer $create = array( 'id INTEGER PRIMARY KEY, -- Numéro attribué automatiquement', |
︙ | ︙ | |||
141 142 143 144 145 146 147 | $last = count($create) - 1; $create[$last] = str_replace(',', '', $create[$last]); $create = 'CREATE TABLE membres_tmp (' . "\n\t" . implode("\n\t", $create) . "\n);"; $copy = 'INSERT INTO membres_tmp (' . implode(', ', $copy) . ') SELECT ' . implode(', ', $copy) . ' FROM membres;'; | | > > > | > > | > | > | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | $last = count($create) - 1; $create[$last] = str_replace(',', '', $create[$last]); $create = 'CREATE TABLE membres_tmp (' . "\n\t" . implode("\n\t", $create) . "\n);"; $copy = 'INSERT INTO membres_tmp (' . implode(', ', $copy) . ') SELECT ' . implode(', ', $copy) . ' FROM membres;'; $db->exec('PRAGMA foreign_keys = OFF;'); $db->exec('BEGIN;'); $db->exec($create); if ($copy) { $db->exec($copy); } $db->exec('DROP TABLE membres;'); $db->exec('ALTER TABLE membres_tmp RENAME TO membres;'); $db->exec('END;'); $db->exec('PRAGMA foreign_keys = ON;'); $config->set('champs_membres', $this); $config->save(); return true; } } ?> |
Modified www/admin/config/membres.php from [86c2b807a2] to [cff9032192].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; if ($user['droits']['config'] < Membres::DROIT_ADMIN) { throw new UserException("Vous n'avez pas le droit d'accéder à cette page."); } $error = false; $champs = new Champs_Membres($config->get('champs_membres')); if (isset($_GET['ok'])) { $error = 'OK'; } | > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; if ($user['droits']['config'] < Membres::DROIT_ADMIN) { throw new UserException("Vous n'avez pas le droit d'accéder à cette page."); } $error = false; // Il est nécessaire de créer une nouvelle instance ici, sinon // l'enregistrement des modifs ne marchera pas car les deux instances seront identiques. // Càd si on utilise directement l'instance de $config, elle sera modifiée directement // du coup quand on essaiera de comparer si ça a changé ça comparera deux fois la même chose // donc ça n'aura pas changé forcément. $champs = new Champs_Membres($config->get('champs_membres')); if (isset($_GET['ok'])) { $error = 'OK'; } |
︙ | ︙ |
Modified www/admin/install.php from [91c497d948] to [45d33d3c32].
︙ | ︙ | |||
75 76 77 78 79 80 81 | $config->set('nom_asso', utils::post('nom_asso')); $config->set('adresse_asso', utils::post('adresse_asso')); $config->set('email_asso', utils::post('email_asso')); $config->set('site_asso', utils::post('site_asso')); $config->set('monnaie', '€'); $config->set('pays', 'FR'); $config->set('email_envoi_automatique', utils::post('email_asso')); | | | > > | | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | $config->set('nom_asso', utils::post('nom_asso')); $config->set('adresse_asso', utils::post('adresse_asso')); $config->set('email_asso', utils::post('email_asso')); $config->set('site_asso', utils::post('site_asso')); $config->set('monnaie', '€'); $config->set('pays', 'FR'); $config->set('email_envoi_automatique', utils::post('email_asso')); $config->setVersion(garradin_version()); $champs = Champs_Membres::import(); $champs->save(false); // Pas de copie car pas de table membres existante $config->set('champs_membres', $champs); // Création catégories $cats = new Membres_Categories; $id = $cats->add(array( 'nom' => 'Membres actifs', 'montant_cotisation' => 10)); $config->set('categorie_membres', $id); |
︙ | ︙ |
Modified www/admin/upgrade.php from [7e21d1bf49] to [9f60cf9682].
︙ | ︙ | |||
89 90 91 92 93 94 95 | // Récupération de l'ancienne config $champs_modifiables_membre = $db->querySingle('SELECT valeur FROM config WHERE cle = "champs_modifiables_membre";'); $champs_modifiables_membre = explode($champs_modifiables_membre); $champs_obligatoires = $db->querySingle('SELECT valeur FROM config WHERE cle = "champs_obligatoires";'); $champs_obligatoires = explode($champs_obligatoires); | > > | > > > > > > > > > > > > > > > | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | // Récupération de l'ancienne config $champs_modifiables_membre = $db->querySingle('SELECT valeur FROM config WHERE cle = "champs_modifiables_membre";'); $champs_modifiables_membre = explode($champs_modifiables_membre); $champs_obligatoires = $db->querySingle('SELECT valeur FROM config WHERE cle = "champs_obligatoires";'); $champs_obligatoires = explode($champs_obligatoires); // Import des champs membres par défaut $champs = Champs_Membres::import(); // Application de l'ancienne config aux nouveaux champs membres foreach ($champs_obligatoires as $name) { $champs->set($name, 'mandatory', true); } foreach ($champs_modifiables_membre as $name) { $champs->set($name, 'editable', true); } $champs->save(); $config->set('champs_membres', $champs); $config->save(); // Suppression de l'ancienne config $db->exec('DELETE FROM config WHERE cle IN ("champs_obligatoires", "champs_modifiables_membre");'); } utils::clearCaches(); |
︙ | ︙ |