Overview
Comment:Change wording for parent/children feature
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA3-256: 2ab90c453ded01d910163faf0119b247eaf85e4066de107a67935830795ed605
User & Date: bohwaz on 2022-08-07 22:57:39
Other Links: branch diff | manifest | tags
Context
2022-08-07
23:19
Use users_search table in search check-in: f9ce20c14d user: bohwaz tags: dev
22:57
Change wording for parent/children feature check-in: 2ab90c453d user: bohwaz tags: dev
22:50
Fix manifest check-in: 6b1399a8e2 user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Entities/Search.php from [e3809b00a9] to [7f67419860].

148
149
150
151
152
153
154

155
156
157
158
159
160
161
162
163
164
165
166
		if (null !== $this->_result) {
			return $this->_result;
		}

		$sql = $this->SQL($force_limit, $force_select);

		$allowed_tables = $this->getProtectedTables();


		try {
			$st = DB::getInstance()->protectSelect($allowed_tables, $sql);

			$this->_result = $st->execute();
			return $this->_result;
		}
		catch (DB_Exception $e) {
			throw new UserException('Erreur dans la requête : ' . $e->getMessage(), 0, $e);
		}
	}








>


|

|







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
		if (null !== $this->_result) {
			return $this->_result;
		}

		$sql = $this->SQL($force_limit, $force_select);

		$allowed_tables = $this->getProtectedTables();
		$db = DB::getInstance();

		try {
			$st = $db->protectSelect($allowed_tables, $sql);

			$this->_result = $db->execute($st);
			return $this->_result;
		}
		catch (DB_Exception $e) {
			throw new UserException('Erreur dans la requête : ' . $e->getMessage(), 0, $e);
		}
	}

Modified src/include/lib/Garradin/Entities/Users/User.php from [c1c6b6afb3] to [d530b13b54].

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
				$login_exists = $db->test(self::TABLE, sprintf('%s = ? COLLATE NOCASE AND id != ?', $db->quoteIdentifier($field)), $this->$field, $this->id());
			}

			$this->assert(!$login_exists, sprintf('Le champ "%s" (utilisé comme identifiant de connexion) est déjà utilisé par un autre membre. Il doit être unique pour chaque membre.', $df->fieldByKey($field)->label));
		}

		if ($this->id_parent !== null) {
			$this->assert(!$this->is_parent, 'Un membre ne peut être parent et enfant');
			$this->assert($this->id_parent > 0, 'Invalid parent ID');
			$this->assert(!$this->exists() || $this->id_parent != $this->id(), 'Invalid parent ID');
			$this->assert(!$db->test(self::TABLE, 'id = ? AND id_parent IS NOT NULL', $this->id_parent), 'Le membre parent sélectionné est déjà un enfant, et ne peut donc être à la fois enfant et parent.');
		}
	}

	public function delete(): bool
	{
		$session = Session::getInstance();








|


|







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
				$login_exists = $db->test(self::TABLE, sprintf('%s = ? COLLATE NOCASE AND id != ?', $db->quoteIdentifier($field)), $this->$field, $this->id());
			}

			$this->assert(!$login_exists, sprintf('Le champ "%s" (utilisé comme identifiant de connexion) est déjà utilisé par un autre membre. Il doit être unique pour chaque membre.', $df->fieldByKey($field)->label));
		}

		if ($this->id_parent !== null) {
			$this->assert(!$this->is_parent, 'Un membre ne peut être responsable et rattaché en même temps.');
			$this->assert($this->id_parent > 0, 'Invalid parent ID');
			$this->assert(!$this->exists() || $this->id_parent != $this->id(), 'Invalid parent ID');
			$this->assert(!$db->test(self::TABLE, 'id = ? AND id_parent IS NOT NULL', $this->id_parent), 'Le membre sélectionné comme responsable est déjà rattaché à un autre membre.');
		}
	}

	public function delete(): bool
	{
		$session = Session::getInstance();

Modified src/include/lib/Garradin/Users/AdvancedSearch.php from [5c1cb0940e] to [0dbf6a0142].

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
			'type'     => 'text',
			'null'     => true,
			'select'   => $fields::getNameFieldsSQL(),
			'order'    => sprintf('%s COLLATE U_NOCASE %%s', current($fields::getNameFields())),
		];

		$columns['is_parent'] = [
			'label' => 'Est parent',
			'type' => 'boolean',
			'null' => false,


		];


		$columns['is_child'] = [
			'label' => 'Est enfant',
			'type' => 'boolean',
			'null' => false,
			'select' => 'CASE WHEN id_parent IS NOT NULL AND id_parent != id THEN \'Oui\' ELSE \'Non\' END',
			'where' => 'id_parent IS NOT NULL',
		];

		foreach ($fields->all() as $name => $field)
		{
			/*
			// already included in identity







|


>
>


<

|


|







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
			'type'     => 'text',
			'null'     => true,
			'select'   => $fields::getNameFieldsSQL(),
			'order'    => sprintf('%s COLLATE U_NOCASE %%s', current($fields::getNameFields())),
		];

		$columns['is_parent'] = [
			'label' => 'Est responsable',
			'type' => 'boolean',
			'null' => false,
			'select' => 'CASE WHEN is_parent = 1 THEN \'Oui\' ELSE \'Non\' END',
			'where' => 'is_parent %s',
		];


		$columns['is_child'] = [
			'label' => 'Est rattaché',
			'type' => 'boolean',
			'null' => false,
			'select' => 'CASE WHEN id_parent IS NOT NULL THEN \'Oui\' ELSE \'Non\' END',
			'where' => 'id_parent IS NOT NULL',
		];

		foreach ($fields->all() as $name => $field)
		{
			/*
			// already included in identity

Modified src/templates/users/details.tpl from [859c95033a] to [4910d2b790].

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
		{/if}
		{if !empty($transactions_created)}
			<dt>Écritures comptables créées</dt>
			<dd><a href="{$admin_url}acc/transactions/creator.php?id={$user.id}">{$transactions_created} écritures comptables créées par ce membre</a></dd>
		{/if}
	{/if}
	{if $user->isChild()}
		<dt>Membre parent</dt>
		<dd>{link href="?id=%d"|args:$user.id_parent label=$parent_name}</dd>
		{if count($siblings)}
			<dt>Membres de la même famille</dt>
			{foreach from=$siblings item="sibling"}
				<dd>{link href="?id=%d"|args:$sibling.id label=$sibling.name}</dd>
			{/foreach}
		{/if}
	{elseif count($children)}
		<dt>Membres enfants</dt>
		{foreach from=$children item="child"}
			<dd>{link href="?id=%d"|args:$child.id label=$child.name}</dd>
		{/foreach}
	{/if}
</dl>

<aside class="describe">







|


|





|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
		{/if}
		{if !empty($transactions_created)}
			<dt>Écritures comptables créées</dt>
			<dd><a href="{$admin_url}acc/transactions/creator.php?id={$user.id}">{$transactions_created} écritures comptables créées par ce membre</a></dd>
		{/if}
	{/if}
	{if $user->isChild()}
		<dt>Membre responsable</dt>
		<dd>{link href="?id=%d"|args:$user.id_parent label=$parent_name}</dd>
		{if count($siblings)}
			<dt>Autres membres rattachés à {$parent_name}</dt>
			{foreach from=$siblings item="sibling"}
				<dd>{link href="?id=%d"|args:$sibling.id label=$sibling.name}</dd>
			{/foreach}
		{/if}
	{elseif count($children)}
		<dt>Membres rattachés</dt>
		{foreach from=$children item="child"}
			<dd>{link href="?id=%d"|args:$child.id label=$child.name}</dd>
		{/foreach}
	{/if}
</dl>

<aside class="describe">

Modified src/templates/users/edit.tpl from [3bfaaaaa12] to [dfe228b130].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
	<fieldset>
		<legend>Informations personnelles</legend>
		<dl>
			{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN)}
					{input type="select" name="id_category" label="Catégorie du membre" required=true source=$user options=$categories}
			{/if}

			{if !$user->hasChildren()}
				{input type="list" name="id_parent" label="Membre parent" target="!users/selector.php?no_children=1" help="Permet de regrouper les personnes de la même famille. Sélectionner ici le membre responsable." default=$user->getParentSelector() can_delete=true}
			{/if}

			{foreach from=$fields item="field"}
				{edit_dynamic_field field=$field user=$user context="edit"}
			{/foreach}
		</dl>
	</fieldset>







|
|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
	<fieldset>
		<legend>Informations personnelles</legend>
		<dl>
			{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN)}
					{input type="select" name="id_category" label="Catégorie du membre" required=true source=$user options=$categories}
			{/if}

			{if !$user->is_parent}
				{input type="list" name="id_parent" label="Rattacher à un membre" target="!users/selector.php?no_children=1" help="Permet de regrouper les personnes d'un même foyer par exemple. Sélectionner ici le membre responsable." default=$user->getParentSelector() can_delete=true}
			{/if}

			{foreach from=$fields item="field"}
				{edit_dynamic_field field=$field user=$user context="edit"}
			{/foreach}
		</dl>
	</fieldset>

Modified src/templates/users/new.tpl from [6607176e72] to [297fa8b627].

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

	<fieldset>
		<legend>Informations personnelles</legend>
		<dl>
			{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN)}
				{input type="select" name="id_category" label="Catégorie du membre" required=true options=$categories default=$default_category}
			{/if}
			{input type="list" name="id_parent" label="Membre parent" target="!users/selector.php?no_children=1" help="Permet de regrouper les personnes de la même famille. Sélectionner ici le membre responsable." can_delete=true}
			{foreach from=$fields item="field"}
				{edit_dynamic_field context="new" field=$field user=$user}
			{/foreach}
		</dl>
	</fieldset>

	<p class="submit">







|







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

	<fieldset>
		<legend>Informations personnelles</legend>
		<dl>
			{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN)}
				{input type="select" name="id_category" label="Catégorie du membre" required=true options=$categories default=$default_category}
			{/if}
			{input type="list" name="id_parent" label="Rattacher à un membre" target="!users/selector.php?no_children=1" help="Permet de regrouper les personnes d'un même foyer par exemple. Sélectionner ici le membre responsable." can_delete=true}
			{foreach from=$fields item="field"}
				{edit_dynamic_field context="new" field=$field user=$user}
			{/foreach}
		</dl>
	</fieldset>

	<p class="submit">