18
18
use App \Services \Model \ISummitProposedScheduleAllowedLocationService ;
19
19
use models \oauth2 \IResourceServerContext ;
20
20
use models \summit \ISummitRepository ;
21
+ use models \summit \PresentationCategory ;
22
+ use models \summit \Summit ;
21
23
use ModelSerializers \SerializerRegistry ;
22
24
use utils \Filter ;
23
25
use utils \FilterElement ;
@@ -75,6 +77,20 @@ public function __construct
75
77
$ this ->repository = $ repository ;
76
78
}
77
79
80
+ /**
81
+ * @param Summit $summit
82
+ * @param PresentationCategory $track
83
+ * @return bool
84
+ */
85
+ private function isCurrentUserAuth (Summit $ summit , PresentationCategory $ track ):bool {
86
+ $ current_member = $ this ->resource_server_context ->getCurrentUser ();
87
+ if (is_null ($ current_member )) return false ;
88
+ if ($ current_member ->isAdmin ()) return true ;
89
+ if ($ summit ->isSummitAdmin ($ current_member )) return true ;
90
+ if ($ summit ->isTrackChair ($ current_member , $ track )) return true ;
91
+ return false ;
92
+ }
93
+
78
94
/**
79
95
* @param $summit_id
80
96
* @param $track_id
@@ -88,6 +104,9 @@ public function getAllAllowedLocationByTrack($summit_id, $track_id){
88
104
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
89
105
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
90
106
107
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
108
+ return $ this ->error403 ();
109
+
91
110
return $ this ->_getAll (
92
111
function () {
93
112
return [
@@ -133,6 +152,9 @@ public function addAllowedLocationToTrack($summit_id, $track_id){
133
152
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
134
153
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
135
154
155
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
156
+ return $ this ->error403 ();
157
+
136
158
$ payload = $ this ->getJsonPayload (SummitProposedScheduleAllowedLocationValidationRulesFactory::buildForAdd ());
137
159
138
160
return $ this ->created (SerializerRegistry::getInstance ()->getSerializer ($ this ->service ->addProposedLocationToTrack ($ track , $ payload ))
@@ -159,6 +181,9 @@ public function getAllowedLocationFromTrack($summit_id, $track_id, $location_id)
159
181
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
160
182
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
161
183
184
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
185
+ return $ this ->error403 ();
186
+
162
187
$ allowed_location = $ track ->getAllowedLocationById (intval ($ location_id ));
163
188
164
189
if (is_null ($ allowed_location )) return $ this ->error404 ();
@@ -181,6 +206,9 @@ public function removeAllowedLocationFromTrack($summit_id, $track_id, $location_
181
206
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
182
207
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
183
208
209
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
210
+ return $ this ->error403 ();
211
+
184
212
$ this ->service ->deleteProposedLocationFromTrack ($ track , intval ($ location_id ));
185
213
186
214
return $ this ->deleted ();
@@ -200,6 +228,9 @@ public function removeAllAllowedLocationFromTrack($summit_id, $track_id){
200
228
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
201
229
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
202
230
231
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
232
+ return $ this ->error403 ();
233
+
203
234
$ this ->service ->deleteAllProposedLocationFromTrack ($ track );
204
235
205
236
return $ this ->deleted ();
@@ -220,6 +251,9 @@ public function addTimeFrame2AllowedLocation($summit_id, $track_id, $location_id
220
251
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
221
252
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
222
253
254
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
255
+ return $ this ->error403 ();
256
+
223
257
$ payload = $ this ->getJsonPayload (SummitProposedScheduleAllowedDayValidationRulesFactory::buildForAdd ());
224
258
225
259
return $ this ->created (SerializerRegistry::getInstance ()->getSerializer ($ this ->service ->addAllowedDayToProposedLocation ($ track , intval ($ location_id ), $ payload ))
@@ -246,6 +280,9 @@ public function getAllTimeFrameFromAllowedLocation($summit_id, $track_id, $locat
246
280
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
247
281
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
248
282
283
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
284
+ return $ this ->error403 ();
285
+
249
286
$ allowed_location = $ track ->getAllowedLocationById (intval ($ location_id ));
250
287
if (is_null ($ allowed_location )) return $ this ->error404 ();
251
288
@@ -321,6 +358,9 @@ public function getTimeFrameFromAllowedLocation($summit_id, $track_id, $location
321
358
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
322
359
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
323
360
361
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
362
+ return $ this ->error403 ();
363
+
324
364
$ allowed_location = $ track ->getAllowedLocationById (intval ($ location_id ));
325
365
326
366
if (is_null ($ allowed_location )) return $ this ->error404 ();
@@ -353,6 +393,9 @@ public function removeTimeFrameFromAllowedLocation($summit_id, $track_id, $locat
353
393
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
354
394
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
355
395
396
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
397
+ return $ this ->error403 ();
398
+
356
399
$ this ->service ->deleteAllowedDayToProposedLocation ($ track , intval ($ location_id ), intval ($ time_frame_id ));
357
400
358
401
return $ this ->deleted ();
@@ -373,6 +416,9 @@ public function removeAllTimeFrameFromAllowedLocation($summit_id, $track_id, $lo
373
416
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
374
417
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
375
418
419
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
420
+ return $ this ->error403 ();
421
+
376
422
$ this ->service ->deleteAllAllowedDayToProposedLocation ($ track , intval ($ location_id ));
377
423
378
424
return $ this ->deleted ();
@@ -394,6 +440,9 @@ public function updateTimeFrameFromAllowedLocation($summit_id, $track_id, $locat
394
440
$ track = $ summit ->getPresentationCategory (intval ($ track_id ));
395
441
if (is_null ($ track ) || !$ track ->isChairVisible ()) return $ this ->error404 ();
396
442
443
+ if (!$ this ->isCurrentUserAuth ($ summit , $ track ))
444
+ return $ this ->error403 ();
445
+
397
446
$ payload = $ this ->getJsonPayload (SummitProposedScheduleAllowedDayValidationRulesFactory::buildForUpdate ());
398
447
399
448
return $ this ->updated (SerializerRegistry::getInstance ()->getSerializer ($ this ->service ->updateAllowedDayToProposedLocation ($ track , intval ($ location_id ), intval ($ time_frame_id ), $ payload ))
0 commit comments