Comment: | Avancement sur les champs personnalisables : ajout, suppression, modification fonctionnels. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
849223ded383fe16f93d0821f8cc2352 |
User & Date: | bohwaz on 2012-12-29 07:04:04 |
Other Links: | manifest | tags |
2012-12-30
| ||
06:04 | Début doc check-in: a91529c872 user: bohwaz tags: trunk | |
2012-12-29
| ||
07:04 | Avancement sur les champs personnalisables : ajout, suppression, modification fonctionnels. check-in: 849223ded3 user: bohwaz tags: trunk | |
05:56 | Soyons plus précis sur l'exception levée check-in: 498f510276 user: bohwaz tags: trunk | |
Modified include/class.champs_membres.php from [a1455f1902] to [e0994432f7].
︙ | ︙ | |||
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 | 'tel' => 'Numéro de téléphone', 'select' => 'Sélecteur de choix', 'country' => 'Sélecteur de pays', 'text' => 'Texte', 'textarea' => 'Texte multi-lignes', ); public function __toString() { 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(); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | 'tel' => 'Numéro de téléphone', 'select' => 'Sélecteur de choix', 'country' => 'Sélecteur de pays', 'text' => 'Texte', 'textarea' => 'Texte multi-lignes', ); protected $config_fields = array( 'type', 'title', 'help', 'editable', 'mandatory', 'private', 'values' ); static protected $presets = null; public function __toString() { 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); } static public function importPresets() { if (is_null(self::$presets)) { $json = file_get_contents(GARRADIN_ROOT . '/include/data/champs_membres.json'); $json = preg_replace('!/[*].*?[*]/!s', '', $json); $champs = json_decode($json, true); $json = file_get_contents(GARRADIN_ROOT . '/include/data/champs_membres_supplementaires.json'); $json = preg_replace('!/[*].*?[*]/!s', '', $json); $champs_supplementaires = json_decode($json, true); self::$presets = array_merge($champs, $champs_supplementaires); } return self::$presets; } static public function listUnusedPresets(Champs_Membres $champs) { return array_diff_key(self::importPresets(), $champs->getAll()); } public function __construct($champs) { if ($champs instanceOf Champs_Membres) { $this->champs = $champs->getAll(); } |
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | } 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.'); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < | < < < < < < < > > > > > > | > | 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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 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 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | } public function getAll() { return $this->champs; } /** * Vérifie la cohérence et la présence des bons éléments pour un champ * @param string $name Nom du champ * @param array $config Configuration du champ * @return boolean true */ protected function _checkField($name, &$config) { if (!preg_match('!^\w+(_\w+)*$!', $name)) { throw new UserException('Le nom du champ est invalide.'); } foreach ($config as $key=>&$value) { if (!in_array($key, $this->config_fields)) { throw new \BadMethodCallException('Champ '.$key.' non valide.'); } if ($key == 'editable' || $key == 'private' || $key == 'mandatory') { $value = (bool) (int) $value; } elseif ($key == 'help' || $key == 'title') { $value = trim((string) $value); } } if (empty($config['title'])) { throw new UserException('Le titre est obligatoire.'); } if (empty($config['type']) || !array_key_exists($config['type'], $this->types)) { throw new UserException('Le type est vide ou non valide.'); } if ($name == 'email' && $config['type'] != 'email') { throw new UserException('Le champ email ne peut être d\'un type différent de email.'); } return true; } /** * Ajouter un nouveau champ * @param string $name Nom du champ * @param array $config Configuration du champ * @return boolean true */ public function add($name, $config) { $this->_checkField($name, $config); $this->champs[$name] = $config; return true; } /** * Modifie un champ particulier * @param string $champ Nom du champ * @param string $key Nom de la clé à modifier * @param mixed $value Valeur à affecter * @return boolean true */ public function set($champ, $key, $value) { $this->champs[$champs][$key] = $value; return true; } /** * Modifie les champs en interne en vérifiant que tout va bien * @param array $champs Liste des champs * @return boolean 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.'); } foreach ($champs as $name=>$config) { $this->_checkField($name, $config); } $this->champs = $champs; return true; } public function diff() { $db = DB::getInstance(); //$config } /** * Enregistre les changements de champs en base de données * @param boolean $copy Recopier les anciennes champs dans les nouveaux ? * @return boolean true */ public function save($copy = true) { $db = DB::getInstance(); $config = Config::getInstance(); // Champs à créer $create = array( 'id INTEGER PRIMARY KEY, -- Numéro attribué automatiquement', 'id_categorie INTEGER NOT NULL, -- Numéro de catégorie', 'passe TEXT NULL, -- Mot de passe', 'date_connexion TEXT NULL, -- Date de dernière connexion', ); // Champs à recopier $copy = array( 'id', 'id_categorie', 'passe', 'date_connexion' ); $anciens_champs = $config->get('champs_membres')->getAll(); foreach ($this->champs as $key=>$cfg) { if ($cfg['type'] == 'number') |
︙ | ︙ |
Modified include/class.membres.php from [f6100e7e8c] to [51fb833586].
︙ | ︙ | |||
61 62 63 64 65 66 67 | public function login($email, $passe) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) return false; $db = DB::getInstance(); | | < < < < | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | public function login($email, $passe) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) return false; $db = DB::getInstance(); $r = $db->simpleQuerySingle('SELECT * FROM membres WHERE email = ? LIMIT 1;', true, trim($email)); if (empty($r)) return false; if (!$this->_checkPassword(trim($passe), $r['passe'])) return false; |
︙ | ︙ | |||
190 191 192 193 194 195 196 | public function sessionStore($key, $value) { if (!isset($_SESSION['storage'])) { $_SESSION['storage'] = array(); } | > > > > > > | > > > > | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | public function sessionStore($key, $value) { if (!isset($_SESSION['storage'])) { $_SESSION['storage'] = array(); } if ($value === null) { unset($_SESSION['storage'][$key]); } else { $_SESSION['storage'][$key] = $value; } return true; } public function sessionGet($key) { if (!isset($_SESSION['storage'][$key])) { return null; } return $_SESSION['storage'][$key]; } public function sendMessage($dest, $sujet, $message, $copie = false) { if (!$this->isLogged()) |
︙ | ︙ | |||
364 365 366 367 368 369 370 | $db->simpleUpdate('membres', $data, 'id = '.(int)$id); } public function get($id) { $db = DB::getInstance(); | | < < < < | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | $db->simpleUpdate('membres', $data, 'id = '.(int)$id); } public function get($id) { $db = DB::getInstance(); return $db->simpleQuerySingle('SELECT * FROM membres WHERE id = ? LIMIT 1;', true, (int)$id); } public function delete($ids) { if (!is_array($ids)) { $ids = array((int)$ids); |
︙ | ︙ |
Modified include/data/champs_membres.json from [f5459a8c5a] to [485bad1faa].
︙ | ︙ | |||
25 26 27 28 29 30 31 | false = visible par le membre */ { "nom": { "type": "text", "title": "Nom & prénom", | < < < < < < < < | 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 | false = visible par le membre */ { "nom": { "type": "text", "title": "Nom & prénom", "editable": true, "mandatory": true }, "email": { "type": "email", "title": "Adresse E-Mail", "editable": true, "mandatory": true }, "adresse": { "type": "textarea", "title": "Adresse postale (rue, numéro, immeuble, etc.)", "editable": true, "mandatory": false }, "code_postal": { "type": "text", "title": "Code postal", "editable": true, "mandatory": false }, "ville": { "type": "text", "title": "Ville", "editable": true, "mandatory": false }, "pays": { "type": "country", "title": "Pays", "editable": true, "mandatory": true }, "telephone": { "type": "tel", "title": "Numéro de téléphone", "editable": true, "mandatory": false }, "lettre_infos": { "type": "checkbox", "title": "Inscription à la lettre d'informations", "editable": true, "mandatory": false } } |
Modified include/data/champs_membres_supplementaires.json from [51a7dc1249] to [fab2d06093].
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 | "notes": { "type": "textarea", "title": "Notes", "editable": false, "mandatory": false, "private": true } } | > > > > > > > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | "notes": { "type": "textarea", "title": "Notes", "editable": false, "mandatory": false, "private": true }, "date_inscription": { "type": "date", "title": "Date d'inscription", "editable": false, "mandatory": true, "private": true } } |
Modified include/template.php from [ac46cd6b28] to [2877356567].
︙ | ︙ | |||
66 67 68 69 70 71 72 | { if ($value == $params['checked']) return ' checked="checked" '; return ''; } | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | { if ($value == $params['checked']) return ' checked="checked" '; return ''; } return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8'); } function tpl_format_tel($n) { $n = preg_replace('![^\d\+]!', '', $n); $n = preg_replace('!(\+?\d{2})!', '\\1 ', $n); return $n; |
︙ | ︙ | |||
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | return $out; } function escape_money($number) { return number_format((float)$number, 2, ',', ' '); } $tpl->register_function('csrf_field', 'Garradin\tpl_csrf_field'); $tpl->register_function('form_field', 'Garradin\tpl_form_field'); $tpl->register_function('select_compte', 'Garradin\tpl_select_compte'); $tpl->register_function('format_droits', 'Garradin\tpl_format_droits'); $tpl->register_function('pagination', 'Garradin\tpl_pagination'); $tpl->register_function('diff', 'Garradin\tpl_diff'); $tpl->register_modifier('get_country_name', array('Garradin\utils', 'getCountryName')); $tpl->register_modifier('format_tel', 'Garradin\tpl_format_tel'); $tpl->register_modifier('format_wiki', 'Garradin\tpl_format_wiki'); $tpl->register_modifier('liens_wiki', 'Garradin\tpl_liens_wiki'); $tpl->register_modifier('escape_money', 'Garradin\escape_money'); $tpl->register_modifier('abs', 'abs'); | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | return $out; } function escape_money($number) { return number_format((float)$number, 2, ',', ' '); } function tpl_html_champ_membre($params) { if (empty($params['config']) || empty($params['name'])) throw new \BadFunctionCallException('Paramètres type et name obligatoires.'); $config = $params['config']; $type = $config['type']; if ($type == 'select') { if (empty($params['values'])) throw new \BadFunctionCallException('Paramètre values obligatoire pour champ select.'); } elseif ($type == 'country') { $type = 'select'; $params['values'] = utils::getCountryList(); $params['default'] = Config::getInstance()->get('pays'); } elseif ($type == 'multiple') { if (empty($params['values'])) throw new \BadFunctionCallException('Paramètre values obligatoire pour champ select.'); } $field = ''; $value = tpl_form_field($params); $attributes = 'name="' . htmlspecialchars($params['name'], ENT_QUOTES, 'UTF-8') . '" '; $attributes .= 'id="f_' . htmlspecialchars($params['name'], ENT_QUOTES, 'UTF-8') . '" '; if (!empty($params['disabled'])) { $attributes .= 'disabled="disabled" '; } if ($type == 'select') { $field .= '<select '.$attributes.'>'; foreach ($params['values'] as $k=>$v) { if (is_int($k)) $k = $v; $field .= '<option value="' . htmlspecialchars($k, ENT_QUOTES, 'UTF-8') . '"'; if ($value == $k) $field .= ' selected="selected"'; $field .= '>' . htmlspecialchars($v, ENT_QUOTES, 'UTF-8') . '</option>'; } $field .= '</select>'; } elseif ($type == 'multiple') { } elseif ($type == 'textarea') { $field .= '<textarea ' . $attributes . 'cols="30" rows="5">' . $value . '</textarea>'; } else { if ($type == 'checkbox' && !empty($value)) { $attributes .= 'checked="checked" '; } $field .= '<input type="' . $type . '" ' . $attributes . ' value="' . $value . '" />'; } $out = ' <dt>'; if ($type == 'checkbox') { $out .= $field . ' '; } $out .= '<label for="f_' . htmlspecialchars($params['name'], ENT_QUOTES, 'UTF-8') . '">' . htmlspecialchars($config['title'], ENT_QUOTES, 'UTF-8') . '</label>'; if (!empty($config['mandatory'])) { $out .= ' <b title="(Champ obligatoire)">obligatoire</b>'; } $out .= '</dt>'; if (!empty($config['help'])) { $out .= ' <dd class="help">' . htmlspecialchars($config['help'], ENT_QUOTES, 'UTF-8') . '</dd>'; } if ($type != 'checkbox') { $out .= ' <dd>' . $field . '</dd>'; } return $out; } $tpl->register_function('csrf_field', 'Garradin\tpl_csrf_field'); $tpl->register_function('form_field', 'Garradin\tpl_form_field'); $tpl->register_function('select_compte', 'Garradin\tpl_select_compte'); $tpl->register_function('format_droits', 'Garradin\tpl_format_droits'); $tpl->register_function('pagination', 'Garradin\tpl_pagination'); $tpl->register_function('diff', 'Garradin\tpl_diff'); $tpl->register_function('html_champ_membre', 'Garradin\tpl_html_champ_membre'); $tpl->register_modifier('get_country_name', array('Garradin\utils', 'getCountryName')); $tpl->register_modifier('format_tel', 'Garradin\tpl_format_tel'); $tpl->register_modifier('format_wiki', 'Garradin\tpl_format_wiki'); $tpl->register_modifier('liens_wiki', 'Garradin\tpl_liens_wiki'); $tpl->register_modifier('escape_money', 'Garradin\escape_money'); $tpl->register_modifier('abs', 'abs'); |
︙ | ︙ |
Modified templates/admin/config/membres.tpl from [65f3f24440] to [7a768e2969].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | {include file="admin/_head.tpl" title="Configuration — Fiche membres" current="config"} {if $error} {if $error == 'OK'} <p class="confirm"> La configuration a bien été enregistrée. </p> {else} <p class="error"> {$error|escape} </p> {/if} {/if} | > > > > > > > > > > | | | | > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > | | | < < < < < < < | < < < < < < > | | 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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | {include file="admin/_head.tpl" title="Configuration — Fiche membres" current="config"} <ul class="actions"> <li><a href="{$www_url}admin/config/">Général</a></li> <li class="current"><a href="{$www_url}admin/config/membres.php">Fiche membres</a></li> <li><a href="{$www_url}admin/config/site.php">Site public</a></li> </ul> {if $error} {if $error == 'OK'} <p class="confirm"> La configuration a bien été enregistrée. </p> {elseif $error == 'ADD_OK'} <p class="confirm"> Le champ a été ajouté à la fin de la liste. </p> {else} <p class="error"> {$error|escape} </p> {/if} {/if} {if $review} <fieldset> <legend>Fiche membre exemple</legend> <dl> {foreach from=$champs item="champ" key="nom"} {html_champ_membre config=$champ name=$nom disabled=true} {if empty($champ.editable) || !empty($champ.private)} <dd> {if !empty($champ.private)} (Champ privé) {elseif empty($champ.editable)} (Non-modifiable par les membres) {/if} </dd> {/if} {/foreach} </dl> </fieldset> <form method="post" action="{$admin_url}config/membres.php"> <p class="submit"> {csrf_field key="config_membres"} <input type="submit" name="back" value="← Retour à l'édition" class="minor" /> <input type="submit" name="reset" value="Annuler les changements" class="minor" /> <input type="submit" name="save" value="Enregistrer →" /> </p> </form> {else} <form method="post" action="{$self_url|escape}"> <p class="help"> Cette page vous permet de personnaliser les fiches d'information des membres de l'association.<br /> <strong>Attention :</strong> Les champs supprimés de la fiche seront effacés de toutes les fiches de tous les membres, et les données qu'ils contenaient seront perdues. </p> <fieldset> <legend>Champs non-personnalisables</legend> <dl> <dt>Numéro unique</dt> <dd>Ce numéro identifie de manière unique chacun des membres. Il est incrémenté à chaque nouveau membre ajouté.</dd> <dt>Catégorie</dt> <dd>Identifie la catégorie du membre.</dd> <dt>Mot de passe</dt> <dd>Le mot de passe permet de se connecter à l'administration de Garradin.</dd> <dt>Date de dernière connexion</dt> <dd>Enregistre la date de dernière connexion à l'administration de Garradin.</dd> </dl> </fieldset> {if !empty($presets)} <fieldset> <legend>Ajouter un champ pré-défini</legend> <p> <select name="preset"> {foreach from=$presets key="name" item="preset"} <option value="{$name|escape}">{$name|escape} — {$preset.title|escape}</option> {/foreach} </select> <input type="submit" name="add" value="Ajouter ce champ à la fiche membre" /> </p> </fieldset> {/if} <fieldset> <legend>Ajouter un champ personnalisé</legend> <dl> <dt><label for="f_name">Nom unique</label> <b title="(Champ obligatoire)">obligatoire</b></dt> <dd class="help">Ne peut comporter que des lettres minuscules et des tirets bas.</dd> <dd><input type="text" name="new" id="f_name" value="{form_field name=new}" size="30" /></dd> <dt><label for="f_title">Titre</label> <b title="(Champ obligatoire)">obligatoire</b></dt> <dd><input type="text" name="new_title" id="f_title" value="{form_field name=new_title}" size="60" /></dd> </dl> <p><input type="submit" name="add" value="Ajouter ce champ à la fiche membre" /></p> </fieldset> <div id="orderFields"> {foreach from=$champs item="champ" key="nom"} <fieldset id="f_{$nom|escape}"> <legend>{$nom|escape}</legend> <dl> <dt><label for="f_{$nom|escape}_type">Type</label></dt> <dd> {if $nom == 'email'} <input type="hidden" name="champs[{$nom|escape}][type]" value="{$champ.type|escape}" /> Adresse E-Mail (non modifiable) |
︙ | ︙ | |||
97 98 99 100 101 102 103 | </dl> </fieldset> {/foreach} </div> <p class="submit"> {csrf_field key="config_membres"} | > | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | </dl> </fieldset> {/foreach} </div> <p class="submit"> {csrf_field key="config_membres"} <input type="submit" name="reset" value="Annuler les changements" class="minor" /> <input type="submit" name="review" value="Enregistrer →" /> (un récapitulatif sera présenté et une confirmation sera demandée) </p> </form> <script type="text/javascript"> {literal} |
︙ | ︙ | |||
171 172 173 174 175 176 177 | while (p.nodeType == 3) { p = p.nextSibling; } field.parentNode.insertBefore(field, p); } return false; }; actions.appendChild(down); | > > | | | | | | | | | | | | | | > > | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | while (p.nodeType == 3) { p = p.nextSibling; } field.parentNode.insertBefore(field, p); } return false; }; actions.appendChild(down); if (field.id != 'f_email') { var rem = document.createElement('span'); rem.className = 'icn remove'; rem.innerHTML = '✕'; rem.title = 'Enlever ce champ de la fiche'; rem.onclick = function (e) { if (!window.confirm('Êtes-vous sûr de supprimer ce champ des fiches de membre ?')) { return false; } var field = this.parentNode.parentNode; field.parentNode.removeChild(field); return false; }; actions.appendChild(rem); } var edit = document.createElement('span'); edit.className = 'icn edit'; edit.innerHTML = '✎'; edit.title = 'Modifier ce champ'; edit.onclick = function (e) { var content = this.parentNode.parentNode.querySelector('dl'); if (content.style.display.toLowerCase() == 'none') content.style.display = 'block'; else content.style.display = 'none'; return false; }; actions.appendChild(edit); } }()); {/literal} </script> {/if} {include file="admin/_foot.tpl"} |
Modified templates/admin/membres/ajouter.tpl from [c5f344c967] to [e5b59b1613].
1 2 3 4 5 6 7 8 9 10 11 12 13 | {include file="admin/_head.tpl" title="Ajouter un membre" current="membres/ajouter"} {if $error} <p class="error"> {$error|escape} </p> {/if} <form method="post" action="{$self_url|escape}"> <fieldset> <legend>Informations personnelles</legend> <dl> | < < < < < < < < < < < < < < < | > > | | < < | | < < < < | 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 | {include file="admin/_head.tpl" title="Ajouter un membre" current="membres/ajouter"} {if $error} <p class="error"> {$error|escape} </p> {/if} <form method="post" action="{$self_url|escape}"> <fieldset> <legend>Informations personnelles</legend> <dl> {foreach from=$champs item="champ" key="nom"} {if empty($champ.private) || $user.droits.membres >= Garradin\Membres::DROIT_ADMIN} {html_champ_membre config=$champ name=$nom} {/if} {/foreach} </dl> </fieldset> <fieldset> <legend>Connexion</legend> <dl> <dt><label for="f_passe">Mot de passe</label></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)</dt> <dd><input type="password" name="repasse" id="f_repasse" value="{form_field name=repasse}" /></dd> </dl> </fieldset> {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN} <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> </dl> </fieldset> {/if} <p class="submit"> {csrf_field key="new_member"} <input type="submit" name="save" value="Enregistrer →" /> |
︙ | ︙ |
Modified www/admin/config/membres.php from [cff9032192] to [b205af7ce0].
1 2 3 4 5 6 7 8 9 10 11 12 | <?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; | > > > > > > > | | | | | | > | > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > | | | | | > > | > | 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 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 121 122 123 124 125 126 127 128 129 130 131 132 133 | <?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; // Restauration de ce qui était en session if ($champs = $membres->sessionGet('champs_membres')) { $champs = new Champs_Membres($champs); } else { // 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'; } if (!empty($_POST['save']) || !empty($_POST['add']) || !empty($_POST['review']) || !empty($_POST['reset'])) { if (!utils::CSRF_check('config_membres')) { $error = 'Une erreur est survenue, merci de renvoyer le formulaire.'; } else { if (!empty($_POST['reset'])) { $membres->sessionStore('champs_membres', null); utils::redirect('/admin/config/membres.php'); } elseif (!empty($_POST['review'])) { try { $champs->setAll(utils::post('champs')); $membres->sessionStore('champs_membres', (string)$champs); utils::redirect('/admin/config/membres.php?review'); } catch (UserException $e) { $error = $e->getMessage(); } } elseif (!empty($_POST['add'])) { try { if (utils::post('preset')) { $presets = Champs_Membres::listUnusedPresets($champs); if (!array_key_exists(utils::post('preset'), $presets)) { throw new UserException('Le champ pré-défini demandé ne fait pas partie des champs disponibles.'); } $champs->add(utils::post('preset'), $presets[utils::post('preset')]); } elseif (utils::post('new')) { $presets = Champs_Membres::importPresets(); $new = utils::post('new'); if (array_key_exists($new['name'], $presets)) { throw new UserException('Le champ ajouté a le même nom qu\'un champ pré-défini.'); } $config = array( 'type' => 'text', 'title' => utils::post('new_title'), ); $champs->add($new, $config); } $membres->sessionStore('champs_membres', (string) $champs); utils::redirect('/admin/config/membres.php?added'); } catch (UserException $e) { $error = $e->getMessage(); } } elseif (!empty($_POST['save'])) { try { $champs->save(); $membres->sessionStore('champs_membres', null); utils::redirect('/admin/config/membres.php?ok'); } catch (UserException $e) { $error = $e->getMessage(); } } } } function tpl_get_type($type) { global $types; return $types[$type]; } $tpl->assign('error', $error); $tpl->assign('review', isset($_GET['review']) ? true : false); $types = $champs->getTypes(); $tpl->assign('champs', $champs->getAll()); $tpl->assign('types', $types); $tpl->assign('presets', Champs_Membres::listUnusedPresets($champs)); $tpl->assign('new', utils::post('new')); $tpl->register_modifier('get_type', 'Garradin\tpl_get_type'); $tpl->display('admin/config/membres.tpl'); ?> |
Modified www/admin/membres/ajouter.php from [cf2d4eb7f8] to [6280225820].
︙ | ︙ | |||
57 58 59 60 61 62 63 | $error = $e->getMessage(); } } } $tpl->assign('error', $error); $tpl->assign('passphrase', utils::suggestPassword()); | | < < < | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | $error = $e->getMessage(); } } } $tpl->assign('error', $error); $tpl->assign('passphrase', utils::suggestPassword()); $tpl->assign('champs', $config->get('champs_membres')->getAll()); $tpl->assign('membres_cats', $cats->listSimple()); $tpl->assign('current_cat', utils::post('id_categorie') ?: $config->get('categorie_membres')); $tpl->display('admin/membres/ajouter.tpl'); ?> |
Modified www/admin/static/admin.css from [10128f42ff] to [eac2078f61].
︙ | ︙ | |||
217 218 219 220 221 222 223 224 225 226 227 228 229 230 | p.submit { margin: 1em; } .submit input[type=submit] { font-size: 1.2em; } form .checkUncheck { float: left; } form .actions { float: right; | > > > > | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | p.submit { margin: 1em; } .submit input[type=submit] { font-size: 1.2em; } .submit input.minor { font-size: .9em; } form .checkUncheck { float: left; } form .actions { float: right; |
︙ | ︙ |