Index: include/class.champs_membres.php ================================================================== --- include/class.champs_membres.php +++ include/class.champs_membres.php @@ -138,10 +138,11 @@ return false; } public function getAll() { + $this->champs['passe']['title'] = 'Mot de passe'; return $this->champs; } public function getList() { Index: include/class.membres.php ================================================================== --- include/class.membres.php +++ include/class.membres.php @@ -281,10 +281,34 @@ } if (!is_numeric($data[$key])) throw new UserException('Le champ "' . $config['title'] . '" doit contenir un chiffre.'); } + elseif ($config['type'] == 'select' && !in_array($data[$key], $config['options'])) + { + throw new UserException('Le champ "' . $config['title'] . '" ne correspond pas à un des choix proposés.'); + } + elseif ($config['type'] == 'multiple') + { + if (empty($data[$key]) || !is_array($data[$key])) + { + $data[$key] = 0; + continue; + } + + $binary = 0; + + foreach ($data[$key] as $k => $v) + { + if (array_key_exists($k, $config['options']) && !empty($v)) + { + $binary |= 0x01 << $k; + } + } + + $data[$key] = $binary; + } } if (!empty($data['code_postal'])) { if (!empty($data['pays']) && $data['pays'] == 'FR' && !preg_match('!^\d{5}$!', $data['code_postal'])) @@ -301,11 +325,11 @@ return true; } public function add($data = array(), $check_mandatory = true) { - $this->_checkFields($data); + $this->_checkFields($data, $check_mandatory); $db = DB::getInstance(); if (!empty($data['email']) && $db->simpleQuerySingle('SELECT 1 FROM membres WHERE email = ? LIMIT 1;', false, $data['email'])) { Index: include/lib.template.php ================================================================== --- include/lib.template.php +++ include/lib.template.php @@ -499,12 +499,19 @@ $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'); + +$tpl->register_modifier('format_sqlite_date_to_french', function ($d) { + if (strlen($d) == 10) + return \DateTime::createFromFormat('Y-m-d', $d)->format('d/m/Y'); + else + return \DateTime::createFromFormat('Y-m-d H:i:s', $d)->format('d/m/Y H:i'); +}); //$tpl->register_modifier('retard_cotisation', array('Membres', 'checkCotisation')); $tpl->register_modifier('strftime_fr', 'Garradin\tpl_strftime_fr'); $tpl->register_modifier('date_fr', 'Garradin\tpl_date_fr'); ?> Index: templates/admin/membres/fiche.tpl ================================================================== --- templates/admin/membres/fiche.tpl +++ templates/admin/membres/fiche.tpl @@ -16,67 +16,59 @@ {/if}