9
9
require 'github.php ' ;
10
10
require 'validation.php ' ;
11
11
12
- use Symfony \Component \Form \Extension \Core \Type \CheckboxType ;
13
- use Symfony \Component \Form \Extension \Core \Type \ChoiceType ;
14
- use Symfony \Component \Form \Extension \Core \Type \HiddenType ;
15
-
16
12
$ page = $ _REQUEST ['page ' ] ?? '' ;
17
13
18
14
use Symfony \Component \Form \Extension \HttpFoundation \HttpFoundationExtension ;
24
20
$ custom_header = null ;
25
21
$ form = null ;
26
22
$ select_form = null ;
23
+ $ comments_form = null ;
27
24
$ embed_file = null ;
28
25
$ info_message = null ;
29
26
$ success_message = null ;
35
32
$ monospace = null ;
36
33
$ bottom_links = null ;
37
34
$ refresh_url = null ;
35
+ $ confirm = null ;
36
+ $ comments = null ;
37
+ $ ci_failures = null ;
38
38
39
39
$ request = \Symfony \Component \HttpFoundation \Request::createFromGlobals ();
40
40
@@ -59,7 +59,8 @@ function terminate($error_message = null, $template = 'main.html.twig',
59
59
$ extra_fields = []) {
60
60
global $ page , $ deadline , $ table , $ lists , $ info_box , $ form , $ select_form ;
61
61
global $ embed_file , $ info_message , $ success_message , $ monospace , $ refresh_url ;
62
- global $ custom_header , $ bottom_links , $ top_box ;
62
+ global $ custom_header , $ bottom_links , $ top_box , $ confirm , $ comments ;
63
+ global $ comments_form , $ ci_failures ;
63
64
64
65
$ appvar = new \ReflectionClass ('\Symfony\Bridge\Twig\AppVariable ' );
65
66
$ loader = new \Twig \Loader \FilesystemLoader ([
@@ -129,12 +130,17 @@ function terminate($error_message = null, $template = 'main.html.twig',
129
130
'top_box ' => $ top_box ,
130
131
'info_box ' => $ info_box ,
131
132
'monospace ' => $ monospace ,
133
+ 'confirm ' => $ confirm ,
134
+ 'comments ' => $ comments ,
135
+ 'ci_failures ' => $ ci_failures ,
132
136
'deadline ' => $ deadline ? $ deadline ->format ('c ' ) : null ,
133
137
'bottom_links ' => $ bottom_links ,
134
138
'refresh_url ' => $ refresh_url ,
135
139
'form ' => $ form === null ? null : $ form ->createView (),
136
140
'select_form ' => $ select_form === null
137
141
? null : $ select_form ->createView (),
142
+ 'comments_form ' => $ comments_form === null
143
+ ? null : $ comments_form ->createView (),
138
144
];
139
145
140
146
if (!$ error_message ) {
@@ -144,103 +150,4 @@ function terminate($error_message = null, $template = 'main.html.twig',
144
150
exit ();
145
151
}
146
152
147
- function filter_by ($ filters ) {
148
- global $ page , $ request , $ formFactory , $ select_form ;
149
- $ select_form = $ formFactory ->createNamedBuilder ('' ,
150
- Symfony \Component \Form \Extension \Core \Type \FormType::class);
151
-
152
- $ select_form ->add ('page ' , HiddenType::class, [
153
- 'data ' => $ page ,
154
- ]);
155
-
156
- $ selected_year = $ request ->query ->get ('year ' , db_get_group_years ()[0 ]['year ' ]);
157
- $ selected_shift = $ request ->query ->get ('shift ' , null );
158
- $ own_shifts_only = $ request ->query ->get ('own_shifts ' , false ) ? true : false ;
159
- $ selected_group = $ request ->query ->get ('group ' , 'all ' );
160
- $ selected_repo = $ request ->query ->get ('repo ' , 'all ' );
161
- $ return = null ;
162
-
163
- $ selected_shift_obj = $ selected_shift && $ selected_shift != 'all '
164
- ? db_fetch_shift_id ($ selected_shift ) : null ;
165
-
166
- if (in_array ('year ' , $ filters )) {
167
- $ years = [];
168
- foreach (db_get_group_years () as $ year ) {
169
- $ years [$ year ['year ' ]] = $ year ['year ' ];
170
- }
171
- $ select_form ->add ('year ' , ChoiceType::class, [
172
- 'label ' => 'Year ' ,
173
- 'choices ' => $ years ,
174
- 'data ' => $ selected_year ,
175
- ]);
176
- $ return = $ selected_year ;
177
- }
178
- if (in_array ('shift ' , $ filters )) {
179
- $ shifts = ['All ' => 'all ' ];
180
- foreach (db_fetch_shifts ($ selected_year ) as $ shift ) {
181
- if (!has_shift_permissions ($ shift ))
182
- continue ;
183
- if ($ own_shifts_only && $ shift ->prof != get_user ())
184
- continue ;
185
- $ shifts [$ shift ->name ] = $ shift ->id ;
186
- }
187
- $ select_form ->add ('shift ' , ChoiceType::class, [
188
- 'label ' => 'Shift ' ,
189
- 'choices ' => $ shifts ,
190
- 'data ' => $ selected_shift ,
191
- ]);
192
- }
193
- if (in_array ('group ' , $ filters )) {
194
- $ groups = ['All ' => 'all ' ];
195
- $ return = [];
196
- foreach (db_fetch_groups ($ selected_year ) as $ group ) {
197
- if (!has_group_permissions ($ group ))
198
- continue ;
199
- if ($ own_shifts_only && $ group ->prof () != get_user ())
200
- continue ;
201
- if ($ selected_shift_obj && $ group ->shift != $ selected_shift_obj )
202
- continue ;
203
- if ($ selected_repo != 'all ' && $ group ->getRepositoryId () != $ selected_repo )
204
- continue ;
205
-
206
- if ($ selected_group == 'all ' || $ group ->id == $ selected_group )
207
- $ return [] = $ group ;
208
- $ groups [$ group ->group_number ] = $ group ->id ;
209
- }
210
- $ select_form ->add ('group ' , ChoiceType::class, [
211
- 'label ' => 'Group ' ,
212
- 'choices ' => $ groups ,
213
- 'data ' => $ selected_group ,
214
- ]);
215
- }
216
- if (in_array ('repo ' , $ filters )) {
217
- $ repos = [];
218
- foreach (db_fetch_groups ($ selected_year ) as $ group ) {
219
- if (!has_group_permissions ($ group ))
220
- continue ;
221
-
222
- if ($ repo = $ group ->getRepositoryId ())
223
- $ repos [$ repo ] = true ;
224
- }
225
- $ repos = array_keys ($ repos );
226
- natsort ($ repos );
227
-
228
- $ repos = ['All ' => 'all ' ] + array_combine ($ repos , $ repos );
229
- $ select_form ->add ('repo ' , ChoiceType::class, [
230
- 'label ' => 'Repository ' ,
231
- 'choices ' => $ repos ,
232
- 'data ' => $ selected_repo ,
233
- ]);
234
- }
235
- if (in_array ('own_shifts ' , $ filters )) {
236
- $ select_form ->add ('own_shifts ' , CheckboxType::class, [
237
- 'label ' => 'Show only own shifts ' ,
238
- 'data ' => $ own_shifts_only ,
239
- ]);
240
- }
241
- $ select_form = $ select_form ->getForm ();
242
- $ select_form ->handleRequest ($ request );
243
- return $ return ;
244
- }
245
-
246
153
terminate ();
0 commit comments