Overview
Comment: | Ajout de membre fonctionnel |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7fbdb48b634958f1e5d95b6385e8bb33 |
User & Date: | bohwaz on 2011-12-13 00:53:19 |
Other Links: | manifest | tags |
Context
2011-12-13
| ||
12:40 | Plan comptable des assos 1901 check-in: 0fa6198131 user: bohwaz tags: trunk | |
00:53 | Ajout de membre fonctionnel check-in: 7fbdb48b63 user: bohwaz tags: trunk | |
00:52 | Mise à jour liste pays, ordonnée alphabétiquement check-in: 681fad1a51 user: bohwaz tags: trunk | |
Changes
Modified DB_SCHEMA from [44face765a] to [f7acc911c5].
︙ | ︙ | |||
19 20 21 22 23 24 25 | droit_wiki INT DEFAULT 1, droit_membres INT DEFAULT 1, droit_compta INT DEFAULT 1, droit_inscription INT DEFAULT 0, droit_connexion INT DEFAULT 1 ); | < < < < < < < | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | droit_wiki INT DEFAULT 1, droit_membres INT DEFAULT 1, droit_compta INT DEFAULT 1, droit_inscription INT DEFAULT 0, droit_connexion INT DEFAULT 1 ); -- Membres de l'asso CREATE TABLE membres ( id INTEGER PRIMARY KEY, id_categorie INTEGER, -- Connexion passe TEXT, -- Données personnelles nom TEXT, email TEXT, adresse TEXT, code_postal INTEGER, ville TEXT, pays TEXT, telephone TEXT, date_naissance TEXT, -- Pour le bordel notes TEXT, date_inscription TEXT, date_connexion TEXT, -- Dernière cotisation enregistrée date_cotisation TEXT ); |
︙ | ︙ |
Modified include/class.membres.php from [9206070c41] to [232fc07e44].
︙ | ︙ | |||
36 37 38 39 40 41 42 | return true; } protected function _login($user) { $this->_sessionStart(true); | < | < < > > | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | return true; } protected function _login($user) { $this->_sessionStart(true); $_SESSION['logged_user'] = $user; return true; } public function login($email, $passe) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) return false; $db = Garradin_DB::getInstance(); $r = $db->querySingle('SELECT * FROM membres WHERE email=\''.$db->escapeString($email).'\' LIMIT 1;', true); if (empty($r)) return false; if (!$this->_checkPassword($passe, $r['passe'])) return false; $droits = $db->simpleQuerySingle('SELECT * FROM membres_categories WHERE id = ?;', true, (int)$r['id_categorie']); foreach ($droits as $key=>$value) { unset($droits[$key]); $key = str_replace('droit_', '', $key, $found); if ($found) { $droits[$key] = (int) $value; } } if ($droits['connexion'] == self::DROIT_AUCUN) return false; $r['droits'] = $droits; $db->simpleExec('UPDATE membres SET date_connexion = datetime(\'now\') WHERE id = ?;', $r['id']); return $this->_login($r); } public function isLogged() { $this->_sessionStart(); |
︙ | ︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | public function logout() { $_SESSION = array(); setcookie(session_name(), '', 0, '/'); return true; } public function _checkFields($data) { $mandatory = Garradin_Config::getInstance()->get('champs_obligatoires'); foreach ($mandatory as $field) { if (!array_key_exists($field, $data) || !trim($data[$field])) { throw new UserException('Le champ \''.$field.'\' ne peut rester vide.'); } } | > > | | > > > > > > > > > > | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | public function logout() { $_SESSION = array(); setcookie(session_name(), '', 0, '/'); return true; } // Gestion des données /////////////////////////////////////////////////////// public function _checkFields($data) { $mandatory = Garradin_Config::getInstance()->get('champs_obligatoires'); foreach ($mandatory as $field) { if (!array_key_exists($field, $data) || !trim($data[$field])) { throw new UserException('Le champ \''.$field.'\' ne peut rester vide.'); } } if (!empty($data['email']) && !filter_var($data['email'], FILTER_VALIDATE_EMAIL)) { throw new UserException('Adresse e-mail invalide.'); } if (!empty($data['code_postal']) && !preg_match('!^\d{5}$!', $data['code_postal'])) { throw new UserException('Code postal invalide.'); } if (!empty($data['passe']) && strlen($data['passe']) < 5) { throw new UserException('Le mot de passe doit faire au moins 5 caractères.'); } return true; } public function add($data = array()) { |
︙ | ︙ | |||
138 139 140 141 142 143 144 | if (!isset($data['id_categorie'])) { $data['id_categorie'] = Garradin_Config::getInstance()->get('categorie_membres'); } $db = Garradin_DB::getInstance(); | | | | | | > > | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | if (!isset($data['id_categorie'])) { $data['id_categorie'] = Garradin_Config::getInstance()->get('categorie_membres'); } $db = Garradin_DB::getInstance(); $db->simpleExec('INSERT INTO membres (id_categorie, passe, nom, email, adresse, code_postal, ville, pays, telephone, date_naissance, notes, date_inscription, date_connexion, date_cotisation) VALUES (:id_categorie, :passe, :nom, :email, :adresse, :code_postal, :ville, :pays, :telephone, :date_naissance, :notes, date(\'now\'), NULL, NULL);', $data); return $db->lastInsertRowId(); } public function edit($id, $data = array()) { $this->_checkFields($data); // UPDATE SQL } |
︙ | ︙ |
Modified include/class.membres_categories.php from [5b96deae11] to [68745b17d6].
︙ | ︙ | |||
83 84 85 86 87 88 89 90 91 92 | if ($db->simpleQuerySingle('SELECT 1 FROM membres WHERE id_categorie = ?;', false, (int)$id)) { throw new UserException('La catégorie contient encore des membres, il n\'est pas possible de la supprimer.'); } return $db->simpleExec('DELETE FROM membres_categories WHERE id = ?;', (int) $id); } } ?> | > > > > > > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | if ($db->simpleQuerySingle('SELECT 1 FROM membres WHERE id_categorie = ?;', false, (int)$id)) { throw new UserException('La catégorie contient encore des membres, il n\'est pas possible de la supprimer.'); } return $db->simpleExec('DELETE FROM membres_categories WHERE id = ?;', (int) $id); } public function listSimple() { $db = Garradin_DB::getInstance(); return $db->queryFetchAssoc('SELECT id, nom FROM membres_categories ORDER BY nom;'); } } ?> |
Modified include/init.php from [e1167b6957] to [6e6d94ad77].
︙ | ︙ | |||
88 89 90 91 92 93 94 95 96 97 | if (!file_exists(GARRADIN_DB_FILE)) { utils::redirect('/admin/install.php'); } require_once GARRADIN_ROOT . '/include/class.db.php'; require_once GARRADIN_ROOT . '/include/class.config.php'; } ?> | > | 88 89 90 91 92 93 94 95 96 97 98 | if (!file_exists(GARRADIN_DB_FILE)) { utils::redirect('/admin/install.php'); } require_once GARRADIN_ROOT . '/include/class.db.php'; require_once GARRADIN_ROOT . '/include/class.config.php'; $config = Garradin_Config::getInstance(); } ?> |
Modified include/template.php from [97de6e82ed] to [26a30c7023].
︙ | ︙ | |||
37 38 39 40 41 42 43 | function tpl_form_field($params) { $name = $params['name']; if (isset($_POST[$name])) $value = $_POST[$name]; | > > | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | function tpl_form_field($params) { $name = $params['name']; if (isset($_POST[$name])) $value = $_POST[$name]; elseif (isset($params['data']) && isset($params['data'][$name])) $value = $params['data'][$name]; elseif (isset($params['default'])) $value = $params['default']; else $value = ''; return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); } $tpl->register_function('csrf_field', 'tpl_csrf_field'); $tpl->register_function('form_field', 'tpl_form_field'); ?> |
Added templates/admin/membres/ajouter.tpl version [948a7fe391].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | {include file="admin/_head.tpl" title="Ajouter un membre"} {if $error} <p class="error"> {$error|escape} </p> {/if} <form method="post" action="{$self_url|escape}"> <fieldset> <legend>Informations personnelles</legend> <dl> <dt><label for="f_nom">Nom et prénom</label>{if in_array('nom', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt> <dd><input type="text" name="nom" id="f_nom" value="{form_field name=nom}" /></dd> <dt><label for="f_email">Adresse E-Mail</label>{if in_array('email', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt> <dd><input type="email" name="email" id="f_email" value="{form_field name=email}" /></dd> <dt><label for="f_telephone">Numéro de téléphone</label>{if in_array('telephone', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt> <dd><input type="tel" name="telephone" id="f_telephone" value="{form_field name=telephone}" /></dd> <dt><label for="f_adresse">Adresse</label> (numéro, rue, etc.){if in_array('adresse', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt> <dd><textarea name="adresse" id="f_adresse" rows="4" cols="30">{form_field name=adresse}</textarea></dd> <dt><label for="f_code_postal">Code postal</label>{if in_array('code_postal', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt> <dd><input type="number" name="code_postal" id="f_code_postal" value="{form_field name=code_postal}" /></dd> <dt><label for="f_ville">Ville</label>{if in_array('ville', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt> <dd><input type="text" name="ville" id="f_ville" value="{form_field name=ville}" /></dd> <dt><label for="f_pays">Pays</label> {if in_array('pays', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt> <dd> <select name="pays" id="f_pays"> {foreach from=$pays key="cc" item="nom"} <option value="{$cc|escape}"{if $cc == $current_cc} selected="selected"{/if}>{$nom|escape}</option> {/foreach} </select> </dd> </dl> </fieldset> <fieldset> <legend>Connexion</legend> <dl> <dt><label for="f_passe">Mot de passe</label>{if in_array('passe', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt> <dd class="help"> Pas d'idée ? Voici une suggestion choisie au hasard : <tt title="Cliquer pour utiliser cette suggestion comme mot de passe" onclick="fillPassword(this);">{$passphrase|escape}</tt> </dd> <dd><input type="password" name="passe" id="f_passe" value="{form_field name=passe}" /></dd> <dt><label for="f_repasse">Encore le mot de passe</label> (vérification){if in_array('passe', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt> <dd><input type="password" name="repasse" id="f_repasse" value="{form_field name=repasse}" /></dd> </dl> </fieldset> <fieldset> <legend>Général</legend> <dl> <dt><label for="f_cat">Catégorie du membre</label> <b title="(Champ obligatoire)">obligatoire</b></dt> <dd> <select name="id_categorie" id="f_cat"> {foreach from=$membres_cats key="id" item="nom"} <option value="{$id|escape}"{if $current_cat == $id} selected="selected"{/if}>{$nom|escape}</option> {/foreach} </select> </dd> <dt> <input type="checkbox" name="cotisation" value="1" id="f_cotisation" /> <label for="f_cotisation">À jour de cotisation</label> </dt> </dl> </fieldset> <p class="submit"> {csrf_field key="new_member"} <input type="submit" name="save" value="Enregistrer →" /> </p> </form> <script type="text/javascript"> {literal} function fillPassword(elm) { var pw = elm.textContent || elm.innerText; document.getElementById('f_passe').value = pw; document.getElementById('f_repasse').value = pw; } {/literal} </script> {include file="admin/_foot.tpl"} |
Modified www/admin/_inc.php from [548f40fbae] to [8570a0ed13].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 | if (!$membres->isLogged()) { utils::redirect('/admin/login.php'); } $tpl->assign('is_logged', true); $tpl->assign('user', $membres->getLoggedUser()); $tpl->assign('self_page', str_replace(WWW_URL . 'admin/', '', utils::getSelfUrl())); } ?> | > | 11 12 13 14 15 16 17 18 19 20 21 22 23 | if (!$membres->isLogged()) { utils::redirect('/admin/login.php'); } $tpl->assign('is_logged', true); $tpl->assign('user', $membres->getLoggedUser()); $user = $membres->getLoggedUser(); $tpl->assign('self_page', str_replace(WWW_URL . 'admin/', '', utils::getSelfUrl())); } ?> |
Modified www/admin/install.php from [ed66856c98] to [7152046a41].
︙ | ︙ | |||
104 105 106 107 108 109 110 | 'nom' => utils::post('nom_membre'), 'email' => utils::post('email_membre'), 'passe' => utils::post('passe_membre'), 'telephone' => '', 'code_postal' => '', 'adresse' => '', 'ville' => '', | | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | 'nom' => utils::post('nom_membre'), 'email' => utils::post('email_membre'), 'passe' => utils::post('passe_membre'), 'telephone' => '', 'code_postal' => '', 'adresse' => '', 'ville' => '', 'pays' => 'FR', 'date_anniversaire' => '', 'notes' => '', )); $config->save(); utils::redirect('/admin/login.php'); } catch (UserException $e) |
︙ | ︙ |
Added www/admin/membres/ajouter.php version [26d9549d45].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | <?php require_once __DIR__ . '/../_inc.php'; if ($user['droits'] < Garradin_Membres::DROIT_ADMIN) { throw new UserException("Vous n'avez pas le droit d'accéder à cette page."); } require_once GARRADIN_ROOT . '/include/lib.passphrase.french.php'; require_once GARRADIN_ROOT . '/include/class.membres_categories.php'; $cats = new Garradin_Membres_Categories; $error = false; if (!empty($_POST['save'])) { if (!utils::CSRF_check('new_member')) { $error = 'Une erreur est survenue, merci de renvoyer le formulaire.'; } elseif (utils::post('passe') != utils::post('repasse')) { $error = 'La vérification ne correspond pas au mot de passe.'; } else { try { $id = $membres->add(array( 'id_categorie' => utils::post('id_categorie'), 'nom' => utils::post('nom'), 'email' => utils::post('email'), 'passe' => utils::post('passe'), 'telephone' => utils::post('telephone'), 'code_postal' => utils::post('code_postal'), 'adresse' => utils::post('adresse'), 'ville' => utils::post('ville'), 'pays' => utils::post('pays'), 'date_naissance'=> utils::post('date_naissance'), 'notes' => '', )); utils::redirect('/admin/membres/'); } catch (UserException $e) { $error = $e->getMessage(); } } } $tpl->assign('error', $error); $tpl->assign('passphrase', Passphrase::generate()); $tpl->assign('obligatoires', $config->get('champs_obligatoires')); $tpl->assign('membres_cats', $cats->listSimple()); $tpl->assign('current_cat', utils::post('id_categorie') ?: $config->get('categorie_membres')); $tpl->assign('pays', utils::getCountryList()); $tpl->assign('current_cc', utils::post('pays') ?: 'FR'); $tpl->display('admin/membres/ajouter.tpl'); ?> |
Modified www/style/admin.css from [141f91b4aa] to [13c3dbd150].
1 2 3 4 5 6 7 | * { margin: 0; padding: 0; } body { font-size: 100%; color: #000; font-family: "Trebuchet MS", Helvetica, Sans-serif; background: #fff; | > | > > > > | < < | | | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | * { margin: 0; padding: 0; } html { width: 100%; height: 100%; } body { font-size: 100%; color: #000; font-family: "Trebuchet MS", Helvetica, Sans-serif; background: #fff; background: url("../img/bg01.png") no-repeat left -100px, url("../img/bg00.png") repeat-y left bottom, #fff; } .header { color: #fff; } .header h1 { color: #9c4f15; margin-left: 180px; margin-bottom: 0.4em; } .header .menu { float: left; width: 168px; margin-top: 100px; } .header .menu li { list-style-type: none; } .header .menu a { color: #fff; font-weight: bold; padding: 0.4em 0.4em 0.4em 1em; display: block; text-decoration: none; } .header .menu a:hover { text-decoration: underline; background: rgba(217, 134, 40, 0.5); } .header .menu li li a { font-size: 0.8em; padding-left: 2em; } .page { margin: 1em 1em 1em 180px; } p.error { border: 1px solid #c00; background: #fcc; padding: 0.5em; margin-bottom: 1em; |
︙ | ︙ | |||
105 106 107 108 109 110 111 | color: #666; } fieldset dl dd { padding: 0.2em 0.5em 0.2em 1em; } | > | > > > > > > | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | color: #666; } fieldset dl dd { padding: 0.2em 0.5em 0.2em 1em; } input[type=text], textarea, input[type=password], input[type=email], input[type=url], input[type=tel], select { padding: 0.2em 0.4em; font-family: Sans-serif; min-width: 20em; } input[type=number] { padding: 0.2em 0.4em; font-family: Sans-serif; min-width: 8em; } input[type=submit], input[type=button] { padding: 0.3em; cursor: pointer; } p.submit { |
︙ | ︙ | |||
131 132 133 134 135 136 137 138 | dd.help { color: #666; } dd.help tt { background: #ddd; padding: 0.2em; } | > | 141 142 143 144 145 146 147 148 149 | dd.help { color: #666; } dd.help tt { background: #ddd; padding: 0.2em; cursor: pointer; } |