Overview
Comment:Improve user list
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA3-256: 60f662fe298788a18f887316aaf5c436806a87b9d591c0de72673e95cbc7bbb8
User & Date: bohwaz on 2022-01-10 20:27:17
Other Links: branch diff | manifest | tags
Context
2022-01-10
21:36
Rename and modernize user details check-in: 820131b891 user: bohwaz tags: dev
20:27
Improve user list check-in: 60f662fe29 user: bohwaz tags: dev
20:08
Fix upgrade check-in: 4e37103dd8 user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Users/DynamicFields.php from [8427c05167] to [aab0ec3d62].

333
334
335
336
337
338
339
340
341




342



343
344
345


346
347
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
	public function getMultiples()
	{
		return array_filter($this->_fields, function ($a) {
			return $a->type == 'multiple';
		});
	}

	public function getListedFields()
	{




		$champs = $this->_fields;




		$champs = array_filter($champs, function ($a) {
			return empty($a->list_row) ? false : true;


		});

		uasort($champs, function ($a, $b) {
			if ($a->list_row == $b->list_row)
				return 0;

			return ($a->list_row > $b->list_row) ? 1 : -1;
		});

		return (object) $champs;
	}

	public function getFirstListed()
	{
		foreach ($this->champs as $key=>$config)
		{
			if (empty($config->list_row))
			{
				continue;
			}

			return $key;
		}
	}



	public function getSQLSchema(string $table_name = User::TABLE): string
	{
		$db = DB::getInstance();

		// Champs à créer
		$create = [







|

>
>
>
>
|
>
>
>
|
|
|
>
>
|

|






<
<
<
<
<
<
<
<
<
<
<
<
|
|
<
<
<







333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
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
	public function getMultiples()
	{
		return array_filter($this->_fields, function ($a) {
			return $a->type == 'multiple';
		});
	}

	public function getListedFields(): array
	{
		$name_fields = self::getNameFields();
		$name_fields[] = self::getNumberField();

		$fields = array_filter(
			$this->_fields,
			function ($a, $b) use ($name_fields) {
				if (in_array($b, $name_fields)) {
					return false;
				}

				return empty($a->list_row) ? false : true;
			},
			ARRAY_FILTER_USE_BOTH
		);

		uasort($fields, function ($a, $b) {
			if ($a->list_row == $b->list_row)
				return 0;

			return ($a->list_row > $b->list_row) ? 1 : -1;
		});













		return $fields;
	}




	public function getSQLSchema(string $table_name = User::TABLE): string
	{
		$db = DB::getInstance();

		// Champs à créer
		$create = [

Modified src/templates/admin/membres/index.tpl from [99c33965df] to [2cd2cdb0a5].

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

{if !empty($categories)}
<form method="get" action="{$self_url}" class="shortFormRight">
    <fieldset>
        <legend>Filtrer par catégorie</legend>
        <select name="cat" id="f_cat" onchange="this.form.submit();">
            <option value="0" {if $current_cat == 0} selected="selected"{/if}>-- Toutes</option>
        {foreach from=$categories key="id" item="nom"}
            {if $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)
                || !array_key_exists($id, $hidden_categories)}
            <option value="{$id}"{if $current_cat == $id} selected="selected"{/if}>{$nom}</option>
            {/if}
        {/foreach}
        </select>
        <noscript><input type="submit" value="Filtrer &rarr;" /></noscript>
    </fieldset>
</form>
{/if}







|


|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

{if !empty($categories)}
<form method="get" action="{$self_url}" class="shortFormRight">
    <fieldset>
        <legend>Filtrer par catégorie</legend>
        <select name="cat" id="f_cat" onchange="this.form.submit();">
            <option value="0" {if $current_cat == 0} selected="selected"{/if}>-- Toutes</option>
        {foreach from=$categories key="id" item="name"}
            {if $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)
                || !array_key_exists($id, $hidden_categories)}
            <option value="{$id}"{if $current_cat == $id} selected="selected"{/if}>{$name}</option>
            {/if}
        {/foreach}
        </select>
        <noscript><input type="submit" value="Filtrer &rarr;" /></noscript>
    </fieldset>
</form>
{/if}
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    {foreach from=$list->iterate() item="row"}
        <tr>
            {if $can_edit}
                <td class="check">{input type="checkbox" name="selected[]" value=$row._user_id}</td>
            {/if}
            {foreach from=$list->getHeaderColumns() key="key" item="value"}
                <?php $value = $row->$key; ?>
                {if $key == 'numero'}
                <td class="num">
                    <a href="{$admin_url}membres/fiche.php?id={$row._user_id}">{$value}</a>
                </td>
                {elseif $key == $id_field}
                <th><a href="{$admin_url}membres/fiche.php?id={$row._user_id}">{$value|raw|display_champ_membre:$key}</a></th>
                {else}
                <td>
                    {$value|raw|display_champ_membre:$key}
                </td>
                {/if}
            {/foreach}

            <td class="actions">
                {linkbutton label="Fiche membre" shape="user" href="!membres/fiche.php?id=%d"|args:$row._user_id}
                {if $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)}
                    {linkbutton label="Modifier" shape="edit" href="!membres/modifier.php?id=%d"|args:$row._user_id}







|
|
|
|
|
|

|
|
|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    {foreach from=$list->iterate() item="row"}
        <tr>
            {if $can_edit}
                <td class="check">{input type="checkbox" name="selected[]" value=$row._user_id}</td>
            {/if}
            {foreach from=$list->getHeaderColumns() key="key" item="value"}
                <?php $value = $row->$key; ?>
                {if $key == 'number'}
                    <td class="num">
                        {link href="details.php?id=%d"|args:$row._user_id label=$value}
                    </td>
                {elseif $key == 'identity'}
                    <th>{link href="details.php?id=%d"|args:$row._user_id label=$value}</th>
                {else}
                    <td>
                        {$value|raw|display_champ_membre:$key}
                    </td>
                {/if}
            {/foreach}

            <td class="actions">
                {linkbutton label="Fiche membre" shape="user" href="!membres/fiche.php?id=%d"|args:$row._user_id}
                {if $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)}
                    {linkbutton label="Modifier" shape="edit" href="!membres/modifier.php?id=%d"|args:$row._user_id}

