22
33namespace Activity ;
44
5- use Activity \Form \ActivityFieldFieldSet ;
5+ use Activity \Form \ActivityCategory as CategoryForm ;
6+ use Activity \Form \SignupList as SignupListForm ;
7+ use Activity \Form \SignupListField ;
68use Activity \Mapper \Activity ;
79use Activity \Mapper \ActivityCalendarOption ;
8- use Activity \Mapper \ActivityFieldValue ;
9- use Activity \Mapper \ActivityOption ;
10+ use Activity \Mapper \ActivityCategory ;
1011use Activity \Mapper \ActivityOptionCreationPeriod ;
1112use Activity \Mapper \ActivityOptionProposal ;
1213use Activity \Mapper \MaxActivities ;
1314use Activity \Mapper \Proposal ;
1415use Activity \Mapper \Signup ;
16+ use Activity \Mapper \SignupFieldValue ;
17+ use Activity \Mapper \SignupList as SignupListMapper ;
18+ use Activity \Mapper \SignupOption ;
1519use DoctrineModule \Stdlib \Hydrator \DoctrineObject ;
16- use User \Permissions \Assertion \IsCreator ;
17- use User \Permissions \Assertion \ IsOrganMember ;
20+ use User \Permissions \Assertion \IsCreatorOrOrganMember ;
21+ use User \Permissions \NotAllowedException ;
1822
1923class Module
2024{
21-
2225 /**
2326 * Get the autoloader configuration.
2427 *
@@ -64,7 +67,8 @@ public function getServiceConfig()
6467 'invokables ' => [
6568 'activity_service_activity ' => 'Activity\Service\Activity ' ,
6669 'activity_service_activityQuery ' => 'Activity\Service\ActivityQuery ' ,
67- 'activity_service_activityTranslator ' => 'Activity\Service\ActivityTranslator ' ,
70+ 'activity_service_category ' => 'Activity\Service\ActivityCategory ' ,
71+ 'activity_service_signupListQuery ' => 'Activity\Service\SignupListQuery ' ,
6872 'activity_form_activity_signup ' => 'Activity\Form\ActivitySignup '
6973 ],
7074 'factories ' => [
@@ -73,29 +77,45 @@ public function getServiceConfig()
7377 'activity_doctrine_em ' => function ($ sm ) {
7478 return $ sm ->get ('doctrine.entitymanager.orm_default ' );
7579 },
76- 'activity_form_activityfield_fieldset ' => function ($ sm ) {
77- $ form = new ActivityFieldFieldSet ();
80+ 'activity_form_signuplist ' => function ($ sm ) {
81+ $ translator = $ sm ->get ('translator ' );
82+ $ form = new SignupListForm ($ translator );
83+ $ form ->setHydrator ($ sm ->get ('activity_hydrator ' ));
84+ return $ form ;
85+ },
86+ 'activity_form_signuplist_fields ' => function ($ sm ) {
87+ $ form = new SignupListField ();
7888 $ form ->setHydrator ($ sm ->get ('activity_hydrator ' ));
7989 return $ form ;
8090 },
8191 'activity_form_activity ' => function ($ sm ) {
8292 $ organService = $ sm ->get ('decision_service_organ ' );
8393 $ organs = $ organService ->getEditableOrgans ();
94+ $ companyService = $ sm ->get ('company_service_company ' );
95+ try {
96+ $ companies = $ companyService ->getHiddenCompanyList ();
97+ } catch (NotAllowedException $ e ) {
98+ $ companies = [];
99+ }
100+ $ categoryService = $ sm ->get ('activity_service_category ' );
101+ $ categories = $ categoryService ->getAllCategories ();
84102 $ translator = $ sm ->get ('translator ' );
85- $ form = new \ Activity \ Form \Activity ($ organs , $ translator , $ sm -> get ( ' activity_doctrine_em ' ) );
103+ $ form = new Form \Activity ($ organs , $ companies , $ categories , $ translator );
86104 $ form ->setHydrator ($ sm ->get ('activity_hydrator ' ));
87105 return $ form ;
88106 },
89107 'activity_form_calendar_proposal ' => function ($ sm ) {
90108 $ calendarService = $ sm ->get ('activity_service_calendar ' );
91- $ form = new Form \ActivityCalendarProposal ($ sm ->get ('translator ' ), $ calendarService );
92- return $ form ;
109+ return new Form \ActivityCalendarProposal ($ sm ->get ('translator ' ), $ calendarService );
93110 },
94111 'activity_form_calendar_option ' => function ($ sm ) {
95112 $ translator = $ sm ->get ('translator ' );
96113 $ calendarService = $ sm ->get ('activity_service_calendar ' );
97- $ form = new Form \ActivityCalendarOption ($ translator , $ calendarService );
98- return $ form ;
114+ return new Form \ActivityCalendarOption ($ translator , $ calendarService );
115+ },
116+ 'activity_form_category ' => function ($ sm ) {
117+ $ translator = $ sm ->get ('translator ' );
118+ return new CategoryForm ($ translator );
99119 },
100120 'activity_hydrator ' => function ($ sm ) {
101121 return new DoctrineObject (
@@ -125,6 +145,11 @@ public function getServiceConfig()
125145 $ sm ->get ('activity_doctrine_em ' )
126146 );
127147 },
148+ 'activity_mapper_category ' => function ($ sm ) {
149+ return new ActivityCategory (
150+ $ sm ->get ('activity_doctrine_em ' )
151+ );
152+ },
128153 'activity_mapper_period ' => function ($ sm ) {
129154 return new ActivityOptionCreationPeriod (
130155 $ sm ->get ('activity_doctrine_em ' )
@@ -135,13 +160,18 @@ public function getServiceConfig()
135160 $ sm ->get ('activity_doctrine_em ' )
136161 );
137162 },
138- 'activity_mapper_activity_field_value ' => function ($ sm ) {
139- return new ActivityFieldValue (
163+ 'activity_mapper_signuplist ' => function ($ sm ) {
164+ return new SignupListMapper (
140165 $ sm ->get ('activity_doctrine_em ' )
141166 );
142167 },
143- 'activity_mapper_activity_option ' => function ($ sm ) {
144- return new ActivityOption (
168+ 'activity_mapper_signup_field_value ' => function ($ sm ) {
169+ return new SignupFieldValue (
170+ $ sm ->get ('activity_doctrine_em ' )
171+ );
172+ },
173+ 'activity_mapper_signup_option ' => function ($ sm ) {
174+ return new SignupOption (
145175 $ sm ->get ('activity_doctrine_em ' )
146176 );
147177 },
@@ -170,34 +200,42 @@ public function getServiceConfig()
170200 $ acl ->addResource ('activity ' );
171201 $ acl ->addResource ('activityApi ' );
172202 $ acl ->addResource ('myActivities ' );
173- $ acl ->addResource ('activitySignup ' );
174203 $ acl ->addResource ('model ' );
175204 $ acl ->addResource ('activity_calendar_proposal ' );
205+ $ acl ->addResource ('signupList ' );
176206
177- $ acl ->allow ('guest ' , 'activity ' , 'view ' );
207+ $ acl ->allow ('guest ' , 'activity ' , ['view ' , 'viewCategory ' ]);
208+ $ acl ->allow ('guest ' , 'signupList ' , ['view ' , 'externalSignup ' ]);
178209
179- $ acl ->allow ('guest ' , 'activitySignup ' , 'externalSignup ' );
210+ $ acl ->allow ('user ' , 'activity_calendar_proposal ' , ['create ' , 'delete_own ' ]);
211+ $ acl ->allow ('admin ' , 'activity_calendar_proposal ' , ['create_always ' , 'delete_all ' , 'approve ' ]);
180212
181- $ acl ->allow ('user ' , 'activity ' , 'create ' );
182213 $ acl ->allow ('user ' , 'myActivities ' , 'view ' );
183- $ acl ->allow ('user ' , 'activitySignup ' , ['view ' , 'signup ' , 'signoff ' , 'checkUserSignedUp ' ]);
214+ $ acl ->allow (
215+ 'user ' ,
216+ 'signupList ' ,
217+ ['view ' , 'viewDetails ' , 'signup ' , 'signoff ' , 'checkUserSignedUp ' ]
218+ );
184219
185- $ acl ->allow ('admin ' , 'activity ' , ['update ' , 'viewDetails ' , 'adminSignup ' ]);
186- $ acl ->allow ('user ' , 'activity ' , ['update ' , 'viewDetails ' , 'adminSignup ' ], new IsCreator ());
220+ $ acl ->allow ('active_member ' , 'activity ' , ['create ' , 'viewAdmin ' , 'listCategories ' ]);
187221 $ acl ->allow (
188222 'active_member ' ,
189223 'activity ' ,
190- ['update ' , 'viewDetails ' , 'adminSignup ' ],
191- new IsOrganMember ()
224+ ['update ' , 'viewDetails ' , 'adminSignup ' , 'viewParticipants ' , 'exportParticipants ' ],
225+ new IsCreatorOrOrganMember ()
226+ );
227+ $ acl ->allow (
228+ 'active_member ' ,
229+ 'signupList ' ,
230+ ['adminSignup ' , 'viewParticipants ' , 'exportParticipants ' ],
231+ new IsCreatorOrOrganMember ()
192232 );
193233
194- $ acl ->allow ('sosuser ' , 'activitySignup ' , ['signup ' , 'signoff ' , 'checkUserSignedUp ' ]);
234+ $ acl ->allow ('sosuser ' , 'signupList ' , ['signup ' , 'signoff ' , 'checkUserSignedUp ' ]);
195235
196236 $ acl ->allow ('user ' , 'activityApi ' , 'list ' );
197237 $ acl ->allow ('apiuser ' , 'activityApi ' , 'list ' );
198238
199- $ acl ->allow ('user ' , 'activity_calendar_proposal ' , ['create ' , 'delete_own ' ]);
200- $ acl ->allow ('admin ' , 'activity_calendar_proposal ' , ['create_always ' , 'delete_all ' , 'approve ' ]);
201239 return $ acl ;
202240 },
203241 ]
0 commit comments