Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
afi
opacce
Commits
db1bfdb3
Commit
db1bfdb3
authored
Mar 25, 2020
by
Patrick Barroca
🤞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hotline #108358 : manuel link to dynamic user groups are ignored
parent
a3d3d130
Pipeline
#9741
passed with stage
in 43 minutes and 17 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
12 deletions
+94
-12
VERSIONS_HOTLINE/108358
VERSIONS_HOTLINE/108358
+1
-0
library/Class/UserGroup.php
library/Class/UserGroup.php
+3
-2
library/Class/Users.php
library/Class/Users.php
+6
-3
library/ZendAfi/Controller/Plugin/Manager/User.php
library/ZendAfi/Controller/Plugin/Manager/User.php
+8
-4
tests/application/modules/admin/controllers/UsersControllerTest.php
...ication/modules/admin/controllers/UsersControllerTest.php
+56
-1
tests/library/Class/DynamicUserGroupTest.php
tests/library/Class/DynamicUserGroupTest.php
+20
-2
No files found.
VERSIONS_HOTLINE/108358
0 → 100644
View file @
db1bfdb3
- ticket #108358 : Gestion des groupes : Les affectations manuelles à des groupes dynamiques ne sont plus supportées
\ No newline at end of file
library/Class/UserGroup.php
View file @
db1bfdb3
...
...
@@ -305,8 +305,9 @@ class Class_UserGroup extends Storm_Model_Abstract {
* @return array
*/
public
function
getUsers
()
{
return
$this
->
isManual
()
?
parent
::
_get
(
'users'
)
:
$this
->
getDynamicUsers
();
return
$this
->
isManual
()
?
parent
::
_get
(
'users'
)
:
$this
->
getDynamicUsers
();
}
...
...
library/Class/Users.php
View file @
db1bfdb3
...
...
@@ -811,8 +811,7 @@ class Class_Users extends Storm_Model_Abstract {
*/
public
function
getUserGroupsIds
()
{
$groups
=
$this
->
getUserGroups
();
return
array_map
(
function
(
$group
)
{
return
$group
->
getId
();},
return
array_map
(
function
(
$group
)
{
return
$group
->
getId
();},
$groups
);
}
...
...
@@ -828,7 +827,11 @@ class Class_Users extends Storm_Model_Abstract {
* @return array
*/
public
function
getUserGroups
()
{
return
array_merge
(
parent
::
_get
(
'user_groups'
),
return
array_merge
(
array_filter
(
parent
::
_get
(
'user_groups'
),
function
(
$group
)
{
return
!
$group
->
isDynamic
();
}),
$this
->
getDynamicUserGroups
());
}
...
...
library/ZendAfi/Controller/Plugin/Manager/User.php
View file @
db1bfdb3
...
...
@@ -78,10 +78,14 @@ class ZendAfi_Controller_Plugin_Manager_User extends ZendAfi_Controller_Plugin_M
protected
function
_getPost
(
$key
=
null
,
$default
=
null
)
{
$post
=
$this
->
_request
->
getPost
();
$post
[
'user_groups'
]
=
array_filter
(
array_map
(
function
(
$id
)
{
return
Class_UserGroup
::
find
((
int
)
$id
);},
explode
(
'-'
,
$this
->
_getParam
(
'user_group_ids'
,
''
)))
);
$mapper
=
function
(
$id
)
{
return
(
$group
=
Class_UserGroup
::
find
((
int
)
$id
))
&&
!
$group
->
isDynamic
()
?
$group
:
null
;
};
$post
[
'user_groups'
]
=
array_filter
(
array_map
(
$mapper
,
explode
(
'-'
,
$this
->
_getParam
(
'user_group_ids'
,
''
))));
$post
[
'date_fin'
]
=
isset
(
$post
[
'date_fin'
])
&&
trim
(
$post
[
'date_fin'
])
?
Class_Date
::
frToIso
(
trim
(
$post
[
'date_fin'
]))
...
...
tests/application/modules/admin/controllers/UsersControllerTest.php
View file @
db1bfdb3
...
...
@@ -2198,4 +2198,59 @@ class UsersControllerMassDeleteRunStepMatchingSuperAdminUserTest
$this
->
assertEquals
(
2
,
$json
->
done
);
$this
->
assertEquals
(
2
,
$json
->
total
);
}
}
\ No newline at end of file
}
/** @see http://forge.afi-sa.fr/issues/108358#note-9 */
class
UsersControllerPostEditWithDynamicGroupTest
extends
Admin_UsersControllerEditAdminTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
$this
->
fixture
(
'Class_UserGroup'
,
[
'id'
=>
33
,
'group_type'
=>
Class_UserGroup
::
TYPE_DYNAMIC
]);
$this
->
fixture
(
'Class_UserGroup'
,
[
'id'
=>
34
,
'group_type'
=>
Class_UserGroup
::
TYPE_MANUAL
]);
Class_Crypt
::
setPhpCommand
(
null
);
$this
->
postDispatch
(
'/admin/users/edit/id/10'
,
[
'login'
=>
'Tom'
,
'password'
=>
'tutu'
,
'nom'
=>
'Davis'
,
'prenom'
=>
'Miles'
,
'pseudo'
=>
'Dave'
,
'mail'
=>
'mdavis@free.fr'
,
'role_level'
=>
ZendAfi_Acl_AdminControllerRoles
::
MODO_PORTAIL
,
'id_site'
=>
'7'
,
'idabon'
=>
'2341'
,
'ordreabon'
=>
'2'
,
'telephone'
=>
''
,
'adresse'
=>
'12 rue miles'
,
'code_postal'
=>
'75000'
,
'ville'
=>
'Paris'
,
'civilite'
=>
1
,
'mobile'
=>
''
,
'naissance'
=>
'1976-02-17'
,
'date_debut'
=>
''
,
'date_fin'
=>
'14/10/2015'
,
'user_group_ids'
=>
'33-34'
,
'redmine_library'
=>
'15'
]);
}
/** @test */
public
function
membershipShouldNotBeCreatedForDynamicGroup
()
{
$this
->
assertNull
(
Class_UserGroupMembership
::
findFirstBy
([
'user_id'
=>
10
,
'user_group_id'
=>
33
]));
}
/** @test */
public
function
membershipShouldBeCreatedForManualGroup
()
{
$this
->
assertNotNull
(
Class_UserGroupMembership
::
findFirstBy
([
'user_id'
=>
10
,
'user_group_id'
=>
34
]));
}
}
tests/library/Class/DynamicUserGroupTest.php
View file @
db1bfdb3
...
...
@@ -170,8 +170,24 @@ class DynamicUserGroupModoBibTest extends DynamicUserGroupTestCase {
[
'id'
=>
13
,
'libelle'
=>
'Abonnés'
,
'group_type'
=>
Class_UserGroup
::
TYPE_DYNAMIC
,
'filters'
=>
json_encode
([
'search_valid_subscription'
=>
1
])]);
'filters'
=>
json_encode
([
'search_role_level'
=>
ZendAfi_Acl_AdminControllerRoles
::
ABONNE_SIGB
,
'search_valid_subscription'
=>
1
])]);
// @see http://forge.afi-sa.fr/issues/108358#note-9, manually linked to dynamic
$this
->
_max
=
$this
->
fixture
(
'Class_Users'
,
[
'id'
=>
32
,
'login'
=>
'max'
,
'password'
=>
'zemenace'
,
'id_site'
=>
1
,
'idabon'
=>
'88308ID'
,
'role_level'
=>
ZendAfi_Acl_AdminControllerRoles
::
ABONNE_SIGB
,
'date_fin'
=>
'2019-01-01'
,
'user_group_memberships'
=>
[
$this
->
fixture
(
'Class_UserGroupMembership'
,
[
'id'
=>
1000
,
'user_id'
=>
32
,
'user_group_id'
=>
13
])],
]);
;
$this
->
_late_subscribers
=
$this
->
fixture
(
'Class_UserGroup'
,
...
...
@@ -293,6 +309,7 @@ class DynamicUserGroupModoBibTest extends DynamicUserGroupTestCase {
[
'_gontran'
,
'_adults'
],
[
'_shella'
,
'_abonnes'
],
[
'_gontran'
,
'_abonnes'
],
[
'_max'
,
'_abonnes'
],
];
}
...
...
@@ -322,6 +339,7 @@ class DynamicUserGroupModoBibTest extends DynamicUserGroupTestCase {
[
'_gontran'
,
'_subscription_ended'
],
[
'_shella'
,
'_adults'
],
[
'_gontran'
,
'_minors'
],
[
'_max'
,
'_subscribers'
],
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment