Overview
Comment: | Adapter la modif de membre aux champs personnalisés |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ef410c31964efe60ad2e2542974101b9 |
User & Date: | bohwaz on 2013-01-30 15:34:19 |
Other Links: | manifest | tags |
Context
2013-01-30
| ||
16:03 | Affichage des infos du membre dans sa fiche check-in: 6bd977274f user: bohwaz tags: trunk | |
15:34 | Adapter la modif de membre aux champs personnalisés check-in: ef410c3196 user: bohwaz tags: trunk | |
15:19 | Ajout de membre en utilisant les champs personnalisés check-in: 3b9b01fecb user: bohwaz tags: trunk | |
Changes
Modified include/class.membres.php from [542975c1d0] to [eddd440dec].
︙ | ︙ | |||
241 242 243 244 245 246 247 | public function _checkFields(&$data, $check_mandatory = true) { $champs = Config::getInstance()->get('champs_membres'); foreach ($champs->getAll() as $key=>$config) { | | > | > > | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | public function _checkFields(&$data, $check_mandatory = true) { $champs = Config::getInstance()->get('champs_membres'); foreach ($champs->getAll() as $key=>$config) { if (!empty($config['mandatory']) && (!isset($data[$key]) || !trim($data[$key]))) { if ($check_mandatory) throw new UserException('Le champ "' . $config['title'] . '" doit obligatoirement être renseigné.'); else continue; } if ($config['type'] == 'email' && !filter_var($data[$key], FILTER_VALIDATE_EMAIL)) { throw new UserException('Adresse e-mail invalide dans le champ "' . $config['title'] . '".'); } elseif ($config['type'] == 'url' && !filter_var($data[$key], FILTER_VALIDATE_URL)) |
︙ | ︙ | |||
545 546 547 548 549 550 551 | { if (is_null($date_verif)) $date_verif = time(); if (!$date_membre) return false; | | | 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | { if (is_null($date_verif)) $date_verif = time(); if (!$date_membre) return false; $echeance = new \DateTime('@' . $date_membre); $echeance->setTime(0, 0); $echeance->modify('+'.$duree_cotisation.' months'); if ($echeance->getTimestamp() < $date_verif) return round(($date_verif - $echeance->getTimestamp()) / 3600 / 24); return true; |
︙ | ︙ |
Modified templates/admin/membres/modifier.tpl from [e562da8857] to [2bf0b6d82e].
︙ | ︙ | |||
11 12 13 14 15 16 17 | <fieldset> <legend>Informations personnelles</legend> <dl> {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN} <dt><label for="f_id">Numéro de membre</label> <b title="(Champ obligatoire)">obligatoire</b></dt> <dd><input type="text" name="id" id="f_id" value="{form_field data=$membre name=id}" /></dd> {/if} | < < < < < < < < < < < < < < < | > > | | < < > | | > < < < < | 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 | <fieldset> <legend>Informations personnelles</legend> <dl> {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN} <dt><label for="f_id">Numéro de membre</label> <b title="(Champ obligatoire)">obligatoire</b></dt> <dd><input type="text" name="id" id="f_id" value="{form_field data=$membre name=id}" /></dd> {/if} {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 data=$membre} {/if} {/foreach} </dl> </fieldset> {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN || empty($champs.passe.private)} <fieldset> <legend>{if $membre.passe}Changer le mot de passe{else}Choisir un mot de passe{/if}</legend> <dl> {if $membre.passe} <dd>Ce membre a déjà un mot de passe, mais vous pouvez le changer si besoin.</dd> {else} <dd>Ce membre n'a pas encore de mot de passe et ne peut donc se connecter.</dd> {/if} <dt><label for="f_passe">Nouveau mot de passe</label>{if $champs.passe.mandatory} <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 $champs.passe.mandatory} <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> {/if} {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="edit_member_"|cat:$membre.id} <input type="submit" name="save" value="Enregistrer →" /> |
︙ | ︙ |
Modified www/admin/membres/ajouter.php from [8f08712aa0] to [e610f8440b].
︙ | ︙ | |||
39 40 41 42 43 44 45 | $data = array('id_categorie' => $id_categorie); foreach ($champs->getAll() as $key=>$config) { $data[$key] = utils::post($key); } | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | $data = array('id_categorie' => $id_categorie); foreach ($champs->getAll() as $key=>$config) { $data[$key] = utils::post($key); } $id = $membres->add($data, ($user['droits']['membres'] == Membres::DROIT_ADMIN) ? false : true); utils::redirect('/admin/membres/fiche.php?id='.(int)$id); } catch (UserException $e) { $error = $e->getMessage(); } |
︙ | ︙ |
Modified www/admin/membres/index.php from [23d868714b] to [1320bcd6d4].
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 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; if ($user['droits']['membres'] < Membres::DROIT_ACCES) { throw new UserException("Vous n'avez pas le droit d'accéder à cette page."); } $cats = new Membres_Categories; $membres_cats = $cats->listSimple(); $membres_cats_cachees = $cats->listHidden(); $cat = (int) utils::get('cat') ?: 0; $page = (int) utils::get('p') ?: 1; if (!$cat) { $cat_id = array_diff(array_keys($membres_cats), array_keys($membres_cats_cachees)); } else { $cat_id = (int) $cat; } | > | | | 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 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; if ($user['droits']['membres'] < Membres::DROIT_ACCES) { throw new UserException("Vous n'avez pas le droit d'accéder à cette page."); } $cats = new Membres_Categories; $champs = $config->get('champs_membres'); $membres_cats = $cats->listSimple(); $membres_cats_cachees = $cats->listHidden(); $cat = (int) utils::get('cat') ?: 0; $page = (int) utils::get('p') ?: 1; if (!$cat) { $cat_id = array_diff(array_keys($membres_cats), array_keys($membres_cats_cachees)); } else { $cat_id = (int) $cat; } $order = $champs->getFirst(); $desc = false; if (utils::get('o')) $order = utils::get('o'); if (isset($_GET['d'])) $desc = true; $tpl->assign('order', $order); $tpl->assign('desc', $desc); $fields = $champs->getListedFields(); $tpl->assign('champs', $fields); $tpl->assign('liste', $membres->listByCategory($cat_id, array_keys($fields), $page, $order, $desc)); $tpl->assign('total', $membres->countByCategory($cat_id)); $tpl->assign('pagination_url', utils::getSelfUrl(true) . '?p=[ID]&o=' . $order . ($desc ? '&d' : '')); |
︙ | ︙ |
Modified www/admin/membres/modifier.php from [acc914fdf8] to [bb64342991].
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | if (!$membre) { throw new UserException("Ce membre n'existe pas."); } $cats = new Membres_Categories; // Protection contre la modification des admins par des membres moins puissants $membre_cat = $cats->get($membre['id_categorie']); if (($membre_cat['droit_membres'] == Membres::DROIT_ADMIN) && ($user['droits']['membres'] < Membres::DROIT_ADMIN)) { throw new UserException("Seul un membre admin peut modifier un autre membre admin."); | > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | if (!$membre) { throw new UserException("Ce membre n'existe pas."); } $cats = new Membres_Categories; $champs = $config->get('champs_membres'); // Protection contre la modification des admins par des membres moins puissants $membre_cat = $cats->get($membre['id_categorie']); if (($membre_cat['droit_membres'] == Membres::DROIT_ADMIN) && ($user['droits']['membres'] < Membres::DROIT_ADMIN)) { throw new UserException("Seul un membre admin peut modifier un autre membre admin."); |
︙ | ︙ | |||
43 44 45 46 47 48 49 | elseif (utils::post('passe') != utils::post('repasse')) { $error = 'La vérification ne correspond pas au mot de passe.'; } else { try { | | | | > | < < < < < < < < < > | | < < < | 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 | elseif (utils::post('passe') != utils::post('repasse')) { $error = 'La vérification ne correspond pas au mot de passe.'; } else { try { $data = array(); foreach ($champs->getAll() as $key=>$config) { $data[$key] = utils::post($key); } if ($user['droits']['membres'] == Membres::DROIT_ADMIN) { $data['id_categorie'] = utils::post('id_categorie'); $data['id'] = utils::post('id'); } $membres->edit($id, $data, ($user['droits']['membres'] == Membres::DROIT_ADMIN) ? false : true); utils::redirect('/admin/membres/fiche.php?id='.(int)$id); } catch (UserException $e) { $error = $e->getMessage(); } } } $tpl->assign('error', $error); $tpl->assign('passphrase', utils::suggestPassword()); $tpl->assign('champs', $champs->getAll()); $tpl->assign('membres_cats', $cats->listSimple()); $tpl->assign('current_cat', utils::post('id_categorie') ?: $membre['id_categorie']); $tpl->assign('can_change_id', $user['droits']['membres'] == Membres::DROIT_ADMIN); $tpl->assign('membre', $membre); $tpl->display('admin/membres/modifier.tpl'); ?> |
Modified www/admin/membres/recherche.php from [0d2f3ccd0b] to [8aa006c8df].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | } $recherche = trim(utils::get('r')); $champ = trim(utils::get('c')); $champs = $config->get('champs_membres'); if (!$champ) { if (is_numeric(trim($recherche))) { $champ = 'id'; } elseif (strpos($recherche, '@') !== false) { $champ = 'email'; | > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | } $recherche = trim(utils::get('r')); $champ = trim(utils::get('c')); $champs = $config->get('champs_membres'); // On détermine magiquement quel champ on recherche if (!$champ) { if (is_numeric(trim($recherche))) { $champ = 'id'; } elseif (strpos($recherche, '@') !== false) { $champ = 'email'; |
︙ | ︙ |