22
22
23
23
$ myCourseListAsCategory = api_get_configuration_value ('my_courses_list_as_category ' );
24
24
25
+ $ baseUrl = api_get_path (WEB_CODE_PATH ).'admin/course_category.php? '
26
+ .http_build_query (['category ' => $ parentInfo ['code ' ] ?? '' ]);
27
+
25
28
if (!empty ($ action )) {
26
29
if ('export ' === $ action ) {
27
30
$ categoryInfo = CourseCategory::getCategoryById ($ categoryId );
@@ -48,10 +51,10 @@ function ($value) {
48
51
if ($ action === 'delete ' ) {
49
52
CourseCategory::deleteNode ($ categoryId );
50
53
Display::addFlash (Display::return_message (get_lang ('Deleted ' )));
51
- header ('Location: ' .api_get_self (). ' ?category= ' .Security:: remove_XSS ( $ category ) );
54
+ header ('Location: ' .$ baseUrl );
52
55
exit ();
53
56
} elseif (($ action === 'add ' || $ action === 'edit ' ) && isset ($ _POST ['formSent ' ]) && $ _POST ['formSent ' ]) {
54
- $ newParentCategoryCode = $ _POST ['parent_id ' ] ?? $ category ;
57
+ $ newParentCategoryCode = $ _POST ['parent_id ' ] ?? $ parentInfo [ ' code ' ] ?? '' ;
55
58
56
59
if ($ action === 'add ' ) {
57
60
$ ret = CourseCategory::addNode (
@@ -69,7 +72,7 @@ function ($value) {
69
72
$ _POST ['auth_course_child ' ],
70
73
$ categoryId ,
71
74
$ newParentCategoryCode ,
72
- $ category
75
+ $ parentInfo [ ' code ' ] ?? ''
73
76
);
74
77
$ categoryInfo = CourseCategory::getCategory ($ _POST ['code ' ]);
75
78
$ ret = $ categoryInfo ['id ' ];
@@ -90,8 +93,8 @@ function ($value) {
90
93
header ('Location: ' .api_get_path (WEB_CODE_PATH ).'admin/course_category.php ' );
91
94
exit ;
92
95
} elseif ($ action === 'moveUp ' ) {
93
- CourseCategory::moveNodeUp ($ categoryId , $ _GET ['tree_pos ' ], $ category );
94
- header ('Location: ' .api_get_self (). ' ?category= ' .Security:: remove_XSS ( $ category ) );
96
+ CourseCategory::moveNodeUp ($ categoryId , $ _GET ['tree_pos ' ], $ parentInfo [ ' code ' ] ?? '' );
97
+ header ('Location: ' .$ baseUrl );
95
98
Display::addFlash (Display::return_message (get_lang ('Updated ' )));
96
99
exit ();
97
100
}
@@ -137,15 +140,16 @@ function showCourses(button, categoryId) {
137
140
echo '<div class="actions"> ' ;
138
141
echo Display::url (
139
142
Display::return_icon ('folder_up.png ' , get_lang ('Back ' ), '' , ICON_SIZE_MEDIUM ),
140
- api_get_path ( WEB_CODE_PATH ). ' admin/course_category.php?category= ' .Security:: remove_XSS ( $ category )
143
+ $ baseUrl
141
144
);
142
145
echo '</div> ' ;
143
146
144
147
$ form_title = $ action === 'add ' ? get_lang ('AddACategory ' ) : get_lang ('EditNode ' );
145
- if (!empty ($ category )) {
146
- $ form_title .= ' ' .get_lang ('Into ' ).' ' .Security:: remove_XSS ( $ category ) ;
148
+ if (!empty ($ categoryInfo [ ' parent_id ' ] )) {
149
+ $ form_title .= ' ' .get_lang ('Into ' ).' ' .$ categoryInfo [ ' parent_id ' ] ;
147
150
}
148
- $ url = api_get_self ().'?action= ' .Security::remove_XSS ($ action ).'&category= ' .Security::remove_XSS ($ category ).'&id= ' .Security::remove_XSS ($ categoryId );
151
+ $ url = $ baseUrl .'& '
152
+ .http_build_query (['action ' => Security::remove_XSS ($ action ), 'id ' => Security::remove_XSS ($ categoryId )]);
149
153
$ form = new FormValidator ('course_category ' , 'post ' , $ url );
150
154
$ form ->addElement ('header ' , '' , $ form_title );
151
155
$ form ->addElement ('hidden ' , 'formSent ' , 1 );
@@ -230,7 +234,7 @@ function showCourses(button, categoryId) {
230
234
$ form ->setDefaults (
231
235
[
232
236
'auth_course_child ' => 'TRUE ' ,
233
- 'parent_id ' => $ category ,
237
+ 'parent_id ' => $ parentInfo [ ' code ' ] ?? '' ,
234
238
]
235
239
);
236
240
$ form ->addButtonCreate ($ text );
@@ -254,7 +258,7 @@ function showCourses(button, categoryId) {
254
258
if (empty ($ parentInfo ) || $ parentInfo ['auth_cat_child ' ] === 'TRUE ' ) {
255
259
$ newCategoryLink = Display::url (
256
260
Display::return_icon ('new_folder.png ' , get_lang ('AddACategory ' ), '' , ICON_SIZE_MEDIUM ),
257
- api_get_path ( WEB_CODE_PATH ). ' admin/course_category.php? action=add&category= ' .Security:: remove_XSS ( $ category )
261
+ $ baseUrl . ' & action=add'
258
262
);
259
263
260
264
if (!empty ($ parentInfo ) && $ parentInfo ['access_url_id ' ] != $ urlId ) {
@@ -266,7 +270,7 @@ function showCourses(button, categoryId) {
266
270
if (!empty ($ parentInfo )) {
267
271
echo Display::page_subheader ($ parentInfo ['name ' ].' ( ' .$ parentInfo ['code ' ].') ' );
268
272
}
269
- echo CourseCategory::listCategories ($ category );
273
+ echo CourseCategory::listCategories ($ parentInfo [ ' code ' ] ?? '' );
270
274
}
271
275
272
276
Display::display_footer ();
0 commit comments