Overview
Comment:ne pas inclure les champs non-éditables/privés dans la vérification pour "mes infos"
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 62f1bacccfa822c437fa70463aba8fdf695c0973
User & Date: bohwaz on 2013-09-18 16:57:42
Other Links: manifest | tags
References
2020-12-08
23:25 Wiki page "Changelog/0.9" artifact: b9c916b4d1 user: bohwaz
Context
2013-09-29
11:27
Merges multiples de corrections dans la branche stable check-in: 3d710711d8 user: bohwaz tags: stable, 0.5.9
09:54
Mise à jour ergonomie mot de passe + 5 caractères minimum + vérification de la sécurité du mot de passe check-in: 71c4dbfd19 user: bohwaz tags: trunk
2013-09-18
16:57
ne pas inclure les champs non-éditables/privés dans la vérification pour "mes infos" check-in: 62f1bacccf user: bohwaz tags: trunk
16:34
  • Ne plus permettre aux admins de remplir des champs obligatoires vides
  • Ne pas limiter les champs privés aux admins, seulement au niveau >= écriture
check-in: 206335f864 user: bohwaz tags: trunk
Changes

Modified src/include/class.membres.php from [14ed0abebb] to [d08935a6ae].

225
226
227
228
229
230
231
232
233
234
235
236
237






238

239
240
241
242
243
244
245
246
247
        }

        return utils::mail($dest, $sujet, $message, array('From' => $from));
    }

    // Gestion des données ///////////////////////////////////////////////////////

    public function _checkFields(&$data, $check_mandatory = 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 (!empty($config['mandatory']) && $check_mandatory && ($check_password || $key != 'passe'))
                {
                    throw new UserException('Le champ "' . $config['title'] . '" doit obligatoirement être renseigné.');
                }
                elseif (!empty($config['mandatory']))
                {
                    continue;
                }







|





>
>
>
>
>
>
|
>

|







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
250
251
252
253
254
        }

        return utils::mail($dest, $sujet, $message, array('From' => $from));
    }

    // Gestion des données ///////////////////////////////////////////////////////

    public function _checkFields(&$data, $check_editable = true, $check_password = true)
    {
        $champs = Config::getInstance()->get('champs_membres');

        foreach ($champs->getAll() as $key=>$config)
        {
            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_password || $key != 'passe'))
                {
                    throw new UserException('Le champ "' . $config['title'] . '" doit obligatoirement être renseigné.');
                }
                elseif (!empty($config['mandatory']))
                {
                    continue;
                }
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
        {
            throw new UserException('Le mot de passe doit faire au moins 5 caractères.');
        }

        return true;
    }

    public function add($data = array(), $check_mandatory = true)
    {
        $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']))
        {
            throw new UserException('Cette adresse e-mail est déjà utilisée par un autre membre, il faut en choisir une autre.');
        }







|

|







325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
        {
            throw new UserException('Le mot de passe doit faire au moins 5 caractères.');
        }

        return true;
    }

    public function add($data = array())
    {
        $this->_checkFields($data);
        $db = DB::getInstance();

        if (!empty($data['email'])
            && $db->simpleQuerySingle('SELECT 1 FROM membres WHERE email = ? LIMIT 1;', false, $data['email']))
        {
            throw new UserException('Cette adresse e-mail est déjà utilisée par un autre membre, il faut en choisir une autre.');
        }
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
            $data['id_categorie'] = Config::getInstance()->get('categorie_membres');
        }

        $db->simpleInsert('membres', $data);
        return $db->lastInsertRowId();
    }

    public function edit($id, $data = array(), $check_mandatory = true)
    {
        $db = DB::getInstance();

        if (isset($data['id']) && ($data['id'] == $id || empty($data['id'])))
        {
            unset($data['id']);
        }

        $this->_checkFields($data, $check_mandatory, 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.');
        }








|








|







354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
            $data['id_categorie'] = Config::getInstance()->get('categorie_membres');
        }

        $db->simpleInsert('membres', $data);
        return $db->lastInsertRowId();
    }

    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_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.');
        }

Modified src/include/lib.template.php from [dd71740f1e] to [3e439b1ab2].

405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
    {
        $attributes .= 'disabled="disabled" ';
    }

    if (!empty($params['user_mode']) && empty($config['editable']))
    {
        $out = '<dt>' . htmlspecialchars($config['title'], ENT_QUOTES, 'UTF-8') . '</dt>';
        $out .= '<dd>' . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '</dd>';
        return $out;
    }

    if ($type == 'select')
    {
        $field .= '<select '.$attributes.'>';
        foreach ($config['options'] as $k=>$v)







|







405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
    {
        $attributes .= 'disabled="disabled" ';
    }

    if (!empty($params['user_mode']) && empty($config['editable']))
    {
        $out = '<dt>' . htmlspecialchars($config['title'], ENT_QUOTES, 'UTF-8') . '</dt>';
        $out .= '<dd>' . htmlspecialchars((trim($value) === '' ? 'Non renseigné' : ''), ENT_QUOTES, 'UTF-8') . '</dd>';
        return $out;
    }

    if ($type == 'select')
    {
        $field .= '<select '.$attributes.'>';
        foreach ($config['options'] as $k=>$v)

Modified src/www/admin/mes_infos.php from [58817fbfd6] to [0c7b4daab6].

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    else
    {
        try {
            $data = array();

            foreach ($config->get('champs_membres')->getAll() as $key=>$c)
            {
                if ($c['editable'])
                {
                    $data[$key] = utils::post($key);
                }
            }

            $membres->edit($membre['id'], $data);
            $membres->updateSessionData();

            utils::redirect('/admin/');
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();







|





|







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    else
    {
        try {
            $data = array();

            foreach ($config->get('champs_membres')->getAll() as $key=>$c)
            {
                if (!empty($c['editable']))
                {
                    $data[$key] = utils::post($key);
                }
            }

            $membres->edit($membre['id'], $data, false);
            $membres->updateSessionData();

            utils::redirect('/admin/');
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();