Index: src/include/class.membres.php ================================================================== --- src/include/class.membres.php +++ src/include/class.membres.php @@ -227,19 +227,26 @@ return utils::mail($dest, $sujet, $message, array('From' => $from)); } // Gestion des données /////////////////////////////////////////////////////// - public function _checkFields(&$data, $check_mandatory = true, $check_password = true) + public function _checkFields(&$data, $check_editable = true, $check_password = true) { $champs = Config::getInstance()->get('champs_membres'); foreach ($champs->getAll() as $key=>$config) { - if (!isset($data[$key]) || empty($data[$key]) || (!is_array($data[$key]) && trim($data[$key]) == '')) + if (!$check_editable && (!empty($config['private']) || empty($config['editable']))) + { + unset($data[$key]); + continue; + } + + if (!isset($data[$key]) || (!is_array($data[$key]) && trim($data[$key]) == '') + || (is_array($data[$key]) && empty($data[$key]))) { - if (!empty($config['mandatory']) && $check_mandatory && ($check_password || $key != 'passe')) + if (!empty($config['mandatory']) && ($check_password || $key != 'passe')) { throw new UserException('Le champ "' . $config['title'] . '" doit obligatoirement être renseigné.'); } elseif (!empty($config['mandatory'])) { @@ -320,13 +327,13 @@ } return true; } - public function add($data = array(), $check_mandatory = true) + public function add($data = array()) { - $this->_checkFields($data, $check_mandatory); + $this->_checkFields($data); $db = DB::getInstance(); if (!empty($data['email']) && $db->simpleQuerySingle('SELECT 1 FROM membres WHERE email = ? LIMIT 1;', false, $data['email'])) { @@ -349,20 +356,20 @@ $db->simpleInsert('membres', $data); return $db->lastInsertRowId(); } - public function edit($id, $data = array(), $check_mandatory = true) + public function edit($id, $data = array(), $check_editable = true) { $db = DB::getInstance(); if (isset($data['id']) && ($data['id'] == $id || empty($data['id']))) { unset($data['id']); } - $this->_checkFields($data, $check_mandatory, false); + $this->_checkFields($data, $check_editable, false); if (!empty($data['email']) && $db->simpleQuerySingle('SELECT 1 FROM membres WHERE email = ? AND id != ? LIMIT 1;', false, $data['email'], (int)$id)) { throw new UserException('Cette adresse e-mail est déjà utilisée par un autre membre, il faut en choisir une autre.'); Index: src/include/lib.template.php ================================================================== --- src/include/lib.template.php +++ src/include/lib.template.php @@ -407,11 +407,11 @@ } if (!empty($params['user_mode']) && empty($config['editable'])) { $out = '