Modified src/www/admin/membres/index.php from [a64439f1c2] to [5865998483].

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
<?php
namespace Garradin;

use Garradin\Users\Categories;


require_once __DIR__ . '/_inc.php';

$categories = Categories::listSimple();
$hidden_categories = Categories::listHidden();

$current_cat = (int) qg('cat') ?: null;

// Deny access to hidden categories to users that are not admins
if ($current_cat && !$session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN) && array_key_exists($current_cat, $hidden_categories)) {
	$current_cat = null;
}

$can_edit = $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN);

$list = $membres->listByCategory($current_cat);
$list->loadFromQueryString();

$tpl->assign('sent', null !== qg('sent'));

$id_field = Config::getInstance()->get('champ_identite');

$tpl->assign(compact('can_edit', 'list', 'current_cat', 'hidden_categories', 'categories', 'id_field'));

$tpl->display('admin/membres/index.tpl');




>















|




<
<
|


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
<?php
namespace Garradin;

use Garradin\Users\Categories;
use Garradin\Users\Users;

require_once __DIR__ . '/_inc.php';

$categories = Categories::listSimple();
$hidden_categories = Categories::listHidden();

$current_cat = (int) qg('cat') ?: null;

// Deny access to hidden categories to users that are not admins
if ($current_cat && !$session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN) && array_key_exists($current_cat, $hidden_categories)) {
	$current_cat = null;
}

$can_edit = $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN);

$list = Users::listByCategory($current_cat);
$list->loadFromQueryString();

$tpl->assign('sent', null !== qg('sent'));



$tpl->assign(compact('can_edit', 'list', 'current_cat', 'hidden_categories', 'categories'));

$tpl->display('admin/membres/index.tpl');